Browse Source

农场任务搜索页面

master
小久哥 3 years ago
parent
commit
1b6f8f0ed9
  1. 21
      src/api/farm/task.js
  2. 55
      src/views/farm/task/index.vue

21
src/api/farm/task.js

@ -1,6 +1,6 @@
import request from '@/utils/request' import request from '@/utils/request'
// 创建农场项目 // 创建农场任务
export function createTask(data) { export function createTask(data) {
return request({ return request({
url: '/farm/task/create', url: '/farm/task/create',
@ -9,7 +9,7 @@ export function createTask(data) {
}) })
} }
// 更新农场项目 // 更新农场任务
export function updateTask(data) { export function updateTask(data) {
return request({ return request({
url: '/farm/task/update', url: '/farm/task/update',
@ -18,7 +18,7 @@ export function updateTask(data) {
}) })
} }
// 删除农场项目 // 删除农场任务
export function deleteTask(id) { export function deleteTask(id) {
return request({ return request({
url: '/farm/task/delete?id=' + id, url: '/farm/task/delete?id=' + id,
@ -26,7 +26,7 @@ export function deleteTask(id) {
}) })
} }
// 获得农场项目 // 获得农场任务
export function getTask(id) { export function getTask(id) {
return request({ return request({
url: '/farm/task/get?id=' + id, url: '/farm/task/get?id=' + id,
@ -34,7 +34,7 @@ export function getTask(id) {
}) })
} }
// 获得农场项目分页 // 获得农场任务分页
export function getTaskPage(query) { export function getTaskPage(query) {
return request({ return request({
url: '/farm/task/page', url: '/farm/task/page',
@ -43,7 +43,16 @@ export function getTaskPage(query) {
}) })
} }
// 导出农场项目 Excel // 条件搜索获得农场任务分页
export function getTaskSearchPage(query) {
return request({
url: '/farm/task/pageSearch',
method: 'get',
params: query
})
}
// 导出农场任务 Excel
export function exportTaskExcel(query) { export function exportTaskExcel(query) {
return request({ return request({
url: '/farm/task/export-excel', url: '/farm/task/export-excel',

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

@ -6,17 +6,14 @@
<template> <template>
<div class="app-container"> <div class="app-container">
<!-- 搜索工作栏 --> <!-- 搜索工作栏 -->
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px"> <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="任务名" prop="name"> <el-form-item label="任务名" prop="name">
<el-input v-model="queryParams.name" placeholder="请输入" clearable @keyup.enter.native="handleQuery"/> <el-input v-model="queryParams.name" placeholder="请输入" clearable @keyup.enter.native="handleQuery"/>
</el-form-item> </el-form-item>
<el-form-item label="资源名" prop="resources">
<!-- 暂时不知道怎么查 -->
<!-- <el-form-item label="资源名" prop="resources">
<el-input v-model="queryParams.resources" placeholder="请输入" clearable @keyup.enter.native="handleQuery"/> <el-input v-model="queryParams.resources" placeholder="请输入" clearable @keyup.enter.native="handleQuery"/>
</el-form-item> --> </el-form-item>
<el-form-item label="开始时间"> <el-form-item label="开始时间">
<el-date-picker v-model="dateRangePlanStartTime" style="width: 240px" value-format="yyyy-MM-dd" <el-date-picker v-model="dateRangePlanStartTime" style="width: 240px" value-format="yyyy-MM-dd"
type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" /> type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" />
@ -53,8 +50,6 @@
<el-table-column label="任务名" align="center" prop="name" /> <el-table-column label="任务名" align="center" prop="name" />
<el-table-column label="任务内容" align="center" prop="content" /> <el-table-column label="任务内容" align="center" prop="content" />
<el-table-column label="需要的资源" align="center" prop="resources" /> <el-table-column label="需要的资源" align="center" prop="resources" />
<el-table-column label="图片" align="center" prop="images" > <el-table-column label="图片" align="center" prop="images" >
<template slot-scope="scope"> <template slot-scope="scope">
<el-image <el-image
@ -65,7 +60,6 @@
</el-image> </el-image>
</template> </template>
</el-table-column> </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"> <template slot-scope="scope">
<span>{{ parseTime(scope.row.planStartTime) }}</span> <span>{{ parseTime(scope.row.planStartTime) }}</span>
@ -104,8 +98,6 @@
<el-form-item label="任务内容"> <el-form-item label="任务内容">
<editor v-model="form.content" :min-height="192"/> <editor v-model="form.content" :min-height="192"/>
</el-form-item> </el-form-item>
<el-form-item label="资源选择"> <el-form-item label="资源选择">
<el-select v-model="selectResourceList" multiple placeholder="请选择"> <el-select v-model="selectResourceList" multiple placeholder="请选择">
<el-option <el-option
@ -117,11 +109,9 @@
</el-option> </el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="任务图片"> <el-form-item label="任务图片">
<imageUpload v-model="form.images"/> <imageUpload v-model="form.images"/>
</el-form-item> </el-form-item>
<el-form-item label="任务开始时间" prop="planStartTime"> <el-form-item label="任务开始时间" prop="planStartTime">
<el-date-picker clearable v-model="form.planStartTime" type="date" value-format="timestamp" placeholder="选择" /> <el-date-picker clearable v-model="form.planStartTime" type="date" value-format="timestamp" placeholder="选择" />
</el-form-item> </el-form-item>
@ -141,7 +131,7 @@
</template> </template>
<script> <script>
import { createTask, updateTask, deleteTask, getTask, getTaskPage, exportTaskExcel } from "@/api/farm/task"; import { createTask, updateTask, deleteTask, getTask, getTaskPage, getTaskSearchPage, exportTaskExcel } from "@/api/farm/task";
import ImageUpload from '@/components/ImageUpload'; import ImageUpload from '@/components/ImageUpload';
import Editor from '@/components/Editor'; import Editor from '@/components/Editor';
import { getResourcePage } from "@/api/farm/resource"; import { getResourcePage } from "@/api/farm/resource";
@ -224,7 +214,6 @@ export default {
// //
element.images = []; element.images = [];
} }
//2 listresource //2 listresource
element.resources = JSON.parse(element.resources); element.resources = JSON.parse(element.resources);
let resourceName = ''; let resourceName = '';
@ -238,14 +227,46 @@ export default {
) )
}) })
element.resources = resourceName; element.resources = resourceName;
}); });
this.list = response.data.list; this.list = response.data.list;
this.total = response.data.total; this.total = response.data.total;
this.loading = false; this.loading = false;
}); });
}, },
/** 搜索条件查询任务列表 */
getSearchList() {
this.loading = true;
//
let params = {...this.queryParams};
this.addBeginAndEndTime(params, this.dateRangePlanStartTime, 'planStartTime');
this.addBeginAndEndTime(params, this.dateRangePlanEndTime, 'planEndTime');
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 = [];
}
element.resources = JSON.parse(element.resources);
let resourceName = '';
element.resources.forEach((inn) =>{
this.resourceList.forEach((resource) =>{
if(inn == resource.id){
resourceName += (resource.name + "、\n");
}
}
)
})
element.resources = resourceName;
});
this.list = response.data.list;
this.total = response.data.total;
this.loading = false;
});
},
/** 取消按钮 */ /** 取消按钮 */
cancel() { cancel() {
this.open = false; this.open = false;
@ -268,7 +289,7 @@ export default {
/** 搜索按钮操作 */ /** 搜索按钮操作 */
handleQuery() { handleQuery() {
this.queryParams.pageNo = 1; this.queryParams.pageNo = 1;
this.getList(); this.getSearchList();
}, },
/** 重置按钮操作 */ /** 重置按钮操作 */
resetQuery() { resetQuery() {

Loading…
Cancel
Save