aftersale.js 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447
  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. filter: {
  10. drawer: false,
  11. data: {
  12. 'aftersale_list.aftersale_status': 'all',
  13. 'aftersale_list.goods_title': '',
  14. keyword: { field: 'aftersale_list.aftersale_sn', value: '' },
  15. user: { field: 'user.nickname', value: '' },
  16. 'aftersale_list.type': '',
  17. 'aftersale_list.dispatch_status': '',
  18. 'aftersale_list.refund_status': '',
  19. },
  20. tools: {
  21. 'aftersale_list.goods_title': {
  22. type: 'tinput',
  23. label: '商品名称',
  24. value: '',
  25. },
  26. keyword: {
  27. type: 'tinputprepend',
  28. label: '售后信息',
  29. placeholder: '请输入查询内容',
  30. value: {
  31. field: 'aftersale_list.aftersale_sn',
  32. value: '',
  33. },
  34. options: {
  35. data: [{
  36. label: '售后单号',
  37. value: 'aftersale_list.aftersale_sn',
  38. },
  39. {
  40. label: '售后手机号',
  41. value: 'aftersale_list.mobile',
  42. },
  43. {
  44. label: '订单编号',
  45. value: 'order_sn',
  46. }]
  47. }
  48. },
  49. user: {
  50. type: 'tinputprepend',
  51. label: '售后用户',
  52. placeholder: '请输入查询内容',
  53. value: {
  54. field: 'user.nickname',
  55. value: '',
  56. },
  57. options: {
  58. data: [{
  59. label: '用户昵称',
  60. value: 'user.nickname',
  61. },
  62. {
  63. label: '手机号',
  64. value: 'user.mobile',
  65. }]
  66. },
  67. },
  68. 'aftersale_list.type': {
  69. type: 'tselect',
  70. label: '售后类型',
  71. value: '',
  72. options: {
  73. data: [],
  74. props: {
  75. label: 'name',
  76. value: 'type',
  77. },
  78. },
  79. },
  80. 'aftersale_list.dispatch_status': {
  81. type: 'tselect',
  82. label: '发货状态',
  83. value: '',
  84. options: {
  85. data: [],
  86. props: {
  87. label: 'name',
  88. value: 'type',
  89. },
  90. },
  91. },
  92. 'aftersale_list.refund_status': {
  93. type: 'tselect',
  94. label: '退款状态',
  95. value: '',
  96. options: {
  97. data: [],
  98. props: {
  99. label: 'name',
  100. value: 'type',
  101. },
  102. },
  103. },
  104. },
  105. condition: {},
  106. }
  107. })
  108. const type = reactive({
  109. data: {}
  110. })
  111. function getType() {
  112. Fast.api.ajax({
  113. url: 'shopro/order/aftersale/getType',
  114. type: 'GET',
  115. }, function (ret, res) {
  116. type.data = res.data
  117. for (key in res.data) {
  118. if (key == 'aftersale_status') {
  119. } else {
  120. state.filter.tools[`aftersale_list.${key}`].options.data = res.data[key]
  121. }
  122. }
  123. return false
  124. }, function (ret, res) { })
  125. }
  126. function getData() {
  127. let tempSearch = JSON.parse(JSON.stringify(state.filter.data));
  128. let search = composeFilter(tempSearch, {
  129. 'aftersale_list.goods_title': 'like',
  130. 'aftersale_list.aftersale_sn': 'like',
  131. 'aftersale_list.mobile': 'like',
  132. order_sn: 'like',
  133. 'user.nickname': 'like',
  134. 'user.mobile': 'like',
  135. });
  136. search = {
  137. search: JSON.stringify({
  138. 'aftersale_list._': '',
  139. ...JSON.parse(search.search),
  140. }),
  141. };
  142. Fast.api.ajax({
  143. url: 'shopro/order/aftersale',
  144. type: 'GET',
  145. data: {
  146. page: pagination.page,
  147. list_rows: pagination.list_rows,
  148. ...search,
  149. },
  150. }, function (ret, res) {
  151. state.data = res.data.data
  152. pagination.total = res.data.total
  153. return false
  154. }, function (ret, res) { })
  155. }
  156. function onOpenFilter() {
  157. state.filter.drawer = true
  158. }
  159. function onChangeFilter() {
  160. pagination.page = 1
  161. getData()
  162. state.filter.drawer && (state.filter.drawer = false)
  163. }
  164. function onChangeTab() {
  165. pagination.page = 1
  166. getData()
  167. }
  168. const pagination = reactive({
  169. page: 1,
  170. list_rows: 10,
  171. total: 0,
  172. })
  173. function onDetail(id) {
  174. Fast.api.open(`shopro/order/aftersale/detail/id/${id}?id=${id}`, "详情", {
  175. callback() {
  176. getData()
  177. }
  178. })
  179. }
  180. function onOpenGoods(id) {
  181. Fast.api.open(`shopro/goods/goods/add?type=edit&id=${id}`, "商品详情", {
  182. callback() {
  183. getData()
  184. }
  185. })
  186. }
  187. function onOpenOrderDetail(id) {
  188. Fast.api.open(`shopro/order/order/detail?id=${id}`, "订单详情", {
  189. callback() {
  190. getData()
  191. }
  192. })
  193. }
  194. onMounted(() => {
  195. getType()
  196. getData()
  197. })
  198. return {
  199. onClipboard,
  200. state,
  201. type,
  202. getData,
  203. onOpenFilter,
  204. onChangeFilter,
  205. onChangeTab,
  206. pagination,
  207. onDetail,
  208. onOpenGoods,
  209. onOpenOrderDetail,
  210. }
  211. }
  212. }
  213. createApp('index', index);
  214. },
  215. detail: () => {
  216. const { reactive, onMounted } = Vue
  217. const detail = {
  218. setup() {
  219. const state = reactive({
  220. id: new URLSearchParams(location.search).get('id'),
  221. data: {},
  222. stepActive: 1,
  223. })
  224. function getDetail() {
  225. Fast.api.ajax({
  226. url: `shopro/order/aftersale/detail/id/${state.id}`,
  227. type: 'GET',
  228. }, function (ret, res) {
  229. state.data = res.data;
  230. setStepActive()
  231. return false
  232. }, function (ret, res) { })
  233. }
  234. function setStepActive() {
  235. if (
  236. state.data.aftersale_status == -1 ||
  237. state.data.aftersale_status == -2 ||
  238. state.data.aftersale_status == 2
  239. ) {
  240. state.stepActive = 3;
  241. } else {
  242. state.stepActive = state.data.aftersale_status + 1;
  243. }
  244. }
  245. function onRefund() {
  246. Fast.api.open(`shopro/order/aftersale/refund/id/${state.id}?id=${state.id}&suggest_refund_fee=${state.data.suggest_refund_fee}&apply_refund_price=${state.data.apply_refund_price}`, "售后退款", {
  247. callback() {
  248. getDetail()
  249. }
  250. })
  251. }
  252. function onRefuse() {
  253. Fast.api.open(`shopro/order/aftersale/refuse/id/${state.id}?id=${state.id}`, "拒绝售后", {
  254. callback() {
  255. getDetail()
  256. }
  257. })
  258. }
  259. function onAgree() {
  260. Fast.api.ajax({
  261. url: `shopro/order/aftersale/agree/id/${state.id}`,
  262. type: 'POST',
  263. }, function (ret, res) {
  264. getDetail()
  265. }, function (ret, res) { })
  266. }
  267. function onCompleted() {
  268. Fast.api.ajax({
  269. url: `shopro/order/aftersale/completed/id/${state.id}`,
  270. type: 'POST',
  271. }, function (ret, res) {
  272. getDetail()
  273. }, function (ret, res) { })
  274. }
  275. function onAddLog() {
  276. Fast.api.open(`shopro/order/aftersale/addLog/id/${state.id}?id=${state.id}`, "回复买家", {
  277. callback() {
  278. getDetail()
  279. }
  280. })
  281. }
  282. onMounted(() => {
  283. getDetail()
  284. })
  285. return {
  286. onClipboard,
  287. state,
  288. onRefund,
  289. onRefuse,
  290. onAgree,
  291. onCompleted,
  292. onAddLog,
  293. }
  294. }
  295. }
  296. createApp('detail', detail);
  297. },
  298. refund: () => {
  299. const { reactive, getCurrentInstance } = Vue
  300. const refund = {
  301. setup() {
  302. const { proxy } = getCurrentInstance();
  303. const state = reactive({
  304. id: new URLSearchParams(location.search).get('id'),
  305. suggest_refund_fee: new URLSearchParams(location.search).get('suggest_refund_fee'),
  306. apply_refund_price: new URLSearchParams(location.search).get('apply_refund_price'),
  307. })
  308. const form = reactive({
  309. model: {
  310. refund_type: 'back',
  311. refund_money: '',
  312. },
  313. rules: {
  314. refund_money: [{ required: true, message: '请输入退款金额', trigger: 'blur' }],
  315. },
  316. })
  317. function onConfirm() {
  318. proxy.$refs['formRef'].validate((valid) => {
  319. if (valid) {
  320. Fast.api.ajax({
  321. url: `shopro/order/aftersale/refund/id/${state.id}`,
  322. type: 'POST',
  323. data: form.model
  324. }, function (ret, res) {
  325. Fast.api.close()
  326. }, function (ret, res) { })
  327. }
  328. });
  329. }
  330. return {
  331. state,
  332. form,
  333. onConfirm,
  334. }
  335. }
  336. }
  337. createApp('refund', refund);
  338. },
  339. refuse: () => {
  340. const { reactive, getCurrentInstance } = Vue
  341. const refuse = {
  342. setup() {
  343. const { proxy } = getCurrentInstance();
  344. const state = reactive({
  345. id: new URLSearchParams(location.search).get('id'),
  346. })
  347. const form = reactive({
  348. model: {
  349. refuse_msg: '',
  350. },
  351. rules: {
  352. refuse_msg: [{ required: true, message: '请输入拒绝原因', trigger: 'blur' }],
  353. },
  354. })
  355. function onConfirm() {
  356. proxy.$refs['formRef'].validate((valid) => {
  357. if (valid) {
  358. Fast.api.ajax({
  359. url: `shopro/order/aftersale/refuse/id/${state.id}`,
  360. type: 'POST',
  361. data: form.model
  362. }, function (ret, res) {
  363. Fast.api.close()
  364. }, function (ret, res) { })
  365. }
  366. });
  367. }
  368. return {
  369. state,
  370. form,
  371. onConfirm,
  372. }
  373. }
  374. }
  375. createApp('refuse', refuse);
  376. },
  377. addlog: () => {
  378. const { reactive, getCurrentInstance } = Vue
  379. const addLog = {
  380. setup() {
  381. const { proxy } = getCurrentInstance();
  382. const state = reactive({
  383. id: new URLSearchParams(location.search).get('id'),
  384. })
  385. const form = reactive({
  386. model: {
  387. content: '',
  388. images: [],
  389. },
  390. rules: {
  391. content: [{ required: true, message: '请输入', trigger: 'blur' }],
  392. },
  393. })
  394. function onConfirm() {
  395. proxy.$refs['formRef'].validate((valid) => {
  396. if (valid) {
  397. Fast.api.ajax({
  398. url: `shopro/order/aftersale/addLog/id/${state.id}`,
  399. type: 'POST',
  400. data: form.model
  401. }, function (ret, res) {
  402. Fast.api.close()
  403. }, function (ret, res) { })
  404. }
  405. });
  406. }
  407. return {
  408. state,
  409. form,
  410. onConfirm,
  411. }
  412. }
  413. }
  414. createApp('addLog', addLog);
  415. },
  416. };
  417. return Controller;
  418. });