<template>
    <div>
        <div class="FormDialog" @click="openDialog">
            <el-button type="text" :disabled="row.state != '已填写'" :loading="btnLoading">详情</el-button>
        </div>
        <NCCForm v-if="dialogVisible" ref="NCCForm" @refreshDataList="refresh"/>
    </div>
  </template>
  
  <script>
    import NCCForm from '@/views/baseSpecialAction/dynamicModel/list/Form'
    import request from "@/utils/request";
  export default {
    components: { NCCForm },
    props: {
        row: {
        type: Object,
        default: {},
      },
      isDetail: {
        type: Boolean,
        default: true,
      },
    },
    data() {
      return {
        dialogVisible: false,
        btnLoading: false,
      }
    },
    methods: {
        openDialog() {
            let row = this.row;
            if(this.row.state != '已填写') return;
            this.btnLoading = true;
            this.dialogVisible = true;
            var  Itemid = row.itemId || '';//数据id，没有的话就是新增 ，有的话就是修改
            var  modelId = row.formId;//关联的表单id
            var taskId = row.id; // 当前专项行动id
            var isPreview = false;//固定死，值不变
            var useFormPermission = false;//固定死，值不变
            var formData = [];
            request({
              url: '/visualdev/OnlineDev/'+modelId+'/Config',
              method: "GET",
              params:null
            }).then(res => {
              formData = JSON.parse(res.data.formData);
              formData.disabled = this.isDetail || false;
              let form = JSON.stringify(formData);
              this.$refs.NCCForm.init(form, modelId, Itemid, isPreview, useFormPermission, taskId, this.isDetail)
              this.btnLoading = false;
            }).catch(() => this.btnLoading = false);
        },
        refresh() {
            this.dialogVisible = false;
        },
    }
  }
  </script>