e3d9df3e6864e2110c472c359619cbb7579acce7.svn-base 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. <#--<#include "../../../../../../../common/utils.ftl">-->
  2. <#include "/common/utils.ftl">
  3. <template>
  4. <a-spin :spinning="confirmLoading">
  5. <j-form-container :disabled="formDisabled">
  6. <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
  7. <a-row>
  8. <#assign form_popup = false>
  9. <#assign form_cat_tree = false>
  10. <#assign form_cat_back = "">
  11. <#assign bpm_flag=false>
  12. <#assign form_span = 24>
  13. <#if tableVo.fieldRowNum==2>
  14. <#assign form_span = 12>
  15. <#elseif tableVo.fieldRowNum==3>
  16. <#assign form_span = 8>
  17. <#elseif tableVo.fieldRowNum==4>
  18. <#assign form_span = 6>
  19. </#if>
  20. <#list columns as po>
  21. <#if po.fieldDbName=='bpm_status'>
  22. <#assign bpm_flag=true>
  23. </#if>
  24. <#if po.isShow =='Y' && po.fieldName != 'id'>
  25. <#assign form_field_dictCode="">
  26. <#if po.dictTable?default("")?trim?length gt 1 && po.dictText?default("")?trim?length gt 1 && po.dictField?default("")?trim?length gt 1>
  27. <#assign form_field_dictCode="${po.dictTable},${po.dictText},${po.dictField}">
  28. <#elseif po.dictField?default("")?trim?length gt 1>
  29. <#assign form_field_dictCode="${po.dictField}">
  30. </#if>
  31. <a-col :span="${form_span}">
  32. <a-form-model-item label="${po.filedComment}" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="${autoStringSuffixForModel(po)}">
  33. <#if po.classType =='date'>
  34. <j-date placeholder="请选择${po.filedComment}" v-model="model.${po.fieldName}" style="width: 100%" <#if po.readonly=='Y'>disabled</#if>/>
  35. <#elseif po.classType =='datetime'>
  36. <j-date placeholder="请选择${po.filedComment}" v-model="model.${po.fieldName}" :show-time="true" date-format="YYYY-MM-DD HH:mm:ss" style="width: 100%" <#if po.readonly=='Y'>disabled</#if>/>
  37. <#elseif po.classType =='time'>
  38. <j-time placeholder="请选择${po.filedComment}" v-model="model.${po.fieldName}" style="width: 100%" <#if po.readonly=='Y'>disabled</#if>/>
  39. <#elseif po.classType =='popup'>
  40. <#assign form_popup=true>
  41. <j-popup
  42. v-model="model.${po.fieldName}"
  43. field="${po.fieldName}"
  44. org-fields="${po.dictField}"
  45. dest-fields="${Format.underlineToHump(po.dictText)}"
  46. code="${po.dictTable}"
  47. :multi="${po.extendParams.popupMulti?c}"
  48. @input="popupCallback"
  49. <#if po.readonly=='Y'>disabled</#if>/>
  50. <#elseif po.classType =='sel_depart'>
  51. <j-select-depart v-model="model.${po.fieldName}" multi <#if po.readonly=='Y'>disabled</#if> />
  52. <#elseif po.classType =='switch'>
  53. <j-switch v-model="model.${po.fieldName}" <#if po.dictField != 'is_open'>:options="${po.dictField}"</#if> <#if po.readonly=='Y'>disabled</#if>></j-switch>
  54. <#elseif po.classType =='pca'>
  55. <j-area-linkage type="cascader" v-model="model.${po.fieldName}" placeholder="请输入省市区" <#if po.readonly=='Y'>disabled</#if> />
  56. <#elseif po.classType =='markdown'>
  57. <j-markdown-editor v-model="model.${autoStringSuffixForModel(po)}" id="${po.fieldName}"></j-markdown-editor>
  58. <#elseif po.classType =='password'>
  59. <a-input-password v-model="model.${po.fieldName}" placeholder="请输入${po.filedComment}" <#if po.readonly=='Y'>disabled</#if>/>
  60. <#elseif po.classType =='sel_user'>
  61. <j-select-user-by-dep v-model="model.${po.fieldName}" <#if po.readonly=='Y'>disabled</#if>/>
  62. <#elseif po.classType =='textarea'>
  63. <a-textarea v-model="model.${autoStringSuffixForModel(po)}" rows="4" placeholder="请输入${po.filedComment}" <#if po.readonly=='Y'>disabled</#if>/>
  64. <#elseif po.classType=='list' || po.classType=='radio'>
  65. <j-dict-select-tag type="${po.classType}" v-model="model.${po.fieldName}" dictCode="${form_field_dictCode}" placeholder="请选择${po.filedComment}" <#if po.readonly=='Y'>disabled</#if>/>
  66. <#elseif po.classType=='list_multi' || po.classType=='checkbox'>
  67. <j-multi-select-tag type="${po.classType}" v-model="model.${po.fieldName}" dictCode="${form_field_dictCode}" placeholder="请选择${po.filedComment}" <#if po.readonly=='Y'>disabled</#if>/>
  68. <#elseif po.classType=='sel_search'>
  69. <j-search-select-tag v-model="model.${po.fieldName}" dict="${form_field_dictCode}" <#if po.readonly=='Y'>disabled</#if> />
  70. <#elseif po.classType=='cat_tree'>
  71. <#assign form_cat_tree = true>
  72. <j-category-select v-model="model.${po.fieldName}" pcode="${po.dictField?default("")}" placeholder="请选择${po.filedComment}" <#if po.dictText?default("")?trim?length gt 1>back="${dashedToCamel(po.dictText)}" @change="handleCategoryChange"</#if> <#if po.readonly=='Y'>disabled</#if>/>
  73. <#if po.dictText?default("")?trim?length gt 1>
  74. <#assign form_cat_back = "${po.dictText}">
  75. </#if>
  76. <#elseif po.fieldDbType=='int' || po.fieldDbType=='double' || po.fieldDbType=='BigDecimal'>
  77. <a-input-number v-model="model.${po.fieldName}" placeholder="请输入${po.filedComment}" style="width: 100%" <#if po.readonly=='Y'>disabled</#if>/>
  78. <#elseif po.classType=='file'>
  79. <j-upload v-model="model.${po.fieldName}" <#if po.readonly=='Y'>disabled</#if> <#if po.uploadnum??>:number=${po.uploadnum}</#if>></j-upload>
  80. <#elseif po.classType=='image'>
  81. <j-image-upload isMultiple <#if po.uploadnum??>:number=${po.uploadnum}</#if> v-model="model.${po.fieldName}" <#if po.readonly=='Y'>disabled</#if>></j-image-upload>
  82. <#elseif po.classType=='umeditor'>
  83. <j-editor v-model="model.${autoStringSuffixForModel(po)}" <#if po.readonly=='Y'>disabled</#if>/>
  84. <#elseif po.fieldDbType=='Blob'>
  85. <a-input v-model="model.${autoStringSuffixForModel(po)}" placeholder="请输入${po.filedComment}" <#if po.readonly=='Y'>disabled</#if>></a-input>
  86. <#elseif po.classType == 'sel_tree'>
  87. <j-tree-select
  88. ref="treeSelect"
  89. placeholder="请选择${po.filedComment}"
  90. v-model="model.${po.fieldName}"
  91. <#if po.dictText??>
  92. <#if po.dictText?split(',')[2]?? && po.dictText?split(',')[0]??>
  93. dict="${po.dictTable},${po.dictText?split(',')[2]},${po.dictText?split(',')[0]}"
  94. <#elseif po.dictText?split(',')[1]??>
  95. pidField="${po.dictText?split(',')[1]}"
  96. <#elseif po.dictText?split(',')[3]??>
  97. hasChildField="${po.dictText?split(',')[3]}"
  98. </#if>
  99. </#if>
  100. pidValue="${po.dictField}"
  101. <#if po.readonly=='Y'>disabled</#if>>
  102. </j-tree-select>
  103. <#else>
  104. <a-input v-model="model.${po.fieldName}" placeholder="请输入${po.filedComment}" <#if po.readonly=='Y'>disabled</#if> ></a-input>
  105. </#if>
  106. </a-form-model-item>
  107. </a-col>
  108. </#if>
  109. </#list>
  110. <#if bpm_flag>
  111. <a-col v-if="showFlowSubmitButton" :span="24" style="text-align: center">
  112. <a-button @click="submitForm">提 交</a-button>
  113. </a-col>
  114. </#if>
  115. </a-row>
  116. </a-form-model>
  117. </j-form-container>
  118. </a-spin>
  119. </template>
  120. <script>
  121. import { httpAction, getAction } from '@/api/manage'
  122. import { validateDuplicateValue } from '@/utils/util'
  123. export default {
  124. name: '${entityName}Form',
  125. components: {
  126. },
  127. props: {
  128. <#if bpm_flag>
  129. //流程表单data
  130. formData: {
  131. type: Object,
  132. default: ()=>{},
  133. required: false
  134. },
  135. //表单模式:true流程表单 false普通表单
  136. formBpm: {
  137. type: Boolean,
  138. default: false,
  139. required: false
  140. },
  141. </#if>
  142. //表单禁用
  143. disabled: {
  144. type: Boolean,
  145. default: false,
  146. required: false
  147. }
  148. },
  149. data () {
  150. return {
  151. model:{
  152. <#include "/common/init/initValue.ftl">
  153. },
  154. labelCol: {
  155. xs: { span: 24 },
  156. sm: { span: 5 },
  157. },
  158. wrapperCol: {
  159. xs: { span: 24 },
  160. sm: { span: 16 },
  161. },
  162. confirmLoading: false,
  163. <#include "/common/validatorRulesTemplate/main.ftl">
  164. url: {
  165. add: "/${entityPackage}/${entityName?uncap_first}/add",
  166. edit: "/${entityPackage}/${entityName?uncap_first}/edit",
  167. queryById: "/${entityPackage}/${entityName?uncap_first}/queryById"
  168. }
  169. }
  170. },
  171. computed: {
  172. formDisabled(){
  173. <#if bpm_flag>
  174. if(this.formBpm===true){
  175. if(this.formData.disabled===false){
  176. return false
  177. }
  178. return true
  179. }
  180. </#if>
  181. return this.disabled
  182. },
  183. <#if bpm_flag>
  184. showFlowSubmitButton(){
  185. if(this.formBpm===true){
  186. if(this.formData.disabled===false){
  187. return true
  188. }
  189. }
  190. return false
  191. }
  192. </#if>
  193. },
  194. created () {
  195. //备份model原始值
  196. this.modelDefault = JSON.parse(JSON.stringify(this.model));
  197. <#if bpm_flag>
  198. //如果是流程中表单,则需要加载流程表单data
  199. this.showFlowData();
  200. </#if>
  201. },
  202. methods: {
  203. add () {
  204. this.edit(this.modelDefault);
  205. },
  206. edit (record) {
  207. this.model = Object.assign({}, record);
  208. this.visible = true;
  209. },
  210. <#if bpm_flag>
  211. //渲染流程表单数据
  212. showFlowData(){
  213. if(this.formBpm === true){
  214. let params = {id:this.formData.dataId};
  215. getAction(this.url.queryById,params).then((res)=>{
  216. if(res.success){
  217. this.edit (res.result);
  218. }
  219. });
  220. }
  221. },
  222. </#if>
  223. submitForm () {
  224. const that = this;
  225. // 触发表单验证
  226. this.$refs.form.validate(valid => {
  227. if (valid) {
  228. that.confirmLoading = true;
  229. let httpurl = '';
  230. let method = '';
  231. if(!this.model.id){
  232. httpurl+=this.url.add;
  233. method = 'post';
  234. }else{
  235. httpurl+=this.url.edit;
  236. method = 'post';
  237. }
  238. httpAction(httpurl,this.model,method).then((res)=>{
  239. if(res.success){
  240. that.$message.success(res.message);
  241. that.$emit('ok');
  242. }else{
  243. that.$message.warning(res.message);
  244. }
  245. }).finally(() => {
  246. that.confirmLoading = false;
  247. })
  248. }
  249. })
  250. },
  251. <#if form_popup>
  252. popupCallback(value,row){
  253. this.model = Object.assign(this.model, row);
  254. },
  255. </#if>
  256. <#if form_cat_tree>
  257. handleCategoryChange(value,backObj){
  258. this.model = Object.assign(this.model, backObj);
  259. }
  260. </#if>
  261. }
  262. }
  263. </script>