<template>
  <ant-modal
    modalWidth="${modalWidth}"
    modalHeight="${modalHeight}"
    :visible="open"
    :modal-title="formTitle"
    :adjust-size="true"
    @cancel="cancel"
  >
#if(${colSpans} == '1') 
#set($colSpanRoot = 24)
#elseif(${colSpans} == '2')
#set($colSpanRoot = 12)
#elseif(${colSpans} == '3')
#set($colSpanRoot = 8)
#elseif(${colSpans} == '4')
#set($colSpanRoot = 6)
#else
#set($colSpanRoot = 12)
#end
    <a-form-model ref="form" :model="form" :rules="rules" slot="content" layout="vertical">
      <a-row :gutter="32">
        <a-col :lg="${colSpanRoot}" :md="${colSpanRoot}" :sm="24">
          <a-form-model-item label="上级节点" prop="parentId">
            <a-tree-select
              v-model="form.parentId"
              style="width: 100%"
              :dropdown-style="{ maxHeight: '400px', overflow: 'auto' }"
              :tree-data="${businessName}Options"
              placeholder="请选择"
              :replaceFields="{ children: 'children', title: '${treeName}', key: 'id', value: 'id' }"
              tree-default-expand-all
            >
            </a-tree-select>
          </a-form-model-item>
        </a-col>
      </a-row>
      <a-row :gutter="32">
#foreach($column in $editColumns)
#set( $listSize = $!{editColumns.size()})
#set( $next = $!velocityCount - 2 )
#set($dictType=$column.dictType)
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
#set($parentheseIndex=$column.columnComment.indexOf("（"))
#if($parentheseIndex != -1)
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
#else
#set($comment=$column.columnComment)
#end
##这里根据不同新行概念而定，如果需要选择新行后独占一行则开启注释部分
###if($column.isNewRow == '1' && $velocityCount !=1 && ($next>=0 && $editColumns.get($next).isNewRow != '1'))
##	  </a-row>
##	  <a-row :gutter="32">
###end
#if(${colSpans} == '1') 
#set($colSpan = $column.colSpan * 24)
#elseif(${colSpans} == '2')
#set($colSpan = $column.colSpan * 12)
#elseif(${colSpans} == '3')
#set($colSpan = $column.colSpan * 8)
#elseif(${colSpans} == '4')
#set($colSpan = $column.colSpan * 6)
#else
#set($colSpan = $column.colSpan * 12)
#end
#if($column.htmlType == "input")
        <a-col :span="${colSpan}">
          <a-form-model-item label="${comment}" prop="${column.javaField}">
            <a-input v-model="form.${column.javaField}" placeholder="请输入${comment}"/>
          </a-form-model-item>
        </a-col>
#elseif($column.htmlType == "textarea")
        <a-col :span="${colSpan}">
          <a-form-model-item label="${comment}" prop="${column.javaField}">
            <a-textarea v-model="form.${column.javaField}" placeholder="请输入${comment}" :rows="4"/>
          </a-form-model-item>
        </a-col>
#elseif(($column.htmlType == "number"))
        <a-col :span="${colSpan}">
          <a-form-model-item label="${comment}" prop="${column.javaField}">
            <a-input-number v-model="form.${column.javaField}" :min="0" style="width: 100%"/>
          </a-form-model-item>
        </a-col>
#elseif(($column.htmlType == "datetime"))
        <a-col :span="${colSpan}">
          <a-form-model-item label="${comment}" prop="${column.javaField}">
            <a-date-picker
              v-model="form.${column.javaField}"
              valueFormat="YYYY-MM-DD"
              :show-today="true"
              placeholder="选择日期"
              style="width: 100%"
            />
          </a-form-model-item>
        </a-col>
#elseif(($column.htmlType == "time"))
        <a-col :span="${colSpan}" >
          <a-form-model-item label="${comment}" prop="${column.javaField}">
            <a-date-picker
              v-model="form.${column.javaField}"
              valueFormat="YYYY-MM-DD"
              :show-today="true"
              placeholder="选择日期"
              style="width: 100%"
            />
          </a-form-model-item>
        </a-col>
#elseif(($column.htmlType == "select") && "" != $dictType)
        <a-col :span="${colSpan}" >
          <a-form-model-item label="${comment}" prop="${column.javaField}">
            <a-select
              placeholder="请选择${comment}"
              v-model="form.${column.javaField}"
              :getPopupContainer="
                triggerNode => {
                  return triggerNode.parentNode || document.body
                }
              "
              style="width: 100%"
              allow-clear>
              <a-select-option v-for="(d, index) in ${column.javaField}Options" :key="index" :value="d.dictValue">{{ d.dictLabel }}</a-select-option>
            </a-select>
          </a-form-model-item>
        </a-col>
#elseif(($column.htmlType == "selectMultiple") && "" != $dictType)
        <a-col :span="${colSpan}" >
          <a-form-model-item label="${comment}" prop="${column.javaField}">
            <a-select
              placeholder="请选择${comment}"
              v-model="form.${column.javaField}"
              :getPopupContainer="
                triggerNode => {
                  return triggerNode.parentNode || document.body
                }
              "
              style="width: 100%"
              mode="multiple"
              allow-clear>
              <a-select-option v-for="(dict, index) in ${column.javaField}Options" :key="index" :value="dict.dictValue">{{ dict.dictLabel }}</a-select-option>
            </a-select>
          </a-form-model-item>
        </a-col>
#elseif(($column.htmlType == "radioButton") && "" != $dictType)
        <a-col :span="${colSpan}" >
          <a-form-model-item label="${comment}" prop="${column.javaField}">
            <a-radio-group v-model="form.${column.javaField}" button-style="solid">
              <a-radio-button
                v-for="(dict, index) in ${column.javaField}Options"
                :key="index"
                :value="dict.dictValue"
              >
                {{ dict.dictLabel }}
              </a-radio-button>
            </a-radio-group>
          </a-form-model-item>
        </a-col>
#elseif(($column.htmlType == "radio") && "" != $dictType)
        <a-col :span="${colSpan}" >
          <a-form-model-item label="${comment}" prop="${column.javaField}">
            <a-radio-group v-model="form.${column.javaField}">
              <a-radio
                v-for="(dict, index) in ${column.javaField}Options"
                :key="index"
                :value="dict.dictValue"
              >
                {{ dict.dictLabel }}
              </a-radio>
            </a-radio-group>
          </a-form-model-item>
        </a-col>
#elseif(($column.htmlType == "checkbox") && "" != $dictType)
        <a-col :span="${colSpan}" >
          <a-form-model-item label="${comment}" prop="${column.javaField}">
            <a-checkbox-group v-model="form.${column.javaField}" button-style="solid">
              <a-checkbox
                v-for="(dict, index) in ${column.javaField}Options"
                :key="index"
                :value="dict.dictValue"
                >
                  {{ dict.dictLabel }}
              </a-checkbox >
            </a-checkbox-group>
          </a-form-model-item>
        </a-col>
#elseif(($column.htmlType == "user"))
        <a-col :span="${colSpan}" >
          <a-form-model-item label="${comment}" prop="${column.javaField}">
            <select-user
              v-model="form.${column.javaField}"
              select-model="single"
            />
          </a-form-model-item>
        </a-col>
#elseif(($column.htmlType == "dept"))
        <a-col :span="${colSpan}" >
          <a-form-model-item label="${comment}" prop="${column.javaField}">
            <select-dept
              v-model="form.${column.javaField}"
              select-model="single"
              select-scope="all"
           />
          </a-form-model-item>
        </a-col>
#end
#if($column.isNewRow == '1' && $listSize != $!velocityCount)
      </a-row>
      <a-row :gutter="32">
#end
#end
#if($hasAttach)
        <a-col :lg="24" :md="24" :sm="24">
          <a-form-model-item label="附件">
            <sys-upload
              key="1"
              element-id="1"
              form-type="add"
              :drag-uploader="true"
              :multiple="true"
              :file-size-limit="40"
              :ref="attachmentRefName"
              :allow-encry="false"
              :allow-same-name="false"
              :allow-preview="true"
              :allow-download="true"
              :allow-delete="true"
              :chunk-enabled="true"
              :colspan="2"
              :form-id="formId"
              :file-num-limit="10"
              table-name="${tableName}"
              @afterUpload="uploadCompleteFile"
            />
          </a-form-model-item>
        </a-col>
#end
      </a-row>
    </a-form-model>
    <template slot="footer">
      <a-button :disabled="disabled" @click="cancel">
        取消
      </a-button>
      <a-button type="primary" :disabled="disabled" @click="submitForm(true)">
        保存
      </a-button>
#if($hasSaveAndAddOption)
      <a-button type="primary" :disabled="disabled" @click="submitForm(false)">
        保存并继续添加
      </a-button>
#end
    </template>
  </ant-modal>
</template>
<script>
import ${BusinessName}AddForm from './${BusinessName}Form'
export default {
  ...${BusinessName}AddForm
}
</script>
