zouyu
17 小时以前 32f10392ab00b07e85c0b4229037c30af7c3f28e
src/views/personnelManagement/payrollManagement/index.vue
@@ -1,57 +1,57 @@
<template>
   <div class="app-container">
      <div class="search_form">
         <div>
            <span class="search_title">姓名:</span>
            <el-input
               v-model="searchForm.name"
               style="width: 240px"
               placeholder="请输入姓名搜索"
               @change="handleQuery"
               clearable
               :prefix-icon="Search"
            />
            <span class="search_title ml10">月份:</span>
            <el-date-picker
               v-model="searchForm.payDateStr"
               type="month"
               @change="handleQuery"
               value-format="YYYY-MM"
               format="YYYY-MM"
               placeholder="请选择月份"
               style="width: 240px"
               clearable
            />
            <el-button type="primary" @click="handleQuery" style="margin-left: 10px"
            >搜索</el-button
            >
         </div>
         <div>
            <el-button type="primary" @click="openForm('add')">新增薪资</el-button>
<!--            <el-button @click="handleOut">导出</el-button>-->
            <el-button type="danger" plain @click="handleDelete">删除</el-button>
         </div>
      </div>
      <div class="table_list">
         <PIMTable
            rowKey="id"
            :column="tableColumn"
            :tableData="tableData"
            :page="page"
            :isSelection="true"
            @selection-change="handleSelectionChange"
            :tableLoading="tableLoading"
            @pagination="pagination"
            :total="page.total"
         ></PIMTable>
      </div>
      <form-dia ref="formDia" @close="handleQuery"></form-dia>
   </div>
  <div class="app-container">
    <div class="search_form">
      <div>
        <span class="search_title">姓名:</span>
        <el-input
            v-model="searchForm.name"
            style="width: 240px"
            placeholder="请输入姓名搜索"
            @change="handleQuery"
            clearable
            :prefix-icon="Search"
        />
        <span class="search_title ml10">月份:</span>
        <el-date-picker
            v-model="searchForm.payDateStr"
            type="month"
            @change="handleQuery"
            value-format="YYYY-MM"
            format="YYYY-MM"
            placeholder="请选择月份"
            style="width: 240px"
            clearable
        />
        <el-button type="primary" @click="handleQuery" style="margin-left: 10px"
        >搜索</el-button
        >
      </div>
      <div>
        <el-button @click="handleExport" style="margin-right: 10px">导出</el-button>
        <el-button type="primary" @click="openForm('add')">新增薪资</el-button>
        <el-button type="danger" plain @click="handleDelete">删除</el-button>
      </div>
    </div>
    <div class="table_list">
      <PIMTable
          rowKey="id"
          :column="tableColumn"
          :tableData="tableData"
          :page="page"
          :isSelection="true"
          @selection-change="handleSelectionChange"
          :tableLoading="tableLoading"
          @pagination="pagination"
          :total="page.total"
      ></PIMTable>
    </div>
    <form-dia ref="formDia" @close="handleQuery"></form-dia>
  </div>
</template>
<script setup>
import { Search } from "@element-plus/icons-vue";
import {onMounted, ref} from "vue";
import {onMounted, ref, reactive, toRefs, getCurrentInstance, nextTick} from "vue";
import FormDia from "@/views/personnelManagement/payrollManagement/components/formDia.vue";
import {staffJoinDel} from "@/api/personnelManagement/onboarding.js";
import {ElMessageBox} from "element-plus";
@@ -59,232 +59,248 @@
import {compensationDelete, compensationListPage} from "@/api/personnelManagement/payrollManagement.js";
const data = reactive({
   searchForm: {
      name: "",
      payDateStr: "",
   },
  searchForm: {
    name: "",
    payDateStr: "",
  },
});
const { searchForm } = toRefs(data);
const tableColumn = ref([
   {
      label: "薪资月份",
      prop: "payDate",
   },
   {
      label: "姓名",
      prop: "name",
   },
   {
      label: "应出勤天数",
      prop: "shouldAttendedNum",
      width:100
   },
   {
      label: "实际出勤天数",
      prop: "actualAttendedNum",
      width:110
   },
   {
      label: "基本工资",
      prop: "basicSalary",
   },
   {
      label: "岗位工资",
      prop: "postSalary",
      width:100
   },
   {
      label: "入离职缺勤扣款",
      prop: "deductionAbsenteeism",
      width:130
   },
   {
      label: "病假扣款",
      prop: "sickLeaveDeductions",
      width:100
   },
   {
      label: "事假扣款",
      prop: "deductionPersonalLeave",
      width:100
   },
   {
      label: "忘记打卡扣款",
      prop: "forgetClockDeduct",
      width:110
   },
   {
      label: "绩效得分",
      prop: "performanceScore",
      width:150
   },
   {
      label: "绩效工资",
      prop: "performancePay",
      width: 120
   },
   {
      label: "应发合计",
      prop: "payableWages",
      width:150
   },
   {
      label: "社保个人",
      prop: "socialSecurityIndividuals",
   },
   {
      label: "社保公司",
      prop: "socialSecurityCompanies",
      width: 120
   },
   {
      label: "社保合计",
      prop: "socialSecurityTotal",
      width: 120
   },
   {
      label: "公积金个人",
      prop: "providentFundIndividuals",
      width: 120
   },
   {
      label: "公积金公司",
      prop: "providentFundCompany",
      width: 120
   },
   {
      label: "公积金合计",
      prop: "providentFundTotal",
      width: 120
   },
   {
      label: "应税工资",
      prop: "taxableWaget",
   },
   {
      label: "个人所得税",
      prop: "personalIncomeTax",
      width: 120
   },
   {
      label: "实发工资",
      prop: "actualWages",
      width: 120
   },
   {
      dataType: "action",
      label: "操作",
      align: "center",
      fixed: 'right',
      operation: [
         {
            name: "编辑",
            type: "text",
            clickFun: (row) => {
               openForm("edit", row);
            },
         },
      ],
   },
  {
    label: "薪资月份",
    prop: "payDate",
  },
  {
    label: "姓名",
    prop: "name",
  },
  {
    label: "应出勤天数",
    prop: "shouldAttendedNum",
    width:100
  },
  {
    label: "实际出勤天数",
    prop: "actualAttendedNum",
    width:110
  },
  {
    label: "基本工资",
    prop: "basicSalary",
  },
  {
    label: "岗位工资",
    prop: "postSalary",
    width:100
  },
  {
    label: "入离职缺勤扣款",
    prop: "deductionAbsenteeism",
    width:130
  },
  {
    label: "病假扣款",
    prop: "sickLeaveDeductions",
    width:100
  },
  {
    label: "事假扣款",
    prop: "deductionPersonalLeave",
    width:100
  },
  {
    label: "忘记打卡扣款",
    prop: "forgetClockDeduct",
    width:110
  },
  {
    label: "绩效得分",
    prop: "performanceScore",
    width:150
  },
  {
    label: "绩效工资",
    prop: "performancePay",
    width: 120
  },
  {
    label: "应发合计",
    prop: "payableWages",
    width:150
  },
  {
    label: "社保个人",
    prop: "socialSecurityIndividuals",
  },
  {
    label: "社保公司",
    prop: "socialSecurityCompanies",
    width: 120
  },
  {
    label: "社保合计",
    prop: "socialSecurityTotal",
    width: 120
  },
  {
    label: "公积金个人",
    prop: "providentFundIndividuals",
    width: 120
  },
  {
    label: "公积金公司",
    prop: "providentFundCompany",
    width: 120
  },
  {
    label: "公积金合计",
    prop: "providentFundTotal",
    width: 120
  },
  {
    label: "应税工资",
    prop: "taxableWaget",
  },
  {
    label: "个人所得税",
    prop: "personalIncomeTax",
    width: 120
  },
  {
    label: "实发工资",
    prop: "actualWages",
    width: 120
  },
  {
    dataType: "action",
    label: "操作",
    align: "center",
    fixed: 'right',
    operation: [
      {
        name: "编辑",
        type: "text",
        clickFun: (row) => {
          openForm("edit", row);
        },
      },
    ],
  },
]);
const tableData = ref([]);
const selectedRows = ref([]);
const tableLoading = ref(false);
const page = reactive({
   current: 1,
   size: 100,
   total: 0,
  current: 1,
  size: 100,
  total: 0,
});
const formDia = ref()
const { proxy } = getCurrentInstance()
const handleDateChange = (value,type) => {
   searchForm.value.entryDateEnd = null
   searchForm.value.entryDateStart = null
   if(type === 1){
      if (value) {
         searchForm.value.entryDateStart = dayjs(value).format("YYYY-MM-DD");
      }
   }else{
      if (value) {
         searchForm.value.entryDateEnd = dayjs(value).format("YYYY-MM-DD");
      }
   }
   getList();
  searchForm.value.entryDateEnd = null
  searchForm.value.entryDateStart = null
  if(type === 1){
    if (value) {
      searchForm.value.entryDateStart = dayjs(value).format("YYYY-MM-DD");
    }
  }else{
    if (value) {
      searchForm.value.entryDateEnd = dayjs(value).format("YYYY-MM-DD");
    }
  }
  getList();
};
// 查询列表
/** 搜索按钮操作 */
const handleQuery = () => {
   page.current = 1;
   getList();
  page.current = 1;
  getList();
};
const pagination = (obj) => {
   page.current = obj.page;
   page.size = obj.limit;
   getList();
  page.current = obj.page;
  page.size = obj.limit;
  getList();
};
const getList = () => {
   tableLoading.value = true;
   compensationListPage({...page, ...searchForm.value, staffState: 1}).then(res => {
      tableLoading.value = false;
      tableData.value = res.data.records
      page.total = res.data.total;
   }).catch(err => {
      tableLoading.value = false;
   })
  tableLoading.value = true;
  compensationListPage({...page, ...searchForm.value, staffState: 1}).then(res => {
    tableLoading.value = false;
    tableData.value = res.data.records
    page.total = res.data.total;
  }).catch(err => {
    tableLoading.value = false;
  })
};
// 表格选择数据
const handleSelectionChange = (selection) => {
   selectedRows.value = selection;
  selectedRows.value = selection;
};
// 打开弹框
const openForm = (type, row) => {
   nextTick(() => {
      formDia.value?.openDialog(type, row)
   })
  nextTick(() => {
    formDia.value?.openDialog(type, row)
  })
};
// 删除
const handleDelete = () => {
   let ids = [];
   if (selectedRows.value.length > 0) {
      ids = selectedRows.value.map((item) => item.id);
   } else {
      proxy.$modal.msgWarning("请选择数据");
      return;
   }
   ElMessageBox.confirm("选中的内容将被删除,是否确认删除?", "导出", {
      confirmButtonText: "确认",
      cancelButtonText: "取消",
      type: "warning",
   })
      .then(() => {
         compensationDelete(ids).then((res) => {
            proxy.$modal.msgSuccess("删除成功");
            getList();
         });
      })
      .catch(() => {
         proxy.$modal.msg("已取消");
      });
  let ids = [];
  if (selectedRows.value.length > 0) {
    ids = selectedRows.value.map((item) => item.id);
  } else {
    proxy.$modal.msgWarning("请选择数据");
    return;
  }
  ElMessageBox.confirm("选中的内容将被删除,是否确认删除?", "导出", {
    confirmButtonText: "确认",
    cancelButtonText: "取消",
    type: "warning",
  })
      .then(() => {
        compensationDelete(ids).then((res) => {
          proxy.$modal.msgSuccess("删除成功");
          getList();
        });
      })
      .catch(() => {
        proxy.$modal.msg("已取消");
      });
};
// 导出
const handleOut = () => {
   ElMessageBox.confirm("选中的内容将被导出,是否确认导出?", "导出", {
      confirmButtonText: "确认",
      cancelButtonText: "取消",
      type: "warning",
   })
      .then(() => {
         proxy.download("/staff/staffJoinLeaveRecord/export", {staffState: 1}, "人员入职.xlsx");
      })
      .catch(() => {
         proxy.$modal.msg("已取消");
      });
  ElMessageBox.confirm("选中的内容将被导出,是否确认导出?", "导出", {
    confirmButtonText: "确认",
    cancelButtonText: "取消",
    type: "warning",
  })
      .then(() => {
        proxy.download("/staff/staffJoinLeaveRecord/export", {staffState: 1}, "人员入职.xlsx");
      })
      .catch(() => {
        proxy.$modal.msg("已取消");
      });
};
// 导出薪资管理
const handleExport = () => {
  ElMessageBox.confirm("选中的内容将被导出,是否确认导出?", "导出", {
    confirmButtonText: "确认",
    cancelButtonText: "取消",
    type: "warning",
  })
      .then(() => {
        proxy.download("/compensationPerformance/export", { ...searchForm.value, ...page }, "薪资管理.xlsx");
      })
      .catch(() => {
        proxy.$modal.msg("已取消");
      });
};
onMounted(() => {
   getList();
  getList();
});
</script>