StationForm.vue 9.15 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="24">
            <a-form-model-item label="信号对接动作" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="actIds">
              <j-select-car-act placeholder="请选择动作" :multiple="true" v-model="model.actIds"/>
<!--              <a-input-number v-model="model.actIds" placeholder="请输入二维码编号" style="width: 100%" />-->
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="类型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="type">
              <a-input-number v-model="model.type" placeholder="请输入类型" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="编号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="code">
              <a-input v-model="model.code" placeholder="请输入工位编号" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="状态" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="status">
              <a-input v-model="model.status" placeholder="请输入状态" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="物料编号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="materialCode">
              <a-input v-model="model.materialCode" placeholder="请输入物料编号" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="行数" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="row">
              <a-input-number v-model="model.row" placeholder="请输入工位行数" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="朝向" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="orientation">
              <a-input-number v-model="model.orientation" placeholder="请输入工位朝向" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="列数" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="column">
              <a-input-number v-model="model.col" placeholder="请输入工位列数" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="层数" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="layer">
              <a-input-number v-model="model.layer" placeholder="请输入工位层数" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="工位最高举升高度" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="highest">
              <a-input-number v-model="model.highest" placeholder="请输入工位最高举升高度" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="工位最低举升高度" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="lowest">
              <a-input-number v-model="model.lowest" placeholder="请输入工位最低举升高度" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="接受信号1" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="accept1">
              <a-input-number v-model="model.accept1" placeholder="请输入接受信号1" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="接受信号2" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="accept2">
              <a-input-number v-model="model.accept2" placeholder="请输入接受信号2" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="接受信号3" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="accept3">
              <a-input-number v-model="model.accept3" placeholder="请输入接受信号3" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="接受信号4" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="accept4">
              <a-input-number v-model="model.accept4" placeholder="请输入接受信号4" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="接受信号5" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="accept5">
              <a-input-number v-model="model.accept5" placeholder="请输入接受信号5" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="发送信号1" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="send1">
              <a-input-number v-model="model.send1" placeholder="请输入发送信号1" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="发送信号2" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="send2">
              <a-input-number v-model="model.send2" placeholder="请输入发送信号2" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="发送信号3" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="send3">
              <a-input-number v-model="model.send3" placeholder="请输入发送信号3" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="发送信号4" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="send4">
              <a-input-number v-model="model.send4" placeholder="请输入发送信号4" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="发送信号5" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="send5">
              <a-input-number v-model="model.send5" placeholder="请输入发送信号5" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="说明" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="specification">
              <a-input v-model="model.specification" placeholder="请输入说明"  ></a-input>
            </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: 'StationForm',
    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: {
          actId: [
              { required: true, message: '请选择工位所处动作!'},
           ],
          code: [
            { required: true, message: '请输入工位编号!'},
          ],
        },
        url: {
          add: "/station/info/add",
          edit: "/station/info/edit",
          queryById: "/station/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>