Skip to content

Commit 1116fb2

Browse files
author
puhui999
committed
商品管理: 调整相关组件优化逻辑
1 parent 6478d29 commit 1116fb2

File tree

7 files changed

+43
-36
lines changed

7 files changed

+43
-36
lines changed

src/api/mall/product/management/spu.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import request from '@/config/axios'
22
import type { SpuType } from './type/spuType'
33

4-
// 获得sku列表
5-
export const getSkuList = (params: any) => {
6-
return request.get({ url: '/product/sku/list', params })
4+
// 获得spu列表
5+
export const getSpuList = (params: any) => {
6+
return request.get({ url: '/product/spu/page', params })
77
}
88
// 创建商品spu
99
export const createSpu = (data: SpuType) => {

src/utils/dict.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,5 +147,6 @@ export enum DICT_TYPE {
147147
MP_MESSAGE_TYPE = 'mp_message_type', // 消息类型
148148

149149
// ========== MALL 模块 ==========
150-
PRODUCT_UNIT = 'product_unit' // 商品单位
150+
PRODUCT_UNIT = 'product_unit', // 商品单位
151+
PRODUCT_SPU_STATUS = 'product_spu_status' //商品状态
151152
}

src/views/mall/product/management/components/BasicInfoForm.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,15 @@ import { copyValueToTarget } from '@/utils/object'
116116
import { ProductAttributes, ProductAttributesAddForm, SkuList } from './index'
117117
// 业务Api
118118
import * as ProductCategoryApi from '@/api/mall/product/category'
119+
import { propTypes } from '@/utils/propTypes'
119120
120121
const message = useMessage() // 消息弹窗
121122
const props = defineProps({
122123
propFormData: {
123124
type: Object as PropType<SpuType>,
124125
default: () => {}
125-
}
126+
},
127+
activeName: propTypes.string.def('')
126128
})
127129
const AttributesAddFormRef = ref() // 添加商品属性表单
128130
const ProductManagementBasicInfoRef = ref() // 表单Ref

src/views/mall/product/management/components/DescriptionForm.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@ import type { SpuType } from '@/api/mall/product/management/type/spuType'
1111
import { Editor } from '@/components/Editor'
1212
import { PropType } from 'vue'
1313
import { copyValueToTarget } from '@/utils/object'
14+
import { propTypes } from '@/utils/propTypes'
1415
1516
const message = useMessage() // 消息弹窗
1617
const props = defineProps({
1718
propFormData: {
1819
type: Object as PropType<SpuType>,
1920
default: () => {}
20-
}
21+
},
22+
activeName: propTypes.string.def('')
2123
})
2224
const DescriptionFormRef = ref() // 表单Ref
2325
const formData = ref<SpuType>({

src/views/mall/product/management/components/OtherSettingsForm.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,15 @@
5353
import type { SpuType } from '@/api/mall/product/management/type/spuType'
5454
import { PropType } from 'vue'
5555
import { copyValueToTarget } from '@/utils/object'
56+
import { propTypes } from '@/utils/propTypes'
5657
5758
const message = useMessage() // 消息弹窗
5859
const props = defineProps({
5960
propFormData: {
6061
type: Object as PropType<SpuType>,
6162
default: () => {}
62-
}
63+
},
64+
activeName: propTypes.string.def('')
6365
})
6466
// 商品推荐选项
6567
const recommend = [

src/views/mall/product/management/components/SkuList.vue

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,17 @@
1919
</template>
2020
</el-table-column>
2121
</template>
22-
<el-table-column align="center" label="商品条码" min-width="120">
22+
<el-table-column align="center" label="商品条码" min-width="168">
2323
<template #default="{ row }">
2424
<el-input v-model="row.barCode" class="w-100%" />
2525
</template>
2626
</el-table-column>
27-
<el-table-column align="center" label="销售价(分)" min-width="120">
27+
<el-table-column align="center" label="销售价(分)" min-width="168">
2828
<template #default="{ row }">
2929
<el-input-number v-model="row.price" :min="0" class="w-100%" controls-position="right" />
3030
</template>
3131
</el-table-column>
32-
<el-table-column align="center" label="市场价(分)" min-width="120">
32+
<el-table-column align="center" label="市场价(分)" min-width="168">
3333
<template #default="{ row }">
3434
<el-input-number
3535
v-model="row.marketPrice"
@@ -39,7 +39,7 @@
3939
/>
4040
</template>
4141
</el-table-column>
42-
<el-table-column align="center" label="成本价(分)" min-width="120">
42+
<el-table-column align="center" label="成本价(分)" min-width="168">
4343
<template #default="{ row }">
4444
<el-input-number
4545
v-model="row.costPrice"
@@ -49,23 +49,23 @@
4949
/>
5050
</template>
5151
</el-table-column>
52-
<el-table-column align="center" label="库存" min-width="120">
52+
<el-table-column align="center" label="库存" min-width="168">
5353
<template #default="{ row }">
5454
<el-input-number v-model="row.stock" :min="0" class="w-100%" controls-position="right" />
5555
</template>
5656
</el-table-column>
57-
<el-table-column align="center" label="重量(kg)" min-width="120">
57+
<el-table-column align="center" label="重量(kg)" min-width="168">
5858
<template #default="{ row }">
5959
<el-input-number v-model="row.weight" :min="0" class="w-100%" controls-position="right" />
6060
</template>
6161
</el-table-column>
62-
<el-table-column align="center" label="体积(m^3)" min-width="120">
62+
<el-table-column align="center" label="体积(m^3)" min-width="168">
6363
<template #default="{ row }">
6464
<el-input-number v-model="row.volume" :min="0" class="w-100%" controls-position="right" />
6565
</template>
6666
</el-table-column>
6767
<template v-if="formData.subCommissionType">
68-
<el-table-column align="center" label="一级返佣(分)" min-width="120">
68+
<el-table-column align="center" label="一级返佣(分)" min-width="168">
6969
<template #default="{ row }">
7070
<el-input-number
7171
v-model="row.subCommissionFirstPrice"
@@ -75,7 +75,7 @@
7575
/>
7676
</template>
7777
</el-table-column>
78-
<el-table-column align="center" label="二级返佣(分)" min-width="120">
78+
<el-table-column align="center" label="二级返佣(分)" min-width="168">
7979
<template #default="{ row }">
8080
<el-input-number
8181
v-model="row.subCommissionSecondPrice"

src/views/mall/product/management/index.vue

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
<el-table v-loading="loading" :data="list">
6969
<el-table-column type="expand">
7070
<template #default="{ row }">
71-
<el-form class="demo-table-expand" inline label-position="left">
71+
<el-form inline label-position="left">
7272
<el-form-item label="市场价:">
7373
<span>{{ row.marketPrice }}</span>
7474
</el-form-item>
@@ -83,23 +83,18 @@
8383
</el-table-column>
8484
<el-table-column label="商品图" min-width="80">
8585
<template #default="{ row }">
86-
<div class="demo-image__preview">
86+
<div class="demo-image__preview z-100">
8787
<el-image
88-
:preview-src-list="[row.image]"
89-
:src="row.image"
88+
:src="row.picUrl"
9089
style="width: 36px; height: 36px"
90+
@click="imgViewVisible = true"
9191
/>
9292
</div>
9393
</template>
9494
</el-table-column>
95-
<el-table-column
96-
:show-overflow-tooltip="true"
97-
label="商品名称"
98-
min-width="300"
99-
prop="storeName"
100-
/>
95+
<el-table-column :show-overflow-tooltip="true" label="商品名称" min-width="300" prop="name" />
10196
<el-table-column align="center" label="商品售价" min-width="90" prop="price" />
102-
<el-table-column align="center" label="销量" min-width="90" prop="sales" />
97+
<el-table-column align="center" label="销量" min-width="90" prop="salesCount" />
10398
<el-table-column align="center" label="库存" min-width="90" prop="stock" />
10499
<el-table-column align="center" label="排序" min-width="70" prop="sort" />
105100
<el-table-column
@@ -112,7 +107,7 @@
112107
<el-table-column fixed="right" label="状态" min-width="80">
113108
<template #default="{ row }">
114109
<!--TODO 暂时用COMMON_STATUS占位一下使其不报错 -->
115-
<dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="row.status" />
110+
<dict-tag :type="DICT_TYPE.PRODUCT_SPU_STATUS" :value="row.status" />
116111
</template>
117112
</el-table-column>
118113
<el-table-column align="center" fixed="right" label="操作" min-width="150" />
@@ -125,11 +120,19 @@
125120
@pagination="getList"
126121
/>
127122
</ContentWrap>
123+
<!-- 必须在表格外面展示。不然单元格会遮挡图层 -->
124+
<el-image-viewer
125+
v-if="imgViewVisible"
126+
:url-list="[
127+
'http://127.0.0.1:48080/admin-api/infra/file/4/get/6ffdf8f5dfc03f7ceec1ff1ebc138adb8b721a057d505ccfb0e61a8783af1371.png'
128+
]"
129+
@close="imgViewVisible = false"
130+
/>
128131
</template>
129132
<script lang="ts" name="ProductManagement" setup>
130133
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
131134
import { dateFormatter } from '@/utils/formatTime' // 业务api
132-
import * as managementApi from '@/api/mall/product/management/spu' // const message = useMessage() // 消息弹窗
135+
import * as managementApi from '@/api/mall/product/management/spu'
133136
// const message = useMessage() // 消息弹窗
134137
// const { t } = useI18n() // 国际化
135138
const { push } = useRouter() // 路由跳转
@@ -163,21 +166,18 @@ const headerNum = ref([
163166
type: 5
164167
}
165168
])
169+
const imgViewVisible = ref(false)
166170
const queryParams = reactive({
167171
pageNo: 1,
168-
pageSize: 10,
169-
name: undefined,
170-
status: undefined,
171-
createTime: [],
172-
type: '1'
172+
pageSize: 10
173173
})
174174
const queryFormRef = ref() // 搜索的表单
175175
176176
/** 查询列表 */
177177
const getList = async () => {
178178
loading.value = true
179179
try {
180-
const data = await managementApi.getSkuList(queryParams)
180+
const data = await managementApi.getSpuList(queryParams)
181181
list.value = data.list
182182
total.value = data.total
183183
} finally {
@@ -218,6 +218,6 @@ const openForm = (id?: number) => {
218218
219219
/** 初始化 **/
220220
onMounted(() => {
221-
// getList()
221+
getList()
222222
})
223223
</script>

0 commit comments

Comments
 (0)