From a1d7e81859f554f3a53680cc35f0f49bf1f77098 Mon Sep 17 00:00:00 2001
From: wwf <1971391498@qq.com>
Date: 星期四, 14 五月 2026 14:37:02 +0800
Subject: [PATCH] 导入项目
---
src/views/mall/product/comment/index.vue | 259 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 259 insertions(+), 0 deletions(-)
diff --git a/src/views/mall/product/comment/index.vue b/src/views/mall/product/comment/index.vue
new file mode 100644
index 0000000..c598974
--- /dev/null
+++ b/src/views/mall/product/comment/index.vue
@@ -0,0 +1,259 @@
+<template>
+ <doc-alert title="銆愬晢鍝併�戝晢鍝佽瘎浠�" url="https://doc.iocoder.cn/mall/product-comment/" />
+
+ <ContentWrap>
+ <!-- 鎼滅储宸ヤ綔鏍� -->
+ <el-form
+ class="-mb-15px"
+ :model="queryParams"
+ ref="queryFormRef"
+ :inline="true"
+ label-width="68px"
+ >
+ <el-form-item label="鍥炲鐘舵��" prop="replyStatus">
+ <el-select v-model="queryParams.replyStatus" class="!w-240px">
+ <el-option label="宸插洖澶�" :value="true" />
+ <el-option label="鏈洖澶�" :value="false" />
+ </el-select>
+ </el-form-item>
+ <el-form-item label="鍟嗗搧鍚嶇О" prop="spuName">
+ <el-input
+ v-model="queryParams.spuName"
+ placeholder="璇疯緭鍏ュ晢鍝佸悕绉�"
+ @keyup.enter="handleQuery"
+ class="!w-240px"
+ />
+ </el-form-item>
+ <el-form-item label="鐢ㄦ埛鍚嶇О" prop="userNickname">
+ <el-input
+ v-model="queryParams.userNickname"
+ placeholder="璇疯緭鍏ョ敤鎴峰悕绉�"
+ @keyup.enter="handleQuery"
+ class="!w-240px"
+ />
+ </el-form-item>
+ <el-form-item label="璁㈠崟缂栧彿" prop="orderId">
+ <el-input
+ v-model="queryParams.orderId"
+ placeholder="璇疯緭鍏ヨ鍗曠紪鍙�"
+ @keyup.enter="handleQuery"
+ class="!w-240px"
+ />
+ </el-form-item>
+ <el-form-item label="璇勮鏃堕棿" prop="createTime">
+ <el-date-picker
+ v-model="queryParams.createTime"
+ value-format="YYYY-MM-DD HH:mm:ss"
+ type="daterange"
+ start-placeholder="寮�濮嬫棩鏈�"
+ end-placeholder="缁撴潫鏃ユ湡"
+ :default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
+ class="!w-240px"
+ />
+ </el-form-item>
+ <el-form-item>
+ <el-button @click="handleQuery">
+ <Icon icon="ep:search" class="mr-5px" />
+ 鎼滅储
+ </el-button>
+ <el-button @click="resetQuery">
+ <Icon icon="ep:refresh" class="mr-5px" />
+ 閲嶇疆
+ </el-button>
+ <el-button
+ type="primary"
+ plain
+ @click="openForm('create')"
+ v-hasPermi="['product:comment:create']"
+ >
+ <Icon icon="ep:plus" class="mr-5px" />
+ 娣诲姞铏氭嫙璇勮
+ </el-button>
+ </el-form-item>
+ </el-form>
+ </ContentWrap>
+
+ <!-- 鍒楄〃 -->
+ <ContentWrap>
+ <el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="false">
+ <el-table-column label="璇勮缂栧彿" align="center" prop="id" min-width="80" />
+ <el-table-column label="鍟嗗搧淇℃伅" align="center" min-width="400">
+ <template #default="scope">
+ <div class="row flex items-center gap-x-4px">
+ <el-image
+ v-if="scope.row.skuPicUrl"
+ :src="scope.row.skuPicUrl"
+ :preview-src-list="[scope.row.skuPicUrl]"
+ class="h-40px w-40px shrink-0"
+ preview-teleported
+ />
+ <div>{{ scope.row.spuName }}</div>
+ <el-tag
+ v-for="property in scope.row.skuProperties"
+ :key="property.propertyId"
+ class="mr-10px"
+ >
+ {{ property.propertyName }}: {{ property.valueName }}
+ </el-tag>
+ </div>
+ </template>
+ </el-table-column>
+ <el-table-column label="鐢ㄦ埛鍚嶇О" align="center" prop="userNickname" width="100" />
+ <el-table-column label="鍟嗗搧璇勫垎" align="center" prop="descriptionScores" width="90" />
+ <el-table-column label="鏈嶅姟璇勫垎" align="center" prop="benefitScores" width="90" />
+ <el-table-column label="璇勮鍐呭" align="center" prop="content" min-width="210">
+ <template #default="scope">
+ <p>{{ scope.row.content }}</p>
+ <div class="flex justify-center gap-x-4px">
+ <el-image
+ v-for="(picUrl, index) in scope.row.picUrls"
+ :key="index"
+ :src="picUrl"
+ :preview-src-list="scope.row.picUrls"
+ :initial-index="index"
+ class="h-40px w-40px"
+ preview-teleported
+ />
+ </div>
+ </template>
+ </el-table-column>
+ <el-table-column
+ label="鍥炲鍐呭"
+ align="center"
+ prop="replyContent"
+ min-width="250"
+ show-overflow-tooltip
+ />
+ <el-table-column
+ label="璇勮鏃堕棿"
+ align="center"
+ prop="createTime"
+ :formatter="dateFormatter"
+ width="180"
+ />
+ <el-table-column label="鏄惁灞曠ず" align="center" width="80px">
+ <template #default="scope">
+ <el-switch
+ v-model="scope.row.visible"
+ :active-value="true"
+ :inactive-value="false"
+ v-hasPermi="['product:comment:update']"
+ @change="handleVisibleChange(scope.row)"
+ />
+ </template>
+ </el-table-column>
+ <el-table-column label="鎿嶄綔" align="center" min-width="60px" fixed="right">
+ <template #default="scope">
+ <el-button
+ link
+ type="primary"
+ @click="handleReply(scope.row.id)"
+ v-hasPermi="['product:comment:update']"
+ >
+ 鍥炲
+ </el-button>
+ </template>
+ </el-table-column>
+ </el-table>
+ <!-- 鍒嗛〉 -->
+ <Pagination
+ :total="total"
+ v-model:page="queryParams.pageNo"
+ v-model:limit="queryParams.pageSize"
+ @pagination="getList"
+ />
+ </ContentWrap>
+
+ <!-- 琛ㄥ崟寮圭獥锛氭坊鍔�/淇敼 -->
+ <CommentForm ref="formRef" @success="getList" />
+ <!-- 鍥炲琛ㄥ崟寮圭獥 -->
+ <ReplyForm ref="replyFormRef" @success="getList" />
+</template>
+
+<script setup lang="ts">
+import { dateFormatter } from '@/utils/formatTime'
+import * as CommentApi from '@/api/mall/product/comment'
+import CommentForm from './CommentForm.vue'
+import ReplyForm from './ReplyForm.vue'
+
+defineOptions({ name: 'ProductComment' })
+
+const message = useMessage() // 娑堟伅寮圭獥
+const { t } = useI18n() // 鍥介檯鍖�
+
+const loading = ref(true) // 鍒楄〃鐨勫姞杞戒腑
+const total = ref(0) // 鍒楄〃鐨勬�婚〉鏁�
+const list = ref([]) // 鍒楄〃鐨勬暟鎹�
+const queryParams = reactive({
+ pageNo: 1,
+ pageSize: 10,
+ replyStatus: null,
+ spuName: null,
+ userNickname: null,
+ orderId: null,
+ createTime: []
+})
+const queryFormRef = ref() // 鎼滅储鐨勮〃鍗�
+
+/** 鏌ヨ鍒楄〃 */
+const getList = async () => {
+ loading.value = true
+ try {
+ const data = await CommentApi.getCommentPage(queryParams)
+ // visible 濡傛灉涓� null锛屼細瀵艰嚧鍒锋柊鐨勬椂鍊欒Е鍙� e-switch 鐨� change 浜嬩欢
+ data.list.forEach((item) => {
+ if (!item.visible) {
+ item.visible = false
+ }
+ })
+ list.value = data.list
+ total.value = data.total
+ } finally {
+ loading.value = false
+ }
+}
+
+/** 鎼滅储鎸夐挳鎿嶄綔 */
+const handleQuery = () => {
+ queryParams.pageNo = 1
+ getList()
+}
+
+/** 閲嶇疆鎸夐挳鎿嶄綔 */
+const resetQuery = () => {
+ queryFormRef.value.resetFields()
+ handleQuery()
+}
+
+/** 娣诲姞/淇敼鎿嶄綔 */
+const formRef = ref()
+const openForm = (type: string, id?: number) => {
+ formRef.value.open(type, id)
+}
+
+/** 鍥炲鎸夐挳鎿嶄綔 **/
+const replyFormRef = ref()
+const handleReply = (id: number) => {
+ replyFormRef.value.open(id)
+}
+
+/** 鏄剧ず/闅愯棌 **/
+const handleVisibleChange = async (row: CommentApi.CommentVO) => {
+ if (loading.value) {
+ return
+ }
+ let changedValue = row.visible
+ try {
+ await message.confirm(changedValue ? '鏄惁鏄剧ず璇勮锛�' : '鏄惁闅愯棌璇勮锛�')
+ await CommentApi.updateCommentVisible({ id: row.id, visible: changedValue })
+ await getList()
+ } catch {
+ row.visible = !changedValue
+ }
+}
+
+/** 鍒濆鍖� **/
+onMounted(() => {
+ getList()
+})
+</script>
--
Gitblit v1.8.0