248 lines
8.3 KiB
Vue
248 lines
8.3 KiB
Vue
<!--
|
|
* @Descripttion: (商品评价/tb_goods_comment 添加弹窗)
|
|
* @version: (1.0)
|
|
* @Author: (admin)
|
|
* @Date: (2023-07-15)
|
|
* @LastEditors: (admin)
|
|
* @LastEditTime: (2023-07-15)
|
|
-->
|
|
<template>
|
|
<el-dialog v-model="props.modelValue" title="添加商品评价信息" width="900px" @closed="closeDialog" @open="openDialog">
|
|
<el-form ref="formRef" :model="formData" :rules="rules">
|
|
<el-row :gutter="20">
|
|
|
|
<el-col v-if="userid == 1" :lg="12">
|
|
<el-form-item :label-width="labelWidth" label="店铺" prop="shopGuid">
|
|
<el-input v-model='formData.shopName' disabled type="text" placeholder='点击选择店铺'>
|
|
<template #append>
|
|
<div @click="handleChooseShop">选择</div>
|
|
</template>
|
|
</el-input>
|
|
</el-form-item>
|
|
</el-col>
|
|
<el-col v-if="userid == 1" :lg="12">
|
|
<el-form-item :label-width="labelWidth" label="客户" prop="customerGuid">
|
|
<el-input v-model='formData.customerNickname' disabled type="text" placeholder='点击选择客户'>
|
|
<template #append>
|
|
<div @click="handleChooseCustomer">选择</div>
|
|
</template>
|
|
</el-input>
|
|
</el-form-item>
|
|
</el-col>
|
|
<el-col :lg="24">
|
|
<el-form-item :label-width="labelWidth" label="商品" prop="goodsGuid">
|
|
<el-input v-model='formData.goodsName' disabled type="text" placeholder='点击选择商品'>
|
|
<template #append>
|
|
<div @click="handleChooseGoods">选择</div>
|
|
</template>
|
|
</el-input>
|
|
</el-form-item>
|
|
</el-col>
|
|
<el-col :lg="12">
|
|
<el-form-item :label-width="labelWidth" label="评分分数" prop="goodsCommentRating">
|
|
<el-rate v-model="formData.goodsCommentRating" allow-half />
|
|
</el-form-item>
|
|
</el-col>
|
|
<el-col :lg="24">
|
|
<el-form-item :label-width="labelWidth" label="评价内容" prop="goodsCommentContent">
|
|
<el-input v-model="formData.goodsCommentContent" type="textarea" :rows="5" placeholder="请输入评价内容" />
|
|
</el-form-item>
|
|
</el-col>
|
|
<el-col :lg="24">
|
|
<el-form-item :label-width="labelWidth" label="评价图片" prop="goodsCommentImages">
|
|
<UploadImage ref="uploadRef" v-model="formData.goodsCommentImages" :data=imgData :limit="1" :fileSize="5"
|
|
:drag="true" />
|
|
</el-form-item>
|
|
</el-col>
|
|
<el-col :lg="12">
|
|
<el-form-item :label-width="labelWidth" label="显示状态" prop="goodsCommentStatus">
|
|
<el-radio-group v-model="formData.goodsCommentStatus">
|
|
<el-radio v-for="item in display_status " :key="item.dictValue" :label="parseInt(item.dictValue)">{{
|
|
item.dictLabel }}</el-radio>
|
|
</el-radio-group>
|
|
</el-form-item>
|
|
</el-col>
|
|
<el-col :lg="12">
|
|
<el-form-item :label-width="labelWidth" label="排序" prop="goodsCommentSort">
|
|
<el-input-number v-model.number="formData.goodsCommentSort" controls-position="right" :min="0" />
|
|
</el-form-item>
|
|
</el-col>
|
|
|
|
</el-row>
|
|
</el-form>
|
|
|
|
<template #footer>
|
|
<div key="dialog-footer">
|
|
<el-button type="primary" @click="handleAddClick(formRef)" :loading="loadingStatus">添加</el-button>
|
|
<el-button @click="handleResetClick(formRef)">重置</el-button>
|
|
</div>
|
|
</template>
|
|
</el-dialog>
|
|
|
|
<!-- 选择店铺 -->
|
|
<ChooseShopDialog v-model="ChooseShopDialogVisible" :data="ChooseShopDialogRow" :done="handelAddShop">
|
|
</ChooseShopDialog>
|
|
<!-- 选择客户 -->
|
|
<ChooseCustomerDialog v-model="ChooseCustomerDialogVisible" :data="ChooseCustomerDialogRow">
|
|
</ChooseCustomerDialog>
|
|
<!-- 选择商品 -->
|
|
<ChooseGoodsDialog v-model="ChooseGoodsDialogVisible" :data="ChooseGoodsDialogRow">
|
|
</ChooseGoodsDialog>
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
import { reactive, ref, watch } from "vue";
|
|
import { ElMessage } from 'element-plus'
|
|
import modal from '@/plugins/modal.js'
|
|
import useUserStore from '@/store/modules/user'
|
|
import { addOrUpdateGoodsComment } from '@/api/business/GoodsManager/GoodsComments/goodsComment.js';
|
|
import ChooseShopDialog from '@/views/business/components/ChooseShopDialog.vue';
|
|
import ChooseCustomerDialog from '@/views/business/components/ChooseCustomerDialog.vue';
|
|
import ChooseGoodsDialog from '@/views/business/components/ChooseGoodsDialog.vue';
|
|
|
|
// 打开弹窗时回调
|
|
const openDialog = async () => {
|
|
|
|
await getrating_type()
|
|
await getrecover_status()
|
|
await getdisplay_status()
|
|
|
|
}
|
|
|
|
// -业务参数
|
|
// 当前用户id
|
|
const userid = useUserStore().userId
|
|
// 评分类型字典选项列表
|
|
const rating_type = ref([]);
|
|
// 回复状态字典选项列表
|
|
const recover_status = ref([]);
|
|
// 显示状态字典选项列表
|
|
const display_status = ref([]);
|
|
// 选择店铺弹窗参数
|
|
const ChooseShopDialogVisible = ref(false);
|
|
const ChooseShopDialogRow = ref({});
|
|
// 选择客户弹窗参数
|
|
const ChooseCustomerDialogVisible = ref(false);
|
|
const ChooseCustomerDialogRow = ref({});
|
|
// 选择商品弹窗参数
|
|
const ChooseGoodsDialogVisible = ref(false);
|
|
const ChooseGoodsDialogRow = ref({});
|
|
|
|
// -业务方法
|
|
// 字典获取
|
|
async function getrating_type() {
|
|
await proxy.getDicts('rating_type').then((res) => {
|
|
rating_type.value = res.data
|
|
})
|
|
}
|
|
// 字典获取
|
|
async function getrecover_status() {
|
|
await proxy.getDicts('recover_status').then((res) => {
|
|
recover_status.value = res.data
|
|
})
|
|
}
|
|
// 字典获取
|
|
async function getdisplay_status() {
|
|
await proxy.getDicts('display_status').then((res) => {
|
|
display_status.value = res.data
|
|
})
|
|
}
|
|
|
|
|
|
// 打开选择店铺弹窗
|
|
const handleChooseShop = () => {
|
|
ChooseShopDialogVisible.value = true
|
|
ChooseShopDialogRow.value = formData
|
|
}
|
|
|
|
// 处理添加店铺后的回调
|
|
async function handelAddShop() {
|
|
|
|
}
|
|
|
|
// 打开选择客户弹窗
|
|
const handleChooseCustomer = () => {
|
|
ChooseCustomerDialogVisible.value = true
|
|
ChooseCustomerDialogRow.value = formData
|
|
}
|
|
|
|
// 打开选择商品弹窗
|
|
const handleChooseGoods = () => {
|
|
if(!formData.shopGuid && userid == 1){
|
|
modal.msgError("请先选择店铺")
|
|
return
|
|
}
|
|
ChooseGoodsDialogVisible.value = true
|
|
ChooseGoodsDialogRow.value = formData
|
|
}
|
|
|
|
|
|
// -基础参数
|
|
const loadingStatus = ref(false)
|
|
const labelWidth = 100;
|
|
const formRef = ref();
|
|
const { proxy } = getCurrentInstance()
|
|
const emits = defineEmits(["update:modelValue"]);
|
|
const formData = reactive({
|
|
goodsCommentStatus: 1,
|
|
goodsCommentSort: 100
|
|
});
|
|
const props = defineProps({
|
|
modelValue: Boolean,
|
|
done: Function,
|
|
});
|
|
const imgData = ref({
|
|
fileDir: "GoodsComment"
|
|
})
|
|
|
|
// 验证
|
|
const rules = reactive({
|
|
shopGuid: [{ required: true, message: "店铺不能为空", trigger: "blur" }],
|
|
customerGuid: [{ required: true, message: "客户不能为空", trigger: "blur" }],
|
|
goodsGuid: [{ required: true, message: "商品不能为空", trigger: "blur" }],
|
|
goodsCommentRating: [{ required: true, message: "评分分数不能为空", trigger: "blur",type: "number" }],
|
|
goodsCommentRatingType: [{ required: true, message: "评分类型不能为空", trigger: "change", type: "number" }],
|
|
goodsCommentContent: [{ required: true, message: "评价内容不能为空", trigger: "blur" }],
|
|
goodsCommentRecoverStatus: [{ required: true, message: "回复状态不能为空", trigger: "blur", type: "number" }],
|
|
goodsCommentStatus: [{ required: true, message: "显示状态不能为空", trigger: "blur", type: "number" }],
|
|
goodsCommentSort: [{ required: true, message: "排序不能为空", trigger: "blur", type: "number" }],
|
|
});
|
|
|
|
// -基础方法
|
|
|
|
// 提交
|
|
const handleAddClick = async (formEl) => {
|
|
if (!formEl) return;
|
|
formEl.validate(async (valid) => {
|
|
if (!valid) {
|
|
return;
|
|
}
|
|
loadingStatus.value = true
|
|
|
|
|
|
const { code } = await addOrUpdateGoodsComment(formData);
|
|
if (code == 200) {
|
|
modal.msgSuccess('添加成功')
|
|
closeDialog();
|
|
loadingStatus.value = false
|
|
}
|
|
});
|
|
};
|
|
const closeDialog = () => {
|
|
formData.shopName = ""
|
|
formData.shopGuid = 0
|
|
formData.customerNickname = ""
|
|
formData.customerGuid = 0
|
|
formData.goodsName = ""
|
|
formData.goodsGuid = 0
|
|
formData.goodsCommentRating = 0
|
|
handleResetClick(formRef.value);
|
|
props.done();
|
|
emits("update:modelValue", false);
|
|
};
|
|
const handleResetClick = async (formEl) => {
|
|
if (!formEl) return;
|
|
formEl.resetFields();
|
|
};
|
|
</script> |