完善文章管理 review 提到的问题

This commit is contained in:
puhui999 2023-10-20 22:16:18 +08:00
parent 2a150cf0c0
commit 0730e215d8
2 changed files with 25 additions and 27 deletions

View File

@ -40,7 +40,6 @@
<UploadImg v-model="formData.picUrl" height="80px" /> <UploadImg v-model="formData.picUrl" height="80px" />
</el-form-item> </el-form-item>
</el-col> </el-col>
<!-- TODO @puhui999浏览次数不能修改 -->
<el-col :span="12"> <el-col :span="12">
<el-form-item label="排序" prop="sort"> <el-form-item label="排序" prop="sort">
<el-input-number v-model="formData.sort" :min="0" clearable controls-position="right" /> <el-input-number v-model="formData.sort" :min="0" clearable controls-position="right" />
@ -59,19 +58,6 @@
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
</el-col> </el-col>
<!-- TODO @puhui999可以使用 SpuTableSelect -->
<el-col :span="12">
<el-form-item label="商品关联" prop="spuId">
<el-select v-model="formData.spuId" placeholder="请选择">
<el-option
v-for="item in spuList"
:key="item.id"
:label="item.name"
:value="item.id"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="是否热门" prop="recommendHot"> <el-form-item label="是否热门" prop="recommendHot">
<el-radio-group v-model="formData.recommendHot"> <el-radio-group v-model="formData.recommendHot">
@ -98,6 +84,14 @@
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="24">
<el-form-item label="商品关联" prop="spuId">
<el-tag v-if="formData.spuId" class="mr-10px">
{{ spuList.find((item) => item.id === formData.spuId)?.name }}
</el-tag>
<el-button @click="spuSelectRef?.open()">选择商品</el-button>
</el-form-item>
</el-col>
<el-col :span="24"> <el-col :span="24">
<el-form-item label="文章内容"> <el-form-item label="文章内容">
<Editor v-model="formData.content" height="150px" /> <Editor v-model="formData.content" height="150px" />
@ -110,12 +104,14 @@
<el-button @click="dialogVisible = false"> </el-button> <el-button @click="dialogVisible = false"> </el-button>
</template> </template>
</Dialog> </Dialog>
<SpuSelect ref="spuSelectRef" @confirm="selectSpu" />
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { DICT_TYPE, getBoolDictOptions, getIntDictOptions } from '@/utils/dict' import { DICT_TYPE, getBoolDictOptions, getIntDictOptions } from '@/utils/dict'
import * as ArticleApi from '@/api/mall/promotion/article' import * as ArticleApi from '@/api/mall/promotion/article'
import * as ArticleCategoryApi from '@/api/mall/promotion/articleCategory' import * as ArticleCategoryApi from '@/api/mall/promotion/articleCategory'
import * as ProductSpuApi from '@/api/mall/product/spu' import * as ProductSpuApi from '@/api/mall/product/spu'
import { SpuSelect } from '@/views/mall/promotion/components'
defineOptions({ name: 'PromotionArticleForm' }) defineOptions({ name: 'PromotionArticleForm' })
@ -135,7 +131,7 @@ const formData = ref({
introduction: undefined, introduction: undefined,
sort: 0, sort: 0,
status: 0, status: 0,
spuId: undefined, spuId: 0,
recommendHot: false, recommendHot: false,
recommendBanner: false, recommendBanner: false,
content: undefined content: undefined
@ -152,7 +148,10 @@ const formRules = reactive({
content: [{ required: true, message: '文章内容不能为空', trigger: 'blur' }] content: [{ required: true, message: '文章内容不能为空', trigger: 'blur' }]
}) })
const formRef = ref() // Ref const formRef = ref() // Ref
const spuSelectRef = ref() // Ref
const selectSpu = (spuId: number) => {
formData.value.spuId = spuId
}
/** 打开弹窗 */ /** 打开弹窗 */
const open = async (type: string, id?: number) => { const open = async (type: string, id?: number) => {
dialogVisible.value = true dialogVisible.value = true
@ -208,7 +207,7 @@ const resetForm = () => {
introduction: undefined, introduction: undefined,
sort: 0, sort: 0,
status: 0, status: 0,
spuId: undefined, spuId: 0,
recommendHot: false, recommendHot: false,
recommendBanner: false, recommendBanner: false,
content: undefined content: undefined

View File

@ -78,23 +78,23 @@
<!-- 列表 --> <!-- 列表 -->
<ContentWrap> <ContentWrap>
<el-table v-loading="loading" :data="list" :show-overflow-tooltip="true" :stripe="true"> <el-table v-loading="loading" :data="list" :show-overflow-tooltip="true" :stripe="true">
<el-table-column align="center" label="编号" prop="id" min-width="60" /> <el-table-column align="center" label="编号" min-width="60" prop="id" />
<el-table-column align="center" label="封面" prop="picUrl" min-width="80"> <el-table-column align="center" label="封面" min-width="80" prop="picUrl">
<template #default="{ row }"> <template #default="{ row }">
<el-image :src="row.picUrl" class="h-30px w-30px" @click="imagePreview(row.picUrl)" /> <el-image :src="row.picUrl" class="h-30px w-30px" @click="imagePreview(row.picUrl)" />
</template> </template>
</el-table-column> </el-table-column>
<el-table-column align="center" label="标题" prop="title" min-width="180" /> <el-table-column align="center" label="标题" min-width="180" prop="title" />
<el-table-column align="center" label="分类" prop="categoryId" min-width="180"> <el-table-column align="center" label="分类" min-width="180" prop="categoryId">
<template #default="scope"> <template #default="scope">
{{ categoryList.find((item) => item.id === scope.row.categoryId)?.name }} {{ categoryList.find((item) => item.id === scope.row.categoryId)?.name }}
</template> </template>
</el-table-column> </el-table-column>
<el-table-column align="center" label="浏览量" prop="browseCount" min-width="180" /> <el-table-column align="center" label="浏览量" min-width="180" prop="browseCount" />
<el-table-column align="center" label="作者" prop="author" min-width="180" /> <el-table-column align="center" label="作者" min-width="180" prop="author" />
<el-table-column align="center" label="文章简介" prop="introduction" min-width="250" /> <el-table-column align="center" label="文章简介" min-width="250" prop="introduction" />
<el-table-column align="center" label="排序" prop="sort" min-width="60" /> <el-table-column align="center" label="排序" min-width="60" prop="sort" />
<el-table-column align="center" label="状态" prop="status" min-width="60"> <el-table-column align="center" label="状态" min-width="60" prop="status">
<template #default="scope"> <template #default="scope">
<dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status" /> <dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status" />
</template> </template>
@ -167,7 +167,6 @@ const queryParams = reactive({
createTime: [] createTime: []
}) })
const queryFormRef = ref() // const queryFormRef = ref() //
const exportLoading = ref(false) //
/** 文章封面预览 */ /** 文章封面预览 */
const imagePreview = (imgUrl: string) => { const imagePreview = (imgUrl: string) => {
createImageViewer({ createImageViewer({