¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <div class="components-input-demo-presuffix"> |
| | | <!----> |
| | | <a-input @click="openModal" placeholder="请ç¹å»éæ©ç»´ä¿®é¨é¨" v-model="textVals" readOnly :disabled="disabled"> |
| | | <a-icon slot="prefix" type="cluster" title="ç»´ä¿®é¨é¨éæ©æ§ä»¶"/> |
| | | <a-icon v-if="storeVals" slot="suffix" type="close-circle" @click="handleEmpty" title="æ¸
空"/> |
| | | </a-input> |
| | | <j-select-repair-depart-modal |
| | | ref="innerRepairDepartSelectModal" |
| | | :modal-width="modalWidth" |
| | | :multi="multi" |
| | | :rootOpened="rootOpened" |
| | | :repairDepartId="value" |
| | | :store="storeField" |
| | | :text="textField" |
| | | :treeRepairDepartOpera="treeRepairDepartOpera" |
| | | @ok="handleOK" |
| | | @initComp="initComp"> |
| | | |
| | | </j-select-repair-depart-modal> |
| | | </div> |
| | | </template> |
| | | |
| | | <script> |
| | | import JSelectRepairDepartModal from './modal/JSelectRepairDepartModal' |
| | | import { underLinetoHump } from '@/components/_util/StringUtil' |
| | | export default { |
| | | name: 'JSelectRepairDepart', |
| | | components:{ |
| | | JSelectRepairDepartModal |
| | | }, |
| | | props:{ |
| | | modalWidth:{ |
| | | type:Number, |
| | | default:500, |
| | | required:false |
| | | }, |
| | | multi:{ |
| | | type:Boolean, |
| | | default:false, |
| | | required:false |
| | | }, |
| | | rootOpened:{ |
| | | type:Boolean, |
| | | default:true, |
| | | required:false |
| | | }, |
| | | value:{ |
| | | type:String, |
| | | required:false |
| | | }, |
| | | disabled:{ |
| | | type: Boolean, |
| | | required: false, |
| | | default: false |
| | | }, |
| | | // èªå®ä¹è¿ååæ®µï¼é»è®¤è¿å id |
| | | customReturnField: { |
| | | type: String, |
| | | default: '' |
| | | }, |
| | | backRepairDepart: { |
| | | type: Boolean, |
| | | default: false, |
| | | required: false |
| | | }, |
| | | // åå¨å段 [key field] |
| | | store: { |
| | | type: String, |
| | | default: 'id', |
| | | required: false |
| | | }, |
| | | // æ¾ç¤ºå段 [label field] |
| | | text: { |
| | | type: String, |
| | | default: 'departName', |
| | | required: false |
| | | }, |
| | | treeRepairDepartOpera: { |
| | | type: Boolean, |
| | | default: false, |
| | | required: false |
| | | } |
| | | |
| | | }, |
| | | data(){ |
| | | return { |
| | | visible:false, |
| | | confirmLoading:false, |
| | | storeVals: '', //[key values] |
| | | textVals: '' //[label values] |
| | | } |
| | | }, |
| | | computed:{ |
| | | storeField(){ |
| | | let field = this.customReturnField |
| | | if(!field){ |
| | | field = this.store; |
| | | } |
| | | return underLinetoHump(field) |
| | | }, |
| | | textField(){ |
| | | return underLinetoHump(this.text) |
| | | } |
| | | }, |
| | | mounted(){ |
| | | this.storeVals = this.value |
| | | }, |
| | | watch:{ |
| | | value(val){ |
| | | this.storeVals = val |
| | | } |
| | | }, |
| | | methods:{ |
| | | initComp(textVals){ |
| | | this.textVals = textVals |
| | | }, |
| | | //è¿åéä¸ç车é´ä¿¡æ¯ |
| | | backRepairDepartInfo(){ |
| | | if(this.backRepairDepart===true){ |
| | | //LOWCOD-2147 ãç¨æ·ç®¡çãéæ©é¨é¨åä¸çº§ä»¥åï¼è´è´£é¨é¨æ²¡ææ°æ®å¯é (é¶çæ¹é èªå®ä¹è¿ååæ®µå¯¼è´) |
| | | if(this.storeVals && this.storeVals.length>0){ |
| | | let arr1 = this.storeVals.split(',') |
| | | let arr2 = this.textVals.split(',') |
| | | let info = [] |
| | | for(let i=0;i<arr1.length;i++){ |
| | | info.push({ |
| | | value: arr1[i], |
| | | text: arr2[i] |
| | | }) |
| | | } |
| | | this.$emit('back', info) |
| | | } |
| | | } |
| | | }, |
| | | openModal(){ |
| | | this.$refs.innerRepairDepartSelectModal.show() |
| | | }, |
| | | handleOK(rows) { |
| | | if (!rows && rows.length <= 0) { |
| | | this.textVals = '' |
| | | this.storeVals = '' |
| | | } else { |
| | | let arr1 = [] |
| | | let arr2 = [] |
| | | for(let dep of rows){ |
| | | arr1.push(dep[this.storeField]) |
| | | arr2.push(dep[this.textField]) |
| | | } |
| | | this.storeVals = arr1.join(',') |
| | | this.textVals = arr2.join(',') |
| | | } |
| | | this.$emit("change", this.storeVals) |
| | | this.backRepairDepartInfo() |
| | | }, |
| | | getRepairDepartNames(){ |
| | | return this.departNames |
| | | }, |
| | | handleEmpty(){ |
| | | this.handleOK('') |
| | | } |
| | | }, |
| | | model: { |
| | | prop: 'value', |
| | | event: 'change' |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style scoped> |
| | | .components-input-demo-presuffix .anticon-close-circle { |
| | | cursor: pointer; |
| | | color: #ccc; |
| | | transition: color 0.3s; |
| | | font-size: 12px; |
| | | } |
| | | .components-input-demo-presuffix .anticon-close-circle:hover { |
| | | color: #f5222d; |
| | | } |
| | | .components-input-demo-presuffix .anticon-close-circle:active { |
| | | color: #666; |
| | | } |
| | | </style> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <j-modal |
| | | title="éæ©ç»´ä¿®é¨é¨" |
| | | :width="modalWidth" |
| | | :visible="visible" |
| | | :confirmLoading="confirmLoading" |
| | | @ok="handleSubmit" |
| | | @cancel="handleCancel" |
| | | @update:fullscreen="isFullscreen" |
| | | wrapClassName="j-repair-depart-select-modal" |
| | | switchFullscreen |
| | | cancelText="å
³é"> |
| | | <a-spin tip="Loading..." :spinning="false"> |
| | | <a-input-search style="margin-bottom: 1px" placeholder="请è¾å
¥ç»´ä¿®é¨é¨åç§°æå车è¿è¡æç´¢" @search="onSearch" /> |
| | | <a-tree |
| | | checkable |
| | | :class="treeScreenClass" |
| | | :treeData="treeData" |
| | | :checkStrictly="checkStrictly" |
| | | @check="onCheck" |
| | | @select="onSelect" |
| | | @expand="onExpand" |
| | | :autoExpandParent="autoExpandParent" |
| | | :expandedKeys="expandedKeys" |
| | | :checkedKeys="checkedKeys"> |
| | | |
| | | <template slot="title" slot-scope="{title}"> |
| | | <span v-if="title.indexOf(searchValue) > -1"> |
| | | {{title.substr(0, title.indexOf(searchValue))}} |
| | | <span style="color: #f50">{{searchValue}}</span> |
| | | {{title.substr(title.indexOf(searchValue) + searchValue.length)}} |
| | | </span> |
| | | <span v-else>{{title}}</span> |
| | | </template> |
| | | </a-tree> |
| | | </a-spin> |
| | | </j-modal> |
| | | </template> |
| | | |
| | | <script> |
| | | import { queryRepairDepartTreeList } from '@/api/api' |
| | | export default { |
| | | name: 'JSelectRepairDepartModal', |
| | | props:['modalWidth','multi','rootOpened','repairDepartId', 'store', 'text','treeOpera'], |
| | | data(){ |
| | | return { |
| | | visible:false, |
| | | confirmLoading:false, |
| | | treeData:[], |
| | | autoExpandParent:true, |
| | | expandedKeys:[], |
| | | dataList:[], |
| | | checkedKeys:[], |
| | | checkedRows:[], |
| | | searchValue:"", |
| | | checkStrictly: false, |
| | | fullscreen:false |
| | | } |
| | | }, |
| | | created(){ |
| | | this.loadRepairDepart(); |
| | | }, |
| | | watch:{ |
| | | repairDepartId(){ |
| | | this.initDepartComponent() |
| | | }, |
| | | visible: { |
| | | handler() { |
| | | this.initRepairDepartComponent(true) |
| | | } |
| | | } |
| | | }, |
| | | computed:{ |
| | | treeScreenClass() { |
| | | return { |
| | | 'my-dept-select-tree': true, |
| | | 'fullscreen': this.fullscreen, |
| | | } |
| | | }, |
| | | }, |
| | | methods:{ |
| | | show(){ |
| | | this.visible=true |
| | | this.checkedRows=[] |
| | | this.checkedKeys=[] |
| | | }, |
| | | loadRepairDepart(){ |
| | | // è¿ä¸ªæ¹æ³æ¯æ¾å°ææçé¨é¨ä¿¡æ¯ |
| | | queryRepairDepartTreeList().then(res=>{ |
| | | if(res.success){ |
| | | let arr = [...res.result] |
| | | this.reWriterWithSlot(arr) |
| | | this.treeData = arr |
| | | this.initRepairDepartComponent() |
| | | if(this.rootOpened){ |
| | | this.initExpandedKeys(res.result) |
| | | } |
| | | } |
| | | }) |
| | | }, |
| | | initRepairDepartComponent(flag){ |
| | | let arr = [] |
| | | //è¯¥æ¹æ³ä¸¤ä¸ªå°æ¹ç¨ 1.visibleæ¹åäºä»¶éæ°è®¾ç½®éä¸é¡¹ 2.ç»ä»¶ç¼è¾é¡µé¢åæ¾ |
| | | let fieldName = flag==true?'key':this.text |
| | | if(this.repairDepartId){ |
| | | let arr2 = this.repairDepartId.split(',') |
| | | for(let item of this.dataList){ |
| | | if(arr2.indexOf(item[this.store])>=0){ |
| | | arr.push(item[fieldName]) |
| | | } |
| | | } |
| | | } |
| | | if(flag==true){ |
| | | this.checkedKeys = [...arr] |
| | | }else{ |
| | | this.$emit("initComp", arr.join(',')) |
| | | } |
| | | }, |
| | | reWriterWithSlot(arr){ |
| | | for(let item of arr){ |
| | | if(item.children && item.children.length>0){ |
| | | this.reWriterWithSlot(item.children) |
| | | let temp = Object.assign({},item) |
| | | temp.children = {} |
| | | this.dataList.push(temp) |
| | | }else{ |
| | | this.dataList.push(item) |
| | | item.scopedSlots={ title: 'title' } |
| | | } |
| | | } |
| | | }, |
| | | initExpandedKeys(arr){ |
| | | if(arr && arr.length>0){ |
| | | let keys = [] |
| | | for(let item of arr){ |
| | | if(item.children && item.children.length>0){ |
| | | keys.push(item.id) |
| | | } |
| | | } |
| | | this.expandedKeys=[...keys] |
| | | //å
¨é¨keys |
| | | //this.allTreeKeys = [...keys] |
| | | }else{ |
| | | this.expandedKeys=[] |
| | | //this.allTreeKeys = [] |
| | | } |
| | | }, |
| | | onCheck (checkedKeys,info) { |
| | | if(!this.multi){ |
| | | let arr = checkedKeys.checked.filter(item => this.checkedKeys.indexOf(item) < 0) |
| | | this.checkedKeys = [...arr] |
| | | this.checkedRows = (this.checkedKeys.length === 0) ? [] : [info.node.dataRef] |
| | | }else{ |
| | | if(this.checkStrictly){ |
| | | this.checkedKeys = checkedKeys.checked |
| | | }else{ |
| | | this.checkedKeys = checkedKeys |
| | | } |
| | | this.checkedRows = this.getCheckedRows(this.checkedKeys) |
| | | } |
| | | }, |
| | | onSelect(selectedKeys,info) { |
| | | //åæ¶å
³èçæ
åµä¸æèµ°onSelectçé»è¾ |
| | | if(this.checkStrictly){ |
| | | let keys = [] |
| | | keys.push(selectedKeys[0]) |
| | | if(!this.checkedKeys || this.checkedKeys.length===0 || !this.multi){ |
| | | this.checkedKeys = [...keys] |
| | | this.checkedRows=[info.node.dataRef] |
| | | }else{ |
| | | let currKey = info.node.dataRef.key |
| | | if(this.checkedKeys.indexOf(currKey)>=0){ |
| | | this.checkedKeys = this.checkedKeys.filter(item=> item !==currKey) |
| | | }else{ |
| | | this.checkedKeys.push(...keys) |
| | | } |
| | | } |
| | | this.checkedRows = this.getCheckedRows(this.checkedKeys) |
| | | } |
| | | }, |
| | | onExpand (expandedKeys) { |
| | | this.expandedKeys = expandedKeys |
| | | this.autoExpandParent = false |
| | | }, |
| | | handleSubmit(){ |
| | | if(!this.checkedKeys || this.checkedKeys.length==0){ |
| | | this.$emit("ok",'') |
| | | }else{ |
| | | let checkRow = this.getCheckedRows(this.checkedKeys) |
| | | let keyStr = this.checkedKeys.join(",") |
| | | this.$emit("ok", checkRow, keyStr) |
| | | } |
| | | this.handleClear() |
| | | }, |
| | | handleCancel(){ |
| | | this.handleClear() |
| | | }, |
| | | handleClear(){ |
| | | this.visible=false |
| | | this.checkedKeys=[] |
| | | }, |
| | | getParentKey(currKey,treeData){ |
| | | let parentKey |
| | | for (let i = 0; i < treeData.length; i++) { |
| | | const node = treeData[i] |
| | | if (node.children) { |
| | | if (node.children.some(item => item.key === currKey)) { |
| | | parentKey = node.key |
| | | } else if (this.getParentKey(currKey, node.children)) { |
| | | parentKey = this.getParentKey(currKey, node.children) |
| | | } |
| | | } |
| | | } |
| | | return parentKey |
| | | }, |
| | | onSearch(value){ |
| | | const expandedKeys = this.dataList.map((item) => { |
| | | if (item.title.indexOf(value) > -1) { |
| | | return this.getParentKey(item.key,this.treeData) |
| | | } |
| | | return null |
| | | }).filter((item, i, self) => item && self.indexOf(item) === i) |
| | | |
| | | Object.assign(this, { |
| | | expandedKeys, |
| | | searchValue: value, |
| | | autoExpandParent: true, |
| | | }) |
| | | |
| | | |
| | | }, |
| | | // æ ¹æ® checkedKeys è·å rows |
| | | getCheckedRows(checkedKeys) { |
| | | const forChildren = (list, key) => { |
| | | for (let item of list) { |
| | | if (item.id === key) { |
| | | return item |
| | | } |
| | | if (item.children instanceof Array) { |
| | | let value = forChildren(item.children, key) |
| | | if (value != null) { |
| | | return value |
| | | } |
| | | } |
| | | } |
| | | return null |
| | | } |
| | | |
| | | let rows = [] |
| | | for (let key of checkedKeys) { |
| | | let row = forChildren(this.treeData, key) |
| | | if (row != null) { |
| | | rows.push(row) |
| | | } |
| | | } |
| | | return rows |
| | | }, |
| | | switchCheckStrictly (v) { |
| | | if(v==1){ |
| | | this.checkStrictly = false |
| | | }else if(v==2){ |
| | | this.checkStrictly = true |
| | | } |
| | | }, |
| | | isFullscreen(val){ |
| | | this.fullscreen=val |
| | | } |
| | | } |
| | | } |
| | | |
| | | </script> |
| | | |
| | | <style lang="less" scoped> |
| | | // éå¶é¨é¨éæ©æ é«åº¦ï¼é¿å
é¨é¨å¤ªå¤æ¶ç¹å»ç¡®å®ä¸ä¾¿ |
| | | .my-dept-select-tree{ |
| | | height:350px; |
| | | |
| | | &.fullscreen{ |
| | | height: calc(100vh - 250px); |
| | | } |
| | | overflow-y: scroll; |
| | | } |
| | | .drawer-bootom-button { |
| | | position: absolute; |
| | | bottom: 0; |
| | | width: 100%; |
| | | border-top: 1px solid #e8e8e8; |
| | | padding: 10px 16px; |
| | | text-align: right; |
| | | left: 0; |
| | | background: #fff; |
| | | border-radius: 0 0 2px 2px; |
| | | } |
| | | </style> |
| | |
| | | ellipsis: true, |
| | | }, |
| | | { |
| | | title: 'ç»´ä¿®é¨é¨', |
| | | align: "center", |
| | | width: 240, |
| | | dataIndex: 'repairDepartName', |
| | | ellipsis: true, |
| | | }, |
| | | { |
| | | title: 'ç¶æ', |
| | | align: "center", |
| | | width: 80, |
| | |
| | | /> |
| | | </a-form-model-item> |
| | | |
| | | <a-form-model-item |
| | | label="ç»´ä¿®é¨é¨/çç»åé
" |
| | | :labelCol="labelCol" |
| | | :wrapperCol="wrapperCol" |
| | | v-show="!repairDepartDisabled" |
| | | > |
| | | <j-select-repair-depart |
| | | v-model="model.selectedRepairDeparts" |
| | | :multi="true" |
| | | @back="backRepairDepartInfo" |
| | | :backRepairDepart="true" |
| | | :treeRepairDepartOpera="true" |
| | | ></j-select-repair-depart> |
| | | </a-form-model-item> |
| | | |
| | | <a-form-model-item |
| | | label="è´è´£é¨é¨" |
| | |
| | | import { disabledAuthFilter } from '@/utils/authFilter' |
| | | import { duplicateCheck } from '@/api/api' |
| | | import JSelectProduction from '../../../components/jeecgbiz/JSelectProduction' |
| | | import JSelectRepairDepart from '../../../components/jeecgbiz/JSelectRepairDepart' |
| | | import { mapActions } from 'vuex' |
| | | import { ajaxGetDictItems, getDictItemsFromCache } from '@/api/api' |
| | | import SelectDeviceModal from './SelectDeviceModal' |
| | |
| | | name: 'UserModal', |
| | | components: { |
| | | SelectDeviceModal, |
| | | JSelectProduction |
| | | JSelectProduction, |
| | | JSelectRepairDepart |
| | | }, |
| | | data() { |
| | | return { |
| | | departDisabled: false, //æ¯å¦æ¯æçé¨é¨è°ç¨è¯¥é¡µé¢ |
| | | productionDisabled: false, //æ¯å¦æ¯æç车é´è°ç¨è¯¥é¡µé¢ |
| | | roleDisabled: false, //æ¯å¦æ¯è§è²ç»´æ¤è°ç¨è¯¥é¡µé¢ |
| | | repairDepartDisabled: false, //æ¯å¦æ¯æçç»´ä¿®é¨é¨çç»è°ç¨è¯¥é¡µé¢ |
| | | modalWidth: 800, |
| | | drawerWidth: 700, |
| | | modaltoggleFlag: true, |
| | |
| | | userProductionList: '/sys/user/userProductionList', |
| | | userId: '/sys/user/generateUserId', // å¼å
¥çææ·»å ç¨æ·æ
åµä¸çurl |
| | | syncUserByUserName: '/act/process/extActProcess/doSyncUserByUserName',//åæ¥ç¨æ·å°å·¥ä½æµ |
| | | queryTenantList: '/sys/tenant/queryList' |
| | | queryTenantList: '/sys/tenant/queryList', |
| | | userRepairDepartList: '/sys/user/userRepairDepartList', |
| | | repairDepartTreeList: '/eam/eamBaseRepairDepart/queryTreeList' |
| | | }, |
| | | tenantsOptions: [], |
| | | rolesOptions: [], |
| | | nextDepartOptions: [], |
| | | nextProductionOptions: [], |
| | | nextRepairDepartOptions: [], |
| | | isDepartType: '', |
| | | model: { |
| | | selectedProduction: '' |
| | | selectedProduction: '', |
| | | selectedRepairDeparts: '' |
| | | } |
| | | } |
| | | }, |
| | |
| | | this.initRoleList() |
| | | this.initTenantList() |
| | | this.queryTreeData() |
| | | this.getRepairDepartTreeDataByApi() |
| | | }, |
| | | computed: { |
| | | uploadAction: function() { |
| | |
| | | }).finally(() => { |
| | | }) |
| | | }, |
| | | // è·åç»´ä¿®çç»æ |
| | | getRepairDepartTreeDataByApi() { |
| | | getAction(this.url.repairDepartTreeList) |
| | | .then(res => { |
| | | if (res.success) { |
| | | this.repairDepartTreeData = res.result |
| | | } else { |
| | | this.$notification.warning({ |
| | | message: 'æ¶æ¯', |
| | | description: res.message |
| | | }) |
| | | } |
| | | }) |
| | | }, |
| | | add() { |
| | | this.refresh() |
| | | this.edit({ |
| | |
| | | userIdentity: 1, |
| | | selectedroles: '', |
| | | selecteddeparts: '', |
| | | selectedProduction: '' |
| | | selectedProduction: '', |
| | | selectedRepairDeparts: '' |
| | | }) |
| | | }, |
| | | edit(record) { |
| | |
| | | if (record.hasOwnProperty('id')) { |
| | | that.getUserRoles(record.id) |
| | | that.getUserDeparts(record.id) |
| | | that.getUserProductions(record.id) |
| | | that.getUserRepairDeparts(record.id) |
| | | } |
| | | }, |
| | | isDisabledAuth(code) { |
| | |
| | | that.nextDepartOptions = departOptions |
| | | } |
| | | }) |
| | | |
| | | }, |
| | | getUserProductions(userid) { |
| | | let that = this |
| | | // è·å车é´åé
|
| | | getAction(that.url.userProductionList, { userId: userid }).then((res) => { |
| | | if (res.success) { |
| | |
| | | that.nextProductionOptions = ProductionOptions |
| | | } |
| | | }) |
| | | //车é´çurl |
| | | }, |
| | | getUserRepairDeparts(userid) { |
| | | let that = this |
| | | // è·åç»´ä¿®é¨é¨/çç»åé
|
| | | getAction(that.url.userRepairDepartList, { userId: userid }).then((res) => { |
| | | if (res.success) { |
| | | let repairDepartOptions = [] |
| | | let selectedRepairDepartKeys = [] |
| | | for (let i = 0; i < res.result.length; i++) { |
| | | selectedRepairDepartKeys.push(res.result[i].key) |
| | | //æ°å¢è´è´£ç»´ä¿®é¨é¨/çç»éæ©ä¸ææ¡ |
| | | repairDepartOptions.push({ |
| | | value: res.result[i].key, |
| | | label: res.result[i].title |
| | | }) |
| | | } |
| | | |
| | | this.$set(this.model, 'selectedRepairDeparts', selectedRepairDepartKeys.join(',')) |
| | | that.nextRepairDepartOptions = repairDepartOptions |
| | | } |
| | | }) |
| | | }, |
| | | backDepartInfo(info) { |
| | | this.model.departIds = this.model.selecteddeparts |
| | |
| | | return c |
| | | }) |
| | | }, |
| | | backRepairDepartInfo(info) { |
| | | this.model.repairDepartIds = this.model.selectedRepairDeparts |
| | | this.nextRepairDepartOptions = info.map((item, index, arr) => { |
| | | let c = { label: item.text, value: item.value + '' } |
| | | return c |
| | | }) |
| | | }, |
| | | |
| | | refresh() { |
| | | this.userId = '' |
| | | this.nextDepartOptions = [] |
| | | this.nextProductionOptions = [] |
| | | this.nextRepairDepartOptions = [] |
| | | this.departIdShow = false |
| | | }, |
| | | close() { |
| | |
| | | this.disableSubmit = false |
| | | this.nextDepartOptions = [] |
| | | this.nextProductionOptions = [] |
| | | this.nextRepairDepartOptions = [] |
| | | this.departIdShow = false |
| | | this.$refs.form.resetFields() |
| | | }, |