<template>
  <el-dialog
    v-dialogDrag
    class="datie-02__systerm"
    :title="title"
    :visible.sync="show"
    width="660px"
    :before-close="doClose"
    :z-index="2000"
    :modal="false"
    :close-on-click-modal="false"
  >
    <div class="TrackInformation">
      <!-- 111 -->
      <!-- form -->
      <el-form ref="form" :model="model" label-width="85px" :rules="rules">
        <el-form-item label="股道:" prop="trackSectionCode">
          <el-select v-model="model.trackSectionCode" placeholder="" style="width:135px">
            <el-option
              v-for="item in filterSectionList"
              :key="item.code"
              :label="item.name"
              :value="item.code"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="线路性质:" prop="lineType">
          <el-select v-model="model.lineType" placeholder="" style="width:145px">
            <el-option
              v-for="item in lineTypeList"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="接发车方向:" prop="direction">
          <el-select v-model="model.direction" placeholder="" style="width:90px">
            <el-option
              v-for="item in directionList"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="接发车类型:" prop="type">
          <el-select v-model="model.type" placeholder="" style="width:90px">
            <el-option
              v-for="item in typeList"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="超限类型:" prop="transfiniteType">
          <el-select v-model="model.transfiniteType" placeholder="" style="width:145px">
            <el-option
              v-for="item in transfiniteTypeList"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="站台:" prop="standType">
          <el-select v-model="model.standType" placeholder="" style="width:90px">
            <el-option
              v-for="item in standTypeList"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="允许动车组:" prop="allowEmu">
          <el-select v-model="model.allowEmu" placeholder="" style="width:90px">
            <el-option
              v-for="item in allowEmuList"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="上水设备:" prop="addWaterEqu">
          <el-select v-model="model.addWaterEqu" placeholder="" style="width:145px">
            <el-option
              v-for="item in addWaterEquList"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="排污设备:" prop="sewageEqu">
          <el-select v-model="model.sewageEqu" placeholder="" style="width:90px">
            <el-option
              v-for="item in sewageEquList"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="军用:" prop="military">
          <el-select v-model="model.military" placeholder="" style="width:90px">
            <el-option
              v-for="item in militaryList"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            />
          </el-select>
        </el-form-item>
      </el-form>
    </div>
    <div style="text-align:right;display:inline-block;width:100%;">
      <div class="trackBtn">
        <el-button :id="domIdCancel" @click="cancel">取消</el-button>
      </div>
      <div class="trackBtn">
        <el-button :id="domIdConfirm " type="primary" :loading="loading" @click="commit">确定 </el-button>
      </div>
    </div>
  </el-dialog>
</template>
<script>
import { OperationEvent } from '@/scripts/cmdPlugin/OperationHandler';
import {menuOperate, commitOperate} from '@/jmapNew/theme/components/utils/menuOperate';
export default {
    name: 'TrackInformation',
    data() {
        return {
            dialogShow: false,
            loading: false,
            filterSectionList:[],
            // trackSectionCode:'',
            lineTypeList:[
                {label:'正线', value:'1'},
                {label:'到发线', value:'2'}
            ],
            directionList:[
                {label:'上行', value:'1'},
                {label:'下行', value:'2'},
                {label:'上下行', value:'3'}
            ],
            typeList:[
                {label:'客车', value:'1'},
                {label:'货车', value:'2'},
                {label:'客货车', value:'3'}
            ],
            transfiniteTypeList:[
                {label:'不能接发超限列车', value:'1'},
                {label:'一级超限', value:'2'},
                {label:'二级超限', value:'3'},
                {label:'超级超限', value:'4'}
            ],
            standTypeList:[
                {label:'无', value:'1'},
                {label:'高站台', value:'2'},
                {label:'低站台', value:'3'}
            ],
            allowEmuList:[
                {label:'是', value:'1'},
                {label:'否', value:'2'}
            ],
            addWaterEquList:[
                {label:'有', value:'1'},
                {label:'无', value:'2'}
            ],
            sewageEquList:[
                {label:'有', value:'1'},
                {label:'无', value:'2'}
            ],
            militaryList:[
                {label:'是', value:'1'},
                {label:'否', value:'2'}
            ],
            model:{
                trackSectionCode:'',
                lineType:'', // 线路性质  正线/到发线
                direction:'', // 接发车方向  上行、下行、 上下行
                type:'', // 接发车类型  客车/货车/客货车
                transfiniteType:'', // 超限类型  选择“不能接发超限列车/一级超限/二级超限/超级超限”
                standType:'', // 站台 选择“无/高站台/低站台”
                allowEmu:'', // 允许动车组  选择“是/否”。
                addWaterEqu:'', // 上水设备 选择“有/无”
                sewageEqu:'', // 排污设备 选择“有/无”
                military:'' // 军用  是/否
            },
            rules:{

            }
        };
    },
    computed: {
        show() {
            return this.dialogShow && !this.$store.state.menuOperation.break;
        },
        domIdCancel() {
            return this.dialogShow ? OperationEvent.Command.cancel.menu.domId : '';
        },
        domIdConfirm() {
            return this.dialogShow ? OperationEvent.CTCCommand.addTrainFixedPath.menu.domId : '';
        },
        title() {
            return '股道信息';
        }
    },
    methods:{
        doShow({row, filterSectionMap}) {
            this.filterSectionList = Object.values(filterSectionMap);
            debugger;
            this.dialogShow = true;
            this.$nextTick(function () {
                this.$store.dispatch('training/emitTipFresh');
            });
            this.model = Object.assign({}, row);
        },
        doClose() {
            this.loading = false;
            this.dialogShow = false;
        },
        commit() {
            this.$refs.form.validate((valid) => {
                if (valid) {
                    // this.loading = true;
                    // const param = {stationCode:this.addModel.stationCode, runPlanParamList:[this.addModel]};
                    // commitOperate(menuOperate.CTC.addTrainFixedPath, param, 3).then(({valid})=>{
                    //     if (valid) {
                    //         this.doClose();
                    //     }
                    // }).catch(() => {
                    //     this.doClose();
                    //     this.$emit('noticeInfo');
                    // });
                }
            });
        },
        cancel() {
            const operate = {
                operation: OperationEvent.Command.cancel.menu.operation
            };
            this.$store.dispatch('training/nextNew', operate).then(({ valid }) => {
                if (valid) {
                    this.doClose();
                }
            }).catch(() => { this.doClose(); });
        }
    }
};
</script>
<style lang="scss" scoped>
.trackBtn{display:inline-block;margin-right: 10px;}
.TrackInformation .el-form-item{
    display:inline-block;
    margin-bottom:20px;
}
.TrackInformation{margin-bottom: 15px;}
</style>
<style lang="scss">
.TrackInformation .el-form-item__content {
    line-height: 30px;
}
</style>
