|
|
@@ -87,6 +87,7 @@
|
|
|
|
|
|
<script>
|
|
|
import { listAllCompanies } from '@/api/workflow/lobster-admin'
|
|
|
+import request from '@/utils/request'
|
|
|
|
|
|
export default {
|
|
|
name: 'SensitiveWords',
|
|
|
@@ -103,15 +104,47 @@ export default {
|
|
|
created() { this.loadCompanies(); this.getList() },
|
|
|
methods: {
|
|
|
async loadCompanies() { try { const res = await listAllCompanies(); this.companyOptions = (res.data || []).map(c => ({ value: c.companyId, label: c.companyName || '未知' })) } catch (e) {} },
|
|
|
- getList() { this.loading = true; /* API: /workflow/lobster/sensitive-words/list */ this.loading = false },
|
|
|
+ async getList() {
|
|
|
+ this.loading = true
|
|
|
+ try {
|
|
|
+ const res = await request({ url: '/workflow/lobster/sensitive-words/list', method: 'get', params: this.queryParams })
|
|
|
+ this.list = (res.data || [])
|
|
|
+ this.total = this.list.length
|
|
|
+ } catch (e) { this.list = []
|
|
|
+ } finally { this.loading = false }
|
|
|
+ },
|
|
|
handleQuery() { this.queryParams.pageNum = 1; this.getList() },
|
|
|
resetQuery() { this.$refs.queryForm.resetFields(); this.handleQuery() },
|
|
|
handleSelectionChange(selection) { this.selectedIds = selection.map(s => s.id) },
|
|
|
- handleAdd() { this.isAdd = true; this.dialogTitle = '新增敏感词'; this.form = { companyId: null, word: '', category: '', severity: 1, remark: '' }; this.dialogVisible = true },
|
|
|
+ handleAdd() { this.isAdd = true; this.dialogTitle = '新增敏感词'; this.form = { companyId: this.queryParams.companyId, word: '', category: '', severity: 1, remark: '', enabled: 1 }; this.dialogVisible = true },
|
|
|
handleEdit(row) { this.isAdd = false; this.dialogTitle = '修改敏感词'; this.form = { ...row }; this.dialogVisible = true },
|
|
|
- submitForm() { this.$refs.formRef.validate(v => { if (!v) return; this.$message.success(this.isAdd ? '新增成功' : '修改成功'); this.dialogVisible = false; this.getList() }) },
|
|
|
- handleDelete(row) { this.$confirm('确认删除?', '警告', { type: 'warning' }).then(() => { this.$message.success('删除成功'); this.getList() }).catch(() => {}) },
|
|
|
- handleBatchDelete() { if (!this.selectedIds.length) return; this.$confirm('确认批量删除?', '警告', { type: 'warning' }).then(() => { this.$message.success('批量删除成功'); this.getList() }).catch(() => {}) }
|
|
|
+ async submitForm() {
|
|
|
+ this.$refs.formRef.validate(async v => {
|
|
|
+ if (!v) return
|
|
|
+ try {
|
|
|
+ await request({ url: '/workflow/lobster/sensitive-words/save', method: 'post', data: this.form })
|
|
|
+ this.$message.success(this.isAdd ? '新增成功' : '修改成功')
|
|
|
+ this.dialogVisible = false; this.getList()
|
|
|
+ } catch (e) { this.$message.error('保存失败') }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ async handleDelete(row) {
|
|
|
+ try {
|
|
|
+ await this.$confirm('确认删除?', '警告', { type: 'warning' })
|
|
|
+ await request({ url: `/workflow/lobster/sensitive-words/${row.id}`, method: 'delete', params: { companyId: row.companyId } })
|
|
|
+ this.$message.success('删除成功'); this.getList()
|
|
|
+ } catch (e) { if (e !== 'cancel') this.$message.error('删除失败') }
|
|
|
+ },
|
|
|
+ async handleBatchDelete() {
|
|
|
+ if (!this.selectedIds.length) return
|
|
|
+ try {
|
|
|
+ await this.$confirm(`确认批量删除 ${this.selectedIds.length} 条?`, '警告', { type: 'warning' })
|
|
|
+ for (const id of this.selectedIds) {
|
|
|
+ await request({ url: `/workflow/lobster/sensitive-words/${id}`, method: 'delete', params: { companyId: this.queryParams.companyId } })
|
|
|
+ }
|
|
|
+ this.$message.success('批量删除成功'); this.getList()
|
|
|
+ } catch (e) { if (e !== 'cancel') this.$message.error('批量删除失败') }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
</script>
|