| | |
| | | </el-tree> |
| | | </div> |
| | | <div class="right"> |
| | | <div v-if="currentPosition" class="position-config"> |
| | | <div v-if="currentDept || currentPosition" class="position-config"> |
| | | <div class="title"> |
| | | <span>岗位配置:{{ currentPosition.label }}</span> |
| | | <span v-if="currentPosition">岗位配置:{{ currentPosition.label }}</span> |
| | | <span v-else-if="currentDept">部门配置:{{ currentDept.label }}</span> |
| | | </div> |
| | | <div class="q-toolbar"> |
| | | <el-button size="small" type="primary" @click="openAddItemDialog">新增用品</el-button> |
| | |
| | | </el-table-column> |
| | | </el-table> |
| | | </div> |
| | | <div v-else class="empty">请选择左侧岗位进行配置</div> |
| | | <div v-else class="empty">请选择左侧部门或岗位进行配置</div> |
| | | </div> |
| | | </div> |
| | | <!-- 新增部门/岗位弹窗 --> |
| | |
| | | const addItemForm = reactive({ id: undefined, dictId: undefined, quantity: 0, quarter: 1 }) |
| | | |
| | | function openAddItemDialog() { |
| | | if (!currentPosition.value) return |
| | | if (!currentDept.value && !currentPosition.value) return |
| | | addItemDialogTitle.value = '新增用品' |
| | | addItemForm.id = undefined |
| | | addItemForm.dictId = undefined |
| | |
| | | } |
| | | |
| | | function openEditItemDialog(row) { |
| | | if (!currentPosition.value || !row) return |
| | | if ((!currentDept.value && !currentPosition.value) || !row) return |
| | | addItemDialogTitle.value = '编辑用品' |
| | | addItemForm.id = row.id |
| | | addItemForm.dictId = row.dictId |
| | |
| | | } |
| | | |
| | | async function onConfirmAddItem() { |
| | | if (!currentPosition.value) return |
| | | if (!currentDept.value && !currentPosition.value) return |
| | | addItemSaving.value = true |
| | | try { |
| | | const qNum = Number(addItemForm.quarter) || 1 |
| | | const deptPositionId = currentPosition.value.id ?? currentPosition.value.raw?.id ?? currentPosition.value?.id |
| | | |
| | | if (addItemForm.id) { |
| | | // 编辑用品 |
| | | await updateLaborConf({ |
| | | id: addItemForm.id, |
| | | dictId: addItemForm.dictId, |
| | |
| | | quarter: qNum, |
| | | }) |
| | | } else { |
| | | // 新增用品 |
| | | const currentId = currentPosition.value?.id ?? currentDept.value?.raw?.id |
| | | await addLaborConf({ |
| | | deptPositionId, |
| | | deptPositionId: currentId, |
| | | dictId: addItemForm.dictId, |
| | | num: Number(addItemForm.quantity) || 0, |
| | | quarter: qNum, |
| | | }) |
| | | } |
| | | const posId = currentPosition.value.raw?.id ?? currentPosition.value.id |
| | | await loadLaborConf(posId) |
| | | |
| | | // 重新加载用品配置列表 |
| | | const currentId = currentPosition.value?.id ?? currentDept.value?.raw?.id |
| | | await loadLaborConf(currentId) |
| | | |
| | | addItemDialogVisible.value = false |
| | | ElMessage.success('保存成功') |
| | | } catch (e) { |
| | |
| | | } |
| | | |
| | | async function onDeleteItem(row) { |
| | | if (!currentPosition.value || !row) return |
| | | if ((!currentDept.value && !currentPosition.value) || !row) return |
| | | try { |
| | | await ElMessageBox.confirm('确定删除该用品配置吗?', '提示', { type: 'warning' }) |
| | | } catch { |
| | |
| | | } |
| | | try { |
| | | await deleteLaborConf([row.id]) |
| | | const posId = currentPosition.value.raw?.id ?? currentPosition.value.id |
| | | await loadLaborConf(posId) |
| | | // 重新加载用品配置列表 |
| | | const currentId = currentPosition.value?.id ?? currentDept.value?.raw?.id |
| | | await loadLaborConf(currentId) |
| | | ElMessage.success('删除成功') |
| | | } catch (e) { |
| | | ElMessage.error((e && (e.msg || e.message)) || '删除失败') |
| | |
| | | if (node.type === 1) { |
| | | currentDept.value = node |
| | | currentPosition.value = null |
| | | // 选择部门时,加载部门级别的用品配置 |
| | | loadLaborConf(node.raw.id) |
| | | } else if (node.type === 2) { |
| | | const dept = findDeptById(departments, node.parentDeptId) |
| | | if (dept) currentDept.value = mapDeptToTree(dept) |
| | | currentPosition.value = node.raw |
| | | // 选择岗位时,按要求查询用品配置列表 |
| | | // 选择岗位时,查询用品配置列表 |
| | | loadLaborConf(node.raw.id) |
| | | } |
| | | } |