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']);
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"
const {t} = useI18n();
@ -38,20 +38,25 @@ const loading = ref(false)
const form = reactive({
wxAccountAppid: '',
tag: '',
id: ''
});
//
const dataRules = ref({})
//
const openDialog = (id: string) => {
const openDialog = (row: any,appid: string) => {
visible.value = true
form.wxAccountAppid = id
//
if (dataFormRef.value) {
dataFormRef.value.resetFields()
}
if(row){
Object.assign(form,row)
}
form.wxAccountAppid = appid
};
//
@ -61,15 +66,27 @@ const onSubmit = () => {
return false
}
loading.value = true
addObj(form).then(() => {
useMessage().success(t('common.addSuccessText'))
visible.value = false //
emit('refresh')
}).catch((err: any) => {
useMessage().error(err.msg)
}).finally(() => {
loading.value = false
})
if(form.id){
putObj(form).then(() => {
useMessage().success(t('common.editSuccessText'))
visible.value = false //
emit('refresh')
}).catch((err: any) => {
useMessage().error(err.msg)
}).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>
<div class="mb8" style="width: 100%">
<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') }}
</el-button>
<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('common.action')" width="150">
<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="handleDelete([scope.row.id])">{{$t('common.delBtn') }}</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)">{{$t('common.delBtn') }}</el-button>
</template>
</el-table-column>
</el-table>
@ -141,10 +141,13 @@ const handleSelectionChange = (objs: any) => {
}
//
const handleDelete = (ids: string[]) => {
const handleDelete = (row: any) => {
useMessageBox().confirm(t('common.delConfirmText'))
.then(() => {
delObjs(ids).then(() => {
delObjs({
id: row.id,
wxAccountAppid: row.wxAccountAppid
}).then(() => {
getDataList(false);
useMessage().success(t('common.delSuccessText'));
}).catch((err: any) => {