|
|
@ -1,65 +1,122 @@ |
|
|
|
<template> |
|
|
|
<Dialog v-model="modelVisible" :title="propData.id ? '修改' : '新增'" width="1400px"> |
|
|
|
<Dialog |
|
|
|
v-model="modelVisible" |
|
|
|
:title="propData.id ? '修改' : '新增'" |
|
|
|
width="1400px" |
|
|
|
> |
|
|
|
<div class="AddNEditDialog"> |
|
|
|
<!-- <Form :value="propData" class="form" ref="basicInfoForm" :formList="formList" column="1" labelWidth="80px" /> --> |
|
|
|
<el-form ref="basicInfoForm" :model="editData" label-width="80px" :rules="groupBasicRules"> |
|
|
|
<el-form |
|
|
|
ref="basicInfoForm" |
|
|
|
:model="editData" |
|
|
|
label-width="80px" |
|
|
|
:rules="groupBasicRules" |
|
|
|
> |
|
|
|
<el-form-item label="名称" prop="groupName"> |
|
|
|
<el-input v-model="editData.groupName" placeholder="任务组名称"></el-input> |
|
|
|
<el-input |
|
|
|
v-model="editData.groupName" |
|
|
|
placeholder="任务组名称" |
|
|
|
></el-input> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item label="描述" prop="remark"> |
|
|
|
<el-input v-model="editData.remark" placeholder="任务组描述"></el-input> |
|
|
|
<el-input |
|
|
|
v-model="editData.remark" |
|
|
|
placeholder="任务组描述" |
|
|
|
></el-input> |
|
|
|
</el-form-item> |
|
|
|
<!-- <el-form-item label="状态" prop="status"> |
|
|
|
<el-switch v-model="editData.status" active-value="1" inactive-value="0"></el-switch> |
|
|
|
</el-form-item> --> |
|
|
|
<div style="display: flex; justify-content: flex-end;"> |
|
|
|
<el-button @click="(modelVisible = false), (submitting = false)" type="info" size="lg"> |
|
|
|
<div style="display: flex; justify-content: flex-end"> |
|
|
|
<el-button |
|
|
|
@click="(modelVisible = false), (submitting = false)" |
|
|
|
type="info" |
|
|
|
size="lg" |
|
|
|
> |
|
|
|
取消 |
|
|
|
</el-button> |
|
|
|
<el-button type="primary" @click="onSaveTaskGroup('basicInfoForm')" :loading="submitting" size="lg"> 提交 |
|
|
|
<el-button |
|
|
|
type="primary" |
|
|
|
@click="onSaveTaskGroup('basicInfoForm')" |
|
|
|
:loading="submitting" |
|
|
|
size="lg" |
|
|
|
> |
|
|
|
提交 |
|
|
|
</el-button> |
|
|
|
</div> |
|
|
|
</el-form> |
|
|
|
<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="all_groups"> |
|
|
|
|
|
|
|
<div class="task_group" v-for="taskGroup,index in taskGroupsEditing"> |
|
|
|
<div |
|
|
|
class="task_group" |
|
|
|
v-for="(taskGroup, index) in taskGroupsEditing" |
|
|
|
> |
|
|
|
<div class="fl-around task_info"> |
|
|
|
<div class="time_show"> |
|
|
|
<el-input placeholder="请输入内容" v-model="taskGroup.time" style="width: 180px;" disabled> |
|
|
|
<el-input |
|
|
|
placeholder="请输入内容" |
|
|
|
v-model="taskGroup.time" |
|
|
|
style="width: 180px" |
|
|
|
disabled |
|
|
|
> |
|
|
|
</el-input> |
|
|
|
<i class="icon el-icon-edit-outline" @click='onModifyTime(taskGroup)'></i> |
|
|
|
<i |
|
|
|
class="icon el-icon-edit-outline" |
|
|
|
@click="onModifyTime(taskGroup)" |
|
|
|
></i> |
|
|
|
</div> |
|
|
|
<div class="fl-around task_op"> |
|
|
|
<el-button size="mini" type="primary" @click="onAddTaskItem(taskGroup)">新增子任务</el-button> |
|
|
|
<el-button size="mini" type="danger" @click="onDeleteTaskGroup(taskGroup)">删除任务组</el-button> |
|
|
|
<el-button |
|
|
|
size="mini" |
|
|
|
type="primary" |
|
|
|
@click="onAddTaskItem(taskGroup)" |
|
|
|
>新增子任务</el-button |
|
|
|
> |
|
|
|
<el-button |
|
|
|
size="mini" |
|
|
|
type="danger" |
|
|
|
@click="onDeleteTaskGroup(taskGroup)" |
|
|
|
>删除任务组</el-button |
|
|
|
> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div> |
|
|
|
<!-- <p v-for="item, index1 in taskGroup.tasksEdit">{{ item }}</p> --> |
|
|
|
<TaskItem v-for="item, index1 in taskGroup.tasksEdit" :propData="item" :groupId="propData.id" |
|
|
|
:time="taskGroup.time" @onSubmit="onSubmitTaskItem"> |
|
|
|
<TaskItem |
|
|
|
v-for="(item, index1) in taskGroup.tasksEdit" |
|
|
|
:propData="item" |
|
|
|
:groupId="propData.id" |
|
|
|
:time="taskGroup.time" |
|
|
|
@onSubmit="onSubmitTaskItem" |
|
|
|
> |
|
|
|
</TaskItem> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
|
|
|
|
</div> |
|
|
|
</template> |
|
|
|
</div> |
|
|
|
|
|
|
|
<template #footer> |
|
|
|
|
|
|
|
</template> |
|
|
|
<template #footer> </template> |
|
|
|
|
|
|
|
<taskEditDialog v-model="isEditing" :groupId="editData.id" :time="selectedTaskGroup.time" :propData="{}" |
|
|
|
@onSubmit="onSubmitTaskItem" /> |
|
|
|
|
|
|
|
<timeEditDialog v-model="isShowTimeEdit" :propData="editingTime" @onSubmit="onSubmitTime" /> |
|
|
|
<taskEditDialog |
|
|
|
v-model="isEditing" |
|
|
|
:groupId="editData.id" |
|
|
|
:time="selectedTaskGroup.time" |
|
|
|
:propData="{}" |
|
|
|
@onSubmit="onSubmitTaskItem" |
|
|
|
/> |
|
|
|
|
|
|
|
<timeEditDialog |
|
|
|
v-model="isShowTimeEdit" |
|
|
|
:propData="editingTime" |
|
|
|
@onSubmit="onSubmitTime" |
|
|
|
/> |
|
|
|
</Dialog> |
|
|
|
</template> |
|
|
|
|
|
|
@ -84,7 +141,7 @@ export default { |
|
|
|
Form, |
|
|
|
TaskItem, |
|
|
|
taskEditDialog, |
|
|
|
timeEditDialog |
|
|
|
timeEditDialog, |
|
|
|
}, |
|
|
|
model: { |
|
|
|
prop: "visible", |
|
|
@ -94,33 +151,33 @@ export default { |
|
|
|
visible: Boolean, |
|
|
|
propData: { |
|
|
|
type: Object, |
|
|
|
default: ()=>{} |
|
|
|
}, |
|
|
|
default: () => {}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
data() { |
|
|
|
let gNameValidator = (rule, value, callback)=>{ |
|
|
|
return callback(new Error('请输入任务组名称')); |
|
|
|
let gNameValidator = (rule, value, callback) => { |
|
|
|
return callback(new Error("请输入任务组名称")); |
|
|
|
// if (value.trim().length<=0){ |
|
|
|
// return callback(new Error('请输入任务组名称')); |
|
|
|
// } |
|
|
|
}; |
|
|
|
return { |
|
|
|
editingTime:"", |
|
|
|
editData:{}, |
|
|
|
mode:"", |
|
|
|
isEditing:false, |
|
|
|
isShowTimeEdit:false, |
|
|
|
group:{}, |
|
|
|
editingTime: "", |
|
|
|
editData: {}, |
|
|
|
mode: "", |
|
|
|
isEditing: false, |
|
|
|
isShowTimeEdit: false, |
|
|
|
group: {}, |
|
|
|
submitting: false, |
|
|
|
formList: addEditFormList, |
|
|
|
taskGroupsEditing:[], |
|
|
|
selectedTaskGroup:{}, |
|
|
|
groupBasicRules:{ |
|
|
|
taskGroupsEditing: [], |
|
|
|
selectedTaskGroup: {}, |
|
|
|
groupBasicRules: { |
|
|
|
groupName: [ |
|
|
|
// { validator: gNameValidator, trigger: 'blur' } |
|
|
|
{ required: true, message: '请输入活动名称', trigger: 'blur' }, |
|
|
|
{ required: true, message: "请输入活动名称", trigger: "blur" }, |
|
|
|
], |
|
|
|
} |
|
|
|
}, |
|
|
|
}; |
|
|
|
}, |
|
|
|
computed: { |
|
|
@ -152,7 +209,6 @@ export default { |
|
|
|
}, |
|
|
|
}, |
|
|
|
mounted() { |
|
|
|
|
|
|
|
// "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890".split('').forEach(item => { |
|
|
|
// request({ |
|
|
|
// url: `/business/dcInfoBoardVocabulary`, |
|
|
@ -164,115 +220,115 @@ export default { |
|
|
|
// }); |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
onSubmitTaskItem(){ |
|
|
|
onSubmitTaskItem() { |
|
|
|
this.isEditing = false; |
|
|
|
this.selectedTaskGroup = {}; |
|
|
|
console.log("onSubmitTaskItemonSubmitTaskItemonSubmitTaskItem"); |
|
|
|
request({ |
|
|
|
url: `/business/dcBatchFunctionsJobGroup/${this.editData.id}`, |
|
|
|
method: "GET" |
|
|
|
}).then(res=>{ |
|
|
|
method: "GET", |
|
|
|
}).then((res) => { |
|
|
|
this.editData = { |
|
|
|
id: res.data.id, |
|
|
|
groupName: res.data.groupName, |
|
|
|
// status: res.data.status, |
|
|
|
remark: res.data.remark, |
|
|
|
detailedConfiguration: res.data.detailedConfiguration |
|
|
|
} |
|
|
|
this.getTaskList(); //新增task后自动刷新任务列表 |
|
|
|
detailedConfiguration: res.data.detailedConfiguration, |
|
|
|
}; |
|
|
|
this.getTaskList(); //新增task后自动刷新任务列表 |
|
|
|
}); |
|
|
|
}, |
|
|
|
onAddTaskGroup(){ |
|
|
|
onAddTaskGroup() { |
|
|
|
this.isShowTimeEdit = true; |
|
|
|
}, |
|
|
|
onModifyTime(taskG){ |
|
|
|
onModifyTime(taskG) { |
|
|
|
this.editingTime = taskG.time; |
|
|
|
this.selectedTaskGroup = taskG; |
|
|
|
this.isShowTimeEdit = true; |
|
|
|
}, |
|
|
|
onDeleteTaskGroup(taskG){ |
|
|
|
onDeleteTaskGroup(taskG) { |
|
|
|
this.$confirm("确定要删除该任务组么?", "操作确认", { |
|
|
|
confirmButtonText: "确定", |
|
|
|
cancelButtonText: "取消", |
|
|
|
type: "warning", |
|
|
|
}).then(() => { |
|
|
|
|
|
|
|
request({ |
|
|
|
url: `/business/dcBatchFunctionsJob/time/${this.editData.id}/${taskG.time}`, |
|
|
|
method: "DELETE" |
|
|
|
}).then(res => { |
|
|
|
}) |
|
|
|
.then(() => { |
|
|
|
request({ |
|
|
|
url: `/business/dcBatchFunctionsJobGroup/${this.editData.id}`, |
|
|
|
method: "GET" |
|
|
|
}).then(res => { |
|
|
|
this.editData = { |
|
|
|
id: res.data.id, |
|
|
|
groupName: res.data.groupName, |
|
|
|
// status: res.data.status, |
|
|
|
remark: res.data.remark, |
|
|
|
detailedConfiguration: res.data.detailedConfiguration |
|
|
|
} |
|
|
|
this.getTaskList(); //新增task后自动刷新任务列表 |
|
|
|
url: `/business/dcBatchFunctionsJob/time/${this.editData.id}/${taskG.time}`, |
|
|
|
method: "DELETE", |
|
|
|
}).then((res) => { |
|
|
|
request({ |
|
|
|
url: `/business/dcBatchFunctionsJobGroup/${this.editData.id}`, |
|
|
|
method: "GET", |
|
|
|
}).then((res) => { |
|
|
|
this.editData = { |
|
|
|
id: res.data.id, |
|
|
|
groupName: res.data.groupName, |
|
|
|
// status: res.data.status, |
|
|
|
remark: res.data.remark, |
|
|
|
detailedConfiguration: res.data.detailedConfiguration, |
|
|
|
}; |
|
|
|
this.getTaskList(); //新增task后自动刷新任务列表 |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
}) |
|
|
|
.catch(() => { |
|
|
|
this.$message.warn("取消删除。"); |
|
|
|
}); |
|
|
|
}, |
|
|
|
onSubmitTime(time){ |
|
|
|
onSubmitTime(time) { |
|
|
|
this.isShowTimeEdit = false; |
|
|
|
if (Object.keys(this.selectedTaskGroup).length>0){ |
|
|
|
if (Object.keys(this.selectedTaskGroup).length > 0) { |
|
|
|
this.selectedTaskGroup.time = time; |
|
|
|
this.selectedTaskGroup = {}; |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
this.taskGroupsEditing.push({ time, tasks: [] }); |
|
|
|
} |
|
|
|
|
|
|
|
let detailedConfiguration =[]; |
|
|
|
this.taskGroupsEditing.forEach(item=>{ |
|
|
|
detailedConfiguration.push({time:item.time, tasks:_.map(item.tasksEdit, "jobId")}); |
|
|
|
let detailedConfiguration = []; |
|
|
|
this.taskGroupsEditing.forEach((item) => { |
|
|
|
detailedConfiguration.push({ |
|
|
|
time: item.time, |
|
|
|
tasks: _.map(item.tasksEdit, "jobId"), |
|
|
|
}); |
|
|
|
}); |
|
|
|
request({ |
|
|
|
url: `/business/dcBatchFunctionsJobGroup`, |
|
|
|
method: "PUT", |
|
|
|
data: { |
|
|
|
id: this.editData.id, |
|
|
|
detailedConfiguration: JSON.stringify(detailedConfiguration) |
|
|
|
detailedConfiguration: JSON.stringify(detailedConfiguration), |
|
|
|
}, |
|
|
|
}) |
|
|
|
.then((result) => { |
|
|
|
if (result.code != 200) return; |
|
|
|
Message.success(`提交成功!`); |
|
|
|
}) |
|
|
|
}).then((result) => { |
|
|
|
if (result.code != 200) return; |
|
|
|
Message.success(`提交成功!`); |
|
|
|
}); |
|
|
|
}, |
|
|
|
onAddTaskItem(taskG){ |
|
|
|
onAddTaskItem(taskG) { |
|
|
|
this.selectedTaskGroup = taskG; |
|
|
|
this.isEditing = true; |
|
|
|
}, |
|
|
|
initEditingData(){ |
|
|
|
if(this.propData?.id){ |
|
|
|
this.mode = "edit" |
|
|
|
initEditingData() { |
|
|
|
if (this.propData?.id) { |
|
|
|
this.mode = "edit"; |
|
|
|
this.editData = { |
|
|
|
id: this.propData.id, |
|
|
|
groupName : this.propData.groupName, |
|
|
|
groupName: this.propData.groupName, |
|
|
|
// status: this.propData.status, |
|
|
|
remark: this.propData.remark, |
|
|
|
detailedConfiguration: this.propData.detailedConfiguration |
|
|
|
} |
|
|
|
detailedConfiguration: this.propData.detailedConfiguration, |
|
|
|
}; |
|
|
|
} else { |
|
|
|
this.mode = "add" |
|
|
|
this.mode = "add"; |
|
|
|
this.editData = { |
|
|
|
groupName: "", |
|
|
|
// status: "1", |
|
|
|
remark: "", |
|
|
|
detailedConfiguration: "" |
|
|
|
} |
|
|
|
detailedConfiguration: "", |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
getTaskList(){ |
|
|
|
getTaskList() { |
|
|
|
this.taskGroupsEditing = JSON.parse(this.editData.detailedConfiguration); |
|
|
|
// this.taskGroupsEditing = [{time:"08:00:00",tasks:[1],tasksEdit:[]}]; |
|
|
|
|
|
|
@ -295,45 +351,46 @@ export default { |
|
|
|
url: `/business/dcBatchFunctionsJob/query`, |
|
|
|
method: "GET", |
|
|
|
params: { |
|
|
|
jobGroup: this.propData.id |
|
|
|
jobGroup: this.propData.id, |
|
|
|
}, |
|
|
|
}) |
|
|
|
.then((result) => { |
|
|
|
if (result.code != 200) return; |
|
|
|
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.jobId)}); |
|
|
|
this.$set(item, "tasksEdit", arr); |
|
|
|
// item.tasksEdit = arr; |
|
|
|
}).then((result) => { |
|
|
|
if (result.code != 200) return; |
|
|
|
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.jobId); |
|
|
|
}); |
|
|
|
}) |
|
|
|
this.$set(item, "tasksEdit", arr); |
|
|
|
// item.tasksEdit = arr; |
|
|
|
}); |
|
|
|
}); |
|
|
|
}, |
|
|
|
onSaveTaskGroup(formName) { |
|
|
|
this.$refs[formName].validate(valid => { |
|
|
|
if (!valid){ |
|
|
|
return ; |
|
|
|
this.$refs[formName].validate((valid) => { |
|
|
|
if (!valid) { |
|
|
|
return; |
|
|
|
} |
|
|
|
this.editData.groupName = this.editData.groupName.trim(); |
|
|
|
this.editData.remark = this.editData.remark.trim(); |
|
|
|
|
|
|
|
|
|
|
|
this.submitting = true; |
|
|
|
|
|
|
|
|
|
|
|
//测试数据开始 |
|
|
|
// this.$set(this.editData, "id", 11); |
|
|
|
// this.submitting = false; |
|
|
|
// return |
|
|
|
//测试数据结束 |
|
|
|
|
|
|
|
|
|
|
|
request({ |
|
|
|
url: `/business/dcBatchFunctionsJobGroup`, |
|
|
|
method: this.mode=="edit" ? "PUT" : "POST", |
|
|
|
method: this.mode == "edit" ? "PUT" : "POST", |
|
|
|
data: this.editData, |
|
|
|
}) |
|
|
|
.then((result) => { |
|
|
@ -342,8 +399,7 @@ export default { |
|
|
|
Message.success(`提交成功!`); |
|
|
|
this.$emit("onSuccess"); |
|
|
|
this.editData = { ...result.data }; |
|
|
|
this.mode = "edit" |
|
|
|
|
|
|
|
this.mode = "edit"; |
|
|
|
}) |
|
|
|
.catch((err) => { |
|
|
|
console.log( |
|
|
@ -373,19 +429,20 @@ export default { |
|
|
|
font-size: 12px; |
|
|
|
} |
|
|
|
} |
|
|
|
.all_groups{ |
|
|
|
border: 1px solid #09B; |
|
|
|
max-height:500px; |
|
|
|
.all_groups { |
|
|
|
border: 1px solid #09b; |
|
|
|
max-height: 500px; |
|
|
|
overflow-y: scroll; |
|
|
|
} |
|
|
|
.task_group{ |
|
|
|
.task_info{ |
|
|
|
padding:10px; background: #004050; |
|
|
|
.time_show{ |
|
|
|
color: #0AC; |
|
|
|
.task_group { |
|
|
|
.task_info { |
|
|
|
padding: 10px; |
|
|
|
background: #004050; |
|
|
|
.time_show { |
|
|
|
color: #0ac; |
|
|
|
} |
|
|
|
} |
|
|
|
.task_op{ |
|
|
|
} |
|
|
|
} |
|
|
|
.task_op { |
|
|
|
} |
|
|
|
} |
|
|
|
</style> |
|
|
|