From 63e85b111f7fec8d62bc9f6a6f9b89831a2ee815 Mon Sep 17 00:00:00 2001 From: hui <770260999@qq.com> Date: Mon, 22 Apr 2024 17:13:58 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E8=AE=BE=E5=A4=87=E7=AE=A1?= =?UTF-8?q?=E6=8E=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../strategy/components/AddNEditDialog.vue | 226 ++++++++---- .../device/strategy/components/TaskItem.vue | 111 ++++-- .../strategy/components/taskEditDialog.vue | 345 +++++++++++------- .../pages/control/device/strategy/index.vue | 34 +- .../views/JiHeExpressway/utils/api/batch.js | 39 ++ .../src/views/JiHeExpressway/utils/enum.js | 11 +- .../views/JiHeExpressway/utils/infoBoard.js | 30 ++ ruoyi-ui/vue.config.js | 6 +- 8 files changed, 536 insertions(+), 266 deletions(-) create mode 100644 ruoyi-ui/src/views/JiHeExpressway/utils/api/batch.js diff --git a/ruoyi-ui/src/views/JiHeExpressway/pages/control/device/strategy/components/AddNEditDialog.vue b/ruoyi-ui/src/views/JiHeExpressway/pages/control/device/strategy/components/AddNEditDialog.vue index a42214a6..8414a004 100644 --- a/ruoyi-ui/src/views/JiHeExpressway/pages/control/device/strategy/components/AddNEditDialog.vue +++ b/ruoyi-ui/src/views/JiHeExpressway/pages/control/device/strategy/components/AddNEditDialog.vue @@ -1,37 +1,57 @@ @@ -43,8 +63,8 @@ import Form from "@screen/components/FormConfig"; import request from "@/utils/request"; import { Message } from "element-ui"; import { addEditFormList } from "./../data"; -import { stakeMarkToArray, findPathIdByTreeId } from "@screen/utils/index.js"; +import taskEditDialog from "./taskEditDialog.vue"; import TaskItem from "./TaskItem.vue"; export default { @@ -53,7 +73,8 @@ export default { Dialog, Button, Form, - TaskItem + TaskItem, + taskEditDialog }, model: { prop: "visible", @@ -61,37 +82,31 @@ export default { }, props: { visible: Boolean, - data: Object, - dataAll: Array, + propData: { + type: Object, + default: ()=>{} + }, }, data() { + let gNameValidator = (rule, value, callback)=>{ + if (value.trim().length<=0){ + return callback(new Error('请输入任务组名称')); + } + }; return { + editData:{}, + mode:"", + isEditing:false, + group:{}, submitting: false, - formData: {}, formList: addEditFormList, - formStrategy:[ - - { - time:"gdfsfds", - content:[ - { - type:"5", - devices:[""], - options:{ - - } - }, - { - type: "2", - devices: [""], - options: { - - } - } - ] - } - - ] + taskGroupsEditing:[], + selectedTaskGroup:{}, + groupBasicRules:{ + groupName: [ + { validator: gNameValidator, trigger: 'blur' } + ], + } }; }, computed: { @@ -110,12 +125,13 @@ export default { handler(bool) { if (!bool) return; - this.formData = !this.data - ? {} - : { - ...this.data, - }; - this.testGetData(); + // this.propData = !this.propData + // ? {} + // : { + // ...this.propData, + // }; + this.initEditingData(); + this.getTaskList(); }, }, }, @@ -132,51 +148,102 @@ export default { // }); }, methods: { + onSubmitTaskItem(){ + this.getTaskList(); //新增task后自动刷新任务列表 + }, + onAddTaskGroup(){ + this.taskGroupsEditing.push({time:"08:00:00",tasks:[1,2,3]}); + }, + onAddTaskItem(taskG){ + this.selectedTaskGroup = taskG; + this.isEditing = true; + }, onModifyItem(newV , oldV){ console.log(newV, oldV , "修改条目》》》") // oldV.devices }, - testGetData(){ + initEditingData(){ + if(this.propData?.id){ + this.mode = "edit" + this.editData = { + id: this.propData.id, + groupName : this.propData.groupName, + status: this.propData.status, + remark: this.propData.remark, + detailedConfiguration: this.propData.detailedConfiguration + } + } else { + this.mode = "add" + this.editData = { + groupName: "任务组AAA", + status: "1", + remark: "", + detailedConfiguration: "" + } + } + + }, + getTaskList(){ + // 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 + // 测试代码结束 + request({ url: `/business/dcBatchFunctionsJob/query`, method: "GET", params: { - jobGroup: 0 + 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.id)}); + item.tasksEdit = arr; + }); }) }, - checkRepeat(word) { - let temp = _.find(this.dataAll, { word: word }); - if ( - temp && - Object.keys(temp).length > 0 && - !(this.data && this.data.id == temp.id) - ) { - this.$message.error("该关键词已存在。"); - return false; - } else { - return true; - } - }, - handleSubmit() { - this.$refs.FormConfigRef.validate().then((data) => { - data.word = data.word.trim(); - + onSaveTaskGroup() { + this.$refs.basicInfoForm.validate().then((result) => { + if (!result){ + return ; + } + this.editData.groupName = this.editData.groupName.trim(); + this.editData.remark = this.editData.remark.trim(); + this.submitting = true; - if (this.data) data.id = this.data.id; - - // if (!this.checkRepeat(data.word)) { - // return; - // } + + //测试数据开始 + this.$set(this.editData, "id", 11); + this.submitting = false; + return + //测试数据结束 request({ - url: `/business/dcInfoBoardVocabulary`, - method: this.data ? "PUT" : "POST", - data, + url: `/business/dcBatchFunctionsJobGroup`, + method: this.mode=="edit" ? "PUT" : "POST", + data: this.editData, }) .then((result) => { if (result.code != 200) return; @@ -184,7 +251,6 @@ export default { Message.success(`提交成功!`); this.$emit("onSuccess"); - this.modelVisible = false; }) .catch((err) => { console.log( diff --git a/ruoyi-ui/src/views/JiHeExpressway/pages/control/device/strategy/components/TaskItem.vue b/ruoyi-ui/src/views/JiHeExpressway/pages/control/device/strategy/components/TaskItem.vue index 4e5b8c51..d0dafe15 100644 --- a/ruoyi-ui/src/views/JiHeExpressway/pages/control/device/strategy/components/TaskItem.vue +++ b/ruoyi-ui/src/views/JiHeExpressway/pages/control/device/strategy/components/TaskItem.vue @@ -1,41 +1,71 @@