删除工厂区域上级区域表单项
This commit is contained in:
@@ -45,13 +45,10 @@
|
|||||||
"confirm_delete": "Are you sure to delete?",
|
"confirm_delete": "Are you sure to delete?",
|
||||||
"validation_fail": "Validation failed",
|
"validation_fail": "Validation failed",
|
||||||
"please_enter": "Please enter {name}",
|
"please_enter": "Please enter {name}",
|
||||||
"parent_area": "Parent Area",
|
|
||||||
"select_parent_area": "Please select parent area",
|
|
||||||
"export": "Export",
|
"export": "Export",
|
||||||
"confirm_export": "Create export task?",
|
"confirm_export": "Create export task?",
|
||||||
"length_1_100": "Length should be 1 to 100 characters",
|
"length_1_100": "Length should be 1 to 100 characters",
|
||||||
"remark_max_500": "Remark cannot exceed 500 characters",
|
"remark_max_500": "Remark cannot exceed 500 characters"
|
||||||
"parent_cycle_error": "Parent area cannot be itself or a child area"
|
|
||||||
},
|
},
|
||||||
"production_line": {
|
"production_line": {
|
||||||
"search": "Search",
|
"search": "Search",
|
||||||
|
|||||||
@@ -45,13 +45,10 @@
|
|||||||
"confirm_delete": "确定要执行该操作吗?",
|
"confirm_delete": "确定要执行该操作吗?",
|
||||||
"validation_fail": "校验失败",
|
"validation_fail": "校验失败",
|
||||||
"please_enter": "请输入{name}",
|
"please_enter": "请输入{name}",
|
||||||
"parent_area": "上级区域",
|
|
||||||
"select_parent_area": "请选择上级区域",
|
|
||||||
"export": "导出",
|
"export": "导出",
|
||||||
"confirm_export": "确认创建导出任务?",
|
"confirm_export": "确认创建导出任务?",
|
||||||
"length_1_100": "长度在 1 到 100 个字符",
|
"length_1_100": "长度在 1 到 100 个字符",
|
||||||
"remark_max_500": "备注不能超过 500 个字符",
|
"remark_max_500": "备注不能超过 500 个字符"
|
||||||
"parent_cycle_error": "上级区域不能选择自身或下级区域"
|
|
||||||
},
|
},
|
||||||
"production_line": {
|
"production_line": {
|
||||||
"search": "查询",
|
"search": "查询",
|
||||||
|
|||||||
@@ -39,7 +39,7 @@
|
|||||||
:visible.sync="dialogVisible"
|
:visible.sync="dialogVisible"
|
||||||
:title="dialogTitle"
|
:title="dialogTitle"
|
||||||
:width="'35%'"
|
:width="'35%'"
|
||||||
:form-cols="dialogFormCols"
|
:form-cols="baseFormCols"
|
||||||
:form-data="formData"
|
:form-data="formData"
|
||||||
:rules="rules"
|
:rules="rules"
|
||||||
:label-width="'100px'"
|
:label-width="'100px'"
|
||||||
@@ -101,24 +101,10 @@ export default {
|
|||||||
baseFormCols: [
|
baseFormCols: [
|
||||||
[{ type: 'input', prop: 'code', label: this.key('code'), placeholder: this.key('enter_code'), clearable: true, style: { width: '90%' } }],
|
[{ 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: '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%' } }]
|
[{ 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 () {
|
created () {
|
||||||
this.columns = useTableColumns([
|
this.columns = useTableColumns([
|
||||||
{ prop: 'sort', label: this.key('sort'), width: 80 },
|
{ prop: 'sort', label: this.key('sort'), width: 80 },
|
||||||
@@ -197,11 +183,6 @@ export default {
|
|||||||
})
|
})
|
||||||
return result
|
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 () {
|
async fetchData () {
|
||||||
this.loading = true
|
this.loading = true
|
||||||
try {
|
try {
|
||||||
@@ -243,17 +224,7 @@ export default {
|
|||||||
this.formData = { code: row.code, name: row.name, parent_id: this.getParentId(row), remark: row.remark || '' }
|
this.formData = { code: row.code, name: row.name, parent_id: this.getParentId(row), remark: row.remark || '' }
|
||||||
this.dialogVisible = true
|
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 () {
|
async onDialogSubmit () {
|
||||||
if (!this.validateHierarchy()) return
|
|
||||||
this.submitting = true
|
this.submitting = true
|
||||||
try {
|
try {
|
||||||
if (this.handleType === 'create') await createFactoryArea(this.formData)
|
if (this.handleType === 'create') await createFactoryArea(this.formData)
|
||||||
|
|||||||
Reference in New Issue
Block a user