index.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. <!--
  2. - Copyright (c) 2018-2025, lengleng All rights reserved.
  3. -
  4. - Redistribution and use in source and binary forms, with or without
  5. - modification, are permitted provided that the following conditions are met:
  6. -
  7. - Redistributions of source code must retain the above copyright notice,
  8. - this list of conditions and the following disclaimer.
  9. - Redistributions in binary form must reproduce the above copyright
  10. - notice, this list of conditions and the following disclaimer in the
  11. - documentation and/or other materials provided with the distribution.
  12. - Neither the name of the pig4cloud.com developer nor the names of its
  13. - contributors may be used to endorse or promote products derived from
  14. - this software without specific prior written permission.
  15. - Author: lengleng (wangiegie@gmail.com)
  16. -->
  17. <template>
  18. <div class="execution">
  19. <basic-container>
  20. <avue-crud ref="crud"
  21. :page="page"
  22. :data="tableData"
  23. :permission="permissionList"
  24. :table-loading="tableLoading"
  25. :option="tableOption"
  26. @on-load="getList"
  27. @refresh-change="refreshChange"
  28. @search-change="searchChange"
  29. @row-save="handleSave"
  30. @row-del="rowDel">
  31. <template slot-scope="scope"
  32. slot="menu">
  33. <el-button type="text" v-if="permissionList.addBtn"
  34. icon="el-icon-check"
  35. size="mini"
  36. plain
  37. @click="reply(scope.row,scope.index)">回复
  38. </el-button>
  39. </template>
  40. </avue-crud>
  41. <el-dialog title="回复消息" :visible.sync="dialogFormVisible">
  42. <avue-crud ref="crudLog"
  43. :page="pageRes"
  44. :data="tableResData"
  45. :option="tableResOption"
  46. @row-save="handleResSave"
  47. @row-del="rowResDel">
  48. </avue-crud>
  49. </el-dialog>
  50. </basic-container>
  51. </div>
  52. </template>
  53. <script>
  54. import {addObj, addResObj, delObj, delResObj, fetchList, fetchResList, getObj, putObj} from '@/api/mp/wxfansmsg'
  55. import {tableOption, tableResOption} from '@/const/crud/mp/wxfansmsg'
  56. import {mapGetters} from 'vuex'
  57. export default {
  58. name: 'wxfansmsg',
  59. data() {
  60. return {
  61. dialogFormVisible: false,
  62. tableData: [],
  63. tableResData: [],
  64. page: {
  65. total: 0, // 总页数
  66. currentPage: 1, // 当前页数
  67. pageSize: 20 // 每页显示多少条
  68. },
  69. pageRes: {
  70. total: 0, // 总页数
  71. currentPage: 1, // 当前页数
  72. pageSize: 20 // 每页显示多少条
  73. },
  74. tableLoading: false,
  75. tableOption: tableOption,
  76. tableResOption: tableResOption,
  77. msgId: undefined
  78. }
  79. },
  80. computed: {
  81. ...mapGetters(['permissions']),
  82. permissionList() {
  83. return {
  84. addBtn: this.vaildData(this.permissions.mp_wxfansmsg_add, false),
  85. delBtn: this.vaildData(this.permissions.mp_wxfansmsg_del, false),
  86. editBtn: this.vaildData(this.permissions.mp_wxfansmsg_edit, false)
  87. };
  88. }
  89. },
  90. methods: {
  91. getList(page, params) {
  92. this.tableLoading = true
  93. fetchList(Object.assign({
  94. current: page.currentPage,
  95. size: page.pageSize
  96. }, params)).then(response => {
  97. this.tableData = response.data.data.records
  98. this.page.total = response.data.data.total
  99. this.tableLoading = false
  100. })
  101. },
  102. getResList(pageRes, params) {
  103. fetchResList(Object.assign({
  104. current: pageRes.currentPage,
  105. size: pageRes.pageSize
  106. }, params)).then(response => {
  107. this.tableResData = response.data.data.records
  108. this.pageRes.total = response.data.data.total
  109. })
  110. },
  111. rowDel: function (row, index) {
  112. var _this = this
  113. this.$confirm('是否确认删除ID为' + row.id, '提示', {
  114. confirmButtonText: '确定',
  115. cancelButtonText: '取消',
  116. type: 'warning'
  117. }).then(function () {
  118. return delObj(row.id)
  119. }).then(data => {
  120. _this.tableData.splice(index, 1)
  121. _this.$message({
  122. showClose: true,
  123. message: '删除成功',
  124. type: 'success'
  125. })
  126. this.getList(this.page)
  127. }).catch(function (err) {
  128. })
  129. },
  130. handleSave: function (row, done) {
  131. addObj(row).then(data => {
  132. this.tableResData.push(Object.assign({}, row))
  133. this.$message({
  134. showClose: true,
  135. message: '添加成功',
  136. type: 'success'
  137. })
  138. done()
  139. this.getList(this.page)
  140. })
  141. },
  142. rowResDel: function (row, index) {
  143. var _this = this
  144. this.$confirm('是否确认删除ID为' + row.id, '提示', {
  145. confirmButtonText: '确定',
  146. cancelButtonText: '取消',
  147. type: 'warning'
  148. }).then(function () {
  149. return delResObj(row.id)
  150. }).then(data => {
  151. _this.$message({
  152. showClose: true,
  153. message: '删除成功',
  154. type: 'success'
  155. })
  156. this.getResList(this.pageRes, {fansMsgId: this.msgId})
  157. }).catch(function (err) {
  158. })
  159. },
  160. handleResSave: function (row, done) {
  161. row.fansMsgId = this.msgId
  162. addResObj(this.filterForm(row)).then(data => {
  163. this.$message({
  164. showClose: true,
  165. message: '发送成功',
  166. type: 'success'
  167. })
  168. done()
  169. this.getResList(this.pageRes, {fansMsgId: this.msgId})
  170. })
  171. },
  172. /**
  173. * 刷新回调
  174. */
  175. refreshChange() {
  176. this.getList(this.page)
  177. },
  178. /**
  179. * 搜索回调
  180. */
  181. searchChange(form) {
  182. this.getList(this.page, form)
  183. },
  184. reply: function (row) {
  185. this.msgId = row.id
  186. this.dialogFormVisible = true
  187. this.getResList(this.pageRes, {fansMsgId: this.msgId})
  188. // 同时刷新 客户消息列表
  189. this.getList(this.page)
  190. }
  191. }
  192. }
  193. </script>
  194. <style lang="scss" scoped>
  195. </style>