Vue3 重构:Review 敏感词管理

This commit is contained in:
YunaiV 2023-03-19 21:30:53 +08:00
parent 45058a9a48
commit cf959599c6
2 changed files with 19 additions and 16 deletions

View File

@ -48,6 +48,7 @@
<script setup lang="ts">
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
import * as SensitiveWordApi from '@/api/system/sensitiveWord'
import { CommonStatusEnum } from '@/utils/constants'
const { t } = useI18n() //
const message = useMessage() //
@ -56,11 +57,10 @@ const modelVisible = ref(false) // 弹窗的是否展示
const modelTitle = ref('') //
const formLoading = ref(false) // 12
const formType = ref('') // create - update -
const tags = ref([])
const formData = ref({
id: undefined,
name: '',
status: true,
status: CommonStatusEnum.ENABLE,
description: '',
tags: []
})
@ -69,6 +69,7 @@ const formRules = reactive({
tags: [{ required: true, message: '标签不能为空', trigger: 'blur' }]
})
const formRef = ref() // Ref
const tags = ref([]) // todo @blue-syd openModal
/** 打开弹窗 */
const openModal = async (type: string, id?: number) => {
@ -101,10 +102,10 @@ const submitForm = async () => {
try {
const data = formData.value as unknown as SensitiveWordApi.SensitiveWordVO
if (formType.value === 'create') {
await SensitiveWordApi.createSensitiveWordApi(data)
await SensitiveWordApi.createSensitiveWordApi(data) // TODO @blue-syd API
message.success(t('common.createSuccess'))
} else {
await SensitiveWordApi.updateSensitiveWordApi(data)
await SensitiveWordApi.updateSensitiveWordApi(data) // TODO @blue-syd API
message.success(t('common.updateSuccess'))
}
modelVisible.value = false
@ -120,7 +121,7 @@ const resetForm = () => {
formData.value = {
id: undefined,
name: '',
status: true,
status: CommonStatusEnum.ENABLE,
description: '',
tags: []
}

View File

@ -40,7 +40,6 @@
:default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
/>
</el-form-item>
<el-form-item>
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
@ -82,9 +81,11 @@
:key="index"
v-for="(tag, index) in scope.row.tags"
:index="index"
class="mr-5px"
>
{{ tag }}
</el-tag>
&nbsp; &nbsp;
</template>
</el-table-column>
<el-table-column
@ -132,14 +133,13 @@ import { DICT_TYPE, getDictOptions } from '@/utils/dict'
import { dateFormatter } from '@/utils/formatTime'
import download from '@/utils/download'
import * as SensitiveWordApi from '@/api/system/sensitiveWord'
import ConfigForm from './form.vue'
import ConfigForm from './form.vue' // TODO @blue-syd
const message = useMessage() //
const { t } = useI18n() //
const loading = ref(true) //
const total = ref(0) //
const list = ref([]) //
const tags = ref([])
const queryParams = reactive({
pageNo: 1,
pageSize: 10,
@ -150,12 +150,13 @@ const queryParams = reactive({
})
const queryFormRef = ref() //
const exportLoading = ref(false) //
const tags = ref([])
/** 查询参数列表 */
const getList = async () => {
loading.value = true
try {
const data = await SensitiveWordApi.getSensitiveWordPageApi(queryParams)
const data = await SensitiveWordApi.getSensitiveWordPageApi(queryParams) // TODO @blue-syd API
list.value = data.list
total.value = data.total
} finally {
@ -163,12 +164,6 @@ const getList = async () => {
}
}
/** 初始化标签select*/
const getTags = async () => {
const data = await SensitiveWordApi.getSensitiveWordTagsApi()
tags.value = data
}
/** 搜索按钮操作 */
const handleQuery = () => {
queryParams.pageNo = 1
@ -187,6 +182,8 @@ const openModal = (type: string, id?: number) => {
modalRef.value.openModal(type, id)
}
// TODO @blue-syd http://dashboard.yudao.iocoder.cn/system/sensitive-word
/** 删除按钮操作 */
const handleDelete = async (id: number) => {
try {
@ -207,7 +204,7 @@ const handleExport = async () => {
await message.exportConfirm()
//
exportLoading.value = true
const data = await SensitiveWordApi.exportSensitiveWordApi(queryParams)
const data = await SensitiveWordApi.exportSensitiveWordApi(queryParams) // TODO @blue-syd API
download.excel(data, '敏感词.xls')
} catch {
} finally {
@ -215,6 +212,11 @@ const handleExport = async () => {
}
}
/** 获得 Tag 标签列表 */
const getTags = async () => {
tags.value = await SensitiveWordApi.getSensitiveWordTagsApi() // TODO @blue-syd API
}
/** 初始化 **/
onMounted(() => {
getTags()