Ver Fonte

fix:修改导入合同逻辑

ly há 11 meses atrás
pai
commit
b5b9aef8b0

+ 13 - 11
src/api/upgrade/contract.js

@@ -99,6 +99,18 @@ export function checkInput(file) {
         }
     })
 }
+export function importLoop(file) {
+    request.defaults.baseURL = '/ezhizao-yzbh-crm'
+    return request({
+        url: `/upgrade/crm/order/importLoop`,
+        method: 'post',
+        data: file,
+        headers: {
+            'Content-Type': 'multipart/form-data'
+        },
+        timeout:200000
+    })
+}
 export function exportCheckExcel(data,type,filename) {
     request.defaults.baseURL = '/ezhizao-yzbh-crm'
     return request({
@@ -169,17 +181,7 @@ export function exportOnceTemplate() {
 }
 
 // 文件上传
-export function importLoop(file) {
-    request.defaults.baseURL = '/ezhizao-yzbh-crm'
-    return request({
-        url: `/business/archive/order/order/importLoop`,
-        method: 'post',
-        data: file,
-        headers: {
-            'Content-Type': 'multipart/form-data'
-        }
-    })
-}
+
 // 文件上传
 export function importOnce(file) {
     request.defaults.baseURL = '/ezhizao-yzbh-crm'

+ 70 - 56
src/views/business/upgrade/WorkOrderDialog.vue

@@ -1,38 +1,15 @@
 <template>
   <el-dialog :close-on-click-modal = "false"
-      id="workdialog" v-model="outerVisible" title="合同列表" width="800">
-    <h1 style="font-weight: bold;">导入的合同开始时间大于当前时间</h1>
-    <span style="color: #F69600;">注:当前导入的以下合同,其最小开始月大于当前时间,会在开始月之前无法将任务委托给工厂进行工作,请确认以下客户开始服务的时间是否正确。</span>
-    <div style="display:flex; flex-direction: row-reverse;">
-      <el-button type="warning" size="small" icon="Download" @click="exportExcel('2')" >导出</el-button>
-    </div>
-    <el-table
-          ref="singleTableRef"
-          :data="data.startMonth"
-          highlight-current-row
-          style="width: 100%"
-          max-height="250"
-          @current-change="handleCurrentChange"
-      >
-        <el-table-column type="index" label="序号" width="50" />
-        <el-table-column property="contractNo" label="合同编号" width="120" />
-        <el-table-column property="companyName" label="客户名称" width="120" />
+      id="workdialog" v-model="outerVisible" title="校验数据" width="825">
+
 
-        <el-table-column property="taskType" label="服务类型" width="120" />
-        <el-table-column property="startMonth" label="开始月" width="120" />
-        <el-table-column property="endMonth" label="结束月" width="120" />
-        <el-table-column label="操作" min-width="120">
-          <template #default="scope">
-            <el-button size="small" :disabled="scope.row.disabled" @click="handleClick(scope.$index, scope.row,this)">
-              确认
-            </el-button>
-          </template>
-        </el-table-column>
-      </el-table>
     <h1 style="font-weight: bold;">导入的合同结束时间小于当前时间</h1>
     <span style="color: #F69600;">注:当前导入的以下合同,其最大结束月小于当前时间,会导致下个月开始该服务将无法委托给工厂工作,请确认一下客户是否都已经停止服务,如果未停止服务,需要补传续合同。</span>
     <div style="display:flex; flex-direction: row-reverse;">
-      <el-button type="warning" size="small" icon="Download" @click="exportExcel('1')" >导出</el-button>
+      <el-button type="primary" size="small" @click="dataConfirm(1)">
+        一键确认
+      </el-button> &nbsp;
+      <el-button type="primary" size="small" icon="Download" @click="exportExcel('1')" >导出</el-button>
     </div>
     <el-table
 
@@ -58,12 +35,44 @@
       </el-table-column>
     </el-table>
 
+    <h1 style="font-weight: bold;">导入的合同开始时间大于当前时间</h1>
+    <span style="color: #F69600;">注:当前导入的以下合同,其最小开始月大于当前时间,会在开始月之前无法将任务委托给工厂进行工作,请确认以下客户开始服务的时间是否正确。</span>
+    <div style="display:flex; flex-direction: row-reverse;">
+      <el-button type="primary" size="small" @click="dataConfirm(2)">
+        一键确认
+      </el-button> &nbsp;
+      <el-button type="primary" size="small" icon="Download" @click="exportExcel('2')" >导出</el-button>
+    </div>
+    <el-table
+          ref="singleTableRef"
+          :data="data.startMonth"
+          highlight-current-row
+          style="width: 100%"
+          max-height="250"
+          @current-change="handleCurrentChange"
+      >
+        <el-table-column type="index" label="序号" width="50" />
+        <el-table-column property="contractNo" label="合同编号" width="120" />
+        <el-table-column property="companyName" label="客户名称" width="120" />
+
+        <el-table-column property="taskType" label="服务类型" width="120" />
+        <el-table-column property="startMonth" label="开始月" width="120" />
+        <el-table-column property="endMonth" label="结束月" width="120" />
+        <el-table-column label="操作" min-width="120">
+          <template #default="scope">
+            <el-button size="small" :disabled="scope.row.disabled" @click="handleClick(scope.$index, scope.row,this)">
+              确认
+            </el-button>
+          </template>
+        </el-table-column>
+      </el-table>
+
 
     <template #footer>
       <div class="dialog-footer">
         <el-button @click="outerVisible = false">取消</el-button>
         <el-button type="primary" @click="sumbit">
-          确认
+          下一步
         </el-button>
       </div>
     </template>
@@ -109,46 +118,51 @@ interface input {
  endMonth:Date;
  disabled: boolean;
 }
-const emit = defineEmits(['event']);
+const emit = defineEmits(['event','resubmit']);
 const props = defineProps({
   data: {
     type: Object,
     default: () => {},
   },
-  checksuccess:{
-    type: Number,
-    default: 0,
+  resubmit:{
+    type: Function,
+    default: () => {},
   }
 });
-const { data,checksuccess } = toRefs(props);
-//torefs()
+const { data,resubmit } = toRefs(props);
 
 
 function open() {
   outerVisible.value = true;
 }
 
-
-function sumbit() {
-
-
-  if(data.value.startMonth == null && data.value.endMonth == null  ){
-    emit('event',1)
-    outerVisible.value = false;
+const dataConfirm = (val:number)=>{
+  let count = 0;
+  if(data.value.startMonth.length+data.value.endMonth.length===checkNumber.value){
+    return;
   }
-  if(data.value.startMonth == 0 && data.value.endMonth == 0){
-    emit('event',1)
-    outerVisible.value = false;
+  if(val==2){
+    data.value.startMonth.forEach((val:input)=>{
+      val.disabled = true;
+      count++;
+    })
+   // console.log(checkNumber.value)
+  //  checkNumber.value = data.value.startMonth.length+checkNumber.value;
+  }else{
+    data.value.endMonth.forEach((val:input)=>{
+      val.disabled = true;
+      count++;
+    })
+    console.log(count)
+  //  = data.value.endMonth.length+checkNumber.value;
   }
-  if(data.value.startMonth.length+data.value.endMonth.length===checkNumber.value){
-    emit('event',1)
-    proxy.$alert(
-        "<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" +
-        "已完成确认请重新上传文件" +
-        "</div>"
-        ,
-        { dangerouslyUseHTMLString: true }
-    );
+  checkNumber.value += count;
+}
+
+function sumbit() {
+  if(data.value.startMonth.length+data.value.endMonth.length===checkNumber.value ||(data.value.startMonth.length ==null && data.value.endMonth.length ==null )){
+    emit('event',0)
+    emit('resubmit')
     outerVisible.value = false;
   }else{
     proxy.$alert(
@@ -166,7 +180,7 @@ function exportExcel(type:string){
   if(type === "1"){
     filename = "导入的合同结束时间小于当前时间.xlsx";
   }else {
-    filename ="导入的合同结束时间大于当前时间.xlsx";
+    filename ="导入的合同开始时间大于当前时间.xlsx";
   }
   exportCheckExcel(data.value,type,filename)
 }

+ 53 - 39
src/views/business/upgrade/order/importExcelDialog.vue

@@ -87,7 +87,7 @@
       </div>
     </template>
   </el-dialog>
-  <work-order-dialog ref="workOrderDialog" @event="setchecksuccess" v-if="inputData" :checksuccess="checksuccess" :data="inputData"></work-order-dialog>
+  <work-order-dialog ref="workOrderDialog" @resubmit="resubmitFrom" @event="setchecksuccess" :checksuccess="checksuccess" :data="inputData"></work-order-dialog>
 </template>
 
 
@@ -120,11 +120,38 @@ const visible = ref(false);
 const fullLoading = ref(false);
 const addType = ref(1);
 const webHost = import.meta.env.VITE_APP_BASE_API;
-const workOrderDialog = ref();
+const workOrderDialog = ref(null);
 const checksuccess = ref(0);
 const setchecksuccess = (val)=>{
   checksuccess.value = val;
 }
+let refile = null;
+const resubmitFrom = ()=>{
+  fullLoading.value = true;
+    visible.value = false;
+    const formData = new FormData();
+    formData.append("file", refile);
+    importLoop(formData).then((res)=>{
+      fullLoading.value = false;
+      proxy.$alert(
+          "<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" +
+          res.msg +
+          "</div>",
+          "导入结果",
+          { dangerouslyUseHTMLString: true }
+      );
+      getList.value();
+    }).catch((e)=>{
+      fullLoading.value = false;
+      proxy.$alert(
+          "<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" +
+          e.msg +
+          "</div>",
+          "导入结果",
+          { dangerouslyUseHTMLString: true }
+      );
+    });
+}
 const setHeaders = {
   Authorization: getToken(),
 };
@@ -142,7 +169,7 @@ const uploadLoop = reactive({
   // 设置上传的请求头部
   headers: { Authorization: "Bearer " + getToken(), tenantId: getTenant() },
   // 上传的地址
-  url: "/ezhizao-yzbh-crm/upgrade/crm/order/importLoop",
+  url: "/ezhizao-yzbh-crm/upgrade/crm/order/checkInput",
 });
 const uploadOnce = reactive({
   // 是否禁用上传
@@ -251,7 +278,6 @@ function cancel() {
 }
 
 function submitForm() {
-
   submitFileForm();
 }
 
@@ -266,8 +292,9 @@ const importTemplate = () => {
 };
 
 function handleBeforeUpload(file) {
-  const formData = new FormData();
-  formData.append("file", file);
+  //const formData = new FormData();
+  refile = file
+  // formData.append("file", file);
   if (
     file.type !==
       "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" &&
@@ -277,29 +304,6 @@ function handleBeforeUpload(file) {
     return false;
   }
   fullLoading.value = true;
-  if(checksuccess.value === 0){
-    checkInput(formData).then(res =>{
-      fullLoading.value = false;
-      inputData.value = res.data;
-      if(res.data != null && res.msg !== "错误数据"){
-        return Promise.resolve()
-      }else if(res.msg === "错误数据"){
-        return Promise.reject(res.data);
-      }
-    }).then(()=>{
-      workOrderDialog.value.open()
-    }).catch((res)=>{
-      fullLoading.value = false;
-      proxy.$alert(
-          "<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" +
-          res +
-          "</div>",
-          "导入结果",
-          { dangerouslyUseHTMLString: true }
-      );
-    })
-    return false;
-  }
   return true;
 }
 
@@ -313,24 +317,30 @@ const handleFileUploadProgress = (event, file, fileList) => {
 };
 /** 文件上传成功处理 */
 const handleFileSuccess = (response, file, fileList) => {
+  inputData.value = response.data;
   fullLoading.value = false;
   checksuccess.value = 0;
-  if (addType === 1) {
+  if (addType.value === 1) {
     uploadLoop.open = false;
     uploadLoop.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 }
-    );
+    if("错误数据" === response.msg){
+      proxy.$alert(
+          "<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" +
+          response.data +
+          "</div>",
+          "导入结果",
+          { dangerouslyUseHTMLString: true }
+      );
+    }else{
+      workOrderDialog.value.open();
+    }
+
+
     getList.value();
   } else {
+    fullLoading.value = false;
     uploadOnce.open = false;
     uploadOnce.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 +
@@ -341,6 +351,10 @@ const handleFileSuccess = (response, file, fileList) => {
     getList.value();
   }
 };
+function remove(files, fileList) {
+  // file = files;
+ // importLoop(file).then(res =>{})
+}
 /** 提交上传文件 */
 function submitFileForm() {
   proxy.$refs["uploadRef"].submit();