index.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item label="用户" prop="userId">
  5. <el-input
  6. v-model="queryParams.userId"
  7. placeholder="请输入用户id"
  8. clearable
  9. size="small"
  10. @keyup.enter.native="handleQuery"
  11. />
  12. </el-form-item>
  13. <el-form-item label="联系方式" prop="phone">
  14. <el-input
  15. v-model="queryParams.phone"
  16. placeholder="请输入联系方式"
  17. clearable
  18. size="small"
  19. @keyup.enter.native="handleQuery"
  20. />
  21. </el-form-item>
  22. <el-form-item label="处理状态" prop="isHandleStore">
  23. <el-select
  24. v-model="queryParams.isHandleStore"
  25. placeholder="请选择处理状态"
  26. clearable
  27. size="small"
  28. >
  29. <el-option label="未处理" value="0"></el-option>
  30. <el-option label="已处理" value="1"></el-option>
  31. </el-select>
  32. </el-form-item>
  33. <el-form-item label="投诉时间" prop="complaintTime">
  34. <el-date-picker v-model="complaintTime" size="small" style="width: 220px" value-format="yyyy-MM-dd" type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" @change="changeTime"></el-date-picker>
  35. </el-form-item>
  36. <el-form-item>
  37. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  38. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  39. </el-form-item>
  40. </el-form>
  41. <el-row :gutter="10" class="mb8">
  42. <el-col :span="1.5">
  43. <el-button
  44. type="warning"
  45. plain
  46. icon="el-icon-download"
  47. size="mini"
  48. :loading="exportLoading"
  49. @click="handleExport"
  50. >导出</el-button>
  51. </el-col>
  52. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  53. </el-row>
  54. <el-table border v-loading="loading" :data="complaintList" @selection-change="handleSelectionChange">
  55. <el-table-column type="selection" width="55" align="center" />
  56. <el-table-column label="id" align="center" prop="id" />
  57. <el-table-column label="用户" align="center" prop="nickName" />
  58. <el-table-column label="投诉方式" align="center" prop="complaintType" >
  59. <template slot-scope="scope">
  60. <template v-for="item in complaintTypeOptions">
  61. <el-tag v-if="item.dictValue === scope.row.complaintType" :key="item.dictValue">
  62. {{ item.dictLabel }}
  63. </el-tag>
  64. </template>
  65. </template>
  66. </el-table-column>
  67. <el-table-column label="投诉类型" align="center" prop="type" >
  68. <template slot-scope="scope">
  69. <dict-tag :options="typeOptions" :value="scope.row.type"/>
  70. </template>
  71. </el-table-column>
  72. <el-table-column label="投诉时间" align="center" prop="createTime" />
  73. <el-table-column
  74. label="店铺是否处理"
  75. align="center"
  76. prop="isHandlePlatform"
  77. :render-header="renderHandleHeader"
  78. >
  79. <template slot-scope="scope">
  80. <el-tag
  81. :type="(scope.row.isHandleStore == 1)? 'success' : 'warning'"
  82. disable-transitions
  83. >
  84. {{ formatHandleStatus(scope.row.isHandle) }}
  85. </el-tag>
  86. </template>
  87. </el-table-column>
  88. <el-table-column label="备注" align="center" prop="remarks" />
  89. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  90. <template slot-scope="scope">
  91. <el-button
  92. size="mini"
  93. type="text"
  94. icon="el-icon-edit"
  95. @click="handleUpdate(scope.row)"
  96. >投诉详情</el-button>
  97. </template>
  98. </el-table-column>
  99. </el-table>
  100. <pagination
  101. v-show="total>0"
  102. :total="total"
  103. :page.sync="queryParams.pageNum"
  104. :limit.sync="queryParams.pageSize"
  105. @pagination="getList"
  106. />
  107. <!-- 修改用户投诉对话框 -->
  108. <el-dialog :title="title" :visible.sync="open" width="900px" append-to-body>
  109. <!-- 修改tab-click事件处理器名称 -->
  110. <el-tabs v-model="activeTab" type="card" @tab-click="handleClick">
  111. <!-- 投诉详情标签页 -->
  112. <el-tab-pane label="投诉详情" name="complaint">
  113. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  114. <el-form-item label="投诉内容" prop="name">
  115. <el-input v-model="form.name" :disabled="true" />
  116. </el-form-item>
  117. <el-form-item label="详细内容" v-if="form.content && form.content!=''">
  118. <el-input type="textarea" v-model="form.content" :disabled="true"/>
  119. </el-form-item>
  120. <el-form-item label="联系方式" prop="phone" v-if="form.phone && form.phone!=''">
  121. <el-input v-model="form.phone" :disabled="true"/>
  122. </el-form-item>
  123. <el-form-item label="图片" v-if="form.images && form.images!=''">
  124. <div v-for="(url, index) in imageUrls(form.images)" :key="index" class="image-container">
  125. <el-image :src="url" :preview-src-list="[url]" style="width: 100px; height: 100px;"></el-image>
  126. </div>
  127. </el-form-item>
  128. <!-- <el-form-item label="交易截图" v-if="form.tradeImage && form.tradeImage!=''">
  129. <div v-for="(url, index) in imageUrls(form.tradeImage)" :key="index" class="image-container">
  130. <el-image :src="url" :preview-src-list="[url]" style="width: 100px; height: 100px;"></el-image>
  131. </div>
  132. </el-form-item> -->
  133. <el-form-item label="用户" prop="nickName">
  134. <el-input v-model="form.nickName" :disabled="true"/>
  135. </el-form-item>
  136. <el-form-item label="是否处理" prop="isHandleStore">
  137. <el-select v-model="form.isHandleStore" placeholder="请选择处理状态" :disabled="true">
  138. <el-option label="未处理" :value="0"></el-option>
  139. <el-option label="已处理" :value="1"></el-option>
  140. </el-select>
  141. </el-form-item>
  142. <el-form-item label="备注" prop="remarks" >
  143. <el-input type="textarea" v-model="form.remarks" :maxlength="250" :disabled="true"/>
  144. </el-form-item>
  145. </el-form>
  146. </el-tab-pane>
  147. <!-- 回复详情标签页 -->
  148. <el-tab-pane label="回复详情" name="replies">
  149. <div class="reply-section">
  150. <!-- 添加回复表单 -->
  151. <el-card class="add-reply-card" shadow="never">
  152. <div slot="header">
  153. <span>添加回复</span>
  154. </div>
  155. <el-form :model="replyForm" ref="replyForm" label-width="80px">
  156. <el-form-item label="回复内容" prop="content" :rules="[{ required: true, message: '请输入回复内容', trigger: 'blur' }]">
  157. <el-input
  158. type="textarea"
  159. v-model="replyForm.content"
  160. placeholder="请输入回复内容"
  161. :rows="3"
  162. maxlength="500"
  163. show-word-limit
  164. />
  165. </el-form-item>
  166. <!-- 添加图片上传功能 -->
  167. <el-form-item label="上传图片" prop="images">
  168. <!-- <div class="image-upload-container">
  169. <el-upload
  170. ref="imageUpload"
  171. :action="uploadUrl"
  172. :show-file-list="false"
  173. :file-list="replyImageList"
  174. :on-success="handleSuccess"
  175. :before-upload="beforeUpload"
  176. :limit="4"
  177. list-type="picture-card"
  178. accept="image/*"
  179. >
  180. <i class="el-icon-plus"></i>
  181. <div slot="tip" class="el-upload__tip">
  182. 最多上传4张图片,单张图片不超过2MB
  183. </div>
  184. </el-upload>
  185. </div> -->
  186. <ImageUpload v-model="replyForm.images" type="image" :num="4" :width="150" :height="150"/>
  187. </el-form-item>
  188. <el-form-item>
  189. <el-button type="primary" size="small" @click="submitReply" :loading="replyLoading">
  190. <i class="el-icon-s-promotion"></i> 发送回复
  191. </el-button>
  192. </el-form-item>
  193. </el-form>
  194. </el-card>
  195. <!-- 回复列表 -->
  196. <el-card class="reply-list-card" shadow="never">
  197. <div slot="header">
  198. <span>回复记录 ({{ replyTotal }}条)</span>
  199. </div>
  200. <div v-loading="replyLoading" class="reply-list">
  201. <div v-if="replyList.length === 0" class="empty-replies">
  202. <el-empty description="暂无回复记录" :image-size="100"></el-empty>
  203. </div>
  204. <div v-else>
  205. <div v-for="reply in replyList" :key="reply.id" class="reply-item">
  206. <div class="reply-header">
  207. <div class="reply-user">
  208. <el-avatar :size="32" :src="reply.avatar || '/default-avatar.png'">
  209. {{ reply.userName ? reply.userName.charAt(0) : 'U' }}
  210. </el-avatar>
  211. <!-- <span class="user-name">{{ reply.userName || '系统管理员' }}</span> -->
  212. <el-tag size="mini" :type="reply.sendType != 1 ? 'success' : 'info'">
  213. {{ reply.sendType === 1 ? '用户' : reply.sendType === 2 ? '系统平台':'店铺平台' }}
  214. </el-tag>
  215. </div>
  216. <div class="reply-time">
  217. {{ reply.createTime }}
  218. </div>
  219. </div>
  220. <div class="reply-content">
  221. {{ reply.content }}
  222. </div>
  223. <!-- 显示回复中的图片 -->
  224. <div class="reply-images" v-if="reply.images && reply.images !== ''">
  225. <div v-for="(url, index) in imageUrls(reply.images)" :key="index" class="reply-image-container">
  226. <el-image
  227. :src="url"
  228. :preview-src-list="imageUrls(reply.images)"
  229. style="width: 80px; height: 80px;"
  230. fit="cover"
  231. ></el-image>
  232. </div>
  233. </div>
  234. <div class="reply-actions" v-if="reply.userType === 'admin'">
  235. <el-button type="text" size="mini" @click="editReply(reply)">
  236. <i class="el-icon-edit"></i> 编辑
  237. </el-button>
  238. <el-button type="text" size="mini" @click="deleteReply(reply)" style="color: #f56c6c;">
  239. <i class="el-icon-delete"></i> 删除
  240. </el-button>
  241. </div>
  242. </div>
  243. </div>
  244. </div>
  245. <!-- 回复分页 -->
  246. <div class="reply-pagination" v-if="replyTotal > 0">
  247. <el-pagination
  248. @size-change="handleReplySizeChange"
  249. @current-change="handleReplyCurrentChange"
  250. :current-page="replyQueryParams.pageNum"
  251. :page-sizes="[5, 10, 20]"
  252. :page-size="replyQueryParams.pageSize"
  253. layout="total, sizes, prev, pager, next, jumper"
  254. :total="replyTotal"
  255. small
  256. />
  257. </div>
  258. </el-card>
  259. </div>
  260. </el-tab-pane>
  261. </el-tabs>
  262. <div slot="footer" class="dialog-footer">
  263. <el-button type="primary" @click="submitForm" v-if="activeTab === 'complaint' && form.id==null">确 定</el-button>
  264. <el-button @click="cancel">取 消</el-button>
  265. </div>
  266. </el-dialog>
  267. <!-- 编辑回复对话框 -->
  268. <el-dialog title="编辑回复" :visible.sync="editReplyVisible" width="500px" append-to-body>
  269. <el-form :model="editReplyForm" ref="editReplyForm" label-width="80px">
  270. <el-form-item label="回复内容" prop="content" :rules="[{ required: true, message: '请输入回复内容', trigger: 'blur' }]">
  271. <el-input
  272. type="textarea"
  273. v-model="editReplyForm.content"
  274. placeholder="请输入回复内容"
  275. :rows="4"
  276. maxlength="500"
  277. show-word-limit
  278. />
  279. </el-form-item>
  280. </el-form>
  281. <div slot="footer" class="dialog-footer">
  282. <el-button type="primary" @click="updateReply" :loading="replyLoading">确 定</el-button>
  283. <el-button @click="editReplyVisible = false">取 消</el-button>
  284. </div>
  285. </el-dialog>
  286. </div>
  287. </template>
  288. <script>
  289. import { listComplaint, getComplaint, delComplaint, addComplaint, updateComplaint, exportComplaint,listMsg,addMsg } from "@/api/store/complaint";
  290. import ImageUpload from '@/components/ImageUpload/index';
  291. export default {
  292. name: "Complaint",
  293. components: {
  294. ImageUpload
  295. },
  296. data() {
  297. return {
  298. replyImageList: [],
  299. uploadUrl:process.env.VUE_APP_BASE_API+"/common/uploadOSS",
  300. complaintId:null,
  301. activeName:"0",
  302. typeOptions:[
  303. {
  304. dictValue:'0',
  305. dictLabel:'默认'
  306. },
  307. {
  308. dictValue:'1',
  309. dictLabel:'店铺'
  310. },
  311. {
  312. dictValue:'2',
  313. dictLabel:'商品'
  314. },
  315. ],
  316. complaintTypeOptions:[
  317. {
  318. dictValue:1,
  319. dictLabel:'咨询'
  320. },
  321. {
  322. dictValue:2,
  323. dictLabel:'投诉/举报'
  324. },
  325. ],
  326. complaintTime:null,
  327. // 遮罩层
  328. loading: true,
  329. // 导出遮罩层
  330. exportLoading: false,
  331. // 选中数组
  332. ids: [],
  333. // 非单个禁用
  334. single: true,
  335. // 非多个禁用
  336. multiple: true,
  337. // 显示搜索条件
  338. showSearch: true,
  339. // 总条数
  340. total: 0,
  341. // 用户投诉表格数据
  342. complaintList: [],
  343. // 弹出层标题
  344. title: "",
  345. // 是否显示弹出层
  346. open: false,
  347. // 当前激活的标签页
  348. activeTab: 'complaint',
  349. // 查询参数
  350. queryParams: {
  351. pageNum: 1,
  352. pageSize: 10,
  353. userId: null,
  354. userName: null,
  355. templateId: null,
  356. content: null,
  357. phone: null,
  358. urls: null,
  359. account: null,
  360. isHandle: null
  361. },
  362. // 表单参数
  363. form: {},
  364. // 表单校验
  365. rules: {
  366. userId: [
  367. { required: true, message: "用户id不能为空", trigger: "blur" }
  368. ],
  369. templateId: [
  370. { required: true, message: "投诉模板id不能为空", trigger: "blur" }
  371. ],
  372. },
  373. // 回复相关数据
  374. replyList: [],
  375. replyTotal: 0,
  376. replyLoading: false,
  377. replyQueryParams: {
  378. pageNum: 1,
  379. pageSize: 10,
  380. complaintId: null
  381. },
  382. replyForm: {
  383. content: '',
  384. complaintId: null
  385. },
  386. // 编辑回复
  387. editReplyVisible: false,
  388. editReplyForm: {
  389. id: null,
  390. content: ''
  391. }
  392. };
  393. },
  394. created() {
  395. this.getList();
  396. },
  397. methods: {
  398. handleClick(tab) {
  399. if (tab.name === 'replies') {
  400. this.getReplyList();
  401. }
  402. },
  403. renderHandleHeader(h, { column }) {
  404. if (column.label === '是否处理') {
  405. return h('div', [
  406. '是否处理',
  407. h('el-tooltip', {
  408. props: {
  409. content: '仅需要处理投诉/举报类',
  410. placement: 'top'
  411. }
  412. }, [
  413. h('i', {
  414. class: 'el-icon-question',
  415. style: 'margin-left: 5px; cursor: pointer; color: #909399;'
  416. })
  417. ])
  418. ]);
  419. } else if (column.label === '店铺是否处理') {
  420. return h('div', [
  421. '店铺是否处理',
  422. h('el-tooltip', {
  423. props: {
  424. content: '仅需要处理咨询类',
  425. placement: 'top'
  426. }
  427. }, [
  428. h('i', {
  429. class: 'el-icon-question',
  430. style: 'margin-left: 5px; cursor: pointer; color: #909399;'
  431. })
  432. ])
  433. ]);
  434. }
  435. return column.label;
  436. },
  437. imageUrls(urls) {
  438. return String(urls).split(",");
  439. },
  440. formatHandleStatus(status) {
  441. return status == 1 ? '已处理' : '未处理';
  442. },
  443. /** 查询用户投诉列表 */
  444. getList() {
  445. this.loading = true;
  446. listComplaint(this.queryParams).then(response => {
  447. this.complaintList = response.rows;
  448. this.total = response.total;
  449. this.loading = false;
  450. });
  451. },
  452. // 取消按钮
  453. cancel() {
  454. this.open = false;
  455. this.reset();
  456. this.resetReplyData();
  457. },
  458. // 表单重置
  459. reset() {
  460. this.form = {
  461. id: null,
  462. userId: null,
  463. templateId: null,
  464. content: null,
  465. phone: null,
  466. urls: null,
  467. account: null,
  468. createTime: null,
  469. isHandle: 0,
  470. remarks:null
  471. };
  472. this.resetForm("form");
  473. },
  474. // 重置回复数据
  475. resetReplyData() {
  476. this.activeTab = 'complaint';
  477. this.replyList = [];
  478. this.replyTotal = 0;
  479. this.replyQueryParams = {
  480. pageNum: 1,
  481. pageSize: 10,
  482. complaintId: null
  483. };
  484. this.replyForm = {
  485. content: '',
  486. complaintId: null,
  487. images: '' // 重置图片字段
  488. };
  489. this.replyImageList = [];
  490. this.editReplyImageList = [];
  491. },
  492. /** 搜索按钮操作 */
  493. handleQuery() {
  494. this.queryParams.pageNum = 1;
  495. this.getList();
  496. },
  497. /** 重置按钮操作 */
  498. resetQuery() {
  499. this.complaintTime = null;
  500. this.queryParams.complaintsTime=null;
  501. this.queryParams.complainteTime=null;
  502. this.resetForm("queryForm");
  503. this.handleQuery();
  504. },
  505. // 多选框选中数据
  506. handleSelectionChange(selection) {
  507. this.ids = selection.map(item => item.id)
  508. this.single = selection.length !== 1
  509. this.multiple = !selection.length
  510. },
  511. /** 新增按钮操作 */
  512. handleAdd() {
  513. this.reset();
  514. this.open = true;
  515. this.title = "添加用户投诉";
  516. },
  517. /** 修改按钮操作 */
  518. handleUpdate(row) {
  519. this.reset();
  520. this.resetReplyData();
  521. // const id = row.id || this.ids
  522. const complaintId = row.id || this.complaintId
  523. this.complaintId = complaintId;
  524. getComplaint(complaintId).then(response => {
  525. this.form = response.data;
  526. this.replyForm.complaintId = complaintId;
  527. this.replyQueryParams.complaintId = complaintId;
  528. this.open = true;
  529. this.title = "投诉详情";
  530. // 加载回复列表
  531. this.getReplyList();
  532. });
  533. },
  534. /** 提交按钮 */
  535. submitForm() {
  536. this.$refs["form"].validate(valid => {
  537. if (valid) {
  538. if (this.form.id != null) {
  539. updateComplaint(this.form).then(response => {
  540. this.msgSuccess("修改成功");
  541. this.open = false;
  542. this.getList();
  543. });
  544. } else {
  545. addComplaint(this.form).then(response => {
  546. this.msgSuccess("新增成功");
  547. this.open = false;
  548. this.getList();
  549. });
  550. }
  551. }
  552. });
  553. },
  554. /** 删除按钮操作 */
  555. handleDelete(row) {
  556. const ids = row.id || this.ids;
  557. this.$confirm('是否确认删除用户投诉编号为"' + ids + '"的数据项?', "警告", {
  558. confirmButtonText: "确定",
  559. cancelButtonText: "取消",
  560. type: "warning"
  561. }).then(function() {
  562. return delComplaint(ids);
  563. }).then(() => {
  564. this.getList();
  565. this.msgSuccess("删除成功");
  566. }).catch(() => {});
  567. },
  568. /** 导出按钮操作 */
  569. handleExport() {
  570. const queryParams = this.queryParams;
  571. this.$confirm('是否确认导出所有用户投诉数据项?', "警告", {
  572. confirmButtonText: "确定",
  573. cancelButtonText: "取消",
  574. type: "warning"
  575. }).then(() => {
  576. this.exportLoading = true;
  577. return exportComplaint(queryParams);
  578. }).then(response => {
  579. this.download(response.msg);
  580. this.exportLoading = false;
  581. }).catch(() => {});
  582. },
  583. changeTime(){
  584. if(this.complaintTime!=null){
  585. this.queryParams.complaintsTime=this.complaintTime[0];
  586. this.queryParams.complainteTime=this.complaintTime[1];
  587. }else{
  588. this.queryParams.complaintsTime=null;
  589. this.queryParams.complainteTime=null;
  590. }
  591. },
  592. // 获取回复列表
  593. getReplyList() {
  594. this.replyLoading = true;
  595. // 模拟API调用 - 你需要替换为实际的API
  596. setTimeout(() => {
  597. // 模拟数据
  598. listMsg(this.replyQueryParams).then(response => {
  599. this.replyList = response.rows;
  600. this.replyTotal = response.total;
  601. this.replyLoading = false;
  602. });
  603. }, 500);
  604. },
  605. // 提交回复
  606. submitReply() {
  607. this.$refs.replyForm.validate(valid => {
  608. if (valid) {
  609. this.replyLoading = true;
  610. // const imageUrls = this.replyImageList.map(file => file.url || file.response?.url).filter(url => url);
  611. // this.replyForm.images = imageUrls.join(',');
  612. // 模拟API调用
  613. setTimeout(() => {
  614. const newReply = {
  615. content: this.replyForm.content,
  616. complaintId:this.replyForm.complaintId,
  617. images: this.replyForm.images, // 包含图片数据
  618. sendType: 2
  619. };
  620. addMsg(newReply).then(response => {
  621. this.replyLoading = false;
  622. this.$message.success('回复发送成功');
  623. this.replyForm.content = '';
  624. this.replyForm.images = ''; // 重置图片字段
  625. this.replyImageList = []; // 重置图片列表
  626. this.getReplyList()
  627. });
  628. }, 500);
  629. }
  630. });
  631. },
  632. // 编辑回复
  633. editReply(reply) {
  634. this.editReplyForm = {
  635. id: reply.id,
  636. content: reply.content,
  637. images: reply.images || '' // 包含图片数据
  638. };
  639. this.editReplyImageList = reply.images ?
  640. reply.images.split(',').map((url, index) => ({
  641. uid: index,
  642. name: `image-${index}`,
  643. url: url
  644. })) : [];
  645. this.editReplyVisible = true;
  646. },
  647. // 更新回复
  648. updateReply() {
  649. this.$refs.editReplyForm.validate(valid => {
  650. if (valid) {
  651. this.replyLoading = true;
  652. // const imageUrls = this.editReplyImageList.map(file => file.url || file.response?.url).filter(url => url);
  653. // this.editReplyForm.images = imageUrls.join(',');
  654. // 模拟API调用
  655. setTimeout(() => {
  656. const index = this.replyList.findIndex(item => item.id === this.editReplyForm.id);
  657. if (index !== -1) {
  658. this.replyList[index].content = this.editReplyForm.content;
  659. this.replyList[index].images = this.editReplyForm.images; // 更新图片
  660. }
  661. this.editReplyVisible = false;
  662. this.replyLoading = false;
  663. this.$message.success('回复更新成功');
  664. }, 500);
  665. }
  666. });
  667. },
  668. // 删除回复
  669. deleteReply(reply) {
  670. this.$confirm('确定要删除这条回复吗?', '提示', {
  671. confirmButtonText: '确定',
  672. cancelButtonText: '取消',
  673. type: 'warning'
  674. }).then(() => {
  675. const index = this.replyList.findIndex(item => item.id === reply.id);
  676. if (index !== -1) {
  677. this.replyList.splice(index, 1);
  678. this.replyTotal--;
  679. this.$message.success('删除成功');
  680. }
  681. });
  682. },
  683. // 回复分页大小改变
  684. handleReplySizeChange(val) {
  685. this.replyQueryParams.pageSize = val;
  686. this.getReplyList();
  687. },
  688. // 回复当前页改变
  689. handleReplyCurrentChange(val) {
  690. this.replyQueryParams.pageNum = val;
  691. this.getReplyList();
  692. },
  693. handleSuccess(res, file) {
  694. if(res.code==200){
  695. this.form.licenseImages=res.url;
  696. this.$forceUpdate()
  697. }
  698. else{
  699. this.msgError(res.msg);
  700. }
  701. },
  702. beforeUpload(file) {
  703. const isLt1M = file.size / 1024 / 1024 < 1;
  704. if (!isLt1M) {
  705. this.$message.error('上传图片大小不能超过 1MB!');
  706. }
  707. return isLt1M;
  708. },
  709. }
  710. };
  711. </script>
  712. <style scoped>
  713. .reply-section {
  714. margin-top: 10px;
  715. }
  716. .add-reply-card {
  717. margin-bottom: 20px;
  718. }
  719. .reply-list-card {
  720. min-height: 400px;
  721. }
  722. .reply-list {
  723. min-height: 300px;
  724. }
  725. .empty-replies {
  726. display: flex;
  727. justify-content: center;
  728. align-items: center;
  729. height: 200px;
  730. }
  731. .reply-item {
  732. border-bottom: 1px solid #f0f0f0;
  733. padding: 15px 0;
  734. }
  735. .reply-item:last-child {
  736. border-bottom: none;
  737. }
  738. .reply-header {
  739. display: flex;
  740. justify-content: space-between;
  741. align-items: center;
  742. margin-bottom: 10px;
  743. }
  744. .reply-user {
  745. display: flex;
  746. align-items: center;
  747. gap: 8px;
  748. }
  749. .user-name {
  750. font-weight: 500;
  751. color: #303133;
  752. }
  753. .reply-time {
  754. color: #909399;
  755. font-size: 12px;
  756. }
  757. .reply-content {
  758. background-color: #f8f9fa;
  759. padding: 12px;
  760. border-radius: 6px;
  761. margin-bottom: 8px;
  762. line-height: 1.5;
  763. color: #606266;
  764. }
  765. .reply-actions {
  766. text-align: right;
  767. }
  768. .reply-pagination {
  769. margin-top: 20px;
  770. text-align: center;
  771. }
  772. .image-container {
  773. display: inline-block;
  774. margin-right: 10px;
  775. margin-bottom: 10px;
  776. }
  777. </style>