|
@@ -1,53 +1,23 @@
|
|
|
<template>
|
|
|
<!-- 添加或修改菜单对话框 -->
|
|
|
- <el-dialog
|
|
|
- title="工资导入"
|
|
|
- v-model="visible"
|
|
|
- width="680px"
|
|
|
- append-to-body
|
|
|
- draggable
|
|
|
- :close-on-click-modal = "false"
|
|
|
- >
|
|
|
- <el-form
|
|
|
- ref="menuRef"
|
|
|
- :model="form"
|
|
|
- size="small"
|
|
|
- :rules="rules"
|
|
|
- label-width="100px"
|
|
|
- >
|
|
|
+ <el-dialog title="工资导入" v-model="visible" width="680px" append-to-body draggable :close-on-click-modal="false">
|
|
|
+ <el-form ref="menuRef" :model="form" size="small" :rules="rules" label-width="100px">
|
|
|
<el-row>
|
|
|
<el-col :span="24">
|
|
|
<el-form-item label="选择导入月份" prop="year">
|
|
|
- <el-date-picker
|
|
|
- v-model="currentMonth"
|
|
|
- type="month"
|
|
|
- format="YYYY年MM月"
|
|
|
- style="width: 150px"
|
|
|
- :clearable="false"
|
|
|
- value-format="YYYY-MM-01"
|
|
|
- :disabled-date="disabledDateHandler"
|
|
|
- @change="monthChangeHandler"
|
|
|
- />
|
|
|
+ <el-date-picker v-model="currentMonth" type="month" format="YYYY年MM月" style="width: 150px"
|
|
|
+ :clearable="false" value-format="YYYY-MM-01" :disabled-date="disabledDateHandler"
|
|
|
+ @change="monthChangeHandler" disabled />
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
<el-row>
|
|
|
<el-col :span="24">
|
|
|
<el-form-item label="上传">
|
|
|
- <el-upload
|
|
|
- ref="uploadRef"
|
|
|
- :limit="1"
|
|
|
- accept=".xlsx, .xls"
|
|
|
- :headers="upload.headers"
|
|
|
- :action="upload.url + `?year=${year}&month=${month}&companyId=${companyId}`"
|
|
|
- :fileList="fileList"
|
|
|
- :before-upload="handleBeforeUpload"
|
|
|
- :disabled="upload.isUploading"
|
|
|
- :on-progress="handleFileUploadProgress"
|
|
|
- :on-success="handleFileSuccess"
|
|
|
- :auto-upload="false"
|
|
|
- drag
|
|
|
- >
|
|
|
+ <el-upload ref="uploadRef" :limit="1" accept=".xlsx, .xls" :headers="upload.headers"
|
|
|
+ :action="upload.url + `?year=${years}&month=${months}&companyId=${companyId}`" :fileList="fileList"
|
|
|
+ :before-upload="handleBeforeUpload" :disabled="upload.isUploading" :on-progress="handleFileUploadProgress"
|
|
|
+ :on-success="handleFileSuccess" :auto-upload="false" drag>
|
|
|
<el-icon class="el-icon--upload">
|
|
|
<upload-filled />
|
|
|
</el-icon>
|
|
@@ -56,16 +26,9 @@
|
|
|
</div>
|
|
|
<template #tip>
|
|
|
<div class="el-upload__tip text-center">
|
|
|
- <span
|
|
|
- >仅允许导入xls、xlsx格式文件。文件大小限制为<50Mb</span
|
|
|
- >
|
|
|
- <el-link
|
|
|
- type="primary"
|
|
|
- :underline="false"
|
|
|
- style="font-size: 12px; vertical-align: baseline"
|
|
|
- @click="importTemplate"
|
|
|
- >下载模板</el-link
|
|
|
- >
|
|
|
+ <span>仅允许导入xls、xlsx格式文件。文件大小限制为<50Mb</span>
|
|
|
+ <el-link type="primary" :underline="false" style="font-size: 12px; vertical-align: baseline"
|
|
|
+ @click="importTemplate">下载模板</el-link>
|
|
|
</div>
|
|
|
</template>
|
|
|
</el-upload>
|
|
@@ -75,13 +38,7 @@
|
|
|
</el-form>
|
|
|
<template #footer>
|
|
|
<div class="dialog-footer">
|
|
|
- <el-button
|
|
|
- type="primary"
|
|
|
- icon="Finished"
|
|
|
- size="small"
|
|
|
- @click="submitForm"
|
|
|
- >确 定</el-button
|
|
|
- >
|
|
|
+ <el-button type="primary" icon="Finished" size="small" @click="submitForm">确 定</el-button>
|
|
|
<el-button icon="Close" size="small" @click="cancel">取 消</el-button>
|
|
|
</div>
|
|
|
</template>
|
|
@@ -90,148 +47,166 @@
|
|
|
|
|
|
|
|
|
<script setup>
|
|
|
-import { exportSalaryTemplateNotCompany } from "@/api/business/production/salary";
|
|
|
-import { getToken, getTenant } from "@/utils/auth";
|
|
|
-import useUserStore from "@/store/modules/user";
|
|
|
-import { deepClone } from "@/utils";
|
|
|
-import { useAttrs } from "vue";
|
|
|
-const attrs = useAttrs();
|
|
|
-const { proxy } = getCurrentInstance();
|
|
|
-/** 父组件传参 */
|
|
|
-const props = defineProps({
|
|
|
- companyId: {
|
|
|
- type: String,
|
|
|
- default: () => {},
|
|
|
- },
|
|
|
- loadData:{
|
|
|
- type:Function,
|
|
|
- default:()=>{}
|
|
|
+ import { exportSalaryTemplateNotCompany } from "@/api/business/production/salary";
|
|
|
+ import { getToken, getTenant } from "@/utils/auth";
|
|
|
+ import useUserStore from "@/store/modules/user";
|
|
|
+ import { deepClone } from "@/utils";
|
|
|
+ import { useAttrs } from "vue";
|
|
|
+ const attrs = useAttrs();
|
|
|
+ const { proxy } = getCurrentInstance();
|
|
|
+ /** 父组件传参 */
|
|
|
+ const props = defineProps({
|
|
|
+ companyId: {
|
|
|
+ type: String,
|
|
|
+ default: () => { },
|
|
|
+ },
|
|
|
+ years: {
|
|
|
+ type: String,
|
|
|
+ default: () => { },
|
|
|
+ },
|
|
|
+ months: {
|
|
|
+ type: String,
|
|
|
+ default: () => { },
|
|
|
+ },
|
|
|
+ loadData: {
|
|
|
+ type: Function,
|
|
|
+ default: () => { }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ const { companyId, years, months } = toRefs(props);
|
|
|
+
|
|
|
+ const emits = defineEmits(["loadData"]);
|
|
|
+ /** 字典数组区 */
|
|
|
+ /** 表单抽屉 页变量 */
|
|
|
+ const fileList = ref([]);
|
|
|
+ const visible = ref(false);
|
|
|
+ // const currentMonth = ref(proxy.moment().subtract("month").format("YYYY-MM-01"));
|
|
|
+ const currentMonth = ref(null);
|
|
|
+
|
|
|
+ const year = ref(proxy.moment().format("YYYY"));
|
|
|
+ const month = ref(proxy.moment().format("MM"));
|
|
|
+
|
|
|
+ const addType = ref(1);
|
|
|
+ const webHost = import.meta.env.VITE_APP_BASE_API;
|
|
|
+
|
|
|
+ const setHeaders = {
|
|
|
+ Authorization: getToken(),
|
|
|
+ };
|
|
|
+
|
|
|
+ const data = reactive({
|
|
|
+ form: {
|
|
|
+ year: proxy.moment().format("YYYY"),
|
|
|
+ month: proxy.moment().format("MM"),
|
|
|
+ },
|
|
|
+ followData: {},
|
|
|
+ });
|
|
|
+ const addComRef = ref(null);
|
|
|
+
|
|
|
+ /*** 客户导入参数 */
|
|
|
+ const upload = reactive({
|
|
|
+ // 是否禁用上传
|
|
|
+ isUploading: false,
|
|
|
+ // 设置上传的请求头部
|
|
|
+ headers: { Authorization: "Bearer " + getToken(), tenantId: getTenant() },
|
|
|
+ // 上传的地址
|
|
|
+ url: `/ezhizao-yzbh-production/business/salary/importData`,
|
|
|
+ });
|
|
|
+
|
|
|
+ /** 查询对象 */
|
|
|
+ const queryParams = ref({});
|
|
|
+
|
|
|
+ const followQuery = ref({});
|
|
|
+ const { form, rules, followData } = toRefs(data);
|
|
|
+
|
|
|
+ /*********************** 表单页方法 ****************************/
|
|
|
+
|
|
|
+ /** 抽屉打开 */
|
|
|
+ function open() {
|
|
|
+ // reset();
|
|
|
+ visible.value = true;
|
|
|
+ currentMonth.value = years.value + "-" + months.value + "-01";
|
|
|
}
|
|
|
-});
|
|
|
-const { companyId } = toRefs(props);
|
|
|
-
|
|
|
-const emits = defineEmits(["loadData"]);
|
|
|
-/** 字典数组区 */
|
|
|
-/** 表单抽屉 页变量 */
|
|
|
-const fileList = ref([]);
|
|
|
-const visible = ref(false);
|
|
|
-const currentMonth = ref(proxy.moment().subtract("month").format("YYYY-MM-01"));
|
|
|
-const year = ref(proxy.moment().format("YYYY"));
|
|
|
-const month = ref(proxy.moment().format("MM"));
|
|
|
-
|
|
|
-const addType = ref(1);
|
|
|
-const webHost = import.meta.env.VITE_APP_BASE_API;
|
|
|
-
|
|
|
-const setHeaders = {
|
|
|
- Authorization: getToken(),
|
|
|
-};
|
|
|
-
|
|
|
-const data = reactive({
|
|
|
- form: {
|
|
|
- year: proxy.moment().format("YYYY"),
|
|
|
- month: proxy.moment().format("MM"),
|
|
|
- },
|
|
|
- followData: {},
|
|
|
-});
|
|
|
-const addComRef = ref(null);
|
|
|
-
|
|
|
-/*** 客户导入参数 */
|
|
|
-const upload = reactive({
|
|
|
- // 是否禁用上传
|
|
|
- isUploading: false,
|
|
|
- // 设置上传的请求头部
|
|
|
- headers: { Authorization: "Bearer " + getToken(), tenantId: getTenant() },
|
|
|
- // 上传的地址
|
|
|
- url: `/ezhizao-yzbh-production/business/salary/importData`,
|
|
|
-});
|
|
|
-
|
|
|
-/** 查询对象 */
|
|
|
-const queryParams = ref({});
|
|
|
-
|
|
|
-const followQuery = ref({});
|
|
|
-const { form, rules, followData } = toRefs(data);
|
|
|
-
|
|
|
-/*********************** 表单页方法 ****************************/
|
|
|
-
|
|
|
-/** 抽屉打开 */
|
|
|
-function open() {
|
|
|
- // reset();
|
|
|
- visible.value = true;
|
|
|
-}
|
|
|
-
|
|
|
-//下载模板
|
|
|
-const importTemplate = () => {
|
|
|
- exportSalaryTemplateNotCompany();
|
|
|
-};
|
|
|
-
|
|
|
-function reset() {
|
|
|
- // console.log(addComRef.value)
|
|
|
- if (addComRef.value != null) addComRef.value.reset();
|
|
|
-}
|
|
|
-
|
|
|
-function cancel() {
|
|
|
- visible.value = false;
|
|
|
-}
|
|
|
-
|
|
|
-function submitForm() {
|
|
|
- submitFileForm();
|
|
|
-}
|
|
|
-
|
|
|
-function handleBeforeUpload(file) {
|
|
|
- console.log(file);
|
|
|
- if (
|
|
|
- file.type !==
|
|
|
+
|
|
|
+ //下载模板
|
|
|
+ const importTemplate = () => {
|
|
|
+ exportSalaryTemplateNotCompany();
|
|
|
+ };
|
|
|
+
|
|
|
+ function reset() {
|
|
|
+ // console.log(addComRef.value)
|
|
|
+ if (addComRef.value != null) addComRef.value.reset();
|
|
|
+ }
|
|
|
+
|
|
|
+ function cancel() {
|
|
|
+ visible.value = false;
|
|
|
+ }
|
|
|
+
|
|
|
+ function submitForm() {
|
|
|
+ submitFileForm();
|
|
|
+ }
|
|
|
+
|
|
|
+ function handleBeforeUpload(file) {
|
|
|
+ console.log(file);
|
|
|
+ if (
|
|
|
+ file.type !==
|
|
|
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" &&
|
|
|
- file.type !== "application/vnd.ms-excel"
|
|
|
- ) {
|
|
|
- proxy.$modal.msgError("请选择excel文件");
|
|
|
- return false;
|
|
|
+ file.type !== "application/vnd.ms-excel"
|
|
|
+ ) {
|
|
|
+ proxy.$modal.msgError("请选择excel文件");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return true;
|
|
|
}
|
|
|
- return true;
|
|
|
-}
|
|
|
-
|
|
|
-/**文件上传中处理 */
|
|
|
-const handleFileUploadProgress = (event, file, fileList) => {
|
|
|
- upload.isUploading = true;
|
|
|
-};
|
|
|
-/** 文件上传成功处理 */
|
|
|
-const handleFileSuccess = (response, file, fileList) => {
|
|
|
- upload.open = false;
|
|
|
- upload.isUploading = false;
|
|
|
- proxy.$refs["uploadRef"].handleRemove(file);
|
|
|
- proxy.$alert(
|
|
|
- "<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" +
|
|
|
+
|
|
|
+ /**文件上传中处理 */
|
|
|
+ const handleFileUploadProgress = (event, file, fileList) => {
|
|
|
+ upload.isUploading = true;
|
|
|
+ };
|
|
|
+ /** 文件上传成功处理 */
|
|
|
+ const handleFileSuccess = (response, file, fileList) => {
|
|
|
+ upload.open = false;
|
|
|
+ upload.isUploading = false;
|
|
|
+ proxy.$refs["uploadRef"].handleRemove(file);
|
|
|
+ proxy.$alert(
|
|
|
+ "<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" +
|
|
|
response.msg +
|
|
|
"</div>",
|
|
|
- "导入结果",
|
|
|
- { dangerouslyUseHTMLString: true }
|
|
|
- );
|
|
|
- attrs.onGetList();
|
|
|
- emits("loadData");
|
|
|
-
|
|
|
-};
|
|
|
-/** 提交上传文件 */
|
|
|
-function submitFileForm() {
|
|
|
- proxy.$refs["uploadRef"].submit();
|
|
|
-}
|
|
|
-
|
|
|
-function monthChangeHandler(arg) {
|
|
|
- year.value = proxy.moment(arg).format("YYYY");
|
|
|
- month.value = proxy.moment(arg).format("MM");
|
|
|
-}
|
|
|
-
|
|
|
-function disabledDateHandler(date) {
|
|
|
- if (date <= proxy.moment().subtract("month")) {
|
|
|
- return false;
|
|
|
- } else {
|
|
|
- return true;
|
|
|
+ "导入结果",
|
|
|
+ { dangerouslyUseHTMLString: true }
|
|
|
+ ).then(() => {
|
|
|
+ if (response.code == "200") {
|
|
|
+ visible.value = false;
|
|
|
+ attrs.onGetList();
|
|
|
+ emits("loadData");
|
|
|
+ }else{
|
|
|
+ visible.value = true;
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ };
|
|
|
+ /** 提交上传文件 */
|
|
|
+ function submitFileForm() {
|
|
|
+ proxy.$refs["uploadRef"].submit();
|
|
|
+ }
|
|
|
+
|
|
|
+ function monthChangeHandler(arg) {
|
|
|
+ year.value = proxy.moment(arg).format("YYYY");
|
|
|
+ month.value = proxy.moment(arg).format("MM");
|
|
|
+ }
|
|
|
+
|
|
|
+ function disabledDateHandler(date) {
|
|
|
+ if (date <= proxy.moment().subtract("month")) {
|
|
|
+ return false;
|
|
|
+ } else {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
}
|
|
|
-}
|
|
|
|
|
|
-// 暴露给父组件的方法
|
|
|
-defineExpose({
|
|
|
- open,
|
|
|
-});
|
|
|
+ // 暴露给父组件的方法
|
|
|
+ defineExpose({
|
|
|
+ open,
|
|
|
+ });
|
|
|
</script>
|
|
|
|
|
|
<style></style>
|