collect.vue 8.4 KB

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