|
@@ -0,0 +1,145 @@
|
|
|
+<script setup lang="ts">
|
|
|
+ import { PageWrapper } from '/@/components/Page';
|
|
|
+ import { BasicTable, useTable, TableAction } from '/@/components/Table';
|
|
|
+ import { useMessage } from '/@/hooks/web/useMessage';
|
|
|
+ import { Upload } from 'ant-design-vue';
|
|
|
+ import BasicForm from '/@/components/TableForm/src/BasicForm.vue';
|
|
|
+ import { downloadByData } from '/@/utils/file/download';
|
|
|
+ import { Modal } from 'ant-design-vue';
|
|
|
+ import { useForm } from '/@/components/Form';
|
|
|
+ import viewModal from './components/viewModal.vue';
|
|
|
+ import { tableColumns, formSchema } from './components/data.config';
|
|
|
+ import {
|
|
|
+ deletePersonnelBasepersonnellabourcapital,
|
|
|
+ getBasepersonnellabourcapitalPage,
|
|
|
+ postBasepersonnellabourcapitalImport,
|
|
|
+ getBasepersonnellabourcapitalExport,
|
|
|
+ } from '/@/services/apis/BasePersonnelLabourCapitalController';
|
|
|
+ import { h, ref, reactive } from 'vue';
|
|
|
+ import { useModal } from '/@/components/Modal';
|
|
|
+ import { formatToDateTime } from '/@/utils/dateUtil';
|
|
|
+ import { t } from '/@/hooks/web/useI18n';
|
|
|
+ const visible = ref(false);
|
|
|
+ const file = ref();
|
|
|
+ const searchInfo = reactive<Recordable>({ category: 2 });
|
|
|
+ const [registerTable, { reload }] = useTable({
|
|
|
+ api: getBasepersonnellabourcapitalPage,
|
|
|
+ title: '社保基数',
|
|
|
+ rowKey: 'id',
|
|
|
+ columns: tableColumns,
|
|
|
+ useSearchForm: false,
|
|
|
+ showTableSetting: true,
|
|
|
+ bordered: true,
|
|
|
+ immediate: true,
|
|
|
+ canResize: true,
|
|
|
+ actionColumn: {
|
|
|
+ width: 150,
|
|
|
+ title: '操作',
|
|
|
+ dataIndex: 'action',
|
|
|
+ slots: { customRender: 'action' },
|
|
|
+ fixed: 'right',
|
|
|
+ },
|
|
|
+ });
|
|
|
+ const [formReg, { validateFields, resetFields }] = useForm({
|
|
|
+ showActionButtonGroup: false,
|
|
|
+ schemas: formSchema,
|
|
|
+ labelWidth: 100,
|
|
|
+ });
|
|
|
+ const [viewModalreg, { openModal }] = useModal();
|
|
|
+ const { createMessage, createConfirm } = useMessage();
|
|
|
+ const handleExport = async () => {
|
|
|
+ const data = await getBasepersonnellabourcapitalExport({});
|
|
|
+ downloadByData(data.data, `社保基数${formatToDateTime(new Date(), 'YYYYMMDDHHmmss')}.xlsx`);
|
|
|
+ createMessage.success('导出成功');
|
|
|
+ };
|
|
|
+ const beforeUpload = async (e) => {
|
|
|
+ file.value = e;
|
|
|
+ return false;
|
|
|
+ };
|
|
|
+ const handleDownload = () => {
|
|
|
+ const a = document.createElement('a');
|
|
|
+ a.href =
|
|
|
+ 'https://zhxy.cqtlzjzx.com/minio/static/resources/%E7%A4%BE%E4%BF%9D%E6%A8%A1%E6%9D%BF.xlsx';
|
|
|
+ a.download = '社保模板.xlsx';
|
|
|
+ a.click();
|
|
|
+ a.remove();
|
|
|
+ createMessage.success('下载成功');
|
|
|
+ };
|
|
|
+ const handleEdit = async (record: any, isUpdate: boolean) => {
|
|
|
+ openModal(true, { ...record, isUpdate: isUpdate });
|
|
|
+ };
|
|
|
+ const handleDelete = (record: any) => {
|
|
|
+ createConfirm({
|
|
|
+ iconType: 'warning',
|
|
|
+ title: () => h('span', t('温馨提醒')),
|
|
|
+ content: () => h('span', t('是否删除该工资条?')),
|
|
|
+ onOk: async () => {
|
|
|
+ try {
|
|
|
+ await deletePersonnelBasepersonnellabourcapital([record.id]);
|
|
|
+ createMessage.success('删除成功');
|
|
|
+ await reload();
|
|
|
+ } catch (e) {
|
|
|
+ createMessage.error('删除失败');
|
|
|
+ }
|
|
|
+ },
|
|
|
+ okText: () => t('确认'),
|
|
|
+ cancelText: () => t('取消'),
|
|
|
+ });
|
|
|
+ };
|
|
|
+ const handleSubmit = async () => {
|
|
|
+ if (!file.value) {
|
|
|
+ createMessage.error('请上传文件');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const data = await validateFields();
|
|
|
+ data.dateOfIssue = data.dateOfIssue + '-01-01';
|
|
|
+ await postBasepersonnellabourcapitalImport({ file: file.value, ...data, category: 2 });
|
|
|
+ createMessage.success('导入成功');
|
|
|
+ resetFields();
|
|
|
+ visible.value = false;
|
|
|
+ reload();
|
|
|
+ };
|
|
|
+ const handleCancel = () => {
|
|
|
+ resetFields();
|
|
|
+ visible.value = false;
|
|
|
+ };
|
|
|
+</script>
|
|
|
+
|
|
|
+<template>
|
|
|
+ <PageWrapper dense contentFullHeight fixedHeight contentClass="flex">
|
|
|
+ <BasicTable @register="registerTable" :searchInfo="searchInfo">
|
|
|
+ <template #toolbar>
|
|
|
+ <a-button type="primary" @click="visible = true">导入</a-button>
|
|
|
+ <!-- <a-button type="primary" @click="handleExport()">导出</a-button> -->
|
|
|
+ <a-button type="primary" @click="handleDownload">下载模板</a-button>
|
|
|
+ </template>
|
|
|
+ <template #action="{ record }">
|
|
|
+ <div style="display: flex; justify-content: center">
|
|
|
+ <TableAction
|
|
|
+ :actions="[
|
|
|
+ {
|
|
|
+ label: '查看',
|
|
|
+ onClick: handleEdit.bind(null, record, false),
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '删除',
|
|
|
+ onClick: handleDelete.bind(null, record),
|
|
|
+ },
|
|
|
+ ]"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </BasicTable>
|
|
|
+ <viewModal @register="viewModalreg" />
|
|
|
+ <Modal @cancel="handleCancel" @ok="handleSubmit" v-model:visible="visible" title="导入">
|
|
|
+ <div style="padding: 12px">
|
|
|
+ <Upload :max-count="1" :before-upload="beforeUpload">
|
|
|
+ <a-button type="primary"> 模板文件 </a-button>
|
|
|
+ </Upload>
|
|
|
+ <BasicForm @register="formReg" />
|
|
|
+ </div>
|
|
|
+ </Modal>
|
|
|
+ </PageWrapper>
|
|
|
+</template>
|
|
|
+
|
|
|
+<style scoped lang="less"></style>
|