detail.vue.vm 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443
  1. #parse("PublicMacro/AppFormMarco.vm")
  2. <template>
  3. <view class="jnpf-wrap jnpf-wrap-form dynamicModel-form-v" v-if="!loading">
  4. <u-form :model="${context.formModel}" :rules="${context.formRules}" ref="${context.formModel}" :errorType="['toast']"
  5. #set($position='left')
  6. #if(${context.labelPosition}=='top')
  7. #set($position='top')
  8. #end
  9. #set($align='left')
  10. #if(${context.labelPosition}=='right')
  11. #set($align='right')
  12. #end
  13. label-position="${position}" label-align="${align}" :label-width="labelwidth" class="jnpf-form">
  14. #AppDetailRendering()
  15. </u-form>
  16. <view class="buttom-actions" >
  17. <template v-if="btnList.includes('btn_edit')">
  18. <CustomButton :btnText="$t('common.cancelText')" btnIcon="icon-ym icon-ym-add-cancel" customIcon />
  19. <u-button class="buttom-btn" type="primary" @click.stop="submitForm">{{$t('common.editText','编辑')}}</u-button>
  20. </template>
  21. <u-button v-else class="buttom-btn" @click="resetForm">{{$t('common.cancelText','取消')}}</u-button>
  22. </view>
  23. <u-modal v-model="show" :content="content" width='70%' border-radius="16" :content-style="{fontSize: '28rpx',padding: '20rpx',lineHeight: '44rpx',textAlign: 'left'}"
  24. :titleStyle="{padding: '20rpx'}" :confirm-style="{height: '80rpx',lineHeight: '80rpx'}" :title="title" confirm-text="确定">
  25. </u-modal>
  26. </view>
  27. </template>
  28. <script>
  29. import {
  30. getDictionaryDataSelector,
  31. getDataInterfaceRes
  32. } from '@/api/common'
  33. import {
  34. getRelationFormDetail,
  35. getDataInterfaceDataInfoByIds
  36. } from '@/api/common.js'
  37. import request from '@/utils/request'
  38. import DisplayList from '@/components/displayList'
  39. import CustomButton from '@/components/CustomButton'
  40. export default {
  41. components:{
  42. DisplayList,
  43. CustomButton
  44. },
  45. data(){
  46. return{
  47. btnLoading: false,
  48. loading: false,
  49. text: '提示:测试文本',
  50. tableKey:'',
  51. timeKey : +new Date(),
  52. ${context.formModel}:{
  53. ${pKeyName}:"",
  54. },
  55. ${context.formRules}:{},
  56. #foreach($fieLdsModel in ${context.form})
  57. #set($jnpfkey = "${fieLdsModel.jnpfKey}")
  58. #set($isEnd = "${fieLdsModel.isEnd}")
  59. #set($formModel = ${fieLdsModel.formModel})
  60. #set($model = "${formModel.model}")
  61. #set($outermost = ${formModel.outermost})
  62. #set($children = ${formModel.children})
  63. #if(${layoutList.contains($jnpfkey)})
  64. #if(${isEnd}=='0')
  65. #if(${outermost}=='0')
  66. #if($jnpfkey=='collapse')
  67. ${model}active: #if($formModel.accordion) '${formModel.active}' #else ${formModel.active} #end,
  68. #end
  69. ${model}Current:${formModel.activeIndex},
  70. ${model}Data:[
  71. #foreach($childrenList in $children)
  72. {
  73. title: #if(${childrenList.titleI18nCode}) this.$t('${childrenList.titleI18nCode}')#else "${childrenList.title}" #end
  74. },
  75. #end
  76. ],
  77. #end
  78. #end
  79. #end
  80. #end
  81. interfaceRes:{
  82. #foreach($html in ${context.fields})
  83. #set($fieLdsModel = $html.formColumnModel.fieLdsModel)
  84. #faceRes($fieLdsModel,'')
  85. #end
  86. #foreach($masetkey in $mastTableList.entrySet())
  87. #set($fieldsAll = $masetkey.value)
  88. #foreach($html in ${fieldsAll})
  89. #set($fieLdsModel = $html.formMastTableModel.mastTable.fieLdsModel)
  90. #faceRes($fieLdsModel,'')
  91. #end
  92. #end
  93. #foreach($child in ${context.children})
  94. #set($className = "${child.className}")
  95. #foreach($childList in ${child.childList})
  96. #set($fieLdsModel = $childList.fieLdsModel)
  97. #faceRes($fieLdsModel,$className)
  98. #end
  99. #end
  100. },
  101. extraOptions:{
  102. #foreach($html in ${context.fields})
  103. #set($fieLdsModel = $html.formColumnModel.fieLdsModel)
  104. #extraOptions($fieLdsModel,'')
  105. #end
  106. #foreach($masetkey in $mastTableList.entrySet())
  107. #set($fieldsAll = $masetkey.value)
  108. #foreach($html in ${fieldsAll})
  109. #set($fieLdsModel = $html.formMastTableModel.mastTable.fieLdsModel)
  110. #extraOptions($fieLdsModel,'')
  111. #end
  112. #end
  113. #foreach($child in ${context.children})
  114. #set($className = "${child.className}")
  115. #foreach($childList in ${child.childList})
  116. #set($fieLdsModel = $childList.fieLdsModel)
  117. #extraOptions($fieLdsModel,$className)
  118. #end
  119. #end
  120. },
  121. extraData:{
  122. #foreach($fieLdsModel in ${context.fields})
  123. #set($html = $fieLdsModel.formColumnModel.fieLdsModel)
  124. #set($vModel = "${html.vModel}")
  125. #if($vModel)
  126. $!{vModel} : {},
  127. #end
  128. #end
  129. #foreach($masetkey in $mastTableList.entrySet())
  130. #set($fieldsAll = $masetkey.value)
  131. #foreach($fieLdsModel in ${fieldsAll})
  132. #set($mastTableModel = $fieLdsModel.formMastTableModel)
  133. #set($html = $fieLdsModel.formMastTableModel.mastTable.fieLdsModel)
  134. #set($vModel = "${mastTableModel.vModel}")
  135. #if($vModel)
  136. $!{vModel} : {},
  137. #end
  138. #end
  139. #end
  140. },
  141. maskConfig:{
  142. #foreach($html in ${context.fields})
  143. #set($fieLdsModel = $html.formColumnModel.fieLdsModel)
  144. #maskConfig($fieLdsModel,'')
  145. #end
  146. #foreach($masetkey in $mastTableList.entrySet())
  147. #set($fieldsAll = $masetkey.value)
  148. #foreach($html in ${fieldsAll})
  149. #set($fieLdsModel = $html.formMastTableModel.mastTable.fieLdsModel)
  150. #maskConfig($fieLdsModel,'')
  151. #end
  152. #end
  153. #foreach($child in ${context.children})
  154. #set($className = "${child.className}")
  155. #foreach($childList in ${child.childList})
  156. #set($fieLdsModel = $childList.fieLdsModel)
  157. #maskConfig($fieLdsModel,$className)
  158. #end
  159. #end
  160. },
  161. labelwidth:${context.labelWidth}*1.5,
  162. menuId:'',
  163. btnList:[],
  164. idList:[],
  165. ruleList:{},
  166. childIndex:-1,
  167. content:'',
  168. title:'',
  169. show:false,
  170. }
  171. },
  172. onLoad(option) {
  173. this.menuId=option.menuId
  174. this.btnList=option.btnList.split(",")
  175. uni.setNavigationBarTitle({
  176. title: this.$t('common.detailText','详情')
  177. })
  178. this.${context.formModel}.${pKeyName} = option.id || 0
  179. this.idList = option.idList?option.idList.split(","):[]
  180. this.initData()
  181. uni.$on('refresh', () => {
  182. #foreach($fieLdsModel in ${context.form})
  183. #set($jnpfkey = "${fieLdsModel.jnpfKey}")
  184. #set($isEnd = "${fieLdsModel.isEnd}")
  185. #set($formModel = ${fieLdsModel.formModel})
  186. #set($model = "${formModel.model}")
  187. #set($outermost = ${formModel.outermost})
  188. #set($children = ${formModel.children})
  189. #if(${layoutList.contains($jnpfkey)})
  190. #if(${isEnd}=='0')
  191. #if(${outermost}=='0')
  192. #if($jnpfkey=='collapse')
  193. this.${model}active=#if($formModel.accordion) '${formModel.active}' #else ${formModel.active} #end
  194. #end
  195. this.${model}Current=${formModel.activeIndex}
  196. #end
  197. #end
  198. #end
  199. #end
  200. //执行接口更新数据
  201. this.initData()
  202. })
  203. uni.$on('initCollapse', () => {
  204. //初始化折叠面板高度高度
  205. this.collapse()
  206. })
  207. },
  208. beforeDestroy() {
  209. uni.$off('refresh')
  210. },
  211. onReady() {
  212. #set($rulesAll = "this."+${context.formRules})
  213. this.$refs.${context.formModel}.setRules(${rulesAll});
  214. },
  215. onShow(){
  216. this.collapse()
  217. },
  218. watch:{
  219. dataForm: {
  220. handler(val, oldVal) {
  221. #foreach($child in ${context.children})
  222. #set($className = "${child.className}")
  223. this.${className}()
  224. #end
  225. },
  226. deep: true
  227. }
  228. },
  229. methods:{
  230. getParamList(key) {
  231. let templateJson = this.interfaceRes[key];
  232. if (!templateJson || !templateJson.length || !this.dataForm) return templateJson;
  233. for (let i = 0; i < templateJson.length; i++) {
  234. if (templateJson[i].relationField && templateJson[i].sourceType == 1) {
  235. templateJson[i].defaultValue = this.dataForm[templateJson[i].relationField + '_id'] || '';
  236. }
  237. }
  238. return templateJson;
  239. },
  240. #foreach($html in ${context.fields})
  241. #set($fieLdsModel = $html.formColumnModel.fieLdsModel)
  242. #extraData($fieLdsModel,'','data')
  243. #end
  244. #foreach($masetkey in $mastTableList.entrySet())
  245. #set($fieldsAll = $masetkey.value)
  246. #foreach($html in ${fieldsAll})
  247. #set($fieLdsModel = $html.formMastTableModel.mastTable.fieLdsModel)
  248. #extraData($fieLdsModel,'','data')
  249. #end
  250. #end
  251. doPreviewImage(url,imagesList) {
  252. const images = imagesList.map(item => this.define.baseURL + item.url);
  253. uni.previewImage({
  254. urls: images,
  255. current: url,
  256. success: () => {},
  257. fail: () => {
  258. uni.showToast({
  259. title: '预览图片失败',
  260. icon: 'none'
  261. });
  262. }
  263. });
  264. },
  265. onCollapseChange() {
  266. uni.$emit('initCollapse')
  267. },
  268. toDetail(id, modelId) {
  269. if (!id) return
  270. let config = {
  271. modelId: modelId,
  272. id: id,
  273. formTitle: this.$t('common.detailText','详情'),
  274. noShowBtn: 1,
  275. noDataLog: 1,
  276. }
  277. this.$nextTick(() => {
  278. const url ='/pages/apply/dynamicModel/detail?config=' + this.jnpf.base64.encode(JSON.stringify(config),"UTF-8")
  279. uni.navigateTo({
  280. url: url
  281. })
  282. })
  283. },
  284. clickIcon(label,tipLabel) {
  285. this.content = tipLabel
  286. this.title = label
  287. this.show = true
  288. },
  289. checkChildRule() {
  290. let title = [];
  291. let _ruleList = this.ruleList
  292. for (let k in _ruleList) {
  293. let childData = this.${context.formModel}[k]
  294. childData.forEach((item, index) => {
  295. for (let model in _ruleList[k]) {
  296. if (item[model] instanceof Array) {
  297. if (item[model].length == 0) {
  298. title.push(_ruleList[k][model])
  299. }
  300. } else if (!item[model]) {
  301. title.push(_ruleList[k][model])
  302. }
  303. }
  304. })
  305. }
  306. if (title.length > 0) {
  307. return title[0]
  308. }
  309. },
  310. resetForm(){
  311. uni.navigateBack()
  312. },
  313. dataAll(){
  314. },
  315. #foreach($child in ${context.children})
  316. #set($tableModel = "${child.tableModel}")
  317. #set($className = "${child.className}")
  318. ${className}(){
  319. let table = this.${context.formModel}.${tableModel}
  320. let summaryField =${child.summaryField}
  321. let summaryFieldName =${child.summaryFieldName}
  322. #if($useFormPermission)
  323. for(let i=0;i<summaryField.length;i++){
  324. if(!this.${setPermission}.hasFormP("${tableModel}-"+summaryField[i],this.menuId)){
  325. summaryField.splice(i)
  326. }
  327. }
  328. #end
  329. let data ={}
  330. if(!table) return data
  331. let thousandsField = ${child.thousandsField}
  332. for (let i in summaryField) {
  333. let map = {}
  334. let val = 0
  335. for (let j = 0; j < table.length; j++) {
  336. let summary = table[j][summaryField[i]];
  337. if (summary) {
  338. let data = isNaN(summary) ? 0 : Number(summary)
  339. val += data
  340. }
  341. }
  342. map.id = summaryField[i];
  343. map.name = summaryFieldName[summaryField[i]+"_i18n"] ? this.$t(summaryFieldName[summaryField[i]+"_i18n"]):summaryFieldName[summaryField[i]];
  344. map.val = (thousandsField.includes(summaryField[i]))? Number(val).toLocaleString('zh', {
  345. maximumFractionDigits: '2',
  346. minimumFractionDigits: '2'
  347. }): val.toFixed(2);
  348. data[summaryField[i]]=map;
  349. }
  350. return data;
  351. },
  352. #end
  353. #foreach($fieLdsModel in ${context.form})
  354. #set($jnpfkey = "${fieLdsModel.jnpfKey}")
  355. #set($isEnd = "${fieLdsModel.isEnd}")
  356. #set($formModel = ${fieLdsModel.formModel})
  357. #set($outermost = ${formModel.outermost})
  358. #if($jnpfkey=='tab' || $jnpfkey=='steps')
  359. #if(${isEnd}=='0')
  360. #if(${outermost}=='0')
  361. ${formModel.model}(index) {
  362. this.${formModel.model}Current = index;
  363. this.timeKey = +new Date()
  364. #if($jnpfkey=='tab')
  365. this.collapse()
  366. setTimeout(() => {
  367. uni.$emit('initCollapse')
  368. }, 1000)
  369. #end
  370. },
  371. #end
  372. #end
  373. #end
  374. #end
  375. initData(){
  376. #set($nextTick='$'+"nextTick")
  377. this.$nextTick(function(){
  378. if (this.${context.formModel}.${pKeyName}) {
  379. this.loading = true
  380. request({
  381. url: '/api/${context.module}/${context.className}/'+'detail/'+this.${context.formModel}.${pKeyName},
  382. method: 'get',
  383. }).then(res => {
  384. this.dataInfo(res.data)
  385. this.loading = false
  386. })
  387. }
  388. })
  389. },
  390. submitForm(){
  391. uni.navigateTo({
  392. url: "./form?menuId=" + this.menuId + "&jurisdictionType=btn_edit&id="+this.${context.formModel}.${pKeyName}+"&idList="+this.idList
  393. })
  394. },
  395. selfInit() {
  396. this.$store.commit('base/UPDATE_RELATION_DATA', {})
  397. },
  398. dataInfo(dataAll){
  399. let _dataAll =dataAll
  400. this.${context.formModel}=_dataAll
  401. #foreach($html in ${context.fields})
  402. #set($fieLdsModel = $html.formColumnModel.fieLdsModel)
  403. #extraData($fieLdsModel,'','')
  404. #end
  405. #foreach($masetkey in $mastTableList.entrySet())
  406. #set($fieldsAll = $masetkey.value)
  407. #foreach($html in ${fieldsAll})
  408. #set($fieLdsModel = $html.formMastTableModel.mastTable.fieLdsModel)
  409. #extraData($fieLdsModel,'','')
  410. #end
  411. #end
  412. this.collapse()
  413. },
  414. collapse(){
  415. setTimeout(()=> {
  416. #foreach($fieLdsModel in ${context.form})
  417. #set($jnpfkey = "${fieLdsModel.jnpfKey}")
  418. #set($isEnd = "${fieLdsModel.isEnd}")
  419. #set($formModel = ${fieLdsModel.formModel})
  420. #set($outermost = ${formModel.outermost})
  421. #set($config=$formModel.config)
  422. #if(${layoutList.contains($jnpfkey)})
  423. #if(${config.app}==true)
  424. #if(${isEnd}=='0')
  425. #if(${outermost}=='0')
  426. this.$refs.${formModel.model}Current && this.$refs.${formModel.model}Current.init()
  427. #end
  428. #end
  429. #end
  430. #end
  431. #end
  432. }, 1000);
  433. },
  434. },
  435. }
  436. </script>
  437. <style>
  438. page{
  439. background-color: #f0f2f6;
  440. }
  441. </style>