{"remainingRequest":"D:\\jenkins\\workspace\\xq-web-fvue\\node_modules\\vue-loader\\lib\\index.js??vue-loader-options!D:\\jenkins\\workspace\\xq-web-fvue\\src\\components\\control\\HtUserSelector.vue?vue&type=script&lang=js&","dependencies":[{"path":"D:\\jenkins\\workspace\\xq-web-fvue\\src\\components\\control\\HtUserSelector.vue","mtime":1667327529137},{"path":"D:\\jenkins\\workspace\\xq-web-fvue\\node_modules\\babel-loader\\lib\\index.js","mtime":315532800000},{"path":"D:\\jenkins\\workspace\\xq-web-fvue\\node_modules\\cache-loader\\dist\\cjs.js","mtime":499162500000},{"path":"D:\\jenkins\\workspace\\xq-web-fvue\\node_modules\\vue-loader\\lib\\index.js","mtime":499162500000}],"contextDependencies":[],"result":["//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n\r\nimport Vue from \"vue\";\r\nimport { mapState } from \"vuex\";\r\nimport utils from \"@/utils.js\";\r\n\r\nexport default {\r\n name: \"ht-user-selector\",\r\n props: [\r\n \"validate\",\r\n \"value\",\r\n \"name\",\r\n \"permission\",\r\n \"single\",\r\n \"selectorconfig\",\r\n\t\"tooltipplacement\"\r\n ],\r\n data() {\r\n return {\r\n tableData: \"\",\r\n orgId: \"\",\r\n userDialogVisible: false,\r\n defaultProps: {\r\n children: \"children\",\r\n label: \"name\"\r\n },\r\n selectUserProps: {\r\n label: \"fullname\"\r\n },\r\n selectUsers: null,\r\n currentDimension: null,\r\n inputSuffixHeight: 30,\r\n config: null,\r\n updating: false,\r\n currentUser: null,\r\n singleSelectId: null\r\n };\r\n },\r\n computed: mapState({\r\n pagination: state => state.user.pagination,\r\n total: state => state.user.total,\r\n dimensions: state => {\r\n return state.user.dimensions;\r\n },\r\n // 左侧组织树的数据\r\n orgs: state => {\r\n return state.user.orgs;\r\n },\r\n // 中间用户表格的数据\r\n users: state => {\r\n return state.user.users;\r\n },\r\n isSingle: function() {\r\n if (this.single === undefined || this.single === null) {\r\n if (this.selectorconfig) {\r\n return this.selectorconfig.isSingle;\r\n }\r\n return false;\r\n }\r\n if (this.single === \"\") {\r\n return true;\r\n }\r\n return !!this.single;\r\n },\r\n inputVal: function() {\r\n if (!this.value) {\r\n return null;\r\n } else if (this.bindSet) {\r\n if (!utils.getAndValidPath(this.bindSet, \"fullname\")) {\r\n throw \"ht-user-selector的bind属性中必须配置fullname属性.\";\r\n }\r\n if (this.value.constructor != String) {\r\n throw \"ht-user-selector中有bind属性时,fullname必须是字符串.\";\r\n }\r\n let subIndex = null;\r\n if (this.$el) {\r\n subIndex = utils.getSomeAttributeFromParentElement(\r\n this.$el,\r\n \"data-index\"\r\n );\r\n }\r\n let nameAry = this.value.split(\",\");\r\n let idAry = null;\r\n let accountAry = null;\r\n let emailAry = [];\r\n let mobileAry = [];\r\n const idPath = utils.getAndValidPath(this.bindSet, \"id\");\r\n if (idPath) {\r\n let idVal = utils.getValueByPath(this.$parent, idPath, subIndex);\r\n if (!idVal || idVal.constructor != String) {\r\n throw \"ht-user-selector中有bind属性中id的值必须是非空的字符串.\";\r\n }\r\n idAry = idVal.split(\",\");\r\n }\r\n const accountPath = utils.getAndValidPath(this.bindSet, \"account\");\r\n if (accountPath) {\r\n let accountVal = utils.getValueByPath(\r\n this.$parent,\r\n accountPath,\r\n subIndex\r\n );\r\n if (!accountVal || accountVal.constructor != String) {\r\n throw \"ht-user-selector中有bind属性中account的值必须是非空的字符串.\";\r\n }\r\n accountAry = accountVal.split(\",\");\r\n }\r\n\r\n const emailPath = utils.getAndValidPath(this.bindSet, \"email\");\r\n if (emailPath) {\r\n let emailVal = utils.getValueByPath(\r\n this.$parent,\r\n emailPath,\r\n subIndex\r\n );\r\n if (emailVal && emailVal.constructor == String) {\r\n emailAry = emailVal.split(\",\");\r\n }\r\n }\r\n\r\n const mobilePath = utils.getAndValidPath(this.bindSet, \"mobile\");\r\n if (mobilePath) {\r\n let mobileVal = utils.getValueByPath(\r\n this.$parent,\r\n mobilePath,\r\n subIndex\r\n );\r\n if (mobileVal && mobileVal.constructor == String) {\r\n mobileAry = mobileVal.split(\",\");\r\n }\r\n\r\n }\r\n\r\n let result = [];\r\n nameAry.forEach((m, i) => {\r\n let n = { fullname: m };\r\n if (idAry) {\r\n n[\"id\"] = idAry[i];\r\n }\r\n if (accountAry) {\r\n n[\"account\"] = accountAry[i];\r\n }\r\n if (emailAry) {\r\n n[\"email\"] = emailAry[i];\r\n }\r\n\r\n if (mobileAry) {\r\n n[\"mobile\"] = mobileAry[i];\r\n }\r\n result.push(n);\r\n });\r\n return result;\r\n } else if (this.value.constructor == Array) {\r\n return this.value;\r\n } else {\r\n return null;\r\n }\r\n },\r\n inputWriteable: function() {\r\n return utils.getWriteable(this.permission);\r\n },\r\n inputValidate: function() {\r\n var validateObj = this.$store.state.index.validate;\r\n return utils.addRequiredOrNot(\r\n this.permission,\r\n this.validate,\r\n validateObj,\r\n this\r\n );\r\n },\r\n inputName: function() {\r\n let labeldesc = \"\";\r\n if(this.$slots && this.$slots.labeldesc && this.$slots.labeldesc[0].children && this.$slots.labeldesc[0].children[0].text){\r\n labeldesc = this.$slots.labeldesc[0].children[0].text;\r\n return this.name ? this.name : utils.getName()+ \"-\" +labeldesc;\r\n }else{\r\n return this.name ? this.name : utils.getName();\r\n }\r\n },\r\n // 是否显示当前用户\r\n selectCurrent: function() {\r\n return this.selectorconfig ? this.selectorconfig.selectCurrent : false;\r\n },\r\n // 是否有回填设置\r\n bindSet: function() {\r\n return this.selectorconfig ? this.selectorconfig.bind : null;\r\n }\r\n }),\r\n mounted() {\r\n // 没有值而且需要显示当前用户\r\n if (!this.inputVal && this.selectCurrent) {\r\n if (this.$store.state.user.currentUserDetail == null) {\r\n this.$store\r\n .dispatch(\"user/loadCurrentUserDetail\")\r\n .then(currentUserDetail => {\r\n this.currentUser = currentUserDetail.user;\r\n this.selectUsers = [currentUserDetail.user];\r\n this.syncInputValue();\r\n this.calacInputSuffixHeight();\r\n });\r\n } else {\r\n this.currentUser = this.$store.state.user.currentUserDetail.user;\r\n this.selectUsers = [this.currentUser];\r\n this.syncInputValue();\r\n this.calacInputSuffixHeight();\r\n }\r\n }\r\n },\r\n created() {\r\n this.$validator = this.$root.$validator;\r\n let pageBean = {\r\n pageBean: { page: \"1\", pageSize: \"10\", showTotal: \"true\" }\r\n };\r\n //初次加载默认pageBean\r\n this.$store.dispatch(\"user/loadDimension\");\r\n this.$store.dispatch(\"user/loadUsersByOrgId\", pageBean);\r\n },\r\n watch: {\r\n userDialogVisible: function(newVal) {\r\n if (newVal) {\r\n if (this.inputVal && this.inputVal.constructor == Array) {\r\n this.selectUsers = [...this.inputVal];\r\n } else {\r\n this.selectUsers = [];\r\n }\r\n this.syncCheckedStatus();\r\n }\r\n }\r\n },\r\n methods: {\r\n loadOrgTree(node, resolve) {\r\n if (node && node.data && node.data.isParent) {\r\n if (node.data.children) {\r\n resolve(node.data.children);\r\n } else {\r\n this.$store\r\n .dispatch(\"user/loadOrgsByParentId\", node.data.id)\r\n .then(rep => {\r\n resolve(rep);\r\n });\r\n }\r\n } else {\r\n resolve([]);\r\n }\r\n },\r\n //点击组织查询用户\r\n handleNodeClick(data, node, vuecomponent) {\r\n if (data.id) {\r\n this.orgId = data.id;\r\n }\r\n let pageBean = {\r\n pageBean: { page: \"1\", pageSize: \"10\", showTotal: \"true\" }\r\n };\r\n let querys = [\r\n {\r\n property: \"org_id_\",\r\n value: this.orgId,\r\n group: \"main\",\r\n operation: \"EQUAL\",\r\n relation: \"AND\"\r\n }\r\n ];\r\n let queryFilter = { pageBean, querys };\r\n this.$store.dispatch(\"user/loadUsersByOrgId\", queryFilter);\r\n },\r\n handleSizeChange: function(size) {\r\n //每页下拉显示数据\r\n this.$store.dispatch(\"user/setPaginationSize\", size);\r\n this.search();\r\n },\r\n handleCurrentChange: function(currentPage) {\r\n //点击第几页\r\n this.$store.dispatch(\"user/setPaginationPageNum\", currentPage);\r\n this.search();\r\n },\r\n //回车查询\r\n searchEnterFun: function(e) {\r\n var keyCode = window.event ? e.keyCode : e.which;\r\n if (keyCode == 13) {\r\n this.search(\"find\");\r\n }\r\n },\r\n // 查询\r\n search(str) {\r\n if (str == \"find\") {\r\n this.$store.dispatch(\"user/setPaginationPageNum\", 1);\r\n }\r\n let querys = []; //查询条件\r\n let queryFilter = {};\r\n let pageBean = { pageBean: this.pagination };\r\n if (this.tableData == \"\" && this.orgId == \"\") {\r\n this.$store.dispatch(\"user/loadUsersByOrgId\", pageBean).then(() => {\r\n this.syncCheckedStatus();\r\n });\r\n } else {\r\n if (this.orgId && this.tableData == \"\") {\r\n querys.push({\r\n property: \"org_id_\",\r\n value: this.orgId,\r\n group: \"main1\",\r\n operation: \"EQUAL\",\r\n relation: \"AND\"\r\n });\r\n } else if (this.orgId && this.tableData != \"\") {\r\n querys = [\r\n {\r\n property: \"org_id_\",\r\n value: this.orgId,\r\n group: \"main1\",\r\n operation: \"EQUAL\",\r\n relation: \"AND\"\r\n },\r\n {\r\n property: \"fullname\",\r\n value: this.tableData,\r\n group: \"main\",\r\n operation: \"LIKE\",\r\n relation: \"OR\"\r\n },\r\n {\r\n property: \"account\",\r\n value: this.tableData,\r\n group: \"main\",\r\n operation: \"LIKE\",\r\n relation: \"OR\"\r\n },\r\n {\r\n property: \"email\",\r\n value: this.tableData,\r\n group: \"main\",\r\n operation: \"LIKE\",\r\n relation: \"OR\"\r\n },\r\n {\r\n property: \"mobile\",\r\n value: this.tableData,\r\n group: \"main\",\r\n operation: \"LIKE\",\r\n relation: \"OR\"\r\n }\r\n ];\r\n } else {\r\n querys = [\r\n {\r\n property: \"fullname\",\r\n value: this.tableData,\r\n group: \"main\",\r\n operation: \"LIKE\",\r\n relation: \"OR\"\r\n },\r\n {\r\n property: \"account\",\r\n value: this.tableData,\r\n group: \"main\",\r\n operation: \"LIKE\",\r\n relation: \"OR\"\r\n },\r\n {\r\n property: \"email\",\r\n value: this.tableData,\r\n group: \"main\",\r\n operation: \"LIKE\",\r\n relation: \"OR\"\r\n },\r\n {\r\n property: \"mobile\",\r\n value: this.tableData,\r\n group: \"main\",\r\n operation: \"LIKE\",\r\n relation: \"OR\"\r\n }\r\n ];\r\n }\r\n queryFilter = { pageBean: this.pagination, querys };\r\n this.$store.dispatch(\"user/loadUsersByOrgId\", queryFilter).then(() => {\r\n this.syncCheckedStatus();\r\n });\r\n }\r\n },\r\n //重置\r\n reset() {\r\n this.tableData = \"\";\r\n this.orgId=\"\";\r\n if(this.$refs.tree){\r\n this.$refs.tree.setCurrentKey(null);\r\n }\r\n this.search(\"find\");\r\n },\r\n showDialog() {\r\n this.reset();\r\n this.userDialogVisible = true;\r\n },\r\n //通过维度获取组织\r\n changeDimension(val) {\r\n this.$store.dispatch(\"user/loadOrgsByDimension\", val);\r\n },\r\n radioChangeHandler(index) {\r\n this.selectUsers = [this.users[index]];\r\n },\r\n userSelectionChange() {\r\n !this.updating && this.syncSelection2selectUsers();\r\n },\r\n userRowClick(row, column, event) {\r\n // 单选\r\n if (this.isSingle) {\r\n this.selectUsers = [row];\r\n this.singleSelectId = row.id;\r\n }\r\n // 多选\r\n else {\r\n const arg = this.getUniqueArg();\r\n let _tag = true;\r\n this.$refs.userTable &&\r\n this.$refs.userTable.selection &&\r\n this.$refs.userTable.selection.forEach(m => {\r\n if (m === row) {\r\n // 对于已选中该行时,取消选中状态\r\n this.$refs.userTable.toggleRowSelection(row, false);\r\n _tag = false;\r\n }\r\n });\r\n // 对于未选中该行时,切换为选中状态\r\n this.$refs.userTable &&\r\n _tag &&\r\n this.$refs.userTable.toggleRowSelection(row);\r\n this.syncSelection2selectUsers();\r\n }\r\n },\r\n // 获取当前用作唯一键的参数\r\n getUniqueArg() {\r\n let arg = \"fullname\";\r\n if (utils.getAndValidPath(this.bindSet, \"id\")) {\r\n arg = \"id\";\r\n } else if (utils.getAndValidPath(this.bindSet, \"account\")) {\r\n arg = \"account\";\r\n }\r\n return arg;\r\n },\r\n dialogConfirm() {\r\n this.userDialogVisible = false;\r\n this.syncInputValue();\r\n },\r\n // 同步userTable中已选行到已选数据中去\r\n syncSelection2selectUsers() {\r\n let arg = this.getUniqueArg();\r\n // 当前分页的orgTable行中已被选择的数据\r\n let curPageAry = this.selectUsers.filter(m =>\r\n this.users.some(n => m[arg] === n[arg])\r\n );\r\n curPageAry.forEach(item => {\r\n this.selectUsers.remove(item);\r\n });\r\n this.selectUsers = [\r\n ...this.selectUsers,\r\n ...this.$refs.userTable.selection\r\n ];\r\n },\r\n // 同步已选数据在orgTable中的checkbox和radio的选中状态\r\n syncCheckedStatus() {\r\n let arg = this.getUniqueArg();\r\n const _me = this;\r\n setTimeout(() => {\r\n _me.updating = true;\r\n _me.singleSelectId = null;\r\n _me.$refs.userTable && _me.$refs.userTable.clearSelection();\r\n _me.users &&\r\n _me.users.forEach(m => {\r\n if (\r\n _me.selectUsers &&\r\n _me.selectUsers.some(n => n[arg] === m[arg])\r\n ) {\r\n _me.singleSelectId = m.id;\r\n if (!_me.isSingle && _me.$refs.userTable) {\r\n _me.$refs.userTable.toggleRowSelection(m);\r\n }\r\n } else {\r\n if (!_me.isSingle && _me.$refs.userTable) {\r\n _me.$refs.userTable.toggleRowSelection(m, false);\r\n }\r\n }\r\n });\r\n _me.updating = false;\r\n }, 200);\r\n },\r\n // 同步选择结果到表单上(会自动修正表单上输入框的高度)\r\n syncInputValue(item) {\r\n if (item) {\r\n if (this.inputVal && this.inputVal.constructor == Array) {\r\n this.selectUsers = [...this.inputVal];\r\n }\r\n // 在表单上点击X删除已选数据\r\n this.selectUsers.remove(item);\r\n }\r\n let subIndex = null;\r\n if (this.$el) {\r\n subIndex = utils.getSomeAttributeFromParentElement(\r\n this.$el,\r\n \"data-index\"\r\n );\r\n }\r\n this.updating = true;\r\n if (this.bindSet) {\r\n if (!utils.getAndValidPath(this.bindSet, \"fullname\")) {\r\n throw \"ht-user-selector的bind属性中必须配置fullname属性.\";\r\n }\r\n let nameAry = [];\r\n let idAry = [];\r\n let accountAry = [];\r\n let mobileArr = [];\r\n let emailArr = [];\r\n this.selectUsers &&\r\n this.selectUsers.forEach(m => {\r\n nameAry.push(m.fullname);\r\n idAry.push(m.id);\r\n accountAry.push(m.account);\r\n mobileArr.push(m.mobile);\r\n emailArr.push(m.email);\r\n });\r\n const idPath = utils.getAndValidPath(this.bindSet, \"id\");\r\n idPath &&\r\n utils.setValueByPath(this.$parent, idPath, idAry.join(\",\"), subIndex);\r\n const accountPath = utils.getAndValidPath(this.bindSet, \"account\");\r\n accountPath &&\r\n utils.setValueByPath(\r\n this.$parent,\r\n accountPath,\r\n accountAry.join(\",\"),\r\n subIndex\r\n );\r\n\r\n const mobilePath = utils.getAndValidPath(this.bindSet, \"mobile\");\r\n mobilePath &&\r\n utils.setValueByPath(\r\n this.$parent,\r\n mobilePath,\r\n mobileArr.join(\",\"),\r\n subIndex\r\n );\r\n\r\n const emailPath = utils.getAndValidPath(this.bindSet, \"email\");\r\n emailPath &&\r\n utils.setValueByPath(\r\n this.$parent,\r\n emailPath,\r\n emailArr.join(\",\"),\r\n subIndex\r\n );\r\n this.$emit(\"input\", nameAry.join(\",\"));\r\n } else {\r\n this.$emit(\"input\", this.selectUsers);\r\n }\r\n this.updating = false;\r\n this.calacInputSuffixHeight();\r\n },\r\n dialogCancel() {\r\n this.userDialogVisible = false;\r\n },\r\n clearAllSelectUsers() {\r\n this.selectUsers = [];\r\n this.syncCheckedStatus();\r\n this.singleSelectId = null;\r\n },\r\n // 调整已选列表中元素的顺序\r\n moveSelectUser(direct) {\r\n let ary = this.$refs.selectTree.getCheckedNodes();\r\n if (direct == \"up\") {\r\n ary.forEach(m => {\r\n let index = this.selectUsers.indexOf(m, 1);\r\n if (index > 0) {\r\n let newAry = [...this.selectUsers];\r\n newAry[index - 1] = this.selectUsers[index];\r\n newAry[index] = this.selectUsers[index - 1];\r\n this.selectUsers = newAry;\r\n }\r\n });\r\n } else if (direct == \"down\") {\r\n for (var i = ary.length - 1, m; (m = ary[i--]); ) {\r\n let index = this.selectUsers.indexOf(m, 0);\r\n if (index > -1 && index < this.selectUsers.length - 1) {\r\n let newAry = [...this.selectUsers];\r\n newAry[index + 1] = this.selectUsers[index];\r\n newAry[index] = this.selectUsers[index + 1];\r\n this.selectUsers = newAry;\r\n }\r\n }\r\n }\r\n setTimeout(() => {\r\n this.$refs.selectTree.setCheckedNodes(ary);\r\n });\r\n },\r\n // 在弹框中的已选数据中删除勾选的项\r\n removeSelectUsers() {\r\n let ary = this.$refs.selectTree.getCheckedNodes();\r\n ary.forEach(item => {\r\n this.selectUsers.remove(item);\r\n });\r\n this.syncCheckedStatus();\r\n },\r\n // 在表单的输入框中点击X删除一条已选数据\r\n removeSelectUser(item) {\r\n this.syncInputValue(item);\r\n },\r\n calacInputSuffixHeight() {\r\n setTimeout(() => {\r\n if(!this.$refs.tagSpans) return;\r\n if (this.$refs.tagSpans.offsetHeight) {\r\n this.inputSuffixHeight = this.$refs.tagSpans.offsetHeight + 5;\r\n } else {\r\n this.inputSuffixHeight = 30;\r\n }\r\n // 触发验证\r\n this.$validator.validate();\r\n }, 0);\r\n }\r\n }\r\n};\r\n",null]}