index.php 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681
  1. <?php
  2. use common\helpers\ComponentHelper;
  3. ComponentHelper::loadComponentView('component/com-edit-template', __DIR__);
  4. ?>
  5. <style>
  6. .table-body {
  7. padding: 20px;
  8. background-color: #fff;
  9. }
  10. .input-item {
  11. display: inline-block;
  12. width: 350px;
  13. margin: 0 0 20px;
  14. }
  15. .input-item .el-input-group__prepend {
  16. background-color: #fff;
  17. }
  18. .input-item .el-input__inner {
  19. border-right: 0;
  20. }
  21. .input-item .el-input__inner:hover {
  22. border: 1px solid #dcdfe6;
  23. border-right: 0;
  24. outline: 0;
  25. }
  26. .input-item .el-input__inner:focus {
  27. border: 1px solid #dcdfe6;
  28. border-right: 0;
  29. outline: 0;
  30. }
  31. .input-item .el-input-group__append {
  32. background-color: #fff;
  33. border-left: 0;
  34. width: 10%;
  35. padding: 0;
  36. }
  37. .input-item .el-input-group__append .el-button {
  38. padding: 15px;
  39. }
  40. .select {
  41. float: left;
  42. width: 100px;
  43. margin-right: 10px;
  44. }
  45. .el-table .cell .el-button {
  46. padding: 0 !important;
  47. border: 0;
  48. margin: 0 5px;
  49. }
  50. .open-img .el-dialog {
  51. margin-top: 0 !important;
  52. }
  53. .click-img {
  54. width: 100%;
  55. }
  56. .input-item .el-input-group__append .el-button {
  57. padding: 0;
  58. }
  59. .input-item .el-input-group__append .el-button {
  60. margin: 0;
  61. }
  62. .label-text {
  63. height: 32px;
  64. margin-right: 10px;
  65. }
  66. /*弹出框表格样式 start*/
  67. .el-dialog__body {
  68. padding: 5px 20px;
  69. }
  70. .card-box {
  71. padding: 10px;
  72. border: 1px solid #E3E3E3;
  73. }
  74. .table-box {
  75. border-top: 1px solid #E3E3E3;
  76. border-left: 1px solid #E3E3E3;
  77. }
  78. .table-item {
  79. border-bottom: 1px solid #E3E3E3;
  80. border-right: 1px solid #E3E3E3;
  81. height: 50px;
  82. padding-left: 5px;
  83. }
  84. .table-item .el-radio__label {
  85. display: none;
  86. }
  87. .select-type-box {
  88. padding: 25px 0;
  89. height: 40px;
  90. }
  91. /*弹出框表格样式 end*/
  92. .el-table th>.cell{
  93. color: #333;
  94. font-weight: bold;
  95. font-size: 14px;
  96. }
  97. .el-table__footer-wrapper, .el-table__header-wrapper{
  98. border-bottom: 1.4px solid #D6D6D6;
  99. }
  100. </style>
  101. <div id="app" v-cloak>
  102. <el-card shadow="never" style="border:0;min-width: 1000px;" body-style="background-color: #f3f3f3;padding: 10px 0 0;">
  103. <div slot="header">
  104. <div flex="cross:center box:first">
  105. <div>评价管理</div>
  106. <div flex="dir:right">
  107. <div>
  108. <el-button type="primary" size="small"
  109. @click="$navigate({r: 'mall/order-comment-templates/index'})">回复模板
  110. </el-button>
  111. <el-button type="primary" size="small"
  112. @click="$navigate({r: 'mall/order-comments/edit'})">添加客户评价
  113. </el-button>
  114. </div>
  115. </div>
  116. </div>
  117. </div>
  118. <div class="table table-body">
  119. <div flex="dir:left">
  120. <div flex="dir:left">
  121. <div class="label-text" flex="cross:center">评价类型</div>
  122. <el-select size="small" v-model="comment_type" class="select" @change="change">
  123. <el-option key="1" label="全部评价" value="0"></el-option>
  124. <el-option key="2" label="好评" value="3"></el-option>
  125. <el-option key="3" label="中评" value="2"></el-option>
  126. <el-option key="4" label="差评" value="1"></el-option>
  127. </el-select>
  128. </div>
  129. <div class="input-item">
  130. <el-input @keyup.enter.native="change" size="small" placeholder="请输入搜索内容" v-model="keyword"
  131. clearable
  132. @clear="change">
  133. <el-select size="small" v-model="type" slot="prepend" class="select">
  134. <el-option key="1" label="昵称" value="1"></el-option>
  135. <el-option key="2" label="商品名称" value="2"></el-option>
  136. <el-option key="3" label="评价内容" value="3"></el-option>
  137. </el-select>
  138. <el-button slot="append" icon="el-icon-search" @click="change"></el-button>
  139. </el-input>
  140. </div>
  141. <div style="float: left;margin-left: 10px;">
  142. <el-button @click="batchReplyDialog" size="small" plain>批量回复</el-button>
  143. </div>
  144. <div style="float: left;margin-left: 10px;">
  145. <el-button @click="batchHide" size="small" plain>批量隐藏</el-button>
  146. </div>
  147. <div style="float: left;margin-left: 10px;" plain>
  148. <el-button @click="batchDestroy" size="small">批量删除</el-button>
  149. </div>
  150. </div>
  151. <el-table :data="form" stripe style="width: 100%;" v-loading="listLoading"
  152. @selection-change="handleSelectionChange">
  153. <el-table-column
  154. type="selection"
  155. width="55">
  156. </el-table-column>
  157. <el-table-column prop="id" label="ID" width="80" align="center"></el-table-column>
  158. <el-table-column prop="goodsSource" label="商品来源" width="100" align="center">
  159. <template slot-scope="scope">
  160. <el-tag v-if="scope.row.goodsSource == 3" type="danger" effect="dark">多商户</el-tag>
  161. <el-tag v-else-if="scope.row.goodsSource == 2" type="info" effect="dark">o2o门店</el-tag>
  162. <el-tag v-else type="success" effect="dark">平台</el-tag>
  163. </template>
  164. </el-table-column>
  165. <el-table-column prop="nickname" label="用户" width="100" align="center">
  166. <template slot-scope="scope">
  167. <div class="goods-info" v-if="scope.row.is_virtual==0">
  168. <com-ellipsis :line="2">{{scope.row.users.nickname}}</com-ellipsis>
  169. </div>
  170. <div class="goods-info" v-if="scope.row.is_virtual==1">
  171. <com-ellipsis :line="2">{{scope.row.virtual_user}}</com-ellipsis>
  172. </div>
  173. </template>
  174. </el-table-column>
  175. <el-table-column prop="platform" align="center" label="平台" width="80" align="center">
  176. <template slot-scope="scope">
  177. <el-tooltip class="item" effect="dark" v-if="scope.row.platform == 'mp-wx'" content="微信"
  178. placement="top">
  179. <img src="resources/img/mall/wx.png" alt="">
  180. </el-tooltip>
  181. <el-tooltip class="item" effect="dark" v-else content="后台" placement="top">
  182. <img src="resources/img/mall/site.png" alt="">
  183. </el-tooltip>
  184. </template>
  185. </el-table-column>
  186. <el-table-column prop="name" label="商品名称" width="200">
  187. <template slot-scope="scope">
  188. <div class="goods-info">
  189. <com-image mode="aspectFill" style="margin-right: 10px;float: left"
  190. :src="scope.row.goods.cover_pic"></com-image>
  191. <com-ellipsis :line="2">{{scope.row.goods.goods_name}}</com-ellipsis>
  192. </div>
  193. </template>
  194. </el-table-column>
  195. <el-table-column prop="order.order_no" label="订单号" width="200" align="center"></el-table-column>
  196. <el-table-column prop="score" align="center" label="评价" width="80" align="center">
  197. <template slot-scope="scope">
  198. <el-tooltip class="item" effect="dark" v-if="scope.row.score>3" content="好评" placement="top">
  199. <img src="resources/img/mall/good.png" alt="">
  200. </el-tooltip>
  201. <el-tooltip class="item" effect="dark" v-else-if="scope.row.score==3||scope.row.score==2" content="中评"
  202. placement="top">
  203. <img src="resources/img/mall/normal.png" alt="">
  204. </el-tooltip>
  205. <el-tooltip class="item" effect="dark" v-else-if="scope.row.score<2" content="差评"
  206. placement="top">
  207. <img src="resources/img/mall/bad.png" alt="">
  208. </el-tooltip>
  209. </template>
  210. </el-table-column>
  211. <el-table-column prop="content" label="详情" align="center">
  212. <template slot-scope="scope">
  213. <el-tooltip effect="dark" placement="top">
  214. <template slot="content">
  215. <div style="width: 320px;">{{scope.row.content}}</div>
  216. </template>
  217. <com-ellipsis :line="2">{{scope.row.content}}</com-ellipsis>
  218. </el-tooltip>
  219. <div>
  220. <div v-for="item in scope.row.pic_url?JSON.parse(scope.row.pic_url):''" @click="openImg(item)"
  221. style="margin: 10px;display: inline-block;cursor: pointer">
  222. <com-image mode="aspectFill" :src="item"></com-image>
  223. </div>
  224. </div>
  225. </template>
  226. </el-table-column>
  227. <el-table-column prop="reply_content" show-overflow-tooltip label="评价回复" align="center"></el-table-column>
  228. <el-table-column prop="is_top" label="置顶" width="100" align="center">
  229. <template slot-scope="scope">
  230. <el-switch :active-value="1" :inactive-value="0" @change="switchTop(scope.row)"
  231. v-model="scope.row.is_top"></el-switch>
  232. </template>
  233. </el-table-column>
  234. <el-table-column prop="status" label="状态" width="100" align="center">
  235. <template slot-scope="scope">
  236. <el-tag v-if="scope.row.status==1" size="small" type="success">显示</el-tag>
  237. <el-tag v-if="scope.row.status==0" size="small" type="warning">隐藏</el-tag>
  238. </template>
  239. </el-table-column>
  240. <el-table-column label="操作" width="220" align="center">
  241. <template slot-scope="scope">
  242. <el-button size="small" type="text" circle @click="replyComment(scope.row)">
  243. <el-tooltip class="item" effect="dark" content="评价回复" placement="top">
  244. <img src="resources/img/mall/reply.png" alt="">
  245. </el-tooltip>
  246. </el-button>
  247. <!-- <el-button size="small" type="text" v-if="scope.row.is_virtual == 1"-->
  248. <!-- @click="$navigate({r: 'mall/order-comments/edit', id:scope.row.id})" circle>-->
  249. <!-- <el-tooltip class="item" effect="dark" content="编辑" placement="top">-->
  250. <!-- <img src="resources/img/mall/edit.png" alt="">-->
  251. <!-- </el-tooltip>-->
  252. <!-- </el-button>-->
  253. <el-button size="small" type="text" @click="destroy(scope.row)" circle>
  254. <el-tooltip class="item" effect="dark" content="删除" placement="top">
  255. <img src="resources/img/mall/del.png" alt="">
  256. </el-tooltip>
  257. </el-button>
  258. <el-button v-if="scope.row.status==1" size="small" type="text"
  259. @click="switchShow(scope.row)" circle>
  260. <el-tooltip class="item" effect="dark" content="隐藏" placement="top">
  261. <img src="resources/img/mall/icon-hidden.png" alt="">
  262. </el-tooltip>
  263. </el-button>
  264. <el-button v-if="scope.row.status==0" size="small" type="text" @click="switchShow(scope.row)" circle>
  265. <el-tooltip class="item" effect="dark" content="显示" placement="top">
  266. <img src="resources/img/mall/icon-show.png" alt="">
  267. </el-tooltip>
  268. </el-button>
  269. </template>
  270. </el-table-column>
  271. </el-table>
  272. <div style="text-align: right;margin: 20px 0;">
  273. <el-pagination @current-change="pagination" background layout="prev, pager, next"
  274. :page-count="pageCount"></el-pagination>
  275. </div>
  276. <el-dialog :visible.sync="dialogImg" class="open-img" :close-on-click-modal="false">
  277. <img :src="click_img" class="click-img" alt="">
  278. </el-dialog>
  279. </div>
  280. <el-dialog
  281. :close-on-click-modal="false"
  282. :visible.sync="dialogVisible"
  283. width="50%">
  284. <template slot="title">
  285. <div flex="dir:left cross:center">
  286. <div style="margin-right: 10px">评价回复</div>
  287. </div>
  288. </template>
  289. <div class="select-type-box" flex="dir:left box:last cross:center">
  290. <div>
  291. <el-radio v-model="reply_type" label="1">直接输入</el-radio>
  292. <el-radio v-model="reply_type" label="2">选择模板</el-radio>
  293. </div>
  294. <div v-if="reply_type == 2">
  295. <el-button @click="openDialog(null, templateVisible = true)" type="primary" size="small">
  296. 添加模板
  297. </el-button>
  298. </div>
  299. </div>
  300. <template v-if="reply_type == 1">
  301. <el-input
  302. type="textarea"
  303. :rows="10"
  304. placeholder="请输入回复内容,字数限制100字以内"
  305. maxlength="100"
  306. v-model="reply_text">
  307. </el-input>
  308. </template>
  309. <template v-if="reply_type == 2">
  310. <div class="card-box">
  311. <div>
  312. <el-tabs v-model="activeName" @tab-click="handleClick">
  313. <el-tab-pane label="好评回复" name="1"></el-tab-pane>
  314. <el-tab-pane label="中评回复" name="2"></el-tab-pane>
  315. <el-tab-pane label="差评回复" name="3"></el-tab-pane>
  316. </el-tabs>
  317. </div>
  318. <div class="table-box" v-loading="tableLoading">
  319. <div flex="dir:left">
  320. <div flex="cross:center" class="table-item" style="width: 10%"></div>
  321. <div flex="cross:center" class="table-item" style="width: 30%">模板名称</div>
  322. <div flex="cross:center" class="table-item" style="width: 60%">模板内容</div>
  323. </div>
  324. <div flex="dir:left" v-for="(item, index) in dialogList" :key="index">
  325. <div flex="main:center cross:center" class="table-item" style="width: 10%">
  326. <el-radio @change="radioChange(item)" v-model="templateId" :label="item.id"></el-radio>
  327. </div>
  328. <div class="table-item" flex="cross:center" style="width: 30%">
  329. <com-ellipsis :line="2">{{item.title}}</com-ellipsis>
  330. </div>
  331. <div class="table-item" flex="cross:center" style="width: 60%">
  332. <com-ellipsis :line="2">{{item.content}}</com-ellipsis>
  333. </div>
  334. </div>
  335. </div>
  336. <div v-if="dialogList.length == 0" style="height: 100px" flex="cross:center main:center">
  337. 暂无模板
  338. </div>
  339. <div style="text-align: right;margin: 20px 0;">
  340. <el-pagination @current-change="dialogPagination" background layout="prev, pager, next"
  341. :page-count="dialogPageCount"></el-pagination>
  342. </div>
  343. </div>
  344. </template>
  345. <span slot="footer" class="dialog-footer">
  346. <el-button size="small" @click="dialogVisible = false">取 消</el-button>
  347. <el-button size="small" :loading="dialogBtnLoading" type="primary"
  348. @click="batchReplySubmit">确 定</el-button>
  349. </span>
  350. </el-dialog>
  351. <com-edit-template
  352. @close="dialogClose"
  353. @submit="dialogSubmit"
  354. :is-show="templateVisible"
  355. :template="template">
  356. </com-edit-template>
  357. </el-card>
  358. </div>
  359. <script>
  360. const app = new Vue({
  361. el: '#app',
  362. data() {
  363. return {
  364. form: [],
  365. pageCount: 0,
  366. pageCount: 0,
  367. listLoading: false,
  368. type: '1',
  369. page: 1,
  370. comment_type: '0',
  371. keyword: '',
  372. btnLoading: false,
  373. dialogImg: false,
  374. click_img: null,
  375. platform: '',
  376. multipleSelection: [],
  377. dialogVisible: false,
  378. activeName: '1',
  379. tableLoading: false,
  380. dialogPageCount: 0,
  381. dialogPage: 1,
  382. dialogList: [],
  383. dialogBtnLoading: false,
  384. templateId: null,
  385. batchIds: [],
  386. template: null,
  387. templateVisible: false,
  388. reply_text: '',
  389. reply_type: '1',
  390. };
  391. },
  392. methods: {
  393. openImg(url) {
  394. this.click_img = url;
  395. this.dialogImg = true;
  396. },
  397. pagination(currentPage) {
  398. this.page = currentPage;
  399. this.search();
  400. },
  401. dialogPagination(currentPage) {
  402. this.dialogPage = currentPage;
  403. this.getTemplateList();
  404. },
  405. change() {
  406. this.page = 1;
  407. this.search();
  408. },
  409. search() {
  410. this.listLoading = true;
  411. request({
  412. params: {
  413. r: 'mall/order-comments/index',
  414. page: this.page,
  415. type: this.type,
  416. comment_type: this.comment_type,
  417. keyword: this.keyword,
  418. platform: this.platform,
  419. },
  420. }).then(e => {
  421. if (e.data.code === 0) {
  422. this.form = e.data.data.list;
  423. this.pageCount = e.data.data.page_count;
  424. } else {
  425. this.$message.error(e.data.msg);
  426. }
  427. this.listLoading = false;
  428. }).catch(e => {
  429. this.listLoading = false;
  430. });
  431. },
  432. //删除
  433. destroy: function (column) {
  434. this.$confirm('确认删除该记录吗?', '提示', {
  435. type: 'warning'
  436. }).then(() => {
  437. this.listLoading = true;
  438. request({
  439. params: {
  440. r: 'mall/order-comments/destroy'
  441. },
  442. data: {id: column.id},
  443. method: 'post'
  444. }).then(e => {
  445. location.reload();
  446. this.listLoading = false;
  447. }).catch(e => {
  448. this.listLoading = false;
  449. });
  450. });
  451. },
  452. switchTop(row) {
  453. let self = this;
  454. request({
  455. params: {
  456. r: 'mall/order-comments/update-top',
  457. },
  458. method: 'post',
  459. data: {
  460. is_top: row.is_top,
  461. id: row.id
  462. }
  463. }).then(e => {
  464. if (e.data.code === 0) {
  465. self.$message.success(e.data.msg);
  466. } else {
  467. self.$message.error(e.data.msg);
  468. }
  469. });
  470. },
  471. switchShow(row) {
  472. let self = this;
  473. const is_show = row.status ? 0 : 1;
  474. request({
  475. params: {
  476. r: 'mall/order-comments/show',
  477. },
  478. method: 'post',
  479. data: {
  480. is_show,
  481. id: row.id
  482. }
  483. }).then(e => {
  484. if (e.data.code === 0) {
  485. row.status = is_show;
  486. self.$message.success(e.data.msg);
  487. } else {
  488. self.$message.error(e.data.msg);
  489. }
  490. });
  491. },
  492. batchValidate() {
  493. this.batchIds = this.multipleSelection.map(item => {
  494. return item.id
  495. });
  496. if (this.batchIds.length <= 0) {
  497. throw new Error('请勾选数据');
  498. }
  499. },
  500. batchReplyDialog() {
  501. try {
  502. this.reply_type = '1';
  503. this.reply_text = '';
  504. this.batchValidate();
  505. this.dialogVisible = true;
  506. this.getTemplateList();
  507. } catch (error) {
  508. this.$message.error(error.message);
  509. }
  510. },
  511. batchHide() {
  512. try {
  513. this.batchValidate();
  514. const title = '已选中' + this.batchIds.length + '条评价,是否批量隐藏?';
  515. this.batchSubmit(title, 'mall/order-comments/batch-update-status');
  516. } catch (error) {
  517. this.$message.error(error.message);
  518. }
  519. },
  520. batchDestroy() {
  521. try {
  522. this.batchValidate();
  523. const title = '已选中' + this.batchIds.length + '条评价,是否批量删除?';
  524. this.batchSubmit(title, 'mall/order-comments/batch-destroy');
  525. } catch (error) {
  526. this.$message.error(error.message);
  527. }
  528. },
  529. batchSubmit(title, r) {
  530. const self = this;
  531. self.$confirm(title, '提示', {
  532. type: 'warning'
  533. }).then(res => {
  534. self.listLoading = true;
  535. request({
  536. params: {
  537. r
  538. },
  539. data: {
  540. batch_ids: self.batchIds,
  541. status: 0
  542. },
  543. method: 'post'
  544. }).then(e => {
  545. self.listLoading = false;
  546. if (e.data.code === 0) {
  547. self.$message.success(e.data.msg);
  548. location.reload();
  549. } else {
  550. self.$message.error(e.data.msg);
  551. }
  552. }).catch(e => {
  553. self.listLoading = false;
  554. })
  555. }).catch(res => {
  556. console.log(res);
  557. })
  558. },
  559. batchReplySubmit() {
  560. if (this.reply_type == 2 && !this.templateId) {
  561. this.$message.warning('请选择评价模板');
  562. return;
  563. }
  564. if (this.reply_type == 1 && !this.reply_text) {
  565. this.$message.warning('请输入回复评价内容');
  566. return;
  567. }
  568. let self = this;
  569. self.dialogBtnLoading = true;
  570. request({
  571. params: {
  572. r: 'mall/order-comments/batch-reply',
  573. },
  574. method: 'post',
  575. data: {
  576. batch_ids: self.batchIds,
  577. template_id: self.templateId,
  578. reply_type: self.reply_type,
  579. reply_text: self.reply_text,
  580. }
  581. }).then(e => {
  582. self.dialogBtnLoading = false;
  583. if (e.data.code === 0) {
  584. self.dialogVisible = false;
  585. self.search();
  586. self.$message.success(e.data.msg);
  587. } else {
  588. self.$message.error(e.data.msg);
  589. }
  590. }).catch(e => {
  591. console.log(e);
  592. });
  593. },
  594. handleSelectionChange(val) {
  595. this.multipleSelection = val;
  596. },
  597. handleClick(tab, event) {
  598. this.templateId = null;
  599. this.getTemplateList();
  600. },
  601. getTemplateList() {
  602. this.tableLoading = true;
  603. request({
  604. params: {
  605. r: 'mall/order-comment-templates/index',
  606. page: this.dialogPage,
  607. type: this.activeName,
  608. },
  609. }).then(e => {
  610. if (e.data.code === 0) {
  611. this.dialogList = e.data.data.list;
  612. this.dialogPageCount = e.data.data.page_count;
  613. } else {
  614. this.$message.error(e.data.msg);
  615. }
  616. this.tableLoading = false;
  617. }).catch(e => {
  618. this.tableLoading = false;
  619. });
  620. },
  621. radioChange(row) {
  622. this.templateId = row.id;
  623. },
  624. openDialog(template) {
  625. this.template = template;
  626. },
  627. dialogClose() {
  628. this.templateVisible = false;
  629. },
  630. dialogSubmit() {
  631. this.getTemplateList();
  632. },
  633. // 单个评价回复
  634. replyComment(row) {
  635. let self = this;
  636. self.reply_type = '1';
  637. self.reply_text = '';
  638. self.multipleSelection = [];
  639. self.batchIds = [];
  640. self.batchIds.push(row.id);
  641. self.dialogVisible = true;
  642. self.getTemplateList();
  643. }
  644. },
  645. mounted: function () {
  646. this.search();
  647. }
  648. });
  649. </script>