Introducing new features. 标签的编辑和删除

This commit is contained in:
aeizzz 2023-03-03 10:00:22 +08:00
parent 392b44264b
commit 83730dec1c
2 changed files with 37 additions and 17 deletions

View File

@ -23,7 +23,7 @@
// / // /
const emit = defineEmits(['refresh']); const emit = defineEmits(['refresh']);
import {useMessage} from "/@/hooks/message"; import {useMessage} from "/@/hooks/message";
import {addObj} from '/@/api/mp/wx-account-tag' import {addObj,putObj} from '/@/api/mp/wx-account-tag'
import {useI18n} from "vue-i18n" import {useI18n} from "vue-i18n"
const {t} = useI18n(); const {t} = useI18n();
@ -38,20 +38,25 @@ const loading = ref(false)
const form = reactive({ const form = reactive({
wxAccountAppid: '', wxAccountAppid: '',
tag: '', tag: '',
id: ''
}); });
// //
const dataRules = ref({}) const dataRules = ref({})
// //
const openDialog = (id: string) => { const openDialog = (row: any,appid: string) => {
visible.value = true visible.value = true
form.wxAccountAppid = id
// //
if (dataFormRef.value) { if (dataFormRef.value) {
dataFormRef.value.resetFields() dataFormRef.value.resetFields()
} }
if(row){
Object.assign(form,row)
}
form.wxAccountAppid = appid
}; };
// //
@ -61,15 +66,27 @@ const onSubmit = () => {
return false return false
} }
loading.value = true loading.value = true
addObj(form).then(() => { if(form.id){
useMessage().success(t('common.addSuccessText')) putObj(form).then(() => {
visible.value = false // useMessage().success(t('common.editSuccessText'))
emit('refresh') visible.value = false //
}).catch((err: any) => { emit('refresh')
useMessage().error(err.msg) }).catch((err: any) => {
}).finally(() => { useMessage().error(err.msg)
loading.value = false }).finally(() => {
}) loading.value = false
})
}else{
addObj(form).then(() => {
useMessage().success(t('common.addSuccessText'))
visible.value = false //
emit('refresh')
}).catch((err: any) => {
useMessage().error(err.msg)
}).finally(() => {
loading.value = false
})
}
}) })
} }

View File

@ -23,7 +23,7 @@
<el-row> <el-row>
<div class="mb8" style="width: 100%"> <div class="mb8" style="width: 100%">
<el-button v-auth="'mp_wx_account_tag_add'" class="ml10" formDialogRef icon="folder-add" type="primary" <el-button v-auth="'mp_wx_account_tag_add'" class="ml10" formDialogRef icon="folder-add" type="primary"
@click="formDialogRef.openDialog(state.queryForm.wxAccountAppid)"> @click="formDialogRef.openDialog(null,state.queryForm.wxAccountAppid)">
{{ $t('common.addBtn') }} {{ $t('common.addBtn') }}
</el-button> </el-button>
<el-button v-auth="'mp_wx_account_tag_export'" class="ml10" formDialogRef icon="Download" type="primary" <el-button v-auth="'mp_wx_account_tag_export'" class="ml10" formDialogRef icon="Download" type="primary"
@ -49,8 +49,8 @@
<el-table-column :label="t('wxAccountTag.tagId')" prop="tagId" show-overflow-tooltip/> <el-table-column :label="t('wxAccountTag.tagId')" prop="tagId" show-overflow-tooltip/>
<el-table-column :label="$t('common.action')" width="150"> <el-table-column :label="$t('common.action')" width="150">
<template #default="scope"> <template #default="scope">
<el-button text type="primary" @click="formDialogRef.openDialog(scope.row.id)">{{ $t('common.editBtn') }}</el-button> <el-button text type="primary" @click="formDialogRef.openDialog(scope.row,state.queryForm.wxAccountAppid)">{{ $t('common.editBtn') }}</el-button>
<el-button text type="primary" @click="handleDelete([scope.row.id])">{{$t('common.delBtn') }}</el-button> <el-button text type="primary" @click="handleDelete(scope.row)">{{$t('common.delBtn') }}</el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
@ -141,10 +141,13 @@ const handleSelectionChange = (objs: any) => {
} }
// //
const handleDelete = (ids: string[]) => { const handleDelete = (row: any) => {
useMessageBox().confirm(t('common.delConfirmText')) useMessageBox().confirm(t('common.delConfirmText'))
.then(() => { .then(() => {
delObjs(ids).then(() => { delObjs({
id: row.id,
wxAccountAppid: row.wxAccountAppid
}).then(() => {
getDataList(false); getDataList(false);
useMessage().success(t('common.delSuccessText')); useMessage().success(t('common.delSuccessText'));
}).catch((err: any) => { }).catch((err: any) => {