mirror of
https://gitee.com/log4j/pig-ui.git
synced 2024-12-23 05:40:20 +08:00
✨ Introducing new features. 标签的编辑和删除
This commit is contained in:
parent
392b44264b
commit
83730dec1c
@ -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
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -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) => {
|
||||
|
Loading…
Reference in New Issue
Block a user