<template>
  <fm-making-form ref="makingForm" upload preview generate-code generate-json clearable style="height: 800px;">
    <template slot="action">
    </template>
    <template slot="action">
      <!-- 自定义操作区域插槽 -->
      <el-button type="text" icon="el-icon-upload" @click="addDescription()">保存</el-button>
    </template>
  </fm-making-form>
</template>

<script>
import { httpAction, getAction, banli, postAction} from '@/api/manage'
import { validateDuplicateValue } from '@/utils/util'
import {getModelList} from "@api/activiti/activiti";
export default {
  name: 'CustomForm',
  components: {

  },
  data() {
    return {
      url: {
        add: "/customform/customForm/add",
      }
    }
  },
  methods: {
    addDescription(){
      const json = this.$refs.makingForm.getJSON()
      if(json.list.length == 0){
        this.$message.error('表单不能为空');
        return;
      }
      this.$prompt('请输入表单说明', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
      }).then(({ value }) => {
        this.loading = true;
        let p = {};
        p.formstatus = value;
        p.formcontent = json;
        postAction(this.url.add, {formstatus: value,formcontent: JSON.stringify(json) + ''}).then(res => {
          this.loading = false;
          if(res.code == 200){
            this.$message({
              message: res.message,
              type: 'success'
            });
          }
          else {
            this.$message.error(res.message);
          }
        })
      }).catch(() => {
        this.$message.error('添加失败');
      });
    },
  },
}
</script>

