123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226 |
- <template>
- <BasicTable @register="registerTable">
- <template #toolbar>
- <a-button type="primary" @click="exportExcel" v-if="getCheckPerm('rights-order-export')"> 导出</a-button>
- </template>
- <template #bodyCell="{ column, record }">
- <template v-if="column.key === 'action'">
- <TableAction
- stopButtonPropagation
- :actions="[
- {
- label: '删除',
- icon: 'ic:outline-delete-outline',
- onClick: handleDelete.bind(null, record),
- },
- ]"
- :dropDownActions="[
- {
- label: '启用',
- popConfirm: {
- title: '是否启用?',
- confirm: handleOpen.bind(null, record),
- },
- },
- ]"
- />
- </template>
- </template>
- </BasicTable>
- </template>
- <script lang="ts">
- import { defineComponent, h, ref } from 'vue';
- import { BasicTable, useTable, TableAction, BasicColumn, TableImg, FormProps } from '/@/components/Table';
- import { PageWrapper } from '/@/components/Page';
- import { Time } from '/@/components/Time';
- import { Descriptions } from 'ant-design-vue';
- import { useI18n } from '/@/hooks/web/useI18n';
- import { useMessage } from '/@/hooks/web/useMessage';
- import { downloadByData, } from '/@/utils/file/download';
- import { IncrementList,IncrementExport } from '/@/api/order'
- import { usePermissionStore } from '/@/store/modules/permission';
- export default defineComponent({
- components: {
- BasicTable,
- TableAction,
- PageWrapper,
- TableImg,
- [Descriptions.name]: Descriptions,
- [Descriptions.Item.name]: Descriptions.Item,
- },
- setup() {
- const { t } = useI18n();
- const isSearch = ref(false)
- const { createMessage,createConfirm } = useMessage();
- const permissionStore = usePermissionStore();
- const { getCheckPerm } = permissionStore;
- const columns: BasicColumn[] = [
- {
- title: '下单时间',
- dataIndex: 'createTime',
- width: 150,
- customRender: ({ record }) => {
- return (
- record.createTime &&
- h(Time, {
- value: record.createTime,
- mode: 'datetime',
- })
- );
- },
- },
- {
- title: '订单号',
- dataIndex: 'orderSn',
- ellipsis: false,
- width: 180,
- },
- {
- title: '用户账号',
- dataIndex: 'userName',
- width: 100,
- },
- {
- title: '数量',
- dataIndex: 'count',
- width: 80,
- },
- {
- title: '交易号',
- dataIndex: 'number',
- width: 180,
- },
- {
- title: '订单金额',
- dataIndex: 'amount',
- width: 80,
- },
- {
- title: '支付方式',
- dataIndex: 'payType',
- // slots: { customRender: 'orderType' },
- width: 80,
- },
- {
- title: '订单状态',
- dataIndex: 'payStatus',
- // slots: { customRender: 'orderStatus' },
- width: 80,
- },
- ];
- const searchForm: Partial<FormProps> = {
- labelWidth: 100,
- autoSubmitOnEnter:true,
- autoAdvancedLine:1,
- actionColOptions: {
- span: 24,
- },
- schemas: [
- {
- field: 'ctivated',
- label: '下单时间',
- component: 'RangePicker',
- componentProps: {
- maxLength: 100,
- format: 'YYYY-MM-DD',
- valueFormat:'YYYY-MM-DD',
- },
- colProps: {
- xl: 7,
- xxl: 7,
- },
- },{
- field: 'orderSn',
- label: '订单号',
- component: 'Input',
- componentProps: {
- maxLength: 100,
- },
- colProps: {
- xl: 7,
- xxl: 7,
- },
- },{
- field: 'userName',
- label: '用户账号',
- component: 'Input',
- componentProps: {
- maxLength: 100,
- },
- colProps: {
- xl: 7,
- xxl: 7,
- },
- },{
- field: 'tradeNum',
- label: '交易号',
- component: 'Input',
- componentProps: {
- maxLength: 100,
- },
- colProps: {
- xl: 7,
- xxl: 7,
- },
- },
- ],
- };
- const [registerTable] = useTable({
- api: IncrementList,
- title: '权益列表',
- // titleHelpMessage: ['已启用expandRowByClick', '已启用stopButtonPropagation'],
- columns: columns,
- useSearchForm: true,
- showIndexColumn:false,
- formConfig: searchForm,
- showTableSetting: true,
- rowKey: 'id',
- beforeFetch:(T)=>{
- const {ctivated,tradeNum,userName,orderSn} = T
- if(ctivated||tradeNum||userName||orderSn){
- isSearch.value = true
- }else{
- isSearch.value = false
- }
- if(T.ctivated){
- T.startTime = T.ctivated[0]
- T.endTime = T.ctivated[1]
- }
- console.log('beforeFetch',T)
- return T
- },
- fetchSetting: {
- pageField: 'pageNum',
- sizeField: 'pageSize',
- listField: 'list',
- totalField: 'total',
- },
- canResize: true,
- });
- function handleDelete(record: Recordable) {
- console.log('点击了删除', record);
- }
- function handleOpen(record: Recordable) {
- console.log('点击了启用', record);
- }
- function exportExcel() {
- createConfirm({
- iconType: 'warning',
- title: () => h('span', '温馨提示'),
- content: () => h('span', isSearch.value?'确认导出搜索结果?':'确认导出全部?'),
- onOk: async () => {
- IncrementExport()
- },
- });
- }
- return {
- registerTable,
- handleDelete,
- handleOpen,
- exportExcel,
- getCheckPerm,
- };
- },
- });
- </script>
|