diff --git a/src/api/pms/category.ts b/src/api/pms/category.ts index 43208e47..74828b50 100644 --- a/src/api/pms/category.ts +++ b/src/api/pms/category.ts @@ -1,4 +1,6 @@ import request from '@/utils/request'; +import { Option } from '@/types/common'; +import { AxiosPromise } from 'axios'; /** * 获取商品分类列表 @@ -9,7 +11,7 @@ export function listCategories(queryParams: object) { return request({ url: '/mall-pms/api/v1/categories', method: 'get', - params: queryParams, + params: queryParams }); } @@ -18,11 +20,10 @@ export function listCategories(queryParams: object) { * * @param queryParams */ -export function listCascadeCategories(queryParams?: object) { +export function listCategoryOptions(): AxiosPromise { return request({ - url: '/mall-pms/api/v1/categories/cascade', - method: 'get', - params: queryParams, + url: '/mall-pms/api/v1/categories/options', + method: 'get' }); } @@ -34,7 +35,7 @@ export function listCascadeCategories(queryParams?: object) { export function getCategoryDetail(id: number) { return request({ url: '/mall-pms/api/v1/categories/' + id, - method: 'get', + method: 'get' }); } @@ -47,7 +48,7 @@ export function addCategory(data: object) { return request({ url: '/mall-pms/api/v1/categories', method: 'post', - data: data, + data: data }); } @@ -61,7 +62,7 @@ export function updateCategory(id: number, data: object) { return request({ url: '/mall-pms/api/v1/categories/' + id, method: 'put', - data: data, + data: data }); } @@ -73,7 +74,7 @@ export function updateCategory(id: number, data: object) { export function deleteCategories(ids: string) { return request({ url: '/mall-pms/api/v1/categories/' + ids, - method: 'delete', + method: 'delete' }); } @@ -87,6 +88,6 @@ export function updateCategoryPart(id: number, data: object) { return request({ url: '/mall-pms/api/v1/categories/' + id, method: 'patch', - data: data, + data: data }); } diff --git a/src/api/sms/coupon.ts b/src/api/sms/coupon.ts index 6613a4fe..8ede02f3 100644 --- a/src/api/sms/coupon.ts +++ b/src/api/sms/coupon.ts @@ -11,11 +11,11 @@ import { AxiosPromise } from 'axios'; * * @param queryParams */ -export function lisCoupontPages( +export function lisCouponPages( queryParams: CouponQueryParam ): AxiosPromise { return request({ - url: '/mall-sms/api/v1/coupons', + url: '/mall-sms/api/v1/coupons/pages', method: 'get', params: queryParams }); diff --git a/src/types/api/sms/coupon.ts b/src/types/api/sms/coupon.ts index 29a4b795..8db46c5d 100644 --- a/src/types/api/sms/coupon.ts +++ b/src/types/api/sms/coupon.ts @@ -1,5 +1,4 @@ import { PageQueryParam, PageResult } from '../base'; -import { Option } from '@/types/common'; /** * 优惠券查询参数类型 @@ -51,6 +50,11 @@ export interface CouponFormData { * 优惠券类型(1:满减券;2:直减券;3:折扣券) */ type: number; + + /** + * 优惠券面值类型 + */ + faceValueType: number; /** * 优惠券面值 */ @@ -60,9 +64,9 @@ export interface CouponFormData { */ discount: number; /** - * 发放数量 + * 发行量 */ - issueCount: number; + circulation: number; /** * 使用门槛(0:无门槛) */ @@ -72,7 +76,7 @@ export interface CouponFormData { */ perLimit: number; /** - * 有效期类型(1:自领取之日起有效天数;2:有效起止时间) + * 有效期类型(1:日期范围;2:固定天数) */ validityPeriodType: number; /** @@ -88,34 +92,22 @@ export interface CouponFormData { */ validityEndTime: string; /** - * 使用类型(0:全场通用;1:指定商品分类;2:指定商品) + * 应用范围(0:全场通用;1:指定商品分类;2:指定商品) */ - useType: number; + applicationScope: number; /** * 使用类型:指定商品分类 */ - spuCategoryList: CouponSpuCategory[]; + spuCategoryIds: number[]; /** * 使用类型:指定商品 */ - spuList: CouponSpu[]; + spuIds: number[]; /** * 使用说明 */ remark: string; } - -export interface CouponSpuCategory { - id: number; - categoryId: number; - categoryName: string; -} - -export interface CouponSpu { - id: number; - spuId: number; - spuName: string; -} diff --git a/src/views/pms/goods/components/GoodsCategory.vue b/src/views/pms/goods/components/GoodsCategory.vue index 142c862f..a0c92035 100644 --- a/src/views/pms/goods/components/GoodsCategory.vue +++ b/src/views/pms/goods/components/GoodsCategory.vue @@ -41,34 +41,35 @@ import { ElCascaderPanel, ElMessage } from 'element-plus'; import { CaretRight } from '@element-plus/icons-vue'; // API 引用 -import { listCascadeCategories } from '@/api/pms/category'; +import { listCategoryOptions } from '@/api/pms/category'; import { computed } from '@vue/reactivity'; +import { Option } from '@/types/common'; const emit = defineEmits(['next', 'update:modelValue']); const props = defineProps({ modelValue: { type: Object, - default: () => {}, - }, + default: () => {} + } }); const goodsInfo: any = computed({ get: () => props.modelValue, - set: (value) => { + set: value => { emit('update:modelValue', value); - }, + } }); const state = reactive({ - categoryOptions: [], - pathLabels: [], + categoryOptions: [] as Option[], + pathLabels: [] }); const { categoryOptions, pathLabels } = toRefs(state); function loadData() { - listCascadeCategories().then((response) => { - state.categoryOptions = response.data; + listCategoryOptions().then(({ data }) => { + state.categoryOptions = data; if (goodsInfo.value.id) { nextTick(() => { handleCategoryChange(); diff --git a/src/views/pms/goods/index.vue b/src/views/pms/goods/index.vue index d2fe1a20..e3dacfb8 100644 --- a/src/views/pms/goods/index.vue +++ b/src/views/pms/goods/index.vue @@ -1,7 +1,7 @@ @@ -16,12 +16,13 @@ import { Edit, Refresh, Delete, - View, + View } from '@element-plus/icons-vue'; import { listSpuPages, deleteSpu } from '@/api/pms/goods'; -import { listCascadeCategories } from '@/api/pms/category'; +import { listCategoryOptions } from '@/api/pms/category'; import { GoodsItem, GoodsQueryParam } from '@/types/api/pms/goods'; import { moneyFormatter } from '@/utils/filter'; +import { Option } from '@/types/common'; const dataTableRef = ref(ElTable); const router = useRouter(); @@ -38,12 +39,12 @@ const state = reactive({ total: 0, queryParams: { pageNum: 1, - pageSize: 10, + pageSize: 10 } as GoodsQueryParam, goodsList: [] as GoodsItem[], - categoryOptions: [], + categoryOptions: [] as Option[], goodDetail: undefined, - dialogVisible: false, + dialogVisible: false }); const { @@ -54,7 +55,7 @@ const { categoryOptions, goodDetail, total, - dialogVisible, + dialogVisible } = toRefs(state); function handleQuery() { @@ -71,7 +72,7 @@ function resetQuery() { pageNum: 1, pageSize: 10, name: undefined, - categoryId: undefined, + categoryId: undefined }; handleQuery(); } @@ -88,7 +89,7 @@ function handleAdd() { function handleUpdate(row: any) { router.push({ path: 'goods-detail', - query: { goodsId: row.id, categoryId: row.categoryId }, + query: { goodsId: row.id, categoryId: row.categoryId } }); } @@ -97,7 +98,7 @@ function handleDelete(row: any) { ElMessageBox.confirm('是否确认删除选中的数据项?', '警告', { confirmButtonText: '确定', cancelButtonText: '取消', - type: 'warning', + type: 'warning' }) .then(function () { return deleteSpu(ids); @@ -119,8 +120,8 @@ function handleSelectionChange(selection: any) { } onMounted(() => { - listCascadeCategories({}).then((response) => { - state.categoryOptions = ref(response.data); + listCategoryOptions().then(({ data }) => { + categoryOptions.value = data; }); handleQuery(); }); diff --git a/src/views/sms/coupon/index.vue b/src/views/sms/coupon/index.vue index 49cd6fdb..6de85685 100644 --- a/src/views/sms/coupon/index.vue +++ b/src/views/sms/coupon/index.vue @@ -1,4 +1,4 @@ - +