Browse Source

完善定时任务

wangqin
hui 7 months ago
parent
commit
bfd32cee66
  1. 84
      ruoyi-ui/src/views/JiHeExpressway/pages/control/device/strategy/components/AddNEditDialog.vue
  2. 31
      ruoyi-ui/src/views/JiHeExpressway/pages/control/device/strategy/components/TaskItem.vue
  3. 9
      ruoyi-ui/src/views/JiHeExpressway/pages/control/device/strategy/components/taskEditDialog.vue
  4. 176
      ruoyi-ui/src/views/JiHeExpressway/pages/control/device/strategy/components/timeEditDialog.vue
  5. 22
      ruoyi-ui/src/views/JiHeExpressway/pages/control/device/strategy/index.vue
  6. 9
      ruoyi-ui/src/views/JiHeExpressway/utils/api/batch.js

84
ruoyi-ui/src/views/JiHeExpressway/pages/control/device/strategy/components/AddNEditDialog.vue

@ -20,15 +20,14 @@
<el-button type="primary" @click="onSaveTaskGroup('basicInfoForm')" :loading="submitting"> 提交 </el-button>
</div>
</el-form>
{{ editData.id }}
<template v-if="editData.id">
<!-- 如果是新增的还没有保存的任务组不能添加任务 -->
<div class="fl-around task_op">
<el-button size="mini" type="primary" @click="onAddTaskGroup">新增</el-button>
<el-button size="mini" type="primary" @click="onAddTaskGroup">新增任务组</el-button>
</div>
<div class="task" v-for="taskGroup,index in taskGroupsEditing">
<div class="fl-around task_info">
<el-input v-model="taskGroup.time"></el-input>
<el-input v-model="taskGroup.time" style="width: 180px;"></el-input>
<div class="fl-around task_op">
<el-button size="mini" type="primary" @click="onAddTaskItem(taskGroup)">新增子任务</el-button>
<el-button size="mini" type="primary">删除</el-button>
@ -50,6 +49,8 @@
<taskEditDialog v-model="isEditing" :groupId="propData.id" :time="selectedTaskGroup.time" :propData="{}"
@onSubmit="onSubmitTaskItem" />
<timeEditDialog v-model="isShowTimeEdit" @onSubmit="onSubmitTime" />
</Dialog>
</template>
@ -63,6 +64,7 @@ import { Message } from "element-ui";
import { addEditFormList } from "./../data";
import taskEditDialog from "./taskEditDialog.vue";
import timeEditDialog from "./timeEditDialog.vue";
import TaskItem from "./TaskItem.vue";
export default {
@ -72,7 +74,8 @@ export default {
Button,
Form,
TaskItem,
taskEditDialog
taskEditDialog,
timeEditDialog
},
model: {
prop: "visible",
@ -96,6 +99,7 @@ export default {
editData:{},
mode:"",
isEditing:false,
isShowTimeEdit:false,
group:{},
submitting: false,
formList: addEditFormList,
@ -152,7 +156,28 @@ export default {
this.getTaskList(); //task
},
onAddTaskGroup(){
this.taskGroupsEditing.push({time:"08:00:00",tasks:[1,2,3]});
this.isShowTimeEdit = true;
},
onSubmitTime(time){
this.isShowTimeEdit = false;
this.taskGroupsEditing.push({ time, tasks: [] });
let detailedConfiguration =[];
this.taskGroupsEditing.forEach(item=>{
detailedConfiguration.push({time:item.time, tasks:_.map(item.tasksEdit, "id")});
});
request({
url: `/business/dcBatchFunctionsJobGroup`,
method: "PUT",
data: {
id: this.editData.id,
detailedConfiguration: JSON.stringify(detailedConfiguration)
},
})
.then((result) => {
if (result.code != 200) return;
Message.success(`提交成功!`);
})
},
onAddTaskItem(taskG){
this.selectedTaskGroup = taskG;
@ -184,22 +209,22 @@ export default {
},
getTaskList(){
// this.taskGroupsEditing = JSON.parse(this.propData.detailedConfiguration);
this.taskGroupsEditing = [{time:"08:00:00",tasks:[1],tasksEdit:[]}];
this.taskGroupsEditing = JSON.parse(this.propData.detailedConfiguration);
// this.taskGroupsEditing = [{time:"08:00:00",tasks:[1],tasksEdit:[]}];
//
let rstData = [
{
id: 1,
callParameter: '{"deviceType":"2","direction":"1","devices":[{"id":904,"iotDeviceId":"81221 - 65535","deviceType":"2","direction":"1"},{"id":2116,"iotDeviceId":"26113 - 65535","deviceType":"2","direction":"1"}],"functions":[{"functionId":"11","params":{"size":"65535","fileName":"play012.lst"}},{"functionId":"13","params":{"STAY":90,"ACTION":"1","SPEED":"0","COLOR":"ffff00","FONT":"3","FONT_SIZE":"24","CONTENT":"长清收费站\\\\n出入口封闭","width":"160","height":"80","formatStyle":"2"}},{"functionId":"1B","params":{"fileId":"12"}}]}',
jobGroup: 1
}
]
this.taskGroupsEditing.forEach(item => {
let arr = _.filter(rstData, itm => { return item.tasks.includes(itm.id) });
item.tasksEdit = arr;
});
return
// let rstData = [
// {
// id: 1,
// callParameter: '{"deviceType":"2","direction":"1","devices":[{"id":904,"iotDeviceId":"81221 - 65535","deviceType":"2","direction":"1"},{"id":2116,"iotDeviceId":"26113 - 65535","deviceType":"2","direction":"1"}],"functions":[{"functionId":"11","params":{"size":"65535","fileName":"play012.lst"}},{"functionId":"13","params":{"STAY":90,"ACTION":"1","SPEED":"0","COLOR":"ffff00","FONT":"3","FONT_SIZE":"24","CONTENT":"\\\\n","width":"160","height":"80","formatStyle":"2"}},{"functionId":"1B","params":{"fileId":"12"}}]}',
// jobGroup: 1
// }
// ]
// this.taskGroupsEditing.forEach(item => {
// let arr = _.filter(rstData, itm => { return item.tasks.includes(itm.id) });
// item.tasksEdit = arr;
// });
// return
//
request({
@ -211,16 +236,18 @@ export default {
})
.then((result) => {
if (result.code != 200) return;
result.data = [
{
id:1,
callParameter: '{"deviceType":"2","devices":[{"id":904,"iotDeviceId":"81221 - 65535","deviceType":"2","direction":"1"},{"id":2116,"iotDeviceId":"26113 - 65535","deviceType":"2","direction":"1"}],"functions":[{"functionId":"11","params":{"size":"65535","fileName":"play012.lst"}},{"functionId":"13","params":{"STAY":90,"ACTION":"1","SPEED":"0","COLOR":"ffff00","FONT":"3","FONT_SIZE":"24","CONTENT":"长清收费站\\\\n出入口封闭","width":"160","height":"80","formatStyle":"2"}},{"functionId":"1B","params":{"fileId":"12"}}]}',
jobGroup:1
}
]
console.log("当前任务组下的任务", result.data);
// result.data = [
// {
// id:1,
// callParameter: '{"deviceType":"2","devices":[{"id":904,"iotDeviceId":"81221 - 65535","deviceType":"2","direction":"1"},{"id":2116,"iotDeviceId":"26113 - 65535","deviceType":"2","direction":"1"}],"functions":[{"functionId":"11","params":{"size":"65535","fileName":"play012.lst"}},{"functionId":"13","params":{"STAY":90,"ACTION":"1","SPEED":"0","COLOR":"ffff00","FONT":"3","FONT_SIZE":"24","CONTENT":"\\\\n","width":"160","height":"80","formatStyle":"2"}},{"functionId":"1B","params":{"fileId":"12"}}]}',
// jobGroup:1
// }
// ]
this.taskGroupsEditing.forEach(item=>{
let arr = _.filter(result.data, itm=>{ return item.tasks.includes(itm.id)});
item.tasksEdit = arr;
let arr = _.filter(result.data, itm => { return item.tasks.includes(itm.jobId)});
this.$set(item, "tasksEdit", arr);
// item.tasksEdit = arr;
});
})
},
@ -250,7 +277,6 @@ export default {
Message.success(`提交成功!`);
this.$emit("onSuccess");
this.editData = { ...result.data };
this.mode = "edit"

31
ruoyi-ui/src/views/JiHeExpressway/pages/control/device/strategy/components/TaskItem.vue

@ -14,19 +14,20 @@
</div>
<!-- <div>{{ editData.params }}</div> -->
<template v-if="editData.deviceType=='2'">
<BoardRecordPreview :tpl="editData.params" style="width:300px; height: 100%;"></BoardRecordPreview>
<BoardRecordPreview :tpl="editData.params" style=" width:300px; height: 100%;">
</BoardRecordPreview>
</template>
<template v-if="editData.deviceType == '5'">
</template>
<template v-if="editData.deviceType == '2'">
</template>
<template v-if="editData.deviceType == '2'">
</template>
<template v-if="editData.deviceType == '2'">
</template>
<el-form-item>
@ -36,7 +37,7 @@
</div>
</el-form>
<taskEditDialog v-model="isEditing" :groupId="groupId" :time="time" :deviceDic="deviceDic" :deviceList="deviceList"
<taskEditDialog v-model="isEditingTask" :groupId="groupId" :time="time" :deviceDic="deviceDic" :deviceList="deviceList"
:propData="editData" @onSubmit="onSubmit" />
</div>
@ -61,7 +62,7 @@ export default {
return {
isCompReady:false,
editData:{},
isEditing: false,
isEditingTask: false,
selectedType:"",
deviceTypeDic:"",
deviceDic:{},
@ -78,28 +79,28 @@ export default {
this.deviceTypeDic = deviceTypeDic;
this.initBasicData().then(res=>{
console.log(this.deviceDic);
let temp = JSON.parse(this.propData.callParameter);
let temp = JSON.parse(this.propData.callParameter)[0]; //callParameter
//BoardRecordPreview
temp.functions[1].params.CONTENT = temp.functions[1].params.CONTENT.replaceAll(/\\n/g, '\\\\n').replaceAll(/=/g, '\\=').replaceAll(/,/g, '\\,').replaceAll(/&nbsp/g, ' ');
this.editData = {
id: this.propData.id,
direction: temp.direction,
deviceType: temp.deviceType,
id: this.propData.jobId,
direction: temp.direction || temp.devices[0].direction,
deviceType: temp.deviceType || temp.devices[0].deviceType,
devices: temp.devices,
params: temp.functions[1].params,
screenSize: "160*80"
screenSize: temp.screenSize || temp.devices[0].screenSize || this.deviceDic[temp.devices[0].id].screenSize
};
console.log(this.editData , "+++======");
this.isCompReady = true;
})
},
methods: {
onModify(){
this.isEditing = true;
this.isEditingTask = true;
},
onSubmit(){
// this.isEditing = false;
this.isEditingTask = false;
// let devices = _.filter(this.deviceOptions, item=>{
// this.editData.devices.includes(item.id);
// })

9
ruoyi-ui/src/views/JiHeExpressway/pages/control/device/strategy/components/taskEditDialog.vue

@ -110,7 +110,7 @@
</el-form-item>
</el-form>
<BoardInfoEditor @afterSubmit="____onEditSubmit" :mode="editDialog.mode" :type="editDialog.type"
:visible.sync="editDialog.visible" :screenSize="this.propData.screenSize" :tpl="editDialog.tpl"></BoardInfoEditor>
:visible.sync="editDialog.visible" :screenSize="filterData.screenSize" :tpl="editDialog.tpl"></BoardInfoEditor>
</Dialog>
</template>
@ -212,7 +212,7 @@ export default {
onEditBoard(){
this.editDialog = {
visible: true,
mode: "edit",
mode: this.mode,
type: "device",
tpl:this.editData.type2
// {
@ -250,7 +250,6 @@ export default {
};
},
____onEditSubmit(data){
console.log(data.data);
this.editDialog.visible = false;
this.editData.type2 = data.data;
},
@ -260,7 +259,7 @@ export default {
this.deviceArr.forEach((item,index)=>{
if (this.editData.devices.includes(item.id)){
let temp = {
id: item.id,
jobId: item.id,
iotDeviceId: item.iotDeviceId,
deviceType: item.deviceType,
direction: item.direction
@ -277,7 +276,7 @@ export default {
if(this.mode == "add"){
}
addTaskRequest(devices, params, { jobGroup: this.groupId, time:this.time }).then(res=>{
addTaskRequest(devices, params, { deviceType: this.searchData.deviceType, screenSize: this.filterData.screenSize, jobGroup: this.groupId, time:this.time }).then(res=>{
console.log(res)
});
this.$emit("onSubmit")

176
ruoyi-ui/src/views/JiHeExpressway/pages/control/device/strategy/components/timeEditDialog.vue

@ -0,0 +1,176 @@
<template>
<Dialog v-model="modelVisible" title="修改" width="400px" label-width="120px">
<el-form>
<el-form-item label="触发时间">
<el-col :span="4">
<el-input v-model="editData.hour"></el-input>
</el-col>
<el-col :span="1">
:
</el-col>
<el-col :span="4">
<el-input v-model="editData.minute"></el-input>
</el-col>
<el-col :span="1">
:
</el-col>
<el-col :span="4">
<el-input v-model="editData.second"></el-input>
</el-col>
</el-form-item>
<el-form-item>
<el-button size="mini" type="primary" @click="onSubmit">保存</el-button>
</el-form-item>
</el-form>
</Dialog>
</template>
<script>
import Dialog from "@screen/components/Dialog/index.vue";
export default {
name: "timeEditDialog",
components: {
Dialog
},
model: {
prop: "visible",
event: "update:value",
},
props: {
visible: Boolean,
propData: Object
},
data() {
return {
editData:{
hour:"",
minute:"",
second:""
}
};
},
computed: {
modelVisible: {
get() {
return this.visible;
},
set(val) {
this.$emit("update:value", val);
},
},
},
watch: {
modelVisible: {
immediate: true,
handler(bool) {
if (!bool) return;
this.transformData();
},
},
},
mounted() {
},
methods: {
onSubmit(){
let time = [this.editData.hour.trim(), this.editData.minute.trim(), this.editData.second.trim()].join(":");
this.$emit("onSubmit", time)
},
transformData(){
let arr = this.propData.split(":");
this.editData.hour = arr[0];
this.editData.minute = arr[1];
this.editData.second = arr[2];
}
}
};
</script>
<style lang="scss" scoped>
.AddNEditDialog {
width: 100%;
display: flex;
flex-direction: column;
gap: 15px;
.tips {
font-size: 12px;
}
}
.task{
border: 1px solid #FFF;
.task_info{
}
.task_op{
}
}
.tplItem {
margin-right: 14px;
display: flex;
align-items: stretch;
padding-bottom: 10px;
.boardPreview {
border: 1px solid rgba(61, 232, 255, 0.5);
// width: 560px;
// height:80px;
flex: 1;
}
.infoBtnBox {
&.infoBtnBoxSm {
width: 60px;
}
width: 110px;
height: 80px;
display: flex;
margin-left: 10px;
/* // border: solid 1px #05afe3; */
border: 1px solid rgba(61, 232, 255, 0.5);
display: flex;
justify-content: space-around;
align-items: center;
.btn {
background-repeat: no-repeat;
background-size: 100% 100%;
width: 30px;
height: 30px;
&.btnApply {
background-image: url(~@/assets/jihe/images/button/toLeft.svg);
}
&.btnEdit {
background-image: url(~@/assets/jihe/images/button/edit.svg);
}
&.btnDelete {
background-image: url(~@/assets/jihe/images/button/delete.svg);
}
}
i {
font-size: 24px;
color: #666;
padding-left: 4px;
cursor: pointer;
caret-color: rgba(0, 0, 0, 0);
user-select: none;
}
i:hover {
color: #05afe3;
}
.disabledClass {
pointer-events: none;
cursor: auto !important;
color: #ccc;
}
}
}
</style>

22
ruoyi-ui/src/views/JiHeExpressway/pages/control/device/strategy/index.vue

@ -38,8 +38,11 @@
</div>
</template>
<template #button>
<Switcher class="switcher" :activeOption="activeOption" :value="item.status!='0'"
@change="(value) => handleSwitcherChange(value, item) " />
<!-- <Switcher class="switcher" :activeOption="activeOption"
@change="(value) => handleSwitcherChange(value, item) " /> -->
<el-switch v-model="item.status" active-color="#0BD" inactive-color="#999" active-value="1"
inactive-value="0" @change="(value) => handleSwitcherChange(value, item) ">
</el-switch>
<Button @click.native="() => onAddEdit(item)">
编辑
</Button>
@ -131,7 +134,20 @@ export default {
},
methods: {
async handleSwitcherChange(value, item) {
item.status == "1" ? item.status = "0" : item.status = "1" ;
// item.status == "1" ? item.status = "0" : item.status = "1" ;
request({
url: `/business/dcBatchFunctionsJobGroup`,
method: "PUT",
data: {
id:item.id,
status:value
},
})
.then((result) => {
item.status = result.data.status;
if (result.code != 200) return;
Message.success(`操作成功!`);
})
},
getSearchData() {
let params = {

9
ruoyi-ui/src/views/JiHeExpressway/utils/api/batch.js

@ -2,7 +2,7 @@
import request from '@/utils/request'
export function addTaskRequest(devices, params, others) {
let data = {
let temp = [{
...others,
devices: devices,
"functions": [
@ -11,7 +11,7 @@ export function addTaskRequest(devices, params, others) {
"params": {
"size": "65535",
"fileName": "play012.lst"
}
}
},
{
"functionId": "13",
@ -21,10 +21,13 @@ export function addTaskRequest(devices, params, others) {
"functionId": "1B",
"params": {
"fileId": "12"
}
}
}
]
}];
let data = {
callParameter: JSON.stringify(temp)
}
// console.log(JSON.stringify(data));
return request({

Loading…
Cancel
Save