<template>
  <div>
    <el-button size="mini" type="primary" @click="dialogFormVisible = true">新 增</el-button>
    <el-dialog title="新 增" :visible.sync="dialogFormVisible" width="30%">
      <div slot="title" style="font-size: 15px">
        关联缔约企业
      </div>
      <el-row :gutter="20">
        <el-form :model="form" :rules="rules" ref="form" label-width="120px" label-position="left" size="mini">
          <el-col :span="24">
            <el-form-item label="企业名称" prop="sys_enterpriseid">
              <el-select v-model="form.sys_enterpriseid" placeholder="请选择关联的企业" clearable @clear="form.sys_enterpriseid=''" size="small">
                <el-option
                  v-for="item in basicData.data().enterpriseList"
                  :key="item.sys_enterpriseid"
                  :label="item.enterprisename"
                  :value="item.sys_enterpriseid">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="备注" prop="remarks">
              <el-input type="textarea" v-model="form.remarks" placeholder="请输入备注"></el-input>
            </el-form-item>
          </el-col>
        </el-form>
      </el-row>
      <div class="dialog-footer">
        <el-button size="small" @click="dialogFormVisible = false" class="normal-btn-width">取 消</el-button>
        <el-button size="small" type="warning" @click="onSubmit" class="normal-btn-width btn-warning">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  name: "add",
  components:{},
  data(){
    return {
      dialogFormVisible:false,
      projectAddress:[],
      form:{
      "sa_project_partiesid": 0,
      "sa_projectid": "",
      "sys_enterpriseid": "",
      "remarks": "" //可选
      },
      rules:{
        sys_enterpriseid:[
          { required: true, message: '请选择企业', trigger: 'blur'},
        ]
      }
    }
  },
  created () {
    console.log(this.basicData.data().enterpriseList);
    
  },
  methods:{
    onSubmit(){
      console.log(this.form)
      this.$refs['form'].validate(async (valid) => {
        if (!valid) return false
        this.form.sa_projectid = this.$route.query.id
        const res = await this.$api.requested({
          "id": "20221027143602",
          "version":1,
          "content": this.form
        })
        this.tool.showMessage(res,()=>{
          this.$emit('onSuccess')
          this.$refs['form'].resetFields();
          this.dialogFormVisible = false
        })
      })
    },
  }
}
</script>

<style scoped>
/deep/.el-select {
  height: 28px !important;
  width: 100%;
}
/deep/.el-input__inner {
  height: 28px !important;
}
</style>