<template>
  <div class="cmain">
    <el-form ref="form" :model="form" :disabled="param.detail || param.audit" :rules="rules" label-width="100px">
      <el-form-item label="设为推荐" prop="recommend">
        <el-select v-model="form.recommend" placeholder="请选择">
          <el-option label="设置" :value="1"></el-option>
          <el-option label="取消" :value="0"></el-option>
        </el-select>
      </el-form-item>
    </el-form>
    <div class="mfooter">
      <el-button type="primary" @click="submitForm()">确定</el-button>
      <el-button @click="$layer.close(layerid)">取 消</el-button>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      form: { recommend: 1 },
      rules: {
        recommend: [{ required: true, message: '不能为空', trigger: 'blur' }]
      }
    };
  },
  props: {
    param: {
      type: Object,
      default: () => {
        return {};
      }
    },
    layerid: {
      type: String
    }
  },
  mounted() {
    if (this.param.id) {
      this.ajax({ url: '/work/enterprise/detail/' + this.param.id }).then((response) => {
        this.form = response.data;
      });
    }
  },
  methods: {
    submitForm(audit) {
      this.$refs['form'].validate((valid) => {
        if (valid) {
          this.ajax({ method: 'post', url: '/work/enterprise/edit', data: this.form }).then((response) => {
            this.$modal.msgSuccess('修改成功');
            this.$layer.close(this.layerid);
            this.$parent.getList();
          });
        }
      });
    }
  }
};
</script>
