| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302 |
- <style scoped lang="scss">
- .system-container {
- :deep(.el-card__body) {
- display: flex;
- flex-direction: column;
- justify-content: space-between;
- flex: 1;
- overflow: auto;
- .el-table {
- flex: 1;
- }
- }
- }
- .page-content {
- margin-bottom: 20px;
- }
- .page-pager {
- background-color: #fff;
- height: 24px;
- }
- </style>
- <template>
- <div class="system-container layout-padding">
- <el-card shadow="hover" class="layout-padding-auto">
- <el-form
- :model="state.formQuery"
- ref="queryRef"
- size="default" label-width="0px" class="mt5 mb5">
- <el-input
- v-model="state.formQuery.activityName"
- placeholder="活动名称"
- clearable
- @blur="loadData(true)"
- class="wd150 mr10">
- </el-input>
- <el-input
- v-model="state.formQuery.couponName"
- placeholder="优惠券名称"
- clearable
- @blur="loadData(true)"
- class="wd150 mr10">
- </el-input>
- <el-input
- v-model="state.formQuery.userName"
- placeholder="用户名称"
- clearable
- @blur="loadData(true)"
- class="wd150 mr10">
- </el-input>
- <el-input
- v-model="state.formQuery.mobilePhone"
- placeholder="手机号"
- clearable
- @blur="loadData(true)"
- class="wd150 mr10">
- </el-input>
- <ext-d-select
- v-model="state.formQuery.couponType"
- placeholder="券种"
- type="Activity.couponType"
- clearable
- @blur="loadData(true)"
- class="wd150 mr10">
- </ext-d-select>
- <ext-d-select
- placeholder="用户状态"
- v-model="state.formQuery.status"
- type="User.status"
- clearable
- @blur="loadData(true)"
- class="wd150 mr10">
- </ext-d-select>
- <ext-d-select
- placeholder="使用状态"
- v-model="state.formQuery.usageStatus"
- type="UserCoupon.usage"
- clearable
- @blur="loadData(true)"
- class="wd150 mr10">
- </ext-d-select>
- <el-button class="ml10" plain size="default" type="success" @click="loadData(true)">
- <SvgIcon name="ele-Search"/>
- 查询
- </el-button>
- </el-form>
- <el-table
- border
- stripe="stripe"
- :height="state.tableData.height"
- highlight-current-row
- current-row-key="id"
- row-key="id"
- :data="state.tableData.data"
- v-loading="state.tableData.loading"
- @row-dblclick="onRowClick('view',$event)"
- @selection-change="handleTableSelectionChange"
- @sort-change="handleTableSortChange">
- <template #empty>
- <el-empty></el-empty>
- </template>
- <el-table-column
- v-for="field in state.tableData.columns"
- :key="field.prop"
- :label="field.label"
- :column-key="field.prop"
- :width="field.width"
- :min-width="field.minWidth"
- :fixed="field.fixed"
- :sortable="field.sortable"
- :show-overflow-tooltip="!field.fixed&&field.width>150"
- >
- <template #default="{row}">
- <template v-if="field.prop==='expand'">
- <p style="padding-left: 2em;" v-html="row[field.prop]"></p>
- </template>
- <template v-else-if="field.prop==='period'">
- {{ row.startTime }} ~ {{ row.endTime }}
- </template>
- <template v-else-if="field.prop==='couponType'">
- <ext-d-label type="Activity.couponType" v-model="row[field.prop]"></ext-d-label>
- </template>
- <template v-else-if="field.prop==='status'">
- <ext-d-label type="User.status" v-model="row[field.prop]"></ext-d-label>
- </template>
- <template v-else-if="field.prop==='usageStatus'">
- <ext-d-label type="UserCoupon.usageStatus" v-model="row[field.prop]"></ext-d-label>
- </template>
- <template v-else-if="field.prop==='allowStacke'">
- <ext-d-label type="Activity.allowStacke" v-model="row[field.prop]"></ext-d-label>
- </template>
- <template v-else-if="field.prop==='action'">
- <!-- <el-button size="small" plain type="danger" @click="onRowTerminal(row)">终止</el-button>-->
- </template>
- <template v-else>
- <div>{{ row[field.prop] }}</div>
- </template>
- </template>
- </el-table-column>
- </el-table>
- <ext-page class="page-pager" v-model:value="state.pageQuery" @change="loadData(false)"/>
- </el-card>
- </div>
- <ActivityDialog ref="activityDialogRef" @refresh="loadData(true)"/>
- </template>
- <script setup lang="ts" name="ActivityList">
- import {defineAsyncComponent, reactive, onMounted, onBeforeMount, ref, getCurrentInstance, nextTick, onBeforeUnmount} from 'vue';
- import {$body, $get} from "/@/utils/request";
- import {Msg} from "/@/utils/message";
- import ExtPage from '/@/components/form/ExtPage.vue'
- import mittBus from '/@/utils/mitt';
- import ExtDSelect from "/@/components/form/ExtDSelect.vue";
- import ExtDLabel from "/@/components/form/ExtDLabel.vue";
- const ActivityDialog = defineAsyncComponent(() => import("/@/views/admin/activity/dialog.vue"));
- //定义引用
- const queryRef = ref();
- const activityDialogRef = ref();
- //定义变量
- const state = reactive({
- formQuery: {},
- pageQuery: {
- pageNum: 1,
- pageSize: 10,
- total: 0
- },
- tableData: {
- height: 500,
- data: [] as Array<any>,
- loading: false,
- columns: [
- {
- label: '活动名称', prop: 'activityName', resizable: true, width: 170, fixed: 'left'
- },
- {label: '活动时间', prop: 'period', resizable: true, width: 350},
- {label: '优惠券名称', prop: 'couponName', align: 'center', width: 230},
- {label: '用户名', prop: 'userName', resizable: true, width: 130},
- {label: '手机号', prop: 'mobilePhone', resizable: true, width: 130},
- {label: '有效期', prop: 'validity', resizable: true, width: 130},
- {label: '用户状态', prop: 'status', resizable: true, width: 130},
- {label: '使用状态', prop: 'usageStatus', resizable: true, width: 130},
- {label: '优惠允许叠加', prop: 'allowStacke', resizable: true, width: 130},
- {label: '创建时间', prop: 'createTime', resizable: true, width: 180},
- {label: '更新时间', prop: 'updateTime', resizable: true, width: 180},
- /* {
- label: '操作', prop: 'action', width: 180, align: 'center', fixed: 'right',
- }*/
- ],
- },
- })
- // 监听双向绑定 modelValue 的变化
- // watch(
- // () => state.pageIndex,
- // () => {
- //
- // }
- // );
- //生命周期钩子
- onBeforeMount(() => {
- })
- onMounted(() => {
- loadData();
- nextTick(() => {
- let bodyHeight = document.body.clientHeight;
- let queryHeight = queryRef.value.$el.clientHeight;
- state.tableData.height = bodyHeight - queryHeight - 320
- })
- mittBus.on("activity.refresh", () => {
- loadData();
- })
- });
- onBeforeUnmount(() => {
- mittBus.off("activity.refresh")
- })
- //region 方法区
- // 初始化表格数据
- const loadData = (refresh: boolean = false) => {
- if (refresh) {
- state.pageQuery.pageNum = 1;
- }
- state.tableData.loading = true;
- $get(`/coupon/listUserCoupons`, {...state.formQuery, ...state.pageQuery}).then((res: any) => {
- let {list, total} = res;
- state.tableData.data = list;
- state.pageQuery.total = total;
- state.tableData.loading = false;
- }).catch(e => {
- console.error(e)
- state.tableData.loading = false;
- })
- };
- // 打开修改用户弹窗
- const handleRowClick = (event) => {
- console.log(event)
- activityDialogRef.value.open("view", event);
- };
- // 打开修改用户弹窗
- const onRowClick = (type: string, row: any) => {
- activityDialogRef.value.open(type, row);
- };
- // 删除用户
- const onRowTerminal = (row: any) => {
- Msg.confirm(`此操作将终止:『${row.name}』,是否继续?`).then(() => {
- $get(`/activity/terminateActivity/${row.id}`).then(() => {
- Msg.message("终止成功", 'success')
- loadData(true)
- }).catch(() => {
- Msg.message("终止失败", 'error')
- })
- });
- };
- const handleTableSelectionChange = (selection: any) => {
- console.log("handleTableSelectionChange>>", selection)
- // emit("on-check-change", selection)
- }
- const handleTableSortChange = (column, prop, order) => {
- console.log("handleTableSortChange>>", column, prop, order)
- // emit("on-sort-change", column)
- }
- //endregion
- // 暴露变量
- // defineExpose({
- // loadData,
- // });
- </script>
|