养护计划

master
lion 3 years ago
parent 3b5dc4dc8d
commit 925eea4fe3

@ -39,3 +39,19 @@ export function del(id) {
params:{ id }
})
}
export function importShow(data) {
return request({
url: '/api/admin/maintain-plan/import-show',
method: 'post',
data
})
}
export function importPlan(data) {
return request({
url: '/api/admin/maintain-plan/import',
method: 'post',
data
})
}

@ -0,0 +1,440 @@
<template>
<div class="container">
<div style="padding: 0px 20px">
<div ref="lxHeader">
<LxHeader icon="md-apps" text="养护计划" style="margin-bottom: 10px; border: 0px; margin-top: 15px">
<div slot="content"></div>
<slot>
<div>
<Input style="width: 200px; margin-right: 10px" v-model="searchFields.keyword" placeholder="关键字搜索" />
<Button type="primary" @click="load" style="margin-left: 10px">查询</Button>
<Button type="primary" @click="edit()" style="margin-left: 10px">新增</Button>
</div>
</slot>
</LxHeader>
</div>
<div ref="lxTable">
<el-table :data="tableData" class="v-table" :height="tableHeight" style="width: 100%">
<el-table-column type="index" width="50" fixed="left" label="序号" align="center"> </el-table-column>
<el-table-column :prop="column.field" :align="column.align" v-for="(column,index) in columns"
:label="column.title" :width="column.width" :fixed="column.fixed">
<template slot-scope="scope">
<div v-if="column.type=='opt'">
<Button ghost size="small" @click="edit(scope.row)" type="primary"
style="margin-left: 10px;">编辑</Button>
<Button ghost size="small" @click="del(scope.row)" type="error" style="margin-left: 10px;">删除</Button>
</div>
<div v-else-if="column.type=='daterange'">
{{scope.row['start_date']}}{{scope.row['end_date']}}
</div>
<div v-else>{{scope.row[column.field]}}</div>
</template>
</el-table-column>
</el-table>
<div class="pagination">
<el-pagination @current-change="handleCurrentChange" :current-page="paginations.page"
:page-size="paginations.page_size" background layout="prev, pager, next" :total="paginations.total">
</el-pagination>
</div>
</div>
<el-dialog class="common-dialog" title="养护计划编辑" :visible.sync="dialogFormVisible" width="40%">
<div class="dialogConcent">
<el-scrollbar style="flex: 1">
<el-form :model="form" :rules="rules" ref="form" label-position="right" :label-width="formLabelWidth">
<el-row>
<el-col :span="24">
<el-form-item label="养护计划名称" prop="name">
<el-input v-model="form.name" placeholder="请填写养护计划名称" autocomplete="off"></el-input>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="养护类型" prop="item_type">
<el-select style="width:100%" v-model="form.item_type" placeholder="请选择养护类型">
<el-option
v-for="item in plantypes"
:key="item.id"
:label="item.value"
:value="item.id">
</el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="养护片区" prop="area_id">
<el-select filterable style="width:100%" v-model="form.area_id" placeholder="请选择养护片区">
<el-option
v-for="item in areaList"
:key="item.id"
:label="item.name"
:value="item.id">
</el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="循环机制" prop="day">
<el-select style="width:100%" v-model="form.day" placeholder="请选择循环机制">
<el-option
v-for="item in dayList"
:key="item.id"
:label="item.value"
:value="item.value">
</el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="养护周期" prop="dateRange">
<el-date-picker
style="width:100%"
v-model="dateRange"
type="daterange"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期"
value-format="yyyy-MM-dd"
>
</el-date-picker>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="养护责任人" prop="responsible_id">
<el-select filterable style="width:100%" v-model="form.responsible_id" placeholder="请选择养护责任人">
<el-option
v-for="item in usersList"
:key="item.id"
:label="item.name"
:value="item.id">
</el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="备注" prop="remark">
<el-input type="textarea" v-model="form.remark" placeholder="请填写备注" autocomplete="off"></el-input>
</el-form-item>
</el-col>
</el-row>
</el-form>
</el-scrollbar>
</div>
<div slot="footer" class="dialog-footer">
<el-button @click="resetForm('form')"> </el-button>
<el-button type="primary" v-preventReClick @click="submitForm('form')"></el-button>
</div>
</el-dialog>
</div>
</div>
</template>
<script>
import {
listplan,
get,
store,
save,
del
} from '../../../api/maintainmanagement/index.js'
import {
listCommonuser
} from '../../../api/common.js'
import {
listarea
} from '../../../api/basic/area.js'
import { getparameteritem } from '../../../api/system/dictionary.js'
import LxHeader from "@/components/LxHeader/index.vue";
export default {
components: {
LxHeader
},
data() {
return {
tableHeight: 0,
dialogFormVisible: false,
formLabelWidth: "120px",
tableData: [],
areaList:[],
plantypes:[{
id:1,
value:"雨水管道疏挖"
},{
id:2,
value:"雨水管道疏通"
},{
id:3,
value:"汛期助排"
},{
id:4,
value:"污泥外运"
},{
id:5,
value:"出水口排查"
},{
id:6,
value:"专项处理"
},{
id:7,
value:"维修"
}],
dayList:[],
dateRange:[],
usersList:[],
tableHeight: 0,
searchFields: {
keyword: ""
},
paginations: {
page: 1,
page_size: 15,
total: 0
},
form: {
name:"",
item_type:"",
area_id:"",
day:"",
start_date:"",
end_date:"",
responsible_id:"",
remark:""
},
rules: {
name:[{
required: true,
message: '请填写养护名称',
trigger: 'blur',
}],
area_id:[{
required: true,
message: '请选择所属片区',
trigger: 'blur',
}]
},
columns: [{
field: "name",
title: "养护名称",
type: "string",
align: "left",
width:240
},
{
field: "item_type_name",
title: "养护类型",
type: "string",
align: "center",
width:180
},
{
field: "area_name",
title: "养护片区",
type: "string",
width:180,
align: "center"
},
{
field: "day",
title: "循环机制",
type: "string",
width:120,
align: "center"
},
{
field: "daterange",
title: "养护周期",
type: "daterange",
width:240,
align:'center'
},
{
field: "responsibleName",
title: "责任人",
type: "string",
align: "center",
width:180,
},
{
field: "created_at",
title: "提交日期",
type: "string",
align: "center",
width:180,
align:'center'
},
{
field: "操作",
title: "操作",
width: 220,
type: "opt",
fixed:"right"
}
],
}
},
created() {
this.initLoad();
this.load();
},
methods: {
initLoad() {
var that = this;
var clientHeight = document.documentElement.clientHeight
var lxHeader_height = 96.5; //
var paginationHeight = 37; //
var topHeight = 50; //
let tableHeight = clientHeight - lxHeader_height - topHeight - paginationHeight - 20;
that.tableHeight = tableHeight;
listarea({
page: 1,
page_size: 999,
}).then(response => {
that.areaList = response.data;
}).catch(error => {
console.log(error)
reject(error)
});
listCommonuser({
page:1,
page_size:999
}).then(res => {
that.usersList = res.data;
}).catch(error => {
console.log(error)
reject(error)
});
// getparameteritem('plan-type').then(res => {
// that.plantypes = res.detail
// })
getparameteritem('plan-day').then(res => {
that.dayList = res.detail
})
},
handleCurrentChange(page) {
this.paginations.page = page;
this.load();
},
load() {
listplan({
page: this.paginations.page,
page_size: this.paginations.page_size,
keyword: this.searchFields.keyword
}).then(response => {
for(var m of response.data){
for(var k of this.plantypes){
if(m.item_type==k.id){
m.item_type_name = k.value
}
}
m.area_name = m.area_info.name
m.responsibleName = m.responsible?m.responsible.name :""
}
this.tableData = response.data;
this.paginations.total = response.total;
}).catch(error => {
console.log(error)
reject(error)
});
},
info(obj) {
var that = this;
get(obj.id).then(res => {
let result = Object.assign(that.form, res);
// this.$set(that.form,res);
that.form = result;
that.dateRange = [result.start_date,result.end_date]
}).catch(error => {
//reject(error)
})
},
edit(obj) {
this.form = this.$options.data().form
if (obj) {
this.info(obj)
}
this.dialogFormVisible = true;
},
del(obj) {
var that = this;
if (obj) {
this.$Modal.confirm({
title: '确认要删除数据?',
onOk: () => {
del(obj.id).then(response => {
this.$Message.success('操作成功');
that.load();
}).catch(error => {
console.log(error)
reject(error)
})
},
onCancel: () => {
//this.$Message.info('Clicked cancel');
}
});
}
},
submitForm(formName) {
this.form.start_date = this.dateRange[0]
this.form.end_date = this.dateRange[1]
var that = this;
this.$refs[formName].validate((valid) => {
if (valid) {
if (that.form.id) {
save(that.form).then(response => {
this.$Message.success('操作成功');
that.load();
that.dialogFormVisible = false;
}).catch(error => {
//reject(error)
})
} else {
store(that.form).then(response => {
this.$Message.success('操作成功');
that.load();
that.dialogFormVisible = false;
}).catch(error => {
//reject(error)
})
}
} else {
this.$Message.error('数据校验失败');
console.log('error submit!!');
return false;
}
});
},
resetForm(formName) {
var that = this;
that.dateRange = [];
this.$refs[formName].resetFields();
that.dialogFormVisible = false;
}
}
}
</script>
<style>
.dialogConcent {
overflow-y: auto;
}
.width100{
width:100%;
}
</style>

@ -8,7 +8,38 @@
<div>
<Input style="width: 200px; margin-right: 10px" v-model="searchFields.keyword" placeholder="关键字搜索" />
<Button type="primary" @click="load" style="margin-left: 10px">查询</Button>
<Button type="primary" @click="edit()" style="margin-left: 10px">新增</Button>
<Button type="primary" @click="edit()" style="margin-left: 10px">新增</Button>
<div class="upfile">
<el-popover
placement="bottom-start"
title="多个日期之间用英文字符;分隔开,两天以上只取前后两天日期(06.12;06.15)"
width="300"
trigger="hover"
content="">
<span >
</span>
<el-upload
slot="reference"
class="upload-demo"
action="/api/admin/maintain-plan/import-show"
:on-preview="handlePreview"
:on-remove="handleRemove"
:before-remove="beforeRemove"
:data="uploadOther"
multiple
:limit="1"
:on-success="handleSuccess"
:on-exceed="handleExceed"
:file-list="fileList">
<el-button size="small" type="primary">点击上传</el-button>
</el-upload>
</el-popover>
</div>
</div>
</slot>
</LxHeader>
@ -44,14 +75,24 @@
<el-form :model="form" :rules="rules" ref="form" label-position="right" :label-width="formLabelWidth">
<el-row>
<el-col :span="24">
<!-- <el-col :span="24">
<el-form-item label="养护计划名称" prop="name">
<el-input v-model="form.name" placeholder="请填写养护计划名称" autocomplete="off"></el-input>
</el-form-item>
</el-col> -->
<el-col :span="24">
<el-form-item label="所属道路" prop="road_id">
<el-select class="width100" v-model="roadName" filterable remote @change="chooseRoad"
:disabled="roaddisabled" clearable @focus="remoteRoad" reserve-keyword placeholder="请输入关键词查找道路信息"
:remote-method="remoteMethod" :loading="roadloading">
<el-option v-for="item in roadsList" :key="item.id" :label="item.name" :value="item.id">
</el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="养护项目" prop="item_type">
<el-select style="width:100%" v-model="form.item_type" placeholder="请选择养护项目">
<el-form-item label="养护类型" prop="item_type">
<el-select style="width:100%" v-model="form.item_type" placeholder="请选择养护类型">
<el-option
v-for="item in plantypes"
:key="item.id"
@ -73,7 +114,7 @@
</el-select>
</el-form-item>
</el-col>
<el-col :span="24">
<!-- <el-col :span="24">
<el-form-item label="循环机制" prop="day">
<el-select style="width:100%" v-model="form.day" placeholder="请选择循环机制">
<el-option
@ -84,7 +125,7 @@
</el-option>
</el-select>
</el-form-item>
</el-col>
</el-col> -->
<el-col :span="24">
<el-form-item label="养护周期" prop="dateRange">
@ -100,7 +141,27 @@
</el-date-picker>
</el-form-item>
</el-col>
<el-col :span="24">
<el-col :span="12">
<el-form-item label="窨井(座)" prop="inspection_well">
<el-input type="number" v-model="form.inspection_well" placeholder="请填写窨井(座)" autocomplete="off"></el-input>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="边井(座)" prop="side_well">
<el-input type="number" v-model="form.side_well" placeholder="请填写边井(座)" autocomplete="off"></el-input>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="主管数" prop="master_pipe">
<el-input type="number" v-model="form.master_pipe" placeholder="请填写主管数" autocomplete="off"></el-input>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="支管数" prop="branch_pipe">
<el-input type="number" v-model="form.branch_pipe" placeholder="请填写支管数" autocomplete="off"></el-input>
</el-form-item>
</el-col>
<!-- <el-col :span="24">
<el-form-item label="养护责任人" prop="responsible_id">
<el-select filterable style="width:100%" v-model="form.responsible_id" placeholder="请选择养护责任人">
<el-option
@ -111,12 +172,12 @@
</el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="24">
</el-col> -->
<!-- <el-col :span="24">
<el-form-item label="备注" prop="remark">
<el-input type="textarea" v-model="form.remark" placeholder="请填写备注" autocomplete="off"></el-input>
</el-form-item>
</el-col>
</el-col> -->
</el-row>
</el-form>
@ -128,8 +189,44 @@
<el-button type="primary" v-preventReClick @click="submitForm('form')"></el-button>
</div>
</el-dialog>
</div>
</div>
<el-dialog class="common-dialog" title="文件预览" @close="resetFile" :visible.sync="dialogFileVisible" width="60%">
<div class="dialogConcent">
<el-scrollbar style="flex: 1">
<el-table :data="fileData" class="v-table" :height="tableHeight" style="width: 100%">
<el-table-column :prop="column.field" :align="column.align" v-for="(column,index) in filecolumns"
:label="column.title" :width="column.width" :fixed="column.fixed">
<template slot-scope="scope">
<!-- <div v-if="column.type=='date'">
<el-form>
<el-form-item label="" prop="scope.row[column.field]">
<el-date-picker
style="width:100%"
v-model="scope.row[column.field]"
type="date"
format="yyyy-MM-dd"
value-format="yyyy-MM-dd"
>
</el-date-picker>
</el-form-item>
</el-form>
</div> -->
<div>
<el-input v-model="scope.row[column.field]"></el-input>
</div>
</template>
</el-table-column>
</el-table>
</el-scrollbar>
</div>
<div slot="footer" class="dialog-footer">
<el-button @click="resetFile"> </el-button>
<el-button type="primary" v-preventReClick @click="submitFile"></el-button>
</div>
</el-dialog>
</div>
</template>
@ -139,12 +236,19 @@
get,
store,
save,
del
del,
importShow,
importPlan
} from '../../../api/maintainmanagement/index.js'
import {
listCommonuser
} from '../../../api/common.js'
import {
listroad
} from '../../../api/basic/road.js'
import {
getToken
} from '@/utils/auth'
import {
listarea
} from '../../../api/basic/area.js'
@ -164,10 +268,25 @@
areaList:[],
plantypes:[{
id:1,
value:"日常雨水设施养护"
value:"雨水管道疏挖"
},{
id:2,
value:"在建工地养护"
value:"雨水管道疏通"
},{
id:3,
value:"汛期助排"
},{
id:4,
value:"污泥外运"
},{
id:5,
value:"出水口排查"
},{
id:6,
value:"专项处理"
},{
id:7,
value:"维修"
}],
dayList:[],
dateRange:[],
@ -180,41 +299,79 @@
page: 1,
page_size: 15,
total: 0
},
roadsList: [],
roadName: "",
roaddisabled: false,
roadloading: false,
fileList:[],
uploadOther: {
token: ""
},
form: {
name:"",
form: {
name:"养护计划",
item_type:"",
area_id:"",
day:"",
road_id:"",
inspection_well:0,
side_well:0,
master_pipe:0,
branch_pipe:0,
start_date:"",
end_date:"",
responsible_id:"",
remark:""
end_date:""
},
rules: {
name:[{
required: true,
message: '请填写养护名称',
trigger: 'blur',
}],
rules: {
area_id:[{
required: true,
message: '请选择所属片区',
trigger: 'blur',
}]
},
},
fileData:[],
dialogFileVisible:false,
filecolumns:[{
field: "序号",
title: "序号",
type: "string",
align: "left",
},{
field: "路名",
title: "路名",
type: "string",
align: "left",
},{
field: "start_date",
title: "开始时间",
type: "date",
align: "left",
},{
field: "end_date",
title: "结束时间",
type: "date",
align: "left",
},{
field: "master_pipe",
title: "主管",
type: "string",
align: "left",
},{
field: "branch_pipe",
title: "支管",
type: "string",
align: "left",
}],
columns: [{
field: "name",
title: "养护名称",
field: "roadName",
title: "所属道路",
type: "string",
align: "left",
width:240
},
{
field: "item_type_name",
title: "养护项目",
title: "养护类型",
type: "string",
align: "center",
width:180
@ -226,14 +383,6 @@
width:180,
align: "center"
},
{
field: "day",
title: "循环机制",
type: "string",
width:120,
align: "center"
},
{
field: "daterange",
title: "养护周期",
@ -243,12 +392,34 @@
},
{
field: "responsibleName",
title: "责任人",
field: "inspection_well",
title: "窨井",
type: "string",
align: "center",
width:180,
},
{
field: "side_well",
title: "边井",
type: "string",
align: "center",
width:180,
},
{
field: "master_pipe",
title: "主管数",
type: "string",
align: "center",
width:180,
},
{
field: "branch_pipe",
title: "支管数",
type: "string",
align: "center",
width:180,
},
{
field: "created_at",
title: "提交日期",
@ -281,6 +452,7 @@
var topHeight = 50; //
let tableHeight = clientHeight - lxHeader_height - topHeight - paginationHeight - 20;
that.tableHeight = tableHeight;
this.uploadOther.token = getToken();
listarea({
page: 1,
page_size: 999,
@ -322,8 +494,9 @@
m.item_type_name = k.value
}
}
m.area_name = m.area_info.name
m.responsibleName = m.responsible?m.responsible.name :""
m.area_name = m.area_info?m.area_info.name:""
m.roadName = m.road?m.road.name:""
// m.responsibleName = m.responsible?m.responsible.name :""
}
this.tableData = response.data;
this.paginations.total = response.total;
@ -336,9 +509,12 @@
info(obj) {
var that = this;
get(obj.id).then(res => {
let result = Object.assign(that.form, res);
let result = Object.assign(that.form, res);
that.roadName = ""
that.roaddisabled = true
// this.$set(that.form,res);
that.form = result;
that.roadName = result.road?result.road.name:""
that.dateRange = [result.start_date,result.end_date]
}).catch(error => {
@ -407,9 +583,114 @@
resetForm(formName) {
var that = this;
that.dateRange = [];
that.roadName = ""
that.roaddisabled = false
this.$refs[formName].resetFields();
that.dialogFormVisible = false;
},
chooseRoad(val) {
this.form.road_id = val
},
remoteRoad() {
this.roadsList = []
},
remoteMethod(query) {
if (query != '') {
this.roadloading = true
listroad({
name: query
}).then(res => {
this.roadloading = false
this.roadsList = res.data
})
} else {
this.roadsList = []
}
},
handleRemove(file, fileList) {
console.log(file, fileList);
},
handlePreview(file) {
console.log(file);
},
handleExceed(files, fileList) {
this.$message.warning(`当前限制选择 1 个文件,本次选择了 ${files.length} 个文件,共选择了 ${files.length + fileList.length} 个文件`);
},
beforeRemove(file, fileList) {
return this.$confirm(`确定移除 ${ file.name }`);
},
handleSuccess(response, file, fileList){
// this.fileList = response
var nowyear = ""
var k = 0
for(var i=0;i<response.length;i++){
for(var m of response[i]){
let result = Object.assign(m, {})
if(result.start_date!=""){
if(result.start_date.length>5){
nowyear = result.start_date.substring(0,4)
}else{
m.start_date = nowyear+"-"+result.start_date.replace(".","-")
m.end_date = nowyear+"-"+result.end_date.replace(".","-")
let startAll = m.start_date.split("-")
let endAll = m.end_date.split("-")
startAll[1] = startAll[1]<10? "0"+startAll[1]:startAll[1]
startAll[2] = startAll[2]<10? "0"+startAll[2]:startAll[2]
endAll[1] = endAll[1]<10? "0"+endAll[1]:endAll[1]
endAll[2] = endAll[2]<10? "0"+endAll[2]:endAll[2]
m.start_date = startAll[0]+"-"+startAll[1]+"-"+startAll[2]
m.end_date = endAll[0]+"-"+endAll[1]+"-"+endAll[2]
}
}else{
let dateStr = result['日期']+""
dateStr = dateStr.replace("",";")
dateStr = dateStr.replace("-",";")
if(dateStr.indexOf(';')!=-1){
let dateall = dateStr.split(";")
m.start_date = nowyear+"-"+dateall[0].replace(".","-")
m.end_date = nowyear+"-"+dateall[1].replace(".","-")
let startAll = m.start_date.split("-")
let endAll = m.end_date.split("-")
startAll[1] = startAll[1]<10? "0"+startAll[1]:startAll[1]
startAll[2] = startAll[2]<10? "0"+startAll[2]:startAll[2]
endAll[1] = endAll[1]<10? "0"+endAll[1]:endAll[1]
endAll[2] = endAll[2]<10? "0"+endAll[2]:endAll[2]
m.start_date = startAll[0]+"-"+startAll[1]+"-"+startAll[2]
m.end_date = endAll[0]+"-"+endAll[1]+"-"+endAll[2]
}
}
if(result['序号']!=""&&result['序号']!="合计"){
this.fileData.push(m)
}
}
}
this.dialogFileVisible = true
},
submitFile(){
console.log(this.fileData)
// return
importPlan({
data:this.fileData
}).then(res=>{
this.$Message.success('操作成功');
this.fileList = []
this.fileData = []
this.load();
this.dialogFileVisible = false
}).catch(error=>{
this.$Message.error('检查信息是否正确,修改后再次提交');
console.log(error)
reject(error)
})
},
resetFile(){
this.fileList = []
this.fileData = []
this.dialogFileVisible = false
}
}
}
@ -421,5 +702,16 @@
}
.width100{
width:100%;
}
.upfile{
display: inline-block;
vertical-align: bottom;
margin-left: 10px;
}
.el-upload-list.el-upload-list--text{
display: inline-block;
height: 32px;
line-height: 32px;
vertical-align: top;
}
</style>

Loading…
Cancel
Save