rt-sim-training-client/src/views/publish/publishMap/project.vue

99 lines
3.5 KiB
Vue
Raw Normal View History

2019-10-29 14:14:14 +08:00
<template>
<el-dialog v-dialogDrag :title="this.$t('publish.setTheProject')" :visible.sync="dialogVisible" width="30%" center>
2019-10-29 14:14:14 +08:00
<el-form ref="form" :model="formModel" label-width="100px" label-position="left">
<el-form-item :label="this.$t('publish.mapName')">
2019-10-29 14:14:14 +08:00
<span>{{ formModel.name }}</span>
</el-form-item>
<el-form-item :label="this.$t('publish.whetherItBelongsToTheProject')" prop="project">
2019-10-29 14:14:14 +08:00
<el-radio-group v-model="formModel.project" @change="changeProject">
<el-radio :label="booleanValue.t">{{ $t('publish.trialYes') }}</el-radio>
<el-radio :label="booleanValue.f">{{ $t('publish.trialNo') }}</el-radio>
2019-10-29 14:14:14 +08:00
</el-radio-group>
</el-form-item>
<el-form-item
v-if="formModel.project"
:label="this.$t('publish.belongsProject')"
2019-10-29 14:14:14 +08:00
prop="projectCode"
:rules="{
required: true, message: this.$t('publish.theBelongsProjectCannotBeEmpty'), trigger: 'change'
2019-10-29 14:14:14 +08:00
}"
>
<el-select v-model="formModel.projectCode" :placeholder="this.$t('publish.pleaseSelectTheBelongsProject')">
2020-04-17 10:16:56 +08:00
<el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value" />
2019-10-29 14:14:14 +08:00
</el-select>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
2019-10-31 14:35:28 +08:00
<el-button v-loading="loading" type="primary" @click="doSave">{{ $t('global.confirm') }}</el-button>
2019-10-29 14:14:14 +08:00
<el-button @click="dialogVisible = false">{{ $t('global.cancel') }}</el-button>
</span>
</el-dialog>
</template>
<script>
import { setMapProject } from '@/api/jmap/map';
2020-04-17 10:16:56 +08:00
import { ProjectList } from '@/scripts/ProjectConfig';
2019-10-29 14:14:14 +08:00
export default {
2019-10-31 10:09:43 +08:00
name: 'SetMapProject',
data() {
return {
dialogVisible: false,
formModel: {
id: '',
name: '',
cityCode: '',
project: false,
projectCode: ''
},
2019-10-31 14:35:28 +08:00
loading: false,
2019-10-31 10:09:43 +08:00
projectCodeShow: false,
booleanValue: {
t: true,
f: false
2020-04-17 10:16:56 +08:00
},
options: []
2019-10-31 10:09:43 +08:00
};
},
methods: {
doShow(row) {
this.dialogVisible = true;
this.formModel.id = row.id;
this.formModel.name = row.name;
this.formModel.cityCode = row.cityCode;
this.formModel.project = row.project;
this.formModel.projectCode = row.project ? row.projectCode : '';
2020-04-17 10:16:56 +08:00
this.options = [];
ProjectList.forEach(item => {
this.options.push({label: item.label, value: item.value.toUpperCase()});
});
2019-10-31 10:09:43 +08:00
},
doSave() {
this.$refs['form'].validate((valid) => {
if (valid) {
2019-10-31 14:35:28 +08:00
if (this.loading) {
return;
}
this.loading = true;
2019-10-31 10:09:43 +08:00
setMapProject(this.formModel).then(resp =>{
this.$message.success(this.$t('tip.setProjectSuccess'));
2019-10-31 14:35:28 +08:00
this.loading = false;
2019-10-31 10:09:43 +08:00
this.dialogVisible = false;
this.$emit('refresh');
2019-10-31 14:35:28 +08:00
}).catch( ()=>{
this.$messageBox(this.$t('tip.setProjectFail'));
2019-10-31 10:09:43 +08:00
});
} else {
return false;
}
});
2019-10-29 14:14:14 +08:00
2019-10-31 10:09:43 +08:00
},
changeProject(val) {
if (!val) {
this.formModel.projectCode = '';
}
}
}
2019-10-29 14:14:14 +08:00
};
</script>