desc: 增加琏计划运行图修改

This commit is contained in:
zyy 2019-09-04 16:32:41 +08:00
parent 6b9047c919
commit 118ed1296c
6 changed files with 210 additions and 55 deletions

View File

@ -89,9 +89,7 @@ export function postCreatePlan(data) {
}); });
} }
/** // 删除运行图
* 删除运行图
*/
export function deleteRunPlan(planId) { export function deleteRunPlan(planId) {
return request({ return request({
url: `/api/runPlan/draft/${planId}`, url: `/api/runPlan/draft/${planId}`,
@ -99,6 +97,15 @@ export function deleteRunPlan(planId) {
}); });
} }
// 修改运行图内容
export function putRunPlanDetail(data) {
return request({
url: `/api/runPlan/draft/${data.planId}`,
method: 'put',
data: data
});
}
/** /**
* 发布运行图 * 发布运行图
*/ */
@ -221,15 +228,6 @@ export function duplicateService(data) {
}); });
} }
/** 修改计划*/
// export function updatePlanService(data) {
// return request({
// url: `/api/runPlan/draft/${data.planId}/service/${data.serviceNumber}`,
// method: 'put',
// data: data
// })
// }
/** 增加任务*/ /** 增加任务*/
export function addPlanTrip(data) { export function addPlanTrip(data) {
return request({ return request({

View File

@ -1,9 +1,9 @@
<template> <template>
<el-dialog :title="this.$t('map.operationGraphPublished')" :visible.sync="dialogShow" width="30%" :before-close="handleClose"> <el-dialog :title="this.$t('map.operationGraphPublished')" :visible.sync="dialogShow" width="30%" :before-close="handleClose">
<div> <div>
<el-form ref="form" label-position="right" :model="editModel" label-width="120px" size="mini"> <el-form ref="form" label-position="right" :model="editModel" label-width="120px" size="mini" :rules="rules">
<el-form-item :label="this.$t('map.operationGraphName')" prop="name"> <el-form-item :label="this.$t('map.operationGraphName')" prop="name">
<el-input v-model="editModel.name" :disabled="true" /> <el-input v-model="editModel.name" />
</el-form-item> </el-form-item>
</el-form> </el-form>
</div> </div>
@ -34,6 +34,11 @@ export default {
editModel: { editModel: {
planId: '', planId: '',
name: '' name: ''
},
rules: {
name: [
{ required: true, message: '请输入运行图名称', trigger: 'blur' }
]
} }
}; };
}, },

View File

@ -155,18 +155,22 @@ export default {
// title: '', // title: '',
// click: this.handleImportRunPlan // click: this.handleImportRunPlan
// }, // },
{
title: '删除运行图',
click: this.handledeleteRunPlan
},
{ {
title: '新建运行图', title: '新建运行图',
click: this.handleCreateEmptyPlan click: this.handleCreateEmptyPlan
}, },
{
title: '修改运行图名称',
click: this.handleEditPlan
},
{ {
title: '修改站间运行时间', title: '修改站间运行时间',
click: this.handleModifyingStationIntervalTime click: this.handleModifyingStationIntervalTime
// disabledCallback: () => { return !this.$route.query.planId }, // disabledCallback: () => { return !this.$route.query.planId },
},
{
title: '删除运行图',
click: this.handledeleteRunPlan
} }
] ]
}, },
@ -398,6 +402,10 @@ export default {
handledeleteRunPlan() { handledeleteRunPlan() {
this.$emit('dispatchDialog', { name: 'openRunPlan', params: {type: 'delete'} }); this.$emit('dispatchDialog', { name: 'openRunPlan', params: {type: 'delete'} });
}, },
//
handleEditPlan() {
this.$emit('dispatchDialog', { name: 'openRunPlan', params: {type: 'edit'} });
},
loadingScreen() { loadingScreen() {
this.loading = this.$loading({ this.loading = this.$loading({
lock: true, lock: true,

View File

@ -51,6 +51,7 @@
<script> <script>
import { createEmptyPlan, queryRunPlanList, postCreatePlan } from '@/api/runplan'; import { createEmptyPlan, queryRunPlanList, postCreatePlan } from '@/api/runplan';
import { UrlConfig } from '@/router/index';
export default { export default {
name: 'CreateEmptyPlan', name: 'CreateEmptyPlan',
@ -135,8 +136,9 @@ export default {
}; };
this.$emit('dispatchOperate', params); this.$emit('dispatchOperate', params);
this.$emit('dispatchDialog', { name: 'openRunPlan', params: {type: 'add'} }); // this.$emit('dispatchDialog', { name: 'openRunPlan', params: {type: 'add'} });
this.$message.success('创建空运行图成功!'); this.$message.success('创建空运行图成功!');
this.jump(resp.data, this.newModel.name);
this.doClose(); this.doClose();
}).catch(() => { }).catch(() => {
this.$messageBox('创建空运行图失败'); this.$messageBox('创建空运行图失败');
@ -149,8 +151,9 @@ export default {
if (valid) { if (valid) {
this.loading = true; this.loading = true;
postCreatePlan(this.pullModel).then(resp => { postCreatePlan(this.pullModel).then(resp => {
this.$emit('dispatchDialog', { name: 'openRunPlan', params: {type: 'add'} }); // this.$emit('dispatchDialog', { name: 'openRunPlan', params: {type: 'add'} });
this.$message.success('创建运行图成功!'); this.$message.success('创建运行图成功!');
this.jump(resp.data, this.pullModel.name);
this.doClose(); this.doClose();
}).catch(() => { }).catch(() => {
this.$messageBox('创建运行图失败'); this.$messageBox('创建运行图失败');
@ -159,7 +162,10 @@ export default {
} }
}); });
} }
},
jump(planId, planName) {
const query = { skinCode: this.$route.query.skinCode, mapId: this.$route.query.mapId, planId: planId, planName: planName };
this.$router.push({ path: `${UrlConfig.plan.tool}`, query: query });
} }
} }
}; };

View File

@ -0,0 +1,116 @@
<template>
<el-dialog
v-dialogDrag
class="planEdit__tool create-empty-plan"
:title="title"
:visible.sync="dialogShow"
width="30%"
:before-close="doClose"
:z-index="3000"
:modal="false"
:close-on-click-modal="false"
>
<div>
<el-row>
<el-form ref="form" :model="editModel" label-width="140px" size="mini" :rules="rules" @submit.native.prevent>
<el-form-item label="运行图名称:" prop="name">
<el-input v-model="editModel.name" autofocus />
</el-form-item>
</el-form>
</el-row>
</div>
<span slot="footer" class="dialog-footer">
<el-button type="primary" :loading="loading" @click="handleEdit">修改</el-button>
<el-button @click="doClose">{{ $t('map.cancel') }}</el-button>
</span>
</el-dialog>
</template>
<script>
import { putRunPlanDetail } from '@/api/runplan';
export default {
name: 'CreateEmptyPlan',
components: {
},
data() {
return {
activeTab: 'first',
dialogShow: false,
loading: false,
publishMapList: [],
editModel: {
planId: '',
name: ''
}
};
},
computed: {
title() {
return '新建运行图';
},
rules() {
return {
name: [
{ required: true, message: '请输入运行图名称', trigger: 'blur' }
]
};
}
},
mounted() {
},
methods: {
doShow(data) {
this.dialogShow = true;
if (data && data.name) {
this.editModel.name = data.name;
this.editModel.planId = data.id;
}
},
doClose() {
this.loading = false;
this.dialogShow = false;
this.editModel.name = '';
if (this.$refs.form) {
this.$refs.form.resetFields();
}
},
handleEdit() {
this.$refs['form'].validate((valid) => {
if (valid) {
this.loading = true;
putRunPlanDetail(this.editModel).then(resp => {
const params = {
dialogName: 'openRunPlan',
operate: 'loadRunPlanData',
params: { planId: resp.data, skinCode: this.$route.query.skinCode, planName: this.editModel.name, refresh: true }
};
this.$emit('dispatchOperate', params);
this.$message.success('修改运行图名称成功!');
this.$emit('renewal');
this.doClose();
}).catch(() => {
this.$messageBox('修改运行图名称失败');
this.doClose();
});
}
});
}
}
};
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
@import "src/styles/mixin.scss";
/deep/ {
.el-input {
width: 160px;
}
.el-input-number {
width: 120px;
}
}
</style>

View File

@ -1,44 +1,49 @@
<template> <template>
<el-dialog <div>
v-dialogDrag <el-dialog
class="planEdit__tool open-runplan" v-dialogDrag
:title="title" class="planEdit__tool open-runplan"
:visible.sync="show" :title="title"
width="640px" :visible.sync="show"
:before-close="doClose" width="640px"
:z-index="2000" :before-close="doClose"
:modal="false" :z-index="2000"
:close-on-click-modal="false" :modal="true"
> :close-on-click-modal="false"
<el-scrollbar wrap-class="scrollbar-wrapper" :style="{height: height+'px'}"> >
<el-tree <el-scrollbar wrap-class="scrollbar-wrapper" :style="{height: height+'px'}">
ref="tree" <el-tree
class="filter-tree" ref="tree"
:data="runPlanList" class="filter-tree"
:props="defaultProps" :data="runPlanList"
default-expand-all :props="defaultProps"
:style="{height: height-20+'px'}" highlight-current
@node-click="handleNodeClick" default-expand-all
> :style="{height: height-20+'px'}"
<!-- <span slot-scope="{ node, data }"> @node-click="handleNodeClick"
<el-radio v-model="planId" :label="data.id"><span>{{ data.name }}</span></el-radio> />
</span> --> </el-scrollbar>
</el-tree> <el-row type="flex" justify="center" class="button-group">
</el-scrollbar> <el-button v-if="type == 'add'" type="primary" @click="handleConfirm">选择运行图</el-button>
<el-row type="flex" justify="center" class="button-group"> <el-button v-if="type == 'delete'" type="primary" @click="handleDelete">删除</el-button>
<el-button v-if="type == 'add'" type="primary" @click="handleConfirm">选择运行图</el-button> <el-button v-if="type == 'edit'" type="primary" @click="handleEdit">修改</el-button>
<el-button v-if="type == 'delete'" type="primary" @click="handleDelete">删除</el-button> <el-button @click="dialogShow = false"> </el-button>
<el-button @click="dialogShow = false"> </el-button> </el-row>
</el-row> </el-dialog>
</el-dialog> <edit-plan-name ref="editPlan" @renewal="getRunPlanList" />
</div>
</template> </template>
<script> <script>
import { getRpListByMapId, deleteRunPlan } from '@/api/runplan'; import { getRpListByMapId, deleteRunPlan } from '@/api/runplan';
import { UrlConfig } from '@/router/index'; import { UrlConfig } from '@/router/index';
import EditPlanName from './editPlanName';
export default { export default {
name: 'OpenRunPlan', name: 'OpenRunPlan',
components: {
EditPlanName
},
props: { props: {
skinCode: { skinCode: {
type: String, type: String,
@ -53,6 +58,7 @@ export default {
planId: '', planId: '',
planName: '', planName: '',
type: 'add', type: 'add',
// defaultShowKeys: [],
runPlanList: [], runPlanList: [],
runPlanDict: {}, runPlanDict: {},
defaultProps: { defaultProps: {
@ -88,21 +94,28 @@ export default {
this.$router.push({ path: `${UrlConfig.plan.tool}`, query: query }); this.$router.push({ path: `${UrlConfig.plan.tool}`, query: query });
} }
}, },
doShow(data) { getRunPlanList() {
this.type = data.type || 'add';
getRpListByMapId(this.$route.query.mapId).then((resp) => { getRpListByMapId(this.$route.query.mapId).then((resp) => {
this.runPlanList = resp.data; this.runPlanList = resp.data;
this.runPlanList.forEach(elem => { this.runPlanList.forEach(elem => {
this.runPlanDict[elem.id] = elem.name; this.runPlanDict[elem.id] = elem.name;
}); });
// this.defaultShowKeys = [this.planId];
this.dialogShow = true; this.dialogShow = true;
}).catch(() => { }).catch(() => {
this.$messageBox('获取运行图列表失败'); this.$messageBox('获取运行图列表失败');
}); });
}, },
doShow(data) {
this.type = data.type || 'add';
this.getRunPlanList();
},
doClose() { doClose() {
this.dialogShow = false; this.dialogShow = false;
this.planId = '';
this.planName = '';
}, },
//
handleConfirm() { handleConfirm() {
this.loadRunPlanData({ this.loadRunPlanData({
planId: this.planId, planId: this.planId,
@ -111,6 +124,7 @@ export default {
}); });
this.doClose(); this.doClose();
}, },
//
handleDelete() { handleDelete() {
deleteRunPlan(this.planId).then(Response => { deleteRunPlan(this.planId).then(Response => {
this.$message.success(`删除成功!`); this.$message.success(`删除成功!`);
@ -122,6 +136,14 @@ export default {
}).catch(() => { }).catch(() => {
this.$messageBox(this.$t('tip.deleteOperationGraphFailed')); this.$messageBox(this.$t('tip.deleteOperationGraphFailed'));
}); });
},
//
handleEdit() {
if (this.planId && this.planName) {
this.$refs.editPlan.doShow({id: this.planId, name: this.planName});
} else {
this.$message.info('请选择运行图');
}
} }
} }
}; };