index-list.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. <template>
  2. <CusDialog
  3. :show="show"
  4. title="索引列表"
  5. @onClose="$emit('update:show', false)"
  6. width="1000px"
  7. height="80%"
  8. :show-close="false"
  9. :show-submit="false"
  10. >
  11. <div class="__cus-manage_content">
  12. <CusForm labelWidth="100px" @handleEnter="onSearch">
  13. <CusFormColumn
  14. :span="8"
  15. v-model:param="state.query.form.keyword"
  16. placeholder="请输入索引中文名称或索引表名进行搜索"
  17. />
  18. <CusButton style="margin-left: 20px" type="main" title="搜索" @click="onSearch"/>
  19. <CusButton type="main" title="重置" @click="onReset"/>
  20. <CusButton style="margin-left: auto" type="main" title="一键同步" @click="onTaskAll"/>
  21. </CusForm>
  22. <div class="__cus-manage_content-main" v-loading="state.query.loading">
  23. <CusTable
  24. :page-num="state.query.page.pageNum"
  25. :page-size="state.query.page.pageSize"
  26. :total="state.query.result.total"
  27. :data="state.query.result.data"
  28. :table-head="state.query.tableHead"
  29. @handlePage="onPage"
  30. >
  31. <template #do-column-value="{scope}">
  32. <CusButton type="table" icon="relation" title="同步历史数据" @click="onTask(scope.row)"/>
  33. </template>
  34. </CusTable>
  35. </div>
  36. </div>
  37. </CusDialog>
  38. </template>
  39. <script setup lang="ts">
  40. import {computed, getCurrentInstance, nextTick, reactive, ref, watch} from "vue";
  41. import {useDictionaryStore} from "@/stores";
  42. import {ElMessage, ElMessageBox} from "element-plus";
  43. import {sysIndexFindIndexByPage} from "@/api/modules/manage";
  44. import {jobCreate} from "@/api/modules/manage/task";
  45. const emit = defineEmits(['update:show', 'refresh'])
  46. const {proxy} = getCurrentInstance()
  47. const DictionaryStore = useDictionaryStore()
  48. const props = defineProps({
  49. show: {default: false},
  50. transfer: {}
  51. })
  52. const state: any = reactive({
  53. query: {
  54. loading: false,
  55. page: {
  56. pageNum: 1,
  57. pageSize: 20
  58. },
  59. tableHead: [
  60. {value: "indexName", label: "索引中文"},
  61. {value: "indexTableName", label: "索引表名", popover: true},
  62. {value: "do", label: "操作", width: 200, fixed: 'right'},
  63. ],
  64. form: {},
  65. formReal: {},
  66. result: {
  67. total: 0,
  68. data: []
  69. }
  70. },
  71. detail: {
  72. show: false,
  73. transfer: {}
  74. },
  75. })
  76. const onPage = (pageNum, pageSize) => {
  77. state.query.page = {
  78. pageNum: pageNum,
  79. pageSize: pageSize
  80. }
  81. const params = {
  82. page: state.query.page.pageNum,
  83. size: state.query.page.pageSize,
  84. isCreateEsIndex: 1
  85. }
  86. // 添加表单参数
  87. for (const [k, v] of Object.entries(state.query.formReal)) {
  88. if (proxy.$util.isValue(v)) {
  89. params[k] = v
  90. }
  91. }
  92. state.query.loading = true
  93. sysIndexFindIndexByPage(proxy.$util.formatGetParam(params)).then(res => {
  94. state.query.result.total = res.data.totalElements
  95. state.query.result.data = res.data.content
  96. state.query.loading = false
  97. })
  98. }
  99. const onSearch = () => {
  100. state.query.formReal = JSON.parse(JSON.stringify(state.query.form))
  101. onPage(1, state.query.page.pageSize)
  102. }
  103. const onReset = () => {
  104. state.query.page = {
  105. pageNum: 1,
  106. pageSize: 20
  107. }
  108. state.query.form = {}
  109. onSearch()
  110. }
  111. watch(() => props.show, (n) => {
  112. if (n) {
  113. initDictionary()
  114. onReset()
  115. }
  116. })
  117. const onTask = (row) => {
  118. ElMessageBox.confirm(`确定要同步索引${row.indexName}(${row.indexTableName})吗?`, '提示', {
  119. confirmButtonText: '确定',
  120. cancelButtonText: '取消',
  121. type: 'warning'
  122. }).then(() => {
  123. const params = {
  124. type: 0,
  125. name: `${DictionaryStore.taskTypeMap.get(String(0))}_${proxy.$util.YMDHms(new Date())}`,
  126. effect: 1,
  127. indexCode: row.indexTableName,
  128. }
  129. jobCreate(params).then(res => {
  130. ElMessage.success(res.data.respMsg)
  131. })
  132. }).catch(() => {})
  133. }
  134. const onTaskAll = () => {
  135. ElMessageBox.confirm(`确定要同步全部索引吗?`, '提示', {
  136. confirmButtonText: '确定',
  137. cancelButtonText: '取消',
  138. type: 'warning'
  139. }).then(() => {
  140. const params = {
  141. type: props.transfer.type,
  142. name: `${DictionaryStore.taskTypeMap.get(String(props.transfer.type))}_${proxy.$util.YMDHms(new Date())}`,
  143. effect: 1,
  144. indexCode: 'all',
  145. }
  146. jobCreate(params).then(res => {
  147. ElMessage.success(res.data.respMsg)
  148. })
  149. }).catch(() => {})
  150. }
  151. const initDictionary = () => {
  152. DictionaryStore.initDict('task_type')
  153. }
  154. </script>
  155. <style lang="scss" scoped>
  156. .__cus-manage_content {
  157. margin-bottom: 0;
  158. height: calc(100% - 24px);
  159. }
  160. </style>