index.vue 7.3 KB

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