Kaynağa Gözat

fix:修改批量修改校验

snow 1 yıl önce
ebeveyn
işleme
09ba8da909

+ 5 - 1
src/views/dataCorrection/managerBatchCorrection/columns.js

@@ -3,7 +3,6 @@ const columns = [
     prop: 'orderCode',
     label: '销售单编号',
     minWidth: '180',
-    _slot_: 'orderCode'
   },
   {
     prop: 'companyNo',
@@ -21,6 +20,11 @@ const columns = [
     _slot_: 'status',
     width: '90px'
   },
+  {
+    label: '业务经理(修改前)',
+    prop: 'old_manager',
+    minWidth: '185'
+  },
   {
     label: '业务经理(修改后)',
     prop: 'manager',

+ 23 - 11
src/views/dataCorrection/managerBatchCorrection/components/importTemplateModal.vue

@@ -8,9 +8,6 @@
     @close="() => {innerVisible = false; tableData = [];manager = ''; managerid = [];}"
   >
     <div v-if="tableData && tableData.length > 0" class="tr" style="padding: 10px 0 0 0;display:flex">
-      <!-- <el-button :size="'mini'" @click="() => tableData = []">取消</el-button>
-      <el-button type="primary" :size="'mini'" @click="onSubmit">提交</el-button> -->
-
       <project-manager size="mini" :is-detail="true" :names="manager" :value="managerid" @searchChange="manageridChange" />
 
       <el-button type="warning" size="mini" style="margin-left:10px" @click="batchSetting">批量设置</el-button>
@@ -33,7 +30,6 @@
 
 <script>
 import asyncRequest from '@/apis/service/dataCorrection/managerBatchCorrection'
-import { isMobile, isPhone, isnumber } from '@/utils/validate'
 import companyHelper from '@/mixins/companyHelper'
 import { MessageBox } from 'element-ui'
 import dayjs from 'dayjs'
@@ -47,7 +43,7 @@ import {
   createFieldVerification,
   requsetFields,
   requiredFields,
-  numberFields
+  orderCodeFields
 } from './template'
 
 export default {
@@ -93,7 +89,6 @@ export default {
       const newTableData = JSON.parse(JSON.stringify(this.tableData));
       const orderCodes = this.selected.map(({orderCode}) => orderCode);
 
-
       newTableData.forEach(item => {
         if(orderCodes.includes(item.orderCode)){
           item.managerid = this.managerid[0];
@@ -103,8 +98,6 @@ export default {
 
 
       this.tableData = newTableData;
-
-      console.log(this.tableData)
     },
     handleSelection(data){
       this.selected = data.list
@@ -133,7 +126,6 @@ export default {
 
       return isHeaderOk
     },
-    /* 所属平台、商品分类、商品名称、单位、收货人、收货地址、PO编号不能为空 **/
     validateRequiredField(requiredFields) {
       const verification = createFieldVerification('销售订单编号、导入业务经理名称,不能为空!')
       const fields = helper.fields(requiredFields)
@@ -147,6 +139,20 @@ export default {
 
       return verification
     },
+    validateCodeField(orderCodeFields) {
+      const verification = createFieldVerification('销售订单编号应该由字母和数字组成!')
+      const fields = helper.fields(orderCodeFields)
+
+      const reg = /^(?=.*[a-zA-Z])(?=.*\d)[a-zA-Z\d]+$/
+      orderCodeFields[fields[0]].forEach((_, index) => {
+        if (!helper.values(orderCodeFields, fields, index).every(value => value && reg.test(value))) {
+          verification.isValid = false
+          verification.notValidRows.push(index + 1)
+        }
+      })
+
+      return verification
+    },
     /* 处理不合法的值,提示错误信息,并返回最终的验证状态 **/
     handleNotValidFields(...validStates) {
       const messages = {}
@@ -187,7 +193,8 @@ export default {
       }
 
       return this.handleNotValidFields(
-        this.validateRequiredField(helper.write(mapTableFieldToTableData, requiredFields))
+        this.validateRequiredField(helper.write(mapTableFieldToTableData, requiredFields)),
+        this.validateCodeField(helper.write(mapTableFieldToTableData, orderCodeFields))
       )
     },
     mapTemplateItemToTableItem(templateItem) {
@@ -221,7 +228,12 @@ export default {
         const tableItem = this.mapTemplateItemToTableItem(templateItem)
         this.tableData.push(tableItem)
       })
-      this.validateFields(this.tableData).message()
+      const {isFinalValid, message} = this.validateFields(this.tableData)
+
+      if(!isFinalValid){
+        message();
+        this.tableData = [];
+      }
     },
     async onSubmit() {
       const { message, isFinalValid } = this.validateFields(this.tableData)

+ 3 - 2
src/views/dataCorrection/managerBatchCorrection/components/template.js

@@ -5,6 +5,7 @@ const mapTemplateToTable = {
 }
 
 export const getTableProperty = (key) => mapTemplateToTable[key]
+
 export const PROPERTYS = {
   ORDER_CODE: getTableProperty('销售订单编号'),
   IMPORT_MANAGER: getTableProperty('导入业务经理名称')
@@ -75,8 +76,8 @@ export const requiredFields = [
   PROPERTYS.IMPORT_MANAGER
 ]
 
-export const numberFields = [
-
+export const orderCodeFields = [
+  PROPERTYS.ORDER_CODE
 ]
 
 export const helper = {

+ 1 - 1
src/views/serviceParam/terrace/index.vue

@@ -256,7 +256,7 @@ export default {
       options: [
         { value: "0", label: "无对接" },
         { value: "1", label: "有赞平台" },
-        { value: "1", label: "BBC" }
+        { value: "2", label: "BBC" }
       ],
       // 表格 - 数据
       tableData: [],