| | |
| | | import { getLazyTree } from '@/api/base/region' |
| | | import { mapGetters } from 'vuex' |
| | | import website from '@/config/website' |
| | | import { getList } from '@/api/device/device'; |
| | | |
| | | export default { |
| | | data () { |
| | | return { |
| | | treeResolveMap: new Map(), |
| | | form: {}, |
| | | selectionList: [], |
| | | query: {}, |
| | |
| | | |
| | | column: [ |
| | | { |
| | | label: '机构名称', |
| | | label: '部门名称', |
| | | prop: 'deptName', |
| | | search: true, |
| | | labelWidth: 120, |
| | | rules: [ |
| | | { |
| | | required: true, |
| | | message: '请输入机构名称', |
| | | message: '请输入部门名称', |
| | | trigger: 'blur', |
| | | }, |
| | | ], |
| | | }, |
| | | { |
| | | label: '机构全称', |
| | | label: '部门全称', |
| | | prop: 'fullName', |
| | | search: true, |
| | | labelWidth: 120, |
| | | rules: [ |
| | | { |
| | | required: true, |
| | | message: '请输入机构全称', |
| | | message: '请输入部门全称', |
| | | trigger: 'blur', |
| | | }, |
| | | ], |
| | | }, |
| | | { |
| | | label: '上级机构', |
| | | label: '上级部门', |
| | | prop: 'parentId', |
| | | dicData: [], |
| | | type: 'tree', |
| | |
| | | rules: [ |
| | | { |
| | | required: false, |
| | | message: '请选择上级机构', |
| | | message: '请选择上级部门', |
| | | trigger: 'click', |
| | | }, |
| | | ], |
| | | }, |
| | | { |
| | | label: '机构类型', |
| | | label: '部门类型', |
| | | type: 'select', |
| | | dicUrl: '/blade-system/dict/dictionary?code=org_category', |
| | | props: { |
| | |
| | | rules: [ |
| | | { |
| | | required: true, |
| | | message: '请输入机构类型', |
| | | message: '请输入部门类型', |
| | | trigger: 'blur', |
| | | }, |
| | | ], |
| | | }, |
| | | { |
| | | label: '机构性质', |
| | | label: '部门性质', |
| | | type: 'select', |
| | | dicUrl: '/blade-system/dict/dictionary?code=org_nature', |
| | | props: { |
| | |
| | | rules: [ |
| | | { |
| | | required: true, |
| | | message: '请输入机构性质', |
| | | message: '请输入部门性质', |
| | | trigger: 'blur', |
| | | }, |
| | | ], |
| | |
| | | type: 'success', |
| | | message: '操作成功!', |
| | | }) |
| | | this.parentId = '' |
| | | const resolve = this.treeResolveMap.get(row.parentId) |
| | | if (resolve) { |
| | | // 重新加载子节点数据 |
| | | getChildLazyTree({ parentId: row.parentId }).then(res => { |
| | | resolve(res.data.data) |
| | | }) |
| | | } |
| | | this.onLoad(this.page) |
| | | done(row) |
| | | }, |
| | |
| | | loading() |
| | | return |
| | | } |
| | | console.log('--- Start rowUpdate ---') |
| | | // console.log('--- Start rowUpdate ---') |
| | | |
| | | // 提交时只使用县级代码 |
| | | const submitData = { |
| | |
| | | areaCode: row.areaCode.split(',').pop(), // 取最后一个代码(县级) |
| | | } |
| | | |
| | | console.log('Row data before submit:', row) |
| | | console.log('编辑', row) |
| | | |
| | | update(submitData) |
| | | .then( |
| | | res => { |
| | | console.log('Update response:', res.data) |
| | | const resolve = this.treeResolveMap.get(row.parentId) |
| | | if (resolve) { |
| | | // 重新加载子节点数据 |
| | | getChildLazyTree({ parentId: row.parentId }).then(res => { |
| | | resolve(res.data.data) |
| | | }) |
| | | } |
| | | this.onLoad(this.page) |
| | | this.$message({ |
| | | type: 'success', |
| | | message: '操作成功!', |
| | | }) |
| | | this.onLoad(this.page) |
| | | done(row) |
| | | }, |
| | | error => { |
| | | console.log('Update error:', error) |
| | | // console.log('Update error:', error) |
| | | this.loading = false |
| | | loading() |
| | | } |
| | | ) |
| | | .catch(error => { |
| | | console.log('Update promise rejected:', error) |
| | | // console.log('Update promise rejected:', error) |
| | | this.loading = false |
| | | }) |
| | | }, |
| | |
| | | return remove(row.id) |
| | | }) |
| | | .then(() => { |
| | | const resolve = this.treeResolveMap.get(row.parentId) |
| | | if (resolve) { |
| | | // 重新加载子节点数据 |
| | | getChildLazyTree({ parentId: row.parentId }).then(res => { |
| | | resolve(res.data.data) |
| | | }) |
| | | } |
| | | this.onLoad(this.page) |
| | | this.$message({ |
| | | type: 'success', |
| | | message: '操作成功!', |
| | | }) |
| | | this.onLoad(this.page) |
| | | done(row) |
| | | }) |
| | | }, |
| | |
| | | }, |
| | | onLoad (page, params = {}) { |
| | | this.loading = true |
| | | console.log('onLoad triggered with page:', page, 'params:', params) |
| | | console.log('Current parentId:', this.parentId, 'query:', this.query) |
| | | // console.log('onLoad triggered with page:', page, 'params:', params) |
| | | // console.log('Current parentId:', this.parentId, 'query:', this.query) |
| | | getLazyList(this.parentId, Object.assign(params, this.query)) |
| | | .then(res => { |
| | | console.log('onLoad response:', res.data) |
| | | // console.log('onLoad response:', res.data) |
| | | // 处理 areaCode,确保是单一字符串 |
| | | const data = (res.data.data || []).map(item => { |
| | | const fullAreaCode = this.getFullAreaCode(item.areaCode) |
| | |
| | | this.data = data |
| | | this.loading = false |
| | | this.selectionClear() |
| | | console.log('Table data after onLoad:', this.data) |
| | | // console.log('Table data after onLoad:', this.data) |
| | | }) |
| | | .catch(error => { |
| | | console.log('onLoad error:', error) |
| | | // console.log('onLoad error:', error) |
| | | this.loading = false |
| | | this.data = this.data // 保留当前数据 |
| | | console.log('Table data after onLoad error:', this.data) |
| | | // console.log('Table data after onLoad error:', this.data) |
| | | }) |
| | | }, |
| | | treeLoad (tree, treeNode, resolve) { |
| | | this.treeResolveMap.set(tree.id, resolve) |
| | | getChildLazyTree({ parentId: tree.id }).then(res => { |
| | | resolve(res.data.data) |
| | | }) |