| | |
| | | <template> |
| | | <div> |
| | | <div class="selectclass"> |
| | | <el-select |
| | | v-model="myValue" |
| | | :loading="isLoading" |
| | |
| | | value-key="organizationid" |
| | | allow-create |
| | | reserve-keyword |
| | | :placeholder="placeholder ? placeholder : '请输入机构名称'" |
| | | :placeholder="placeholder ? placeholder : '请选择'" |
| | | class="full-block" |
| | | ref="selecter" |
| | | > |
| | |
| | | </template> |
| | | |
| | | <script> |
| | | import { listOrganization,listReportname } from "@/api/project/organization"; |
| | | import { listOrganization, listReportname } from "@/api/project/organization"; |
| | | |
| | | export default { |
| | | name: "OrgSelecter", |
| | |
| | | props: { |
| | | //Select基础属性 |
| | | value: { |
| | | type: [String, Array], |
| | | type: [String, Array] |
| | | }, |
| | | //获取列表 |
| | | dataList: { |
| | | type: Array, |
| | | default: function() { |
| | | return []; |
| | | } |
| | | }, |
| | | disabled: { |
| | | type: Boolean, |
| | | default: false, |
| | | default: false |
| | | }, |
| | | clearable: { |
| | | type: Boolean, |
| | | default: false, |
| | | default: false |
| | | }, |
| | | filterable: { |
| | | type: Boolean, |
| | | default: true, |
| | | default: true |
| | | }, |
| | | multiple: { |
| | | type: Boolean, |
| | | default: false, |
| | | default: false |
| | | }, |
| | | multipleLimit: { |
| | | type: Number, |
| | | default: 0, |
| | | default: 0 |
| | | }, |
| | | defaultFirstOption: { |
| | | type: Boolean, |
| | | default: true, |
| | | default: true |
| | | }, |
| | | size: { |
| | | type: String, |
| | | default: "small", |
| | | default: "small" |
| | | }, |
| | | placeholder: { |
| | | type: String, |
| | | default: "", |
| | | default: "" |
| | | }, |
| | | //业务属性 |
| | | lazyLoad: { |
| | | type: Boolean, |
| | | default: false, |
| | | default: false |
| | | }, |
| | | isAll: { |
| | | type: Boolean, |
| | | default: false, |
| | | default: false |
| | | }, |
| | | //机构类型 |
| | | orgType: { |
| | | type: String, |
| | | default: "", |
| | | }, |
| | | default: "" |
| | | } |
| | | }, |
| | | data() { |
| | | return { |
| | | pageData: { pageNum:1,pageSize:100 }, |
| | | pageData: { pageNum: 1, pageSize: 100 }, |
| | | isLoading: false, |
| | | dataList: [], |
| | | // dataList: [], |
| | | tempList: [], |
| | | myValue: this.multiple ? [] : "", |
| | | focusEvents: { |
| | | func: () => {}, |
| | | loaded: false, |
| | | }, |
| | | loaded: false |
| | | } |
| | | }; |
| | | }, |
| | | mounted() { |
| | |
| | | } |
| | | }, |
| | | methods: { |
| | | |
| | | renderSelecter() { |
| | | this.pageData.PageSize = 100; |
| | | this.dataList = []; |
| | | this.myValue = this.value; |
| | | |
| | | this.getdataList(); |
| | | }, |
| | | |
| | | //获取数据 |
| | | getdataList() { |
| | | this.isLoading = true; |
| | | let searchData={ |
| | | organizationtype:this.orgType,//传入的类型 |
| | | pageNum:1, |
| | | pageSize:100000 |
| | | };//搜索条件 |
| | | let searchData = { |
| | | organizationtype: this.orgType, //传入的类型 |
| | | pageNum: 1, |
| | | pageSize: 100000 |
| | | }; //搜索条件 |
| | | |
| | | let userType={"userType":"1"}; |
| | | let userType = { userType: "1" }; |
| | | if (this.orgType == 4) { |
| | | let arr = this.$store.state.user.organization; |
| | | this.dataList.push(...arr); |
| | | if (this.isAll) { |
| | | let all = { |
| | | organizationid: "", |
| | | organizationname: "全部" |
| | | }; |
| | | this.dataList.unshift(all); |
| | | } |
| | | this.tempList = this.dataList.map(item => item); |
| | | this.focusEvents.loaded = true; |
| | | this.isLoading = false; |
| | | return; |
| | | } |
| | | |
| | | listOrganization(searchData) |
| | | .then((response) => { |
| | | .then(response => { |
| | | this.dataList.push(...response.rows); |
| | | if (this.isAll) { |
| | | let all = { |
| | | organizationid: "", |
| | | organizationname: "全部", |
| | | organizationname: "全部" |
| | | }; |
| | | this.dataList.unshift(all); |
| | | } |
| | | this.tempList = this.dataList.map(item=>item); |
| | | this.tempList = this.dataList.map(item => item); |
| | | this.focusEvents.loaded = true; |
| | | }) |
| | | .catch((error) => { |
| | | .catch(error => { |
| | | // 暂无处理 |
| | | }) |
| | | .finally(() => { |
| | |
| | | |
| | | getOptionByValue(key) { |
| | | let outValue = null; |
| | | this.dataList.forEach((e) => { |
| | | if (e.organizationid == key) { |
| | | outValue = e; |
| | | } |
| | | this.dataList.forEach(e => { |
| | | if (e.organizationid == key) { |
| | | outValue = e; |
| | | } |
| | | }); |
| | | |
| | | return outValue; |
| | |
| | | filterMethod(val) { |
| | | this.myValue = val; |
| | | if (val) { |
| | | this.dataList = this.tempList.filter((item) => { |
| | | this.dataList = this.tempList.filter(item => { |
| | | if ( |
| | | (item.PYM && |
| | | !!~item.PYM.toUpperCase().indexOf(val.toUpperCase())) || |
| | |
| | | } |
| | | }); |
| | | } else { |
| | | this.dataList = this.tempList.map(item=>item); |
| | | this.dataList = this.tempList.map(item => item); |
| | | } |
| | | }, |
| | | focus() { |
| | |
| | | defaultInit(defaultItem, defaultItemName) { |
| | | if (defaultItem && defaultItemName) { |
| | | let list = this.dataList.filter( |
| | | (r) => |
| | | r => |
| | | r.organizationid == defaultItem && |
| | | r.organizationname == defaultItemName |
| | | ); |
| | | if (list.length == 0) { |
| | | let data = { |
| | | organizationname: defaultItemName, |
| | | organizationid: defaultItem, |
| | | organizationid: defaultItem |
| | | }; |
| | | this.dataList.push(data); |
| | | } |
| | | } |
| | | this.tempList = this.dataList.map(item=>item); |
| | | }, |
| | | this.tempList = this.dataList.map(item => item); |
| | | } |
| | | }, |
| | | computed: {}, |
| | | watch: { |
| | |
| | | myValue(newVal) { |
| | | this.$emit("input", newVal); |
| | | this.$emit("change", newVal); |
| | | }, |
| | | }, |
| | | } |
| | | } |
| | | }; |
| | | </script> |
| | | |
| | | <style></style> |
| | | <style lang="scss" scoped> |
| | | ::v-deep.selectclass .el-select { |
| | | display: inline-block; |
| | | position: relative; |
| | | width: 90%; |
| | | } |
| | | </style> |