|
@@ -1,65 +1,19 @@
|
|
|
<template>
|
|
|
<div id="es-dict">
|
|
|
- <el-row justify="space-between" style="margin-bottom:10px">
|
|
|
- <el-col :span="6" style="text-align: left">
|
|
|
- <el-button type="success" @click="toSave">保存</el-button>
|
|
|
- </el-col>
|
|
|
- <el-col :span="6" style="text-align: right">
|
|
|
- <el-button type="primary" @click="toAdd">添加字典</el-button>
|
|
|
- </el-col>
|
|
|
- </el-row>
|
|
|
- <el-row>
|
|
|
- <el-col :span="24">
|
|
|
- <el-table :data="data" height="70vh" border stripe>
|
|
|
- <el-table-column align="center" label="字典项">
|
|
|
- <template #default="{ row }">{{ row }}</template>
|
|
|
- </el-table-column>
|
|
|
- <el-table-column align="center" label="操作" width="150px">
|
|
|
- <template #default="{ $index }">
|
|
|
- <el-button text type="danger" @click="toDelete($index)">删除</el-button>
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
- </el-table>
|
|
|
- </el-col>
|
|
|
- </el-row>
|
|
|
+ <el-tabs v-model="activeName" type="card">
|
|
|
+ <el-tab-pane label="扩展词典" name="dict">
|
|
|
+ <dict></dict>
|
|
|
+ </el-tab-pane>
|
|
|
+ <el-tab-pane label="停用词典" name="stop">
|
|
|
+ <stop-dict></stop-dict>
|
|
|
+ </el-tab-pane>
|
|
|
+ </el-tabs>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
-const $checkRes = inject('$checkRes')
|
|
|
-import { get, cloneDeep } from 'lodash-es'
|
|
|
-import { EsDictStore } from '@/store/api/esDict'
|
|
|
-const store = EsDictStore()
|
|
|
-const data = ref([])
|
|
|
-const search = async () => {
|
|
|
- const result = await store.getDict()
|
|
|
- if ($checkRes(result)) {
|
|
|
- data.value = get(result, 'data', [])
|
|
|
- }
|
|
|
-}
|
|
|
-const toAdd = () =>{
|
|
|
- ElMessageBox.prompt('请填写字典项', '添加字典项', {
|
|
|
- confirmButtonText: '确认',
|
|
|
- cancelButtonText: '取消',
|
|
|
- })
|
|
|
- .then(({ value }) => {
|
|
|
- data.value.push(value)
|
|
|
- })
|
|
|
- .catch(() => {
|
|
|
- })
|
|
|
-}
|
|
|
-const toDelete = (index) => {
|
|
|
- data.value.splice(index, 1)
|
|
|
-}
|
|
|
-const toSave = async () => {
|
|
|
- const updateData = cloneDeep(data.value)
|
|
|
- const result = store.updateDict(updateData)
|
|
|
- if ($checkRes(result, true, result.errmsg)) {
|
|
|
- search()
|
|
|
- }
|
|
|
-}
|
|
|
-onMounted(() => {
|
|
|
- search()
|
|
|
-})
|
|
|
+import dict from './es-dict/dict.vue'
|
|
|
+import stopDict from './es-dict/stop.vue'
|
|
|
+const activeName = ref('dict')
|
|
|
</script>
|
|
|
<style scoped></style>
|