feedback.js 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2. var Controller = {
  3. index: () => {
  4. const { reactive, onMounted } = Vue
  5. const { ElMessageBox } = ElementPlus
  6. const index = {
  7. setup() {
  8. const state = reactive({
  9. data: [],
  10. order: '',
  11. sort: '',
  12. filter: {
  13. drawer: false,
  14. data: {
  15. keyword: '',
  16. phone: '',
  17. },
  18. tools: {
  19. keyword: {
  20. type: 'tinput',
  21. label: '查询内容',
  22. placeholder: '请输入查询内容',
  23. value: '',
  24. },
  25. phone: {
  26. type: 'tinput',
  27. label: '联系电话',
  28. placeholder: '请输入联系电话',
  29. value: '',
  30. },
  31. },
  32. condition: {},
  33. }
  34. })
  35. function getData() {
  36. let tempSearch = JSON.parse(JSON.stringify(state.filter.data));
  37. let search = composeFilter(tempSearch, {
  38. keyword: 'like',
  39. phone: 'like',
  40. });
  41. Fast.api.ajax({
  42. url: 'shopro/feedback',
  43. type: 'GET',
  44. data: {
  45. page: pagination.page,
  46. list_rows: pagination.list_rows,
  47. order: state.order,
  48. sort: state.sort,
  49. ...search,
  50. },
  51. }, function (ret, res) {
  52. state.data = res.data.data
  53. pagination.total = res.data.total
  54. return false
  55. }, function (ret, res) { })
  56. }
  57. function onChangeSort({ prop, order }) {
  58. state.order = order == 'ascending' ? 'asc' : 'desc';
  59. state.sort = prop;
  60. getData();
  61. }
  62. function onOpenFilter() {
  63. state.filter.drawer = true
  64. }
  65. function onChangeFilter() {
  66. pagination.page = 1
  67. getData()
  68. state.filter.drawer && (state.filter.drawer = false)
  69. }
  70. const pagination = reactive({
  71. page: 1,
  72. list_rows: 10,
  73. total: 0,
  74. })
  75. const batchHandle = reactive({
  76. data: [],
  77. })
  78. function onChangeSelection(val) {
  79. batchHandle.data = val
  80. }
  81. function onBatchHandle(type) {
  82. let ids = []
  83. batchHandle.data.forEach((item) => {
  84. ids.push(item.id)
  85. })
  86. switch (type) {
  87. case 'delete':
  88. ElMessageBox.confirm('此操作将删除, 是否继续?', '提示', {
  89. confirmButtonText: '确定',
  90. cancelButtonText: '取消',
  91. type: 'warning',
  92. }).then(() => {
  93. onDelete(ids.join(','))
  94. });
  95. break;
  96. default:
  97. Fast.api.ajax({
  98. url: `shopro/feedback/edit/id/${ids.join(',')}`,
  99. type: 'POST',
  100. data: {
  101. status: type
  102. }
  103. }, function (ret, res) {
  104. getData()
  105. }, function (ret, res) { })
  106. break;
  107. }
  108. }
  109. function onDetail(id) {
  110. Fast.api.open(`shopro/feedback/detail?type=edit&id=${id}`, "编辑", {
  111. callback() {
  112. getData()
  113. }
  114. })
  115. }
  116. function onDelete(id) {
  117. Fast.api.ajax({
  118. url: `shopro/feedback/delete/id/${id}`,
  119. type: 'DELETE',
  120. }, function (ret, res) {
  121. getData()
  122. }, function (ret, res) { })
  123. }
  124. onMounted(() => {
  125. getData()
  126. })
  127. return {
  128. state,
  129. getData,
  130. onChangeSort,
  131. onOpenFilter,
  132. onChangeFilter,
  133. pagination,
  134. batchHandle,
  135. onChangeSelection,
  136. onBatchHandle,
  137. onDetail,
  138. onDelete
  139. }
  140. }
  141. }
  142. createApp('index', index);
  143. },
  144. detail: () => {
  145. const { reactive, onMounted, getCurrentInstance } = Vue
  146. const detail = {
  147. setup() {
  148. const { proxy } = getCurrentInstance();
  149. const state = reactive({
  150. type: new URLSearchParams(location.search).get('type'),
  151. id: new URLSearchParams(location.search).get('id')
  152. })
  153. const form = reactive({
  154. model: {},
  155. rules: {},
  156. })
  157. function getDetail() {
  158. Fast.api.ajax({
  159. url: `shopro/feedback/detail/id/${state.id}`,
  160. type: 'GET',
  161. }, function (ret, res) {
  162. form.model = res.data;
  163. return false
  164. }, function (ret, res) { })
  165. }
  166. function onConfirm() {
  167. proxy.$refs['formRef'].validate((valid) => {
  168. if (valid) {
  169. Fast.api.ajax({
  170. url: `shopro/feedback/edit/id/${state.id}`,
  171. type: 'POST',
  172. data: {
  173. status: form.model.status,
  174. remark: form.model.remark,
  175. }
  176. }, function (ret, res) {
  177. Fast.api.close()
  178. }, function (ret, res) { })
  179. }
  180. });
  181. }
  182. onMounted(() => {
  183. state.type == 'edit' && getDetail()
  184. })
  185. return {
  186. state,
  187. form,
  188. onConfirm
  189. }
  190. }
  191. }
  192. createApp('detail', detail);
  193. }
  194. };
  195. return Controller;
  196. });