v1.2版
This commit is contained in:
@@ -0,0 +1,165 @@
|
||||
、、<template>
|
||||
<div class="app-container">
|
||||
<Form ref="formRef" :formList="formList" :ruleFormData="ruleForm" :config="this.paramsData && this.paramsData.readonly ? {labelWidth: '140px', buttonGroup: []} : {labelWidth: '140px'}" @fnClick="callback"></Form>
|
||||
<el-button v-if="this.paramsData && this.paramsData.readonly" style="float: right;margin-top: 12px;margin-left: 10px;" @click="callback({fnCode: 'cancel'})">返回</el-button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import Form from '@/components/form/index.vue';
|
||||
import {getPolicy, addPolicy, updatePolicy} from "@/api/disRevenue/resource"
|
||||
import {getAllBusScriptName} from "@/api/disRevenue/earnManage"
|
||||
export default {
|
||||
name: 'severScriptStratDetails',
|
||||
components: {Form},
|
||||
dicts: ['policy_method', 'policy_status'],
|
||||
props: {
|
||||
open: {
|
||||
type: String,
|
||||
default: () => {}
|
||||
},
|
||||
dialogRowData: {
|
||||
type: Object,
|
||||
default: (() => {})
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
open: {
|
||||
handler(val) {
|
||||
if (val === 'type_true') {
|
||||
this.paramsData = {};
|
||||
this.$set(this.ruleForm, 'deployDevice', this.dialogRowData.clientId);
|
||||
} else if (val === 'type_false') {
|
||||
// 清空form
|
||||
this.$refs['formRef'].$refs.ruleForm.resetFields();
|
||||
}
|
||||
},
|
||||
deep: true,
|
||||
immediate: true
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
loading: false,
|
||||
ruleForm: {},
|
||||
formList: [],
|
||||
paramsData: {},
|
||||
scriptList: {},
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.paramsData = this.$route && this.$route.query;
|
||||
if (this.open) {
|
||||
this.paramsData = {};
|
||||
this.$set(this.ruleForm, 'deployDevice', this.dialogRowData.clientId);
|
||||
}
|
||||
if (this.paramsData && this.paramsData.id) {
|
||||
this.getFormDataList(this.paramsData.id);
|
||||
}
|
||||
this.fnFormList();
|
||||
this.getBusScriptNames();
|
||||
},
|
||||
methods: {
|
||||
// formList集合
|
||||
fnFormList(objVal) {
|
||||
this.formList = [{
|
||||
config: {title: '',labelWidth: '140px', readonly: this.paramsData && this.paramsData.readonly, colSpan: 'disBlock m0Auto'},
|
||||
controls: {
|
||||
id: {label: 'ID',hidden: true},
|
||||
policyName: {label: '策略名称', span: 18, type: 'input', required: true},
|
||||
description: {label: '描述', span: 18, type: 'textarea'},
|
||||
taskName: {label: '关联业务下发任务', span: 18, type: 'input', hidden: !(this.paramsData && this.paramsData.readonly)},
|
||||
deployDevice: {label: '部署设备', span: 18, type: 'textarea',rows: 15, required: true},
|
||||
scriptName: {label: '脚本名称', span: 18, type: 'select', eventName: 'change', options: [], required: true},
|
||||
scriptPath: {label: '脚本文件地址', span: 18, type: 'input', disabled: true, required: true},
|
||||
defaultParams: {label: '脚本参数', span: 18, type: 'input'},
|
||||
executionMethod: {label: '执行方式', span: 18, type: 'select', eventName:'change', options: this.dict.type.policy_method},
|
||||
scheduledTime: {label: '定时时间', span: 18, type: 'datetime', required: true, hidden: true},
|
||||
policyStatus: {label: '策略状态', span: 18, type: 'select', options: this.dict.type.policy_status, hidden: !(this.paramsData && this.paramsData.readonly)},
|
||||
deployTime: {label: '下发策略时间', span: 18, type: 'datetime', hidden: !(this.paramsData && this.paramsData.readonly)},
|
||||
createBy: {label: '创建人', span: 18, type: 'input', hidden: !(this.paramsData && this.paramsData.readonly)},
|
||||
createTime: {label: '创建时间', span: 18, type: 'datetime', hidden: !(this.paramsData && this.paramsData.readonly)},
|
||||
updateTime: {label: '修改时间', span: 18, type: 'datetime', hidden: !(this.paramsData && this.paramsData.readonly)},
|
||||
}
|
||||
}];
|
||||
},
|
||||
// 脚本名称
|
||||
getBusScriptNames() {
|
||||
getAllBusScriptName().then(val => {
|
||||
this.formList[0].controls.scriptName['options'] = val && val.data.map(item => {
|
||||
this.scriptList[item.scriptName] = item;
|
||||
return Object.assign({label: item.scriptName, value: item.scriptName});
|
||||
});
|
||||
});
|
||||
},
|
||||
// 获取详情
|
||||
getFormDataList(id) {
|
||||
getPolicy(id).then(val => {
|
||||
if (val && val.data) {
|
||||
if (val.data.executionMethod === 1) {
|
||||
this.formList[0].controls.scheduledTime['hidden'] = false;
|
||||
}
|
||||
if (this.paramsData && this.paramsData.readonly) {
|
||||
val.data.deployDevice = val.data.deployDevice.replace(/\n/g, '<br>');
|
||||
}
|
||||
val.data.executionMethod = val && val.data.executionMethod.toString();
|
||||
// val.data['scriptName'] = Number(val.data['scriptName']);
|
||||
this.ruleForm = val && val.data;
|
||||
}
|
||||
}).catch(() => {
|
||||
});
|
||||
},
|
||||
// 监听事件
|
||||
callback(result, dataVal, formVal) {
|
||||
if (result && result.fnCode) {
|
||||
switch (result.fnCode) {
|
||||
case 'scriptName':
|
||||
this.ruleForm = Object.assign({}, this.ruleForm, this.$refs.formRef.$refs.ruleForm.model);
|
||||
if (dataVal) {
|
||||
let dataListVal = this.scriptList[dataVal];
|
||||
this.$set(this.ruleForm, 'scriptPath', dataListVal['scriptPath']);
|
||||
this.$set(this.ruleForm, 'defaultParams', dataListVal['defaultParams']);
|
||||
}
|
||||
break;
|
||||
case 'executionMethod':
|
||||
if (dataVal && dataVal === '1') {
|
||||
this.formList[0].controls.scheduledTime['hidden'] = false;
|
||||
} else {
|
||||
this.formList[0].controls.scheduledTime['hidden'] = true;
|
||||
}
|
||||
break;
|
||||
case 'submit':
|
||||
let fnType = addPolicy;
|
||||
if (dataVal && dataVal.id) {
|
||||
fnType = updatePolicy;
|
||||
}
|
||||
if(this.loading) return;
|
||||
this.loading = true;
|
||||
fnType(dataVal).then(response => {
|
||||
this.$modal.msgSuccess(response.msg);
|
||||
if (this.open) {
|
||||
this.$emit("dialogResult", {open: false});
|
||||
} else {
|
||||
this.$router.push("/resource/serverScriptStrat");
|
||||
}
|
||||
this.loading = false;
|
||||
}).catch(() => {
|
||||
this.$modal.msgError("操作失败")
|
||||
});
|
||||
break;
|
||||
case 'cancel':
|
||||
if (this.open) {
|
||||
this.$emit("dialogResult", {open: false});
|
||||
} else {
|
||||
this.$router.push("/resource/serverScriptStrat");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
</style>
|
||||
@@ -0,0 +1,304 @@
|
||||
<template>
|
||||
<div class="app-container pageTopForm">
|
||||
<el-form :model="queryParams" ref="queryRef" size="small" v-show="showSearch" label-width="auto">
|
||||
<el-col :span="8">
|
||||
<el-form-item label="策略名称" prop="policyName">
|
||||
<el-input
|
||||
v-model="queryParams.policyName"
|
||||
placeholder="请输入策略名称"
|
||||
clearable
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-form-item label="策略状态" prop="policyStatus">
|
||||
<el-select
|
||||
v-model="queryParams.policyStatus"
|
||||
placeholder="请选择策略状态"
|
||||
clearable>
|
||||
<el-option
|
||||
v-for="dict in dict.type.policy_status"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-form-item class="lastBtnSty">
|
||||
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-form>
|
||||
<TableList :columns="columns" :config="config" :modelIdent="this.$options.name" :queryParams="queryParams" :tableList="tableList" @fnClick="callback" @fnRenderList="getList" @value-change="handleValueChange">
|
||||
<template #tempFirst="{ row, column }">
|
||||
<div @click="fnDetails(1,row)">
|
||||
<a href="javascript:;" style="color: #51afff;text-decoration: underline;">{{row.offlineNum}}</a>
|
||||
</div>
|
||||
</template>
|
||||
<template #tempSecond="{ row, column }">
|
||||
<div @click="fnDetails(2,row)">
|
||||
<a href="javascript:;" style="color: #51afff;text-decoration: underline;">{{row.sucessNum}}</a>
|
||||
</div>
|
||||
</template>
|
||||
<template #tempThird="{ row, column }">
|
||||
<div @click="fnDetails(3,row)">
|
||||
<a href="javascript:;" style="color: #51afff;text-decoration: underline;">{{row.failNum}}</a>
|
||||
</div>
|
||||
</template>
|
||||
<template #tmpExecution="{ row, column }">
|
||||
<dict-tag :options="dict.type.policy_method" :value="row.executionMethod"/>
|
||||
</template>
|
||||
<template #tempStatus="{ row, column }">
|
||||
<dict-tag :options="dict.type.policy_status" :value="row.policyStatus"/>
|
||||
</template>
|
||||
</TableList>
|
||||
<!-- 弹窗 -->
|
||||
<el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
|
||||
<template v-if="clientList && clientList.length > 0">
|
||||
<el-radio-group v-model="checkboxGroup" :disabled="dialogData['timeline'] ? false : true" size="mini" @input="handleCheckedCitiesChange">
|
||||
<el-radio-button style="margin-right: 10px;" v-for="city in clientList" :label="city" :key="city">{{city}}</el-radio-button>
|
||||
</el-radio-group>
|
||||
|
||||
<div v-if="dialogData['timeline']" class="block mt10">
|
||||
<el-timeline :reverse="true">
|
||||
<template v-for="(timeline,key,index) of dialogData.timelineList">
|
||||
<el-timeline-item v-for="item of timeline" :timestamp="item.createTime" placement="top">
|
||||
<pre>{{item.content}}</pre>
|
||||
</el-timeline-item>
|
||||
</template>
|
||||
</el-timeline>
|
||||
</div>
|
||||
</template>
|
||||
<el-empty v-else :image-size="200"></el-empty>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import TableList from "@/components/table/index.vue"
|
||||
import {listPolicy, delPolicy, getScriptResultBySn} from "@/api/disRevenue/resource"
|
||||
export default {
|
||||
name: 'serverMonitorStrat',
|
||||
components: {TableList},
|
||||
dicts: ['policy_status', 'policy_method'],
|
||||
data() {
|
||||
return {
|
||||
loading: true,
|
||||
showSearch: true,
|
||||
tableList: [],
|
||||
queryParams: {
|
||||
total: 0,
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
status: ''
|
||||
},
|
||||
// 列显隐信息
|
||||
columns: {
|
||||
id: { label: `ID`,width: '50'},
|
||||
policyName: { label: `策略名称`, minWidth: '200', visible: true },
|
||||
description: { label: `描述`,minWidth: '200'},
|
||||
taskName: { label: `关联业务下发`,minWidth: '200',visible: true},
|
||||
deployDevice: { label: `部署设备`,minWidth: '250'},
|
||||
scriptName: { label: `脚本名称`,minWidth: '150'},
|
||||
scriptPath: { label: `脚本地址`,minWidth: '200'},
|
||||
scriptParams: { label: `脚本参数`,minWidth: '200'},
|
||||
executionMethod: { label: `执行方式`,minWidth: '200', slotName: 'tmpExecution'},
|
||||
offlineNum: { label: `不在线数量`,minWidth: '100', slotName: 'tempFirst', visible: true},
|
||||
sucessNum: { label: `执行成功数量`,minWidth: '120', slotName: 'tempSecond', visible: true},
|
||||
failNum: { label: `执行失败数量`,minWidth: '120', slotName: 'tempThird', visible: true},
|
||||
policyStatus: { label: `策略状态`, minWidth: '100', slotName: 'tempStatus', visible: true },
|
||||
deployTime: { label: `下发策略时间`,minWidth: '160'},
|
||||
createBy:{ label: `创建人`,minWidth: '100'},
|
||||
createTime: { label: `创建时间`,minWidth: '160'},
|
||||
updateTime: { label: `修改时间`,minWidth: '160'},
|
||||
},
|
||||
config: {
|
||||
tableButton: {
|
||||
top: [
|
||||
{content: '新增', fnCode: 'add', type: 'primary', icon: 'el-icon-plus', hasPermi: 'resource:serverScriptStrat:add'},
|
||||
{content: '删除', fnCode: 'delete', type: 'danger', icon: 'el-icon-delete', hasPermi: 'resource:serverScriptStrat:detele'},
|
||||
{content: '导出', fnCode: 'export', type: 'warning', icon: 'el-icon-download', hasPermi: 'resource:serverScriptStrat:export'},
|
||||
],
|
||||
line: [
|
||||
{content: '修改', fnCode: 'edit', type: 'text', showName: 'policyStatus', showVal: '0', icon: 'el-icon-edit', hasPermi: 'resource:serverScriptStrat:edit'},
|
||||
{content: '详情', fnCode: 'details', type: 'text', icon: 'el-icon-view', hasPermi: 'resource:serverScriptStrat:details'},
|
||||
{content: '删除', fnCode: 'delete', type: 'text', showName: 'policyStatus', showVal: '0', icon: 'el-icon-delete', hasPermi: 'resource:serverScriptStrat:detele'},
|
||||
]
|
||||
}
|
||||
},
|
||||
open: false,
|
||||
checkboxGroup: '',
|
||||
title: '',
|
||||
dialogData: {
|
||||
timeline: false,
|
||||
timelineList: {}
|
||||
},
|
||||
clientList: [],
|
||||
changeRowData: {},
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.getList();
|
||||
},
|
||||
activated() {
|
||||
this.$nextTick(() => {
|
||||
this.getList();
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
/** 查询列表 */
|
||||
getList() {
|
||||
// this.$modal.loading();
|
||||
listPolicy(this.queryParams).then(response => {
|
||||
this.tableList = response.rows;
|
||||
this.queryParams.total = response.total;
|
||||
// this.$modal.closeLoading();
|
||||
}).catch(err => {
|
||||
// this.$modal.closeLoading();
|
||||
})
|
||||
},
|
||||
// 处理子组件传递的新值
|
||||
handleValueChange(newValue) {
|
||||
// 父组件更新自身数据,实现同步
|
||||
this.showSearch = newValue;
|
||||
// console.log('父组件拿到新值:', newValue);
|
||||
},
|
||||
/** 搜索按钮操作 */
|
||||
handleQuery() {
|
||||
this.queryParams.pageNum = 1;
|
||||
this.getList();
|
||||
},
|
||||
|
||||
/** 重置按钮操作 */
|
||||
resetQuery() {
|
||||
this.resetForm("queryRef");
|
||||
this.handleQuery();
|
||||
},
|
||||
|
||||
fnDetails(num, row){
|
||||
this.checkboxGroup = '';
|
||||
this.changeRowData = row;
|
||||
this.clientList = [];
|
||||
this.open = true;
|
||||
if (num === 1) {
|
||||
this.title = '不在线设备';
|
||||
this.dialogData['timeline'] = false;
|
||||
this.clientList = row.offlineClientIds;
|
||||
} else if (num === 2) {
|
||||
this.title = '执行成功设备';
|
||||
this.dialogData['timeline'] = true;
|
||||
this.clientList = row.sucessClientIds;
|
||||
if (this.clientList && this.clientList.length > 0) {
|
||||
this.checkboxGroup = this.clientList[0];
|
||||
this.handleCheckedCitiesChange(this.clientList[0]);
|
||||
}
|
||||
} else {
|
||||
this.title = '执行失败设备';
|
||||
this.dialogData['timeline'] = true;
|
||||
this.clientList = row.failClientIds;
|
||||
if (this.clientList && this.clientList.length > 0) {
|
||||
this.checkboxGroup = this.clientList[0];
|
||||
this.handleCheckedCitiesChange(this.clientList[0]);
|
||||
}
|
||||
}
|
||||
},
|
||||
// 选中clientId
|
||||
handleCheckedCitiesChange(valModel) {
|
||||
if (valModel) {
|
||||
getScriptResultBySn({clientId: valModel, scriptId: this.changeRowData.id}).then(val => {
|
||||
if ( val && val.data && val.data.scriptResult && val.data.scriptResult.length > 0) {
|
||||
this.dialogData['timelineList'] = {};
|
||||
this.$set(this.dialogData['timelineList'], valModel, val.data.scriptResult);
|
||||
}
|
||||
}).catch(error => {
|
||||
this.dialogData['timelineList'] = {};
|
||||
});
|
||||
} else {
|
||||
this.$delete(this.dialogData['timelineList'], valModel);
|
||||
}
|
||||
},
|
||||
|
||||
callback(result, rowData, selectChange, selectList) {
|
||||
if (result && result.fnCode) {
|
||||
switch (result.fnCode) {
|
||||
case 'add':
|
||||
this.$router.push({
|
||||
path:'/resource/serverScriptStrat/details/index'});
|
||||
break;
|
||||
case 'edit':
|
||||
this.$router.push({
|
||||
path:'/resource/serverScriptStrat/details/index',
|
||||
query:{
|
||||
id: rowData.id
|
||||
}
|
||||
});
|
||||
break;
|
||||
case 'details':
|
||||
this.$router.push({
|
||||
path:'/resource/serverScriptStrat/details/index',
|
||||
query:{
|
||||
id: rowData.id,
|
||||
readonly: true
|
||||
}
|
||||
});
|
||||
break;
|
||||
case 'delete':
|
||||
let ids;
|
||||
if (rowData && rowData.id) {
|
||||
ids = rowData.id;
|
||||
} else {
|
||||
if (selectList && selectList.length <= 0) {
|
||||
this.$modal.msgWarning("请选择数据!");
|
||||
return;
|
||||
}
|
||||
ids = selectChange;
|
||||
}
|
||||
this.$modal.confirm('是否确认删除数据项?').then(function() {
|
||||
return delPolicy(ids)
|
||||
}).then(() => {
|
||||
this.getList();
|
||||
this.$modal.msgSuccess("删除成功")
|
||||
}).catch(() => {});
|
||||
break;
|
||||
case 'export':
|
||||
// let dataList = [];
|
||||
// Object.keys(this.columns).forEach(item => {
|
||||
// if (item.visible) {
|
||||
// dataList.push(item.prop);
|
||||
// }
|
||||
// });
|
||||
// this.download("/system/monitorStategy/export", {properties: dataList,}, `拓扑管理_${new Date().getTime()}.xlsx`);
|
||||
let paramsList = Object.assign({}, this.queryParams,rowData);
|
||||
this.download("rocketmq/policy/export", paramsList, `服务器脚本策略_${new Date().getTime()}.xlsx`, null, 'json');
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style scoped>
|
||||
::v-deep .lastBtnSty .el-form-item__content{
|
||||
margin-left: 10px!important;
|
||||
}
|
||||
::v-deep .el-radio-button__inner{
|
||||
border-radius: 4px!important;
|
||||
border-left: 1px solid #DCDFE6!important;
|
||||
}
|
||||
::v-deep .el-radio-button.is-checked .el-radio-button__inner{
|
||||
box-shadow: none!important;
|
||||
}
|
||||
::v-deep .el-radio-button.is-focus .el-radio-button__inner{
|
||||
border-color: #1890ff!important;
|
||||
}
|
||||
::v-deep .el-timeline .el-timeline-item:last-child .el-timeline-item__tail {
|
||||
display: block!important;
|
||||
}
|
||||
::v-deep .el-dialog{
|
||||
min-height: 300px;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user