fix: 完善 SPU 选择快递模版的功能

pull/159/head
puhui999 2023-05-31 15:37:26 +08:00
parent 39c92cb944
commit 2ddb605076
4 changed files with 28 additions and 8 deletions

View File

@ -33,6 +33,11 @@ export const getDeliveryExpressTemplate = async (id: number) => {
return await request.get({ url: '/trade/delivery/express-template/get?id=' + id })
}
// 查询快递运费模板详情
export const getSimpleTemplateList = async () => {
return await request.get({ url: '/trade/delivery/express-template/list-all-simple' })
}
// 新增快递运费模板
export const createDeliveryExpressTemplate = async (data: DeliveryExpressTemplateVO) => {
return await request.post({ url: '/trade/delivery/express-template/create', data })

View File

@ -28,7 +28,9 @@
</el-tabs>
<el-form>
<el-form-item style="float: right">
<el-button :loading="formLoading" type="primary" @click="submitForm"></el-button>
<el-button v-if="!isDetail" :loading="formLoading" type="primary" @click="submitForm">
保存
</el-button>
<el-button @click="close"></el-button>
</el-form-item>
</el-form>
@ -94,7 +96,9 @@ const formData = ref<ProductSpuApi.Spu>({
/** 获得详情 */
const getDetail = async () => {
console.log(name)
if ('productSpuDetail' === name) {
isDetail.value = true
}
const id = params.spuId as number
if (id) {
formLoading.value = true

View File

@ -67,7 +67,12 @@
<el-col :span="12">
<el-form-item label="运费模板" prop="deliveryTemplateId">
<el-select v-model="formData.deliveryTemplateId" placeholder="请选择">
<el-option v-for="item in []" :key="item.id" :label="item.name" :value="item.id" />
<el-option
v-for="item in deliveryTemplateList"
:key="item.id"
:label="item.name"
:value="item.id"
/>
</el-select>
<el-button class="ml-20px">运费模板</el-button>
</el-form-item>
@ -127,6 +132,9 @@
<template #brandId="{ row }">
{{ brandList.find((item) => item.id === row.brandId)?.name }}
</template>
<template #deliveryTemplateId="{ row }">
{{ deliveryTemplateList.find((item) => item.id === row.deliveryTemplateId)?.name }}
</template>
<template #specType="{ row }">
{{ row.specType ? '多规格' : '单规格' }}
</template>
@ -157,19 +165,19 @@
</template>
<script lang="ts" name="ProductSpuBasicInfoForm" setup>
import { PropType } from 'vue'
import { isArray } from '@/utils/is'
import { copyValueToTarget } from '@/utils'
import { propTypes } from '@/utils/propTypes'
import { checkSelectedNode, defaultProps, handleTree, treeToString } from '@/utils/tree'
import { createImageViewer } from '@/components/ImageViewer'
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
import type { Spu } from '@/api/mall/product/spu'
import { UploadImg, UploadImgs } from '@/components/UploadFile'
import { ProductAttributes, ProductAttributesAddForm, SkuList } from './index'
import { basicInfoSchema } from './spu.data'
import { createImageViewer } from '@/components/ImageViewer'
import type { Spu } from '@/api/mall/product/spu'
import * as ProductCategoryApi from '@/api/mall/product/category'
import { getSimpleBrandList } from '@/api/mall/product/brand'
import { isArray } from '@/utils/is'
import { getSimpleTemplateList } from '@/api/mall/trade/delivery/expressTemplate/index'
// ====== ======
const { allSchemas } = useCrudSchemas(basicInfoSchema)
/** 商品图预览 */
@ -345,11 +353,14 @@ const categoryString = (categoryId) => {
return treeToString(categoryList.value, categoryId)
}
const brandList = ref([]) //
const deliveryTemplateList = ref([]) //
onMounted(async () => {
//
const data = await ProductCategoryApi.getCategoryList({})
categoryList.value = handleTree(data, 'id', 'parentId')
//
brandList.value = await getSimpleBrandList()
//
deliveryTemplateList.value = await getSimpleTemplateList()
})
</script>

View File

@ -408,7 +408,7 @@ const openForm = (id?: number) => {
* 查看商品详情
*/
const openDetail = (id?: number) => {
push('/product/productSpuDetail' + id)
push('/product/productSpuDetail/' + id)
}
/** 导出按钮操作 */