ly 1 år sedan
förälder
incheckning
d191b151fb

+ 21 - 24
src/views/business/crm/company/form.vue

@@ -214,7 +214,6 @@
                   <el-col :span="8">
                     <el-form-item
                       label="税号:"
-                      required
                       prop="socialCreditCode"
                     >
                       <el-input
@@ -406,7 +405,6 @@
                   <el-col :span="16">
                     <el-form-item
                       label="注册省市区:"
-                      required
                       prop="provinceCode"
                     >
                       <template v-if="editStatus">
@@ -1173,11 +1171,10 @@ const data = reactive({
   },
   rules: {
     name: [{ required: true, message: "客户名称不能为空", trigger: "blur" }],
-    socialCreditCode: [
-      { required: true, message: "税号不能为空", trigger: "blur" },
-      { max: 18, min: 18, message: "税号为18位", trigger: "blur" },
-    ],
-    provinceCode: [{ validator: areaValidator, trigger: "blur" }],
+    // socialCreditCode: [
+    //   { max: 18, min: 18, message: "税号为18位", trigger: "blur" },
+    // ],
+    // provinceCode: [{ validator: areaValidator, trigger: "blur" }],
     taxType: [{ require: true, message: "纳税性质不能为空", trigger: "blur" }],
     sourceCategoryName: [
       { validator: sourceValidator, trigger: "change" },
@@ -1593,23 +1590,23 @@ function handleAddContactor() {
   form.value.contactors.push(contactor);
   return;
 }
-function areaValidator(rule, value, callback) {
-  console.log("省份验证");
-  if (form.value.provinceCode === "") {
-    callback(new Error("省份不能为空"));
-    return;
-  }
-  if (form.value.cityCode === "") {
-    callback(new Error("城市不能为空"));
-    return;
-  }
-  if (form.value.districtCode === "") {
-    callback(new Error("行政区不能为空"));
-    return;
-  }
-
-  return callback();
-}
+// function areaValidator(rule, value, callback) {
+//   console.log("省份验证");
+//   if (form.value.provinceCode === "") {
+//     callback(new Error("省份不能为空"));
+//     return;
+//   }
+//   if (form.value.cityCode === "") {
+//     callback(new Error("城市不能为空"));
+//     return;
+//   }
+//   if (form.value.districtCode === "") {
+//     callback(new Error("行政区不能为空"));
+//     return;
+//   }
+
+//   return callback();
+// }
 
 function handleSelectProvince() {
   const _provinceCode = form.value.provinceCode;

+ 227 - 0
src/views/business/production/salary/importExcelDialogCustomer.vue

@@ -0,0 +1,227 @@
+<template>
+  <!-- 添加或修改菜单对话框 -->
+  <el-dialog
+    title="工资导入"
+    v-model="visible"
+    width="680px"
+    append-to-body
+    draggable
+  >
+    <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-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-icon class="el-icon--upload">
+                <upload-filled />
+              </el-icon>
+              <div class="el-upload__text">
+                将文件拖到此处,或<em>点击上传</em>
+              </div>
+              <template #tip>
+                <div class="el-upload__tip text-center">
+                  <span
+                    >仅允许导入xls、xlsx格式文件。文件大小限制为&lt;50Mb</span
+                  >
+                  <el-link
+                    type="primary"
+                    :underline="false"
+                    style="font-size: 12px; vertical-align: baseline"
+                    @click="importTemplate"
+                    >下载模板</el-link
+                  >
+                </div>
+              </template>
+            </el-upload>
+          </el-form-item>
+        </el-col>
+      </el-row>
+    </el-form>
+    <template #footer>
+      <div class="dialog-footer">
+        <el-button
+          type="primary"
+          icon="Finished"
+          size="small"
+          @click="submitForm"
+          >确 定</el-button
+        >
+        <el-button icon="Close" size="small" @click="cancel">取 消</el-button>
+      </div>
+    </template>
+  </el-dialog>
+</template>
+
+
+<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";
+
+const { proxy } = getCurrentInstance();
+/** 父组件传参 */
+const props = defineProps({
+  companyId: {
+    type: String,
+    default: () => {},
+  },
+});
+const { companyId } = toRefs(props);
+/** 字典数组区 */
+/** 表单抽屉 页变量 */
+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 !==
+      "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" &&
+    file.type !== "application/vnd.ms-excel"
+  ) {
+    proxy.$modal.msgError("请选择excel文件");
+    return false;
+  }
+  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;'>" +
+      response.msg +
+      "</div>",
+    "导入结果",
+    { dangerouslyUseHTMLString: true }
+  );
+  // getList.value();
+};
+/** 提交上传文件 */
+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,
+});
+</script>
+
+<style></style>