<template>
  <ele-form-dialog
   v-bind="formConfig"
    v-model="formFieldsData"
    v-dialogDrag
    :title="title"
    :request-fn="handleFormSubmit"
    :visible.sync="DialogVisible"
    width="550px"
    custom-class="abow_dialog"
    label-width="100px"
    label-position="left"
    :dialogAttrs="{ 'close-on-click-modal': false,'top':'8vh'}"
  />

</template>

<script>
export default {
  props: ["formModelVisible", "title"],
  data() {
    return {
      formData: {},
      formFieldsData: {
        id:"",
        number: "",
        fan_id:"",
        work_location:"",
        parts:"",
        bolt_style:"",
        boit_type:"",
        info: "",

      }, 
      url: "workLocation",
      formConfig: {
        formDesc: {
          //风场id
          fan_id:{
              type: "cascader",
              label: "风机编号",
              isOptions: true,
              options: [],
              required: true,
              vif:true,
              attrs: {
                //查询 
                filterable:true,
                props: {
                  label: "text",
                  value: "value",
                  emitPath: false,
                  multiple:false
                }
            }

          },
          number: {  
            required:true,
            type: "input",
            label: "编号",
           
          },
           work_location: {
            
            type: "input",
            label: "工作位置",
            required:true
          },
          parts: {
            
            required:true,
            type: "select",
            label: "所属部件",
            required:true,
            options:[]
          },
           bolt_style:{
            
            type: "input",
            label: "螺丝样式",
             required:true
          },
           boit_type:{
             
             type: "input",
             label: "螺丝型号",
             required:true,
             rules: [
             {pattern: /^((0{1}\.\d{1,2})|([1-9]\d*\.{1}\d{1,2})|([1-9]+\d*)|0)$/,message: '请輸入正数,最多保存两位小数'}
            ]
          },
          info: {
            
            type: "textarea",
            label: "备注"
          }
        },
        order: ["number","fan_id","work_location","parts","bolt_style", "boit_type","info","info"]
      }
    };
  },
  created() {
   
    //  this.$http.get("getwindfan").then(response => {
    //   this.formConfig.formDesc.fan_id.options = response.data;
    // });
    // this.$http.get("get_device_mold",{ params: {type:2} }).then(resp => {
    //     this.formConfig.formDesc.model.options = resp.data
    //  });
    // this.$http.get("wrenchtype").then(response => {
    //   this.formConfig.formDesc.wrench.options = response.data;
    // });
    // this.$http.get("synschemetype").then(response => {
    //   this.formConfig.formDesc.fastening_scheme.options = response.data;
    // });



  },
  methods: {
    handleFormSubmit(data) {

      this.$parent.handleSubmit();
    },
    handleRequest(data) {
      return Promise.resolve();
    },
    handleRequestSuccess() {
      this.$message.success("发送成功");
    }
  },


  computed: {
    DialogVisible: {
      set(val) {
        this.$emit("sendVal", val); // 表示将子组件改变的值传递给父组件
      },
      get() {
        return this.formModelVisible; // 表示获取父组件的值
      }
    }
  }
};
</script>
