4
0

editFormModel.ftl 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. <#import "function.ftl" as func>
  2. <#assign package=model.variables.package>
  3. <#assign class=model.variables.class>
  4. <#assign classVar=model.variables.classVar>
  5. <#assign comment=model.tabComment>
  6. <#assign subtables=model.subTableList>
  7. <#assign pk=func.getPk(model) >
  8. <#assign pkModel=model.pkModel >
  9. <#assign pkVar=func.convertUnderLine(pk) >
  10. <#assign pkType=func.getPkType(model)>
  11. <#assign fkType=func.getFkType(model)>
  12. <#assign system=vars.system>
  13. <#assign domain=vars.domain>
  14. <#assign tableName=model.tableName>
  15. <#assign colList=model.columnList>
  16. <#assign commonList=model.commonList>
  17. <#assign subSize=func.hasSubTable(model)>
  18. <template>
  19. <rx-dialog @handOk="handleSubmit" @cancel="cancel">
  20. <rx-layout>
  21. <div slot="center">
  22. <a-form-model ref="form" :model="mdl" :label-col="labelCol" :wrapper-col="wrapperCol">
  23. <#list commonList as col>
  24. <#assign colName=func.convertUnderLine(col.columnName)>
  25. <#if func.isExcludeField(colName) >
  26. <#if colName?if_exists?string=="name">
  27. <a-form-model-item label="${colName}" prop = "${colName}">
  28. <a-input placeholder="请输入${col.comment}" v-model="mdl.${colName}"/>
  29. </a-form-model-item>
  30. <#else>
  31. <a-form-model-item label="${colName}" prop = "${colName}">
  32. <#if (col.colType=="java.util.Date")>
  33. <a-date-picker placeholder="请输入${col.comment}" v-model="mdl.${colName}"
  34. format="YYYY-MM-DD"/>至
  35. <a-date-picker placeholder="请输入${col.comment}" v-model="mdl.${colName}"
  36. format="YYYY-MM-DD"/>
  37. <#elseif (col.colType=="Integer")>
  38. <a-input-number :min="0" :max="1000000" placeholder="请输入${colName}"
  39. v-model="mdl.${colName}"/>
  40. <#else>
  41. <a-input placeholder="请输入${col.comment}" v-model="mdl.${colName}"/>
  42. </#if>
  43. </a-form-model-item>
  44. </#if>
  45. </#if>
  46. </#list>
  47. </a-form-model>
  48. <#if (subSize?number gt 0) >
  49. <#assign subtables=model.subTableList>
  50. <#list subtables as subTable>
  51. <a-button class="editable-add-btn" @click="handleAdd('${subTable.variables.classVar}')">
  52. 新增
  53. </a-button>
  54. <a-table :columns=subTable.${subTable.variables.classVar}.columns :data-source="mdl['${subTable.variables.classVar}']" :pagination = false bordered>
  55. <template
  56. v-for="col in subTable['${subTable.variables.classVar}'].fields"
  57. :slot="col"
  58. slot-scope="text, record, index">
  59. <div :key="col">
  60. <a-input
  61. v-if="record.editable"
  62. style="margin: -5px 0"
  63. :value="text"
  64. @change="e => handleChange(e.target.value, record.uid, col,'${subTable.variables.classVar}')"/>
  65. <template v-else>
  66. {{ text }}
  67. </template>
  68. </div>
  69. </template>
  70. <template slot="operation" slot-scope="text, record, index">
  71. <div class="editable-row-operations">
  72. <span v-if="record.editable">
  73. <a @click="saveChild(record.uid,'${subTable.variables.classVar}')">保存</a>
  74. </span>
  75. <span v-else class="relick">
  76. <a @click="edit(record.uid,'${subTable.variables.classVar}')">编辑</a>
  77. <a @click="onDelete(record.uid,'${subTable.variables.classVar}')">删除</a>
  78. </span>
  79. </div>
  80. </template>
  81. </a-table>
  82. </#list>
  83. </#if>
  84. </div>
  85. </rx-layout>
  86. </rx-dialog>
  87. </template>
  88. <script>
  89. import ${class}Api from '@/api/${system}/${package}/${classVar}'
  90. import {RxDialog,BaseFormModel} from 'jpaas-common-lib';
  91. export default {
  92. name: '${class}Edit',
  93. mixins:[BaseFormModel],
  94. components: {
  95. RxDialog,
  96. },
  97. data(){
  98. return {
  99. /**
  100. * 子表列表,以及表格属性
  101. */
  102. subTable:{
  103. <#if (subSize?number gt 0) >
  104. <#assign subtables=model.subTableList>
  105. <#list subtables as subTable>
  106. "${subTable.variables.classVar}": {
  107. row:{
  108. <#list subTable.columnList as col>
  109. <#assign colName=func.convertUnderLine(col.columnName)>
  110. <#if func.isExcludeField(colName) >
  111. <#if colName?if_exists?string!="id" && colName?if_exists?string!="fkid" >
  112. ${colName}:'',
  113. </#if>
  114. </#if>
  115. </#list>
  116. editable: true,
  117. },
  118. columns:[
  119. <#list subTable.columnList as col>
  120. <#assign colName=func.convertUnderLine(col.columnName)>
  121. <#if func.isExcludeField(colName) >
  122. {
  123. title: '${col.comment}',
  124. dataIndex: '${colName}',
  125. width: '20%',
  126. scopedSlots: { customRender: '${colName}' },
  127. },
  128. </#if>
  129. </#list>
  130. {
  131. title: 'operation',
  132. dataIndex: 'operation',
  133. scopedSlots: { customRender: 'operation' },
  134. },
  135. ],
  136. fields:[
  137. <#list subTable.columnList as col>
  138. <#assign colName=func.convertUnderLine(col.columnName)>
  139. <#if func.isExcludeField(colName) >
  140. '${colName}',
  141. </#if>
  142. </#list>
  143. ]
  144. },
  145. </#list>
  146. </#if>
  147. },
  148. rules: {
  149. <#list commonList as col>
  150. <#assign colName=func.convertUnderLine(col.columnName)>
  151. <#if func.isExcludeField(colName) >
  152. <#assign isNotNull=col.getIsNotNull()?string("true","false") >
  153. ${colName}: [{ required:${isNotNull},message:"请输入${col.comment}", trigger: 'change' }],
  154. </#if>
  155. </#list>
  156. }
  157. }
  158. },
  159. methods: {
  160. get(id){
  161. return ${class}Api.get(id);
  162. },
  163. save(){
  164. return ${class}Api.save(this.mdl);
  165. },
  166. }
  167. }
  168. </script>
  169. <style>
  170. .relick a{
  171. margin-right: 10px;
  172. }
  173. </style>