mirror of
https://gitee.com/hhyykk/ipms-sjy-ui.git
synced 2025-08-24 06:51:54 +08:00
多图上传组件优化
This commit is contained in:
@@ -1,17 +1,17 @@
|
||||
<template>
|
||||
<Dialog title="添加虚拟评论" v-model="dialogVisible">
|
||||
<Dialog v-model="dialogVisible" title="添加虚拟评论">
|
||||
<el-form
|
||||
ref="formRef"
|
||||
v-loading="formLoading"
|
||||
:model="formData"
|
||||
:rules="formRules"
|
||||
label-width="100px"
|
||||
v-loading="formLoading"
|
||||
>
|
||||
<el-form-item label="商品" prop="spuId">
|
||||
<SpuShowcase v-model="formData.spuId" :limit="1" />
|
||||
</el-form-item>
|
||||
<el-form-item label="商品规格" prop="skuId" v-if="formData.spuId">
|
||||
<div @click="handleSelectSku" class="h-60px w-60px">
|
||||
<el-form-item v-if="formData.spuId" label="商品规格" prop="skuId">
|
||||
<div class="h-60px w-60px" @click="handleSelectSku">
|
||||
<div v-if="skuData && skuData.picUrl">
|
||||
<el-image :src="skuData.picUrl" />
|
||||
</div>
|
||||
@@ -27,7 +27,7 @@
|
||||
<el-input v-model="formData.userNickname" placeholder="请输入用户名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="评论内容" prop="content">
|
||||
<el-input type="textarea" v-model="formData.content" />
|
||||
<el-input v-model="formData.content" type="textarea" />
|
||||
</el-form-item>
|
||||
<el-form-item label="描述星级" prop="descriptionScores">
|
||||
<el-rate v-model="formData.descriptionScores" />
|
||||
@@ -40,13 +40,13 @@
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="submitForm" type="primary" :disabled="formLoading">确 定</el-button>
|
||||
<el-button :disabled="formLoading" type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||
</template>
|
||||
</Dialog>
|
||||
<SkuTableSelect ref="skuTableSelectRef" @change="handleSkuChange" :spu-id="formData.spuId" />
|
||||
<SkuTableSelect ref="skuTableSelectRef" :spu-id="formData.spuId" @change="handleSkuChange" />
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
<script lang="ts" setup>
|
||||
import * as CommentApi from '@/api/mall/product/comment'
|
||||
import SpuShowcase from '@/views/mall/product/spu/components/SpuShowcase.vue'
|
||||
import * as ProductSpuApi from '@/api/mall/product/spu'
|
||||
@@ -115,13 +115,8 @@ const submitForm = async () => {
|
||||
// 提交请求
|
||||
formLoading.value = true
|
||||
try {
|
||||
//处理评论图片
|
||||
const picUrls = formData.value.picUrls.map((item) => {
|
||||
return item?.url ? item.url : item
|
||||
})
|
||||
const data = { ...formData.value, picUrls }
|
||||
if (formType.value === 'create') {
|
||||
await CommentApi.createComment(data)
|
||||
await CommentApi.createComment(unref(formData.value) as any)
|
||||
message.success(t('common.createSuccess'))
|
||||
}
|
||||
dialogVisible.value = false
|
||||
|
@@ -1,16 +1,16 @@
|
||||
<!-- 商品发布 - 基础设置 -->
|
||||
<template>
|
||||
<el-form ref="formRef" :model="formData" :rules="rules" label-width="120px" :disabled="isDetail">
|
||||
<el-form ref="formRef" :disabled="isDetail" :model="formData" :rules="rules" label-width="120px">
|
||||
<el-form-item label="商品名称" prop="name">
|
||||
<el-input
|
||||
v-model="formData.name"
|
||||
:autosize="{ minRows: 2, maxRows: 2 }"
|
||||
:clearable="true"
|
||||
:show-word-limit="true"
|
||||
class="w-80!"
|
||||
maxlength="64"
|
||||
placeholder="请输入商品名称"
|
||||
type="textarea"
|
||||
:autosize="{ minRows: 2, maxRows: 2 }"
|
||||
maxlength="64"
|
||||
:show-word-limit="true"
|
||||
:clearable="true"
|
||||
class="w-80!"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="商品分类" prop="categoryId">
|
||||
@@ -20,12 +20,12 @@
|
||||
:props="defaultProps"
|
||||
class="w-80"
|
||||
clearable
|
||||
placeholder="请选择商品分类"
|
||||
filterable
|
||||
placeholder="请选择商品分类"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="商品品牌" prop="brandId">
|
||||
<el-select v-model="formData.brandId" placeholder="请选择商品品牌" class="w-80">
|
||||
<el-select v-model="formData.brandId" class="w-80" placeholder="请选择商品品牌">
|
||||
<el-option
|
||||
v-for="item in brandList"
|
||||
:key="item.id"
|
||||
@@ -35,25 +35,25 @@
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="商品关键字" prop="keyword">
|
||||
<el-input v-model="formData.keyword" placeholder="请输入商品关键字" class="w-80!" />
|
||||
<el-input v-model="formData.keyword" class="w-80!" placeholder="请输入商品关键字" />
|
||||
</el-form-item>
|
||||
<el-form-item label="商品简介" prop="introduction">
|
||||
<el-input
|
||||
v-model="formData.introduction"
|
||||
:autosize="{ minRows: 2, maxRows: 2 }"
|
||||
:clearable="true"
|
||||
:show-word-limit="true"
|
||||
class="w-80!"
|
||||
maxlength="128"
|
||||
placeholder="请输入商品名称"
|
||||
type="textarea"
|
||||
:autosize="{ minRows: 2, maxRows: 2 }"
|
||||
maxlength="128"
|
||||
:show-word-limit="true"
|
||||
:clearable="true"
|
||||
class="w-80!"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="商品封面图" prop="picUrl">
|
||||
<UploadImg v-model="formData.picUrl" height="80px" :disabled="isDetail" />
|
||||
<UploadImg v-model="formData.picUrl" :disabled="isDetail" height="80px" />
|
||||
</el-form-item>
|
||||
<el-form-item label="商品轮播图" prop="sliderPicUrls">
|
||||
<UploadImgs v-model:modelValue="formData.sliderPicUrls" :disabled="isDetail" />
|
||||
<UploadImgs v-model="formData.sliderPicUrls" :disabled="isDetail" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</template>
|
||||
@@ -64,9 +64,9 @@ import { propTypes } from '@/utils/propTypes'
|
||||
import { defaultProps, handleTree } from '@/utils/tree'
|
||||
import type { Spu } from '@/api/mall/product/spu'
|
||||
import * as ProductCategoryApi from '@/api/mall/product/category'
|
||||
import { CategoryVO } from '@/api/mall/product/category'
|
||||
import * as ProductBrandApi from '@/api/mall/product/brand'
|
||||
import { BrandVO } from '@/api/mall/product/brand'
|
||||
import { CategoryVO } from '@/api/mall/product/category'
|
||||
|
||||
defineOptions({ name: 'ProductSpuInfoForm' })
|
||||
const props = defineProps({
|
||||
@@ -107,10 +107,6 @@ watch(
|
||||
return
|
||||
}
|
||||
copyValueToTarget(formData, data)
|
||||
// TODO @puhui999:优化多文件上传,看看有没可能搞成返回 v-model 图片列表这种
|
||||
formData.sliderPicUrls = data['sliderPicUrls']?.map((item) => ({
|
||||
url: item
|
||||
}))
|
||||
},
|
||||
{
|
||||
immediate: true
|
||||
|
Reference in New Issue
Block a user