collect.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. <template>
  2. <template-page
  3. ref="pageRef"
  4. :get-list="getList"
  5. :exportList="exportList"
  6. :table-attributes="tableAttributes"
  7. :table-events="tableEvents"
  8. :moreParameters="moreParameters"
  9. :column-parsing="columnParsing"
  10. :operation="operation()"
  11. :operationColumnWidth="200"
  12. :optionsEvensGroup="optionsEvensGroup"
  13. :defaultSearchData="defaultSearchData"
  14. >
  15. <div class="cartographer">
  16. <el-dialog
  17. :title="formTypeName[formType]"
  18. width="100%"
  19. :modal="false"
  20. :visible.sync="formDialog"
  21. :before-close="formCancel"
  22. >
  23. <zj-form-container v-if="formDialog" ref="formRef" :form-data="formData" :styleSwitch="false">
  24. <zj-form-module
  25. title="基础信息"
  26. label-width="120px"
  27. :showPackUp="false"
  28. :form-data="formData"
  29. :form-items="formItems"
  30. >
  31. </zj-form-module>
  32. <zj-form-module
  33. title="订单信息"
  34. label-width="120px"
  35. :showPackUp="false"
  36. :form-data="formData"
  37. :form-items="formItemsList"
  38. >
  39. </zj-form-module>
  40. <zj-form-module
  41. title="附件图片"
  42. label-width="120px"
  43. :showPackUp="false"
  44. :form-data="formData"
  45. :form-items="formItemsImgs"
  46. >
  47. </zj-form-module>
  48. </zj-form-container>
  49. <div slot="footer" v-if="formType" class="dialog-footer">
  50. <el-button size="mini" @click="formCancel">取 消</el-button>
  51. <el-button size="mini" @click="formConfirm" type="primary">确定</el-button>
  52. </div>
  53. </el-dialog>
  54. </div>
  55. </template-page>
  56. </template>
  57. <script>
  58. import TemplatePage from '@/components/template/template-page-1.vue'
  59. import import_mixin from '@/components/template/import_mixin.js'
  60. import {
  61. increOrderSettleList,
  62. increOrderSettleListExport,
  63. increOrderSettleDetail,
  64. increOrderSettleConfirm,
  65. increOrderSettleRefund
  66. } from '@/api/orderSettleManag.js'
  67. import operation_mixin from '@/components/template/operation_mixin.js'
  68. import formItems from '../mixins/formItems.js'
  69. export default {
  70. props: {
  71. storageType: {
  72. type: String,
  73. default: ''
  74. }
  75. },
  76. components: { TemplatePage },
  77. mixins: [import_mixin, operation_mixin, formItems],
  78. data() {
  79. return {
  80. // 表格属性
  81. tableAttributes: {
  82. // 启用勾选列
  83. selectColumn: true,
  84. selectable: this.selectable
  85. },
  86. // 表格事件
  87. tableEvents: {
  88. 'selection-change': this.selectionChange
  89. },
  90. // 勾选选中数据
  91. recordSelected: [],
  92. formTypeName: ['查看', '结算'],
  93. formType: -1,
  94. formData: {
  95. pgIncreItems: []
  96. },
  97. formDialog: false,
  98. defaultSearchData: []
  99. }
  100. },
  101. computed: {
  102. // 事件组合
  103. optionsEvensGroup() {
  104. return [
  105. [
  106. [
  107. this.optionsEvensAuth('bulkSettlemen', {
  108. click: () => {
  109. if (this.recordSelected.length === 0) {
  110. this.$message.warning('请勾选订单')
  111. return
  112. }
  113. increOrderSettleConfirm(this.recordSelected.map(item => item.id)).then(res => {
  114. this.$message({ type: 'success', message: `成功!` })
  115. this.$refs.pageRef.refreshList()
  116. })
  117. }
  118. })
  119. ]
  120. ]
  121. ]
  122. },
  123. // 更多参数
  124. moreParameters() {
  125. return [
  126. {
  127. name: '支付状态',
  128. key: 'payStatus',
  129. value: this?.$route?.params?.pageCode || '',
  130. conditions: [
  131. {
  132. label: '全部',
  133. value: ''
  134. },
  135. {
  136. label: '已支付',
  137. value: 'PAID'
  138. },
  139. {
  140. label: '待支付',
  141. value: 'WAIT'
  142. },
  143. {
  144. label: '已退款',
  145. value: 'REFUND'
  146. },
  147. {
  148. label: '过期',
  149. value: 'EXPIRE'
  150. },
  151. {
  152. label: '取消',
  153. value: 'CANCEL'
  154. }
  155. ]
  156. }
  157. ]
  158. }
  159. },
  160. created() {
  161. if (this.pageCode && !~['PAID', 'WAIT', 'REFUND', 'EXPIRE', 'CANCEL'].indexOf(this.pageCode)) {
  162. this.defaultSearchData = [{ param: 'a.id', compare: '=', value: this.pageCode, label: '订单单号' }]
  163. }
  164. },
  165. methods: {
  166. selectable(row, index) {
  167. return (
  168. ['PAID'].includes(
  169. Object.entries(row.selectMapData.payStatus).find(([key, val]) => val == row.payStatus)?.[0]
  170. ) &&
  171. ['ING'].includes(
  172. Object.entries(row.selectMapData.settleStatus).find(([key, val]) => val == row.settleStatus)?.[0]
  173. )
  174. )
  175. },
  176. // 列表请求函数
  177. getList(p, cb) {
  178. var pam = JSON.parse(JSON.stringify(p))
  179. try {
  180. if (pam.payStatus) {
  181. pam.params.push({ param: 'a.pay_status', compare: '=', value: pam.payStatus })
  182. }
  183. pam.params.push({ param: 'a.order_channel', compare: '=', value: 'ONLINE' })
  184. cb && cb(pam)
  185. return increOrderSettleList(pam)
  186. } catch (err) {}
  187. },
  188. // 列表导出函数
  189. exportList: increOrderSettleListExport,
  190. // 表格列解析渲染数据更改
  191. columnParsing(item, defaultData) {
  192. if (item.jname === 'residuNum') {
  193. defaultData.render = (h, { row, index, column }) => {
  194. return <div style="padding:0 6px;cursor: pointer;">{row['increType'] != 1 ? row['residuNum'] : ''}</div>
  195. }
  196. }
  197. if (item.jname === 'serviceEndTime') {
  198. defaultData.render = (h, { row, index, column }) => {
  199. return (
  200. <div style="padding:0 6px;cursor: pointer;">
  201. {row[column.columnAttributes.prop] ? row[column.columnAttributes.prop].split(' ')[0] : ''}
  202. </div>
  203. )
  204. }
  205. }
  206. return defaultData
  207. },
  208. // 监听勾选变化
  209. selectionChange(data) {
  210. this.recordSelected = data
  211. },
  212. // 表格操作列
  213. operation() {
  214. return this.operationBtn({
  215. detail: {
  216. btnType: 'text',
  217. click: ({ row, index, column }) => {
  218. this.formType = 0
  219. this.getDetail(row.id)
  220. }
  221. },
  222. orderDetail: {
  223. btnType: 'text',
  224. conditions: ({ row, index, column }) => {
  225. return ['PAID', 'REFUND'].includes(row.payStatus)
  226. },
  227. click: ({ row, index, column }) => {
  228. this.$router.push({
  229. name: 'workOrderPool',
  230. params: {
  231. pageName: row.id,
  232. pageType: 'pgIncreItemId',
  233. pageCode: row.id
  234. }
  235. })
  236. }
  237. },
  238. refund: {
  239. btnType: 'text',
  240. prompt: '是否确定退款?',
  241. conditions: ({ row, index, column }) => {
  242. return (
  243. ['PAID'].includes(row.payStatus) &&
  244. ['ING'].includes(row.settleStatus) &&
  245. (() => {
  246. var currentDate = new Date(row.payTime)
  247. currentDate.setDate(currentDate.getDate() + 7)
  248. currentDate.setHours(23)
  249. currentDate.setMinutes(59)
  250. currentDate.setSeconds(59)
  251. return currentDate > new Date()
  252. })()
  253. )
  254. },
  255. click: ({ row, index, column }) => {
  256. increOrderSettleRefund({ id: row.id }).then(res => {
  257. this.$message({ type: 'success', message: `退款成功!` })
  258. this.$refs.pageRef.refreshList()
  259. })
  260. }
  261. },
  262. settlement: {
  263. btnType: 'text',
  264. prompt: '是否确定结算?',
  265. conditions: ({ row, index, column }) => {
  266. return ['PAID'].includes(row.payStatus) && ['ING'].includes(row.settleStatus)
  267. },
  268. click: ({ row, index, column }) => {
  269. this.formType = 1
  270. this.getDetail(row.id)
  271. }
  272. }
  273. })
  274. },
  275. getDetail(id) {
  276. increOrderSettleDetail({ id }).then(res => {
  277. Object.assign(this.formData, res.data)
  278. this.openForm()
  279. })
  280. },
  281. openForm() {
  282. this.formDialog = true
  283. },
  284. // 关闭弹窗
  285. formCancel() {
  286. this.$refs.formRef.$refs.inlineForm.clearValidate()
  287. this.$data.formData = this.$options.data().formData
  288. this.formDialog = false
  289. },
  290. formConfirm() {
  291. this.$refs.formRef.validate((valid, invalidFields, errLabels) => {
  292. if (valid) {
  293. increOrderSettleConfirm([this.formData.id]).then(res => {
  294. this.$message({ type: 'success', message: `操作成功!` })
  295. this.formCancel()
  296. this.$refs.pageRef.refreshList()
  297. })
  298. }
  299. })
  300. }
  301. }
  302. }
  303. </script>
  304. <style lang="scss">
  305. .redbordererr {
  306. .el-form-item {
  307. margin: 0 !important;
  308. overflow: hidden;
  309. }
  310. }
  311. </style>