tangning 11 months ago
parent
commit
b2fdebfb39
2 changed files with 42 additions and 15 deletions
  1. 40 13
      src/views/productOperation/modal/detailModal.vue
  2. 2 2
      src/views/sceneShare/addModal.vue

+ 40 - 13
src/views/productOperation/modal/detailModal.vue

@@ -25,7 +25,7 @@
   import { companyAdd, companyUpdate } from '/@/api/customer';
   import { useI18n } from '/@/hooks/web/useI18n';
   import { uploadApi } from '/@/api/product/index';
-  import { getByRyId, addAuth, checkAuthOtherApi } from '/@/api/operate';
+  import { getByRyId, getinnerByRyId, addAuth, checkAuthOtherApi } from '/@/api/operate';
   import { useModalInner } from '/@/components/Modal';
   import dayjs from 'dayjs';
 
@@ -118,19 +118,46 @@
           component: 'AutoComplete',
           label: '人员编号',
           required: true,
-          componentProps: {
-            filterOption: onFilterOption,
-            onSearch: onSearch,
-            onChange: (data) => {
-              setTimeout(() => {
-                const item = optionsName.value && optionsName.value.find((ele) => ele.ryNo == data);
-                setFieldsValue({
-                  ryNickName: item && item.ryNickName ? item.ryNickName : '',
-                  id: item && item.id ? item.id : '',
-                });
-              }, 100);
+          rules: [
+            {
+              required: true,
+              // @ts-ignore
+              validator: async (rule, value) => {
+                let myData = await getFieldsValue();
+                if (!value) {
+                  return Promise.reject('请输入人员编号');
+                }
+                let res = await getinnerByRyId({ ryNo: value });
+                console.log('value', value, res);
+                if (res && !res.data) {
+                  return Promise.reject('人员编号不存在');
+                }
+                Promise.resolve();
+                let ryNickName = res && res.data && res.data.ryNickName;
+                console.log('id', myData.id != ryNickName || !myData.id);
+                if(myData.ryNickName != ryNickName || !myData.ryNickName){
+                  setFieldsValue({
+                    ryNickName: res && res.data ? res.data.ryNickName : '',
+                    id: res && res.data ? res.data.id : '',
+                  });
+                }
+              },
+              trigger: 'blur',
             },
-          },
+          ],
+          // componentProps: {
+          //   filterOption: onFilterOption,
+          //   onSearch: onSearch,
+          //   onChange: (data) => {
+          //     setTimeout(() => {
+          //       const item = optionsName.value && optionsName.value.find((ele) => ele.ryNo == data);
+          //       setFieldsValue({
+          //         ryNickName: item && item.ryNickName ? item.ryNickName : '',
+          //         id: item && item.id ? item.id : '',
+          //       });
+          //     }, 100);
+          //   },
+          // },
           colProps: {
             span: 20,
           },

+ 2 - 2
src/views/sceneShare/addModal.vue

@@ -66,8 +66,8 @@
                   return Promise.reject('人员编号不存在');
                 }
                 Promise.resolve();
-                let id = res && res.data && res.data.id;
-                if(myData.id != id || !myData.id){
+                let ryNickName = res && res.data && res.data.ryNickName;
+                if(myData.ryNickName != ryNickName || !myData.ryNickName){
                   setFieldsValue({
                     ryNickName: res && res.data ? res.data.ryNickName : '',
                     id: res && res.data ? res.data.id : '',