| | |
| | | <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(data)"> |
| | | {{ data.name }} |
| | | <div>{{ data.name }}</div> |
| | | <i style="font-size: 18px;font-weight: bold;color: #0d997c;margin-right: 10px" |
| | | class="el-icon-check"></i> |
| | | </div> |
| | | </template> |
| | | </el-tree> |
| | |
| | | </div> |
| | | </div> |
| | | <div slot="footer" align="center" class="dialog-footer"> |
| | | <my-button name="取消" site="form" @click="close" /> |
| | | <my-button name="保存" site="form" @click="save" /> |
| | | <my-button name="取消" site="form" @click="close"/> |
| | | <my-button name="保存" site="form" @click="save"/> |
| | | </div> |
| | | </win-md> |
| | | </template> |
| | |
| | | |
| | | export default { |
| | | name: 'person', |
| | | components: { winMd, myButton }, |
| | | components: {winMd, myButton}, |
| | | props: { |
| | | setting: { |
| | | type: Object, |
| | | default: () => {}, |
| | | default: () => { |
| | | }, |
| | | }, |
| | | }, |
| | | data() { |
| | | return { |
| | | loading:true, |
| | | loadingText:'加载中', |
| | | loading: true, |
| | | loadingText: '加载中', |
| | | selectdSections: [], |
| | | treeData: [], |
| | | formData: {}, |
| | |
| | | this.formData = Object.assign({}, JSON.parse(this.setting.info)); |
| | | } |
| | | this.init(); |
| | | warehouseManagerList({ warehouseId: this.formData.id }).then((res) => { |
| | | this.selectdSections = res.map((item) => { |
| | | item.name = item.managerName; |
| | | item.id = item.managerId; |
| | | return item; |
| | | }); |
| | | this.key = Math.random(); |
| | | this.loading = false |
| | | }); |
| | | }, |
| | | methods: { |
| | | async init() { |
| | | let managerRes = await warehouseManagerList({ warehouseId: this.formData.id }); |
| | | this.managerListStr = JSON.stringify(managerRes); |
| | | const res = await userSelectDepartment({ agencyId: this.formData.agencyId }); |
| | | let managerRes = await warehouseManagerList({warehouseId: this.formData.id}); |
| | | this.selectdSections = managerRes.map((item) => { |
| | | item.name = item.managerName; |
| | | item.id = item.managerId; |
| | | item.checked = true |
| | | return item; |
| | | }); |
| | | const res = await userSelectDepartment({agencyId: this.formData.agencyId}); |
| | | this.treeData = this.deepList([res]); |
| | | this.key = Math.random(); |
| | | this.loading = false |
| | | }, |
| | | 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; |
| | | } |
| | | item.checked = this.selectdSections.some(s=>item.id===s.id) |
| | | } |
| | | return item; |
| | | }); |
| | | }, |
| | | handleCheckItem(data) { |
| | | this.selectdSections = []; |
| | | if (!data.checked) { |
| | | this.selectdSections.push(data); |
| | | } else { |
| | | let idx = this.selectdSections.findIndex(item => item.id === data.id) |
| | | if (idx !== -1) { |
| | | this.selectdSections.splice(idx, 1) |
| | | } |
| | | } |
| | | this.treeData[0].children.forEach((item, index) => { |
| | | if (item.children) { |
| | | item.children.forEach((child, childIndex) => { |
| | | if (child.id == data.id) { |
| | | this.$set(this.treeData[0].children[index].children[childIndex], 'checked', !child.checked); |
| | | } |
| | | if (child.checked) { |
| | | this.selectdSections.push(child); |
| | | } |
| | | }); |
| | | } |
| | |
| | | this.$emit('close'); |
| | | }, |
| | | save() { |
| | | if(this.selectdSections.length===0){ |
| | | this.$message.error('请选择库管员!'); |
| | | return |
| | | } |
| | | let params = { |
| | | warehouseId: this.setting.id, |
| | | warehouseManagerInfoList: [], |
| | |
| | | managerName: item.name, |
| | | }); |
| | | }); |
| | | // setTimeout(()=>{ |
| | | // warehouseManagerAdd(params).then((res) => { |
| | | // this.$message.success('保存成功!'); |
| | | // this.close(); |
| | | // this.$emit('search'); |
| | | // }); |
| | | // this.$message.success('保存成功!'); |
| | | // this.close(); |
| | | // this.$emit('search'); |
| | | // },6000) |
| | | warehouseManagerAdd(params).then((res) => { |
| | | this.$message.success('保存成功!'); |
| | | this.close(); |
| | |
| | | height: 400px; |
| | | display: flex; |
| | | justify-content: space-between; |
| | | |
| | | ::v-deep { |
| | | .el-tree-node__expand-icon.is-leaf { |
| | | display: none; |
| | | } |
| | | } |
| | | } |
| | | |
| | | .section-left, |
| | | .section-right { |
| | | width: calc((100% - 20px) / 2); |
| | |
| | | border-radius: 4px; |
| | | overflow-y: auto; |
| | | } |
| | | |
| | | .header-row { |
| | | display: flex; |
| | | align-items: center; |
| | | justify-content: space-between; |
| | | |
| | | .title { |
| | | color: #3d3d3d; |
| | | font-size: 14px; |
| | |
| | | font-weight: 400; |
| | | } |
| | | } |
| | | |
| | | .section-body { |
| | | margin-top: 20px; |
| | | } |
| | | |
| | | .section-right { |
| | | .btn { |
| | | display: inline-block; |
| | |
| | | background: rgba($color: #0d997c, $alpha: 0.1); |
| | | cursor: pointer; |
| | | } |
| | | |
| | | .del-btn { |
| | | color: #f9675b; |
| | | border: 1px solid #f9675b; |
| | | background: rgba($color: #f9675b, $alpha: 0.1); |
| | | } |
| | | |
| | | .section-item { |
| | | width: 44%; |
| | | margin: 0 auto; |
| | |
| | | margin-bottom: 10px; |
| | | } |
| | | } |
| | | |
| | | .leaf-node { |
| | | width: 100%; |
| | | height: 26px; |
| | | line-height: 26px; |
| | | padding-left: 10px; |
| | | &:hover { |
| | | background: #f5f7fa; |
| | | display: flex; |
| | | justify-content: space-between; |
| | | align-items: center; |
| | | |
| | | i { |
| | | display: none; |
| | | } |
| | | } |
| | | |
| | | .checked { |
| | | width: 100%; |
| | | background: #f5f7fa; |
| | | height: 26px; |
| | | line-height: 26px; |
| | | box-sizing: border-box; |
| | | i { |
| | | display: inline-flex; |
| | | } |
| | | } |
| | | </style> |