|
|
@@ -7,12 +7,12 @@
|
|
7
|
7
|
<div class="grid grid-cols-8 gap-4">
|
|
8
|
8
|
<div
|
|
9
|
9
|
|
|
10
|
|
- class="flex flex-col items-center p-4 border rounded-lg hover:bg-gray-50 hover:border-blue-500 shadow-sm relative group h-full">
|
|
|
10
|
+ class="flex flex-col items-center p-4 border rounded-lg hover:bg-gray-50 hover:border-blue-500 shadow-sm relative group h-full"
|
|
|
11
|
+ @click="handleAddCategory">
|
|
11
|
12
|
<span
|
|
12
|
13
|
class="flex flex-col justify-center items-center flex-1 w-full cursor-pointer hover:text-blue-500">
|
|
13
|
14
|
<el-icon class="text-2xl"><Plus /></el-icon>
|
|
14
|
15
|
</span>
|
|
15
|
|
-
|
|
16
|
16
|
</div>
|
|
17
|
17
|
<div
|
|
18
|
18
|
v-for="(item, index) in wordCategories"
|
|
|
@@ -119,7 +119,9 @@
|
|
119
|
119
|
</template>
|
|
120
|
120
|
|
|
121
|
121
|
<script lang="ts" setup name="RuleWord">
|
|
122
|
|
-import { ref } from 'vue'
|
|
|
122
|
+import { onMounted, ref } from 'vue'
|
|
|
123
|
+import { ElMessageBox } from 'element-plus'
|
|
|
124
|
+import { createPageData, getPageListData } from '@/api/main/system/system'
|
|
123
|
125
|
|
|
124
|
126
|
const wordCategories = ref([
|
|
125
|
127
|
{ name: '敏感词', count: 12 },
|
|
|
@@ -188,4 +190,42 @@ const handleDelete = (index: number) => {
|
|
188
|
190
|
const handleEdit = (index: number) => {
|
|
189
|
191
|
console.log('编辑词库:', index)
|
|
190
|
192
|
}
|
|
|
193
|
+
|
|
|
194
|
+const handleAddCategory = async () => {
|
|
|
195
|
+ try {
|
|
|
196
|
+ const { value } = await ElMessageBox.prompt('请输入词库名称', '新建词库', {
|
|
|
197
|
+ confirmButtonText: '确定',
|
|
|
198
|
+ cancelButtonText: '取消',
|
|
|
199
|
+ inputPattern: /^\S+$/,
|
|
|
200
|
+ inputErrorMessage: '词库名称不能为空'
|
|
|
201
|
+ })
|
|
|
202
|
+
|
|
|
203
|
+ if (!value.trim()) return;
|
|
|
204
|
+ const params = {
|
|
|
205
|
+ term: value.trim(),
|
|
|
206
|
+ type: 1,
|
|
|
207
|
+ };
|
|
|
208
|
+
|
|
|
209
|
+ const {state} = await createPageData('/quality/searchLexicon', params);
|
|
|
210
|
+ // 新增数据增加到词库列表第一个里面
|
|
|
211
|
+ if (state === 'success') wordCategories.value = [{ name: value.trim(), count: 0 }, ...wordCategories.value];
|
|
|
212
|
+
|
|
|
213
|
+
|
|
|
214
|
+ } catch (error) {
|
|
|
215
|
+ // 用户取消输入
|
|
|
216
|
+ }
|
|
|
217
|
+}
|
|
|
218
|
+
|
|
|
219
|
+const getList = () => {
|
|
|
220
|
+ getPageListData('/quality/searchLexicon', {page: 1, size: 10000}).then((res) => {
|
|
|
221
|
+ console.log(res);
|
|
|
222
|
+ if (res.state === 'success') {
|
|
|
223
|
+ wordCategories.value = res.data.map((item: any) => ({ name: item.term, count: item.count }));
|
|
|
224
|
+ }
|
|
|
225
|
+ });
|
|
|
226
|
+}
|
|
|
227
|
+
|
|
|
228
|
+onMounted(() => {
|
|
|
229
|
+ getList();
|
|
|
230
|
+})
|
|
191
|
231
|
</script>
|