equityList.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. <template>
  2. <BasicTable @register="registerTable">
  3. <template #toolbar>
  4. <a-button type="primary" @click="exportExcel" v-if="getCheckPerm('rights-order-export')"> 导出</a-button>
  5. </template>
  6. <template #bodyCell="{ column, record }">
  7. <template v-if="column.key === 'action'">
  8. <TableAction
  9. stopButtonPropagation
  10. :actions="[
  11. {
  12. label: '删除',
  13. icon: 'ic:outline-delete-outline',
  14. onClick: handleDelete.bind(null, record),
  15. },
  16. ]"
  17. :dropDownActions="[
  18. {
  19. label: '启用',
  20. popConfirm: {
  21. title: '是否启用?',
  22. confirm: handleOpen.bind(null, record),
  23. },
  24. },
  25. ]"
  26. />
  27. </template>
  28. </template>
  29. </BasicTable>
  30. </template>
  31. <script lang="ts">
  32. import { defineComponent, h, ref } from 'vue';
  33. import { BasicTable, useTable, TableAction, BasicColumn, TableImg, FormProps } from '/@/components/Table';
  34. import { PageWrapper } from '/@/components/Page';
  35. import { Time } from '/@/components/Time';
  36. import { Descriptions } from 'ant-design-vue';
  37. import { useI18n } from '/@/hooks/web/useI18n';
  38. import { useMessage } from '/@/hooks/web/useMessage';
  39. import { downloadByData, } from '/@/utils/file/download';
  40. import { IncrementList,IncrementExport } from '/@/api/order'
  41. import { usePermissionStore } from '/@/store/modules/permission';
  42. export default defineComponent({
  43. components: {
  44. BasicTable,
  45. TableAction,
  46. PageWrapper,
  47. TableImg,
  48. [Descriptions.name]: Descriptions,
  49. [Descriptions.Item.name]: Descriptions.Item,
  50. },
  51. setup() {
  52. const { t } = useI18n();
  53. const isSearch = ref(false)
  54. const { createMessage,createConfirm } = useMessage();
  55. const permissionStore = usePermissionStore();
  56. const { getCheckPerm } = permissionStore;
  57. const columns: BasicColumn[] = [
  58. {
  59. title: '下单时间',
  60. dataIndex: 'createTime',
  61. width: 150,
  62. customRender: ({ record }) => {
  63. return (
  64. record.createTime &&
  65. h(Time, {
  66. value: record.createTime,
  67. mode: 'datetime',
  68. })
  69. );
  70. },
  71. },
  72. {
  73. title: '订单号',
  74. dataIndex: 'orderSn',
  75. ellipsis: false,
  76. width: 180,
  77. },
  78. {
  79. title: '用户账号',
  80. dataIndex: 'userName',
  81. width: 100,
  82. },
  83. {
  84. title: '数量',
  85. dataIndex: 'count',
  86. width: 80,
  87. },
  88. {
  89. title: '交易号',
  90. dataIndex: 'number',
  91. width: 180,
  92. },
  93. {
  94. title: '订单金额',
  95. dataIndex: 'amount',
  96. width: 80,
  97. },
  98. {
  99. title: '支付方式',
  100. dataIndex: 'payType',
  101. // slots: { customRender: 'orderType' },
  102. width: 80,
  103. },
  104. {
  105. title: '订单状态',
  106. dataIndex: 'payStatus',
  107. // slots: { customRender: 'orderStatus' },
  108. width: 80,
  109. },
  110. ];
  111. const searchForm: Partial<FormProps> = {
  112. labelWidth: 100,
  113. autoSubmitOnEnter:true,
  114. autoAdvancedLine:1,
  115. actionColOptions: {
  116. span: 24,
  117. },
  118. schemas: [
  119. {
  120. field: 'ctivated',
  121. label: '下单时间',
  122. component: 'RangePicker',
  123. componentProps: {
  124. maxLength: 100,
  125. format: 'YYYY-MM-DD',
  126. valueFormat:'YYYY-MM-DD',
  127. },
  128. colProps: {
  129. xl: 7,
  130. xxl: 7,
  131. },
  132. },{
  133. field: 'orderSn',
  134. label: '订单号',
  135. component: 'Input',
  136. componentProps: {
  137. maxLength: 100,
  138. },
  139. colProps: {
  140. xl: 7,
  141. xxl: 7,
  142. },
  143. },{
  144. field: 'userName',
  145. label: '用户账号',
  146. component: 'Input',
  147. componentProps: {
  148. maxLength: 100,
  149. },
  150. colProps: {
  151. xl: 7,
  152. xxl: 7,
  153. },
  154. },{
  155. field: 'tradeNum',
  156. label: '交易号',
  157. component: 'Input',
  158. componentProps: {
  159. maxLength: 100,
  160. },
  161. colProps: {
  162. xl: 7,
  163. xxl: 7,
  164. },
  165. },
  166. ],
  167. };
  168. const [registerTable] = useTable({
  169. api: IncrementList,
  170. title: '权益列表',
  171. // titleHelpMessage: ['已启用expandRowByClick', '已启用stopButtonPropagation'],
  172. columns: columns,
  173. useSearchForm: true,
  174. showIndexColumn:false,
  175. formConfig: searchForm,
  176. showTableSetting: true,
  177. rowKey: 'id',
  178. beforeFetch:(T)=>{
  179. const {ctivated,tradeNum,userName,orderSn} = T
  180. if(ctivated||tradeNum||userName||orderSn){
  181. isSearch.value = true
  182. }else{
  183. isSearch.value = false
  184. }
  185. if(T.ctivated){
  186. T.startTime = T.ctivated[0]
  187. T.endTime = T.ctivated[1]
  188. }
  189. console.log('beforeFetch',T)
  190. return T
  191. },
  192. fetchSetting: {
  193. pageField: 'pageNum',
  194. sizeField: 'pageSize',
  195. listField: 'list',
  196. totalField: 'total',
  197. },
  198. canResize: true,
  199. });
  200. function handleDelete(record: Recordable) {
  201. console.log('点击了删除', record);
  202. }
  203. function handleOpen(record: Recordable) {
  204. console.log('点击了启用', record);
  205. }
  206. function exportExcel() {
  207. createConfirm({
  208. iconType: 'warning',
  209. title: () => h('span', '温馨提示'),
  210. content: () => h('span', isSearch.value?'确认导出搜索结果?':'确认导出全部?'),
  211. onOk: async () => {
  212. IncrementExport()
  213. },
  214. });
  215. }
  216. return {
  217. registerTable,
  218. handleDelete,
  219. handleOpen,
  220. exportExcel,
  221. getCheckPerm,
  222. };
  223. },
  224. });
  225. </script>