<template>
  <!--新增 / 编辑 表单组件-->
  <el-dialog class="preview-dialog" :modal-append-to-body="false" :close-on-click-modal="false" append-to-body :before-close="handleClose" :visible="formVisible" :title="formTitle">
    <span class="dialog-right-top" />
    <span class="dialog-left-bottom" />
    <div class="setting-dialog">
      <!-- form -->
      <!--  @emitTableList="getTableList" -->
      <PreviewForm ref="previewForm" :form-preview-data.sync="formPreviewData" :selected-category="selectedCategory" :parents-id="parentsId" :arc-id="arcId" :is-des-form-type="isDesFormType" :is-disabled="isDisabled" :is-has-code="isHasCode" />
      <div slot="footer" class="dialog-footer">
        <!-- :loading="crud.status.cu === 2"  -->
        <el-button type="text" @click="formVisible = false">取消</el-button>
        <el-button type="primary" @click="formVisible = false">确定</el-button>
      </div>
    </div>
  </el-dialog>
</template>

<script>
import PreviewForm from '@/views/components/category/PreviewForm'
import addJson from './add.json'
export default {
  components: { PreviewForm },
  data() {
    return {
      formVisible: false,
      formTitle: '新增文件',
      loading: false,
      formPreviewData: null,
      selectedCategory: null,
      parentsId: null,
      arcId: null,
      isDesFormType: 'arcives',
      isDisabled: true,
      isHasCode: false
    }
  },
  created() {
    this.formPreviewData = addJson
  },
  methods: {
    handleClose(done) {
      done()
      this.formVisible = false
    },
    save() {
      // this.loading = true
      // if (this.title === '新增文件') {
      //   const addData = this.formData.fields.map((item) => {
      //     return {
      //       dictionaryId: item.id,
      //       fieldName: item.fieldName,
      //       fieldCnName: item.fieldCnName,
      //       connector: item.connector,
      //       categoryId: item.categoryId
      //     }
      //   })
      //   add(addData).then((res) => {
      //     this.$message({
      //       message: '保存成功',
      //       type: 'success',
      //       duration: 2500
      //     })
      //     this.cuDialogVisible = false
      //     this.loading = false
      //     this.$emit('refresh')
      //   })
      // } else {
      //   edit(this.formData.fields).then((res) => {
      //     this.$message({
      //       message: '保存成功',
      //       type: 'success',
      //       duration: 2500
      //     })
      //     this.cuDialogVisible = false
      //     this.loading = false
      //     this.$emit('refresh')
      //   })
      // }
    }
  }
}
</script>

<style lang="scss" scoped>
</style>
