<!--<template>
  <div>
    <el-button size="mini" type="primary" @click="dialogFormVisible = true">新 建</el-button>
    <el-dialog title="新 建" :visible.sync="dialogFormVisible" width="50%">
      <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="right" 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 enterpriseList()"
                  :key="item.sys_enterpriseid"
                  :label="item.enterprisename"
                  :value="item.sys_enterpriseid">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="企业名称" prop="enterprisename">
              <el-input :disabled="form.sys_enterpriseid != ''" v-model="form.enterprisename" placeholder="请输入企业名称"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="品牌名称" prop="brandname">
              <el-input v-model="form.brandname" placeholder="请输入品牌名称"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="优势信息" prop="advantage">
              <el-input v-model="form.advantage" placeholder="请输入优势信息"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="劣势信息" prop="inferiority">
              <el-input v-model="form.inferiority" placeholder="请输入劣势信息"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <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>-->
<template>
  
</template>

<script>
export default {
  name: "add",
  components:{},
  inject:['enterpriseList'],
  data(){
    return {
      dialogFormVisible:false,
      projectAddress:[],
      form:{
      "sa_competitorid":"",
       "sys_enterpriseid":"",//传0时会创建企业档案
       "enterprisename":"",
       "brandname":"",
       "inferiority":"",
       "advantage":"",
       "remarks":""
      },
      rules:{
        enterprisename:[
          { required: true, message: '请输入企业名称', trigger: 'blur'},
        ]
      }
    }
  },
  methods:{
    onSubmit(){
      console.log(this.form)
      this.$refs['form'].validate(async (valid) => {
        if (!valid) return false
        this.form.sys_enterpriseid ? this.form.enterprisename = '' : ''
        this.form.sa_competitorid ? '' : this.form.sa_competitorid = 0
        const res = await this.$api.requested({
          "id": "20221018164102",
          "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>