Browse Source

Merge branch 'main' of http://git.cc-lotus.info/Information/cxyy-admin into main

zs 7 months ago
parent
commit
a68ea16a86

+ 9 - 1
src/store/api/esDict.js

@@ -11,5 +11,13 @@ export const EsDictStore = defineStore('esDict', () => {
     const res = await axios.$post(`${url}`, { data: payload })
     return res
   }
-  return { getDict, updateDict }
+  const getStopDict = async (payload) => {
+    const res = await axios.$get(`${url}/stop`)
+    return res
+  }
+  const updateStopDict = async (payload) => {
+    const res = await axios.$post(`${url}/stop`, { data: payload })
+    return res
+  }
+  return { getDict, updateDict, getStopDict, updateStopDict }
 })

+ 11 - 57
src/views/platform/parts/es-dict.vue

@@ -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>

+ 65 - 0
src/views/platform/parts/es-dict/dict.vue

@@ -0,0 +1,65 @@
+<template>
+  <div id="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="60vh" 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>
+  </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()
+})
+</script>
+<style scoped></style>

+ 65 - 0
src/views/platform/parts/es-dict/stop.vue

@@ -0,0 +1,65 @@
+<template>
+  <div id="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="60vh" 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>
+  </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.getStopDict()
+  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.updateStopDict(updateData)
+  if ($checkRes(result, true, result.errmsg)) {
+    search()
+  }
+}
+onMounted(() => {
+  search()
+})
+</script>
+<style scoped></style>