gaoluyang
2025-11-20 591392aea7dfdaa526fc50c46cd88245688ee78b
1.金鹰黄金-劳保管理部门管理修改
2.金鹰黄金-劳保台账新增逻辑修改
已添加1个文件
已修改6个文件
505 ■■■■ 文件已修改
src/api/lavorissce/issue.js 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/lavorissue/issue/index.vue 38 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/lavorissue/ledger/EditModal.vue 189 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/lavorissue/ledger/Form.vue 66 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/lavorissue/ledger/Modal.vue 197 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/lavorissue/ledger/index.vue 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/personnelManagement/onboarding/components/formDia.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/lavorissce/issue.js
@@ -81,3 +81,11 @@
    data: query
  })
}
// åˆ é™¤åŠ³ä¿ç”¨å“
export function getDeptPositionByDeptIdLabor(query) {
  return request({
    url: '/deptPosition/getDeptPositionByDeptIdLabor',
    method: 'get',
    params: query
  })
}
src/views/lavorissue/issue/index.vue
@@ -35,9 +35,10 @@
            </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>
@@ -58,7 +59,7 @@
                </el-table-column>
              </el-table>
            </div>
            <div v-else class="empty">请选择左侧岗位进行配置</div>
            <div v-else class="empty">请选择左侧部门或岗位进行配置</div>
          </div>
        </div>
    <!-- æ–°å¢žéƒ¨é—¨/岗位弹窗 -->
@@ -224,7 +225,7 @@
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
@@ -234,7 +235,7 @@
}
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
@@ -248,12 +249,13 @@
}
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,
@@ -261,15 +263,20 @@
        quarter: qNum,
      })
    } else {
      // æ–°å¢žç”¨å“
      const currentId = currentPosition.value?.id ?? currentPosition.value?.raw?.id ?? currentDept.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 ?? currentPosition.value?.raw?.id ?? currentDept.value?.id ?? currentDept.value?.raw?.id
    await loadLaborConf(currentId)
    addItemDialogVisible.value = false
    ElMessage.success('保存成功')
  } catch (e) {
@@ -280,7 +287,7 @@
}
async function onDeleteItem(row) {
  if (!currentPosition.value || !row) return
  if ((!currentDept.value && !currentPosition.value) || !row) return
  try {
    await ElMessageBox.confirm('确定删除该用品配置吗?', '提示', { type: 'warning' })
  } catch {
@@ -288,8 +295,9 @@
  }
  try {
    await deleteLaborConf([row.id])
    const posId = currentPosition.value.raw?.id ?? currentPosition.value.id
    await loadLaborConf(posId)
    // é‡æ–°åŠ è½½ç”¨å“é…ç½®åˆ—è¡¨
    const currentId = currentPosition.value?.id ?? currentPosition.value?.raw?.id ?? currentDept.value?.id ?? currentDept.value?.raw?.id
    await loadLaborConf(currentId)
    ElMessage.success('删除成功')
  } catch (e) {
    ElMessage.error((e && (e.msg || e.message)) || '删除失败')
@@ -367,11 +375,13 @@
  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)
  }
}
src/views/lavorissue/ledger/EditModal.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,189 @@
<template>
  <el-dialog :title="modalOptions.title" v-model="visible" @close="close" width="60%">
    <el-form :model="form" label-width="100px" :rules="formRules" ref="formRef">
            <el-form-item label="岗位名称" prop="deptPositionId">
                <el-select v-model="form.deptPositionId" placeholder="请选择" clearable @change="handlePositionChange">
                    <el-option :label="item.name" :value="item.id" v-for="(item,index) in positionOptions" :key="item.id" />
                </el-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="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 label="发放日期" prop="issueDate">
                <el-date-picker
                    style="width: 100%"
                    v-model="form.issueDate"
                    format="YYYY-MM-DD"
                    value-format="YYYY-MM-DD"
                    type="date"
                    placeholder="请选择日期"
                    clearable
                />
            </el-form-item>
            <el-form-item label="员工名称" prop="staffId">
                <el-select
                    v-model="form.staffId"
                    placeholder="请选择"
                    clearable
                >
                    <el-option :label="item.staffName" :value="item.id" v-for="(item,index) in personList" :key="id" />
                </el-select>
            </el-form-item>
            <el-form-item label="发放数量" prop="num">
                <el-input-number :step="1" :min="0" style="width: 100%"
                                                 v-model="form.num"
                                                 placeholder="请输入"
                />
            </el-form-item>
    </el-form>
    <template #footer>
      <el-button type="primary" @click="sendForm" :loading="loading">{{ modalOptions.confirmText }}</el-button>
      <el-button @click="closeModal">{{ modalOptions.cancelText }}</el-button>
    </template>
  </el-dialog>
</template>
<script setup>
import { ref, getCurrentInstance, onMounted, nextTick } from 'vue'
import { useModal } from "@/hooks/useModal";
import { add, update } from "@/api/lavorissce/ledger";
import useFormData from "@/hooks/useFormData";
import useUserStore from "@/store/modules/user";
import {staffOnJobListPage} from "@/api/personnelManagement/employeeRecord.js";
import { getDept } from "@/api/collaborativeApproval/approvalProcess.js";
import { deptPositionListPage, getDeptPositionByDeptIdLabor } from "@/api/lavorissce/issue";
import { deepCopySameProperties } from '@/utils/util'
import { ElMessage } from "element-plus";
const { proxy } = getCurrentInstance()
defineOptions({ name: "收入新增编辑" });
const emits = defineEmits(["success"]);
const formRef = ref(null)
const userStore = useUserStore();
const { sys_lavor_issue } = proxy.useDict("sys_lavor_issue")
const { sys_lavor_issue_type } = proxy.useDict("sys_lavor_issue_type")
const productOptions = ref([]);
const personList = ref([]);
const positionOptions = ref([]);
const laborSuppliesOptions = ref([]);
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: "请选择" }],
}
const { form, resetForm } = useFormData({
  deptPositionId: undefined,
  dictType: undefined,
  dictId: undefined,
  adoptedDate: undefined,
  factoryDate: undefined,
  issueDate: undefined,
    staffId: undefined,
    num: undefined
});
function getPersonList() {
  staffOnJobListPage({current: -1, size:-1, staffState: 1}).then(res => { personList.value = res.data.records })
}
function getProductOptions() {
  getDept().then(res => { productOptions.value = res.data })
}
function clearValidate() { formRef.value?.clearValidate() }
function resetFormAndValidate() {
  resetForm()
  clearValidate()
  getProductOptions()
  getPersonList()
}
const {
  id,
  visible,
  loading,
  openModal,
  modalOptions,
  closeModal,
} = useModal({ title: "劳保台账" });
function sendForm() {
  formRef.value?.validate(async valid => {
    if (!valid) return
    const payload = { ...form }
    const { code } = id.value ? await update({ id: id.value, ...payload }) : await add(payload)
    if (code == 200) {
      emits("success")
      ElMessage({ message: "操作成功", type: "success" })
      close()
    } else {
      loading.value = false
    }
  })
}
function close() {
  resetFormAndValidate()
  closeModal()
}
async function loadForm(row) {
  openModal(row.id)
  await nextTick()
  deepCopySameProperties(row, form)
  // å¦‚果传入了岗位ID,自动查询劳保用品数据
  if (form.deptPositionId) {
    await handlePositionChange(form.deptPositionId)
  }
}
async function loadPositions() {
  const res = await deptPositionListPage({pageNum: -1, pageSize:-1})
    positionOptions.value = res?.data?.records || res?.data || []
}
async function handlePositionChange(deptPositionId) {
  if (!deptPositionId) {
    laborSuppliesOptions.value = []
    form.dictId = undefined
    return
  }
  const res = await getDeptPositionByDeptIdLabor({ id: deptPositionId })
  laborSuppliesOptions.value = res?.data || []
}
onMounted(() => {
  loadPositions()
  getPersonList()
})
defineExpose({ openModal, loadForm })
</script>
src/views/lavorissue/ledger/Form.vue
@@ -1,70 +1,6 @@
<template>
  <el-form :model="form" label-width="100px" :rules="formRules" ref="formRef">
    <el-form-item label="部门名称" prop="deptId">
      <el-select
          v-model="form.deptId"
          placeholder="请选择"
          clearable
          disabled
      >
        <el-option :label="item.deptName" :value="item.deptId" v-for="(item,index) in productOptions" :key="deptId" />
      </el-select>
        </el-form-item>
        <el-form-item label="员工名称" prop="staffId">
          <el-select
            v-model="form.staffId"
            placeholder="请选择"
            clearable
          >
            <el-option :label="item.staffName" :value="item.id" v-for="(item,index) in personList" :key="id" />
          </el-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="value" />
          </el-select>
        </el-form-item>
        <el-form-item label="劳保防具" prop="dictId">
          <el-select
              v-model="form.dictId"
              placeholder="请选择"
              clearable
          >
            <el-option :label="item.label" :value="item.value" v-for="(item,index) in sys_lavor_issue" :key="value" />
          </el-select>
        </el-form-item>
        <el-form-item label="发放数量" prop="num">
          <el-input-number :step="1" :min="0" style="width: 100%"
            v-model="form.num"
            placeholder="请输入"
          />
        </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 label="发放日期" prop="issueDate">
      <el-date-picker
          style="width: 100%"
          v-model="form.issueDate"
          format="YYYY-MM-DD"
          value-format="YYYY-MM-DD"
          type="date"
          placeholder="请选择日期"
          clearable
      />
    </el-form-item>
        
  </el-form>
</template>
src/views/lavorissue/ledger/Modal.vue
@@ -1,70 +1,191 @@
<template>
  <el-dialog :title="modalOptions.title" v-model="visible" @close="close" width="30%">
    <Form ref="formRef"></Form>
  <el-dialog :title="modalOptions.title" v-model="visible" @close="close" width="60%">
    <el-form :model="form" label-width="100px" :rules="formRules" ref="formRef">
      <el-form-item label="岗位名称" prop="deptPositionId">
        <el-select v-model="form.deptPositionId" placeholder="请选择" clearable @change="handlePositionChange">
          <el-option :label="item.name" :value="item.id" v-for="(item,index) in positionOptions" :key="item.id" />
        </el-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 label="发放日期" prop="issueDate">
        <el-date-picker style="width: 100%" v-model="form.issueDate" format="YYYY-MM-DD" value-format="YYYY-MM-DD" type="date" placeholder="请选择日期" clearable />
      </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-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>
              </template>
            </el-table-column>
            <el-table-column label="发放数量" align="center">
              <template #default="scope">
                <el-input-number v-model="scope.row.num" :min="0" :step="1" />
              </template>
            </el-table-column>
            <el-table-column label="操作" width="120" align="center">
              <template #default="scope">
                <el-button link type="danger" size="small" @click="removeItemRow(scope.$index)">删除</el-button>
              </template>
            </el-table-column>
          </el-table>
        </div>
      </el-form-item>
    </el-form>
    <template #footer>
            <el-button type="primary" @click="sendForm" :loading="loading">
                {{ modalOptions.confirmText }}
            </el-button>
      <el-button type="primary" @click="sendForm" :loading="loading">{{ modalOptions.confirmText }}</el-button>
      <el-button @click="closeModal">{{ modalOptions.cancelText }}</el-button>
    </template>
  </el-dialog>
</template>
<script setup>
import { ref, getCurrentInstance, onMounted, nextTick } from 'vue'
import { useModal } from "@/hooks/useModal";
import { add, update } from "@/api/lavorissce/ledger";
import Form from "./Form.vue";
import useFormData from "@/hooks/useFormData";
import useUserStore from "@/store/modules/user";
import {staffOnJobListPage} from "@/api/personnelManagement/employeeRecord.js";
import { getDept } from "@/api/collaborativeApproval/approvalProcess.js";
import { deptPositionListPage, getDeptPositionByDeptIdLabor } from "@/api/lavorissce/issue";
import { deepCopySameProperties } from '@/utils/util'
import { ElMessage } from "element-plus";
const { proxy } = getCurrentInstance()
defineOptions({
  name: "收入新增编辑",
});
defineOptions({ name: "收入新增编辑" });
const emits = defineEmits(["success"]);
const formRef = ref();
const formRef = ref(null)
const userStore = useUserStore();
const { sys_lavor_issue } = proxy.useDict("sys_lavor_issue")
const { sys_lavor_issue_type } = proxy.useDict("sys_lavor_issue_type")
const productOptions = ref([]);
const personList = ref([]);
const positionOptions = ref([]);
const laborSuppliesOptions = ref([]);
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: "请选择" }],
}
const { form, resetForm } = useFormData({
  deptPositionId: undefined,
  dictType: undefined,
  dictId: undefined,
  adoptedDate: undefined,
  factoryDate: undefined,
  issueDate: undefined,
  laborIssueList: [ { staffId: undefined, num: undefined } ],
});
function getPersonList() {
  staffOnJobListPage({current: -1, size:-1, staffState: 1}).then(res => { personList.value = res.data.records })
}
function getProductOptions() {
  getDept().then(res => { productOptions.value = res.data })
}
function clearValidate() { formRef.value?.clearValidate() }
function resetFormAndValidate() {
  resetForm()
  clearValidate()
  getProductOptions()
  getPersonList()
}
function addItemRow() {
  form.laborIssueList.push({ staffId: undefined, num: undefined })
}
function removeItemRow(index) {
  form.laborIssueList.splice(index, 1)
}
const {
  id,
  visible,
  loading,
  openModal,
  modalOptions,
  handleConfirm,
  closeModal,
} = useModal({ title: "劳保台账" });
const sendForm = () => {
    proxy.$refs.formRef.$refs.formRef.validate(async valid => {
        if (valid) {
            const {code} = id.value
                ? await update({id: id.value, ...formRef.value.form})
                : await add(formRef.value.form);
            if (code == 200) {
                emits("success");
                ElMessage({message: "操作成功", type: "success"});
                close();
            } else {
                loading.value = false;
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.num == null || row.num === '' || Number(row.num) < 0) { ElMessage.error('请输入数量'); return }
    }
    const payload = { ...form }
    const { code } = id.value ? await update({ id: id.value, ...payload }) : await add(payload)
    if (code == 200) {
      emits("success")
      ElMessage({ message: "操作成功", type: "success" })
      close()
    } else {
      loading.value = false
        }
    })
};
}
const close = () => {
    formRef.value.resetFormAndValidate();
  closeModal();
};
function close() {
  resetFormAndValidate()
  closeModal()
}
const loadForm = async (row) => {
  openModal(row.id);
  await nextTick();
  formRef.value.loadForm(row);
async function loadForm(row) {
  openModal(row.id)
  await nextTick()
  deepCopySameProperties(row, form)
}
async function loadPositions() {
  const res = await deptPositionListPage({pageNum: -1, pageSize:-1})
    positionOptions.value = res?.data?.records || res?.data || []
}
};
async function handlePositionChange(deptPositionId) {
  if (!deptPositionId) {
    laborSuppliesOptions.value = []
    form.dictId = undefined
    return
  }
  const res = await getDeptPositionByDeptIdLabor({ id: deptPositionId })
  laborSuppliesOptions.value = res?.data || []
}
defineExpose({
  openModal,
  loadForm,
});
onMounted(() => {
  loadPositions()
  getPersonList()
})
defineExpose({ openModal, loadForm })
</script>
src/views/lavorissue/ledger/index.vue
@@ -67,6 +67,7 @@
      </PIMTable>
    </div>
    <Modal ref="modalRef" @success="getTableData"></Modal>
    <EditModal ref="editModalRef" @success="getTableData"></EditModal>
    <files-dia ref="filesDia"></files-dia>
  </div>
</template>
@@ -76,6 +77,7 @@
import { listPage,deleteLedger,update } from "@/api/lavorissce/ledger";
import { onMounted, getCurrentInstance } from "vue";
import Modal from "./Modal.vue";
import EditModal from "./EditModal.vue";
import { ElMessageBox, ElMessage } from "element-plus";
import dayjs from "dayjs";
import FilesDia from "./filesDia.vue";
@@ -85,6 +87,7 @@
const multipleList = ref([]);
const { proxy } = getCurrentInstance();
const modalRef = ref();
const editModalRef = ref();
const { payment_methods } = proxy.useDict("payment_methods");
const { income_types } = proxy.useDict("income_types");
const filesDia = ref()
@@ -216,7 +219,7 @@
  modalRef.value.openModal();
};
const edit = (row) => {
  modalRef.value.loadForm(row);
  editModalRef.value.loadForm(row);
};
/** æœç´¢æŒ‰é’®æ“ä½œ */
src/views/personnelManagement/onboarding/components/formDia.vue
@@ -187,7 +187,7 @@
async function loadPositions() {
  try {
    positionLoading.value = true
    const res = await deptPositionListPage({pageNum: 1, pageSize: 9999})
    const res = await deptPositionListPage({pageNum: -1, pageSize:-1})
    positionOptions.value = res?.data?.records || res?.data || []
  } finally {
    positionLoading.value = false