删除工厂区域上级区域表单项
This commit is contained in:
@@ -45,13 +45,10 @@
|
||||
"confirm_delete": "Are you sure to delete?",
|
||||
"validation_fail": "Validation failed",
|
||||
"please_enter": "Please enter {name}",
|
||||
"parent_area": "Parent Area",
|
||||
"select_parent_area": "Please select parent area",
|
||||
"export": "Export",
|
||||
"confirm_export": "Create export task?",
|
||||
"length_1_100": "Length should be 1 to 100 characters",
|
||||
"remark_max_500": "Remark cannot exceed 500 characters",
|
||||
"parent_cycle_error": "Parent area cannot be itself or a child area"
|
||||
"remark_max_500": "Remark cannot exceed 500 characters"
|
||||
},
|
||||
"production_line": {
|
||||
"search": "Search",
|
||||
|
||||
@@ -45,13 +45,10 @@
|
||||
"confirm_delete": "确定要执行该操作吗?",
|
||||
"validation_fail": "校验失败",
|
||||
"please_enter": "请输入{name}",
|
||||
"parent_area": "上级区域",
|
||||
"select_parent_area": "请选择上级区域",
|
||||
"export": "导出",
|
||||
"confirm_export": "确认创建导出任务?",
|
||||
"length_1_100": "长度在 1 到 100 个字符",
|
||||
"remark_max_500": "备注不能超过 500 个字符",
|
||||
"parent_cycle_error": "上级区域不能选择自身或下级区域"
|
||||
"remark_max_500": "备注不能超过 500 个字符"
|
||||
},
|
||||
"production_line": {
|
||||
"search": "查询",
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
:visible.sync="dialogVisible"
|
||||
:title="dialogTitle"
|
||||
:width="'35%'"
|
||||
:form-cols="dialogFormCols"
|
||||
:form-cols="baseFormCols"
|
||||
:form-data="formData"
|
||||
:rules="rules"
|
||||
:label-width="'100px'"
|
||||
@@ -101,24 +101,10 @@ export default {
|
||||
baseFormCols: [
|
||||
[{ type: 'input', prop: 'code', label: this.key('code'), placeholder: this.key('enter_code'), clearable: true, style: { width: '90%' } }],
|
||||
[{ type: 'input', prop: 'name', label: this.key('name'), placeholder: this.key('enter_name'), clearable: true, style: { width: '90%' } }],
|
||||
[{ type: 'select', prop: 'parent_id', label: this.key('parent_area'), placeholder: this.key('select_parent_area'), clearable: true, filterable: true, style: { width: '90%' }, options: [] }],
|
||||
[{ type: 'input', prop: 'remark', inputType: 'textarea', autosize: { minRows: 2, maxRows: 6 }, label: this.key('remark'), placeholder: this.key('remark_required'), clearable: true, style: { width: '90%' } }]
|
||||
]
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
dialogFormCols () {
|
||||
const cols = JSON.parse(JSON.stringify(this.baseFormCols))
|
||||
cols[2][0].options = this.parentAreaOptions
|
||||
return cols
|
||||
},
|
||||
parentAreaOptions () {
|
||||
const disabledIds = this.handleType === 'edit' ? new Set([String(this.editId), ...this.collectDescendantIds(this.editId)]) : new Set()
|
||||
return this.flattenTree(this.tableData)
|
||||
.filter(item => !disabledIds.has(String(this.getId(item))))
|
||||
.map(item => ({ value: this.getId(item), label: item._treeLabel || item.name }))
|
||||
}
|
||||
},
|
||||
created () {
|
||||
this.columns = useTableColumns([
|
||||
{ prop: 'sort', label: this.key('sort'), width: 80 },
|
||||
@@ -197,11 +183,6 @@ export default {
|
||||
})
|
||||
return result
|
||||
},
|
||||
collectDescendantIds (id) {
|
||||
const current = this.flattenTree(this.tableData).find(item => String(this.getId(item)) === String(id))
|
||||
if (!current || !Array.isArray(current.children)) return []
|
||||
return this.flattenTree(current.children).map(item => String(this.getId(item)))
|
||||
},
|
||||
async fetchData () {
|
||||
this.loading = true
|
||||
try {
|
||||
@@ -243,17 +224,7 @@ export default {
|
||||
this.formData = { code: row.code, name: row.name, parent_id: this.getParentId(row), remark: row.remark || '' }
|
||||
this.dialogVisible = true
|
||||
},
|
||||
validateHierarchy () {
|
||||
if (this.handleType !== 'edit' || this.formData.parent_id === '') return true
|
||||
const parentId = String(this.formData.parent_id)
|
||||
if (parentId === String(this.editId) || this.collectDescendantIds(this.editId).includes(parentId)) {
|
||||
this.$message.warning(this.$t(this.key('parent_cycle_error')))
|
||||
return false
|
||||
}
|
||||
return true
|
||||
},
|
||||
async onDialogSubmit () {
|
||||
if (!this.validateHierarchy()) return
|
||||
this.submitting = true
|
||||
try {
|
||||
if (this.handleType === 'create') await createFactoryArea(this.formData)
|
||||
|
||||
Reference in New Issue
Block a user