feat: 通知模板页面
This commit is contained in:
parent
cf4314d29c
commit
817226e1d5
|
@ -0,0 +1,201 @@
|
||||||
|
<template>
|
||||||
|
<a-modal
|
||||||
|
v-model:visible="_vis"
|
||||||
|
title="调试"
|
||||||
|
cancelText="取消"
|
||||||
|
okText="确定"
|
||||||
|
@ok="handleOk"
|
||||||
|
@cancel="handleCancel"
|
||||||
|
:confirmLoading="btnLoading"
|
||||||
|
>
|
||||||
|
<a-form layout="vertical">
|
||||||
|
<a-form-item label="通知模版" v-bind="validateInfos.templateId">
|
||||||
|
<a-select
|
||||||
|
v-model:value="formData.templateId"
|
||||||
|
placeholder="请选择通知模版"
|
||||||
|
@change="getTemplateDetail"
|
||||||
|
>
|
||||||
|
<a-select-option
|
||||||
|
v-for="(item, index) in templateList"
|
||||||
|
:key="index"
|
||||||
|
:value="item.id"
|
||||||
|
>
|
||||||
|
{{ item.name }}
|
||||||
|
</a-select-option>
|
||||||
|
</a-select>
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item
|
||||||
|
label="变量"
|
||||||
|
v-bind="validateInfos.variableDefinitions"
|
||||||
|
v-if="templateDetailTable && templateDetailTable.length"
|
||||||
|
>
|
||||||
|
<a-table
|
||||||
|
ref="myTable"
|
||||||
|
class="debug-table"
|
||||||
|
:columns="columns"
|
||||||
|
:data-source="templateDetailTable"
|
||||||
|
:pagination="false"
|
||||||
|
:rowKey="
|
||||||
|
(record, index) => {
|
||||||
|
return record.id;
|
||||||
|
}
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<template #bodyCell="{ column, text, record }">
|
||||||
|
<template
|
||||||
|
v-if="['id', 'name'].includes(column.dataIndex)"
|
||||||
|
>
|
||||||
|
<span>{{ record[column.dataIndex] }}</span>
|
||||||
|
</template>
|
||||||
|
<template v-else>
|
||||||
|
<ValueItem
|
||||||
|
v-model:modelValue="record.value"
|
||||||
|
:itemType="record.type"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</template>
|
||||||
|
</a-table>
|
||||||
|
</a-form-item>
|
||||||
|
</a-form>
|
||||||
|
</a-modal>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { Form } from 'ant-design-vue';
|
||||||
|
import { PropType } from 'vue';
|
||||||
|
import ConfigApi from '@/api/notice/config';
|
||||||
|
import {
|
||||||
|
TemplateFormData,
|
||||||
|
IVariableDefinitions,
|
||||||
|
} from '@/views/notice/Template/types';
|
||||||
|
import { message } from 'ant-design-vue';
|
||||||
|
|
||||||
|
const useForm = Form.useForm;
|
||||||
|
|
||||||
|
type Emits = {
|
||||||
|
(e: 'update:visible', data: boolean): void;
|
||||||
|
};
|
||||||
|
const emit = defineEmits<Emits>();
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
visible: { type: Boolean, default: false },
|
||||||
|
data: {
|
||||||
|
type: Object as PropType<Partial<Record<string, any>>>,
|
||||||
|
default: () => ({}),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const _vis = computed({
|
||||||
|
get: () => props.visible,
|
||||||
|
set: (val) => emit('update:visible', val),
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取通知模板
|
||||||
|
*/
|
||||||
|
const templateList = ref<TemplateFormData[]>([]);
|
||||||
|
const getTemplateList = async () => {
|
||||||
|
const params = {
|
||||||
|
terms: [
|
||||||
|
{ column: 'type', value: props.data.type },
|
||||||
|
{ column: 'provider', value: props.data.provider },
|
||||||
|
],
|
||||||
|
};
|
||||||
|
const { result } = await ConfigApi.getTemplate(params, props.data.id);
|
||||||
|
templateList.value = result;
|
||||||
|
};
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => _vis.value,
|
||||||
|
(val) => {
|
||||||
|
if (val) getTemplateList();
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取模板详情
|
||||||
|
*/
|
||||||
|
const templateDetailTable = ref<IVariableDefinitions[]>();
|
||||||
|
const getTemplateDetail = async () => {
|
||||||
|
const { result } = await ConfigApi.getTemplateDetail(
|
||||||
|
formData.value.templateId,
|
||||||
|
);
|
||||||
|
templateDetailTable.value = result.variableDefinitions.map((m: any) => ({
|
||||||
|
...m,
|
||||||
|
value: undefined,
|
||||||
|
}));
|
||||||
|
};
|
||||||
|
|
||||||
|
const columns = [
|
||||||
|
{
|
||||||
|
title: '变量',
|
||||||
|
dataIndex: 'id',
|
||||||
|
scopedSlots: { customRender: 'id' },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '名称',
|
||||||
|
dataIndex: 'name',
|
||||||
|
scopedSlots: { customRender: 'name' },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '值',
|
||||||
|
dataIndex: 'type',
|
||||||
|
width: 160,
|
||||||
|
scopedSlots: { customRender: 'type' },
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
// 表单数据
|
||||||
|
const formData = ref({
|
||||||
|
templateId: '',
|
||||||
|
variableDefinitions: '',
|
||||||
|
});
|
||||||
|
|
||||||
|
// 验证规则
|
||||||
|
const formRules = ref({
|
||||||
|
templateId: [{ required: true, message: '请选择通知模板' }],
|
||||||
|
variableDefinitions: [{ required: false, message: '该字段是必填字段' }],
|
||||||
|
});
|
||||||
|
|
||||||
|
const { resetFields, validate, validateInfos, clearValidate } = useForm(
|
||||||
|
formData.value,
|
||||||
|
formRules.value,
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 提交
|
||||||
|
*/
|
||||||
|
const btnLoading = ref(false);
|
||||||
|
const handleOk = () => {
|
||||||
|
validate()
|
||||||
|
.then(async () => {
|
||||||
|
const params = {};
|
||||||
|
templateDetailTable.value?.forEach((item) => {
|
||||||
|
params[item.id] = item.value;
|
||||||
|
});
|
||||||
|
// console.log('params: ', params);
|
||||||
|
btnLoading.value = true;
|
||||||
|
ConfigApi.debug(params, props.data.id, formData.value.templateId)
|
||||||
|
.then((res) => {
|
||||||
|
if (res.success) {
|
||||||
|
message.success('操作成功');
|
||||||
|
handleCancel();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
btnLoading.value = false;
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
console.log('err: ', err);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleCancel = () => {
|
||||||
|
_vis.value = false;
|
||||||
|
templateDetailTable.value = [];
|
||||||
|
resetFields();
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="less" scoped></style>
|
|
@ -0,0 +1,156 @@
|
||||||
|
<template>
|
||||||
|
<a-modal v-model:visible="_vis" title="通知记录" :footer="null" width="70%">
|
||||||
|
<Search
|
||||||
|
type="simple"
|
||||||
|
:columns="columns"
|
||||||
|
target="product"
|
||||||
|
@search="handleSearch"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<JTable
|
||||||
|
ref="instanceRef"
|
||||||
|
:columns="columns"
|
||||||
|
:request="(e:any) => configApi.getHistory(e, data.id)"
|
||||||
|
:defaultParams="{
|
||||||
|
sorts: [{ name: 'notifyTime', order: 'desc' }],
|
||||||
|
terms: [{ column: 'notifyType$IN', value: data.type }],
|
||||||
|
}"
|
||||||
|
:params="params"
|
||||||
|
model="table"
|
||||||
|
>
|
||||||
|
<template #notifyTime="slotProps">
|
||||||
|
{{ moment(slotProps.notifyTime).format('YYYY-MM-DD HH:mm:ss') }}
|
||||||
|
</template>
|
||||||
|
<template #state="slotProps">
|
||||||
|
<a-space>
|
||||||
|
<a-badge
|
||||||
|
:status="slotProps.state.value"
|
||||||
|
:text="slotProps.state.text"
|
||||||
|
></a-badge>
|
||||||
|
<AIcon
|
||||||
|
v-if="slotProps.state.value === 'error'"
|
||||||
|
type="ExclamationCircleOutlined"
|
||||||
|
style="color: #1d39c4; cursor: pointer"
|
||||||
|
@click="handleError(slotProps.errorStack)"
|
||||||
|
/>
|
||||||
|
</a-space>
|
||||||
|
</template>
|
||||||
|
<template #action="slotProps">
|
||||||
|
<AIcon
|
||||||
|
type="ExclamationCircleOutlined"
|
||||||
|
style="color: #1d39c4; cursor: pointer"
|
||||||
|
@click="handleDetail(slotProps.context)"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</JTable>
|
||||||
|
</a-modal>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import configApi from '@/api/notice/config';
|
||||||
|
import { PropType } from 'vue';
|
||||||
|
import moment from 'moment';
|
||||||
|
import { Modal } from 'ant-design-vue';
|
||||||
|
|
||||||
|
type Emits = {
|
||||||
|
(e: 'update:visible', data: boolean): void;
|
||||||
|
};
|
||||||
|
const emit = defineEmits<Emits>();
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
visible: { type: Boolean, default: false },
|
||||||
|
data: {
|
||||||
|
type: Object as PropType<Partial<Record<string, any>>>,
|
||||||
|
default: () => ({}),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const _vis = computed({
|
||||||
|
get: () => props.visible,
|
||||||
|
set: (val) => emit('update:visible', val),
|
||||||
|
});
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => _vis.value,
|
||||||
|
(val) => {
|
||||||
|
if (val) handleSearch({ terms: [] });
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
const columns = [
|
||||||
|
{
|
||||||
|
title: 'ID',
|
||||||
|
dataIndex: 'id',
|
||||||
|
key: 'id',
|
||||||
|
search: {
|
||||||
|
type: 'string',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '发送时间',
|
||||||
|
dataIndex: 'notifyTime',
|
||||||
|
key: 'notifyTime',
|
||||||
|
scopedSlots: true,
|
||||||
|
search: {
|
||||||
|
type: 'date',
|
||||||
|
handleValue: (v: any) => {
|
||||||
|
return '123';
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '状态',
|
||||||
|
dataIndex: 'state',
|
||||||
|
key: 'state',
|
||||||
|
scopedSlots: true,
|
||||||
|
search: {
|
||||||
|
type: 'select',
|
||||||
|
options: [
|
||||||
|
{ label: '成功', value: 'success' },
|
||||||
|
{ label: '失败', value: 'error' },
|
||||||
|
],
|
||||||
|
handleValue: (v: any) => {
|
||||||
|
return '123';
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '操作',
|
||||||
|
key: 'action',
|
||||||
|
scopedSlots: true,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
const params = ref<Record<string, any>>({});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 搜索
|
||||||
|
* @param params
|
||||||
|
*/
|
||||||
|
const handleSearch = (e: any) => {
|
||||||
|
// console.log('handleSearch e:', e);
|
||||||
|
params.value = e;
|
||||||
|
// console.log('params.value: ', params.value);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查看错误信息
|
||||||
|
*/
|
||||||
|
const handleError = (e: any) => {
|
||||||
|
Modal.info({
|
||||||
|
title: '错误信息',
|
||||||
|
content: JSON.stringify(e),
|
||||||
|
});
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* 查看详情
|
||||||
|
*/
|
||||||
|
const handleDetail = (e: any) => {
|
||||||
|
Modal.info({
|
||||||
|
title: '详情信息',
|
||||||
|
content: JSON.stringify(e),
|
||||||
|
});
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="less" scoped></style>
|
|
@ -1,22 +1,399 @@
|
||||||
<!-- 通知模板 -->
|
|
||||||
<template>
|
<template>
|
||||||
<div class="page-container">通知模板</div>
|
<div class="page-container">
|
||||||
|
<a-card style="margin-bottom: 20px">
|
||||||
|
<Search
|
||||||
|
:columns="columns"
|
||||||
|
target="notice-config"
|
||||||
|
@search="handleSearch"
|
||||||
|
/>
|
||||||
|
</a-card>
|
||||||
|
<a-card>
|
||||||
|
<JTable
|
||||||
|
ref="configRef"
|
||||||
|
:columns="columns"
|
||||||
|
:request="ConfigApi.list"
|
||||||
|
:defaultParams="{
|
||||||
|
sorts: [{ name: 'createTime', order: 'desc' }],
|
||||||
|
}"
|
||||||
|
:params="params"
|
||||||
|
>
|
||||||
|
<template #headerTitle>
|
||||||
|
<a-space>
|
||||||
|
<a-button type="primary" @click="handleAdd">
|
||||||
|
新增
|
||||||
|
</a-button>
|
||||||
|
<a-upload
|
||||||
|
name="file"
|
||||||
|
accept="json"
|
||||||
|
:showUploadList="false"
|
||||||
|
:before-upload="beforeUpload"
|
||||||
|
>
|
||||||
|
<a-button>导入</a-button>
|
||||||
|
</a-upload>
|
||||||
|
<a-popconfirm
|
||||||
|
title="确认导出当前页数据?"
|
||||||
|
ok-text="确定"
|
||||||
|
cancel-text="取消"
|
||||||
|
@confirm="handleExport"
|
||||||
|
>
|
||||||
|
<a-button>导出</a-button>
|
||||||
|
</a-popconfirm>
|
||||||
|
</a-space>
|
||||||
|
</template>
|
||||||
|
<template #card="slotProps">
|
||||||
|
<CardBox
|
||||||
|
:showStatus="false"
|
||||||
|
:value="slotProps"
|
||||||
|
:actions="getActions(slotProps, 'card')"
|
||||||
|
v-bind="slotProps"
|
||||||
|
>
|
||||||
|
<template #img>
|
||||||
|
<slot name="img">
|
||||||
|
<img
|
||||||
|
:src="
|
||||||
|
getLogo(
|
||||||
|
slotProps.type,
|
||||||
|
slotProps.provider,
|
||||||
|
)
|
||||||
|
"
|
||||||
|
/>
|
||||||
|
</slot>
|
||||||
|
</template>
|
||||||
|
<template #content>
|
||||||
|
<h3 class="card-item-content-title">
|
||||||
|
{{ slotProps.name }}
|
||||||
|
</h3>
|
||||||
|
<a-row>
|
||||||
|
<a-col :span="12">
|
||||||
|
<div class="card-item-content-text">
|
||||||
|
通知方式
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
{{ getMethodTxt(slotProps.type) }}
|
||||||
|
</div>
|
||||||
|
</a-col>
|
||||||
|
<a-col :span="12">
|
||||||
|
<div class="card-item-content-text">
|
||||||
|
说明
|
||||||
|
</div>
|
||||||
|
<div>{{ slotProps.description }}</div>
|
||||||
|
</a-col>
|
||||||
|
</a-row>
|
||||||
|
</template>
|
||||||
|
<template #actions="item">
|
||||||
|
<a-tooltip
|
||||||
|
v-bind="item.tooltip"
|
||||||
|
:title="item.disabled && item.tooltip.title"
|
||||||
|
>
|
||||||
|
<a-popconfirm
|
||||||
|
v-if="item.popConfirm"
|
||||||
|
v-bind="item.popConfirm"
|
||||||
|
:disabled="item.disabled"
|
||||||
|
>
|
||||||
|
<a-button :disabled="item.disabled">
|
||||||
|
<AIcon
|
||||||
|
type="DeleteOutlined"
|
||||||
|
v-if="item.key === 'delete'"
|
||||||
|
/>
|
||||||
|
<template v-else>
|
||||||
|
<AIcon :type="item.icon" />
|
||||||
|
<span>{{ item.text }}</span>
|
||||||
|
</template>
|
||||||
|
</a-button>
|
||||||
|
</a-popconfirm>
|
||||||
|
<template v-else>
|
||||||
|
<a-button
|
||||||
|
:disabled="item.disabled"
|
||||||
|
@click="item.onClick"
|
||||||
|
>
|
||||||
|
<AIcon
|
||||||
|
type="DeleteOutlined"
|
||||||
|
v-if="item.key === 'delete'"
|
||||||
|
/>
|
||||||
|
<template v-else>
|
||||||
|
<AIcon :type="item.icon" />
|
||||||
|
<span>{{ item.text }}</span>
|
||||||
|
</template>
|
||||||
|
</a-button>
|
||||||
|
</template>
|
||||||
|
</a-tooltip>
|
||||||
|
</template>
|
||||||
|
</CardBox>
|
||||||
|
</template>
|
||||||
|
<template #action="slotProps">
|
||||||
|
<a-space :size="16">
|
||||||
|
<a-tooltip
|
||||||
|
v-for="i in getActions(slotProps, 'table')"
|
||||||
|
:key="i.key"
|
||||||
|
v-bind="i.tooltip"
|
||||||
|
>
|
||||||
|
<a-popconfirm
|
||||||
|
v-if="i.popConfirm"
|
||||||
|
v-bind="i.popConfirm"
|
||||||
|
:disabled="i.disabled"
|
||||||
|
>
|
||||||
|
<a-button
|
||||||
|
:disabled="i.disabled"
|
||||||
|
style="padding: 0"
|
||||||
|
type="link"
|
||||||
|
><AIcon :type="i.icon"
|
||||||
|
/></a-button>
|
||||||
|
</a-popconfirm>
|
||||||
|
<a-button
|
||||||
|
style="padding: 0"
|
||||||
|
type="link"
|
||||||
|
v-else
|
||||||
|
@click="i.onClick && i.onClick(slotProps)"
|
||||||
|
>
|
||||||
|
<a-button
|
||||||
|
:disabled="i.disabled"
|
||||||
|
style="padding: 0"
|
||||||
|
type="link"
|
||||||
|
><AIcon :type="i.icon"
|
||||||
|
/></a-button>
|
||||||
|
</a-button>
|
||||||
|
</a-tooltip>
|
||||||
|
</a-space>
|
||||||
|
</template>
|
||||||
|
</JTable>
|
||||||
|
</a-card>
|
||||||
|
|
||||||
|
<Debug v-model:visible="debugVis" :data="currentConfig" />
|
||||||
|
<Log v-model:visible="logVis" :data="currentConfig" />
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import templateApi from '@/api/notice/template';
|
import ConfigApi from '@/api/notice/config';
|
||||||
|
import type { ActionsType } from '@/components/Table/index.vue';
|
||||||
|
import { getImage, LocalStore } from '@/utils/comm';
|
||||||
|
import { message } from 'ant-design-vue';
|
||||||
|
import { BASE_API_PATH, TOKEN_KEY } from '@/utils/variable';
|
||||||
|
|
||||||
const getList = async () => {
|
import { NOTICE_METHOD, MSG_TYPE } from '@/views/notice/const';
|
||||||
const res = await templateApi.list({
|
|
||||||
current: 1,
|
import Debug from './Debug/index.vue';
|
||||||
pageIndex: 0,
|
import Log from './Log/index.vue';
|
||||||
pageSize: 12,
|
import { downloadObject } from '@/utils/utils';
|
||||||
sorts: [{ name: 'createTime', order: 'desc' }],
|
|
||||||
terms: [],
|
let providerList: any = [];
|
||||||
});
|
Object.keys(MSG_TYPE).forEach((key) => {
|
||||||
console.log('res: ', res);
|
providerList = [...providerList, ...MSG_TYPE[key]];
|
||||||
|
});
|
||||||
|
|
||||||
|
const router = useRouter();
|
||||||
|
|
||||||
|
const configRef = ref<Record<string, any>>({});
|
||||||
|
const params = ref<Record<string, any>>({});
|
||||||
|
|
||||||
|
const columns = [
|
||||||
|
{
|
||||||
|
title: '配置名称',
|
||||||
|
dataIndex: 'name',
|
||||||
|
key: 'name',
|
||||||
|
search: {
|
||||||
|
type: 'string',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '通知方式',
|
||||||
|
dataIndex: 'type',
|
||||||
|
key: 'type',
|
||||||
|
scopedSlots: true,
|
||||||
|
search: {
|
||||||
|
type: 'select',
|
||||||
|
options: NOTICE_METHOD,
|
||||||
|
handleValue: (v: any) => {
|
||||||
|
return '123';
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '类型',
|
||||||
|
dataIndex: 'provider',
|
||||||
|
key: 'provider',
|
||||||
|
scopedSlots: true,
|
||||||
|
search: {
|
||||||
|
type: 'select',
|
||||||
|
options: providerList,
|
||||||
|
handleValue: (v: any) => {
|
||||||
|
return '123';
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '说明',
|
||||||
|
dataIndex: 'description',
|
||||||
|
key: 'description',
|
||||||
|
search: {
|
||||||
|
type: 'string',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '操作',
|
||||||
|
key: 'action',
|
||||||
|
fixed: 'right',
|
||||||
|
width: 250,
|
||||||
|
scopedSlots: true,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 搜索
|
||||||
|
* @param params
|
||||||
|
*/
|
||||||
|
const handleSearch = (e: any) => {
|
||||||
|
console.log('handleSearch:', e);
|
||||||
|
params.value = e;
|
||||||
|
console.log('params.value: ', params.value);
|
||||||
};
|
};
|
||||||
getList();
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style lang="less" scoped></style>
|
/**
|
||||||
|
* 根据通知方式展示对应logo
|
||||||
|
*/
|
||||||
|
const getLogo = (type: string, provider: string) => {
|
||||||
|
return MSG_TYPE[type].find((f: any) => f.value === provider)?.logo;
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* 通知方式字段展示对应文字
|
||||||
|
*/
|
||||||
|
const getMethodTxt = (type: string) => {
|
||||||
|
return NOTICE_METHOD.find((f) => f.value === type)?.label;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增
|
||||||
|
*/
|
||||||
|
const handleAdd = () => {
|
||||||
|
router.push(`/notice/Config/detail/:id`);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导入
|
||||||
|
*/
|
||||||
|
const beforeUpload = (file: any) => {
|
||||||
|
console.log('file: ', file);
|
||||||
|
const reader = new FileReader();
|
||||||
|
reader.readAsText(file);
|
||||||
|
reader.onload = async (result) => {
|
||||||
|
const text = result.target?.result;
|
||||||
|
console.log('text: ', text);
|
||||||
|
if (!file.type.includes('json')) {
|
||||||
|
message.error('请上传json格式文件');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const data = JSON.parse(text || '{}');
|
||||||
|
const { success } = await ConfigApi.update(data);
|
||||||
|
if (success) {
|
||||||
|
message.success('操作成功');
|
||||||
|
configRef.value.reload();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} catch {
|
||||||
|
// message.error('请上传json格式文件');
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出
|
||||||
|
*/
|
||||||
|
const handleExport = () => {
|
||||||
|
downloadObject(configRef.value.dataSource, `通知配置`);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查看
|
||||||
|
*/
|
||||||
|
const handleView = (id: string) => {
|
||||||
|
message.warn(id + '暂未开发');
|
||||||
|
};
|
||||||
|
|
||||||
|
const syncVis = ref(false);
|
||||||
|
const debugVis = ref(false);
|
||||||
|
const logVis = ref(false);
|
||||||
|
const currentConfig = ref<Partial<Record<string, any>>>();
|
||||||
|
const getActions = (
|
||||||
|
data: Partial<Record<string, any>>,
|
||||||
|
type: 'card' | 'table',
|
||||||
|
): ActionsType[] => {
|
||||||
|
if (!data) return [];
|
||||||
|
const actions = [
|
||||||
|
{
|
||||||
|
key: 'edit',
|
||||||
|
text: '编辑',
|
||||||
|
tooltip: {
|
||||||
|
title: '编辑',
|
||||||
|
},
|
||||||
|
icon: 'EditOutlined',
|
||||||
|
onClick: () => {
|
||||||
|
// visible.value = true;
|
||||||
|
// current.value = data;
|
||||||
|
router.push(`/notice/Config/detail/${data.id}`);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'debug',
|
||||||
|
text: '调试',
|
||||||
|
tooltip: {
|
||||||
|
title: '调试',
|
||||||
|
},
|
||||||
|
icon: 'BugOutlined',
|
||||||
|
onClick: () => {
|
||||||
|
debugVis.value = true;
|
||||||
|
currentConfig.value = data;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'debug',
|
||||||
|
text: '通知记录',
|
||||||
|
tooltip: {
|
||||||
|
title: '通知记录',
|
||||||
|
},
|
||||||
|
icon: 'BarsOutlined',
|
||||||
|
onClick: () => {
|
||||||
|
logVis.value = true;
|
||||||
|
currentConfig.value = data;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'debug',
|
||||||
|
text: '导出',
|
||||||
|
tooltip: {
|
||||||
|
title: '导出',
|
||||||
|
},
|
||||||
|
icon: 'ArrowDownOutlined',
|
||||||
|
onClick: () => {
|
||||||
|
downloadObject(data, `通知配置`);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'delete',
|
||||||
|
text: '删除',
|
||||||
|
popConfirm: {
|
||||||
|
title: '确认删除?',
|
||||||
|
onConfirm: async () => {
|
||||||
|
const resp = await ConfigApi.del(data.id);
|
||||||
|
if (resp.status === 200) {
|
||||||
|
message.success('操作成功!');
|
||||||
|
configRef.value?.reload();
|
||||||
|
} else {
|
||||||
|
message.error('操作失败!');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
icon: 'DeleteOutlined',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
return actions;
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
<style lang="less" scoped>
|
||||||
|
.page-container {
|
||||||
|
background: #f0f2f5;
|
||||||
|
padding: 24px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
Loading…
Reference in New Issue