From 94943df4f9a777a5c0c09f523232e8b47a1ec4d8 Mon Sep 17 00:00:00 2001 From: qsh <> Date: Wed, 5 Jun 2024 17:08:27 +0800 Subject: [PATCH] =?UTF-8?q?=E8=81=94=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/mall/product/brand.ts | 2 +- src/api/mall/product/category.ts | 7 +- src/api/mall/product/index.js | 4 + src/api/mall/product/property.ts | 4 +- src/api/mall/product/spu.ts | 92 ----- src/api/mall/purchase/index.js | 25 ++ src/api/system/dict/dict.data.ts | 2 +- src/api/system/library/index.js | 26 ++ src/api/system/library/resource.js | 26 ++ src/components/SSTable/index.vue | 6 +- src/components/UploadFile/src/UploadFile.vue | 14 +- src/components/UploadFile/src/UploadImg.vue | 5 +- src/utils/formatTime.ts | 2 +- .../Basic/Library/Comp/DialogLibrary.vue | 62 ++-- .../Basic/Library/Comp/DialogResource.vue | 126 +++++-- src/views/Basic/Library/Comp/ImagePreview.vue | 44 ++- src/views/Basic/Library/index.vue | 188 ++++++----- src/views/MiniMall/MallSet/Comp/BrandSet.vue | 17 +- .../MiniMall/MallSet/Comp/CategorySet.vue | 14 +- .../MiniMall/MallSet/Comp/DialogCategory.vue | 14 +- .../MiniMall/MallSet/Comp/DialogSupplier.vue | 36 +- .../MiniMall/MallSet/Comp/SupplierSet.vue | 67 ++-- .../Product/Comp/ProductAttributesAddForm.vue | 24 +- src/views/MiniMall/Product/Comp/SkuList.vue | 317 ------------------ src/views/MiniMall/Product/add.vue | 296 +++++++++++++--- src/views/MiniMall/Product/index.vue | 51 ++- .../MiniMall/Purchase/Comp/DialogAdd.vue | 130 ++++--- .../MiniMall/Purchase/Comp/DialogAudit.vue | 114 ++++--- src/views/MiniMall/Purchase/index.data.js | 16 +- src/views/MiniMall/Purchase/index.vue | 172 +++++++--- 30 files changed, 1063 insertions(+), 840 deletions(-) delete mode 100644 src/api/mall/product/spu.ts create mode 100644 src/api/mall/purchase/index.js create mode 100644 src/api/system/library/index.js create mode 100644 src/api/system/library/resource.js delete mode 100644 src/views/MiniMall/Product/Comp/SkuList.vue diff --git a/src/api/mall/product/brand.ts b/src/api/mall/product/brand.ts index d4a58c1..1173d98 100644 --- a/src/api/mall/product/brand.ts +++ b/src/api/mall/product/brand.ts @@ -57,5 +57,5 @@ export const getBrandParam = (params: PageParam) => { // 获得商品品牌精简信息列表 export const getSimpleBrandList = () => { - return request.get({ url: '/product/brand/list-all-simple' }) + return request.get({ url: '/admin-api/crm/erp-product-brand/simple-list' }) } diff --git a/src/api/mall/product/category.ts b/src/api/mall/product/category.ts index 61a61fb..9b40189 100644 --- a/src/api/mall/product/category.ts +++ b/src/api/mall/product/category.ts @@ -56,5 +56,10 @@ export const getCategory = (id: number) => { // 获得商品分类列表 export const getCategoryList = (params: any) => { - return request.get({ url: '/admin-api/crm/erp-product-category/page', params }) + return request.get({ url: '/admin-api/crm/erp-product-category/list', params }) +} + +// 获得商品分类列表 +export const getCategorySimpleList = (params: any) => { + return request.get({ url: '/admin-api/crm/erp-product-category/simple-list', params }) } diff --git a/src/api/mall/product/index.js b/src/api/mall/product/index.js index b4afa64..3d1d185 100644 --- a/src/api/mall/product/index.js +++ b/src/api/mall/product/index.js @@ -23,3 +23,7 @@ export const updateProduct = async (params) => { export const deleteProduct = async (id) => { return await request.delete({ url: '/admin-api/crm/erp-product/delete?id=' + id }) } + +export const getSimpleProductList = async () => { + return await request.get({ url: '/admin-api/crm/erp-product/simple-list' }) +} diff --git a/src/api/mall/product/property.ts b/src/api/mall/product/property.ts index ac8bac5..b9fb9b7 100644 --- a/src/api/mall/product/property.ts +++ b/src/api/mall/product/property.ts @@ -42,7 +42,7 @@ export interface PropertyValueDetailVO { // 创建属性项 export const createProperty = (data: PropertyVO) => { - return request.post({ url: '/product/property/create', data }) + return request.post({ url: '/admin-api/crm/erp-product-property/create', data }) } // 更新属性项 @@ -89,7 +89,7 @@ export const getPropertyValue = (id: number): Promise => { // 创建属性值 export const createPropertyValue = (data: PropertyValueVO) => { - return request.post({ url: '/product/property/value/create', data }) + return request.post({ url: '/admin-api/crm/erp-product-property-value/create', data }) } // 更新属性值 diff --git a/src/api/mall/product/spu.ts b/src/api/mall/product/spu.ts deleted file mode 100644 index fd55e12..0000000 --- a/src/api/mall/product/spu.ts +++ /dev/null @@ -1,92 +0,0 @@ -import request from '@/config/axios' - -export interface Property { - propertyId?: number // 属性编号 - propertyName?: string // 属性名称 - valueId?: number // 属性值编号 - valueName?: string // 属性值名称 -} - -// TODO puhui999:是不是直接叫 Sku 更简洁一点哈。type 待后面,总感觉有个类型? -export interface SkuType { - id?: number // 商品 SKU 编号 - spuId?: number // SPU 编号 - properties?: Property[] // 属性数组 - price?: number // 商品价格 - marketPrice?: number // 市场价 - costPrice?: number // 成本价 - barCode?: string // 商品条码 - picUrl?: string // 图片地址 - stock?: number // 库存 - weight?: number // 商品重量,单位:kg 千克 - volume?: number // 商品体积,单位:m^3 平米 - subCommissionFirstPrice?: number // 一级分销的佣金 - subCommissionSecondPrice?: number // 二级分销的佣金 - salesCount?: number // 商品销量 -} - -// TODO puhui999:是不是直接叫 Spu 更简洁一点哈。type 待后面,总感觉有个类型? -export interface SpuType { - id?: number - name?: string // 商品名称 - categoryId?: number | null // 商品分类 - keyword?: string // 关键字 - unit?: number | null // 单位 - picUrl?: string // 商品封面图 - sliderPicUrls?: string[] // 商品轮播图 - introduction?: string // 商品简介 - deliveryTemplateId?: number | null // 运费模版 - brandId?: number | null // 商品品牌编号 - specType?: boolean // 商品规格 - subCommissionType?: boolean // 分销类型 - skus: SkuType[] // sku数组 - description?: string // 商品详情 - sort?: string // 商品排序 - giveIntegral?: number // 赠送积分 - virtualSalesCount?: number // 虚拟销量 - recommendHot?: boolean // 是否热卖 - recommendBenefit?: boolean // 是否优惠 - recommendBest?: boolean // 是否精品 - recommendNew?: boolean // 是否新品 - recommendGood?: boolean // 是否优品 -} - -// 获得 Spu 列表 -export const getSpuPage = (params: PageParam) => { - return request.get({ url: '/product/spu/page', params }) -} - -// 获得 Spu 列表 tabsCount -export const getTabsCount = () => { - return request.get({ url: '/product/spu/get-count' }) -} - -// 创建商品 Spu -export const createSpu = (data: SpuType) => { - return request.post({ url: '/product/spu/create', data }) -} - -// 更新商品 Spu -export const updateSpu = (data: SpuType) => { - return request.put({ url: '/product/spu/update', data }) -} - -// 更新商品 Spu status -export const updateStatus = (data: { id: number; status: number }) => { - return request.put({ url: '/product/spu/update-status', data }) -} - -// 获得商品 Spu -export const getSpu = (id: number) => { - return request.get({ url: `/product/spu/get-detail?id=${id}` }) -} - -// 删除商品 Spu -export const deleteSpu = (id: number) => { - return request.delete({ url: `/product/spu/delete?id=${id}` }) -} - -// 导出商品 Spu Excel -export const exportSpu = async (params) => { - return await request.download({ url: '/product/spu/export', params }) -} diff --git a/src/api/mall/purchase/index.js b/src/api/mall/purchase/index.js new file mode 100644 index 0000000..97b2f5e --- /dev/null +++ b/src/api/mall/purchase/index.js @@ -0,0 +1,25 @@ +import request from '@/config/axios' +// 查询列表 +export const getPurchasePage = async (params) => { + return await request.get({ url: '/admin-api/crm/erp-purchase/page', params }) +} + +// 新增 +export const createPurchase = async (data) => { + return await request.post({ url: '/admin-api/crm/erp-purchase/create', data: data }) +} + +// 修改 +export const updatePurchase = async (params) => { + return await request.put({ url: '/admin-api/crm/erp-purchase/update', data: params }) +} + +// 删除 +export const deletePurchase = async (id) => { + return await request.delete({ url: '/admin-api/crm/erp-purchase/delete?id=' + id }) +} + +// 审核 +export const auditPurchase = async (params) => { + return await request.get({ url: '/admin-api/crm/erp-purchase/audit', params }) +} diff --git a/src/api/system/dict/dict.data.ts b/src/api/system/dict/dict.data.ts index deded27..3b38226 100644 --- a/src/api/system/dict/dict.data.ts +++ b/src/api/system/dict/dict.data.ts @@ -15,7 +15,7 @@ export type DictDataVO = { // 查询字典数据(精简)列表 export const listSimpleDictData = () => { - return request.get({ url: '/admin-api/system/dict-data/simple-list' }) + return request.get({ url: '/admin-api/crm/dict-data/simple-list' }) } // 查询字典数据列表 diff --git a/src/api/system/library/index.js b/src/api/system/library/index.js new file mode 100644 index 0000000..3dedfcf --- /dev/null +++ b/src/api/system/library/index.js @@ -0,0 +1,26 @@ +import request from '@/config/axios' + +// 查询知识库列表 +export const getLibraryPage = (params) => { + return request.get({ url: '/admin-api/crm/knowledge-lib/page', params }) +} + +// 查询知识库详情 +export const getLibrary = (id) => { + return request.get({ url: '/admin-api/crm/knowledge-lib/get?id=' + id }) +} + +// 新增知识库 +export const createLibrary = (data) => { + return request.post({ url: '/admin-api/crm/knowledge-lib/create', data }) +} + +// 修改知识库 +export const updateLibrary = (data) => { + return request.put({ url: '/admin-api/crm/knowledge-lib/update', data }) +} + +// 删除知识库 +export const deleteLibrary = (id) => { + return request.delete({ url: '/admin-api/crm/knowledge-lib/delete?id=' + id }) +} diff --git a/src/api/system/library/resource.js b/src/api/system/library/resource.js new file mode 100644 index 0000000..633244f --- /dev/null +++ b/src/api/system/library/resource.js @@ -0,0 +1,26 @@ +import request from '@/config/axios' + +// 查询资源列表 +export const getResourcePage = (params) => { + return request.get({ url: '/admin-api/crm/knowledge-lib-info/page', params }) +} + +// 查询资源详情 +export const getResource = (id) => { + return request.get({ url: '/admin-api/crm/knowledge-lib-info/get?id=' + id }) +} + +// 新增资源 +export const createResource = (data) => { + return request.post({ url: '/admin-api/crm/knowledge-lib-info/create', data }) +} + +// 修改资源 +export const updateResource = (data) => { + return request.put({ url: '/admin-api/crm/knowledge-lib-info/update', data }) +} + +// 删除资源 +export const deleteResource = (id) => { + return request.delete({ url: '/admin-api/crm/knowledge-lib-info/delete?id=' + id }) +} diff --git a/src/components/SSTable/index.vue b/src/components/SSTable/index.vue index 72dac3f..bcdfeb0 100644 --- a/src/components/SSTable/index.vue +++ b/src/components/SSTable/index.vue @@ -39,7 +39,7 @@ @@ -61,7 +61,7 @@ const emit = defineEmits(['update:tableObject', 'getList', 'getCheckedColumns']) const route = useRoute() const { id: userId } = useUserStore().user //取用户ID -const currentPage = ref(props.tableObject?.currentPage || 1) +const pageNo = ref(props.tableObject?.pageNo || 1) const pageSize = ref(props.tableObject?.pageSize || 20) @@ -74,7 +74,7 @@ const checkedColumns = ref([]) // 调用获取数据的接口,分页时需要使用 function getList({ page, limit }) { - emit('update:tableObject', { ...props.tableObject, currentPage: page, pageSize: limit }) + emit('update:tableObject', { ...props.tableObject, pageNo: page, pageSize: limit }) nextTick(() => { emit('getList') }) diff --git a/src/components/UploadFile/src/UploadFile.vue b/src/components/UploadFile/src/UploadFile.vue index 689d59b..bca62b8 100644 --- a/src/components/UploadFile/src/UploadFile.vue +++ b/src/components/UploadFile/src/UploadFile.vue @@ -34,20 +34,14 @@ diff --git a/src/views/Basic/Library/Comp/DialogResource.vue b/src/views/Basic/Library/Comp/DialogResource.vue index aca33c4..36019a9 100644 --- a/src/views/Basic/Library/Comp/DialogResource.vue +++ b/src/views/Basic/Library/Comp/DialogResource.vue @@ -1,6 +1,6 @@ - diff --git a/src/views/Basic/Library/Comp/ImagePreview.vue b/src/views/Basic/Library/Comp/ImagePreview.vue index 1ca05fb..d184dd1 100644 --- a/src/views/Basic/Library/Comp/ImagePreview.vue +++ b/src/views/Basic/Library/Comp/ImagePreview.vue @@ -1,7 +1,6 @@ - - - {{ info.title }} - - - {{ info.fileName }} - - - {{ - item - }} - - - {{ info.remark }} - - +
+
+
标题:
+
{{ info.title }}
+
+
+
文件名称:
+
{{ + info.files + }}
+
+
+
标签:
+
+ + {{ getDictLabel('knowledge_tags', item) }} + +
+
+
+
备注:
+
{{ info.remark }}
+
+
- +
{{ imgIndex + 1 }} / {{ imgList.length }}
diff --git a/src/views/MiniMall/MallSet/Comp/CategorySet.vue b/src/views/MiniMall/MallSet/Comp/CategorySet.vue index a8f753d..6a312fc 100644 --- a/src/views/MiniMall/MallSet/Comp/CategorySet.vue +++ b/src/views/MiniMall/MallSet/Comp/CategorySet.vue @@ -16,10 +16,10 @@ - - + + - + @@ -33,16 +33,16 @@ diff --git a/src/views/MiniMall/MallSet/Comp/DialogCategory.vue b/src/views/MiniMall/MallSet/Comp/DialogCategory.vue index 0468e14..f2362f5 100644 --- a/src/views/MiniMall/MallSet/Comp/DialogCategory.vue +++ b/src/views/MiniMall/MallSet/Comp/DialogCategory.vue @@ -7,7 +7,7 @@ :rules="formRules" label-width="80px" > - + @@ -71,12 +71,14 @@ const open = async (type, info) => { if (type == 'update') { formData.value = await ProductCategoryApi.getCategory(info.id) } else { - formData.value.level = info.level + 1 formData.value.parentCategory = info.name + formData.value.parentId = info.id } } finally { formLoading.value = false } + } else { + formData.value.parentId = 0 } } defineExpose({ open }) // 提供 open 方法,用于打开弹窗 @@ -91,12 +93,12 @@ const submitForm = async () => { // 提交请求 formLoading.value = true try { - if (formType.value === 'create') { + if (formType.value === 'update') { + await ProductCategoryApi.updateCategory(formData.value) + message.success(t('common.updateSuccess')) + } else { await ProductCategoryApi.createCategory(formData.value) message.success(t('common.createSuccess')) - } else { - await ProductCategoryApi.updateCategory(data) - message.success(t('common.updateSuccess')) } dialogVisible.value = false // 发送操作成功的事件 diff --git a/src/views/MiniMall/MallSet/Comp/DialogSupplier.vue b/src/views/MiniMall/MallSet/Comp/DialogSupplier.vue index 423d1ae..0581691 100644 --- a/src/views/MiniMall/MallSet/Comp/DialogSupplier.vue +++ b/src/views/MiniMall/MallSet/Comp/DialogSupplier.vue @@ -7,11 +7,11 @@ :rules="formRules" label-width="80px" > - - + + - - + + diff --git a/src/views/MiniMall/Product/Comp/ProductAttributesAddForm.vue b/src/views/MiniMall/Product/Comp/ProductAttributesAddForm.vue index 9ab56aa..e596cd2 100644 --- a/src/views/MiniMall/Product/Comp/ProductAttributesAddForm.vue +++ b/src/views/MiniMall/Product/Comp/ProductAttributesAddForm.vue @@ -6,6 +6,7 @@ :model="formData" :rules="formRules" label-width="80px" + @submit.prevent > @@ -33,7 +34,7 @@ const formRules = reactive({ name: [{ required: true, message: '名称不能为空', trigger: 'blur' }] }) const formRef = ref() // 表单 Ref -const attributeList = ref([]) // 商品属性列表 +const attributeList = ref([]) // 商品属性列表 const props = defineProps({ propertyList: { type: Array, @@ -69,17 +70,13 @@ const submitForm = async () => { formLoading.value = true try { const data = formData.value as PropertyApi.PropertyVO - // 检查属性是否已存在,如果有则返回属性和其下属性值 - const res = await PropertyApi.getPropertyListAndValue({ name: data.name }) - if (res.length === 0) { - const propertyId = await PropertyApi.createProperty(data) - attributeList.value.push({ id: propertyId, ...formData.value, values: [] }) - } else { - if (res[0].values === null) { - res[0].values = [] - } - attributeList.value.push(res[0]) // 因为只用一个 - } + const propertyId = await PropertyApi.createProperty(data) + // 添加到属性列表 + attributeList.value.push({ + id: propertyId + '', + ...formData.value, + values: [] + }) message.success(t('common.createSuccess')) dialogVisible.value = false } finally { @@ -90,8 +87,7 @@ const submitForm = async () => { /** 重置表单 */ const resetForm = () => { formData.value = { - name: '', - remark: '' + name: '' } formRef.value?.resetFields() } diff --git a/src/views/MiniMall/Product/Comp/SkuList.vue b/src/views/MiniMall/Product/Comp/SkuList.vue deleted file mode 100644 index 527f658..0000000 --- a/src/views/MiniMall/Product/Comp/SkuList.vue +++ /dev/null @@ -1,317 +0,0 @@ - - diff --git a/src/views/MiniMall/Product/add.vue b/src/views/MiniMall/Product/add.vue index a3b45b3..10a16e6 100644 --- a/src/views/MiniMall/Product/add.vue +++ b/src/views/MiniMall/Product/add.vue @@ -1,5 +1,5 @@ + > + + diff --git a/src/views/MiniMall/Product/index.vue b/src/views/MiniMall/Product/index.vue index 739bb2c..a006c7a 100644 --- a/src/views/MiniMall/Product/index.vue +++ b/src/views/MiniMall/Product/index.vue @@ -20,9 +20,9 @@ > @@ -33,6 +33,7 @@ placeholder="请选择分类" clearable filterable + :props="{ label: 'name', value: 'id', checkStrictly: true }" show-all-levels @change="handleQuery" /> @@ -40,7 +41,7 @@ 搜索 重置 - + 新增 @@ -53,6 +54,16 @@
+ + + + @@ -105,6 +116,9 @@ import { dateFormatter } from '@/utils/formatTime' import { createImageViewer } from '@/components/ImageViewer' import * as ProductApi from '@/api/mall/product' +import * as BrandApi from '@/api/mall/product/brand' +import * as CategoryApi from '@/api/mall/product/category' +import { handleTree } from '@/utils/tree' const { currentRoute, push } = useRouter() const message = useMessage() // 消息弹窗 @@ -143,8 +157,18 @@ async function handleDelete(id) { async function getList() { loading.value = true try { - const data = await ProductApi.getProductPage(queryParams.value) - tableList.value = data.list + const params = { ...queryParams.value } + if (params.productCategory && params.productCategory.length) { + params.productCategory = params.productCategory.at(-1) + } + const data = await ProductApi.getProductPage(params) + tableList.value = data.list.map((prod) => ({ + ...prod, + properties: prod.productSpecList[0].properties.map((item) => ({ + propertyId: item.propertyId, + label: item.propertyName + })) + })) total.value = data.total } finally { loading.value = false @@ -163,6 +187,15 @@ function handleQuery() { getList() } +async function getOptions() { + BrandApi.getSimpleBrandList().then((data) => { + opts.value.brand = data || [] + }) + CategoryApi.getCategorySimpleList().then((data) => { + opts.value.productCategory = handleTree(data || []) + }) +} + /** 重置按钮操作 */ function resetQuery() { queryParams.value = { @@ -182,7 +215,7 @@ function resetQuery() { */ function openForm(id) { // 修改 - if (typeof id == 'number') { + if (id) { push({ path: '/miniMall/productEdit', query: { id } @@ -201,6 +234,10 @@ watch( ) handleQuery() + +onMounted(() => { + getOptions() +})