Skip to content

Commit

Permalink
Add model and cancel data use typescript #106
Browse files Browse the repository at this point in the history
  • Loading branch information
Jzow committed Oct 25, 2023
1 parent 7dcd74f commit 7cf0207
Show file tree
Hide file tree
Showing 7 changed files with 170 additions and 48 deletions.
4 changes: 3 additions & 1 deletion src/api/product/model/productAttributeModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,7 @@ export interface AddOrUpdateProductAttributeReq {
}

export interface ProductAttributeListReq {
attributeName: string;
attributeName: string | undefined;
page: number;
pageSize: number;
}
53 changes: 29 additions & 24 deletions src/api/product/model/productModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[];
Expand All @@ -67,6 +67,8 @@ export interface QueryProductReq {
export interface ProductInfoDetailResp {
productId: string;
productCategoryId: string;
productUnitId: string;
productUnit: string;
productName: string;
productStandard: string;
productModel: string;
Expand All @@ -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;
Expand All @@ -102,7 +107,7 @@ export interface ProductPriceResp {
}

export interface ProductStockResp {
id: number | string;
productStockId: number | string;
warehouseId: number | string;
warehouseName: string;
initStockQuantity: number;
Expand Down
2 changes: 1 addition & 1 deletion src/api/product/model/productUnitModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export interface AddOrUpdateProductUnitReq {
}

export interface ProductUnitQueryReq {
computeUnit: string;
computeUnit: string | undefined;
page: number;
pageSize: number;
}
8 changes: 2 additions & 6 deletions src/api/product/productAttribute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<BaseDataResp<ProductAttributeResp>>(
{
url: Api.List,
params,
},
{
errorMessageMode: mode,
successMessageMode: mode,
},
}
);
}

Expand Down
7 changes: 2 additions & 5 deletions src/api/product/productCategory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,11 @@ enum Api {
deleteBatch = '/product/category/deleteBatch',
}

export function getCategoryList(mode: ErrorMessageMode = 'notice') {
export function getCategoryList() {
return defHttp.get<BaseDataResp<ProductCategoryResp>>(
{
url: Api.List,
},
{
errorMessageMode: mode,
},
}
);
}

Expand Down
8 changes: 2 additions & 6 deletions src/api/product/productUnit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<BaseDataResp<ProductUnitResp>>(
{
url: Api.List,
params,
},
{
errorMessageMode: mode,
successMessageMode: mode,
},
}
);
}

Expand Down
136 changes: 131 additions & 5 deletions src/views/product/info/info.data.ts
Original file line number Diff line number Diff line change
@@ -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',
Expand Down Expand Up @@ -109,7 +112,7 @@ export const columns: BasicColumn[] = [
}
]

export const searchFormSchema: FormSchema[] = [
const searchFormSchema: FormSchema[] = [
{
label: '商品类别',
field: 'productCategoryId',
Expand Down Expand Up @@ -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',
});


]
export {
columns,
searchFormSchema,
meTable,
stock,
formState,
productInfo,
};

0 comments on commit 7cf0207

Please sign in to comment.