Browse Source

项目 任务、成员

master
小久哥 3 years ago
parent
commit
9525f34970
  1. 72
      src/views/farm/project/index.vue
  2. 141
      src/views/farm/task/index.vue

72
src/views/farm/project/index.vue

@ -61,6 +61,8 @@
<span> {{cropList.find(t=>t.id == scope.row.cropId ).name}} </span>
</template>
</el-table-column>
<el-table-column label="项目成员" align="center" prop="members"/>
<el-table-column label="图片" align="center" prop="images">
<template slot-scope="scope">
<el-image style="" :src="scope.row.images.split(',')[0]"
@ -103,10 +105,10 @@
<el-form-item label="项目名" prop="name">
<el-input v-model="form.name" placeholder="请输入" />
</el-form-item>
<el-form-item label="项目内容">
<el-form-item label="项目内容" prop="content">
<editor v-model="form.content" :min-height="192"/>
</el-form-item>
<el-form-item label="区域选择">
<el-form-item label="区域选择" prop="selectAreasList">
<el-select v-model="selectAreasList" multiple placeholder="请选择">
<el-option
v-for="item in areasList"
@ -117,12 +119,18 @@
</el-option>
</el-select>
</el-form-item>
<el-form-item label="作物选择">
<el-select v-model="form.cropId" placeholder="请选择" @change="selectCrop">
<el-form-item label="作物选择" prop="cropId">
<el-select v-model="form.cropId" placeholder="请选择">
<el-option v-for="item in cropList" :key="item.id" :label="item.name" :value="item.id"> {{item.name}}
</el-option>
</el-select>
</el-form-item>
<el-form-item label="成员选择" prop="selectMembersList">
<el-select v-model="selectMembersList" multiple placeholder="请选择">
<el-option v-for="item in membersList" :key="item.id" :label="item.name" :value="item.id"> {{item.name}}
</el-option>
</el-select>
</el-form-item>
<el-form-item label="项目图片">
<imageUpload v-model="form.images"/>
</el-form-item>
@ -151,6 +159,7 @@ import Editor from '@/components/Editor';
// import { getResourcePage } from "@/api/farm/resource";
import { getAreaPage} from "@/api/farm/area";
import { getCropPage} from "@/api/farm/crop";
import { getCpUserPage} from "@/api/system/cpUser"
export default {
@ -188,22 +197,34 @@ export default {
images: null,
weight: null,
areas: null,
cropId: null
cropId: null,
members: null
},
//
form: {},
//
rules: {
name: [{ required: true, message: "不能为空", trigger: "blur" }],
content: [{ required: true, message: "不能为空", trigger: "blur" }],
selectAreasList: [{ required: true, message: "不能为空", trigger: "blur" }],
cropId: [{ required: true, message: "不能为空", trigger: "blur" }],
selectMembersList: [{ required: true, message: "不能为空", trigger: "blur" }],
planStartTime: [{ required: true, message: "不能为空", trigger: "blur" }],
planEndTime: [{ required: true, message: "不能为空", trigger: "blur" }],
weight: [{ required: true, message: "不能为空", trigger: "blur" }],
},
areasList:[],
selectAreasList:[],
cropList:[]
cropList:[],
membersList:[],
selectMembersList:[]
};
},
created() {
this.getAreasList();
this.getCropList();
this.getCpUserList();
this.getList();
},
methods: {
@ -223,6 +244,14 @@ export default {
this.areasList = res.data.list;
})
},
getCpUserList(){
getCpUserPage({
pageNo: 1,
pageSize: 100
}).then(res =>{
this.membersList = res.data.list;
})
},
/** 查询项目列表 */
getList() {
this.loading = true;
@ -241,11 +270,26 @@ export default {
if(inn == ar.id){
areasName += (ar.name + "、\n");
}
}
)
})
})
element.areas = areasName;
element.members = JSON.parse(element.members);
if(element.members != null){
let memberName = '';
element.members.forEach((mem) =>{
this.membersList.forEach((sel) =>{
if(mem == sel.id){
memberName += (sel.name + "、\n");
}
})
})
element.members = memberName;
}
});
this.list = response.data.list;
this.total = response.data.total;
this.loading = false;
@ -294,7 +338,8 @@ export default {
planEndTime: undefined,
weight: undefined,
areas: undefined,
cropId:undefined
cropId:undefined,
members: undefined
};
this.resetForm("form");
},
@ -315,6 +360,7 @@ export default {
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.getCpUserList();
this.open = true;
this.title = "添加农场项目";
},
@ -327,6 +373,11 @@ export default {
let areasArray = JSON.parse(response.data.areas);
this.form.areas = areasArray;
this.selectAreasList = areasArray;
let membersArray = JSON.parse(response.data.members);
this.form.members = membersArray;
this.selectMembersList = membersArray;
this.open = true;
this.title = "修改农场项目";
});
@ -338,6 +389,8 @@ export default {
return;
}
this.form.areas = JSON.stringify(this.selectAreasList);
this.form.members = JSON.stringify(this.selectMembersList);
//
if (this.form.id != null) {
updateProject(this.form).then(response => {
@ -350,6 +403,7 @@ export default {
//
createProject(this.form).then(response => {
this.form.areas = JSON.stringify(this.form.areas);
this.form.members = JSON.stringify(this.form.members);
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();

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

@ -52,6 +52,13 @@
<span> {{projectList.find(t=>t.id == scope.row.projectId ).name}} </span>
</template>
</el-table-column>
<el-table-column label="负责人" align="center" prop="mainPerson" >
<template slot-scope="scope">
<span> {{cpUserList.find(t=>t.id == scope.row.mainPerson ).name}} </span>
</template>
</el-table-column>
<el-table-column label="执行人" align="center" prop="executorPerson"/>
<el-table-column label="作物名" align="center" prop="cropName" >
<template slot-scope="scope">
<span> {{cropList.find(t=>t.id == scope.row.cropId ).name}} </span>
@ -61,6 +68,8 @@
<el-table-column label="任务名" align="center" prop="name" />
<el-table-column label="任务内容" align="center" prop="content" />
<el-table-column label="需要的资源" align="center" prop="resources" />
<el-table-column label="工时" align="center" prop="workingHours" />
<el-table-column label="图片" align="center" prop="images" >
<template slot-scope="scope">
<el-image
@ -104,7 +113,7 @@
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="项目选择">
<el-form-item label="项目选择" prop="projectId">
<el-select v-model="form.projectId" placeholder="请选择">
<el-option
v-for="item in projectList"
@ -116,7 +125,31 @@
</el-select>
</el-form-item>
<el-form-item label="作物选择">
<el-form-item label="负责人" prop="mainPerson">
<el-select v-model="form.mainPerson" placeholder="请选择">
<el-option
v-for="item in cpUserList"
:key="item.id"
:label="item.name"
:value="item.id">
{{item.name}}
</el-option>
</el-select>
</el-form-item>
<el-form-item label="执行人" prop="executorPerson">
<el-select v-model="executorPerson" multiple placeholder="请选择" >
<el-option
v-for="item in cpUserList"
:key="item.id"
:label="item.name"
:value="item.id">
{{item.name}}
</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 cropList"
@ -128,32 +161,34 @@
</el-select>
</el-form-item>
<el-form-item label="作物数量">
<el-form-item label="作物数量" prop="cropNum">
<el-input v-model="form.cropNum" placeholder="请输入"/>
</el-form-item>
<el-form-item label="任务名" prop="name">
<el-input v-model="form.name" placeholder="请输入" />
</el-form-item>
<el-form-item label="任务内容">
<el-form-item label="任务内容" prop="content">
<editor v-model="form.content" :min-height="192"/>
</el-form-item>
<!-- <el-form-item label="资源选择">
<el-select v-model="selectResourceList" multiple placeholder="请选择" @change="changeResource">
<el-option
v-for="item in resourceList"
:key="item.id"
:label="item.name"
:value="item.id">
{{item.name}}
</el-option>
</el-select>
</el-form-item> -->
<el-form-item label="资源选择">
<el-cascader :options="twoList" :props="props" clearable v-model="form.resources"></el-cascader>
</el-form-item>
<div v-for="(item,index) in resourceTypeList" :key="index">
<el-form-item label="资源选择">
<el-cascader
:options="twoList"
:props="props"
collapse-tags
clearable
v-model="form.resources">
</el-cascader>
<el-button @click="addR(index)">添加</el-button>
<el-button @click="delR(index)">删除</el-button>
</el-form-item>
</div>
<el-form-item label="工时" prop="workingHours">
<el-input v-model="form.workingHours" placeholder="请输入工时" />
</el-form-item>
<el-form-item label="任务图片">
<imageUpload v-model="form.images"/>
@ -184,6 +219,7 @@ import { getResourcePage } from "@/api/farm/resource";
import { getProjectPage} from "@/api/farm/project";
import { getCropPage} from "@/api/farm/crop";
import { getResourceTypePage} from "@/api/farm/resourceType";
import { getCpUserPage} from "@/api/system/cpUser"
import { values } from 'min-dash';
export default {
@ -222,12 +258,24 @@ export default {
weight: null,
projectId: null,
cropId: null,
cropNum: null
cropNum: null,
workingHours: null
},
//
form: {},
//
rules: {
projectId: [{ required: true, message: "不能为空", trigger: "blur" }],
mainPerson: [{ required: true, message: "不能为空", trigger: "blur" }],
executorPerson: [{ required: true, message: "不能为空", trigger: "blur" }],
cropId: [{ required: true, message: "不能为空", trigger: "blur" }],
cropNum: [{ required: true, message: "不能为空", trigger: "blur" }],
name: [{ required: true, message: "不能为空", trigger: "blur" }],
content: [{ required: true, message: "不能为空", trigger: "blur" }],
workingHours: [{ required: true, message: "不能为空", trigger: "blur" }],
planStartTime: [{ required: true, message: "不能为空", trigger: "blur" }],
planEndTime: [{ required: true, message: "不能为空", trigger: "blur" }],
weight: [{ required: true, message: "不能为空", trigger: "blur" }],
},
resourceList:[],
selectResourceList:[],
@ -238,7 +286,13 @@ export default {
selectResourceTypeList:[],
twoList:[],
props: { multiple: true }
props: { multiple: true },
selectRList:[],
cpUserList:[],
selectExecutorPerson:[],
executorPerson:[]
};
},
@ -246,9 +300,18 @@ export default {
this.getResource();
this.getResourceTypeList();
this.getProjectList();
this.getCpUserList();
this.getCropList();
},
methods: {
getCpUserList(){
getCpUserPage({
pageNo: 1,
pageSize: 100
}).then(res=>{
this.cpUserList = res.data.list;
})
},
getCropList(){
getCropPage({
pageNo: 1,
@ -294,6 +357,7 @@ export default {
this.addBeginAndEndTime(params, this.dateRangeCreateTime, 'createTime');
//
getTaskPage(params).then(response => {
//1 list
response.data.list.forEach(element => {
if(element.images != null){
@ -316,6 +380,18 @@ export default {
)
})
element.resources = resourceName;
element.executorPerson = JSON.parse(element.executorPerson);
let executorName = '';
element.executorPerson.forEach((exe)=>{
this.cpUserList.forEach((cp)=>{
if(exe == cp.id){
executorName += (cp.name +"、\n");
}
})
})
element.executorPerson = executorName;
});
this.list = response.data.list;
this.total = response.data.total;
@ -375,8 +451,13 @@ export default {
weight: undefined,
projectName: undefined,
cropId: undefined,
cropNum: undefined
cropNum: undefined,
mainPerson: undefined,
executorPerson: undefined,
workingHours: undefined
};
this.executorPerson = undefined,
this.resetForm("form");
},
/** 搜索按钮操作 */
@ -415,6 +496,11 @@ export default {
let imagesArr = JSON.parse(response.data.images);
this.form.images = imagesArr;
}
if(response.data.executorPerson != null){
let executorArr = JSON.parse(response.data.executorPerson);
this.form.executorPerson = executorArr;
}
this.open = true;
this.title = "修改农场任务";
});
@ -427,11 +513,7 @@ export default {
}
//json
this.form.resources = JSON.stringify(this.selectResourceList);
console.log(this.form);
console.log(1111,this.form.resources);
this.form.executorPerson = JSON.stringify(this.executorPerson);
//json
let im = this.form.images;
this.form.images = JSON.stringify("");
@ -452,6 +534,7 @@ export default {
}
//
createTask(this.form).then(response => {
this.form.executorPerson = JSON.stringify(this.form.executorPerson);
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
@ -498,6 +581,12 @@ export default {
firstList.push({value: type.id, label : type.name, children: secondList});
})
this.twoList = firstList;
},
addR(row){
console.log("添加", row);
},
delR(row){
console.log("删除", row);
}
}
};

Loading…
Cancel
Save