withdraw.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2. var Controller = {
  3. index: () => {
  4. const { reactive, onMounted } = Vue
  5. const index = {
  6. setup() {
  7. const state = reactive({
  8. data: [],
  9. order: '',
  10. sort: '',
  11. filter: {
  12. drawer: false,
  13. data: {
  14. status: 'all',
  15. user: { field: 'user_id', value: '' },
  16. withdraw_type: 'all',
  17. createtime: [],
  18. updatetime: [],
  19. },
  20. tools: {
  21. user: {
  22. type: 'tinputprepend',
  23. label: '用户信息',
  24. placeholder: '请输入查询内容',
  25. value: {
  26. field: 'user_id',
  27. value: '',
  28. },
  29. options: {
  30. data: [{
  31. label: '用户ID',
  32. value: 'user_id',
  33. },
  34. {
  35. label: '用户昵称',
  36. value: 'user.nickname',
  37. },
  38. {
  39. label: '用户手机号',
  40. value: 'user.mobile',
  41. }]
  42. }
  43. },
  44. withdraw_type: {
  45. type: 'tselect',
  46. label: '提现方式',
  47. value: '',
  48. options: {
  49. data: [{
  50. label: '全部',
  51. value: 'all',
  52. },
  53. {
  54. label: '支付宝账户',
  55. value: 'alipay',
  56. },
  57. {
  58. label: '微信零钱',
  59. value: 'wechat',
  60. },
  61. {
  62. label: '银行卡',
  63. value: 'bank',
  64. }]
  65. },
  66. },
  67. createtime: {
  68. type: 'tdatetimerange',
  69. label: '下单时间',
  70. value: [],
  71. },
  72. updatetime: {
  73. type: 'tdatetimerange',
  74. label: '上次操作时间',
  75. value: [],
  76. },
  77. },
  78. condition: {},
  79. },
  80. statusStyle: {
  81. '-1': 'sa-color--danger',
  82. 0: 'sa-color--info',
  83. 1: 'sa-color--warning',
  84. 2: 'sa-color--success',
  85. }
  86. })
  87. const type = reactive({
  88. data: {
  89. status: [{
  90. name: '全部',
  91. type: 'all',
  92. },
  93. {
  94. name: '待审核',
  95. type: '0',
  96. },
  97. {
  98. name: '处理中',
  99. type: '1',
  100. },
  101. {
  102. name: '已处理',
  103. type: '2',
  104. },
  105. {
  106. name: '已拒绝',
  107. type: '-1',
  108. },],
  109. }
  110. })
  111. function getData() {
  112. let tempSearch = JSON.parse(JSON.stringify(state.filter.data));
  113. let search = composeFilter(tempSearch, {
  114. 'user.nickname': 'like',
  115. 'user.mobile': 'like',
  116. createtime: 'range',
  117. updatetime: 'range',
  118. });
  119. Fast.api.ajax({
  120. url: 'shopro/withdraw',
  121. type: 'GET',
  122. data: {
  123. page: pagination.page,
  124. list_rows: pagination.list_rows,
  125. order: state.order,
  126. sort: state.sort,
  127. ...search,
  128. },
  129. }, function (ret, res) {
  130. state.data = res.data.data
  131. pagination.total = res.data.total
  132. return false
  133. }, function (ret, res) { })
  134. }
  135. function onChangeSort({ prop, order }) {
  136. state.order = order == 'ascending' ? 'asc' : 'desc';
  137. state.sort = prop;
  138. getData();
  139. }
  140. function onOpenFilter() {
  141. state.filter.drawer = true
  142. }
  143. function onChangeFilter() {
  144. pagination.page = 1
  145. getData()
  146. state.filter.drawer && (state.filter.drawer = false)
  147. }
  148. function onChangeTab() {
  149. pagination.page = 1
  150. getData()
  151. }
  152. const pagination = reactive({
  153. page: 1,
  154. list_rows: 10,
  155. total: 0,
  156. })
  157. const handlePopover = reactive({
  158. flag: {}
  159. })
  160. function onAgree(id, index, type) {
  161. handlePopover.flag[index] = false;
  162. Fast.api.ajax({
  163. url: `shopro/withdraw/handle/id/${id}`,
  164. type: 'POST',
  165. data: {
  166. action: type,
  167. },
  168. }, function (ret, res) {
  169. getData();
  170. }, function (ret, res) { })
  171. }
  172. function onRefuse(id) {
  173. Fast.api.open(`shopro/withdraw/handle/id/${id}?id=${id}`, "拒绝", {
  174. callback() {
  175. getData()
  176. }
  177. })
  178. }
  179. function onLog(id) {
  180. Fast.api.open(`shopro/withdraw/log/id/${id}?id=${id}`, "日志")
  181. }
  182. onMounted(() => {
  183. getData()
  184. })
  185. return {
  186. onClipboard,
  187. state,
  188. type,
  189. getData,
  190. onChangeSort,
  191. onOpenFilter,
  192. onChangeFilter,
  193. onChangeTab,
  194. pagination,
  195. handlePopover,
  196. onAgree,
  197. onRefuse,
  198. onLog,
  199. }
  200. }
  201. }
  202. createApp('index', index);
  203. },
  204. handle: () => {
  205. const { reactive, getCurrentInstance } = Vue
  206. const handle = {
  207. setup() {
  208. const { proxy } = getCurrentInstance();
  209. const state = reactive({
  210. id: new URLSearchParams(location.search).get('id'),
  211. })
  212. const form = reactive({
  213. model: {
  214. action: 'refuse',
  215. refuse_msg: '',
  216. },
  217. rules: {
  218. refuse_msg: [{ required: true, message: '请输入拒绝理由', trigger: 'blur' }],
  219. },
  220. });
  221. function onConfirm() {
  222. proxy.$refs['formRef'].validate((valid) => {
  223. if (valid) {
  224. Fast.api.ajax({
  225. url: `shopro/withdraw/handle/id/${state.id}`,
  226. type: 'POST',
  227. data: form.model
  228. }, function (ret, res) {
  229. Fast.api.close()
  230. }, function (ret, res) { })
  231. }
  232. });
  233. }
  234. return {
  235. state,
  236. form,
  237. onConfirm,
  238. }
  239. }
  240. }
  241. createApp('handle', handle);
  242. },
  243. log: () => {
  244. const { reactive, onMounted } = Vue
  245. const log = {
  246. setup() {
  247. const state = reactive({
  248. id: new URLSearchParams(location.search).get('id'),
  249. data: [],
  250. })
  251. function getData() {
  252. Fast.api.ajax({
  253. url: `shopro/withdraw/log/id/${state.id}`,
  254. type: 'GET',
  255. }, function (ret, res) {
  256. state.data = res.data
  257. return false
  258. }, function (ret, res) { })
  259. }
  260. onMounted(() => {
  261. getData()
  262. })
  263. return {
  264. state,
  265. }
  266. }
  267. }
  268. createApp('log', log);
  269. },
  270. };
  271. return Controller;
  272. });