Commit f98f6192 authored by 张耀's avatar 张耀

feat:

接口对接
parent e0a468f1
...@@ -97,7 +97,7 @@ const props = defineProps({ ...@@ -97,7 +97,7 @@ const props = defineProps({
}, },
history: { history: {
type: Object, type: Object,
default: () => ({}), default: null,
}, },
labelWidth: { labelWidth: {
type: String, type: String,
...@@ -212,10 +212,12 @@ const Remove = (index) => { ...@@ -212,10 +212,12 @@ const Remove = (index) => {
watch( watch(
() => props.history, () => props.history,
(n) => { (n) => {
let history = { ...n };
getUserLists(); getUserLists();
if (n) {
let history = { ...n };
state.form.method = history?.method || []; state.form.method = history?.method || [];
state.form.lists = history?.lists || []; state.form.lists = history?.lists || [];
}
// 如果没有默认下发用户则创建一条空数据 // 如果没有默认下发用户则创建一条空数据
if (state.form.lists.length == 0) { if (state.form.lists.length == 0) {
Add(0); Add(0);
......
...@@ -3,6 +3,6 @@ export const STATUS_OBJ = { ...@@ -3,6 +3,6 @@ export const STATUS_OBJ = {
error: '未恢复' error: '未恢复'
} }
export const PUSH_STATUS = { export const PUSH_STATUS = {
success: '成功', 1: '成功',
error: '失败' 2: '失败'
} }
\ No newline at end of file
...@@ -8,8 +8,8 @@ ...@@ -8,8 +8,8 @@
height="100%" height="100%"
:isIndex="true" :isIndex="true"
:stripe="true"> :stripe="true">
<template #person="{ row }"> <template #method="{ row }">
<span>{{ row.person.join(",") }}</span> <span>{{ row.method.map((e) => methodLists[e]).join("") }}</span>
</template> </template>
<template #status="{ row }"> <template #status="{ row }">
<span v-if="item.prop == 'push'"> <span v-if="item.prop == 'push'">
...@@ -28,12 +28,17 @@ ...@@ -28,12 +28,17 @@
<script setup> <script setup>
import { ref } from "vue"; import { ref } from "vue";
import { STATUS_OBJ, PUSH_STATUS } from "./env.js"; import { STATUS_OBJ, PUSH_STATUS } from "./env.js";
import { METHODS } from "@/components/manual-distribution/env.js";
const activeTab = ref("push"); const activeTab = ref("push");
const props = defineProps({ const props = defineProps({
tabs: { tabs: {
type: Array, type: Array,
default: () => [], default: () => [],
}, },
methodLists: {
type: Object,
default: METHODS,
},
}); });
const headers = { const headers = {
push: [ push: [
...@@ -81,8 +86,8 @@ const headers = { ...@@ -81,8 +86,8 @@ const headers = {
<style lang="scss" scoped> <style lang="scss" scoped>
$statusObj: ( $statusObj: (
success: #48ad97, 1: #48ad97,
error: #d75138, 2: #d75138,
); );
.tab { .tab {
@each $status, $color in $statusObj { @each $status, $color in $statusObj {
......
...@@ -80,26 +80,11 @@ const labelData = [ ...@@ -80,26 +80,11 @@ const labelData = [
], ],
]; ];
const info = ref({}); const info = ref({});
const tabs = [ const tabs = ref([
{ {
label: "推送记录", label: "推送记录",
prop: "push", prop: "push",
lists: [ lists: [],
{
method: "短信",
person: [11, 22, 33, 44],
push_time: "2022-07-29 10:23:59",
push_type: "自动推送",
status: "success",
},
{
method: "钉钉",
person: [11, 33, 44],
push_time: "2022-07-29 10:23:59",
push_type: "自动推送",
status: "error",
},
],
}, },
{ {
label: "处置记录", label: "处置记录",
...@@ -119,7 +104,7 @@ const tabs = [ ...@@ -119,7 +104,7 @@ const tabs = [
}, },
], ],
}, },
]; ]);
const getInfo = () => { const getInfo = () => {
const params = { const params = {
id, id,
...@@ -161,8 +146,29 @@ const GetRuleTypeOptions = () => { ...@@ -161,8 +146,29 @@ const GetRuleTypeOptions = () => {
} }
}); });
}; };
const pushType = {
1: "自动推送",
2: "手动推送",
};
const getPushLog = () => {
axios.get("/v1/api/push_record/list", { params: { alert_list_id: id } }).then((res) => {
if (res.data.code == 200) {
tabs.value[0].lists =
res.data.data.list?.map((e) => {
return {
method: e.notify_method,
person: e.system_account,
push_time: e.push_time?.split("+")[0].replace("T", " ").replace("Z", " ") || "-",
push_type: pushType[e.push_type],
status: e.status,
};
}) || [];
}
});
};
onBeforeMount(() => { onBeforeMount(() => {
GetRuleTypeOptions(); GetRuleTypeOptions();
getPushLog();
}); });
</script> </script>
......
...@@ -120,15 +120,11 @@ ...@@ -120,15 +120,11 @@
icon="#bg-ic-s-circle-tips"></bg-icon icon="#bg-ic-s-circle-tips"></bg-icon
>该推送为临时推送,可调整推送人员,仅本次有效!如固定通知人员,则前往【预警规则设置】调整预警内容 >该推送为临时推送,可调整推送人员,仅本次有效!如固定通知人员,则前往【预警规则设置】调整预警内容
</div> </div>
<el-form ref="pushForm" :model="pushFormData" :rules="pushRules" label-width="120px" class="bg_form"> <ManualDistributionForm
<el-form-item label="预警工单推送" prop="method" style="margin-bottom: 24px"> ref="manual_distribution_form"
<el-checkbox-group v-model="pushFormData.method"> :noElLabel="false"
<el-checkbox :label="1">钉钉</el-checkbox> methodLabel="预警工单推送"
<el-checkbox :label="2">短信</el-checkbox> :history="state.history" />
</el-checkbox-group>
</el-form-item>
</el-form>
<user-input-table v-if="userTableFlag" ref="userTable" :data="userData" @change="changeData" />
<template v-slot:footer> <template v-slot:footer>
<div class="apaas_button"> <div class="apaas_button">
<el-button type="default" @click="cancelPushDialog">取消</el-button> <el-button type="default" @click="cancelPushDialog">取消</el-button>
...@@ -180,6 +176,7 @@ import { Search } from "@element-plus/icons-vue"; ...@@ -180,6 +176,7 @@ import { Search } from "@element-plus/icons-vue";
import bgBreadcrumb from "@/components/bg-breadcrumb.vue"; import bgBreadcrumb from "@/components/bg-breadcrumb.vue";
import userInputTable from "./user-input-table.vue"; import userInputTable from "./user-input-table.vue";
import { useRouter } from "vue-router"; import { useRouter } from "vue-router";
import ManualDistributionForm from "@/components/manual-distribution/form.vue";
import { GetRuleTypeOptions } from "@/components/env.js"; import { GetRuleTypeOptions } from "@/components/env.js";
const router = useRouter(); const router = useRouter();
...@@ -188,7 +185,7 @@ const bgForm = ref(null); ...@@ -188,7 +185,7 @@ const bgForm = ref(null);
const dataTable = ref(null); const dataTable = ref(null);
const closeForm = ref(null); const closeForm = ref(null);
const userTable = ref(null); const userTable = ref(null);
const pushForm = ref(null); const manual_distribution_form = ref(null);
const statusOptions = { const statusOptions = {
"": "全部", "": "全部",
1: "已恢复", 1: "已恢复",
...@@ -285,14 +282,8 @@ const state = reactive({ ...@@ -285,14 +282,8 @@ const state = reactive({
closeRules: { closeRules: {
close_notes: [{ required: true, message: "请输入关闭备注", trigger: "blur" }], close_notes: [{ required: true, message: "请输入关闭备注", trigger: "blur" }],
}, },
history: null,
pushDialog: false, pushDialog: false,
userData: [],
pushFormData: {
method: [],
},
pushRules: {
method: [{ type: "array", required: true, message: "请最少选择一种推送方式", trigger: "change" }],
},
pushType: 0, // 1-单条推送 2-批量推送 pushType: 0, // 1-单条推送 2-批量推送
closeType: 0, // 1-单条推送 2-批量推送 closeType: 0, // 1-单条推送 2-批量推送
}); });
...@@ -371,89 +362,73 @@ const changeSize = (size) => { ...@@ -371,89 +362,73 @@ const changeSize = (size) => {
}; // 改变每页条数 }; // 改变每页条数
const batchPush = () => { const batchPush = () => {
console.log("批量推送");
if (!state.selected || state.selected.length == 0) { if (!state.selected || state.selected.length == 0) {
ElMessage.error("请先勾选要推送的数据"); ElMessage.error("请先勾选要推送的数据");
return; return;
} }
state.pushType = 2; state.pushType = 2;
state.userData = [ state.history = null;
{
account: 1,
name: "张一",
mobile: "13111111111",
},
{
account: 2,
name: "张二二",
mobile: "13222222222",
},
{
account: 4,
name: "张四三",
mobile: "13443434344",
},
];
state.pushDialog = true; state.pushDialog = true;
}; // 批量推送 }; // 批量推送
const pushWarning = (row) => { const pushWarning = (row) => {
state.actionRow = row; state.actionRow = row;
console.log("推送提醒");
state.pushType = 1; state.pushType = 1;
state.userData = [
{
account: 1,
name: "张一",
mobile: "13111111111",
},
{
account: 2,
name: "张二二",
mobile: "13222222222",
},
{
account: 4,
name: "张四三",
mobile: "13443434344",
},
];
state.pushDialog = true; state.pushDialog = true;
let alert_rules_id = row.alert_rules_id;
axios.get(`/v1/api/alert_rules/list`, { params: { id: alert_rules_id } }).then((res) => {
if (res.data.code == 200) {
if (!res.data.data.list || res.data.data.list.length == 0) return;
state.history = {
method: res.data.data.list[0].notify_method || [],
lists:
res.data.data.list[0].notify_recipients?.map((e) => {
return {
user_id: e.system_account,
user_name: e.user_name,
phone: e.phone,
};
}) || [],
};
} else {
ElMessage.error(res.data.msg);
}
});
}; // 推送提醒 }; // 推送提醒
const changeData = (data) => {
state.userData = data.data;
};
const cancelPushDialog = () => { const cancelPushDialog = () => {
pushForm.value.resetFields();
state.pushDialog = false; state.pushDialog = false;
}; // 预警推送弹窗取消按钮:重置表单 }; // 预警推送弹窗取消按钮:重置表单
const pushConfirm = () => { const pushConfirm = async () => {
pushForm.value.validate((valid) => { const manual_distribution_form_valid = await manual_distribution_form.value.Submit();
if (valid) { if (!manual_distribution_form_valid) return;
let ids = []; const { method, lists } = manual_distribution_form.value.form || {};
if (state.pushType == 1) {
ids.push(state.actionRow.id);
} else {
ids = state.selected.map((e) => {
return e.id;
});
}
let params = { let params = {
ids: ids, ids: state.pushType == 1 ? [`${state.actionRow.id}`] : state.selected.map((e) => `${e.id}`),
method: state.pushFormData.method || [], notify_method: method || [],
notify_recipients: lists?.map((e) => {
return {
system_account: e.user_id,
user_name: e.user_name,
phone: e.phone,
};
}),
}; };
setTimeout(() => { axios
.put("/v1/api/alert_list/batch/push", params)
.then((res) => {
if (res.data.code == 200) {
ElMessage.success("推送成功");
} else {
ElMessage.error(res.data.msg);
}
})
.finally((e) => {
cancelPushDialog(); cancelPushDialog();
clearSelected(); clearSelected();
changePage(1); changePage(1);
}, 200);
}
}); });
}; };
const closeWarning = (row) => { const closeWarning = (row) => {
state.actionRow = row; state.actionRow = row;
state.closeType = 1; state.closeType = 1;
...@@ -469,25 +444,25 @@ const cancelCloseWarningDialog = () => { ...@@ -469,25 +444,25 @@ const cancelCloseWarningDialog = () => {
const confirmClose = () => { const confirmClose = () => {
closeForm.value.validate((valid) => { closeForm.value.validate((valid) => {
if (valid) { if (valid) {
let ids = [];
if (state.closeType == 1) {
ids.push(state.actionRow.id);
} else {
ids = state.selected.map((e) => {
return e.id;
});
}
let params = { let params = {
ids: ids, ids: state.closeType == 1 ? [state.actionRow.id] : state.selected.map((e) => e.id),
close_notes: state.closeFormData.close_notes, close_remark: state.closeFormData.close_notes,
close_remind: state.closeFormData.close_remind, defer_push: state.closeFormData.close_remind ? 1 : 0,
}; };
console.log(params); axios
setTimeout(() => { .put("/v1/api/alert_list/batch/close", params)
.then((res) => {
if (res.data.code == 200) {
ElMessage.success("关闭预警操作成功");
} else {
ElMessage.error(res.dta.msg);
}
})
.finally((e) => {
cancelCloseWarningDialog(); cancelCloseWarningDialog();
clearSelected(); clearSelected();
changePage(1); changePage(1);
}, 200); });
} }
}); });
}; // 关闭预警弹窗确定按钮:提交表单 }; // 关闭预警弹窗确定按钮:提交表单
...@@ -510,9 +485,6 @@ const { ...@@ -510,9 +485,6 @@ const {
closeFormData, closeFormData,
closeRules, closeRules,
pushDialog, pushDialog,
userData,
pushFormData,
pushRules,
} = toRefs(state); } = toRefs(state);
</script> </script>
......
...@@ -30,14 +30,14 @@ const add_form = ref(null); ...@@ -30,14 +30,14 @@ const add_form = ref(null);
const SaveSubmit = async () => { const SaveSubmit = async () => {
let res = await add_form.value.Submit(); let res = await add_form.value.Submit();
if (!res) return; if (!res) return;
Save(res, { url: "/v1/api/work_order/work_order_manage/add" }, () => { Save({ res, is_push: 0 }, { url: "/v1/api/work_order/work_order_manage/add" }, () => {
Cancle(); Cancle();
}); });
}; };
const Distribute = async () => { const Distribute = async () => {
let res = await add_form.value.Submit(); let res = await add_form.value.Submit();
if (!res) return; if (!res) return;
Save(res, {}, () => { Save({ res, is_push: 1 }, {}, () => {
Cancle(); Cancle();
}); });
}; };
......
...@@ -34,14 +34,14 @@ const add_form = ref(null); ...@@ -34,14 +34,14 @@ const add_form = ref(null);
const Save = async () => { const Save = async () => {
let res = await add_form.value.Submit(); let res = await add_form.value.Submit();
if (!res) return; if (!res) return;
Save(res, { url: "/v1/api/work_order/work_order_manage/edit" }, () => { Save({ res, is_push: 0 }, { url: "/v1/api/work_order/work_order_manage/edit" }, () => {
Cancle(); Cancle();
}); });
}; };
const Distribute = async () => { const Distribute = async () => {
let res = await add_form.value.Submit(); let res = await add_form.value.Submit();
if (!res) return; if (!res) return;
Save(res, { id, url: "/v1/api/work_order/work_order_manage/edit" }, () => { Save({ res, is_push: 1 }, { id, url: "/v1/api/work_order/work_order_manage/edit" }, () => {
Cancle(); Cancle();
}); });
}; };
......
...@@ -2,6 +2,7 @@ import { ElMessage } from "element-plus"; ...@@ -2,6 +2,7 @@ import { ElMessage } from "element-plus";
import axios from "@/request/http.js"; import axios from "@/request/http.js";
const setParams = (res, { id }) => { const setParams = (res, { id }) => {
let params = { let params = {
is_push: res.is_push,
order_name: res.ticket_name, order_name: res.ticket_name,
order_level: +res.ticket_level, order_level: +res.ticket_level,
order_desc: res.ticket_desc, order_desc: res.ticket_desc,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment