index.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. <template>
  2. <div class="__cus-manage_content">
  3. <div class="__cus-manage_content-title"><SvgIcon class="flag" name="flag_1" color="var(--cus-main-color)"/>{{$route.meta.title}}</div>
  4. <div class="__cus-manage_content-filters">
  5. <CusForm labelWidth="100px" @handleEnter="onSearch">
  6. <CusFormColumn
  7. :span="8"
  8. v-model:param="state.query.form.keyword"
  9. placeholder="请输入索引中文名称或索引表名进行搜索"
  10. />
  11. <CusButton type="main" title="搜索" @click="onSearch"/>
  12. <CusButton type="main" title="重置" @click="onReset"/>
  13. <CusButton title="导出" style="margin-left: auto" @click="onExport"/>
  14. <CusButton type="main" title="新增" @click="onAdd"/>
  15. </CusForm>
  16. </div>
  17. <div class="__cus-manage_content-main" v-loading="state.query.loading">
  18. <CusTable
  19. :page-num="state.query.page.pageNum"
  20. :page-size="state.query.page.pageSize"
  21. :total="state.query.result.total"
  22. :data="state.query.result.data"
  23. :table-head="state.query.tableHead"
  24. @handlePage="onPage"
  25. >
  26. <template #shareMethod-column-value="{scope}">
  27. {{DictionaryStore.gxMethodMap.get(scope.row.shareMethod)}}
  28. </template>
  29. <template #shareCycle-column-value="{scope}">
  30. {{DictionaryStore.gxCycleMap.get(scope.row.shareCycle)}}
  31. </template>
  32. <template #themeMode-column-value="{scope}">
  33. {{DictionaryStore.themeModeMap.get(scope.row.themeMode)}}
  34. </template>
  35. <template #do-column-value="{scope}">
  36. <CusButton type="table" icon="relation" title="关联分类" @click="onRelation(scope.row)"/>
  37. <CusButton type="table-add" icon="text" title="字段" @click="onText(scope.row)"/>
  38. <CusButton type="table-edit" @click="onEdit(scope.row)"/>
  39. <CusButton type="table-del" @click="onDel(scope.row)"/>
  40. </template>
  41. </CusTable>
  42. </div>
  43. <DetailCom v-model:show="state.detail.show" :transfer="state.detail.transfer" @refresh="onSearch"/>
  44. <RelationCom v-model:show="state.relation.show" :transfer="state.relation.transfer" @refresh="onSearch"/>
  45. <TextCom v-model:show="state.text.show" :transfer="state.text.transfer"/>
  46. </div>
  47. </template>
  48. <script setup lang="ts">
  49. import {getCurrentInstance, onMounted, reactive} from "vue";
  50. import {ElMessage, ElMessageBox} from "element-plus";
  51. import {
  52. sysIndexDeleteIndexById,
  53. sysIndexExport,
  54. sysIndexFieldDeleteById,
  55. sysIndexFindIndexByPage
  56. } from "@/api/modules/manage";
  57. import DetailCom from "./detail.vue";
  58. import RelationCom from "./relation.vue";
  59. import TextCom from "./text.vue";
  60. import {useDictionaryStore} from "@/stores";
  61. import {downLoadBlob} from "@/utils/downLoadUrl";
  62. const {proxy} = getCurrentInstance()
  63. const DictionaryStore = useDictionaryStore()
  64. const state: any = reactive({
  65. query: {
  66. loading: false,
  67. page: {
  68. pageNum: 1,
  69. pageSize: 10
  70. },
  71. tableHead: [
  72. {value: "indexName", label: "索引中文", fixed: 'left', width: 180},
  73. {value: "indexTableName", label: "索引表名", fixed: 'left', width: 180, popover: true},
  74. {value: "dataSource", label: "数据共享来源", width: 180},
  75. {value: "dataOffer", label: "数据提供来源", width: 180},
  76. {value: "shareMethod", label: "共享方式", width: 180},
  77. {value: "shareCycle", label: "共享周期", width: 180},
  78. {value: "pictureField", label: "图片字段", width: 180},
  79. {value: "themeMode", label: "主题模式", width: 180},
  80. {value: "pictureModeCardNum", label: "图模式卡片数", width: 180},
  81. {value: "cardColumnNum", label: "卡片列数", width: 180},
  82. {value: "columnModelNum", label: "列模式列数", width: 180},
  83. {value: "num", label: "数据量", width: 180},
  84. {value: "linkTypeNum", label: "关联分类数量", width: 180},
  85. {value: "createTime", label: "创建时间", width: 200},
  86. {value: "updateTime", label: "最后修改时间", width: 200},
  87. {value: "remark", label: "备注", width: 200},
  88. {value: "do", label: "操作", width: 320, fixed: 'right'},
  89. ],
  90. form: {},
  91. formReal: {},
  92. result: {
  93. total: 0,
  94. data: []
  95. }
  96. },
  97. detail: {
  98. show: false,
  99. transfer: {}
  100. },
  101. relation: {
  102. show: false,
  103. transfer: {}
  104. },
  105. text: {
  106. show: false,
  107. transfer: {}
  108. }
  109. })
  110. const onPage = (pageNum, pageSize) => {
  111. state.query.page = {
  112. pageNum: pageNum,
  113. pageSize: pageSize
  114. }
  115. const params = {
  116. page: state.query.page.pageNum,
  117. size: state.query.page.pageSize,
  118. }
  119. // 添加表单参数
  120. for (const [k, v] of Object.entries(state.query.formReal)) {
  121. if (proxy.$util.isValue(v)) {
  122. params[k] = v
  123. }
  124. }
  125. state.query.loading = true
  126. sysIndexFindIndexByPage(proxy.$util.formatGetParam(params)).then(res => {
  127. if (res.code === 200) {
  128. state.query.result.total = res.data.totalElements
  129. state.query.result.data = res.data.content
  130. state.query.loading = false
  131. } else {
  132. ElMessage.error(res.msg)
  133. }
  134. })
  135. }
  136. const onSearch = () => {
  137. state.query.formReal = JSON.parse(JSON.stringify(state.query.form))
  138. onPage(1, state.query.page.pageSize)
  139. }
  140. const onReset = () => {
  141. state.query.page = {
  142. pageNum: 1,
  143. pageSize: 10
  144. }
  145. state.query.form = {}
  146. onSearch()
  147. }
  148. const onRelation = (row) => {
  149. state.relation.transfer = {
  150. id: row.id
  151. }
  152. state.relation.show = true
  153. }
  154. const onText = (row) => {
  155. state.text.transfer = {
  156. id: row.id,
  157. maxCol: row.columnModelNum < row.cardColumnNum ? row.columnModelNum : row.cardColumnNum,
  158. }
  159. state.text.show = true
  160. }
  161. const onAdd = () => {
  162. state.detail.transfer = {
  163. mode: 'add'
  164. }
  165. state.detail.show = true
  166. }
  167. const onEdit = (row) => {
  168. state.detail.transfer = {
  169. mode: 'edit',
  170. id: row.id,
  171. }
  172. state.detail.show = true
  173. }
  174. const onDel = (row) => {
  175. ElMessageBox.confirm(`请确认是否删除${row.indexName}?`, "提示", {
  176. confirmButtonText: "确定",
  177. cancelButtonText: "取消",
  178. type: "warning",
  179. } as any).then(() => {
  180. state.query.loading = true
  181. sysIndexDeleteIndexById(row.id).then(res => {
  182. if (res.code === 200) {
  183. ElMessage.success('删除成功!')
  184. state.query.loading = false
  185. onSearch()
  186. } else {
  187. ElMessage.error(res.msg)
  188. }
  189. })
  190. }).catch(() => {})
  191. }
  192. const onExport = () => {
  193. state.query.loading = true
  194. const params = {}
  195. // 添加表单参数
  196. for (const [k, v] of Object.entries(state.query.formReal)) {
  197. if (proxy.$util.isValue(v)) {
  198. params[k] = v
  199. }
  200. }
  201. sysIndexExport(proxy.$util.formatGetParam(params)).then(res => {
  202. downLoadBlob(res.data, '索引导出.xlsx')
  203. state.query.loading = false
  204. })
  205. }
  206. const initDictionary = () => {
  207. DictionaryStore.initDict('gx_method')
  208. DictionaryStore.initDict('gx_cycle')
  209. DictionaryStore.initDict('theme_mode')
  210. DictionaryStore.initDict('default_model')
  211. }
  212. onMounted(() => {
  213. initDictionary()
  214. onReset()
  215. })
  216. </script>
  217. <style lang="scss" scoped>
  218. </style>