2019-10-31 15:34:38 +08:00
|
|
|
<template>
|
|
|
|
<div>
|
|
|
|
<el-dialog :title="title" :visible.sync="dialogVisible" width="500px" :before-close="doClose" center>
|
|
|
|
<data-form ref="dataform" :form="form" :form-model="formModel" :rules="rules" />
|
|
|
|
<span slot="footer" class="dialog-footer">
|
|
|
|
<el-button type="primary" @click="doCreate">{{ $t('global.confirm') }}</el-button>
|
|
|
|
<el-button @click="doClose">{{ $t('global.cancel') }}</el-button>
|
|
|
|
</span>
|
|
|
|
</el-dialog>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<script>
|
|
|
|
import ConstConfig from '@/scripts/ConstConfig';
|
|
|
|
import Cookies from 'js-cookie';
|
|
|
|
export default {
|
2019-11-05 16:53:39 +08:00
|
|
|
name: 'CreateSubSystem',
|
2019-10-31 15:34:38 +08:00
|
|
|
props: {
|
2019-11-05 16:53:39 +08:00
|
|
|
title: { type:String, required:true },
|
|
|
|
operateType:{ type:String, required:true },
|
|
|
|
mapList:{
|
|
|
|
required:true,
|
|
|
|
type:Array
|
|
|
|
}
|
2019-10-31 15:34:38 +08:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
dialogVisible: false,
|
|
|
|
disabled:null,
|
|
|
|
productList:[],
|
|
|
|
projectList:[],
|
|
|
|
typeList:[],
|
|
|
|
formModel:{
|
2019-12-26 18:07:43 +08:00
|
|
|
customized:'',
|
2019-10-31 15:34:38 +08:00
|
|
|
mapId:'',
|
|
|
|
name: '',
|
2019-12-25 19:28:03 +08:00
|
|
|
prdType: '',
|
2019-10-31 15:34:38 +08:00
|
|
|
type: '',
|
|
|
|
id:null
|
|
|
|
}
|
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
2019-12-25 19:28:03 +08:00
|
|
|
prdTypeList() {
|
|
|
|
const productTypeList = ConstConfig.ConstSelect.prdType;
|
|
|
|
return Cookies.get('user_lang') == 'en'
|
|
|
|
? productTypeList.map(elem => { return { value: elem.value, label: elem.enlabel }; })
|
|
|
|
: productTypeList.map(elem => { return { value: elem.value, label: elem.label }; });
|
|
|
|
},
|
2019-10-31 15:34:38 +08:00
|
|
|
form() {
|
|
|
|
let form = {};
|
|
|
|
if (this.operateType == 'add') {
|
|
|
|
form = {
|
|
|
|
labelWidth: '150px',
|
|
|
|
items: [
|
|
|
|
{ prop: 'customized', label: this.$t('systemGenerate.customized'), type: 'select', required: true, options: this.projectList},
|
2019-12-25 19:28:03 +08:00
|
|
|
{ prop: 'mapId', label: this.$t('systemGenerate.mapName'), type: 'select', required: true, options: this.mapList},
|
|
|
|
{ prop: 'prdType', label: this.$t('system.prdType'), type: 'select', required: true, options:this.prdTypeList},
|
2019-10-31 15:34:38 +08:00
|
|
|
{ prop: 'name', label: this.$t('systemGenerate.name'), type: 'text', required: true},
|
|
|
|
{ prop: 'type', label: this.$t('systemGenerate.type'), type: 'select', required: true, options: this.typeList}
|
|
|
|
]
|
|
|
|
};
|
|
|
|
} else {
|
|
|
|
form = {
|
|
|
|
labelWidth: '150px',
|
|
|
|
items: [
|
|
|
|
{ prop: 'name', label: this.$t('systemGenerate.name'), type: 'text', required: true}
|
|
|
|
]
|
|
|
|
};
|
|
|
|
}
|
|
|
|
return form;
|
|
|
|
},
|
|
|
|
rules() {
|
|
|
|
let crules = {};
|
|
|
|
if (this.operateType == 'add') {
|
|
|
|
crules = {customized:[
|
|
|
|
{ required: true, message: this.$t('systemGenerate.selectProject'), trigger: 'change'}
|
|
|
|
],
|
|
|
|
mapId:[
|
|
|
|
{ required: true, message: this.$t('systemGenerate.selectMap'), trigger: 'change'}
|
|
|
|
],
|
|
|
|
name: [
|
|
|
|
{ required: true, message: this.$t('systemGenerate.inputName'), trigger: 'blur' },
|
|
|
|
{ required: true, message: this.$t('systemGenerate.inputName'), trigger: 'change' }
|
|
|
|
],
|
|
|
|
type:[
|
|
|
|
{ required: true, message: this.$t('systemGenerate.selectType'), trigger: 'change'}
|
|
|
|
],
|
2019-12-25 19:28:03 +08:00
|
|
|
prdType:[
|
|
|
|
{ required: true, message: this.$t('rules.productTypeInput'), trigger: 'change'}
|
2019-10-31 15:34:38 +08:00
|
|
|
]
|
|
|
|
};
|
|
|
|
} else {
|
|
|
|
crules = {
|
|
|
|
name: [
|
|
|
|
{ required: true, message: this.$t('systemGenerate.inputName'), trigger: 'blur' },
|
|
|
|
{ required: true, message: this.$t('systemGenerate.inputName'), trigger: 'change' }
|
|
|
|
]
|
|
|
|
};
|
|
|
|
}
|
|
|
|
return crules;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
this.loadInitData();
|
|
|
|
},
|
|
|
|
methods:{
|
|
|
|
loadInitData() {
|
2019-12-30 18:06:40 +08:00
|
|
|
this.projectList = [{value:'xty', label:'西铁院'}, {value: 'gzb', label: '贵州装备'}];
|
2019-10-31 15:34:38 +08:00
|
|
|
const customeredProductType = ConstConfig.ConstSelect.customeredProductType;
|
|
|
|
this.typeList = Cookies.get('user_lang') == 'en'
|
|
|
|
? customeredProductType.map(elem => { return { value: elem.value, label: elem.enlabel }; })
|
|
|
|
: customeredProductType.map(elem => { return { value: elem.value, label: elem.label }; });
|
|
|
|
},
|
|
|
|
doShow(data) {
|
|
|
|
if (data) {
|
|
|
|
this.formModel.name = data.name;
|
|
|
|
this.formModel.id = data.id;
|
|
|
|
}
|
|
|
|
this.dialogVisible = true;
|
|
|
|
},
|
|
|
|
doCreate() {
|
|
|
|
const self = this;
|
|
|
|
this.$refs.dataform.validateForm(() => {
|
|
|
|
self.$emit('create', Object.assign({}, this.formModel));
|
|
|
|
self.doClose();
|
|
|
|
});
|
|
|
|
},
|
|
|
|
doClose() {
|
|
|
|
this.$refs.dataform.resetForm();
|
|
|
|
this.dialogVisible = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
/deep/ .el-dialog--center .el-dialog__body{
|
|
|
|
padding: 25px 55px 20px 20px;
|
|
|
|
}
|
|
|
|
/deep/ .el-dialog--center .el-dialog__body .el-input{
|
|
|
|
width:200px !important;
|
|
|
|
}
|
|
|
|
</style>
|