index.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  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
  21. ref="crud"
  22. :page="page"
  23. :data="tableData"
  24. :permission="permissionList"
  25. :table-loading="tableLoading"
  26. :option="tableOption"
  27. @on-load="getList"
  28. @refresh-change="refreshChange"
  29. @search-change="searchChange"
  30. @row-save="handleSave"
  31. @row-del="rowDel">
  32. <template
  33. slot-scope="scope"
  34. slot="menu">
  35. <el-button
  36. v-if="permissionList.addBtn"
  37. type="text"
  38. icon="el-icon-check"
  39. @click="reply(scope.row,scope.index)">回复
  40. </el-button>
  41. </template>
  42. </avue-crud>
  43. <el-dialog :visible.sync="dialogFormVisible" title="回复消息">
  44. <avue-crud
  45. ref="crudLog"
  46. :page="pageRes"
  47. :data="tableResData"
  48. :option="tableResOption"
  49. @row-save="handleResSave"
  50. @row-del="rowResDel"/>
  51. </el-dialog>
  52. </basic-container>
  53. </div>
  54. </template>
  55. <script>
  56. import { addObj, addResObj, delObj, delResObj, fetchList, fetchResList } from '@/api/mp/wxfansmsg'
  57. import { tableOption, tableResOption } from '@/const/crud/mp/wxfansmsg'
  58. import { mapGetters } from 'vuex'
  59. export default {
  60. name: 'Wxfansmsg',
  61. data() {
  62. return {
  63. searchForm: {},
  64. dialogFormVisible: false,
  65. tableData: [],
  66. tableResData: [],
  67. page: {
  68. total: 0, // 总页数
  69. currentPage: 1, // 当前页数
  70. pageSize: 20 // 每页显示多少条
  71. },
  72. pageRes: {
  73. total: 0, // 总页数
  74. currentPage: 1, // 当前页数
  75. pageSize: 20 // 每页显示多少条
  76. },
  77. tableLoading: false,
  78. tableOption: tableOption,
  79. tableResOption: tableResOption,
  80. msgId: undefined
  81. }
  82. },
  83. computed: {
  84. ...mapGetters(['permissions']),
  85. permissionList() {
  86. return {
  87. addBtn: this.vaildData(this.permissions.mp_wxfansmsg_add, false),
  88. delBtn: this.vaildData(this.permissions.mp_wxfansmsg_del, false),
  89. editBtn: this.vaildData(this.permissions.mp_wxfansmsg_edit, false)
  90. }
  91. }
  92. },
  93. methods: {
  94. getList(page, params) {
  95. this.tableLoading = true
  96. fetchList(Object.assign({
  97. current: page.currentPage,
  98. size: page.pageSize
  99. }, params, this.searchForm)).then(response => {
  100. this.tableData = response.data.data.records
  101. this.page.total = response.data.data.total
  102. this.tableLoading = false
  103. })
  104. },
  105. getResList(pageRes, params) {
  106. fetchResList(Object.assign({
  107. current: pageRes.currentPage,
  108. size: pageRes.pageSize
  109. }, params)).then(response => {
  110. this.tableResData = response.data.data.records
  111. this.pageRes.total = response.data.data.total
  112. })
  113. },
  114. rowDel: function(row, index) {
  115. var _this = this
  116. this.$confirm('是否确认删除ID为' + row.id, '提示', {
  117. confirmButtonText: '确定',
  118. cancelButtonText: '取消',
  119. type: 'warning'
  120. }).then(function() {
  121. return delObj(row.id)
  122. }).then(() => {
  123. _this.tableData.splice(index, 1)
  124. _this.$message({
  125. showClose: true,
  126. message: '删除成功',
  127. type: 'success'
  128. })
  129. this.getList(this.page)
  130. }).catch(function() {
  131. })
  132. },
  133. handleSave: function(row, done) {
  134. addObj(row).then(() => {
  135. this.tableResData.push(Object.assign({}, row))
  136. this.$message({
  137. showClose: true,
  138. message: '添加成功',
  139. type: 'success'
  140. })
  141. done()
  142. this.getList(this.page)
  143. })
  144. },
  145. rowResDel: function(row) {
  146. var _this = this
  147. this.$confirm('是否确认删除ID为' + row.id, '提示', {
  148. confirmButtonText: '确定',
  149. cancelButtonText: '取消',
  150. type: 'warning'
  151. }).then(function() {
  152. return delResObj(row.id)
  153. }).then(() => {
  154. _this.$message({
  155. showClose: true,
  156. message: '删除成功',
  157. type: 'success'
  158. })
  159. this.getResList(this.pageRes, { fansMsgId: this.msgId })
  160. }).catch(function() {
  161. })
  162. },
  163. handleResSave: function(row, done) {
  164. row.fansMsgId = this.msgId
  165. addResObj(row).then(() => {
  166. this.$message({
  167. showClose: true,
  168. message: '发送成功',
  169. type: 'success'
  170. })
  171. done()
  172. this.getResList(this.pageRes, { fansMsgId: this.msgId })
  173. })
  174. },
  175. /**
  176. * 刷新回调
  177. */
  178. refreshChange() {
  179. this.getList(this.page)
  180. },
  181. /**
  182. * 搜索回调
  183. */
  184. searchChange(form) {
  185. this.searchForm = form
  186. this.getList(this.page, form)
  187. },
  188. reply: function(row) {
  189. this.msgId = row.id
  190. this.dialogFormVisible = true
  191. this.getResList(this.pageRes, { fansMsgId: this.msgId })
  192. // 同时刷新 客户消息列表
  193. this.getList(this.page)
  194. }
  195. }
  196. }
  197. </script>
  198. <style lang="scss" scoped>
  199. </style>