Commit b416f247 authored by caicaicai's avatar caicaicai

修改

parent 250c26db
......@@ -130,6 +130,68 @@ var HttpReq = function(){
data:data,
})
},
//系统管理——数据字典——月统计设置
monthStatisticsQuery: function(param){
return request({
url: '/api/Month',
method: 'get',
params:param,
})
},
monthStatisticsAdd: function(data){
return request({
url: '/api/Month',
method: 'POST',
data:data,
}).then((res) => {
return res
})
},
monthStatisticsUpdate: function(data){
return request({
url: '/api/Month',
method: 'PUT',
data:data,
})
},
monthStatisticsDel: function(data){
return request({
url: '/api/Month',
method: 'Delete',
data:data,
})
},
//系统管理——数据字典——通知频率设置
notifiyFrequencyQuery: function(param){
return request({
url: '/api/Hz',
method: 'get',
params:param,
})
},
notifiyFrequencyAdd: function(data){
return request({
url: '/api/Hz',
method: 'POST',
data:data,
}).then((res) => {
return res
})
},
notifiyFrequencyUpdate: function(data){
return request({
url: '/api/Hz',
method: 'PUT',
data:data,
})
},
notifiyFrequencyDel: function(data){
return request({
url: '/api/Hz',
method: 'Delete',
data:data,
})
},
//车辆管理——车辆类型
carTypeQuery: function(param){
return request({
......
......@@ -161,12 +161,6 @@ export default {
// 点击搜索
toSearch() {
this.page = 1;
// if(this.query.startTime){
// this.query.startTime = this.currentTime(this.query.startTime);
// }
// if(this.query.endTime){
// this.query.endTime = this.currentTime(this.query.endTime);
// }
this.loadData();
},
// 重置搜索
......
......@@ -444,9 +444,6 @@ export default {
this.loadGradeData();
})
},
//修改时间格式
changeTimeFormat(row){
return this.currentTime(row.month);
......
<template>
<div class="common-page device-manage">
<!-- 表格 -->
<div class="panel-bottom page-row">
<h3>月统计设置</h3>
<div class="ctin-box">
<div class="content-within">
<div class="content-fix">
<div class="toolbar">
<el-button size="mini" type="primary" icon="el-icon-plus" @click="toAdd">新增</el-button>
</div>
<div class="content">
<el-table :data="tableData" v-loading="loading" border style="width:auto" :row-class-name="tableRowClassName">
<el-table-column prop="id" label="序号" align="center"></el-table-column>
<el-table-column prop="startTime" label="开始时间" align="center" :formatter="changeDate1"></el-table-column>
<el-table-column prop="endTime" label="结束时间" align="center" :formatter="changeDate2"></el-table-column>
<el-table-column label="操作" align="center" fixed="right">
<template slot-scope="scope">
<el-button size="mini" type="primary" icon="el-icon-edit" @click="toEdit(scope.row)"></el-button>
<el-button size="mini" type="danger" icon="el-icon-delete" @click="toDelete(scope.row)"></el-button>
</template>
</el-table-column>
</el-table>
<!--分页组件-->
<el-pagination :total="total" :current-page="page" style="margin-top: 8px;" layout="total, prev, pager, next, sizes" @size-change="sizeChange" @current-change="pageChange" />
</div>
</div>
</div>
</div>
</div>
<!-- 表单渲染 -->
<el-dialog append-to-body :close-on-click-modal="true" :before-close="cancelForm" :visible.sync="form.visible" :title="form.title" width="700px">
<el-form :model="form.item" :rules="rules" ref="form1" :inline="true" size="small" label-width="150px">
<el-form-item label="开始时间" prop="startTime">
<el-date-picker v-model="form.item.startTime" type="date" placeholder="选择日期"></el-date-picker>
</el-form-item>
<el-form-item label="结束时间" prop="endTime">
<el-date-picker v-model="form.item.endTime" type="date" placeholder="选择日期"></el-date-picker>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="text" @click="cancelForm">取消</el-button>
<el-button :loading="form.status.cu === 2" type="primary" @click="submitForm('form1', form.item)">确认</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { Tools, HttpReq, Dates} from '@/assets/js/common.js';
export default {
name: 'MonthStatistics',
components: {},
data() {
return {
loading: false,
page: 1,
size: 10,
total: 0,
query:{},
tableData: [],
form: {
title:'新增月统计规则',
visible:false,
reqType:'add',
status:{cu:0},
item:{},
},
rules: {
// fdritime: [
// {required: true, message: '请输入月统计规则', trigger: 'blur' }
// ],
},
}
},
mounted() {
var that = this;
this.$nextTick(() => {
this.loadData();
})
},
methods: {
loadData() {
var sort = 'id,desc';
var param = this.query;
param.page = this.page - 1;
param.size = this.size;
param.sort = sort;
this.$nextTick(()=>{
HttpReq.truckDispatching.monthStatisticsQuery(param).then((res) => {
if(res.code == 200){
this.loading = false;
this.tableData = res.data.content;
this.total = res.data.totalElements;
}
})
})
},
tableRowClassName({row, rowIndex}) {
if (rowIndex === 1) {
return 'warning-row';
} else if (rowIndex === 3) {
return 'success-row';
}
return '';
},
cancelForm(a, b, c){
this.form.visible = false;
},
toAdd() {
// 请除表单验证
this.$refs['form1'] && this.$refs['form1'].clearValidate();
this.form.title = '新增月统计规则';
this.form.status.cu = 0;
this.form.visible = true;
this.form.reqType = 'add';
this.form.item = {};
},
toEdit(item) {
// 请除表单验证
this.$refs['form1'] && this.$refs['form1'].clearValidate();
this.form.title = '修改月统计规则';
this.form.status.cu = 0;
this.form.visible = true;
this.form.item = {...item};
this.form.reqType = 'edit';
},
toDelete(item) {
var id = item.id;
this.$confirm('确认删除该条数据吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then((e) => {
this.reqRemoveProject([id])
}).catch((e) => {})
},
pageChange(e) {
this.page = e
this.loadData()
},
sizeChange(e) {
this.page = 1
this.size = e
this.loadData()
},
submitForm(validateName, item){
if(!this.form.status.cu){
this.form.status.cu = 2;
this.$refs[validateName].validate(valid => {
if(valid){
if(this.form.reqType === 'add'){
this.reqAddItem(this.form, item)
}else{
this.reqUpdateItem(this.form, item)
}
}else{
this.form.status.cu = 0
}
});
};
},
//新增月统计规则
reqAddItem(form, item){
let lastData = {...item};
HttpReq.truckDispatching.monthStatisticsAdd(lastData).then((res) => {
form.visible = false;
if(res.code == 200){
this.$notify({
title: '月统计规则新增成功!',
type: 'success',
duration: 2500
});
this.loadData()
}else{
this.$notify({
title: res.msg,
type: 'error',
duration: 2500
})
}
}).catch(function(error) {
form.status.cu = 0
});
},
//修改月统计规则
reqUpdateItem(form, item){
let lastData = {...item};
HttpReq.truckDispatching.monthStatisticsUpdate(lastData).then((res) => {
form.visible = false;
if(res.code == 200){
this.$notify({
title: '月统计规则修改成功!',
type: 'success',
duration: 2500
});
this.loadData()
}else{
this.$notify({
title: res.msg,
type: 'error',
duration: 2500
})
}
}).catch(function(error) {
form.status.cu = 0
});
},
//删除月统计规则
reqRemoveProject(item){
HttpReq.truckDispatching.monthStatisticsDel(item).then((res) => {
if(res.status == 400){
this.$notify({
title: res.msg,
type: 'error',
duration: 2500
})
}else{
this.$notify({
title: '删除成功!',
type: 'success',
duration: 2500
});
}
this.loadData();
})
},
//改变日期格式
changeDate1(row){
var date = new Date(row.startTime);
var year = date.getFullYear(); //年 ,从 Date 对象以四位数字返回年份
var month = date.getMonth() + 1; //月 ,从 Date 对象返回月份 (0 ~ 11) ,date.getMonth()比实际月份少 1 个月
var day = date.getDate(); //日 ,从 Date 对象返回一个月中的某一天 (1 ~ 31)
var hours = date.getHours(); //小时 ,返回 Date 对象的小时 (0 ~ 23)
var minutes = date.getMinutes(); //分钟 ,返回 Date 对象的分钟 (0 ~ 59)
var seconds = date.getSeconds(); //秒 ,返回 Date 对象的秒数 (0 ~ 59)
//修改月份格式
if (month >= 1 && month <= 9) {
month = "0" + month;
}
//修改日期格式
if (day >= 0 && day <= 9) {
day = "0" + day;
}
let currentFormatDate = year + "-" + month + "-" + day;
return currentFormatDate;
},
//改变日期格式
changeDate2(row){
var date = new Date(row.endTime);
var year = date.getFullYear(); //年 ,从 Date 对象以四位数字返回年份
var month = date.getMonth() + 1; //月 ,从 Date 对象返回月份 (0 ~ 11) ,date.getMonth()比实际月份少 1 个月
var day = date.getDate(); //日 ,从 Date 对象返回一个月中的某一天 (1 ~ 31)
var hours = date.getHours(); //小时 ,返回 Date 对象的小时 (0 ~ 23)
var minutes = date.getMinutes(); //分钟 ,返回 Date 对象的分钟 (0 ~ 59)
var seconds = date.getSeconds(); //秒 ,返回 Date 对象的秒数 (0 ~ 59)
//修改月份格式
if (month >= 1 && month <= 9) {
month = "0" + month;
}
//修改日期格式
if (day >= 0 && day <= 9) {
day = "0" + day;
}
let currentFormatDate = year + "-" + month + "-" + day;
return currentFormatDate;
}
}
}
</script>
<style rel="stylesheet/scss" lang="scss" scope>
.el-table .warning-row {
background: oldlace;
}
.el-table .success-row {
background: #f0f9eb;
}
.device-manage{
.panel-bottom{
.el-button{margin:2px 0;padding:6px 15px;font-size:14px;}
.btn-groub2{
display:inline-block;
.el-button{margin:2px 0;padding:6px 15px;font-size:15px;}
.el-button--warning {
background-color: #e6a23c;
border-color: #e6a23c;
}
.el-button--warning:focus,.el-button--warning:hover{background:#ebb563;border-color:#ebb563;}
}
}
}
.ecahrt1-dialog{
display:flex;align-items:center;
.el-dialog{
margin-top:inherit !important;display:table !important;width:fit-content;
.el-form-item{margin-right:0;}
}
.el-dialog__header{height:0;padding:0;display:block;}
.form-body{
border:1px solid #999;width:800px;height:500px;position:relative;
>div{position:absolute;top:0;left:0;height:100%;width:100%;}
}
}
</style>
<template>
<div class="common-page device-manage">
<!-- 表格 -->
<div class="panel-bottom page-row">
<h3>通知频率设置</h3>
<div class="ctin-box">
<div class="content-within">
<div class="content-fix">
<div class="toolbar">
<el-button size="mini" type="primary" icon="el-icon-plus" @click="toAdd">新增</el-button>
</div>
<div class="content">
<el-table :data="tableData" v-loading="loading" border style="width:auto" :row-class-name="tableRowClassName">
<el-table-column prop="id" label="序号" align="center"></el-table-column>
<el-table-column prop="endclass" label="终端类型" align="center"></el-table-column>
<el-table-column prop="hz" label="通知频率(分钟)" align="center"></el-table-column>
<el-table-column label="操作" align="center" fixed="right">
<template slot-scope="scope">
<el-button size="mini" type="primary" icon="el-icon-edit" @click="toEdit(scope.row)"></el-button>
<el-button size="mini" type="danger" icon="el-icon-delete" @click="toDelete(scope.row)"></el-button>
</template>
</el-table-column>
</el-table>
<!--分页组件-->
<el-pagination :total="total" :current-page="page" style="margin-top: 8px;" layout="total, prev, pager, next, sizes" @size-change="sizeChange" @current-change="pageChange" />
</div>
</div>
</div>
</div>
</div>
<!-- 表单渲染 -->
<el-dialog append-to-body :close-on-click-modal="true" :before-close="cancelForm" :visible.sync="form.visible" :title="form.title" width="700px">
<el-form :model="form.item" :rules="rules" ref="form1" :inline="true" size="small" label-width="150px">
<el-form-item label="终端类型" prop="endclass">
<el-select v-model="form.item.endclass" placeholder="请选择终端类型" style="width:280px;">
<el-option label="卡车" value="卡车"></el-option>
<el-option label="电铲" value="电铲"></el-option>
</el-select>
</el-form-item>
<el-form-item label="通知频率(分钟)" prop="hz">
<el-input v-model="form.item.hz" style="width:280px;" placeholder="请输入通知频率"/>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="text" @click="cancelForm">取消</el-button>
<el-button :loading="form.status.cu === 2" type="primary" @click="submitForm('form1', form.item)">确认</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { Tools, HttpReq, Dates} from '@/assets/js/common.js';
export default {
name: 'NotifiyFrequency',
components: {},
data() {
return {
loading: false,
page: 1,
size: 10,
total: 0,
query:{},
tableData: [],
form: {
title:'新增通知频率',
visible:false,
reqType:'add',
status:{cu:0},
item:{},
},
rules: {
// fdritime: [
// {required: true, message: '请输入通知频率', trigger: 'blur' }
// ],
},
}
},
mounted() {
var that = this;
this.$nextTick(() => {
this.loadData();
})
},
methods: {
loadData() {
var sort = 'id,desc';
var param = this.query;
param.page = this.page - 1;
param.size = this.size;
param.sort = sort;
this.$nextTick(()=>{
HttpReq.truckDispatching.notifiyFrequencyQuery(param).then((res) => {
if(res.code == 200){
this.loading = false;
this.tableData = res.data.content;
this.total = res.data.totalElements;
}
})
})
},
tableRowClassName({row, rowIndex}) {
if (rowIndex === 1) {
return 'warning-row';
} else if (rowIndex === 3) {
return 'success-row';
}
return '';
},
cancelForm(a, b, c){
this.form.visible = false;
},
toAdd() {
// 请除表单验证
this.$refs['form1'] && this.$refs['form1'].clearValidate();
this.form.title = '新增通知频率';
this.form.status.cu = 0;
this.form.visible = true;
this.form.reqType = 'add';
this.form.item = {};
},
toEdit(item) {
// 请除表单验证
this.$refs['form1'] && this.$refs['form1'].clearValidate();
this.form.title = '修改通知频率';
this.form.status.cu = 0;
this.form.visible = true;
this.form.item = {...item};
this.form.reqType = 'edit';
},
toDelete(item) {
var id = item.id;
this.$confirm('确认删除该条数据吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then((e) => {
this.reqRemoveProject([id])
}).catch((e) => {})
},
pageChange(e) {
this.page = e
this.loadData()
},
sizeChange(e) {
this.page = 1
this.size = e
this.loadData()
},
submitForm(validateName, item){
if(!this.form.status.cu){
this.form.status.cu = 2;
this.$refs[validateName].validate(valid => {
if(valid){
if(this.form.reqType === 'add'){
this.reqAddItem(this.form, item)
}else{
this.reqUpdateItem(this.form, item)
}
}else{
this.form.status.cu = 0
}
});
};
},
//新增通知频率
reqAddItem(form, item){
let lastData = {...item};
HttpReq.truckDispatching.notifiyFrequencyAdd(lastData).then((res) => {
form.visible = false;
if(res.code == 200){
this.$notify({
title: '通知频率新增成功!',
type: 'success',
duration: 2500
});
this.loadData()
}else{
this.$notify({
title: res.msg,
type: 'error',
duration: 2500
})
}
}).catch(function(error) {
form.status.cu = 0
});
},
//修改通知频率
reqUpdateItem(form, item){
let lastData = {...item};
HttpReq.truckDispatching.notifiyFrequencyUpdate(lastData).then((res) => {
form.visible = false;
if(res.code == 200){
this.$notify({
title: '通知频率修改成功!',
type: 'success',
duration: 2500
});
this.loadData()
}else{
this.$notify({
title: res.msg,
type: 'error',
duration: 2500
})
}
}).catch(function(error) {
form.status.cu = 0
});
},
//删除通知频率
reqRemoveProject(item){
HttpReq.truckDispatching.notifiyFrequencyDel(item).then((res) => {
if(res.status == 400){
this.$notify({
title: res.msg,
type: 'error',
duration: 2500
})
}else{
this.$notify({
title: '删除成功!',
type: 'success',
duration: 2500
});
}
this.loadData();
})
},
}
}
</script>
<style rel="stylesheet/scss" lang="scss" scope>
.el-table .warning-row {
background: oldlace;
}
.el-table .success-row {
background: #f0f9eb;
}
.device-manage{
.panel-bottom{
.el-button{margin:2px 0;padding:6px 15px;font-size:14px;}
.btn-groub2{
display:inline-block;
.el-button{margin:2px 0;padding:6px 15px;font-size:15px;}
.el-button--warning {
background-color: #e6a23c;
border-color: #e6a23c;
}
.el-button--warning:focus,.el-button--warning:hover{background:#ebb563;border-color:#ebb563;}
}
}
}
.ecahrt1-dialog{
display:flex;align-items:center;
.el-dialog{
margin-top:inherit !important;display:table !important;width:fit-content;
.el-form-item{margin-right:0;}
}
.el-dialog__header{height:0;padding:0;display:block;}
.form-body{
border:1px solid #999;width:800px;height:500px;position:relative;
>div{position:absolute;top:0;left:0;height:100%;width:100%;}
}
}
</style>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment