Browse Source

页面流程修改

master
zhanyunjiu 3 years ago
parent
commit
9c558bed9a
  1. 190
      src/views/farm/discuss/index.vue
  2. 175
      src/views/farm/task/index.vue

190
src/views/farm/discuss/index.vue

@ -10,13 +10,6 @@
</el-option>
</el-select>
</el-form-item>
<!-- <el-form-item label="任务内容" prop="projectId">
<el-select v-model="queryParams.taskId" filterable placeholder="请单选">
<el-option v-for="item in taskCateList" :key="item.id" :label="item.name" :value="item.id">
{{ item.name }}
</el-option>
</el-select>
</el-form-item> -->
<el-form-item label="讨论发表时间">
<el-date-picker v-model="dateRangeCreateTime" style="width: 240px" value-format="yyyy-MM-dd"
type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" />
@ -45,7 +38,19 @@
<el-table-column label="讨论ID" align="center" prop="id" />
<el-table-column label="项目名" align="center" prop="projectId" />
<el-table-column label="任务内容" align="center" prop="taskId" />
<el-table-column label="采收数量" align="center" prop="recoveryNumber" />
<el-table-column label="工时" align="center" prop="workingHours" />
<el-table-column label="参与人" align="center" prop="joinPerson" width="80" >
<template slot-scope="scope">
<span v-if="scope.row.joinPerson">{{executorPersonConvert(scope.row.joinPerson)}}</span>
</template>
</el-table-column>
<el-table-column label="讨论内容" align="center" prop="content" />
<el-table-column label="需要的资源" align="center" prop="resources" width="180">
<template slot-scope="scope">
<span>{{resouceConvert(scope.row.resources)}}</span>
</template>
</el-table-column>
<el-table-column label="事件图片" align="center" prop="images">
<template slot-scope="scope">
<el-image
@ -54,7 +59,12 @@
</el-image>
</template>
</el-table-column>
<el-table-column label="发表时间" align="center" prop="createTime" width="180">
<el-table-column label="执行时间" align="center" prop="executeTime" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.executeTime) }}</span>
</template>
</el-table-column>
<el-table-column label="创建时间" align="center" prop="createTime" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime) }}</span>
</template>
@ -76,7 +86,7 @@
<el-dialog :title="title" :visible.sync="open" :close-on-click-modal="false" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="项目" prop="projectId">
<el-select v-model="form.projectId" placeholder="请选择项目">
<el-select v-model="form.projectId" placeholder="请选择项目" @change="changeProject">
<el-option
v-for="item in projectList"
:key="item.id"
@ -85,10 +95,10 @@
</el-option>
</el-select>
</el-form-item>
<el-form-item label="任务" prop="projectId">
<el-select v-model="form.taskId" placeholder="请选择任务">
<el-form-item label="任务" prop="taskId">
<el-select v-model="form.taskId" placeholder="请选择任务" @change="changeTask">
<el-option
v-for="item in taskList"
v-for="item in selectTaskList"
:key="item.id"
:label="item.name"
:value="item.id">
@ -101,6 +111,33 @@
<el-form-item label="讨论图片">
<imageUpload v-model="form.images"/>
</el-form-item>
<el-form-item label="工时" prop="workingHours">
<el-input v-model="form.workingHours" placeholder="请输入工时" />
</el-form-item>
<el-form-item label="采收数量" prop="recoveryNumber">
<el-input id="recoveryNumber" v-model="form.recoveryNumber" :disabled="false" placeholder="请填写数量" />
</el-form-item>
<el-form-item label="执行人" prop="joinPerson">
<el-select v-model="form.joinPerson" filterable multiple placeholder="请先选择项目">
<el-option v-for="item in selectCpUserList" :key="item.id" :label="item.name" :value="item.id">
{{ item.name }}
</el-option>
</el-select>
</el-form-item>
<el-form-item label="执行时间" prop="executeTime">
<el-date-picker clearable v-model="form.executeTime" type="datetime" value-format="timestamp"
placeholder="选择" />
</el-form-item>
<el-button type="primary" @click="addResource">添加资源</el-button>
<el-form-item label="资源选择" v-for="(item,index) in form.resources" :key="index">
<el-cascader :options="twoList" clearable v-model="item.resourceId" @change="(obj)=>ziyuanxuanze(item,index,obj)">
</el-cascader>
<el-input v-model="item.num"/>
<el-button @click="deleteResource(item)">删除</el-button>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
@ -117,6 +154,9 @@ import Editor from '@/components/Editor';
import { getProjectPage } from "@/api/farm/project";
import { getTaskPage } from "@/api/farm/task";
import { getTaskCatePage } from "@/api/farm/taskCate";
import { getResourcePage } from "@/api/farm/resource";
import { getResourceTypePage } from "@/api/farm/resourceType";
import { getCpUserPage } from "@/api/system/cpUser";
export default {
name: "Discuss",
@ -149,9 +189,12 @@ export default {
taskId: null,
content: null,
images: null,
resources: null,
},
//
form: {},
form: {
recoveryNumber: '0'
},
//
rules: {
projectId: [{ required: true, message: "不能为空", trigger: "blur" }],
@ -159,15 +202,94 @@ export default {
},
projectList:[],
taskList:[],
taskCateList:[]
selectTaskList:[], //
taskCateList:[],
resourceTypeList:[], //
resourceList:[], //
twoList:[],
cpUserList:[], //cpUser
selectCpUserList:[] //
};
},
created() {
this.getProject();
this.getTaskCateList();
this.getResourceTypeList();
this.getResource();
this.twoRescoure();
this.getCpUserList();
},
methods: {
getCpUserList() {
getCpUserPage({
pageNo: 1,
pageSize: 400
}).then(res => {
this.cpUserList = res.data.list;
})
},
executorPersonConvert(joinPerson){
let executorPersonName = "";
joinPerson.forEach(joinId =>{
this.cpUserList.forEach(user =>{
if(joinId == user.id){
executorPersonName += user.name +"\n";
}
})
})
return executorPersonName;
},
twoRescoure() {
let firstList = [];
this.resourceTypeList.forEach((type) => {
let secondList = [];
this.resourceList.forEach((res) => {
if (res.resourceType == type.id) {
secondList.push({ value: res.id, label: res.name });
}
})
firstList.push({ value: type.id, label: type.name, children: secondList });
})
this.twoList = firstList;
},
ziyuanxuanze(item,index,obj){
this.form.resource[index].reource = obj[1];
},
addResource(){
let resourceTmp = {reource:0,num:1}
this.form.resources = this.form.resources.concat(resourceTmp);
},
deleteResource(item){
this.form.resources = this.form.resources.filter(res => res!=item)
},
resouceConvert(resources){
let resouceMsg = "";
resources.forEach(res =>{
let typeName = this.resourceTypeList.filter(type => type.id == res.resourceId[0])[0].name;
let name = this.resourceList.filter(name => name.id == res.resourceId[1])[0].name;
resouceMsg += typeName +"/" + name +":" + res.num +"\n";
})
return resouceMsg;
},
getResourceTypeList() {
getResourceTypePage({
pageNo: 1,
pageSize: 100
}).then(res => {
this.resourceTypeList = res.data.list;
})
},
getResource() {
getResourcePage({
pageNo: 1,
pageSize: 10,
}).then(res => {
this.resourceList = res.data.list;
})
},
getTaskCateList() {
getTaskCatePage({
pageNo: 1,
@ -238,6 +360,7 @@ export default {
taskId: undefined,
content: undefined,
images: undefined,
resources: [],
};
this.resetForm("form");
},
@ -255,17 +378,20 @@ export default {
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.twoRescoure();
this.open = true;
this.title = "添加农场任务讨论";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
this.twoRescoure();
const id = row.id;
getDiscuss(id).then(response => {
this.form = response.data;
this.open = true;
this.title = "修改农场任务讨论";
this.showCpUserList(response.data.projectId);
});
},
/** 提交按钮 */
@ -335,7 +461,43 @@ export default {
this.$download.excel(response, '${table.classComment}.xls');
this.exportLoading = false;
}).catch(() => {});
},
changeProject(row){
this.form.taskId = null;
this.selectTaskList = this.taskList.filter(task => task.projectId == row);
this.showCpUserList(row);
},
showCpUserList(projectId){
let project = this.projectList.filter(project => project.id == projectId)[0];
let projectMemberList = [];
if(project.members != undefined && project.members != null){
project.members.forEach(memberId =>{
this.cpUserList.forEach(user =>{
if(memberId == user.id){
projectMemberList.push(user);
}
})
})
}
this.selectCpUserList = projectMemberList;
},
changeTask(row){
this.form.recoveryNumber = null;
let task = this.taskList.filter(task => task.id == row)[0];
let taskCate = this.taskCateList.filter(cate => cate.id == task.taskCateName)[0];
var reco = document.getElementById("recoveryNumber");
if(taskCate.synchronizeErp){
//
reco.removeAttribute("disabled");
}else{
//
reco.setAttribute("disabled", true);
}
}
}
};
</script>

175
src/views/farm/task/index.vue

@ -112,11 +112,11 @@
<span>{{scope.row.mainPersonName}}</span>
</template>
</el-table-column>
<el-table-column label="执行人" align="center" prop="executorPerson" width="80" >
<!-- <el-table-column label="执行人" align="center" prop="executorPerson" width="80" >
<template slot-scope="scope">
<span>{{executorPersonConvert(scope.row.executorNameList)}}</span>
</template>
</el-table-column>
</el-table-column> -->
<el-table-column label="区域" align="center" prop="areas" width="180" >
<template slot-scope="scope">
<span>{{areaConvert(scope.row.areaNameList)}}</span>
@ -127,7 +127,7 @@
<span> {{scope.row.cropName}} </span>
</template>
</el-table-column>
<el-table-column label="作物数量" align="center" prop="cropNum" />
<!-- <el-table-column label="作物数量" align="center" prop="cropNum" /> -->
<el-table-column label="任务名" align="center" prop="taskCateId">
<template slot-scope="scope">
<span> {{scope.row.taskName}} </span>
@ -142,8 +142,8 @@
<template slot-scope="scope">
<span>{{resouceConvert(scope.row.taskResourceList)}}</span>
</template>
</el-table-column>
<el-table-column label="工时" align="center" prop="workingHours" />
</el-table-column> -->
<!-- <el-table-column label="工时" align="center" prop="workingHours" />
<el-table-column label="图片" align="center" prop="images">
<template slot-scope="scope">
<el-image v-if="scope.row.images != null && scope.row.images[0] != null" style="" :src="scope.row.images[0]"
@ -151,16 +151,16 @@
</el-image>
</template>
</el-table-column>
<el-table-column label="开始时间" align="center" prop="planStartTime" width="180">
<el-table-column label="预计执行时间" align="center" prop="planStartTime" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.planStartTime) }}</span>
</template>
</el-table-column>
<el-table-column label="截止时间" align="center" prop="planEndTime" width="180">
<!-- <el-table-column label="截止时间" align="center" prop="planEndTime" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.planEndTime) }}</span>
</template>
</el-table-column>
</el-table-column> -->
<el-table-column label="优先级" align="center" prop="weight" />
<el-table-column label="创建时间" align="center" prop="createTime" width="180">
<template slot-scope="scope">
@ -190,6 +190,14 @@
</el-option>
</el-select>
</el-form-item>
<el-form-item label="作物选择" prop="cropId">
<el-select v-model="form.cropId" placeholder="请选择">
<el-option v-for="item in selectCropList" :key="item.id" :label="item.name" :value="item.id">
{{ item.name }}
</el-option>
</el-select>
</el-form-item>
<el-form-item label="负责人" prop="mainPerson">
<el-select v-model="form.mainPerson" filterable placeholder="请先选择项目">
<el-option v-for="item in selectCpUserList" :key="item.id" :label="item.name" :value="item.id">
@ -197,27 +205,21 @@
</el-option>
</el-select>
</el-form-item>
<el-form-item label="执行人" prop="executorPerson">
<!-- <el-form-item label="执行人" prop="executorPerson">
<el-select v-model="form.executorPerson" filterable multiple placeholder="请先选择项目">
<el-option v-for="item in selectCpUserList" :key="item.id" :label="item.name" :value="item.id">
{{ item.name }}
</el-option>
</el-select>
</el-form-item>
</el-form-item> -->
<el-form-item label="区域选择" prop="assemAreaList">
<el-cascader :options="assemAreaList" :props="props" emitPath clearable ref="chooseA" v-model="form.areas">
</el-cascader>
</el-form-item>
<el-form-item label="作物选择" prop="cropId">
<el-select v-model="form.cropId" placeholder="请选择">
<el-option v-for="item in selectCropList" :key="item.id" :label="item.name" :value="item.id">
{{ item.name }}
</el-option>
</el-select>
</el-form-item>
<el-form-item label="作物数量" prop="cropNum">
<!-- <el-form-item label="作物数量" prop="cropNum">
<el-input v-model="form.cropNum" placeholder="请输入" />
</el-form-item>
</el-form-item> -->
<el-form-item label="任务类型" prop="taskCateId">
<el-select v-model="form.taskCateId" placeholder="请选择" @change="changeCateOne">
<el-option v-for="item in cateOneList" :key="item.id" :label="item.name" :value="item.id">
@ -237,22 +239,23 @@
<el-cascader :options="twoList" clearable v-model="item.resourceId" @change="(obj)=>ziyuanxuanze(item,index,obj)">
</el-cascader>
<el-input v-model="item.num"/>
<el-button @click="deleteResource(item)">删除</el-button>
</el-form-item>
<el-form-item label="工时" prop="workingHours">
<!-- <el-form-item label="工时" prop="workingHours">
<el-input v-model="form.workingHours" placeholder="请输入工时" />
</el-form-item>
</el-form-item> -->
<el-form-item label="任务图片">
<imageUpload v-model="form.images" />
</el-form-item>
<el-form-item label="任务开始时间" prop="planStartTime">
<el-form-item label="预计执行时间" prop="planStartTime">
<el-date-picker clearable v-model="form.planStartTime" type="datetime" value-format="timestamp"
placeholder="选择" />
</el-form-item>
<el-form-item label="任务结束时间" prop="planEndTime">
<!-- <el-form-item label="任务结束时间" prop="planEndTime">
<el-date-picker clearable v-model="form.planEndTime" type="datetime" value-format="timestamp"
placeholder="选择" />
</el-form-item>
</el-form-item> -->
<el-form-item label="优先级" prop="weight">
<el-input v-model="form.weight" placeholder="请输入优先级" />
</el-form-item>
@ -286,6 +289,7 @@ import { getCpUserPage } from "@/api/system/cpUser";
import { getAreaPage } from "@/api/farm/area";
import { values } from 'min-dash';
import { ifStatement } from "@babel/types";
export default {
name: "Task",
@ -425,6 +429,10 @@ export default {
let resourceTmp = {reource:0,num:1}
this.form.resources = this.form.resources.concat(resourceTmp)
},
deleteResource(item){
console.log(this.form.resources);
this.form.resources = this.form.resources.filter(res => res!=item)
},
getAreasList() {
getAreaPage({
pageNo: 1,
@ -503,7 +511,7 @@ export default {
/** 查询任务列表 */
getList() {
this.loading = true;
this.assemArea();
// this.assemArea();
//
let params = { ...this.queryParams };
this.addBeginAndEndTime(params, this.dateRangePlanStartTime, 'planStartTime');
@ -579,7 +587,7 @@ export default {
this.startMethod();
this.reset();
this.twoRescoure();
this.assemArea();
// this.assemArea();
this.resourceNumberList = [];
this.open = true;
this.title = "添加农场任务";
@ -588,7 +596,7 @@ export default {
handleUpdate(row) {
this.startMethod();
this.reset();
this.assemArea();
// this.assemArea();
const id = row.id;
getTask(id).then(response => {
this.form = response.data;
@ -596,6 +604,7 @@ export default {
this.title = "修改农场任务";
let project = this.projectList.filter(project => project.id == response.data.projectId)[0];
this.changeCpUser(project);
this.showAreaByProject(project);
this.selectCropList = this.cropList.filter(crop => crop.id == project.cropId);
});
},
@ -689,49 +698,47 @@ export default {
},
assemArea() {
let parentLsit = this.areasList.filter(t => t.parentId == 0);
let sonList = this.areasList.filter(s => s.parentId != 0);
let firstList = [];
parentLsit.forEach(p => {
this.areasParentList.push(p);
let secondList = [];
sonList.forEach(s => {
if (p.id == s.parentId) {
this.areasSonList.push(s);
secondList.push({ value: s.id, label: s.name });
}
})
firstList.push({ value: p.id, label: p.name, children: secondList })
})
this.assemAreaList = firstList;
},
// assemArea() {
// let parentLsit = this.areasList.filter(t => t.parentId == 0);
// let sonList = this.areasList.filter(s => s.parentId != 0);
// let firstList = [];
// parentLsit.forEach(p => {
// this.areasParentList.push(p);
// let secondList = [];
// sonList.forEach(s => {
// if (p.id == s.parentId) {
// let three = this.areasList.filter(t => t.parentId == s.id);
// if(three.length == 0){
// secondList.push({ value: s.id, label: s.name });
// }else{
// let threeList = [];
// three.forEach(three =>{
// threeList.push({value:three.id, label:three.name});
// })
// secondList.push({value:s.id, label:s.name, children:threeList});
// }
// }
// })
// firstList.push({ value: p.id, label: p.name, children: secondList })
// })
// this.assemAreaList = firstList;
// },
changeProject(row) {
this.form.areas = null;
this.assemArea();
let project = this.projectList.filter(project => project.id == row)[0];
let projectArea = project.areas;
let filterArr = [];
this.assemAreaList.forEach(t => {
projectArea.forEach(a => {
if (a == t.value) {
filterArr.push(t);
}
})
})
this.assemAreaList = filterArr;
//
this.form.cropId = null;
this.selectCropList = this.cropList.filter(crop => crop.id == project.cropId);
//
this.form.areas = null;
this.showAreaByProject(project);
//
this.selectCpUserList = [];
this.form.mainPerson = null;
this.form.executorPerson = null;
this.changeCpUser(project);
},
changeCpUser(project){
project.members.forEach(member =>{
@ -741,6 +748,56 @@ export default {
}
})
})
},
showAreaByProject(project){
//
let first = [];
let second =[];
let third =[];
this.areasList.forEach(ar =>{
project.areas.forEach(sel =>{
if(ar.id == sel){
if(ar.parentId != 0){
let parentAr = this.areasList.filter(item => item.id == ar.parentId)[0];
let thi = this.areasList.filter(item => item.id == sel)[0]
if(parentAr.parentId != 0){
let ppA = this.areasList.filter(item => item.id == parentAr.parentId)[0];
first.push(ppA);
second.push(parentAr);
third.push(thi);
}else{
first.push(parentAr);
second.push(thi);
}
}
}
})
})
let setFirst = new Set(first);
let setSecond = new Set(second);
let oneList = [];
setFirst.forEach(fi =>{
let twoList = [];
setSecond.forEach(se =>{
if(se.parentId == fi.id){
let threeList = [];
third.forEach(th =>{
if(th.parentId == se.id){
threeList.push({value:th.id, label:th.name});
}
})
if(threeList.length != 0){
twoList.push({value:se.id, label:se.name, children:threeList});
}else{
twoList.push({value:se.id, label:se.name});
}
}
})
oneList.push({value:fi.id, label:fi.name, children:twoList});
})
this.assemAreaList = oneList;
}

Loading…
Cancel
Save