提交订单列表和详情20230619

This commit is contained in:
xiaobai
2023-06-19 15:57:20 +08:00
30 changed files with 1626 additions and 95 deletions

View File

@@ -104,7 +104,7 @@ const getDetail = async () => {
formLoading.value = true
try {
const res = (await ProductSpuApi.getSpu(id)) as ProductSpuApi.Spu
res.skus!.forEach((item) => {
res.skus?.forEach((item) => {
// 回显价格分转元
item.price = formatToFraction(item.price)
item.marketPrice = formatToFraction(item.marketPrice)

View File

@@ -14,7 +14,6 @@
</el-form-item>
</el-col>
<el-col :span="12">
<!-- TODO @puhui999只能选根节点 fix: 已完善-->
<el-form-item label="商品分类" prop="categoryId">
<el-tree-select
v-model="formData.categoryId"
@@ -166,8 +165,7 @@
</Descriptions>
<!-- 商品属性添加 Form 表单 -->
<!-- TODO @puhui999: ProductPropertyAddForm 是不是更合适呀 -->
<ProductAttributesAddForm ref="attributesAddFormRef" :propertyList="propertyList" />
<ProductPropertyAddForm ref="attributesAddFormRef" :propertyList="propertyList" />
</template>
<script lang="ts" name="ProductSpuBasicInfoForm" setup>
import { PropType } from 'vue'
@@ -178,7 +176,7 @@ import { checkSelectedNode, defaultProps, handleTree, treeToString } from '@/uti
import { createImageViewer } from '@/components/ImageViewer'
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
import { UploadImg, UploadImgs } from '@/components/UploadFile'
import { ProductAttributes, ProductAttributesAddForm, SkuList } from './index'
import { ProductAttributes, ProductPropertyAddForm, SkuList } from './index'
import { basicInfoSchema } from './spu.data'
import type { Spu } from '@/api/mall/product/spu'
import * as ProductCategoryApi from '@/api/mall/product/category'
@@ -258,7 +256,7 @@ watch(
return
}
copyValueToTarget(formData, data)
formData.sliderPicUrls = data['sliderPicUrls'].map((item) => ({
formData.sliderPicUrls = data['sliderPicUrls']?.map((item) => ({
url: item
}))
// 只有是多规格才处理
@@ -267,16 +265,16 @@ watch(
}
// 直接拿返回的 skus 属性逆向生成出 propertyList
const properties = []
formData.skus.forEach((sku) => {
sku.properties.forEach(({ propertyId, propertyName, valueId, valueName }) => {
formData.skus?.forEach((sku) => {
sku.properties?.forEach(({ propertyId, propertyName, valueId, valueName }) => {
// 添加属性
if (!properties.some((item) => item.id === propertyId)) {
if (!properties?.some((item) => item.id === propertyId)) {
properties.push({ id: propertyId, name: propertyName, values: [] })
}
// 添加属性值
const index = properties.findIndex((item) => item.id === propertyId)
if (!properties[index].values.some((value) => value.id === valueId)) {
properties[index].values.push({ id: valueId, name: valueName })
const index = properties?.findIndex((item) => item.id === propertyId)
if (!properties[index].values?.some((value) => value.id === valueId)) {
properties[index].values?.push({ id: valueId, name: valueName })
}
})
})

View File

@@ -17,7 +17,7 @@
</template>
</Dialog>
</template>
<script lang="ts" name="ProductPropertyForm" setup>
<script lang="ts" name="ProductPropertyAddForm" setup>
import * as PropertyApi from '@/api/mall/product/property'
const { t } = useI18n() //

View File

@@ -23,7 +23,6 @@
min-width="120"
>
<template #default="{ row }">
<!-- TODO puhui999展示成蓝色有点区分度哈 fix-->
<span style="font-weight: bold; color: #40aaff">
{{ row.properties[index]?.valueName }}
</span>

View File

@@ -2,7 +2,7 @@ import BasicInfoForm from './BasicInfoForm.vue'
import DescriptionForm from './DescriptionForm.vue'
import OtherSettingsForm from './OtherSettingsForm.vue'
import ProductAttributes from './ProductAttributes.vue'
import ProductAttributesAddForm from './ProductAttributesAddForm.vue'
import ProductPropertyAddForm from './ProductPropertyAddForm.vue'
import SkuList from './SkuList.vue'
export {
@@ -10,6 +10,6 @@ export {
DescriptionForm,
OtherSettingsForm,
ProductAttributes,
ProductAttributesAddForm,
ProductPropertyAddForm,
SkuList
}

View File

@@ -1,6 +1,5 @@
import { CrudSchema } from '@/hooks/web/useCrudSchemas'
// TODO @puhui999如果只要 detail可以不用 CrudSchema只要描述的 Schema
export const basicInfoSchema = reactive<CrudSchema[]>([
{
label: '商品名称',

View File

@@ -396,18 +396,18 @@ const resetQuery = () => {
const openForm = (id?: number) => {
// 修改
if (typeof id === 'number') {
push('/product/productSpuEdit/' + id)
push('/product/spu/edit/' + id)
return
}
// 新增
push('/product/productSpuAdd')
push({ name: 'ProductSpuAdd' })
}
/**
* 查看商品详情
*/
const openDetail = (id?: number) => {
push('/product/productSpuDetail/' + id)
push('/product/spu/detail/' + id)
}
/** 导出按钮操作 */

View File

@@ -12,7 +12,7 @@
<el-select class="!w-280px" v-model="queryParams.status" clearable placeholder="全部">
<el-option
v-for="dict in getStrDictOptions(DICT_TYPE.TRADE_ORDER_STATUS)"
:key="dict.value"
:key="(dict.value as string)"
:label="dict.label"
:value="dict.value"
/>
@@ -27,7 +27,7 @@
>
<el-option
v-for="dict in getStrDictOptions(DICT_TYPE.PAY_CHANNEL_CODE_TYPE)"
:key="dict.value"
:key="(dict.value as string)"
:label="dict.label"
:value="dict.value"
/>
@@ -48,7 +48,7 @@
<el-select class="!w-280px" v-model="queryParams.terminal" clearable placeholder="全部">
<el-option
v-for="dict in getStrDictOptions(DICT_TYPE.TERMINAL)"
:key="dict.value"
:key="(dict.value as string)"
:label="dict.label"
:value="dict.value"
/>
@@ -58,7 +58,7 @@
<el-select class="!w-280px" v-model="queryParams.type" clearable placeholder="全部">
<el-option
v-for="dict in getStrDictOptions(DICT_TYPE.TRADE_ORDER_TYPE)"
:key="dict.value"
:key="(dict.value as string)"
:label="dict.label"
:value="dict.value"
/>
@@ -363,7 +363,6 @@ const handleDropType = (command: string) => {
}
//所有页按钮
if (command === '2') {
initSelect() //重置之前选中的类容清空
orderSelect.selectAllFlag = !orderSelect.selectAllFlag
if (orderSelect.selectAllFlag) {
@@ -379,6 +378,7 @@ const handleDropType = (command: string) => {
for (i; i < list.value.length; i++) {
list.value[i]['itemSelect'] = false
}
initSelect() //重置之前选中的类容清空
}
}
}
@@ -494,54 +494,6 @@ const getList = async () => {
}
}
// const getList = async () => {
// loading.value = true
// try {
// const data = await TradeOrderApi.getOrderList(queryParams)
// list.value = data.list
// total.value = data.total
// let i = 0
// //给数组添加选中属性 itemSelect 默认为false 当前状态如果时全选 则新加载的页面都为选中状态
// if (orderSelect.selectAllFlag) {
// if (orderSelect.selectData && orderSelect.selectData.has(queryParams.pageNo)) {
// //页面已经加载过了
// for (i = 0; i < list.value.length; i++) {
// if (orderSelect.selectData.get(queryParams.pageNo)!.has(list.value[i].id)) {
// list.value[i]['itemSelect'] = true //之前已经选取过了
// } else {
// list.value[i]['itemSelect'] = false
// }
// }
// } else {
// //首次加载页面 默认全部选中
// orderSelect.selectData.set(queryParams.pageNo, new Set<string>())
// for (i = 0; i < list.value.length; i++) {
// list.value[i]['itemSelect'] = true
// orderSelect.selectData.get(queryParams.pageNo)!.add(list.value[i].id)
// }
// }
// } else {
// if (orderSelect.selectData && orderSelect.selectData.has(queryParams.pageNo)) {
// //页面已经加载过了
// for (i = 0; i < list.value.length; i++) {
// if (orderSelect.selectData.get(queryParams.pageNo)!.has(list.value[i].id)) {
// list.value[i]['itemSelect'] = true //之前已经选取过了
// } else {
// list.value[i]['itemSelect'] = false
// }
// }
// } else {
// for (i; i < list.value.length; i++) {
// list.value[i]['itemSelect'] = false //设置状态为未选中状态
// }
// }
// }
// } finally {
// loading.value = false
// }
// }
/**
* 跳转订单详情
*/

View File

@@ -124,11 +124,14 @@
parseFloat((order.adjustPrice / 100.0) as unknown as string).toFixed(2)
}}</el-descriptions-item
>
<el-descriptions-item>
<template #label><span style="color: red">商品优惠: </span></template>
<!-- 没理解TODO order.totalPrice - order.totalPrice -->
{{
parseFloat((order.totalPrice - order.totalPrice / 100.0) as unknown as string).toFixed(2)
parseFloat(((order.totalPrice - order.totalPrice) / 100.0) as unknown as string).toFixed(
2
)
}}
</el-descriptions-item>
<el-descriptions-item>
@@ -163,6 +166,7 @@
</el-descriptions-item>
<!-- 物流信息 -->
<!-- TODO @xiaobai改成一个包裹哈目前只允许发货一次 -->
<el-descriptions-item v-if="group.key === 'expressInfo'" labelClassName="no-colon">
<!-- 循环包裹物流信息 -->
<div v-show="(pkgInfo = detailInfo[group.key]) !== null" style="border: 1px dashed">
@@ -222,6 +226,7 @@
</ContentWrap>
</template>
<script lang="ts" name="TradeOrderDetail" setup>
// TODO @xiaobai在 order 下创建一个 order/detail然后改名为 index.vue
import { DICT_TYPE } from '@/utils/dict'
import * as TradeOrderApi from '@/api/mall/trade/order'
const message = useMessage() // 消息弹窗
@@ -235,7 +240,7 @@ const loading = ref(false)
const order = ref<any>({
items: [],
user: {}
}) //详情数据
}) // 详情数据
const detailGroups = ref([
{
@@ -301,7 +306,7 @@ const detailInfo = ref({
],
goodsInfo: [] // 商品详情tableData
})
//暂考虑一次性加载详情页面所有数据
// 暂考虑一次性加载详情页面所有数据 TODO
const getlist = async () => {
dialogVisible.value = true
loading.value = true
@@ -327,9 +332,11 @@ const clipboardSuccess = () => {
&:not(:nth-child(1)) {
margin-top: 20px;
}
.el-descriptions__title {
display: flex;
align-items: center;
&::before {
content: '';
display: inline-block;
@@ -339,10 +346,13 @@ const clipboardSuccess = () => {
background-color: #409eff;
}
}
.el-descriptions-item__container {
margin: 0 10px;
.no-colon {
margin: 0;
&::after {
content: '';
}