code review:门店自提、快递运费

This commit is contained in:
YunaiV 2023-06-03 19:52:14 +08:00
parent 000aa95012
commit 60c1604d49
5 changed files with 51 additions and 25 deletions

View File

@ -47,8 +47,3 @@ export const updateDeliveryExpressTemplate = async (data: DeliveryExpressTemplat
export const deleteDeliveryExpressTemplate = async (id: number) => { export const deleteDeliveryExpressTemplate = async (id: number) => {
return await request.delete({ url: '/trade/delivery/express-template/delete?id=' + id }) return await request.delete({ url: '/trade/delivery/express-template/delete?id=' + id })
} }
// 导出快递运费模板 Excel
export const exportDeliveryExpressTemplateApi = async (params) => {
return await request.download({ url: '/trade/delivery/express-template/export-excel', params })
}

View File

@ -89,7 +89,7 @@
<el-table border style="width: 100%" :data="formData.templateFree"> <el-table border style="width: 100%" :data="formData.templateFree">
<el-table-column align="center" label="区域"> <el-table-column align="center" label="区域">
<template #default="{ row }"> <template #default="{ row }">
<!-- 区域数据太多用赖加载方式要不然性能有问题 --> <!-- 区域数据太多用赖加载方式要不然性能有问题 -->
<el-tree-select <el-tree-select
v-model="row.areaIds" v-model="row.areaIds"
multiple multiple
@ -171,7 +171,10 @@ const formRules = reactive({
sort: [{ required: true, message: '分类排序不能为空', trigger: 'blur' }] sort: [{ required: true, message: '分类排序不能为空', trigger: 'blur' }]
}) })
const formRef = ref() // Ref const formRef = ref() // Ref
const areaCache = ref([]) // const areaCache = ref([]) //
// TODO @jason
// TODO @jaosn
/** 打开弹窗 */ /** 打开弹窗 */
const open = async (type: string, id?: number) => { const open = async (type: string, id?: number) => {
dialogVisible.value = true dialogVisible.value = true
@ -204,9 +207,9 @@ const open = async (type: string, id?: number) => {
} }
item.freePrice = fenToYuan(item.freePrice) item.freePrice = fenToYuan(item.freePrice)
}) })
// //
const areaIds = chargeAreaIds.concat(freeAreaIds) const areaIds = chargeAreaIds.concat(freeAreaIds)
// //
areaCache.value = await getAreaListByIds(areaIds.join(',')) areaCache.value = await getAreaListByIds(areaIds.join(','))
} }
} finally { } finally {
@ -226,8 +229,9 @@ const submitForm = async () => {
formLoading.value = true formLoading.value = true
try { try {
const data = formData.value as DeliveryExpressTemplateApi.DeliveryExpressTemplateVO const data = formData.value as DeliveryExpressTemplateApi.DeliveryExpressTemplateVO
//
// TODO @jason
data.templateCharge.forEach((item) => { data.templateCharge.forEach((item) => {
//
item.startPrice = yuanToFen(item.startPrice) item.startPrice = yuanToFen(item.startPrice)
item.extraPrice = yuanToFen(item.extraPrice) item.extraPrice = yuanToFen(item.extraPrice)
}) })
@ -248,6 +252,7 @@ const submitForm = async () => {
formLoading.value = false formLoading.value = false
} }
} }
/** 重置表单 */ /** 重置表单 */
const resetForm = () => { const resetForm = () => {
formData.value = { formData.value = {
@ -269,6 +274,7 @@ const resetForm = () => {
columnTitle.value = columnTitleMap.get(1) columnTitle.value = columnTitleMap.get(1)
formRef.value?.resetFields() formRef.value?.resetFields()
} }
/** 配送计费方法改变 */ /** 配送计费方法改变 */
const changeChargeMode = (chargeMode: number) => { const changeChargeMode = (chargeMode: number) => {
columnTitle.value = columnTitleMap.get(chargeMode) columnTitle.value = columnTitleMap.get(chargeMode)
@ -276,6 +282,24 @@ const changeChargeMode = (chargeMode: number) => {
const defaultArea = [{ id: 1, name: '全国', disabled: false }] const defaultArea = [{ id: 1, name: '全国', disabled: false }]
/** 初始化数据 */ /** 初始化数据 */
// TODO @jasoncolumnTitleMap
// const columnTitleMap = {
// '1': {
// startCountTitle: '',
// extraCountTitle: '',
// freeCountTitle: ''
// },
// '2': {
// startCountTitle: '(kg)',
// extraCountTitle: '(kg)',
// freeCountTitle: '(kg)'
// },
// '3': {
// startCountTitle: '(m³)',
// extraCountTitle: '(m³)',
// freeCountTitle: '(m³)'
// }
// }
const initData = async () => { const initData = async () => {
// TODO // TODO
// formLoading.value = true // formLoading.value = true
@ -286,7 +310,7 @@ const initData = async () => {
// } finally { // } finally {
// formLoading.value = false // formLoading.value = false
// } // }
// //
columnTitleMap.set(1, { columnTitleMap.set(1, {
startCountTitle: '首件', startCountTitle: '首件',
extraCountTitle: '续件', extraCountTitle: '续件',
@ -320,6 +344,7 @@ const loadChargeArea = async (node, resolve) => {
const item = data[0] const item = data[0]
if (areaIds.includes(item.id)) { if (areaIds.includes(item.id)) {
// TODO @ // TODO @
// TODO @jason
//item.disabled = true //item.disabled = true
} }
resolve(data) resolve(data)
@ -357,10 +382,11 @@ const loadFreeArea = async (node, resolve) => {
} else { } else {
const id = node.data.id const id = node.data.id
const data = await getChildrenArea(id) const data = await getChildrenArea(id)
// //
data.forEach((item) => { data.forEach((item) => {
if (areaIds.includes(item.id)) { if (areaIds.includes(item.id)) {
// TODO @ // TODO @
// TODO @jason
//item.disabled = true //item.disabled = true
} }
}) })
@ -378,11 +404,13 @@ const addChargeArea = () => {
extraPrice: 1 extraPrice: 1
}) })
} }
/** 删除计费区域 */ /** 删除计费区域 */
const deleteChargeArea = (index) => { const deleteChargeArea = (index) => {
const data = formData.value const data = formData.value
data.templateCharge.splice(index, 1) data.templateCharge.splice(index, 1)
} }
/** 添加包邮区域 */ /** 添加包邮区域 */
const addFreeArea = () => { const addFreeArea = () => {
const data = formData.value const data = formData.value
@ -392,6 +420,7 @@ const addFreeArea = () => {
freePrice: 1 freePrice: 1
}) })
} }
/** 删除包邮区域 */ /** 删除包邮区域 */
const deleteFreeArea = (index) => { const deleteFreeArea = (index) => {
const data = formData.value const data = formData.value

View File

@ -110,6 +110,7 @@ const queryParams = reactive({
chargeMode: undefined chargeMode: undefined
}) })
const queryFormRef = ref() // const queryFormRef = ref() //
/** 查询列表 */ /** 查询列表 */
const getList = async () => { const getList = async () => {
loading.value = true loading.value = true

View File

@ -51,7 +51,7 @@
<el-row> <el-row>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="门店所在地区" prop="areaId"> <el-form-item label="门店所在地区" prop="areaId">
<el-cascader v-model="formData.areaId" :options="areaList" :props="cascaderProps" /> <el-cascader v-model="formData.areaId" :options="areaList" :props="areaTreeProps" />
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
@ -99,7 +99,7 @@
</el-col> </el-col>
</el-row> </el-row>
<el-form-item label="获取经纬度"> <el-form-item label="获取经纬度">
<el-button type="primary" @click="searchLocation">获取</el-button> <el-button type="primary" @click="mapDialogVisible.value = true">获取</el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
<template #footer> <template #footer>
@ -125,6 +125,7 @@ import { getAreaTree } from '@/api/system/area'
import * as ConfigApi from '@/api/infra/config' import * as ConfigApi from '@/api/infra/config'
const { t } = useI18n() // const { t } = useI18n() //
const message = useMessage() // const message = useMessage() //
const dialogVisible = ref(false) // const dialogVisible = ref(false) //
const mapDialogVisible = ref(false) // const mapDialogVisible = ref(false) //
const dialogTitle = ref('') // const dialogTitle = ref('') //
@ -160,14 +161,15 @@ const formRules = reactive({
status: [{ required: true, message: '开启状态不能为空', trigger: 'blur' }] status: [{ required: true, message: '开启状态不能为空', trigger: 'blur' }]
}) })
const formRef = ref() // Ref const formRef = ref() // Ref
const cascaderProps = { const areaTreeProps = {
children: 'children', children: 'children',
label: 'name', label: 'name',
value: 'id', value: 'id',
emitPath: false emitPath: false
} }
const areaList = ref() // const areaList = ref() //
const tencentLbsUrl = ref('') // url const tencentLbsUrl = ref('') // url
/** 打开弹窗 */ /** 打开弹窗 */
const open = async (type: string, id?: number) => { const open = async (type: string, id?: number) => {
dialogVisible.value = true dialogVisible.value = true
@ -196,7 +198,6 @@ const submitForm = async () => {
// //
formLoading.value = true formLoading.value = true
try { try {
console.log('formData.value', formData.value)
const data = formData.value as DeliveryPickUpStoreApi.DeliveryPickUpStoreVO const data = formData.value as DeliveryPickUpStoreApi.DeliveryPickUpStoreVO
if (formType.value === 'create') { if (formType.value === 'create') {
await DeliveryPickUpStoreApi.createDeliveryPickUpStore(data) await DeliveryPickUpStoreApi.createDeliveryPickUpStore(data)
@ -222,7 +223,7 @@ const resetForm = () => {
logo: '', logo: '',
detailAddress: '', detailAddress: '',
introduction: '', introduction: '',
areaId: 1, areaId: undefined,
openingTime: undefined, openingTime: undefined,
closingTime: undefined, closingTime: undefined,
latitude: undefined, latitude: undefined,
@ -232,11 +233,7 @@ const resetForm = () => {
formRef.value?.resetFields() formRef.value?.resetFields()
} }
// /** 选择经纬度 */
const searchLocation = async () => {
mapDialogVisible.value = true
}
//
const selectAddress = function (loc: any): void { const selectAddress = function (loc: any): void {
if (loc.latlng && loc.latlng.lat) { if (loc.latlng && loc.latlng.lat) {
formData.value.latitude = loc.latlng.lat formData.value.latitude = loc.latlng.lat
@ -246,6 +243,7 @@ const selectAddress = function (loc: any): void {
} }
mapDialogVisible.value = false mapDialogVisible.value = false
} }
/** 初始化数据 */ /** 初始化数据 */
const initData = async () => { const initData = async () => {
formLoading.value = true formLoading.value = true
@ -255,6 +253,7 @@ const initData = async () => {
} finally { } finally {
formLoading.value = false formLoading.value = false
} }
// TODO @jason initTencentLbsMap
window.selectAddress = selectAddress window.selectAddress = selectAddress
window.addEventListener( window.addEventListener(
'message', 'message',
@ -262,7 +261,7 @@ const initData = async () => {
// //
let loc = event.data let loc = event.data
if (loc && loc.module === 'locationPicker') { if (loc && loc.module === 'locationPicker') {
// postmodule'locationPicker' // post module 'locationPicker'
window.parent.selectAddress(loc) window.parent.selectAddress(loc)
} }
}, },

View File

@ -121,6 +121,7 @@ import { dateFormatter } from '@/utils/formatTime'
import download from '@/utils/download' import download from '@/utils/download'
const message = useMessage() // const message = useMessage() //
const { t } = useI18n() // const { t } = useI18n() //
const total = ref(0) // const total = ref(0) //
const loading = ref(true) // const loading = ref(true) //
const exportLoading = ref(false) // const exportLoading = ref(false) //
@ -134,6 +135,7 @@ const queryParams = reactive({
createTime: [] createTime: []
}) })
const queryFormRef = ref() // const queryFormRef = ref() //
/** 添加/修改操作 */ /** 添加/修改操作 */
const formRef = ref() const formRef = ref()
const openForm = (type: string, id?: number) => { const openForm = (type: string, id?: number) => {
@ -153,7 +155,7 @@ const handleDelete = async (id: number) => {
} catch {} } catch {}
} }
//** */ /** 查询列表 */
const getList = async () => { const getList = async () => {
loading.value = true loading.value = true
try { try {