diff --git a/src/views/farm/area/index.vue b/src/views/farm/area/index.vue index bbf8949..d56c38a 100644 --- a/src/views/farm/area/index.vue +++ b/src/views/farm/area/index.vue @@ -66,7 +66,7 @@ - + diff --git a/src/views/farm/crop/index.vue b/src/views/farm/crop/index.vue index 376855b..539c601 100644 --- a/src/views/farm/crop/index.vue +++ b/src/views/farm/crop/index.vue @@ -36,9 +36,8 @@ @@ -192,6 +191,7 @@ export default { if (!valid) { return; } + this.judgePictureExists(); // 修改的提交 if (this.form.id != null) { updateCrop(this.form).then(response => { @@ -209,6 +209,24 @@ export default { }); }); }, + /*判断图片是否存在*/ + judgePictureExists(){ + if (this.form.id != null) { + if (this.form.images == "") { + this.form.images = []; + }else{ + let imagesType = typeof(this.form.images); + if (imagesType == "string") { + let imgArr = this.form.images.split(",") + this.form.images = imgArr; + } + } + return; + } + if (this.form.images == undefined || this.form.images =="") { + this.form.images = []; + } + }, /** 删除按钮操作 */ handleDelete(row) { const id = row.id; diff --git a/src/views/farm/discuss/index.vue b/src/views/farm/discuss/index.vue index c1fb3ab..f9dfb16 100644 --- a/src/views/farm/discuss/index.vue +++ b/src/views/farm/discuss/index.vue @@ -40,8 +40,9 @@ @@ -254,6 +255,7 @@ export default { if (!valid) { return; } + this.judgePictureExists(); // 修改的提交 if (this.form.id != null) { updateDiscuss(this.form).then(response => { @@ -271,6 +273,24 @@ export default { }); }); }, + /*判断图片是否存在*/ + judgePictureExists(){ + if (this.form.id != null) { + if (this.form.images == "") { + this.form.images = []; + }else{ + let imagesType = typeof(this.form.images); + if (imagesType == "string") { + let imgArr = this.form.images.split(",") + this.form.images = imgArr; + } + } + return; + } + if (this.form.images == undefined || this.form.images =="") { + this.form.images = []; + } + }, /** 删除按钮操作 */ handleDelete(row) { const id = row.id; diff --git a/src/views/farm/event/index.vue b/src/views/farm/event/index.vue index 391134e..bd66d62 100644 --- a/src/views/farm/event/index.vue +++ b/src/views/farm/event/index.vue @@ -38,14 +38,26 @@ - - + + + + + + + + + @@ -70,7 +82,6 @@ - - - @@ -117,7 +126,7 @@ import ImageUpload from '@/components/ImageUpload'; import Editor from '@/components/Editor'; import { getProjectPage } from "@/api/farm/project"; import { getTaskPage } from "@/api/farm/task"; - +import {getTaskCatePage} from "@/api/farm/taskCate"; export default { name: "Event", @@ -163,18 +172,33 @@ export default { projectList:[], projectId:'', taskId:'', + taskCateList:[] }; }, created() { this.getProject(); + this.getTaskCate(); }, methods: { + taskConvert(task){ + let taskArr = this.taskList.filter(t => t.id == task)[0]; + let taskTypeName = ""; + let taskName = ""; + this.taskCateList.forEach(cate =>{ + if (cate.id == taskArr.taskCateId) { + taskTypeName = cate.name; + } + if (cate.id == taskArr.taskCateName) { + taskName = cate.name; + } + }) + return taskTypeName + "/" +taskName; + }, /*获取项目列表*/ getProject(){ getProjectPage({ pageNo: 1, - pageSize: 10, - name: null, + pageSize: 100, }).then(res=>{ this.projectList = res.data.list; this.getTask(); @@ -184,13 +208,20 @@ export default { getTask(){ getTaskPage({ pageNo: 1, - pageSize: 10, - name: null, + pageSize: 100, }).then(res=>{ this.taskList = res.data.list; this.getList(); }) }, + getTaskCate(){ + getTaskCatePage({ + pageNo: 1, + pageSize: 100, + }).then(res =>{ + this.taskCateList = res.data.list; + }) + }, /** 查询列表 */ getList() { @@ -201,20 +232,20 @@ export default { // 执行查询 getEventPage(params).then(response => { - //循环遍历List - response.data.list.forEach(eve => { - //循环对比 project - this.projectList.forEach(project =>{ - if(project.id == eve.projectId){ - eve.projectId = project.name; - } - }); - this.taskList.forEach(task =>{ - if (task.id == eve.taskId) { - eve.taskId = task.name; - } - }) - }); + // //循环遍历List + // response.data.list.forEach(eve => { + // //循环对比 project + // this.projectList.forEach(project =>{ + // if(project.id == eve.projectId){ + // eve.projectId = project.name; + // } + // }); + // this.taskList.forEach(task =>{ + // if (task.id == eve.taskId) { + // eve.taskId = task.name; + // } + // }) + // }); this.list = response.data.list; this.total = response.data.total; @@ -297,6 +328,7 @@ export default { if (!valid) { return; } + this.judgePictureExists(); // 修改的提交 if (this.form.id != null) { updateEvent(this.form).then(response => { @@ -314,6 +346,24 @@ export default { }); }); }, + /*判断图片是否存在*/ + judgePictureExists(){ + if (this.form.id != null) { + if (this.form.images == "") { + this.form.images = []; + }else{ + let imagesType = typeof(this.form.images); + if (imagesType == "string") { + let imgArr = this.form.images.split(",") + this.form.images = imgArr; + } + } + return; + } + if (this.form.images == undefined || this.form.images =="") { + this.form.images = []; + } + }, /** 删除按钮操作 */ handleDelete(row) { const id = row.id; diff --git a/src/views/farm/project/index.vue b/src/views/farm/project/index.vue index 0e37a32..e72f247 100644 --- a/src/views/farm/project/index.vue +++ b/src/views/farm/project/index.vue @@ -55,10 +55,9 @@ - @@ -66,19 +65,16 @@ {{cropList.find(t=>t.id == scope.row.cropId ).name}} - - - - @@ -376,7 +372,7 @@ export default { if (!valid) { return; } - + this.judgePictureExists(); // 修改的提交 if (this.form.id != null) { updateProject(this.form).then(response => { @@ -394,6 +390,24 @@ export default { }); }); }, + /*判断图片是否存在*/ + judgePictureExists(){ + if (this.form.id != null) { + if (this.form.images == "") { + this.form.images = []; + }else{ + let imagesType = typeof(this.form.images); + if (imagesType == "string") { + let imgArr = this.form.images.split(",") + this.form.images = imgArr; + } + } + return; + } + if (this.form.images == undefined || this.form.images =="") { + this.form.images = []; + } + }, /** 删除按钮操作 */ handleDelete(row) { const id = row.id; diff --git a/src/views/farm/resource/index.vue b/src/views/farm/resource/index.vue index b6f8808..82f4dd9 100644 --- a/src/views/farm/resource/index.vue +++ b/src/views/farm/resource/index.vue @@ -61,9 +61,7 @@ @@ -119,10 +117,10 @@ - + - + @@ -184,6 +182,10 @@ export default { form: {}, // 表单校验 rules: { + resourceType: [{ required: true, message: "资源类型不能为空", trigger: "blur" }], + name: [{ required: true, message: "资源名称不能为空", trigger: "blur" }], + validityStartTime: [{ required: true, message: "有效期开始不能为空", trigger: "blur" }], + validityEndTime: [{ required: true, message: "有效期结束不能为空", trigger: "blur" }], }, resourceTypeList:[] }; @@ -193,7 +195,6 @@ export default { this.getList(); }, methods: { - /** 查询列表 */ getList() { this.loading = true; @@ -269,10 +270,12 @@ export default { }, /** 提交按钮 */ submitForm() { + console.log("农场资源提交信息", this.form); this.$refs["form"].validate(valid => { if (!valid) { return; } + this.judgePictureExists(); // 修改的提交 if (this.form.id != null) { updateResource(this.form).then(response => { @@ -290,6 +293,21 @@ export default { }); }); }, + /*判断图片是否存在*/ + judgePictureExists(){ + if (this.form.id != null) { + if (this.form.images == "") { + this.form.images = []; + }else{ + let imgArr = this.form.images.split(",") + this.form.images = imgArr; + } + return; + } + if (this.form.images == undefined) { + this.form.images = []; + } + }, /** 删除按钮操作 */ handleDelete(row) { const id = row.id; diff --git a/src/views/farm/task/index.vue b/src/views/farm/task/index.vue index 8c6463a..5dee9dd 100644 --- a/src/views/farm/task/index.vue +++ b/src/views/farm/task/index.vue @@ -298,7 +298,6 @@ export default { cateOneList: [], cateTwoList: [], - formR: {}, areasList: [], assemAreaList: [], @@ -318,13 +317,15 @@ export default { methods: { executorPersonConvert(executorPerson){ let executorPersonName = ""; - executorPerson.forEach(person => { - this.cpUserList.forEach( user => { - if (person == user.id) { - executorPersonName += user.name + "\n"; - } + if (executorPerson != null) { + executorPerson.forEach(person => { + this.cpUserList.forEach( user => { + if (person == user.id) { + executorPersonName += user.name + "\n"; + } + }) }) - }) + } return executorPersonName; }, areaConvert(area){ @@ -339,7 +340,6 @@ export default { }) return areaMsg; } - }, resouceConvert(resources){ let resouceMsg = ""; @@ -442,16 +442,6 @@ export default { this.addBeginAndEndTime(params, this.dateRangeCreateTime, 'createTime'); // 执行查询 getTaskPage(params).then(response => { - //1 循环list - response.data.list.forEach(element => { - if (element.images != null) { - //有图片转json - element.images = JSON.parse(element.images); - } else { - //无图片给个空 - element.images = []; - } - }); this.list = response.data.list; this.total = response.data.total; this.loading = false; @@ -468,13 +458,6 @@ export default { this.addBeginAndEndTime(params, this.dateRangeCreateTime, 'createTime'); // 执行查询 getTaskSearchPage(params).then(response => { - response.data.list.forEach(element => { - if (element.images != null) { - element.images = JSON.parse(element.images); - } else { - element.images = []; - } - }); this.list = response.data.list; this.total = response.data.total; this.loading = false; @@ -535,10 +518,6 @@ export default { const id = row.id; getTask(id).then(response => { this.form = response.data; - if (response.data.images != null) { - let imagesArr = JSON.parse(response.data.images); - this.form.images = imagesArr; - } this.open = true; this.title = "修改农场任务"; }); @@ -550,15 +529,8 @@ export default { if (!valid) { return; } - //图片转json - let im = this.form.images; - this.form.images = JSON.stringify(""); - if (im) { - //不为空 - let imgArr = im.split(",") - this.form.images = JSON.stringify(imgArr); - } + this.judgePictureExists(); // 修改的提交 if (this.form.id != null) { updateTask(this.form).then(response => { @@ -576,6 +548,24 @@ export default { }); }); }, + /*判断图片是否存在*/ + judgePictureExists(){ + if (this.form.id != null) { + if (this.form.images == "") { + this.form.images = []; + }else{ + let imagesType = typeof(this.form.images); + if (imagesType == "string") { + let imgArr = this.form.images.split(",") + this.form.images = imgArr; + } + } + return; + } + if (this.form.images == undefined || this.form.images =="") { + this.form.images = []; + } + }, /** 删除按钮操作 */ handleDelete(row) { const id = row.id; @@ -643,7 +633,7 @@ export default { changeProject(row) { this.form.areas = null; this.assemArea(); - let projectArea = JSON.parse(this.projectList.filter(project => project.id == row)[0].areas); + let projectArea = this.projectList.filter(project => project.id == row)[0].areas; let filterArr = []; this.assemAreaList.forEach(t => { projectArea.forEach(a => {