index.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. <template>
  2. <div class="snapshot-invite-code-list-container layout-padding">
  3. <div class="layout-padding-auto layout-padding-view pd20">
  4. <vxe-grid v-bind="gridOptions" ref="gridRef" @checkbox-all="selectAllChangeEvent" @checkbox-change="selectChangeEvent">
  5. <template #toolbar_buttons>
  6. <el-button type="primary" @click="onAdd" v-auth="'snapshot:inviteCode:list:add'">
  7. <SvgIcon name="ele-Plus" class="mr5" />新增邀请码
  8. </el-button>
  9. <el-button type="danger" @click="onDelete" v-auth="'snapshot:inviteCode:list:delete'" :disabled="isChecked" :loading="state.loading">
  10. <SvgIcon name="ele-Delete" class="mr5" />删除<span v-if="checkTable.length">({{ checkTable.length }})</span>
  11. </el-button>
  12. <el-button type="primary" @click="onExport" v-auth="'snapshot:inviteCode:list:export'">
  13. <SvgIcon name="iconfont icon-daochu" class="mr5" />导出邀请码
  14. </el-button>
  15. <el-button type="primary" @click="onCreate" v-auth="'snapshot:inviteCode:list:create'">
  16. <SvgIcon name="iconfont icon-daochu" class="mr5" />批量生成
  17. </el-button>
  18. </template>
  19. <template #qrCodeUrl="{ row }">
  20. <el-image
  21. style="width: 40px; height: 40px"
  22. :src="'https://fuss10.elemecdn.com/a/3f/3302e58f9a181d2509f3dc0fa68b0jpeg.jpeg'"
  23. :preview-src-list="['https://fuss10.elemecdn.com/a/3f/3302e58f9a181d2509f3dc0fa68b0jpeg.jpeg']"
  24. fit="cover"
  25. />
  26. </template>
  27. <template #action="{ row }">
  28. <el-button link type="primary" @click="onEdit(row)" v-auth="'snapshot:inviteCode:list:edit'" title="编辑"> 编辑 </el-button>
  29. <el-button link type="primary" @click="download(row)" v-auth="'snapshot:inviteCode:list:download'" title="编辑人员"> 下载 </el-button>
  30. </template>
  31. <template #pager>
  32. <pagination
  33. @pagination="queryList"
  34. :total="state.total"
  35. v-model:current-page="state.queryParams.PageIndex"
  36. v-model:page-size="state.queryParams.PageSize"
  37. :disabled="state.loading"
  38. />
  39. </template>
  40. </vxe-grid>
  41. </div>
  42. <!-- 新增 -->
  43. <code-add ref="codeAddRef" @updateList="queryList" />
  44. <!-- 编辑 -->
  45. <code-edit ref="codeEditRef" @updateList="queryList" />
  46. <!-- 导出邀请码 -->
  47. <export-code ref="exportCodeRef" />
  48. </div>
  49. </template>
  50. <script lang="tsx" setup name="snapshotInviteCodeList">
  51. import { computed, defineAsyncComponent, onMounted, reactive, ref } from 'vue';
  52. import { ElMessage, ElMessageBox } from 'element-plus';
  53. import { getInviteCodeList } from '@/api/snapshot/inviteCode';
  54. // 引入组件
  55. const pagination = defineAsyncComponent(() => import('@/components/ProTable/components/Pagination.vue')); // 分页
  56. const CodeAdd = defineAsyncComponent(() => import('@/views/snapshot/inviteCode/list/components/Code-add.vue')); // 新增
  57. const CodeEdit = defineAsyncComponent(() => import('@/views/snapshot/inviteCode/list/components/Code-edit.vue')); // 编辑
  58. const ExportCode = defineAsyncComponent(() => import('@/views/snapshot/inviteCode/list/components/Export-code.vue'));
  59. // 定义变量内容
  60. const state = reactive<any>({
  61. loading: false,
  62. queryParams: {
  63. // 查询参数
  64. PageIndex: 1,
  65. PageSize: 20,
  66. CaseName: null, // 线索名称
  67. IndustryName: null, // 行业类型
  68. },
  69. total: 0, // 总条数
  70. });
  71. const gridOptions = reactive<any>({
  72. loading: false,
  73. border: true,
  74. showOverflow: true,
  75. columnConfig: {
  76. resizable: true,
  77. },
  78. scrollY: {
  79. enabled: true,
  80. gt: 100,
  81. },
  82. toolbarConfig: {
  83. zoom: true,
  84. custom: true,
  85. refresh: {
  86. queryMethod: () => {
  87. handleQuery();
  88. },
  89. },
  90. slots: {
  91. buttons: 'toolbar_buttons',
  92. },
  93. },
  94. customConfig: {
  95. storage: true,
  96. },
  97. id: 'snapshotInviteCodeList',
  98. rowConfig: { isHover: true, height: 50, isCurrent: true, useKey: true },
  99. height: 'auto',
  100. columns: [
  101. { type: 'checkbox', width: 50, align: 'center' },
  102. {
  103. field: 'orgName',
  104. title: '部门名称',
  105. minWidth: 200,
  106. },
  107. {
  108. field: 'beginCode',
  109. title: '邀请码',
  110. },
  111. {
  112. field: 'endCode',
  113. title: '邀请码2',
  114. },
  115. {
  116. field: 'qrCodeUrl',
  117. title: '邀请码地址',
  118. slots: { default: 'qrCodeUrl' },
  119. },
  120. { title: '操作', width: 120, fixed: 'right', align: 'center', slots: { default: 'action' } },
  121. ],
  122. data: [],
  123. });
  124. /** 搜索按钮操作 节流操作 */
  125. const handleQuery = () => {
  126. state.queryParams.PageIndex = 1;
  127. queryList();
  128. };
  129. // 获取参数列表
  130. const queryList = () => {
  131. state.loading = true;
  132. gridOptions.loading = true;
  133. getInviteCodeList(state.queryParams)
  134. .then((res) => {
  135. state.loading = false;
  136. gridOptions.data = res.result.items ?? [];
  137. state.total = res.result.total ?? 0;
  138. gridOptions.loading = false;
  139. })
  140. .finally(() => {
  141. state.loading = false;
  142. gridOptions.loading = false;
  143. });
  144. };
  145. // 新增
  146. const codeAddRef = ref<RefType>();
  147. const onAdd = () => {
  148. codeAddRef.value.openDialog();
  149. };
  150. // 编辑
  151. const codeEditRef = ref<RefType>();
  152. const onEdit = (row: any) => {
  153. codeEditRef.value.openDialog(row.id);
  154. };
  155. // 下载
  156. const download = (row: any) => {};
  157. const checkTable = ref<EmptyArrayType>([]);
  158. const gridRef = ref<RefType>();
  159. const selectAllChangeEvent = ({ checked }) => {
  160. if (gridRef.value) {
  161. const records = gridRef.value.getCheckboxRecords();
  162. checkTable.value = records;
  163. console.log(checked ? '所有勾选事件' : '所有取消事件', records);
  164. }
  165. };
  166. const selectChangeEvent = ({ checked }) => {
  167. if (gridRef.value) {
  168. const records = gridRef.value.getCheckboxRecords();
  169. checkTable.value = records;
  170. console.log(checked ? '勾选事件' : '取消事件', records);
  171. }
  172. };
  173. const isChecked = computed(() => {
  174. return !Boolean(checkTable.value.length);
  175. });
  176. // 删除
  177. const onDelete = () => {};
  178. // 导出邀请码
  179. const exportCodeRef = ref<RefType>();
  180. const onExport = () => {
  181. exportCodeRef.value.openDialog();
  182. };
  183. // 批量生成
  184. const onCreate = () => {
  185. ElMessageBox.confirm(`您确定要批量生成邀请码,是否继续?`, '提示', {
  186. confirmButtonText: '确认',
  187. cancelButtonText: '取消',
  188. type: 'warning',
  189. draggable: true,
  190. cancelButtonClass: 'default-button',
  191. autofocus: false,
  192. })
  193. .then(() => {
  194. queryList();
  195. })
  196. .catch(() => {});
  197. };
  198. // 页面加载时
  199. onMounted(() => {
  200. queryList();
  201. });
  202. </script>