From 1ffcde231c29b06a89aa3019d43676a01952bf93 Mon Sep 17 00:00:00 2001 From: jameszow Date: Tue, 24 Oct 2023 22:36:03 +0800 Subject: [PATCH 1/4] delete console print info --- src/views/product/info/components/ProductInfoModal.vue | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/views/product/info/components/ProductInfoModal.vue b/src/views/product/info/components/ProductInfoModal.vue index 384ac6e..d8b7d69 100644 --- a/src/views/product/info/components/ProductInfoModal.vue +++ b/src/views/product/info/components/ProductInfoModal.vue @@ -1319,11 +1319,6 @@ export default defineComponent({ } } - console.info(editableData) - console.info(meTable.dataSource) - // 我的editableData是一个对象,但是meTable.dataSource是一个数组, - // 我需要将数据覆盖到meTable.dataSource中 我的源数据是editableData 这里应该循环editableData - const product : AddProductReq = { productId: formState.productId, productName: formState.productName, From 7dcd74fd6d2bdd058e92ff55e37c74ae59718f38 Mon Sep 17 00:00:00 2001 From: jameszow Date: Wed, 25 Oct 2023 19:36:31 +0800 Subject: [PATCH 2/4] Add product model --- .../product/info/model/productInfoModel.ts | 99 +++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 src/views/product/info/model/productInfoModel.ts diff --git a/src/views/product/info/model/productInfoModel.ts b/src/views/product/info/model/productInfoModel.ts new file mode 100644 index 0000000..0ebe426 --- /dev/null +++ b/src/views/product/info/model/productInfoModel.ts @@ -0,0 +1,99 @@ + +export interface Column { + title: string; + key: string; + type: string; + placeholder: string; + validateRules?: { required: boolean; message: string }[]; + readonly?: boolean; + defaultValue?: string | number; +} + +export interface ProductAttributeModel { + id: number | string; + attributeName: string; + attributeValue: string; + remark: string; + sort: number; + disabled: boolean; +} + +export interface ProductImageModel { + productImageId: string; + imageName: string; + imageUrl: string; +} + +export interface ProductPriceModel { + key: number|string; + productPriceId: string; + barCode: number; + productUnit: string; + multiAttribute: string; + purchasePrice: number; + retailPrice: number; + salesPrice: number; + lowSalesPrice: number; +} + +export interface ProductStockModel { + key: number|string; + productStockId: number | string; + id: number | string; + warehouseName: string; + initStockQuantity: number; + lowStockQuantity: number; + highStockQuantity: number; +} + +export interface MeTable { + loading: boolean; + dataSource: ProductPriceModel[]; + columns: Column[]; +} + +export interface Stock { + loading: boolean; + dataSource: ProductStockModel[]; + columns: Column[]; +} + +export interface ProductInfo { + mfrs: string; + otherField1: string; + otherField2: string; + otherField3: string; +} + +export interface FormState { + productId: number | string | undefined; + productName: string | undefined; + productStandard: string | undefined; + productModel: string | undefined; + productUnit: string | undefined; + productUnitId: string | undefined; + productColor: string | undefined; + productWeight: number | undefined; + productExpiryNum: number | undefined; + productCategoryId: string | undefined; + enableSerialNumber: number | undefined; + enableBatchNumber: number | undefined; + warehouseShelves: string | undefined; + productManufacturer: string | undefined; + otherFieldOne: string | undefined; + otherFieldTwo: string | undefined; + otherFieldThree: string | undefined; + remark: string | undefined; +} + +export interface Unit { + id: number; + computeUnit: string + basicUnit: string; + otherUnit: string; + ratio: number; + otherUnitTwo: string; + ratioTwo: number; + otherUnitThree: string; + ratioThree: number; +} \ No newline at end of file From 7cf02072334478b80ed5f3aed3fc33358603b9d7 Mon Sep 17 00:00:00 2001 From: jameszow Date: Wed, 25 Oct 2023 19:37:26 +0800 Subject: [PATCH 3/4] Add model and cancel data use typescript #106 --- .../product/model/productAttributeModel.ts | 4 +- src/api/product/model/productModel.ts | 53 +++---- src/api/product/model/productUnitModel.ts | 2 +- src/api/product/productAttribute.ts | 8 +- src/api/product/productCategory.ts | 7 +- src/api/product/productUnit.ts | 8 +- src/views/product/info/info.data.ts | 136 +++++++++++++++++- 7 files changed, 170 insertions(+), 48 deletions(-) diff --git a/src/api/product/model/productAttributeModel.ts b/src/api/product/model/productAttributeModel.ts index 104e790..0a82fac 100644 --- a/src/api/product/model/productAttributeModel.ts +++ b/src/api/product/model/productAttributeModel.ts @@ -24,5 +24,7 @@ export interface AddOrUpdateProductAttributeReq { } export interface ProductAttributeListReq { - attributeName: string; + attributeName: string | undefined; + page: number; + pageSize: number; } \ No newline at end of file diff --git a/src/api/product/model/productModel.ts b/src/api/product/model/productModel.ts index edc7db4..8750fd7 100644 --- a/src/api/product/model/productModel.ts +++ b/src/api/product/model/productModel.ts @@ -19,34 +19,34 @@ export interface AddProductPriceReq { } export interface AddProductImageReq { - productImageId: number | string; - uid: string; - type: string; - status: string; - imageName: string; - imageUrl: string; - imageSize: number; + productImageId: number | string | null; + uid: string | null; + type: string | null | undefined; + status: string | null | undefined; + imageName: string | null; + imageUrl: string | null; + imageSize: number | null | undefined; } export interface AddProductReq { productId: number | string; productName: string; productStandard: string; - productModel: string; - productUnit: string | undefined, - productUnitId: number | string | undefined; - productColor: string; - productWeight: number; - productExpiryNum: number; - productCategoryId: number | string | undefined; - enableSerialNumber: number; - enableBatchNumber: number; - warehouseShelves: string; - remark: string; - productManufacturer: string; - otherFieldOne: string; - otherFieldTwo: string; - otherFieldThree: string; + productModel: string + productUnit: string + productUnitId: number | string; + productColor: string + productWeight: number | string; + productExpiryNum: number | string; + productCategoryId: number | string; + enableSerialNumber: number | string; + enableBatchNumber: number | string; + warehouseShelves: string + remark: string + productManufacturer: string + otherFieldOne: string + otherFieldTwo: string + otherFieldThree: string priceList: AddProductPriceReq[]; stockList: AddProductStockReq[]; imageList: AddProductImageReq[]; @@ -67,6 +67,8 @@ export interface QueryProductReq { export interface ProductInfoDetailResp { productId: string; productCategoryId: string; + productUnitId: string; + productUnit: string; productName: string; productStandard: string; productModel: string; @@ -81,17 +83,20 @@ export interface ProductInfoDetailResp { otherFieldOne: string; otherFieldTwo: string; otherFieldThree: string; + remark: string; priceList: ProductPriceResp[]; stockList: ProductStockResp[]; imageList: ProductImageResp[]; } export interface ProductImageResp { + productImageId: string; imageName: string; - iImageUrl: string; + imageUrl: string; } export interface ProductPriceResp { + productPriceId: string; barCode: number; productUnit: string; multiAttribute: string; @@ -102,7 +107,7 @@ export interface ProductPriceResp { } export interface ProductStockResp { - id: number | string; + productStockId: number | string; warehouseId: number | string; warehouseName: string; initStockQuantity: number; diff --git a/src/api/product/model/productUnitModel.ts b/src/api/product/model/productUnitModel.ts index 9a4065f..f23b9ed 100644 --- a/src/api/product/model/productUnitModel.ts +++ b/src/api/product/model/productUnitModel.ts @@ -22,7 +22,7 @@ export interface AddOrUpdateProductUnitReq { } export interface ProductUnitQueryReq { - computeUnit: string; + computeUnit: string | undefined; page: number; pageSize: number; } \ No newline at end of file diff --git a/src/api/product/productAttribute.ts b/src/api/product/productAttribute.ts index 75949a5..3a89d3a 100644 --- a/src/api/product/productAttribute.ts +++ b/src/api/product/productAttribute.ts @@ -10,16 +10,12 @@ enum Api { GetAttributeById = '/product/attribute/getValuesById', } -export function getAttributeList(params: ProductAttributeListReq ,mode: ErrorMessageMode = 'notice') { +export function getAttributeList(params: ProductAttributeListReq) { return defHttp.post>( { url: Api.List, params, - }, - { - errorMessageMode: mode, - successMessageMode: mode, - }, + } ); } diff --git a/src/api/product/productCategory.ts b/src/api/product/productCategory.ts index 10f3309..6097d0a 100644 --- a/src/api/product/productCategory.ts +++ b/src/api/product/productCategory.ts @@ -9,14 +9,11 @@ enum Api { deleteBatch = '/product/category/deleteBatch', } -export function getCategoryList(mode: ErrorMessageMode = 'notice') { +export function getCategoryList() { return defHttp.get>( { url: Api.List, - }, - { - errorMessageMode: mode, - }, + } ); } diff --git a/src/api/product/productUnit.ts b/src/api/product/productUnit.ts index cad1037..8f69c71 100644 --- a/src/api/product/productUnit.ts +++ b/src/api/product/productUnit.ts @@ -10,16 +10,12 @@ enum Api { UpdateStatus = '/product/unit/updateUnitStatus', } -export function getUnitList(params: ProductUnitQueryReq ,mode: ErrorMessageMode = 'notice') { +export function getUnitList(params: ProductUnitQueryReq) { return defHttp.post>( { url: Api.List, params, - }, - { - errorMessageMode: mode, - successMessageMode: mode, - }, + } ); } diff --git a/src/views/product/info/info.data.ts b/src/views/product/info/info.data.ts index f756915..21c9e3b 100644 --- a/src/views/product/info/info.data.ts +++ b/src/views/product/info/info.data.ts @@ -1,15 +1,18 @@ import {FormSchema} from "@/components/Form"; import {BasicColumn} from "@/components/Table"; -import { h } from 'vue'; +import {h, reactive, ref} from 'vue'; import {Switch} from "ant-design-vue"; import {useMessage} from "@/hooks/web/useMessage"; import {useI18n} from "@/hooks/web/useI18n"; import {updateProductStatus} from "@/api/product/product"; import {getCategoryList} from "@/api/product/productCategory"; +import {FormState, MeTable, ProductInfo, ProductStockModel, Stock} from "@/views/product/info/model/productInfoModel"; +import {UnwrapRef} from "vue/dist/vue"; +import {AddProductReq, AddProductStockReq} from "@/api/product/model/productModel"; const { t } = useI18n(); -export const columns: BasicColumn[] = [ +const columns: BasicColumn[] = [ { title: '条码', dataIndex: 'productBarcode', @@ -109,7 +112,7 @@ export const columns: BasicColumn[] = [ } ] -export const searchFormSchema: FormSchema[] = [ +const searchFormSchema: FormSchema[] = [ { label: '商品类别', field: 'productCategoryId', @@ -217,6 +220,129 @@ export const searchFormSchema: FormSchema[] = [ }, ] -export const formSchema: FormSchema[] = [ +const meTable: MeTable = reactive({ + loading: false, + dataSource: ref([]), + columns: [ + { + title: '条码', + key: 'barCode', + type: 'inputNumber', + placeholder: '请输入${title}', + validateRules: [ + { required: true, message: '条码不能为空' }, + { pattern: /^.{4,40}$/, message: '长度为4到40位' }, + ], + }, + { + title: '单位', + key: 'productUnit', + type: 'input', + placeholder: '请输入${title}', + validateRules: [{ required: true, message: '单位不能为空' }], + }, + { + title: '多属性', + key: 'multiAttribute', + type: 'input', + readonly: true, + placeholder: '请输入${title}', + }, + { + title: '采购价', + key: 'purchasePrice', + type: 'inputNumber', + defaultValue: '', + placeholder: '请输入${title}', + }, + { + title: '零售价', + key: 'retailPrice', + type: 'inputNumber', + defaultValue: '', + placeholder: '请输入${title}', + }, + { + title: '销售价', + key: 'salesPrice', + type: 'inputNumber', + defaultValue: '', + placeholder: '请输入${title}', + }, + { + title: '最低售价', + key: 'lowSalesPrice', + type: 'inputNumber', + defaultValue: '', + placeholder: '请输入${title}', + }, + ], +}); + +const stock: Stock = reactive({ + loading: false, + dataSource: ref([]), + columns: [ + { + title: '仓库', + key: 'warehouseName', + type: 'input', + }, + { + title: '期初库存数量', + key: 'initStockQuantity', + type: 'inputNumber', + placeholder: '请输入${title}', + }, + { + title: '最低安全库存数量', + key: 'lowStockQuantity', + type: 'inputNumber', + placeholder: '请输入${title}', + }, + { + title: '最高安全库存数量', + key: 'highStockQuantity', + type: 'inputNumber', + placeholder: '请输入${title}', + }, + ], +}); + +const formState: AddProductReq = reactive({ + productId: '', + productName: '', + productStandard: '', + productModel: '', + productUnit: '', + productUnitId: null, + productColor: '', + productWeight: null, + productExpiryNum: null, + productCategoryId: null, + enableSerialNumber: null, + enableBatchNumber: null, + remark: '', + warehouseShelves: '', + productManufacturer: '', + otherFieldOne: '', + otherFieldTwo: '', + otherFieldThree: '', +}); + +const productInfo: ProductInfo = reactive({ + mfrs: '制造商', + otherField1: '自定义1', + otherField2: '自定义2', + otherField3: '自定义3', +}); + -] \ No newline at end of file +export { + columns, + searchFormSchema, + meTable, + stock, + formState, + productInfo, +}; \ No newline at end of file From 80432048ae8710e6f10aa5d0ce649c40b34d9ee8 Mon Sep 17 00:00:00 2001 From: jameszow Date: Wed, 25 Oct 2023 19:37:46 +0800 Subject: [PATCH 4/4] Fix typescript syntax errors #106 --- .../info/components/ProductInfoModal.vue | 383 ++++++------------ 1 file changed, 127 insertions(+), 256 deletions(-) diff --git a/src/views/product/info/components/ProductInfoModal.vue b/src/views/product/info/components/ProductInfoModal.vue index d8b7d69..22f4120 100644 --- a/src/views/product/info/components/ProductInfoModal.vue +++ b/src/views/product/info/components/ProductInfoModal.vue @@ -55,7 +55,7 @@ placeholder="选择多单位" v-model:value="formState.productUnitId" :rules="[{ required: true}]" - @change="manyUnitOnChange" + @change="manyUnitOnChange(formState.productUnitId)" showSearch optionFilterProp="children" :dropdownMatchSelectWidth="false" @@ -151,7 +151,7 @@ 需要先录入单位才能激活 - + {{ item.attributeName }} @@ -165,7 +165,7 @@ :wrapperCol="{xs: { span: 24 },sm: { span: 20 }}" :label="skuOneTitle"> - + {{ item.value }} @@ -176,7 +176,7 @@ :wrapperCol="{xs: { span: 24 },sm: { span: 20 }}" :label="skuTwoTitle"> - + {{ item.value }} @@ -187,7 +187,7 @@ :wrapperCol="{xs: { span: 24 },sm: { span: 20 }}" :label="skuThreeTitle"> - + {{ item.value }} @@ -214,7 +214,7 @@ bordered :row-selection="rowSelection" :scroll="{ x: '100%', y: 300 }"> -