<template>
  <div>
    <NgFormDesign ref="designRef" @handleSave="handleSave" />
  </div>
</template>

<script>
import NgFormDesign from './components/form-design/index.vue'
import { addModel, updateModel } from '@/api/configure/template.js'
export default {
  components: {
    NgFormDesign
  },
  data() {
    return {}
  },
  methods: {
    handleSave(data) {
      const params = {
        ...data,
        modelName: data.title,
        modelType: data.modelType,
        modelDetal: JSON.stringify(data.list)
      }
      const Api = this.$route.query.type === 'edit' ? updateModel : addModel
      Api(params).then((res) => {
        if (res.code === 200) {
          this.$message.success('保存成功')
          const obj = { path: '/configure/templateList' }
          this.$tab.closeOpenPage(obj)
        }
      })
    }
  }
}
</script>

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