<template>
  <div>
    <el-form ref="elForm" :model="formData" :rules="rules" size="medium" label-width="80px">
      <el-row>
          <el-col :span="12">
                <el-form-item label="专业分类" prop="cccpv_class" :span="8">
            <treeselect
            v-model="formData.cnas_scopes"
            :multiple="true"
            :options="cnasOptions"
            :disable-branch-nodes="true"
            placeholder="请选择专业分类"
            :style="{width: '100%'}"
            clearable
          />
          </el-form-item>
          </el-col>
          <el-col :span="12">
                <el-form-item label="认证范围" prop="content" >
            <el-input v-model="formData.content" placeholder="请输入认证范围"></el-input>
          </el-form-item>
          </el-col>
      </el-row>
    </el-form>
    <div slot="footer" align="center">
      <el-button @click="close(false)">取消</el-button>
      <el-button type="primary" @click="handelConfirm">确定</el-button>
    </div>
  </div>
</template>
<script>
import { createSubApplication } from "@/api/application"
import { getAddressList } from "@/api/enterprise"
import { genTree } from '../../utils';
import { getDictList } from '../../api/dict';
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
export default {
  name: "QMSform",
  inheritAttrs: false,
  components: { Treeselect },
  props: ["origindata", "cert_field"],
  data() {
    return {
      formData: {
          cert_field:this.cert_field,
          application:this.origindata.id,
        cccpv_class:null,
        cnas_scopes:[],
        pattern:'正常'
      },
      rules: {

      },
      dgVisiable: false,
      dgType: 1,
      cnasOptions:[],
    };
  },
  computed: {},
  watch: {},
  created() {
      this.getCnasOptions()
  },
  mounted() {},
  methods: {
    close(val) {
      // this.$refs['elForm'].resetFields()
      this.$emit("closeDg", val);
    },
    handelConfirm() {
      this.$refs["elForm"].validate((valid) => {
        if (!valid) return;
        createSubApplication(this.formData).then(res=>{
            this.close(res.data);
        })
        
      });
    },
    getCnasOptions(){
        let query = {type__code:'cnas_scope'}
        getDictList(query).then(res=>{
            this.cnasOptions=genTree(res.data)
        })
    },
  },
};
</script>
<style>
</style>
