| | |
| | | <el-tree ref="tree" :data="treeData" node-key="id" :props="defaultProps" default-expand-all> |
| | | <template slot-scope="{ node, data }"> |
| | | <div v-if="data.type != 'user'">{{ data.name }}</div> |
| | | <div v-else class="leaf-node" :class="data.checked ? 'checked' : ''" @click="handleCheckItem(node, data)"> |
| | | <div v-else class="leaf-node" :class="data.checked ? 'checked' : ''" @click="handleCheckItem(data)"> |
| | | {{ data.name }} |
| | | </div> |
| | | </template> |
| | |
| | | children: 'children', |
| | | label: 'name', |
| | | }, |
| | | key: Math.random(), |
| | | }; |
| | | }, |
| | | computed: { |
| | | checkedKeys() { |
| | | console.log( |
| | | 1111, |
| | | this.selectdSections.map((v) => v.id), |
| | | ); |
| | | return this.selectdSections.map((v) => v.id); |
| | | }, |
| | | }, |
| | |
| | | if (this.setting.info) { |
| | | this.formData = Object.assign({}, JSON.parse(this.setting.info)); |
| | | } |
| | | this.initTree(); |
| | | this.init(); |
| | | warehouseManagerList({ warehouseId: this.formData.id }).then((res) => { |
| | | console.log(res); |
| | | this.selectdSections = res.map((item) => { |
| | | item.name = item.managerName; |
| | | item.id = item.managerId; |
| | | return item; |
| | | }); |
| | | this.key = Math.random(); |
| | | }); |
| | | }, |
| | | methods: { |
| | | initTree() { |
| | | userSelectDepartment({ agencyId: this.formData.agencyId }).then((res) => { |
| | | this.treeData = [res]; |
| | | async init() { |
| | | let managerRes = await warehouseManagerList({ warehouseId: this.formData.id }); |
| | | this.managerListStr = JSON.stringify(managerRes); |
| | | const res = await userSelectDepartment({ agencyId: this.formData.agencyId }); |
| | | this.treeData = this.deepList([res]); |
| | | }, |
| | | deepList(list) { |
| | | return list.map((item) => { |
| | | if (item.children && item.children.length) { |
| | | this.deepList(item.children); |
| | | } else { |
| | | if (this.managerListStr.includes(item.id)) { |
| | | item.checked = true; |
| | | } else { |
| | | item.checked = false; |
| | | } |
| | | } |
| | | return item; |
| | | }); |
| | | }, |
| | | handleCheckItem(node, data) { |
| | | handleCheckItem(data) { |
| | | this.selectdSections = []; |
| | | this.treeData[0].children.forEach((item, index) => { |
| | | if (item.children) { |
| | |
| | | }); |
| | | } |
| | | }); |
| | | console.log(this.treeData); |
| | | }, |
| | | handleDel(item) { |
| | | this.handleCheckItem({}, item); |
| | | this.handleCheckItem(item); |
| | | }, |
| | | handleClear() { |
| | | this.selectdSections.forEach((item) => { |
| | | this.handleCheckItem({}, item); |
| | | this.handleCheckItem(item); |
| | | }); |
| | | this.selectdSections = []; |
| | | }, |
| | |
| | | this.$emit('close'); |
| | | }, |
| | | save() { |
| | | let params = []; |
| | | let params = { |
| | | warehouseId: this.setting.id, |
| | | warehouseManagerInfoList: [], |
| | | }; |
| | | this.selectdSections.forEach((item) => { |
| | | params.push({ |
| | | params.warehouseManagerInfoList.push({ |
| | | managerId: item.id, |
| | | managerName: item.name, |
| | | baseWarehouseId: this.setting.id, |
| | | }); |
| | | }); |
| | | debugger; |
| | | warehouseManagerAdd(params).then((res) => { |
| | | if (res) { |
| | | this.$message.success('保存成功!'); |
| | | this.close(); |
| | | this.$emit('search'); |
| | | } else { |
| | | this.$message.error('保存失败'); |
| | | } |
| | | this.$message.success('保存成功!'); |
| | | this.close(); |
| | | this.$emit('search'); |
| | | }); |
| | | }, |
| | | }, |