CaractInfoForm.vue 12.8 KB
<template>
  <a-spin :spinning="confirmLoading">
    <j-form-container :disabled="formDisabled">
      <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
        <a-row>
          <a-col :span="12">
            <a-form-model-item label="前置地标" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="frontLandmark">
              <a-input-number v-model="model.frontLandmark" placeholder="请输入前置地标" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="当前地标" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="landmark">
              <a-input-number v-model="model.landmark" placeholder="请输入当前地标" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="后置地标" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="behindLandmark">
              <a-input-number v-model="model.behindLandmark" placeholder="请输入后置地标" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="距离" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="distance">
              <a-input-number v-model="model.distance" placeholder="请输入距离" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="站点类型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="stationType">
              <j-dict-select-tag
                placeholder="请选择站点类型"
                dictCode="station_type"
                v-model="model.stationType"
              />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="站点停车" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="waitPark">
              <a-input-number v-model="model.waitPark" placeholder="请输入站点停车" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="停靠方式" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="stopWay">
              <j-dict-select-tag
                placeholder="请选择停靠方式"
                dictCode="stop_way"
                v-model="model.stopWay"
              />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="插销动作" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="bolt">
              <a-input-number v-model="model.bolt" placeholder="请输入插销动作" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="充电" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="chargeFlag">
              <a-input-number v-model="model.chargeFlag" placeholder="请输入充电" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="运行方向" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="direction">
              <j-dict-select-tag
                placeholder="请选择运行方向"
                dictCode="direction"
                v-model="model.direction"
              />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="雷达区" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="radar">
              <a-input-number v-model="model.radar" placeholder="请输入雷达区" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="扬声器" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="speaker">
              <a-input-number v-model="model.speaker" placeholder="请输入扬声器" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="警示灯" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="lamp">
              <a-input-number v-model="model.lamp" placeholder="请输入警示灯" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="黄色警示灯" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="yellowLamp">
              <a-input-number v-model="model.yellowLamp" placeholder="请输入黄色警示灯" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="速度" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="speed">
              <a-input-number v-model="model.speed" placeholder="请输入速度" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="充电时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="charge">
              <a-input-number v-model="model.charge" placeholder="请输入充电时间" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="旋转" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="custom1">
              <a-input-number v-model="model.custom1" placeholder="请输入自定义1" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="宽窄" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="custom2">
              <a-input-number v-model="model.custom2" placeholder="请输入自定义2" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="皮带运转" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="custom3">
              <a-input-number v-model="model.custom3" placeholder="请输入自定义3" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="自定义4" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="custom4">
              <a-input-number v-model="model.custom4" placeholder="请输入自定义4" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="自定义5" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="custom5">
              <a-input-number v-model="model.custom5" placeholder="请输入自定义5" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="自定义6" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="custom6">
              <a-input-number v-model="model.custom6" placeholder="请输入自定义6" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="自定义7" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="custom7">
              <a-input-number v-model="model.custom7" placeholder="请输入自定义7" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="自定义8" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="custom8">
              <a-input-number v-model="model.custom8" placeholder="请输入自定义8" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="自定义9" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="custom9">
              <a-input-number v-model="model.custom9" placeholder="请输入自定义9" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="岔道" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="loads">
              <a-input-number v-model="model.loads" placeholder="请输入岔道" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="区域" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="region">
              <a-input-number v-model="model.region" placeholder="请输入区域" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="对接标识" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="jointSignal">
              <a-input-number v-model="model.jointSignal" placeholder="请输入对接标识" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="举升高度" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="liftHeight">
              <a-input-number v-model="model.liftHeight" placeholder="请输入举升高度" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="X坐标" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="coordX">
              <a-input-number v-model="model.coordX" placeholder="请输入X坐标" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="Y坐标" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="coordY">
              <a-input-number v-model="model.coordY" placeholder="请输入Y坐标" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="W角度" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="angleW">
              <a-input-number v-model="model.angleW" placeholder="请输入W角度" style="width: 100%" />
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-form-model>
    </j-form-container>
  </a-spin>
</template>

<script>

  import { httpAction, getAction } from '@/api/manage'
  import { validateDuplicateValue } from '@/utils/util'

  export default {
    name: 'CaractInfoForm',
    components: {
    },
    props: {
      //表单禁用
      disabled: {
        type: Boolean,
        default: false,
        required: false
      }
    },
    data () {
      return {
        model:{
         },
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },
        confirmLoading: false,
        validatorRules: {
           frontLandmark: [
              { required: true, message: '请输入前置地标!'},
           ],
           landmark: [
              { required: true, message: '请输入当前地标!'},
           ],
           behindLandmark: [
              { required: true, message: '请输入后置地标!'},
           ],
          stationType: [
            { required: true, message: '请选择站点类型!'},
          ],
           direction: [
              { required: true, message: '请输入运行方向!'},
           ],
          region: [
            { required: true, message: '请输入区域!'},
          ],
          coordX: [
            { required: true, message: '请输入X坐标!'},
          ],
          coordY: [
            { required: true, message: '请输入Y坐标!'},
          ],
        },
        url: {
          add: "/caract/info/add",
          edit: "/caract/info/edit",
          queryById: "/caract/info/queryById"
        }
      }
    },
    computed: {
      formDisabled(){
        return this.disabled
      },
    },
    created () {
       //备份model原始值
      this.modelDefault = JSON.parse(JSON.stringify(this.model));
    },
    methods: {
      add () {
        this.edit(this.modelDefault);
      },
      edit (record) {
        this.model = Object.assign({}, record);
        this.visible = true;
      },
      submitForm () {
        const that = this;
        // 触发表单验证
        this.$refs.form.validate(valid => {
          if (valid) {
            that.confirmLoading = true;
            let httpurl = '';
            let method = '';
            if(!this.model.id){
              httpurl+=this.url.add;
              method = 'post';
            }else{
              httpurl+=this.url.edit;
               method = 'put';
            }
            httpAction(httpurl,this.model,method).then((res)=>{
              if(res.success){
                that.$message.success(res.message);
                that.$emit('ok');
              }else{
                that.$message.warning(res.message);
              }
            }).finally(() => {
              that.confirmLoading = false;
            })
          }
         
        })
      },
    }
  }
</script>