index.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. <template>
  2. <div class="default-main ">
  3. <el-alert class="ba-table-alert" v-if="baTable.table.remark" :title="baTable.table.remark" type="info"
  4. show-icon/>
  5. <el-row>
  6. <el-col :span="24">
  7. <!-- 表格顶部菜单 -->
  8. <TableHeader :buttons="['refresh', 'add', 'edit', 'delete', 'comSearch']"
  9. quick-search-placeholder="通过订单号模糊搜索"
  10. @action="baTable.onTableHeaderAction"/>
  11. <!-- 表格 -->
  12. <!-- 要使用`el-table`组件原有的属性,直接加在Table标签上即可 -->
  13. <Table @action="baTable.onTableAction"/>
  14. </el-col>
  15. </el-row>
  16. <auditDialog ref="dialogRef" @close="baTable.onTableHeaderAction('refresh', {loading: true})"></auditDialog>
  17. </div>
  18. </template>
  19. <script setup lang="ts">
  20. import _ from 'lodash'
  21. import {ref, onMounted, provide} from 'vue'
  22. import {order, orderRefund} from '/@/api/controllerUrls'
  23. import Table from '/@/components/table/index.vue'
  24. import TableHeader from '/@/components/table/header/index.vue'
  25. import {useRouter} from 'vue-router'
  26. import {defaultOptButtons} from '/@/components/table'
  27. import {baTableApi} from '/@/api/common'
  28. import baTableClass from '/@/utils/baTable'
  29. import useCurrentInstance from '/@/utils/useCurrentInstance'
  30. import {auth} from "/@/utils/common";
  31. import auditDialog from './auditDialog.vue'
  32. const router = useRouter()
  33. let auditBtn: OptButton[] = [
  34. {
  35. render: 'tipButton',
  36. name: 'audit',
  37. title: '审核',
  38. text: '审核',
  39. type: 'warning',
  40. icon: '',
  41. class: 'table-row-edit',
  42. disabledTip: false,
  43. },
  44. ]
  45. //根据权限增加按钮
  46. function optButtons() {
  47. let newBtns = defaultOptButtons([])
  48. if (auth('audit') == true) {
  49. newBtns = _.concat(auditBtn, newBtns)
  50. }
  51. return newBtns
  52. }
  53. const tableRef = ref()
  54. const baTable = new baTableClass(
  55. new baTableApi(orderRefund),
  56. {
  57. dblClickNotEditColumn: [undefined, 'status'],
  58. column: [
  59. {label: '会员姓名', prop: 'memberName', align: 'center', width: 120, operator: false},
  60. {label: '订单编号', prop: 'orderNumber' ,"min-width":'180px', align: 'left', operator: 'LIKE'},
  61. {label: '退款原因', prop: 'refundReason',"min-width":'180px', align: 'left', operator: false},
  62. {label: '申请退款金额', prop: 'requestAmount', align: 'center', width: 120, operator: false},
  63. {
  64. label: '退款类型',
  65. prop: 'refundType',
  66. align: 'center',
  67. render: 'tag',
  68. operator: '=',
  69. width: 120,
  70. custom: {0: '', 1: '', 2: '', 3: 'success', 4: 'warning', 5: 'info', 6: 'info'},
  71. replaceValue: {0: '全额退款', 1: '部分退款',},
  72. },
  73. {
  74. label: '退款状态',
  75. prop: 'refundStatus',
  76. align: 'center',
  77. render: 'tag',
  78. operator: '=',
  79. width: 120,
  80. custom: {0: 'warning', 1: 'info'},
  81. replaceValue: {0: '待退款', 1: '已退款',},
  82. },
  83. {label: '退款金额', prop: 'auditAmount', align: 'center', width: 120, operator: false},
  84. {
  85. label: '审核状态',
  86. prop: 'auditStatus',
  87. align: 'center',
  88. render: 'tag',
  89. operator: '=',
  90. width: 120,
  91. custom: {0: 'warning', 1: 'success', 2: 'info'},
  92. replaceValue: {0: '待审核', 1: '审核通过', 2: '审核驳回',},
  93. },
  94. {label: '创建时间', prop: 'createTime', align: 'center', width: '170', operator: false},
  95. {
  96. label: '操作',
  97. align: 'center',
  98. width: 120,
  99. render: 'buttons',
  100. buttons: optButtons(),
  101. operator: false
  102. },
  103. ],
  104. },
  105. {
  106. defaultItems: {
  107. },
  108. },
  109. {
  110. // 获得编辑数据后
  111. requestEdit: () => {
  112. if (baTable.form.items && !baTable.form.items.icon) baTable.form.items.icon = 'el-icon-Minus'
  113. },
  114. }
  115. )
  116. provide('baTable', baTable)
  117. baTable.mount()
  118. baTable.getIndex()
  119. onMounted(() => {
  120. const {proxy} = useCurrentInstance()
  121. /**
  122. * 表格内的按钮响应
  123. * @param name 按钮name
  124. * @param row 被操作行数据
  125. */
  126. proxy.eventBus.on('onTableButtonClick', (data: { name: string; row: TableRow }) => {
  127. if (!baTable.activate) return
  128. if (data.name == 'audit') {
  129. buttonClick(data.row)
  130. }
  131. })
  132. })
  133. let dialogRef = ref()
  134. /** 点击查看详情按钮响应 */
  135. const buttonClick = (row: TableRow) => {
  136. if (!row) return
  137. // 数据来自表格数据,未重新请求api,深克隆,不然可能会影响表格
  138. let rowClone = _.cloneDeep(row)
  139. dialogRef.value.open(rowClone)
  140. }
  141. </script>
  142. <style scoped lang="scss"></style>