You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

370 lines
13 KiB

  1. <template>
  2. <view class="page">
  3. <view v-if="ready">
  4. <l-date-picker
  5. @input="setValue('StuInfoBasic.Birthday', $event)"
  6. :value="getValue('StuInfoBasic.Birthday')"
  7. :disabled="!edit"
  8. title="出生日期"
  9. />
  10. <l-select
  11. @input="setValue('StuInfoBasic.PartyFaceNo', $event)"
  12. :value="getValue('StuInfoBasic.PartyFaceNo')"
  13. :disabled="!edit"
  14. :range="dataSource.StuInfoBasic.PartyFaceNo"
  15. title="政治面貌"
  16. />
  17. <l-select
  18. @input="setValue('StuInfoBasic.NationalityNo', $event)"
  19. :value="getValue('StuInfoBasic.NationalityNo')"
  20. :disabled="!edit"
  21. :range="dataSource.StuInfoBasic.NationalityNo"
  22. title="民族"
  23. />
  24. <l-select
  25. @input="setValue('StuInfoBasic.ResidenceNo', $event)"
  26. :value="getValue('StuInfoBasic.ResidenceNo')"
  27. :disabled="!edit"
  28. :range="dataSource.StuInfoBasic.ResidenceNo"
  29. title="户口分类"
  30. />
  31. <l-upload-file
  32. @input="setValue('StuInfoBasic.Photo', $event)"
  33. :value="getValue('StuInfoBasic.Photo')"
  34. :readonly="!edit"
  35. :number="3"
  36. title="照片"
  37. />
  38. <l-input
  39. @input="setValue('StuInfoBasic.mobile', $event)"
  40. :value="getValue('StuInfoBasic.mobile')"
  41. :disabled="!edit"
  42. title="联系电话"
  43. />
  44. <l-input
  45. @input="setValue('StuInfoBasic.EMail', $event)"
  46. :value="getValue('StuInfoBasic.EMail')"
  47. :disabled="!edit"
  48. title="邮箱"
  49. />
  50. <l-input
  51. @input="setValue('StuInfoBasic.MailAddress', $event)"
  52. :value="getValue('StuInfoBasic.MailAddress')"
  53. :disabled="!edit"
  54. title="通信地址"
  55. />
  56. <l-input
  57. @input="setValue('StuInfoBasic.PostalCode', $event)"
  58. :value="getValue('StuInfoBasic.PostalCode')"
  59. :disabled="!edit"
  60. title="邮政编码"
  61. />
  62. <l-input
  63. @input="setValue('StuInfoBasic.FatherUnit', $event)"
  64. :value="getValue('StuInfoBasic.FatherUnit')"
  65. :disabled="!edit"
  66. title="户口所在地"
  67. />
  68. <l-input
  69. @input="setValue('StuInfoBasic.MatherUnit', $event)"
  70. :value="getValue('StuInfoBasic.MatherUnit')"
  71. :disabled="!edit"
  72. title="档案所在地"
  73. />
  74. <l-input
  75. @input="setValue('StuInfoBasic.FatherName', $event)"
  76. :value="getValue('StuInfoBasic.FatherName')"
  77. :disabled="!edit"
  78. title="父亲名字"
  79. />
  80. <l-input
  81. @input="setValue('StuInfoBasic.FatherPhone', $event)"
  82. :value="getValue('StuInfoBasic.FatherPhone')"
  83. :disabled="!edit"
  84. title="父亲电话"
  85. required
  86. />
  87. <l-input
  88. @input="setValue('StuInfoBasic.MatherName', $event)"
  89. :value="getValue('StuInfoBasic.MatherName')"
  90. :disabled="!edit"
  91. title="母亲名字"
  92. />
  93. <l-input
  94. @input="setValue('StuInfoBasic.MatherPhone', $event)"
  95. :value="getValue('StuInfoBasic.MatherPhone')"
  96. :disabled="!edit"
  97. title="母亲电话"
  98. />
  99. <l-select
  100. @input="setValue('StuInfoBasic.FamilyOriginNo', $event)"
  101. :value="getValue('StuInfoBasic.FamilyOriginNo')"
  102. :disabled="!edit"
  103. :range="dataSource.StuInfoBasic.FamilyOriginNo"
  104. title="家庭出生"
  105. />
  106. <l-select
  107. @input="setValue('StuInfoBasic.OverseasChineseNo', $event)"
  108. :value="getValue('StuInfoBasic.OverseasChineseNo')"
  109. :disabled="!edit"
  110. :range="dataSource.StuInfoBasic.OverseasChineseNo"
  111. title="港澳台侨"
  112. />
  113. <l-select
  114. @input="setValue('StuInfoBasic.GraduateNo', $event)"
  115. :value="getValue('StuInfoBasic.GraduateNo')"
  116. :disabled="!edit"
  117. :range="dataSource.StuInfoBasic.GraduateNo"
  118. title="本专科"
  119. />
  120. <l-input
  121. @input="setValue('StuInfoBasic.InSchoolAddress', $event)"
  122. :value="getValue('StuInfoBasic.InSchoolAddress')"
  123. :disabled="!edit"
  124. title="校内地址"
  125. />
  126. <l-input
  127. @input="setValue('StuInfoBasic.InSchoolTelephone', $event)"
  128. :value="getValue('StuInfoBasic.InSchoolTelephone')"
  129. :disabled="!edit"
  130. title="校内电话"
  131. />
  132. <l-input
  133. @input="setValue('StuInfoBasic.QQ', $event)"
  134. :value="getValue('StuInfoBasic.QQ')"
  135. :disabled="!edit"
  136. title="QQ"
  137. />
  138. <l-textarea
  139. @input="setValue('StuInfoBasic.GoodAt', $event)"
  140. :value="getValue('StuInfoBasic.GoodAt')"
  141. :readonly="!edit"
  142. title="特长"
  143. />
  144. </view>
  145. <view v-if="ready" class="bg-white margin-tb padding" style="padding-top: 0; overflow: hidden;">
  146. <l-button v-if="edit" @click="action('save')" size="lg" color="green" class="block margin-top" block>
  147. 提交保存
  148. </l-button>
  149. <l-button v-if="!edit && mode !== 'create'" @click="action('edit')" size="lg" line="orange" class="block margin-top" block>
  150. 编辑本页
  151. </l-button>
  152. <l-button v-if="edit && mode !== 'create'" @click="action('reset')" size="lg" line="red" class="block margin-top" block>
  153. 取消编辑
  154. </l-button>
  155. <l-button v-if="!edit && mode !== 'create'" @click="action('delete')" size="lg" line="red" class="block margin-top" block>
  156. 删除
  157. </l-button>
  158. </view>
  159. </view>
  160. </template>
  161. <script>
  162. /*
  163. * 版 本 Learun-ADMS V7.0.3 力软敏捷开发框架(http://www.learun.cn)
  164. * Copyright (c) 2013-2020 上海力软信息技术有限公司
  165. * 创建人:超级管理员
  166. * 日 期:2020-10-15 10:16
  167. * 描 述:个人信息
  168. */
  169. /**
  170. * 本段代码由移动端代码生成器输出,移动端须 2.2.0 版本及以上可以使用
  171. * 请在移动端 /pages.json 中的 pages 字段中添加一条记录:
  172. * { "path": "pages/EducationalAdministration/StuInfoBasic/single", "style": { "navigationBarTitleText": "表单详情页" } }
  173. *
  174. * (navigationBarTitleText 字段为本页面的标题文本,可以修改)
  175. * (必须自行操作该步骤,力软代码生成器不会自动帮您修改 /pages.json 文件)
  176. */
  177. import get from 'lodash/get'
  178. import set from 'lodash/set'
  179. import moment from 'moment'
  180. import customPageMixins from '@/common/custompage.js'
  181. export default {
  182. mixins: [customPageMixins],
  183. data() {
  184. return {
  185. // 页面相关参数
  186. id: null,
  187. mode: null,
  188. edit: null,
  189. ready: false,
  190. // 表单数据
  191. current: {},
  192. origin: {},
  193. // 表单项数据结构
  194. scheme: {
  195. StuInfoBasic: {
  196. Birthday: { type: 'text', title: '出生日期', dateformat: '0' },
  197. PartyFaceNo: { type: 'select', title: '政治面貌', dataSource: '1', dataSourceId: 'BCdPartyFace,partyface,partyfaceno' },
  198. NationalityNo: { type: 'select', title: '民族', itemCode: 'National', dataSource: '0' },
  199. ResidenceNo: { type: 'select', title: '户口分类', itemCode: 'ResidenceNo', dataSource: '0' },
  200. Photo: { type: 'upload', title: '照片' },
  201. mobile: { type: 'text', title: '联系电话' },
  202. EMail: { type: 'text', title: '邮箱' },
  203. MailAddress: { type: 'text', title: '通信地址' },
  204. PostalCode: { type: 'text', title: '邮政编码' },
  205. FatherUnit: { type: 'text', title: '户口所在地' },
  206. MatherUnit: { type: 'text', title: '档案所在地' },
  207. FatherName: { type: 'text', title: '父亲名字' },
  208. FatherPhone: { type: 'text', title: '父亲电话', verify: 'PhoneOrNull' },
  209. MatherName: { type: 'text', title: '母亲名字' },
  210. MatherPhone: { type: 'text', title: '母亲电话' },
  211. FamilyOriginNo: { type: 'select', title: '家庭出生', dataSource: '1', dataSourceId: 'BCdFamilyOrigin,familyorigin,familyoriginno' },
  212. OverseasChineseNo: { type: 'select', title: '港澳台侨', dataSource: '1', dataSourceId: 'BCdOverseasChinese,overseaschinesename,overseaschineseno' },
  213. GraduateNo: { type: 'select', title: '本专科', itemCode: 'CollegeType', dataSource: '0' },
  214. InSchoolAddress: { type: 'text', title: '校内地址' },
  215. InSchoolTelephone: { type: 'text', title: '校内电话' },
  216. QQ: { type: 'text', title: 'QQ' },
  217. GoodAt: { type: 'textarea', title: '特长' },
  218. },
  219. },
  220. // 数据源
  221. dataSource: {
  222. StuInfoBasic: {
  223. PartyFaceNo: [],
  224. NationalityNo: Object.values(this.GET_GLOBAL('dataDictionary').National).map(t => ({ value: t.value, text: t.text })),
  225. ResidenceNo: Object.values(this.GET_GLOBAL('dataDictionary').ResidenceNo).map(t => ({ value: t.value, text: t.text })),
  226. FamilyOriginNo: [],
  227. OverseasChineseNo: [],
  228. GraduateNo: Object.values(this.GET_GLOBAL('dataDictionary').CollegeType).map(t => ({ value: t.value, text: t.text })),
  229. },
  230. }
  231. }
  232. },
  233. async onLoad({ type, id }) {
  234. let account=this.GET_GLOBAL('loginUser').account;
  235. console.log(this.GET_GLOBAL('loginUser'));
  236. let stuInfo = await this.HTTP_GET('learun/adms/EducationalAdministration/StuInfoBasic/stuinfo', account)
  237. id=stuInfo.StuId;
  238. await this.init(type, id)
  239. // this.HTTP_GET('learun/adms/EducationalAdministration/StuInfoBasic/stuinfo', account).then(res => {
  240. // console.log(res)
  241. // })
  242. },
  243. methods: {
  244. // 页面初始化
  245. async init(type, id) {
  246. this.LOADING('加载数据中...')
  247. this.id = id
  248. this.mode = type
  249. this.edit = ['create', 'edit'].includes(this.mode)
  250. // 拉取表单数据,同时拉取所有来自数据源的选单数据
  251. await Promise.all([
  252. this.FETCH_DATASOURCE('BCdPartyFace').then(result => {
  253. this.dataSource.StuInfoBasic.PartyFaceNo = result.data.map(t => ({ text: t.partyface, value: t.partyfaceno }))
  254. }),
  255. this.FETCH_DATASOURCE('BCdFamilyOrigin').then(result => {
  256. this.dataSource.StuInfoBasic.FamilyOriginNo = result.data.map(t => ({ text: t.familyorigin, value: t.familyoriginno }))
  257. }),
  258. this.FETCH_DATASOURCE('BCdOverseasChinese').then(result => {
  259. this.dataSource.StuInfoBasic.OverseasChineseNo = result.data.map(t => ({ text: t.overseaschinesename, value: t.overseaschineseno }))
  260. }),
  261. () => {}
  262. ])
  263. await this.fetchForm()
  264. this.ready = true
  265. this.HIDE_LOADING()
  266. },
  267. // 加载表单数据
  268. async fetchForm() {
  269. if (this.mode === 'create') {
  270. this.origin = await this.getDefaultForm()
  271. } else {
  272. const result = await this.HTTP_GET('learun/adms/EducationalAdministration/StuInfoBasic/form', this.id)
  273. this.origin = await this.formatFormData(result)
  274. }
  275. this.current = this.COPY(this.origin)
  276. },
  277. // 点击 「编辑」、「重置」、「保存」、「删除」 按钮
  278. async action(type) {
  279. switch (type) {
  280. case 'edit':
  281. this.edit = true
  282. break
  283. case 'reset':
  284. this.current = this.COPY(this.origin)
  285. this.edit = false
  286. break
  287. case 'save':
  288. const verifyResult = this.verifyForm()
  289. if (verifyResult.length > 0) {
  290. this.CONFIRM('表单验证失败', verifyResult.join('\n'))
  291. return
  292. }
  293. if (!(await this.CONFIRM('提交确认', '确定要提交本页表单内容吗?', true))) {
  294. return
  295. }
  296. this.LOADING('正在提交...')
  297. const postData = await this.getPostData(this.id)
  298. this.HTTP_POST('learun/adms/EducationalAdministration/StuInfoBasic/save', postData, '表单提交保存失败').then(success => {
  299. this.HIDE_LOADING()
  300. if (!success) {
  301. return
  302. }
  303. this.EMIT('EducationalAdministrationStuInfoBasic-list-change')
  304. this.NAV_BACK()
  305. this.TOAST('提交保存成功')
  306. })
  307. break
  308. case 'delete':
  309. if (!(await this.CONFIRM('删除项目', '确定要删除本项吗?', true))) {
  310. return
  311. }
  312. this.LOADING('提交删除中...')
  313. this.HTTP_POST('learun/adms/EducationalAdministration/StuInfoBasic/delete', this.id, '删除失败').then(success => {
  314. this.HIDE_LOADING()
  315. if (!success) {
  316. return
  317. }
  318. this.EMIT('EducationalAdministrationStuInfoBasic-list-change')
  319. this.NAV_BACK()
  320. this.this.TOAST('删除成功', 'success')
  321. })
  322. break
  323. default: break
  324. }
  325. },
  326. // 获取表单值
  327. getValue(path) {
  328. return get(this.current, path)
  329. },
  330. // 设置表单值
  331. setValue(path, val) {
  332. set(this.current, path, val)
  333. }
  334. }
  335. }
  336. </script>