feat: support dingtalk push

This commit is contained in:
engigu
2024-01-06 17:44:45 +08:00
parent 2730bb97ca
commit e6f7c2c64e
26 changed files with 418 additions and 121 deletions
+32
View File
@@ -0,0 +1,32 @@
<template>
<div class="tips">
<el-text size="small">{{ text }}</el-text>
<el-tooltip v-if="desc" placement="top">
<template #content>
<div v-html="desc"></div>
</template>
<el-icon>
<QuestionFilled />
</el-icon>
</el-tooltip>
</div>
</template>
<script>
import { defineComponent } from 'vue';
import { QuestionFilled } from '@element-plus/icons-vue'
export default defineComponent({
components: {
QuestionFilled,
},
props: {
text: String,
desc: String,
},
methods: {
},
});
</script>
<style scoped></style>
@@ -6,7 +6,7 @@
</div>
<hr />
<div ref="refContainer">
<el-table :data="tableData" empty-text="发信日志为空" :row-style="rowStyle()">
<el-table :data="tableData" stripe empty-text="发信日志为空" :row-style="rowStyle()">
<el-table-column label="ID" prop="id" width="100px" />
<el-table-column label="任务名" prop="task_name" show-overflow-tooltip width="150px" />
<el-table-column label="发信日志" prop="log">
@@ -13,16 +13,24 @@
<hr />
<div ref="refContainer">
<el-table :data="tableData" empty-text="发信任务为空" :row-style="rowStyle()">
<el-table :data="tableData" stripe empty-text="发信任务为空" :row-style="rowStyle()">
<el-table-column label="ID" prop="id" width="320px" />
<el-table-column label="任务名" prop="name" />
<el-table-column label="创建时间" prop="created_on" />
<el-table-column fixed="right" label="操作" width="190px">
<template #default="scope">
<el-button link size="small" type="primary" @click="handleViewAPI(scope.$index, scope.row)">接口</el-button>
<el-button link size="small" type="primary" @click="handleViewLogs(scope.$index, scope.row)">日志</el-button>
<el-button link size="small" type="primary" @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
<tableDeleteButton @customHandleDelete="handleDelete(scope.$index, scope.row)" />
<div v-if="sysKeptTaskIds.includes(scope.row.id)">
<el-button link size="small" type="primary"
@click="handleViewLogs(scope.$index, scope.row)">日志</el-button>
<el-text class="mx-1" type="info" size="small" style="margin-left: 15px;">系统保留任务</el-text>
</div>
<div v-if="!sysKeptTaskIds.includes(scope.row.id)">
<el-button link size="small" type="primary" @click="handleViewAPI(scope.$index, scope.row)">接口</el-button>
<el-button link size="small" type="primary"
@click="handleViewLogs(scope.$index, scope.row)">日志</el-button>
<el-button link size="small" type="primary" @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
<tableDeleteButton @customHandleDelete="handleDelete(scope.$index, scope.row)" />
</div>
</template>
</el-table-column>
</el-table>
@@ -75,7 +83,7 @@ export default {
// confirmBtnVisible: false,
tableData: [],
total: CONSTANT.TOTAL,
pageSize: CONSTANT.PAGE_SIZE,
pageSize: CONSTANT.PAGE_SIZE,
currPage: CONSTANT.PAGE,
displayCols: [
{ 'col': 'id', 'label': '任务ID' },
@@ -86,7 +94,9 @@ export default {
options: [
{ label: '邮箱', value: 'Email' },
{ label: '钉钉', value: 'Dtalk' }
]
],
sysKeptTaskIds: [CONSTANT.LOG_TASK_ID],
});
const handleEdit = (index, row) => {
@@ -122,7 +132,7 @@ export default {
}
const handleViewLogs = (index, row) => {
router.push('/sendlogs?name=' + row.name, { replace: true });
router.push('/sendlogs?taskid=' + row.id, { replace: true });
}
const filterFunc = async () => {
@@ -37,19 +37,21 @@
<el-text class="mx-1" size="small">渠道创建时间{{ currWayTmp.created_on }}</el-text><br />
</div>
<el-radio-group v-model="currInsInput.content_type" class="ml-4">
<el-radio label="text" size="small">text</el-radio>
<el-radio label="html" size="small">html</el-radio>
<el-radio-group v-model="currInsInputContentType">
<el-radio v-for="item in CONSTANT.WAYS_DATA_MAP[currWayTmp.type].taskInsRadios" :label="item.subLabel"
size="small">
{{ item.content }}
</el-radio>
</el-radio-group>
<div>
<el-input v-model="currInsInput.toAccount" placeholder="目的邮箱账号(发给谁)" size="small"
style="width: 200px; margin: 10px 40px 5px 0;" class="searchInput"></el-input>
<el-input v-model="currInsInput.title" placeholder="邮箱标题" size="small"
style="width: 200px; margin: 0px 40px 5px 0;" class="searchInput"></el-input>
<el-button @click="clickStore()" size="small" style="width: 200px">暂存</el-button>
<el-input v-model="currInsInput[item.col]"
v-for="item in CONSTANT.WAYS_DATA_MAP[currWayTmp.type].taskInsInputs" :placeholder="item.desc" size="small"
style="width: 200px; margin: 10px 40px 5px 0;" class="searchInput">
</el-input>
</div>
<el-button @click="clickStore()" size="small" style="width: 200px">暂存</el-button>
</div>
</div>
@@ -97,6 +99,7 @@ import { QuestionFilled } from '@element-plus/icons-vue'
import { v4 as uuidv4 } from 'uuid';
import { usePageState } from '@/store/page_sate.js';
import { request } from '@/api/api'
import { CONSTANT } from '@/constant'
export default defineComponent({
@@ -114,9 +117,8 @@ export default defineComponent({
isShowAddBox: false,
searchWayID: '',
currWayTmp: {},
currInsInput: {
content_type: 'text'
},
currInsInput: {},
currInsInputContentType: 'text',
currTaskInput: {
taskName: '',
taskId: uuidv4(),
@@ -139,7 +141,8 @@ export default defineComponent({
// 页面每次弹出,重置数据
const resetPageInitData = () => {
state.insTableData = [];
state.currInsInput = { content_type: 'text' };
state.currInsInputContentType = 'text';
state.currInsInput = {};
state.currWayTmp = {};
state.searchWayID = '';
state.isShowAddBox = false;
@@ -163,8 +166,8 @@ export default defineComponent({
way_id: state.currWayTmp.id,
way_type: state.currWayTmp.type,
way_name: state.currWayTmp.name,
content_type: state.currInsInput.content_type,
config: JSON.stringify({ to_account: state.currInsInput.toAccount, title: state.currInsInput.title })
content_type: state.currInsInputContentType,
config: JSON.stringify(state.currInsInput)
};
state.insTableData.push(insData);
}
@@ -175,6 +178,10 @@ export default defineComponent({
state.isShowAddBox = Boolean(data.data);
if (data.data) {
state.currWayTmp = data.data;
// 初始化currInsInput
CONSTANT.WAYS_DATA_MAP[data.data.type].taskInsInputs.forEach(element => {
state.currInsInput[element.col] = ""
});
}
}
@@ -184,8 +191,6 @@ export default defineComponent({
return postData
}
const handleSubmit = async () => {
let postData = getFinalData();
const rsp = await request.post('/sendtasks/ins/addmany', postData);
@@ -196,17 +201,12 @@ export default defineComponent({
}
const formatExtraInfo = (scope) => {
if (!scope.row.config) {
return ""
}
let config = JSON.parse(scope.row.config)
let info = `发送账号:${config.to_account}\n标题:${config.title}`
return info
return CommonUtils.formatInsConfigDisplay(scope);
}
return {
...toRefs(state), handleCancer, handleSubmit,
searchID, formatExtraInfo,
searchID, formatExtraInfo, CONSTANT,
clickStore, insRowStyle
};
},
@@ -2,8 +2,6 @@
<el-dialog v-model="isShow" width="58%" :close-on-press-escape="false" :before-close="() => { }" :show-close="false">
<template #header="">
<el-text class="mx-1">编辑发信任务</el-text>
<el-tooltip placement="top">
</el-tooltip>
</template>
<div class="add-top">
@@ -29,15 +27,19 @@
<el-text class="mx-1" size="small">渠道创建时间{{ currWayTmp.created_on }}</el-text><br />
</div>
<el-radio-group v-model="currInsInput.content_type" class="ml-4">
<el-radio label="text" size="small">text</el-radio>
<el-radio label="html" size="small">html</el-radio>
<el-radio-group v-model="currInsInputContentType">
<el-radio v-for="item in CONSTANT.WAYS_DATA_MAP[currWayTmp.type].taskInsRadios" :label="item.subLabel"
size="small">
{{ item.content }}
</el-radio>
</el-radio-group>
<div>
<el-input v-model="currInsInput.toAccount" placeholder="目的邮箱账号(发给谁)" size="small"
style="width: 200px; margin: 10px 40px 5px 0;" class="searchInput"></el-input>
<el-input v-model="currInsInput.title" placeholder="邮箱标题" size="small"
style="width: 200px; margin: 0px 40px 5px 0;" class="searchInput"></el-input>
<el-input v-model="currInsInput[item.col]"
v-for="item in CONSTANT.WAYS_DATA_MAP[currWayTmp.type].taskInsInputs" :placeholder="item.desc" size="small"
style="width: 200px; margin: 10px 40px 5px 0;" class="searchInput">
</el-input>
</div>
<div>
<el-button @click="handleAddSubmit()" size="small" style="width: 200px">添加</el-button>
@@ -87,6 +89,8 @@ import { usePageState } from '@/store/page_sate.js';
import { request } from '@/api/api'
import tableDeleteButton from '@/views/common/tableDeleteButton.vue'
import { ElMessage } from 'element-plus'
import { CONSTANT } from '@/constant'
import { CommonUtils } from "@/util/commonUtils.js";
export default defineComponent({
@@ -104,6 +108,7 @@ export default defineComponent({
isShow: false,
isShowAddBox: false,
searchWayID: '',
currInsInputContentType: '',
currWayTmp: {},
currInsInput: {},
currTaskInput: {
@@ -140,7 +145,9 @@ export default defineComponent({
state.insTableData = [];
state.currInsInput = {};
state.currWayTmp = {};
state.currInsInput = {};
state.searchWayID = '';
state.currInsInputContentType = '';
state.isShowAddBox = false;
state.currTaskInput = {
taskName: '',
@@ -162,12 +169,7 @@ export default defineComponent({
}
const formatExtraInfo = (scope) => {
if (!scope.row.config) {
return ""
}
let config = JSON.parse(scope.row.config)
let info = `发送账号:${config.to_account}\n标题:${config.title}`
return info
return CommonUtils.formatInsConfigDisplay(scope);
}
const searchID = async () => {
@@ -186,8 +188,8 @@ export default defineComponent({
way_id: state.currWayTmp.id,
way_type: state.currWayTmp.type,
way_name: state.currWayTmp.name,
content_type: state.currInsInput.content_type,
config: JSON.stringify({ to_account: state.currInsInput.toAccount, title: state.currInsInput.title })
content_type: state.currInsInputContentType,
config: JSON.stringify(state.currInsInput)
}
return postData
}
@@ -210,7 +212,7 @@ export default defineComponent({
}
return {
...toRefs(state), handleCancer, handleAddSubmit, handleEditTask,
...toRefs(state), handleCancer, handleAddSubmit, handleEditTask,CONSTANT,
searchID, handleDelete, insRowStyle, formatExtraInfo
};
},
@@ -8,9 +8,9 @@
<br />
实例的内容类型大体上可以可以分为texthtmlmarkdown
<br />
发送的消息会优先现在相应的类型消息进行发送如果没有将使用传的text消息进行发送
发送的消息会优先现在相应的类型消息进行发送如果没有将使用传的text消息进行发送
<br />
** text节点必传指定mode=async将步发送否则同步发送
** text节点必传指定mode=sync将步发送默认异步发送
</template>
<el-icon>
<QuestionFilled />
@@ -40,6 +40,7 @@ import { usePageState } from '@/store/page_sate.js';
import Prism from "prismjs";
import { ApiStrGenerate } from "@/util/viewApi.js";
import { QuestionFilled } from '@element-plus/icons-vue'
import { request } from '@/api/api'
export default defineComponent({
components: {
@@ -70,10 +71,24 @@ export default defineComponent({
}
}
const renderApiString = () => {
// 获取接口查看格式
const getViewOptions = async (taskId) => {
let params = { id: taskId };
const rsp = await request.get('/sendtasks/ins/gettask', { params: params });
let insTableData = await rsp.data.data.ins_data;
let viewOptions = {}
insTableData.forEach(element => {
viewOptions[element.content_type] = 1;
});
return viewOptions
}
const renderApiString = async () => {
let task_id = pageState.ShowDialogData[props.componentName].rowData.id;
let options = await getViewOptions(task_id)
if (state.activeName == 'curl') {
state.currCode = ApiStrGenerate.getCurlString(task_id, {});
state.currCode = ApiStrGenerate.getCurlString(task_id, options);
}
setTimeout(() => {
Prism.highlightAll()
@@ -18,7 +18,7 @@
<hr />
<div ref="refContainer">
<el-table :data="tableData" empty-text="发信渠道为空" :row-style="rowStyle()">
<el-table :data="tableData" stripe empty-text="发信渠道为空" :row-style="rowStyle()">
<el-table-column label="ID" width="320px">
<template #default="scope">
{{ scope.row.id }}
@@ -8,34 +8,23 @@
<el-form label-width="100px" v-for="item in waysLabelData">
<el-tab-pane :label="item.label" :name="item.type">
<el-form-item :label="one.subLabel" v-for="one in item.inputs">
<el-input v-model="one.value" />
<el-input size="small" v-model="one.value" :placeholder="one.desc" />
</el-form-item>
<textTips v-if="item.tips" :text="item.tips.text" :desc="item.tips.desc" />
</el-tab-pane>
</el-form>
</el-tabs>
<template #footer>
<span class="dialog-footer">
<el-button @click="testMseeageDialogVisible = true" size="small">测试发信</el-button>
<el-button @click="handleCancer()" size="small">取消</el-button>
<testSendButton @customhandleSubmit="handleTest()" />
<el-button type="primary" size="small" @click="handleSubmit()">
确定添加
</el-button>
</span>
</template>
</el-dialog>
<el-dialog v-model="testMseeageDialogVisible" width="50%" align-center>
<span>将发送一条测试信息将注意查收</span>
<template #footer>
<span class="dialog-footer">
<el-button size="small" @click="testMseeageDialogVisible = false">取消</el-button>
<el-button size="small" type="primary" @click="(testMseeageDialogVisible = false) || handleTest()">
确定发送
</el-button>
</span>
</template>
</el-dialog>
</template>
<script>
@@ -45,9 +34,15 @@ import { request } from '@/api/api'
import { CONSTANT } from '@/constant'
import { _ } from 'lodash';
import { ElMessage } from 'element-plus'
import textTips from '@/views/common/textTips.vue'
import testSendButton from './testSendButton.vue'
export default defineComponent({
components: {
textTips,
testSendButton,
},
props: {
componentName: String
},
@@ -9,7 +9,7 @@
<el-form label-width="100px" v-for="item in waysLabelData">
<!-- <el-tab-pane :label="item.label" :name="item.type"> -->
<el-form-item :label="one.subLabel" v-for="one in item.inputs">
<el-input v-model="one.value" />
<el-input size="small" v-model="one.value" :placeholder="one.desc" />
</el-form-item>
<!-- </el-tab-pane> -->
</el-form>
@@ -18,26 +18,14 @@
<template #footer>
<span class="dialog-footer">
<el-button @click="testMseeageDialogVisible = true" size="small">测试发信</el-button>
<el-button @click="handleCancer()" size="small">取消</el-button>
<testSendButton @customhandleSubmit="handleTest()" />
<el-button type="primary" size="small" @click="handleSubmit()">
确定编辑
</el-button>
</span>
</template>
</el-dialog>
<el-dialog v-model="testMseeageDialogVisible" width="50%" align-center>
<span>将发送一条测试信息将注意查收</span>
<template #footer>
<span class="dialog-footer">
<el-button size="small" @click="testMseeageDialogVisible = false">取消</el-button>
<el-button size="small" type="primary" @click="(testMseeageDialogVisible = false) || handleTest()">
确定发送
</el-button>
</span>
</template>
</el-dialog>
</template>
<script>
@@ -47,9 +35,13 @@ import { request } from '@/api/api'
import { CONSTANT } from '@/constant'
import { _ } from 'lodash';
import { ElMessage } from 'element-plus'
import testSendButton from './testSendButton.vue'
export default defineComponent({
components: {
testSendButton,
},
props: {
componentName: String
},
@@ -57,7 +49,6 @@ export default defineComponent({
const pageState = usePageState();
const state = reactive({
isShow: false,
testMseeageDialogVisible: false,
waysLabelData: [],
editData: {},
@@ -0,0 +1,22 @@
<template>
<el-popconfirm width="400px" confirm-button-text="确定" cancel-button-text="算了" icon-color="#626AEF"
title="将往添加的渠道发送一条测试消息,请注意查收!" @confirm="handleSubmit()">
<template #reference>
<el-button size="small" type="primary">点击测试</el-button>
</template>
</el-popconfirm>
</template>
<script>
import { defineComponent } from 'vue';
export default defineComponent({
methods: {
handleSubmit() {
this.$emit('customhandleSubmit');
}
}
});
</script>
@@ -4,7 +4,7 @@
<div class="buttom">
<div class="tips">
<el-text size="small">版本功能说明</el-text>
<el-tooltip placement="top">
<el-tooltip v-if="desc" placement="top">
<template #content>
<div v-html="desc"></div>
</template>