Преглед изворни кода

fix(nugs): 修改tapd上面问题

tangning пре 3 година
родитељ
комит
4682542903

+ 1 - 0
src/locales/lang/ja/routes/devices.ts

@@ -47,6 +47,7 @@ export default {
   unbindWarning: '現在のアカウントのバインドを解除するかどうか?',
   addeduser: '追加されたアカウントの数',
   subNum: '機器数量',
+  deviceCode: 'デバイスIDが重複しています。再入力してください',
 
   // normalSales: '正常销售',
   // normalSales: '正常销售',

+ 1 - 1
src/locales/lang/zh-CN/routes/devices.ts

@@ -48,7 +48,7 @@ export default {
   addeduser: '已添加员工数',
   num: '设备数量',
   subNum: '可添加员工数',
-
+  deviceCode: '设备ID重复,请重新输入',
   // normalSales: '正常销售',
   // normalSales: '正常销售',
 };

+ 108 - 105
src/views/corporation/AddCorporationModal.vue

@@ -21,110 +21,6 @@
   import { useI18n } from '/@/hooks/web/useI18n';
   import { uploadLogoApi, insertCompnayApi } from '/@/api/corporation/list';
   const { t } = useI18n();
-  const schemas: FormSchema[] = [
-    {
-      field: 'companyName',
-      component: 'Input',
-      required: true,
-      label: t('routes.corporation.enterpriseName'),
-      componentProps: {
-        maxLength: 20,
-      },
-      colProps: {
-        span: 22,
-      },
-    },
-    {
-      field: 'managerPhone',
-      component: 'Input',
-      label: t('sys.login.corporationMail'),
-      rules: [
-        {
-          required: true,
-          // @ts-ignore
-          validator: async (rule, value) => {
-            // var reg_tel =
-            //   /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/;
-            var reg = /\S+@\S+\.\S+/;
-            if (!value) {
-              /* eslint-disable-next-line */
-
-              return Promise.reject(t('sys.login.fillMail'));
-            }
-            if (!reg.test(value)) {
-              /* eslint-disable-next-line */
-              return Promise.reject(t('sys.login.fillMailCorrect'));
-            }
-            return Promise.resolve();
-          },
-          trigger: 'change',
-        },
-      ],
-      colProps: {
-        span: 22,
-      },
-    },
-    {
-      field: 'managerName',
-      component: 'Input',
-      label: t('routes.corporation.managerName'),
-
-      required: true,
-      componentProps: {
-        maxLength: 85,
-      },
-      colProps: {
-        span: 22,
-      },
-    },
-    {
-      field: 'address',
-      component: 'Input',
-      label: t('routes.corporation.address'),
-      required: true,
-      colProps: {
-        span: 22,
-      },
-      componentProps: {
-        maxLength: 50,
-      },
-    },
-    {
-      field: 'logo',
-      component: 'Upload',
-      label: t('routes.corporation.companyLogo'),
-      required: true,
-      rules: [{ required: true, message: '请选择上传文件' }],
-      helpMessage: '支持png  jpg图片格式',
-      componentProps: {
-        api: uploadLogoApi,
-        maxNumber: 1,
-        maxSize: 10,
-        accept: ['jpg', 'jpeg', 'gif', 'png'],
-        afterFetch: function (data) {
-          console.log('data', data);
-          Reflect.set(data, 'url', data.data);
-          return data;
-        },
-      },
-
-      colProps: {
-        span: 22,
-      },
-    },
-    {
-      field: 'introduce',
-      component: 'InputTextArea',
-      label: t('routes.corporation.introduce'),
-      required: true,
-      colProps: {
-        span: 22,
-      },
-      componentProps: {
-        maxLength: 200,
-      },
-    },
-  ];
   export default defineComponent({
     components: { BasicModal, BasicForm },
     props: {
@@ -134,12 +30,119 @@
     setup(props, { emit }) {
       const modelRef = ref({});
       const { createMessage } = useMessage();
+      const schemas: FormSchema[] = [
+        {
+          field: 'companyName',
+          component: 'Input',
+          required: true,
+          label: t('routes.corporation.enterpriseName'),
+          componentProps: {
+            maxLength: 20,
+          },
+          colProps: {
+            span: 22,
+          },
+        },
+        {
+          field: 'managerPhone',
+          component: 'Input',
+          label: t('sys.login.corporationMail'),
+          rules: [
+            {
+              required: true,
+              // @ts-ignore
+              validator: async (rule, value) => {
+                // var reg_tel =
+                //   /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/;
+                var reg = /\S+@\S+\.\S+/;
+                if (!value) {
+                  /* eslint-disable-next-line */
+
+                  return Promise.reject(t('sys.login.fillMail'));
+                }
+                if (!reg.test(value)) {
+                  /* eslint-disable-next-line */
+                  return Promise.reject(t('sys.login.fillMailCorrect'));
+                }
+                return Promise.resolve();
+              },
+              trigger: 'change',
+            },
+          ],
+          colProps: {
+            span: 22,
+          },
+        },
+        {
+          field: 'managerName',
+          component: 'Input',
+          label: t('routes.corporation.managerName'),
+
+          required: true,
+          componentProps: {
+            maxLength: 85,
+          },
+          colProps: {
+            span: 22,
+          },
+        },
+        {
+          field: 'address',
+          component: 'Input',
+          label: t('routes.corporation.address'),
+          required: true,
+          colProps: {
+            span: 22,
+          },
+          componentProps: {
+            maxLength: 50,
+          },
+        },
+        {
+          field: 'logo',
+          component: 'Upload',
+          label: t('routes.corporation.companyLogo'),
+          required: true,
+          rules: [{ required: true, message: '请选择上传文件' }],
+          helpMessage: '支持png  jpg图片格式',
+          componentProps: {
+            api: uploadLogoApi,
+            maxNumber: 1,
+            maxSize: 10,
+            onChange: async () => {
+              await validateFields(['logo']);
+            },
+            accept: ['jpg', 'jpeg', 'gif', 'png'],
+            afterFetch: function (data) {
+              console.log('data', data);
+              Reflect.set(data, 'url', data.data);
+              return data;
+            },
+          },
+
+          colProps: {
+            span: 22,
+          },
+        },
+        {
+          field: 'introduce',
+          component: 'InputTextArea',
+          label: t('routes.corporation.introduce'),
+          required: true,
+          colProps: {
+            span: 22,
+          },
+          componentProps: {
+            maxLength: 200,
+          },
+        },
+      ];
       const [
         registerForm,
         {
           // getFieldsValue,
           // setFieldsValue,
-          // setProps
+          validateFields,
           resetFields,
           validate,
         },

+ 43 - 102
src/views/corporation/deviceModal.vue

@@ -27,17 +27,38 @@
             @press-enter="deviceMapping"
           >
             <template #addonBefore>
-              <a-button size="small" type="link" @click="handleMinusDevice">
+              <a-button
+                :disabled="modelRef.mappingLength == 0"
+                size="small"
+                type="link"
+                @click="handleMinusDevice"
+              >
                 <Icon icon="ic:baseline-minus" :size="20" />
               </a-button>
             </template>
             <template #addonAfter>
-              <a-button size="small" type="link" @click="handlePlusDevice">
+              <a-button
+                :disabled="modelRef.mappingLength == 20"
+                size="small"
+                type="link"
+                @click="handlePlusDevice"
+              >
                 <Icon icon="ic:round-plus" :size="20" />
               </a-button>
             </template>
           </input-number>
         </template>
+        <template #IDInput="{ model, field }">
+          <Input v-model:value="model[field]" />
+          <a-button
+            :disabled="modelRef.mappingLength == 0"
+            size="small"
+            type="link"
+            @click="handleMinusDevice"
+          >
+            <Icon icon="ic:baseline-minus" :size="20" />
+          </a-button>
+        </template>
       </BasicForm>
     </div>
   </BasicModal>
@@ -47,7 +68,7 @@
   import { BasicModal, useModalInner } from '/@/components/Modal';
   import { BasicForm, FormSchema, useForm } from '/@/components/Form/index';
   import { useMessage } from '/@/hooks/web/useMessage';
-  import { InputNumber } from 'ant-design-vue';
+  import { InputNumber, Input } from 'ant-design-vue';
   // AddDevice
   import { checkDevice, AddDevice } from '/@/api/corporation/modal';
   import { useI18n } from '/@/hooks/web/useI18n';
@@ -55,7 +76,7 @@
   import { clamp, range } from 'lodash-es';
 
   export default defineComponent({
-    components: { BasicModal, BasicForm, InputNumber, Icon },
+    components: { BasicModal, BasicForm, InputNumber, Icon, Input },
     props: {
       userData: { type: Object },
     },
@@ -74,8 +95,19 @@
         data && onDataReceive(data);
       });
 
-      const handlevalidator = async (_, value) => {
-        console.log('handlevalidator', value);
+      const handlevalidator = async (item, value) => {
+        let values = getFieldsValue();
+        console.log('handlevalidator', value, item, values);
+        let childNameList: string[] = [];
+        Object.keys(values).map((ele) => {
+          if (ele.includes('ID') && item.field !== ele) {
+            childNameList.push(values[ele]);
+          }
+        });
+        const issort = childNameList.some((element) => element == value);
+        if (issort) {
+          return Promise.reject(t('routes.devices.deviceCode'));
+        }
         if (!value) {
           return Promise.resolve();
         }
@@ -158,42 +190,6 @@
         },
       });
 
-      // async function submitModal() {
-      //   let formData = {
-      //     ...getFieldsValue(),
-      //   };
-      //   let validate = false;
-      //   try {
-      //     const res = await validateFields();
-      //     validate = true;
-      //     console.log('passing', res, formData);
-      //   } catch (error: unknown) {
-      //     console.log('not passing', error);
-      //   }
-      //   if (validate) {
-      //     const { subNum, id, userName } = modelRef.value;
-      //     let childNameList = [];
-      //     Object.keys(formData).map((ele) => {
-      //       if (ele.includes('ID')) {
-      //         childNameList.push(formData[ele]);
-      //       }
-      //     });
-      //     console.log('modelRef.value', Object.keys(formData), childNameList);
-      //     try {
-      //       const res = await AddDevice({
-      //         childNames: childNameList as any as string[],
-      //         companyId: id,
-      //         subNum: String(subNum),
-      //         userName,
-      //       });
-      //       success(res);
-      //       closeModal();
-      //     } catch (errors) {
-      //       // error('errors');
-      //       // console.log('not passing', error);
-      //     }
-      //   }
-      // }
       async function submitModal() {
         try {
           const values = await validate();
@@ -227,62 +223,6 @@
         });
       }
 
-      // function numOnChange(data) {
-      //   const value = Number(data);
-      //   if (num.value > value) {
-      //     //减
-      //     let delList = Array.from(new Array(num.value)).map((_, index) => {
-      //       console.log(index, value, num.value);
-      //       if (index >= value) {
-      //         return `ID${index}`;
-      //       }
-      //     });
-
-      //     removeSchemaByFiled(delList as any as string[]);
-      //     console.log('schemasList减', value, num.value, delList);
-      //     // value,num.value,schemasList.filter((_,index) => {return !(index<num.value)}).map((_,index) => `ID${index}`))
-      //   } else {
-      //     //增
-      //     let device = t('routes.corporation.device');
-      //     let schemasList: FormSchema[] = Array.from(new Array(value)).map((_, index) => {
-      //       return {
-      //         field: `ID${index}`,
-      //         component: 'Input',
-      //         label: device + 'ID' + index,
-      //         helpMessage: [t('common.checkTips'), `${device} ${t('common.unusual')}`],
-      //         itemProps: {
-      //           validateTrigger: 'blur',
-      //         },
-      //         colProps: {
-      //           span: 24,
-      //         },
-      //         rules: [
-      //           {
-      //             required: true,
-      //             message: `${t('common.inputText')} ${device} ID`,
-      //           },
-      //           {
-      //             validator: handlevalidator,
-      //           },
-      //         ],
-      //       };
-      //     });
-      //     console.log(
-      //       'schemasList增',
-      //       num.value,
-      //       schemasList.filter((_, index) => {
-      //         return index >= num.value;
-      //       }),
-      //     );
-      //     schemasList
-      //       .filter((_, index) => {
-      //         return index >= num.value;
-      //       })
-      //       .forEach((item) => appendSchemaByField(item, ''));
-      //   }
-      //   num.value = value;
-      // }
-
       function handleVisibleChange(v) {
         v && props.userData && nextTick(() => onDataReceive(props.userData));
       }
@@ -302,13 +242,14 @@
             field: `ID${startIndex}`,
             component: 'Input',
             label: `${t('routes.corporation.device')} ID  ${startIndex}`,
-            helpMessage: [
-              t('common.checkTips'),
-              `${t('routes.corporation.device')} ${t('common.unusual')}`,
-            ],
+            // helpMessage: [
+            //   t('common.checkTips'),
+            //   `${t('routes.corporation.device')} ${t('common.unusual')}`,
+            // ],
             itemProps: {
               validateTrigger: 'blur',
             },
+            // slot: 'IDInput',
             colProps: {
               span: 24,
             },

+ 3 - 2
src/views/staff/list.vue

@@ -17,12 +17,12 @@
               onClick: () => {
                 createMessage.info(t('common.notConnect'));
               },
+              icon: 'mdi:information-outline',
             },-->
       <template #action="{ record }">
         <TableAction
           :actions="[
             {
-              icon: 'mdi:information-outline',
               label: t('routes.staff.setpaswd'),
               onClick: handleOpenModal.bind(null, record),
             },
@@ -107,7 +107,8 @@
           dataIndex: '',
           slots: { customRender: 'action' },
           fixed: 'right',
-          width: isJA.value ? 160 : 120,
+          align: 'center',
+          width: isJA.value ? 160 : 80,
         },
       ];
 

+ 1 - 1
src/views/sys/login/RegisterForm.vue

@@ -28,7 +28,6 @@
           :fieldProps="{ autocomplete: 'new-password' }"
           :sendCodeApi="sendEmailCode"
         />
-        <!-- :sendCodeApi="" -->
       </FormItem>
       <FormItem name="password" class="enter-x">
         <StrengthMeter
@@ -124,6 +123,7 @@
     if (!form) {
       return Promise.resolve(false);
     }
+    await form.validateFields(['managerPhone']);
     const mail_reg = /\S+@\S+\.\S+/;
     if (formData.managerPhone?.length > 0 && formData.managerPhone.match(mail_reg)) {
       try {