|
@@ -0,0 +1,207 @@
|
|
|
|
+<template>
|
|
|
|
+ <div class="__cus-manage_content">
|
|
|
|
+ <div class="__cus-manage_content-title"><SvgIcon class="flag" name="flag_1" color="var(--cus-main-color)"/>{{$route.meta.title}}</div>
|
|
|
|
+ <div class="__cus-manage_content-filters">
|
|
|
|
+ <CusForm labelWidth="100px" @handleEnter="onSearch">
|
|
|
|
+ <CusFormColumn
|
|
|
|
+ :span="4"
|
|
|
|
+ label="同义词名称"
|
|
|
|
+ v-model:param="state.query.form.swName"
|
|
|
|
+ />
|
|
|
|
+ <CusFormColumn
|
|
|
|
+ :span="4"
|
|
|
|
+ label="状态"
|
|
|
|
+ v-model:param="state.query.form.swStatus"
|
|
|
|
+ link="select"
|
|
|
|
+ :options="DictionaryStore.synonymStatusList"
|
|
|
|
+ />
|
|
|
|
+ <CusButton type="main" title="搜索" @click="onSearch"/>
|
|
|
|
+ <CusButton type="main" title="重置" @click="onReset"/>
|
|
|
|
+ <CusButton type="main" title="新增" style="margin-left: auto" @click="onAdd"/>
|
|
|
|
+ <CusButton type="main" title="索引同步" @click="onIndex"/>
|
|
|
|
+ </CusForm>
|
|
|
|
+ </div>
|
|
|
|
+ <div class="__cus-manage_content-main" v-loading="state.query.loading">
|
|
|
|
+ <CusTable
|
|
|
|
+ :page-num="state.query.page.pageNum"
|
|
|
|
+ :page-size="state.query.page.pageSize"
|
|
|
|
+ :total="state.query.result.total"
|
|
|
|
+ :data="state.query.result.data"
|
|
|
|
+ :table-head="state.query.tableHead"
|
|
|
|
+ @handlePage="onPage"
|
|
|
|
+ >
|
|
|
|
+ <template #swStatus-column-value="{scope}">
|
|
|
|
+ {{DictionaryStore.synonymStatusMap.get(String(scope.row.swStatus))}}
|
|
|
|
+ </template>
|
|
|
|
+ <template #do-column-value="{scope}">
|
|
|
|
+ <CusButton v-if="scope.row.swStatus == 0" type="table" title="启用" icon="enabled" @click="onStart(scope.row)"/>
|
|
|
|
+ <CusButton v-if="scope.row.swStatus == 1" type="table-del" title="停用" icon="disabled" @click="onStop(scope.row)"/>
|
|
|
|
+ <CusButton v-if="scope.row.swStatus == 0" type="table-edit" @click="onEdit(scope.row)"/>
|
|
|
|
+ <CusButton v-if="scope.row.swStatus == 0" type="table-del" @click="onDel(scope.row)"/>
|
|
|
|
+ </template>
|
|
|
|
+ </CusTable>
|
|
|
|
+ </div>
|
|
|
|
+ <DetailCom v-model:show="state.detail.show" :transfer="state.detail.transfer" @refresh="onSearch"/>
|
|
|
|
+ <IndexCom v-model:show="state.indexDetail.show" :transfer="state.indexDetail.transfer"/>
|
|
|
|
+ </div>
|
|
|
|
+</template>
|
|
|
|
+
|
|
|
|
+<script setup lang="ts">
|
|
|
|
+import {getCurrentInstance, onMounted, reactive} from "vue";
|
|
|
|
+import {ElMessage, ElMessageBox} from "element-plus";
|
|
|
|
+import DetailCom from "./detail.vue";
|
|
|
|
+import IndexCom from "../entry/index-list.vue";
|
|
|
|
+import {useDictionaryStore} from "@/stores";
|
|
|
|
+import {synonymDelete, synonymQuerySynonymWordByPage, synonymStart, synonymStop} from "@/api/modules/manage/synonym";
|
|
|
|
+
|
|
|
|
+const {proxy} = getCurrentInstance()
|
|
|
|
+const DictionaryStore = useDictionaryStore()
|
|
|
|
+const state: any = reactive({
|
|
|
|
+ query: {
|
|
|
|
+ loading: false,
|
|
|
|
+ page: {
|
|
|
|
+ pageNum: 1,
|
|
|
|
+ pageSize: 10
|
|
|
|
+ },
|
|
|
|
+ tableHead: [
|
|
|
|
+ {value: "swName", label: "同义词名称", minWidth: 400},
|
|
|
|
+ {value: "swStatus", label: "状态"},
|
|
|
|
+ {value: "createTime", label: "创建时间", width: 200},
|
|
|
|
+ {value: "createUser", label: "创建人"},
|
|
|
|
+ {value: "updateTime", label: "最后修改时间", width: 200},
|
|
|
|
+ {value: "updateUser", label: "最后修改人"},
|
|
|
|
+ {value: "do", label: "操作", width: 260, fixed: 'right'},
|
|
|
|
+ ],
|
|
|
|
+ form: {},
|
|
|
|
+ formReal: {},
|
|
|
|
+ result: {
|
|
|
|
+ total: 0,
|
|
|
|
+ data: []
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ detail: {
|
|
|
|
+ show: false,
|
|
|
|
+ transfer: {}
|
|
|
|
+ },
|
|
|
|
+ indexDetail: {
|
|
|
|
+ show: false,
|
|
|
|
+ transfer: {}
|
|
|
|
+ },
|
|
|
|
+})
|
|
|
|
+const onPage = (pageNum, pageSize) => {
|
|
|
|
+ state.query.page = {
|
|
|
|
+ pageNum: pageNum,
|
|
|
|
+ pageSize: pageSize
|
|
|
|
+ }
|
|
|
|
+ const params = {
|
|
|
|
+ pageNum: state.query.page.pageNum,
|
|
|
|
+ pageSize: state.query.page.pageSize,
|
|
|
|
+ }
|
|
|
|
+ // 添加表单参数
|
|
|
|
+ for (const [k, v] of Object.entries(state.query.formReal)) {
|
|
|
|
+ if (proxy.$util.isValue(v)) {
|
|
|
|
+ params[k] = v
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ state.query.loading = true
|
|
|
|
+ synonymQuerySynonymWordByPage(params).then(res => {
|
|
|
|
+ state.query.result.total = res.data.records
|
|
|
|
+ state.query.result.data = res.data.datas
|
|
|
|
+ state.query.loading = false
|
|
|
|
+ })
|
|
|
|
+}
|
|
|
|
+const onSearch = () => {
|
|
|
|
+ state.query.formReal = JSON.parse(JSON.stringify(state.query.form))
|
|
|
|
+ onPage(1, state.query.page.pageSize)
|
|
|
|
+}
|
|
|
|
+const onReset = () => {
|
|
|
|
+ state.query.page = {
|
|
|
|
+ pageNum: 1,
|
|
|
|
+ pageSize: 10
|
|
|
|
+ }
|
|
|
|
+ state.query.form = {}
|
|
|
|
+ onSearch()
|
|
|
|
+}
|
|
|
|
+const onAdd = () => {
|
|
|
|
+ state.detail.transfer = {
|
|
|
|
+ mode: 'add'
|
|
|
|
+ }
|
|
|
|
+ state.detail.show = true
|
|
|
|
+}
|
|
|
|
+const onEdit = (row) => {
|
|
|
|
+ state.detail.transfer = {
|
|
|
|
+ mode: 'edit',
|
|
|
|
+ id: row.swId
|
|
|
|
+ }
|
|
|
|
+ state.detail.show = true
|
|
|
|
+}
|
|
|
|
+const onIndex = () => {
|
|
|
|
+ state.indexDetail.transfer = {
|
|
|
|
+ type: 1, // 队列类型:0-词,1-结构
|
|
|
|
+ }
|
|
|
|
+ state.indexDetail.show = true
|
|
|
|
+}
|
|
|
|
+const onDel = (row) => {
|
|
|
|
+ let str = row.swName + ''
|
|
|
|
+ if (str.length > 20) {
|
|
|
|
+ str = str.slice(0, 20) + '......'
|
|
|
|
+ }
|
|
|
|
+ ElMessageBox.confirm(`请确认是否删除${str}?`, "提示", {
|
|
|
|
+ confirmButtonText: "确定",
|
|
|
|
+ cancelButtonText: "取消",
|
|
|
|
+ type: "warning",
|
|
|
|
+ } as any).then(() => {
|
|
|
|
+ state.loading = true
|
|
|
|
+ synonymDelete(row.id).then(res => {
|
|
|
|
+ ElMessage.success('删除成功!')
|
|
|
|
+ onSearch()
|
|
|
|
+ })
|
|
|
|
+ }).catch(() => {})
|
|
|
|
+}
|
|
|
|
+const onStart = (row) => {
|
|
|
|
+ let str = row.swName + ''
|
|
|
|
+ if (str.length > 20) {
|
|
|
|
+ str = str.slice(0, 20) + '......'
|
|
|
|
+ }
|
|
|
|
+ ElMessageBox.confirm(`请确认是否启用${str}?<br/><span style="color: #FF5454;">启用后仅对新数据生效,如需同步历史数据,请手动进行索引同步!</span>`, "提示", {
|
|
|
|
+ dangerouslyUseHTMLString: true,
|
|
|
|
+ confirmButtonText: "确定",
|
|
|
|
+ cancelButtonText: "取消",
|
|
|
|
+ type: "warning",
|
|
|
|
+ } as any).then(() => {
|
|
|
|
+ state.loading = true
|
|
|
|
+ synonymStart(row.id).then(res => {
|
|
|
|
+ ElMessage.success('启用成功!')
|
|
|
|
+ onSearch()
|
|
|
|
+ })
|
|
|
|
+ }).catch(() => {})
|
|
|
|
+}
|
|
|
|
+const onStop = (row) => {
|
|
|
|
+ let str = row.swName + ''
|
|
|
|
+ if (str.length > 20) {
|
|
|
|
+ str = str.slice(0, 20) + '......'
|
|
|
|
+ }
|
|
|
|
+ ElMessageBox.confirm(`请确认是否停用${str}?<br/><span style="color: #FF5454;">停用后将自动同步历史数据!</span>`, "提示", {
|
|
|
|
+ dangerouslyUseHTMLString: true,
|
|
|
|
+ confirmButtonText: "确定",
|
|
|
|
+ cancelButtonText: "取消",
|
|
|
|
+ type: "warning",
|
|
|
|
+ } as any).then(() => {
|
|
|
|
+ state.loading = true
|
|
|
|
+ synonymStop(row.id).then(res => {
|
|
|
|
+ ElMessage.success('启用成功!')
|
|
|
|
+ onSearch()
|
|
|
|
+ })
|
|
|
|
+ }).catch(() => {})
|
|
|
|
+}
|
|
|
|
+const initDictionary = () => {
|
|
|
|
+ DictionaryStore.initDict('synonym_status')
|
|
|
|
+}
|
|
|
|
+onMounted(() => {
|
|
|
|
+ initDictionary()
|
|
|
|
+ onReset()
|
|
|
|
+})
|
|
|
|
+</script>
|
|
|
|
+
|
|
|
|
+<style lang="scss" scoped>
|
|
|
|
+</style>
|