Skip to content

Commit 0730e21

Browse files
author
puhui999
committed
完善文章管理 review 提到的问题
1 parent 2a150cf commit 0730e21

File tree

2 files changed

+25
-27
lines changed

2 files changed

+25
-27
lines changed

src/views/mall/promotion/article/ArticleForm.vue

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
<UploadImg v-model="formData.picUrl" height="80px" />
4141
</el-form-item>
4242
</el-col>
43-
<!-- TODO @puhui999:浏览次数,不能修改 -->
4443
<el-col :span="12">
4544
<el-form-item label="排序" prop="sort">
4645
<el-input-number v-model="formData.sort" :min="0" clearable controls-position="right" />
@@ -59,19 +58,6 @@
5958
</el-radio-group>
6059
</el-form-item>
6160
</el-col>
62-
<!-- TODO @puhui999:可以使用 SpuTableSelect -->
63-
<el-col :span="12">
64-
<el-form-item label="商品关联" prop="spuId">
65-
<el-select v-model="formData.spuId" placeholder="请选择">
66-
<el-option
67-
v-for="item in spuList"
68-
:key="item.id"
69-
:label="item.name"
70-
:value="item.id"
71-
/>
72-
</el-select>
73-
</el-form-item>
74-
</el-col>
7561
<el-col :span="12">
7662
<el-form-item label="是否热门" prop="recommendHot">
7763
<el-radio-group v-model="formData.recommendHot">
@@ -98,6 +84,14 @@
9884
</el-radio-group>
9985
</el-form-item>
10086
</el-col>
87+
<el-col :span="24">
88+
<el-form-item label="商品关联" prop="spuId">
89+
<el-tag v-if="formData.spuId" class="mr-10px">
90+
{{ spuList.find((item) => item.id === formData.spuId)?.name }}
91+
</el-tag>
92+
<el-button @click="spuSelectRef?.open()">选择商品</el-button>
93+
</el-form-item>
94+
</el-col>
10195
<el-col :span="24">
10296
<el-form-item label="文章内容">
10397
<Editor v-model="formData.content" height="150px" />
@@ -110,12 +104,14 @@
110104
<el-button @click="dialogVisible = false">取 消</el-button>
111105
</template>
112106
</Dialog>
107+
<SpuSelect ref="spuSelectRef" @confirm="selectSpu" />
113108
</template>
114109
<script lang="ts" setup>
115110
import { DICT_TYPE, getBoolDictOptions, getIntDictOptions } from '@/utils/dict'
116111
import * as ArticleApi from '@/api/mall/promotion/article'
117112
import * as ArticleCategoryApi from '@/api/mall/promotion/articleCategory'
118113
import * as ProductSpuApi from '@/api/mall/product/spu'
114+
import { SpuSelect } from '@/views/mall/promotion/components'
119115
120116
defineOptions({ name: 'PromotionArticleForm' })
121117
@@ -135,7 +131,7 @@ const formData = ref({
135131
introduction: undefined,
136132
sort: 0,
137133
status: 0,
138-
spuId: undefined,
134+
spuId: 0,
139135
recommendHot: false,
140136
recommendBanner: false,
141137
content: undefined
@@ -152,7 +148,10 @@ const formRules = reactive({
152148
content: [{ required: true, message: '文章内容不能为空', trigger: 'blur' }]
153149
})
154150
const formRef = ref() // 表单 Ref
155-
151+
const spuSelectRef = ref() // 商品和属性选择 Ref
152+
const selectSpu = (spuId: number) => {
153+
formData.value.spuId = spuId
154+
}
156155
/** 打开弹窗 */
157156
const open = async (type: string, id?: number) => {
158157
dialogVisible.value = true
@@ -208,7 +207,7 @@ const resetForm = () => {
208207
introduction: undefined,
209208
sort: 0,
210209
status: 0,
211-
spuId: undefined,
210+
spuId: 0,
212211
recommendHot: false,
213212
recommendBanner: false,
214213
content: undefined

src/views/mall/promotion/article/index.vue

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,23 +78,23 @@
7878
<!-- 列表 -->
7979
<ContentWrap>
8080
<el-table v-loading="loading" :data="list" :show-overflow-tooltip="true" :stripe="true">
81-
<el-table-column align="center" label="编号" prop="id" min-width="60" />
82-
<el-table-column align="center" label="封面" prop="picUrl" min-width="80">
81+
<el-table-column align="center" label="编号" min-width="60" prop="id" />
82+
<el-table-column align="center" label="封面" min-width="80" prop="picUrl">
8383
<template #default="{ row }">
8484
<el-image :src="row.picUrl" class="h-30px w-30px" @click="imagePreview(row.picUrl)" />
8585
</template>
8686
</el-table-column>
87-
<el-table-column align="center" label="标题" prop="title" min-width="180" />
88-
<el-table-column align="center" label="分类" prop="categoryId" min-width="180">
87+
<el-table-column align="center" label="标题" min-width="180" prop="title" />
88+
<el-table-column align="center" label="分类" min-width="180" prop="categoryId">
8989
<template #default="scope">
9090
{{ categoryList.find((item) => item.id === scope.row.categoryId)?.name }}
9191
</template>
9292
</el-table-column>
93-
<el-table-column align="center" label="浏览量" prop="browseCount" min-width="180" />
94-
<el-table-column align="center" label="作者" prop="author" min-width="180" />
95-
<el-table-column align="center" label="文章简介" prop="introduction" min-width="250" />
96-
<el-table-column align="center" label="排序" prop="sort" min-width="60" />
97-
<el-table-column align="center" label="状态" prop="status" min-width="60">
93+
<el-table-column align="center" label="浏览量" min-width="180" prop="browseCount" />
94+
<el-table-column align="center" label="作者" min-width="180" prop="author" />
95+
<el-table-column align="center" label="文章简介" min-width="250" prop="introduction" />
96+
<el-table-column align="center" label="排序" min-width="60" prop="sort" />
97+
<el-table-column align="center" label="状态" min-width="60" prop="status">
9898
<template #default="scope">
9999
<dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status" />
100100
</template>
@@ -167,7 +167,6 @@ const queryParams = reactive({
167167
createTime: []
168168
})
169169
const queryFormRef = ref() // 搜索的表单
170-
const exportLoading = ref(false) // 导出的加载中
171170
/** 文章封面预览 */
172171
const imagePreview = (imgUrl: string) => {
173172
createImageViewer({

0 commit comments

Comments
 (0)