| | |
| | | <el-tree-select |
| | | v-model="form.deptPositionId" |
| | | :data="deptPositionTree" |
| | | :props="{ value: 'id', label: 'label', children: 'children' }" |
| | | placeholder="请选择部门或岗位" |
| | | :props="{ value: 'id', label: 'label', children: 'children', disabled: checkDisabled }" |
| | | placeholder="请选择岗位" |
| | | clearable |
| | | check-strictly |
| | | :render-after-expand="false" |
| | |
| | | </template> |
| | | </el-tree-select> |
| | | </el-form-item> |
| | | <el-form-item label="劳保类型" prop="dictType"> |
| | | <el-select v-model="form.dictType" placeholder="请选择" clearable> |
| | | <el-option :label="item.label" :value="item.value" v-for="(item,index) in sys_lavor_issue_type" :key="item.value" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="劳保用品" prop="dictId"> |
| | | <el-select v-model="form.dictId" placeholder="请选择" clearable> |
| | | <el-option :label="item.dictName" :value="item.dictId" v-for="(item,index) in laborSuppliesOptions" :key="item.dictId" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="进厂日期" prop="factoryDate"> |
| | | <el-date-picker style="width: 100%" v-model="form.factoryDate" format="YYYY-MM-DD" value-format="YYYY-MM-DD" type="date" placeholder="请选择日期" clearable /> |
| | | </el-form-item> |
| | |
| | | </el-form-item> |
| | | <el-form-item label="员工与数量" required> |
| | | <div style="width:100%"> |
| | | <div style="margin-bottom:8px; text-align:right;"> |
| | | <el-button size="small" type="primary" @click="addItemRow">新增一行</el-button> |
| | | </div> |
| | | <el-table :data="form.laborIssueList" border size="small"> |
| | | <el-table :data="form.laborIssueList" border size="small" :span-method="arraySpanMethod"> |
| | | <el-table-column label="员工名称" width="220"> |
| | | <template #default="scope"> |
| | | <el-select v-model="scope.row.staffId" placeholder="请选择" filterable> |
| | | <el-option :label="p.staffName" :value="p.id" v-for="p in personList" :key="p.id" /> |
| | | </el-select> |
| | | <span>{{ personList.find(p => p.id === scope.row.staffId)?.staffName }}</span> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="发放数量" align="center"> |
| | | <el-table-column label="劳保用品" prop="dictName" align="center" /> |
| | | <el-table-column label="发放数量" align="center" width="150"> |
| | | <template #default="scope"> |
| | | <el-input-number v-model="scope.row.num" :min="0" :step="1" /> |
| | | </template> |
| | |
| | | |
| | | const formRules = { |
| | | deptPositionId: [{ required: true, trigger: "blur", message: "请输入" }], |
| | | dictType: [{ required: true, trigger: "change", message: "请选择" }], |
| | | dictId: [{ required: true, trigger: "change", message: "请选择" }], |
| | | adoptedDate: [{ required: true, trigger: "change", message: "请选择" }], |
| | | factoryDate: [{ required: true, trigger: "change", message: "请选择" }], |
| | | issueDate: [{ required: true, trigger: "change", message: "请选择" }], |
| | |
| | | getPersonList() |
| | | } |
| | | |
| | | function addItemRow() { |
| | | form.laborIssueList.push({ staffId: undefined, num: undefined }) |
| | | } |
| | | function removeItemRow(index) { |
| | | form.laborIssueList.splice(index, 1) |
| | | } |
| | |
| | | function sendForm() { |
| | | formRef.value?.validate(async valid => { |
| | | if (!valid) return |
| | | // 额外校验多人明细 |
| | | if (!Array.isArray(form.laborIssueList) || form.laborIssueList.length === 0) { |
| | | ElMessage.error('请至少添加一行员工与数量') |
| | | return |
| | | } |
| | | for (const row of form.laborIssueList) { |
| | | if (!row.staffId) { ElMessage.error('请选择员工'); return } |
| | | if (!row.dictId) { ElMessage.error('请选择劳保用品'); return } |
| | | if (row.num == null || row.num === '' || Number(row.num) < 0) { ElMessage.error('请输入数量'); return } |
| | | } |
| | | const payload = { ...form } |
| | |
| | | if (!deptPositionId) { |
| | | laborSuppliesOptions.value = [] |
| | | form.dictId = undefined |
| | | form.laborIssueList = [] |
| | | return |
| | | } |
| | | const res = await getDeptPositionByDeptIdLabor({ id: deptPositionId }) |
| | | laborSuppliesOptions.value = res?.data || [] |
| | | |
| | | const staffRes = await staffOnJobListPage({ current: -1, size: -1, staffState: 1, deptPositionId: deptPositionId }) |
| | | const staffList = staffRes?.data?.records || [] |
| | | const suppliesList = laborSuppliesOptions.value || [] |
| | | |
| | | if (staffList.length > 0 && suppliesList.length > 0) { |
| | | form.laborIssueList = [] |
| | | staffList.forEach(staff => { |
| | | suppliesList.forEach(supply => { |
| | | form.laborIssueList.push({ |
| | | staffId: staff.id, |
| | | dictId: supply.dictId, |
| | | dictName: supply.dictName, |
| | | num: supply.num || 0 |
| | | }) |
| | | }) |
| | | }) |
| | | } else { |
| | | form.laborIssueList = [] |
| | | } |
| | | } |
| | | |
| | | function arraySpanMethod({ row, column, rowIndex, columnIndex }) { |
| | | if (columnIndex === 0) { |
| | | const staffId = row.staffId |
| | | const sameStaffRows = form.laborIssueList.filter(item => item.staffId === staffId) |
| | | const firstIndex = form.laborIssueList.findIndex(item => item.staffId === staffId) |
| | | if (rowIndex === firstIndex) { |
| | | return { |
| | | rowspan: sameStaffRows.length, |
| | | colspan: 1 |
| | | } |
| | | } else { |
| | | return { |
| | | rowspan: 0, |
| | | colspan: 0 |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | function checkDisabled(data) { |
| | | return data.type === 1 |
| | | } |
| | | |
| | | onMounted(() => { |