invoice.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  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. status: 'all',
  13. order: { field: 'order.order_sn', value: '' },
  14. user: { field: 'user.nickname', value: '' },
  15. invoice: { field: 'name', value: '' },
  16. type: '',
  17. },
  18. tools: {
  19. order: {
  20. type: 'tinputprepend',
  21. label: '订单信息',
  22. placeholder: '请输入查询内容',
  23. value: {
  24. field: 'order.order_sn',
  25. value: '',
  26. },
  27. options: {
  28. data: [{
  29. label: '订单编号',
  30. value: 'order.order_sn',
  31. },
  32. {
  33. label: '订单ID',
  34. value: 'order_id',
  35. }]
  36. }
  37. },
  38. user: {
  39. type: 'tinputprepend',
  40. label: '用户信息',
  41. placeholder: '请输入查询内容',
  42. value: {
  43. field: 'user.nickname',
  44. value: '',
  45. },
  46. options: {
  47. data: [{
  48. label: '用户昵称',
  49. value: 'user.nickname',
  50. },
  51. {
  52. label: '用户手机号',
  53. value: 'user.mobile',
  54. }]
  55. }
  56. },
  57. invoice: {
  58. type: 'tinputprepend',
  59. label: '发票信息',
  60. placeholder: '请输入查询内容',
  61. value: {
  62. field: 'name',
  63. value: '',
  64. },
  65. options: {
  66. data: [{
  67. label: '发票抬头',
  68. value: 'name',
  69. },
  70. {
  71. label: '税号',
  72. value: 'tax_no',
  73. },
  74. {
  75. label: ' 联系方式',
  76. value: 'mobile',
  77. },
  78. {
  79. label: ' 公司地址',
  80. value: 'address',
  81. }]
  82. }
  83. },
  84. type: {
  85. type: 'tselect',
  86. label: '发票类型',
  87. value: '',
  88. options: {
  89. data: [{
  90. label: '全部',
  91. value: 'all',
  92. },
  93. {
  94. label: '个人',
  95. value: 'person',
  96. },
  97. {
  98. label: '企/事业单位',
  99. value: 'company',
  100. }]
  101. },
  102. },
  103. },
  104. condition: {},
  105. },
  106. statusStyle: {
  107. cancel: 'danger',
  108. unpaid: 'info',
  109. waiting: 'warning',
  110. finish: 'success',
  111. },
  112. })
  113. const type = reactive({
  114. data: {
  115. status: [{
  116. name: '全部',
  117. type: 'all',
  118. },
  119. {
  120. name: '已取消',
  121. type: 'cancel',
  122. },
  123. {
  124. name: '未支付',
  125. type: 'unpaid',
  126. },
  127. {
  128. name: '等待处理',
  129. type: 'waiting',
  130. },
  131. {
  132. name: '已开具',
  133. type: 'finish',
  134. }],
  135. }
  136. })
  137. function getData() {
  138. let tempSearch = JSON.parse(JSON.stringify(state.filter.data));
  139. let search = composeFilter(tempSearch, {
  140. 'order.order_sn': 'like',
  141. 'user.nickname': 'like',
  142. 'user.mobile': 'like',
  143. name: 'like',
  144. tax_no: 'like',
  145. address: 'like',
  146. });
  147. Fast.api.ajax({
  148. url: 'shopro/order/invoice',
  149. type: 'GET',
  150. data: {
  151. page: pagination.page,
  152. list_rows: pagination.list_rows,
  153. ...search,
  154. },
  155. }, function (ret, res) {
  156. state.data = res.data.data
  157. pagination.total = res.data.total
  158. return false
  159. }, function (ret, res) { })
  160. }
  161. function onOpenFilter() {
  162. state.filter.drawer = true
  163. }
  164. function onChangeFilter() {
  165. pagination.page = 1
  166. getData()
  167. state.filter.drawer && (state.filter.drawer = false)
  168. }
  169. function onChangeTab() {
  170. pagination.page = 1
  171. getData()
  172. }
  173. const pagination = reactive({
  174. page: 1,
  175. list_rows: 10,
  176. total: 0,
  177. })
  178. function onConfirm(item) {
  179. let params = {
  180. id: item.id,
  181. order_status_text: item.order_status_text,
  182. order_fee: item.order_fee,
  183. amount: item.amount,
  184. }
  185. Fast.api.open(`shopro/order/invoice/confirm/id/${item.id}?item=${encodeURI(JSON.stringify(params))}`, "开具发票", {
  186. callback() {
  187. getData()
  188. }
  189. })
  190. }
  191. function onOpenOrderDetail(id) {
  192. Fast.api.open(`shopro/order/order/detail?id=${id}`, "订单详情", {
  193. callback() {
  194. getData()
  195. }
  196. })
  197. }
  198. onMounted(() => {
  199. getData()
  200. })
  201. return {
  202. onClipboard,
  203. state,
  204. type,
  205. getData,
  206. onOpenFilter,
  207. onChangeFilter,
  208. onChangeTab,
  209. pagination,
  210. onOpenOrderDetail,
  211. onConfirm,
  212. }
  213. }
  214. }
  215. createApp('index', index);
  216. },
  217. confirm: () => {
  218. const { reactive, getCurrentInstance } = Vue
  219. const confirm = {
  220. setup() {
  221. const { proxy } = getCurrentInstance();
  222. const state = reactive({
  223. item: JSON.parse(new URLSearchParams(location.search).get('item')),
  224. })
  225. const form = reactive({
  226. model: {
  227. invoice_amount: state.item.amount,
  228. download_urls: [],
  229. },
  230. rules: {
  231. invoice_amount: [{ required: true, message: '请输入实际开票金额', trigger: 'blur' }],
  232. download_urls: [{ required: true, message: '请选择发票图片', trigger: 'blur' }],
  233. },
  234. });
  235. function onConfirm() {
  236. proxy.$refs['formRef'].validate((valid) => {
  237. if (valid) {
  238. Fast.api.ajax({
  239. url: `shopro/order/invoice/confirm/id/${state.item.id}`,
  240. type: 'POST',
  241. data: form.model
  242. }, function (ret, res) {
  243. Fast.api.close()
  244. }, function (ret, res) { })
  245. }
  246. });
  247. }
  248. return {
  249. state,
  250. form,
  251. onConfirm,
  252. }
  253. }
  254. }
  255. createApp('confirm', confirm);
  256. },
  257. };
  258. return Controller;
  259. });