PbomBack.vue 5.14 KB
<template>
  <a-modal
    :width="modalWidth"
    :style="modalStyle"
    :visible="visible"
    :confirmLoading="confirmLoading"
    :maskClosable="false"
    @cancel="handleCancel">
    <template slot="footer">
      <a-button @click="handleCancel">关闭</a-button>
    </template>
    <a-spin :spinning="confirmLoading">
    <a-form :form="form" >
        <a-row>
          <a-col :span="24">
            <a-form-item label="项目名称" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input v-decorator="['projectName']"    disabled></a-input>
            </a-form-item>
          </a-col>
          <a-col :span="24">
            <a-form-item label="工作令" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input v-decorator="['workNo']"    disabled></a-input>
            </a-form-item>
          </a-col>


          <a-col :span="24">
            <a-form-item label="回滚版本" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-select
                show-search
                placeholder="请选择版本"
                option-filter-prop="children"
                style="width: 200px" v-model="ver1"
              >
                <a-select-option v-for="item in versionList" :key="item" :value="item">{{ item }}</a-select-option>
              </a-select>
              <a-input v-decorator="['uuid']"  style="display:none"></a-input>
              <a-input v-decorator="['version']" style="display:none" ></a-input>
            </a-form-item>
          </a-col>

          <a-col  :span="24" style="text-align: center" class="table-page-search-submitButtons">
            <a-button type="primary" @click="submitForm" icon="check-circle">提 交</a-button>
          </a-col>
        </a-row>
    </a-form>
    </a-spin>
  </a-modal>
</template>

<script>

import { httpAction} from '@/api/manage'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import pick from 'lodash.pick'
import {getVersionList} from "../../../api/api";
export default {
  name: 'PbomBack',
  mixins:[JeecgListMixin],
  components: {
  },
  props: {
    //流程表单data
    formData: {
      type: Object,
      default: ()=>{},
      required: false
    },
    //表单模式:true流程表单 false普通表单
    formBpm: {
      type: Boolean,
      default: false,
      required: false
    },
    //表单禁用
    disabled: {
      type: Boolean,
      default: false,
      required: false
    }
  },
  data () {
    return {
      versionList:[],
      visible: false,
      ver1:'',
      modalWidth: '50%',
      modalStyle: { 'top': '20px'},
      form: this.$form.createForm(this),
      model: {},
      f04:'',
      pbom_status:'',
      labelCol: {
        xs: { span: 24 },
        sm: { span: 5 },
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 16 },
      },
      confirmLoading: false,
      validatorRules: {
      },
      searchOptions:[{
        text:"外协",
        value:"外协"
      },{
        text:"自制",
        value:"自制"
      },{
        text:"外购",
        value:"外购"
      }],
      url: {
        list:"1",
        add: "/epbom_info/epbomInfo/ebomBack",
        edit: "/pbom_type/pbomType/produceSendPbom",
      }
    }
  },
  computed: {
    formDisabled(){
      if(this.formBpm===true){
        if(this.formData.disabled===false){
          return false
        }
        return true
      }
      return this.disabled
    },
    showFlowSubmitButton(){
      if(this.formBpm===true){
        if(this.formData.disabled===false){
          return true
        }
      }
      return false
    },

  },
  created () {

  },
  methods: {
    add () {
      this.edit({});
    },
    edit (workNo,uuid,projectName) {
      this.visible = true;
      this.$nextTick(() => {
        this.form.setFieldsValue({
          workNo:workNo,
          uuid:uuid,
          projectName:projectName
        })
      })

      let params = {
        'workno': workNo
      }
      getVersionList(params).then((res) => {
        if (res.success) {
          this.versionList = res.result
        }
      })
    },
    handleCancel(){
      this.form.setFieldsValue({
        version:'',
        workNo:'',
        uuid:'',
        projectName:''
      })
      this.versionList=[]
      this.ver1=''
      this.visible = false
    },

    submitForm () {
      const that = this;
      this.form.setFieldsValue({
        version:this.ver1
      })
      // 触发表单验证
      this.form.validateFields((err, values) => {
        if (!err) {
          that.confirmLoading = true;
          let httpurl = '';
          let method = '';
          httpurl+=this.url.add;
          method = 'post';
          let formData = Object.assign(this.model, values);
          httpAction(httpurl,formData,method).then((res)=>{
            if(res.success){
              that.$message.success(res.message);
              that.$emit('ok');
            }else{
              that.$message.warning(res.message);
            }
          }).finally(() => {
            that.confirmLoading = false;
          })
        }

      })
    },
    popupCallback(row){
      this.form.setFieldsValue(pick(row,'cno','uuid','f04','code'))
    },
  }
}
</script>