index.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. f<template>
  2. <ele-page flex-table>
  3. <universities-search @search="reload" />
  4. <common-table ref="pageRef" :pageConfig="pageConfig" :columns="columns">
  5. <template #toolbar>
  6. <el-button
  7. type="primary"
  8. plain
  9. :icon="PlusOutlined"
  10. v-permission="'data:universities:add'"
  11. @click="handleUpdate()"
  12. >
  13. 新增高校
  14. </el-button>
  15. <el-button
  16. type="danger"
  17. plain
  18. :icon="DeleteOutlined"
  19. v-permission="'data:universities:batchDelete'"
  20. @click="handleBatchDelete()"
  21. >
  22. 批量删除
  23. </el-button>
  24. <el-button
  25. type="success"
  26. plain
  27. v-permission="'data:universities:export'"
  28. @click="handleExportExcel"
  29. :icon="DownloadOutlined"
  30. >
  31. 导出EXCEL
  32. </el-button>
  33. </template>
  34. <template #schoolTag="{ row }">
  35. <dict-data
  36. code="school_tag"
  37. type="tag"
  38. :model-value="row.schoolTag"
  39. />
  40. </template>
  41. <template #action="{ row }">
  42. <div>
  43. <el-button
  44. type="primary"
  45. link
  46. v-permission="'data:universities:update'"
  47. @click="handleUpdate(row)"
  48. >
  49. 编辑
  50. </el-button>
  51. <el-button
  52. type="danger"
  53. link
  54. v-permission="'data:universities:delete'"
  55. @click="handleBatchDelete(row)"
  56. >
  57. 删除
  58. </el-button>
  59. <el-button
  60. type="warning"
  61. link
  62. v-permission="'data:universities:schoolTag'"
  63. @click="handleSchoolTag(row)"
  64. >
  65. {{ row.schoolTag == 2 ? '标为正常' : '标为盗版' }}
  66. </el-button>
  67. </div>
  68. </template>
  69. </common-table>
  70. <universities-edit ref="editRef" @success="reload()" />
  71. </ele-page>
  72. </template>
  73. <script setup>
  74. import { ref, reactive } from 'vue';
  75. import { ElMessageBox } from 'element-plus/es';
  76. import { EleMessage } from 'ele-admin-plus/es';
  77. import {
  78. PlusOutlined,
  79. DeleteOutlined,
  80. DownloadOutlined
  81. } from '@/components/icons';
  82. import CommonTable from '@/components/CommonPage/CommonTable.vue';
  83. import universitiesEdit from '@/views/data/universities/components/universities-edit.vue';
  84. import universitiesSearch from '@/views/data/universities/components/universities-search.vue';
  85. import { useDictData } from '@/utils/use-dict-data';
  86. import { useRouter } from 'vue-router';
  87. import request from '@/utils/request';
  88. defineOptions({ name: 'Universities' });
  89. const [schoolLevelDicts, schoolTagDicts] = useDictData([
  90. 'school_level',
  91. 'school_tag'
  92. ]);
  93. /** 表格列配置 */
  94. const columns = ref([
  95. {
  96. type: 'selection',
  97. columnKey: 'selection',
  98. width: 50,
  99. align: 'center',
  100. fixed: 'left'
  101. },
  102. {
  103. label: '学校名称',
  104. prop: 'schoolName',
  105. align: 'center',
  106. minWidth: 140
  107. },
  108. { label: '省份', prop: 'provinceName', align: 'center' },
  109. { label: '所在市', prop: 'cityName', align: 'center' },
  110. { label: '主管部门', prop: 'departmentName', align: 'center' },
  111. {
  112. label: '办学层次',
  113. prop: 'schoolLevel',
  114. align: 'center',
  115. formatter: (row) =>
  116. schoolLevelDicts.value.find(
  117. (d) => d.dictValue == row.schoolLevel
  118. )?.dictLabel
  119. },
  120. {
  121. label: '标记',
  122. prop: 'schoolTag',
  123. align: 'center',
  124. slot: 'schoolTag',
  125. formatter: (row) =>
  126. schoolTagDicts.value.find((d) => d.dictValue == row.schoolTag)
  127. ?.dictLabel
  128. },
  129. {
  130. columnKey: 'action',
  131. label: '操作',
  132. width: 240,
  133. align: 'center',
  134. slot: 'action'
  135. }
  136. ]);
  137. let router = useRouter();
  138. /** 页面组件实例 */
  139. const pageRef = ref(null);
  140. const pageConfig = reactive({
  141. pageUrl: '/baseinfo/schoolInfo/list',
  142. exportUrl: '/baseinfo/schoolInfo/export',
  143. fileName: '高校列表',
  144. cacheKey: 'universitiesTable'
  145. });
  146. //刷新表格
  147. function reload(where) {
  148. pageRef.value?.reload(where);
  149. }
  150. //批量删除
  151. function handleBatchDelete(row) {
  152. let selections = row ? [row] : pageRef.value?.getSelections();
  153. let ids = selections.map((item) => item.id).join(',');
  154. let url = `/baseinfo/schoolInfo/removeById/${ids}`;
  155. pageRef.value?.operatBatch({
  156. title: '确认删除?',
  157. method: 'post',
  158. url,
  159. row
  160. });
  161. }
  162. //导出excel
  163. function handleExportExcel() {
  164. pageRef.value?.exportData('高校列表');
  165. }
  166. //申请恢复订单
  167. function handleSchoolTag(row) {
  168. let message = row.schoolTag == 1 ? '确认标为盗版?' : '确认标为正常?';
  169. let data = JSON.parse(JSON.stringify(row));
  170. data.schoolTag = row.schoolTag == 1 ? 2 : 1;
  171. pageRef.value?.messageBoxConfirm({
  172. message,
  173. fetch: () => request.post('/baseinfo/schoolInfo/edit', data)
  174. });
  175. }
  176. //编辑页面
  177. const editRef = ref(null);
  178. function handleUpdate(row) {
  179. editRef.value?.handleOpen(row);
  180. }
  181. </script>