Procházet zdrojové kódy

feat: 页面更新

Lk před 2 roky
rodič
revize
973c4e134e

+ 0 - 4
.husky/commit-msg

@@ -1,4 +0,0 @@
-#!/usr/bin/env sh
-. "$(dirname -- "$0")/_/husky.sh"
-
-npx --no-install commitlint --edit

+ 0 - 4
.husky/pre-commit

@@ -1,4 +0,0 @@
-#!/usr/bin/env sh
-. "$(dirname -- "$0")/_/husky.sh"
-
-pnpm pre-commit

+ 0 - 4
.husky/pre-rebase

@@ -1,4 +0,0 @@
-#!/usr/bin/env sh
-. "$(dirname -- "$0")/_/husky.sh"
-
-pnpm pre-commit

+ 2 - 6
package.json

@@ -68,12 +68,7 @@
     }
   },
   "lint-staged": {
-    "**/*/*.css": [
-      "stylelint"
-    ],
-    "**/*/*.{js,jsx,ts,tsx,vue}": [
-      "eslint"
-    ]
+    
   },
   "dependencies": {
     "@icon-park/vue-next": "^1.4.2",
@@ -93,6 +88,7 @@
     "sortablejs": "^1.15.0",
     "veboundary": "1.2.2",
     "vee-validate": "^4.9.3",
+    "vite-vue-proste": "link:",
     "vue": "^3.3.2",
     "vue-final-modal": "^4.4.2",
     "vue-i18n": "^9.2.2",

+ 3 - 0
pnpm-lock.yaml

@@ -56,6 +56,9 @@ dependencies:
   vee-validate:
     specifier: ^4.9.3
     version: 4.9.3(vue@3.3.2)
+  vite-vue-proste:
+    specifier: 'link:'
+    version: 'link:'
   vue:
     specifier: ^3.3.2
     version: 3.3.2

+ 9 - 1
src/apis/customer.ts

@@ -4,7 +4,6 @@ import {
   VendorListData,
   BaseListResult,
   getCustomer,
-  AddCustomerData,
   getCustomerData,
   getModelParams,
   getModelData,
@@ -46,3 +45,12 @@ export function getModel(data?: getModelParams): BaseResult<getModelData> {
     data,
   });
 }
+/** 新增型号 */
+export function getAddModel(cCusModelName: string): BaseResult {
+  return request({
+    method: 'POST',
+    url: BASE_URL + '/addCustomerModel',
+    data: {cCusModelName},
+  });
+}
+

+ 35 - 3
src/apis/inventory.ts

@@ -2,13 +2,15 @@ import {
   GetInventoryParams,
   BaseResult,
   MplanInventoryParams,
+  EditInventoryParams,
+  AddInventoryParams,
   BaseListResult,
   GetInventoryData,
 } from '@models';
 import {request} from './network';
 
 const BASE_URL = '/inventory';
-/** 查询检验标准列表 */
+/** 查询物料管理列表 */
 export function GetInventoryList(
   data: GetInventoryParams,
 ): BaseListResult<GetInventoryData> {
@@ -18,7 +20,7 @@ export function GetInventoryList(
     data,
   });
 }
-/** 查询检验标准列表 */
+/** 查询物料管理列表 */
 export function GetInventoryInfo(
   id: string,
 ): BaseListResult<GetInventoryData> {
@@ -31,10 +33,40 @@ export function GetInventoryInfo(
 /** 物料管理导出 */
 export function exportInventory(
   data: GetInventoryParams,
-): any {
+): BaseResult {
   return request({
     method: 'GET',
     url: BASE_URL + '/inventoryExport',
     data,
   });
 }
+/** 新增物料管理 */
+export function addInventory(
+  data: AddInventoryParams,
+): BaseResult {
+  return request({
+    method: 'POST',
+    url: BASE_URL + '/addInventory',
+    data,
+  });
+}
+/** 删除物料 */
+export function DeleteInventory(
+  id: string,
+): BaseResult {
+  return request({
+    method: 'DELETE',
+    url: BASE_URL + '/delInventory',
+    data: {id},
+  });
+}
+/** 修改物料 */
+export function updateInventory(
+  data: EditInventoryParams,
+): BaseResult {
+  return request({
+    method: 'PUT',
+    url: BASE_URL + '/updateInventory',
+    data,
+  });
+}

+ 67 - 99
src/components/customSelect/index.tsx

@@ -4,32 +4,10 @@ import {computed, defineComponent, ref, PropType} from 'vue';
 import {selectProps, NSelect, NEmpty, NButton, useMessage} from 'naive-ui';
 import {useField} from 'vee-validate';
 import {debounce} from 'lodash-es';
-import { useI18n } from 'vue-i18n';
-import {BaseResultContent, BaseResult} from '@models';
-import {GetCustomer, addCustomer}from '@apis'
-import { useMutation, useQuery, useQueryClient } from '@tanstack/vue-query';
-
-async function mockGetList() {
-  return await new Promise<{msg: '200', data: {id: string, name:string}[]}>(function(res){
-    setTimeout(function() {
-      res({
-        msg: '200',
-        data: [{id: '1', name: 'simon'}, {id: '2', name: 'david'}]
-      });
-    }, 2000);
-  })
-}
-
-async function mockAdd(name: string){
-  return await new Promise<{msg: '200', data: string}>(function(res){
-    setTimeout(function() {
-      res({
-        msg: '200',
-        data: '12',
-      });
-    }, 2000);
-  })
-}
+import {useI18n} from 'vue-i18n';
+import {BaseResult, BaseResultContent} from '@models';
+import {addCustomer, getAddModel} from '@apis';
+import {useMutation, useQuery, useQueryClient} from '@tanstack/vue-query';
 
 export default defineComponent({
   name: 'LDSelectInput',
@@ -43,18 +21,21 @@ export default defineComponent({
       required: true,
     },
     getFn: {
-      type: Function as PropType<() => BaseResult<{name: string,id: string}[]>>,
+      type: Function as PropType<
+        () => BaseResult<{name: string, id: string}[]>
+      >,
       required: true,
     },
-    addFn: {
-      type: Function as PropType<() => BaseResult<{data:string}>>,
+    getAdd: {
+      type: Function as PropType<(name: string) => BaseResult<string>>,
       required: true,
     },
     optional: Boolean,
     multiple: selectProps.multiple,
   },
   setup(props) {
-    const {value, setValue, errorMessage} = useField<string | string[]>(
+    const {value, setValue, errorMessage}
+    = useField<string | string[]>(
       props.name,
       void 0,
       {validateOnMount: false, validateOnValueUpdate: false},
@@ -64,89 +45,75 @@ export default defineComponent({
     const showOptions = ref(false);
 
     // 请求options
-    // const {isFetching, data} = useQuery({
-    //   queryKey: [GetCustomer.name],
-    //   async queryFn () {
-    //     const data = await GetCustomer();
-        
-    //     if(data.msg === '200') return data.data.map(function({cCusName}, index) {
-    //       return {label: cCusName, value:(index+1).toString() };
-    //     });
-
-    //     return [];
-    //   },
-    //   initialData: [],
-    // })
-    //函数传过来有ts提示错误目前为解决
     const {isFetching, data} = useQuery({
       queryKey: [props.getFn.name],
-      async queryFn () {
+      async queryFn() {
         const data = await props.getFn();
-        
-        if(data.msg === '200') return data.data.map(function({name, id}) {
-          return {label: name, value:id };
-        });
+
+        if (data.msg === '200') {
+          return data.data.map(function({id, name}) {
+            return {label: name, value: id};
+          });
+        }
 
         return [];
       },
       initialData: [],
-    })
-    
+    });
+    const filterValue = ref<string>('');
+    const filterOptions = computed(function() {
+      const options = data.value;
+      if (!filterValue.value) return options;
+
+      return options.filter(function(val) {
+        return (val?.label ?? '').includes(filterValue.value)
+         || (val?.value ?? '').includes(filterValue.value);
+      });
+    });
+    const onDefaultSearch = debounce(
+      function(value: string) {
+        filterValue.value = value;
+      },
+      0,
+      {
+        trailing: true,
+        leading: false,
+      },
+    );
+
     // 新增options
     const client = useQueryClient();
     const {isLoading, mutate} = useMutation({
-      mutationFn: addCustomer,
-      onSuccess(data, variables){
-        if(data.msg === '200'){
+      mutationFn: props.getAdd,
+      onSuccess(data, variables) {
+        if (data.msg === '200') {
           const id = data.data;
           const name = variables;
+
           client.setQueryData<{label: string, value: string}[]>(
-            [mockGetList.name],
+            [props.getFn.name],
             function(data) {
               return [...(data ?? []), {label: name, value: id}];
-            }
+            },
           );
-
           setValue(id);
           showOptions.value = false;
         }
-      }
+      },
     });
     const message = useMessage();
     function onAdd() {
-      if(!filterValue.value) return message.warning('请输入客户名称');
+      if (!filterValue.value) return message.warning('请输入客户名称');
 
       mutate(filterValue.value);
     }
 
     function onUpdateShow(state: boolean) {
-      if(isLoading.value) return;
+      if (isLoading.value) return;
 
       showOptions.value = state;
     }
 
-    const filterValue = ref<string>('');
-    const filterOptions = computed(function() {
-      const options = data.value;
-
-      if (!filterValue.value) return options;
-
-      return options.filter(function(val) {
-        console.log((val?.value as string ?? ''))
-        return (val?.label as string ?? '').includes(filterValue.value)
-         || (val?.value as string ?? '').includes(filterValue.value);
-      });
-    });
-    const onDefaultSearch = debounce(
-      function(value: string) {
-        filterValue.value = value;
-      },
-      0,
-      {
-        trailing: true,
-        leading: false,
-      },
-    );
     // 失去焦点之后判断是否有搜索结果
     // 如果没有搜索结果将搜索值清空
     // 防止没搜索到之后失去焦点再返回会显示空选项
@@ -158,9 +125,6 @@ export default defineComponent({
     }
 
     const {t} = useI18n();
-
-
-
     return () => (
       <div class="ld-modal-field-wrapper">
         <div class="ld-modal-field-group">
@@ -182,25 +146,29 @@ export default defineComponent({
             onUpdateValue={setValue}
             onSearch={onDefaultSearch}
             onBlur={onBlur}
-            on-update:show={onUpdateShow}
+            onUpdateShow={onUpdateShow}
           >
-            {{empty() {
-              return <NEmpty description="未查到客户,点击新增按钮新增客户信息">
-                {{extra() {
-                  return <NButton 
-                    disabled={isLoading.value} 
-                    loading={isLoading.value}
-                    onClick={onAdd}
-                  >
+            {{
+              empty() {
+                return <NEmpty description="未查到客户,点击新增按钮新增客户信息">
+                  {{
+                    extra() {
+                      return <NButton
+                        disabled={isLoading.value}
+                        loading={isLoading.value}
+                        onClick={onAdd}
+                      >
                     新增
-                  </NButton>
-                }}}
-              </NEmpty>
-            }}}
+                      </NButton>;
+                    },
+                  }}
+                </NEmpty>;
+              },
+            }}
           </NSelect>
         </div>
         <p class="ld-modal-filed-error">{errorMessage.value && t(errorMessage.value)}</p>
       </div>
     );
   },
-});
+});

+ 10 - 8
src/locales/inventory.ts

@@ -3,14 +3,15 @@ export default {
     label: '物料管理',
     filter: ['型号', '图纸号', 'ERP CODE', '供应商名称'],
     table: ['客户', '型号', 'ERP CODE', '图纸号', '品名', '供应商名称', '单价', '生产周期'],
-    AddTable: ['客户', '型号'],
+    AddTable: ['客户', '型号', 'ERP CODE', '图纸号', '品名'],
     modal: {
       title: ['新增物料管理', '修改物料管理'],
       errors: [
-        '请选择月份',
+        '请选择客户',
         '请选择型号',
-        '请输入客户名称',
-        '请输入计划数量',
+        '请输入ERP CODE',
+        '图纸号',
+        '品名',
       ],
     },
   },
@@ -18,14 +19,15 @@ export default {
     label: '物料管理',
     filter: ['型号', '图纸号', 'ERP CODE', '供应商名称'],
     table: ['客户', '型号', 'ERP CODE', '图纸号', '品名', '供应商名称', '单价', '生产周期'],
-    AddTable: ['客户', '型号'],
+    AddTable: ['客户', '型号', 'ERP CODE', '图纸号', '品名'],
     modal: {
       title: ['新增物料管理', '修改物料管理'],
       errors: [
-        '请选择月份',
+        '请选择客户',
         '请选择型号',
-        '请输入客户名称',
-        '请输入计划数量',
+        '请输入ERP CODE',
+        '图纸号',
+        '品名',
       ],
     },
   },

+ 0 - 4
src/models/request/customer.ts

@@ -4,10 +4,6 @@ export type getCustomer = {
     cCusName?: string;
     cCusCode?: string;
 };
-//新增客户
-export type AddCustomerData = {
-    id: string
-};
 //查询型号
 export type getModelParams = {
     cCusModelName?: string;

+ 40 - 0
src/models/request/inventory.ts

@@ -19,3 +19,43 @@ export type MplanInventoryParams = {
   token: string
 
 } & ListParams;
+
+//新增物料管理
+export type AddInventoryParams = {
+//  /**
+//      * 客户编号
+//      */
+//  cCusName: string;
+//  /**
+//   * 型号编号
+//   */
+//  cCusModelName: string;
+ /**
+  * 品名,物料名称
+  */
+ cInvName: string;
+ /**
+  * ERP编码,物料编码
+  */
+ erpCode: string;
+ /**
+  * 图纸号
+  */
+ pcode: string;
+};
+//新增物料管理
+export type EditInventoryParams = {
+  id: string;
+   /**
+    * 品名,物料名称
+    */
+   cInvName: string;
+   /**
+    * ERP编码,物料编码
+    */
+   erpCode: string;
+   /**
+    * 图纸号
+    */
+   pcode: string;
+  };

+ 4 - 0
src/models/response/inventory.ts

@@ -15,4 +15,8 @@ export type GetInventoryData = {
   price: string;
   //生产周期
   supDays: string;
+  //客户编码
+  cInvDefine1: string;
+  //型号编码
+  cInvDefine2: string;
 };

+ 14 - 4
src/pages/check/table/modal/info.vue

@@ -1,7 +1,13 @@
 <script setup lang='ts'>
-import {LDModalInput, LDModalSelect} from '@components';
+import {LDModalInput, LDSelectInput} from '@components';
 import {useQueryDataInfo} from '@hooks';
-import {getAllRole, GetCheckInfo} from '@apis';
+import {
+  GetCustomer,
+  GetCheckInfo,
+  addCustomer,
+  getModel,
+  getAddModel,
+} from '@apis';
 import {computed, watchEffect} from 'vue';
 import {useI18n} from 'vue-i18n';
 import type {FormState} from './hooks';
@@ -70,12 +76,16 @@ const authorityOptions = computed(function() {
 
 <template>
   <div class="model-box">
-    <LDModalInput
+    <LDSelectInput
       name="cCusName"
       :label="t('check.AddTable1[0]')"
+      :getFn="GetCustomer"
+      :getAdd="addCustomer"
     />
-    <LDModalInput
+    <LDSelectInput
+      :getFn="getModel"
       name="cCusModelName"
+      :getAdd="getAddModel"
       :label="t('check.AddTable1[1]')"
     />
     <LDModalInput

+ 3 - 3
src/pages/inventory/table/hooks.ts

@@ -1,5 +1,5 @@
 import {searchSymbol, pageSymbol, filterSymbol} from '../state';
-import {GetInventoryList, delMplan, resetPassword} from '@apis';
+import {GetInventoryList, DeleteInventory, resetPassword} from '@apis';
 import {type DataTableColumn, NSpace, useMessage, useDialog} from 'naive-ui';
 import {GetCheckListParams} from '@models';
 import {
@@ -28,9 +28,9 @@ export function useColumns(refetch: () => void) {
   ] = useTableModalEvent();
 
   const [deleteId, onDelete] = useTableDeleteEvent(
-    delMplan,
+    DeleteInventory,
     refetch,
-    {label: t('user.label')},
+    {label: t('inventory.label')},
   );
 
   const columns = computed<DataTableColumn<GetCheckListParams>[]>(function() {

+ 18 - 1
src/pages/inventory/table/index.vue

@@ -17,7 +17,24 @@ const [isExporting, onExport] = useTableExportEvent(
   pageSymbol,
   {fn: exportInventory},
 );
-console.log(columns, data);
+// const datas = [
+//   {
+//     ErpCode: 'ERD111',
+//     Pcode: '111',
+//     cCusModelName: '型号3',
+//     cCusName: '山西传媒有限公司',
+//     cInvName: '液压轴',
+//     id: 4,
+//   },
+//   {
+//     ErpCode: 'ERD111',
+//     Pcode: '111',
+//     cCusModelName: '型号3',
+//     cCusName: '山西传媒有限公司',
+//     cInvName: '液压轴',
+//     id: 4,
+//   },
+// ];
 </script>
 <template>
   <NCard class="table-wrapper">

+ 48 - 30
src/pages/inventory/table/modal/hooks.ts

@@ -1,13 +1,19 @@
-import {AddMplan, EditMplan} from '@apis';
+import {addInventory, updateInventory} from '@apis';
 import {usePutData} from '@hooks';
-import {AddUserParams, AddMplanParams} from '@models';
+import {AddUserParams, AddInventoryParams} from '@models';
 import {formatValidateError} from '@utils';
 import {toTypedSchema} from '@vee-validate/zod';
 import {useForm} from 'vee-validate';
 import {Ref, watchEffect} from 'vue';
 import {object, string, number} from 'zod';
 
-export type FormState = Omit<AddMplanParams, 'Plansnum'>;
+export type FormState = Omit<AddInventoryParams, ''> &
+{
+  cCusName: string,
+  cCusModelName: string,
+  cInvDefine1: string,
+  cInvDefine2: string,
+};
 
 export function useFormState(
   id: Ref<string>,
@@ -16,31 +22,37 @@ export function useFormState(
 ) {
   const {handleSubmit, setErrors, setValues, resetField} = useForm<FormState>({
     initialValues: {
-      plandate: '',
-      cCusModelName: '',
       cCusName: '',
-      PlanNum: 0,
+      cCusModelName: '',
+      erpCode: '',
+      pcode: '',
+      cInvName: '',
+      cInvDefine1: '',
+      cInvDefine2: '',
     },
 
     validationSchema: toTypedSchema(object({
-      plandate: string(formatValidateError('mplan.modal.errors[0]'))
-        .min(1, 'mplan.modal.errors[0]'),
-      cCusModelName: string(formatValidateError('mplan.modal.errors[1]'))
-        .min(1, 'mplan.modal.errors[1]'),
-      cCusName: string(formatValidateError('mplan.modal.errors[2]'))
-        .min(1, 'mplan.modal.errors[2]'),
-      PlanNum: string(formatValidateError('mplan.modal.errors[3]'))
-        .min(1, 'mplan.modal.errors[3]'),
-    })),
+      cCusName: string(formatValidateError('inventory.modal.errors[0]'))
+        .min(1, 'inventory.modal.errors[0]'),
+      cCusModelName: string(formatValidateError('inventory.modal.errors[1]'))
+        .min(1, 'inventory.modal.errors[1]'),
+      erpCode: string(formatValidateError('inventory.modal.errors[2]'))
+        .min(1, 'inventory.modal.errors[2]'),
+      pcode: string(formatValidateError('inventory.modal.errors[3]'))
+        .min(1, 'inventory.modal.errors[3]'),
+      cInvName: string(formatValidateError('inventory.modal.errors[4]'))
+        .min(1, 'inventory.modal.errors[4]'),
+    }).passthrough()),
   });
 
   watchEffect(function() {
     if (visible.value) {
       setErrors({
-        plandate: void 0,
         cCusModelName: void 0,
         cCusName: void 0,
-        PlanNum: void 0,
+        pcode: void 0,
+        erpCode: void 0,
+        cInvName: void 0,
       });
     }
   });
@@ -48,27 +60,33 @@ export function useFormState(
   const {onFetch, onClose} = options;
 
   const [isLoading, {addMutate, editMutate}] = usePutData({
-    addFn: AddMplan,
-    editFn: EditMplan,
+    addFn: addInventory,
+    editFn: updateInventory,
     onFetch,
     onClose,
   });
 
   const onSubmit = handleSubmit(function({
-    plandate,
-    cCusModelName,
     cCusName,
-    PlanNum,
+    cCusModelName,
+    erpCode,
+    pcode,
+    cInvName,
+    cInvDefine1,
+    cInvDefine2,
   }) {
-    const parasm: AddMplanParams = {
-      plandate,
-      cCusModelName,
-      cCusName,
-      PlanNum,
+    console.log(cCusName);
+    const parasm: AddInventoryParams &
+    {cInvDefine1: string, cInvDefine2: string} = {
+      cInvDefine1: id.value.length > 0 ? cInvDefine1 : cCusName,
+      cInvDefine2: id.value.length > 0 ? cInvDefine2 : cCusModelName,
+      erpCode,
+      pcode,
+      cInvName,
     };
-    id.value.length > 0
-      ? editMutate({plansnum: id.value, ...parasm})
-      : addMutate(parasm);
+    // id.value.length > 0
+    //   ? editMutate({id: id.value, ...parasm})
+    //   : addMutate(parasm);
   });
 
   return [isLoading, {setValues, onSubmit}] as const;

+ 38 - 21
src/pages/inventory/table/modal/info.vue

@@ -1,7 +1,13 @@
 <script setup lang='ts'>
 import {LDModalInput, LDSelectInput} from '@components';
 import {useQueryDataInfo} from '@hooks';
-import {getModel, GetMplanInfo, GetCustomer} from '@apis';
+import {
+  getModel,
+  getAddModel,
+  addCustomer,
+  GetCustomer,
+  GetInventoryInfo,
+} from '@apis';
 import {computed, watchEffect} from 'vue';
 import {useI18n} from 'vue-i18n';
 import type {FormState} from './hooks';
@@ -15,7 +21,7 @@ type Props = {
 
 const props = defineProps<Props>();
 const [data, suspense] = useQueryDataInfo({
-  queryFn: GetMplanInfo,
+  queryFn: GetInventoryInfo,
   params: computed<[id: string]>(() => [props.id]),
   enabled: computed(() => props.id.length > 0),
 });
@@ -24,19 +30,24 @@ if (props.id.length > 0) await suspense();
 
 watchEffect(function() {
   const {
-    plandate = '',
     cCusModelName = '',
     cCusName = '',
-    PlanNum = '' as unknown as number,
+    ErpCode = '',
+    Pcode = '',
+    cInvName = '',
+    cInvDefine1 = '',
+    cInvDefine2 = '',
   } = data.value ?? {};
   props.setValues({
-    plandate,
-    cCusModelName,
-    cCusName,
-    PlanNum,
+    cCusModelName: cInvDefine2,
+    cCusName: cInvDefine1,
+    erpCode: ErpCode,
+    pcode: Pcode,
+    cInvName,
+    cInvDefine1,
+    cInvDefine2,
   });
 });
-
 const {t} = useI18n();
 
 // const {isLoading, data: options} = useQuery({
@@ -57,22 +68,28 @@ const {t} = useI18n();
 <template>
   <div class="model-box">
     <LDSelectInput
-    name="cCusName"
-    :getFn=GetCustomer
-    :label="t('inventory.AddTable[0]')"
+      name="cCusName"
+      :label="t('inventory.AddTable[0]')"
+      :getFn="GetCustomer"
+      :getAdd="addCustomer"
+    />
+    <LDSelectInput
+      :getFn="getModel"
+      name="cCusModelName"
+      :getAdd="getAddModel"
+      :label="t('inventory.AddTable[1]')"
+    />
+    <LDModalInput
+      name="erpCode"
+      :label="t('inventory.AddTable[2]')"
     />
-    <!-- <LDSelectInput
-    :getFn=getModel
-    name="cCusModelName"
-    :label="t('inventory.AddTable[1]')"
-    /> -->
     <LDModalInput
-      name="plandate"
-      :label="t('mplan.AddTable[0]')"
+      name="pcode"
+      :label="t('inventory.AddTable[3]')"
     />
     <LDModalInput
-      name="PlanNum"
-      :label="t('mplan.AddTable[3]')"
+      name="cInvName"
+      :label="t('inventory.AddTable[4]')"
     />
   </div>
 </template>

+ 0 - 1
src/pages/login/login-info/index.vue

@@ -16,7 +16,6 @@ defineOptions({name: 'LoginInfo'});
 const [remberPassword, toggleRemberPassword] = useToggle(
   Boolean(localStorage.getItem(USER_PASSWORD_LOGIN_STORAGE)),
 );
-
 const {t} = useI18n();
 
 const [{isLoading, isCompanyLoading}, onSubmit] = useFormState(remberPassword);