123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207 |
- <template>
- <div class="snapshot-invite-code-list-container layout-padding">
- <div class="layout-padding-auto layout-padding-view pd20">
- <vxe-grid v-bind="gridOptions" ref="gridRef" @checkbox-all="selectAllChangeEvent" @checkbox-change="selectChangeEvent">
- <template #toolbar_buttons>
- <el-button type="primary" @click="onAdd" v-auth="'snapshot:inviteCode:list:add'">
- <SvgIcon name="ele-Plus" class="mr5" />新增邀请码
- </el-button>
- <el-button type="danger" @click="onDelete" v-auth="'snapshot:inviteCode:list:delete'" :disabled="isChecked" :loading="state.loading">
- <SvgIcon name="ele-Delete" class="mr5" />删除<span v-if="checkTable.length">({{ checkTable.length }})</span>
- </el-button>
- <el-button type="primary" @click="onExport" v-auth="'snapshot:inviteCode:list:export'">
- <SvgIcon name="iconfont icon-daochu" class="mr5" />导出邀请码
- </el-button>
- <el-button type="primary" @click="onCreate" v-auth="'snapshot:inviteCode:list:create'">
- <SvgIcon name="iconfont icon-daochu" class="mr5" />批量生成
- </el-button>
- </template>
- <template #qrCodeUrl="{ row }">
- <el-image
- style="width: 40px; height: 40px"
- :src="'https://fuss10.elemecdn.com/a/3f/3302e58f9a181d2509f3dc0fa68b0jpeg.jpeg'"
- :preview-src-list="['https://fuss10.elemecdn.com/a/3f/3302e58f9a181d2509f3dc0fa68b0jpeg.jpeg']"
- fit="cover"
- />
- </template>
- <template #action="{ row }">
- <el-button link type="primary" @click="onEdit(row)" v-auth="'snapshot:inviteCode:list:edit'" title="编辑"> 编辑 </el-button>
- <el-button link type="primary" @click="download(row)" v-auth="'snapshot:inviteCode:list:download'" title="编辑人员"> 下载 </el-button>
- </template>
- <template #pager>
- <pagination
- @pagination="queryList"
- :total="state.total"
- v-model:current-page="state.queryParams.PageIndex"
- v-model:page-size="state.queryParams.PageSize"
- :disabled="state.loading"
- />
- </template>
- </vxe-grid>
- </div>
- <!-- 新增 -->
- <code-add ref="codeAddRef" @updateList="queryList" />
- <!-- 编辑 -->
- <code-edit ref="codeEditRef" @updateList="queryList" />
- <!-- 导出邀请码 -->
- <export-code ref="exportCodeRef" />
- </div>
- </template>
- <script lang="tsx" setup name="snapshotInviteCodeList">
- import { computed, defineAsyncComponent, onMounted, reactive, ref } from 'vue';
- import { ElMessage, ElMessageBox } from 'element-plus';
- import { getInviteCodeList } from '@/api/snapshot/inviteCode';
- // 引入组件
- const pagination = defineAsyncComponent(() => import('@/components/ProTable/components/Pagination.vue')); // 分页
- const CodeAdd = defineAsyncComponent(() => import('@/views/snapshot/inviteCode/list/components/Code-add.vue')); // 新增
- const CodeEdit = defineAsyncComponent(() => import('@/views/snapshot/inviteCode/list/components/Code-edit.vue')); // 编辑
- const ExportCode = defineAsyncComponent(() => import('@/views/snapshot/inviteCode/list/components/Export-code.vue'));
- // 定义变量内容
- const state = reactive<any>({
- loading: false,
- queryParams: {
- // 查询参数
- PageIndex: 1,
- PageSize: 20,
- CaseName: null, // 线索名称
- IndustryName: null, // 行业类型
- },
- total: 0, // 总条数
- });
- const gridOptions = reactive<any>({
- loading: false,
- border: true,
- showOverflow: true,
- columnConfig: {
- resizable: true,
- },
- scrollY: {
- enabled: true,
- gt: 100,
- },
- toolbarConfig: {
- zoom: true,
- custom: true,
- refresh: {
- queryMethod: () => {
- handleQuery();
- },
- },
- slots: {
- buttons: 'toolbar_buttons',
- },
- },
- customConfig: {
- storage: true,
- },
- id: 'snapshotInviteCodeList',
- rowConfig: { isHover: true, height: 50, isCurrent: true, useKey: true },
- height: 'auto',
- columns: [
- { type: 'checkbox', width: 50, align: 'center' },
- {
- field: 'orgName',
- title: '部门名称',
- minWidth: 200,
- },
- {
- field: 'beginCode',
- title: '邀请码',
- },
- {
- field: 'endCode',
- title: '邀请码2',
- },
- {
- field: 'qrCodeUrl',
- title: '邀请码地址',
- slots: { default: 'qrCodeUrl' },
- },
- { title: '操作', width: 120, fixed: 'right', align: 'center', slots: { default: 'action' } },
- ],
- data: [],
- });
- /** 搜索按钮操作 节流操作 */
- const handleQuery = () => {
- state.queryParams.PageIndex = 1;
- queryList();
- };
- // 获取参数列表
- const queryList = () => {
- state.loading = true;
- gridOptions.loading = true;
- getInviteCodeList(state.queryParams)
- .then((res) => {
- state.loading = false;
- gridOptions.data = res.result.items ?? [];
- state.total = res.result.total ?? 0;
- gridOptions.loading = false;
- })
- .finally(() => {
- state.loading = false;
- gridOptions.loading = false;
- });
- };
- // 新增
- const codeAddRef = ref<RefType>();
- const onAdd = () => {
- codeAddRef.value.openDialog();
- };
- // 编辑
- const codeEditRef = ref<RefType>();
- const onEdit = (row: any) => {
- codeEditRef.value.openDialog(row.id);
- };
- // 下载
- const download = (row: any) => {};
- const checkTable = ref<EmptyArrayType>([]);
- const gridRef = ref<RefType>();
- const selectAllChangeEvent = ({ checked }) => {
- if (gridRef.value) {
- const records = gridRef.value.getCheckboxRecords();
- checkTable.value = records;
- console.log(checked ? '所有勾选事件' : '所有取消事件', records);
- }
- };
- const selectChangeEvent = ({ checked }) => {
- if (gridRef.value) {
- const records = gridRef.value.getCheckboxRecords();
- checkTable.value = records;
- console.log(checked ? '勾选事件' : '取消事件', records);
- }
- };
- const isChecked = computed(() => {
- return !Boolean(checkTable.value.length);
- });
- // 删除
- const onDelete = () => {};
- // 导出邀请码
- const exportCodeRef = ref<RefType>();
- const onExport = () => {
- exportCodeRef.value.openDialog();
- };
- // 批量生成
- const onCreate = () => {
- ElMessageBox.confirm(`您确定要批量生成邀请码,是否继续?`, '提示', {
- confirmButtonText: '确认',
- cancelButtonText: '取消',
- type: 'warning',
- draggable: true,
- cancelButtonClass: 'default-button',
- autofocus: false,
- })
- .then(() => {
- queryList();
- })
- .catch(() => {});
- };
- // 页面加载时
- onMounted(() => {
- queryList();
- });
- </script>
|