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.
 
 
 
 
 
 

284 lines
9.9 KiB

  1. <template>
  2. <view class="page">
  3. <view v-if="ready">
  4. <l-select
  5. @input="setValue('StuGraduateStatistic.GraduateGo', $event)"
  6. :value="getValue('StuGraduateStatistic.GraduateGo')"
  7. :disabled="!edit"
  8. :range="dataSource.StuGraduateStatistic.GraduateGo"
  9. title="毕业去向"
  10. required
  11. />
  12. <l-input
  13. @input="setValue('StuGraduateStatistic.EnterUniversityName', $event)"
  14. :value="getValue('StuGraduateStatistic.EnterUniversityName')"
  15. :disabled="!edit"
  16. title="升入高校名称"
  17. />
  18. <l-select
  19. @input="setValue('StuGraduateStatistic.UniversityLevel', $event)"
  20. :value="getValue('StuGraduateStatistic.UniversityLevel')"
  21. :disabled="!edit"
  22. :range="dataSource.StuGraduateStatistic.UniversityLevel"
  23. title="大学层次"
  24. />
  25. <l-input
  26. @input="setValue('StuGraduateStatistic.EmployerName', $event)"
  27. :value="getValue('StuGraduateStatistic.EmployerName')"
  28. :disabled="!edit"
  29. title="就业单位名称"
  30. />
  31. <l-select
  32. @input="setValue('StuGraduateStatistic.EmployerProvince', $event)"
  33. :value="getValue('StuGraduateStatistic.EmployerProvince')"
  34. :disabled="!edit"
  35. :range="dataSource.StuGraduateStatistic.EmployerProvince"
  36. @change="EmployerProvinceChange"
  37. title="就业单位所属省"
  38. />
  39. <l-select
  40. @input="setValue('StuGraduateStatistic.EmployerCity', $event)"
  41. :value="getValue('StuGraduateStatistic.EmployerCity')"
  42. :disabled="!edit"
  43. :range="dataSource.StuGraduateStatistic.EmployerCity"
  44. @change="EmployerCityChange"
  45. title="就业单位所属市"
  46. />
  47. <l-select
  48. @input="setValue('StuGraduateStatistic.EmployerCountry', $event)"
  49. :value="getValue('StuGraduateStatistic.EmployerCountry')"
  50. :disabled="!edit"
  51. :range="dataSource.StuGraduateStatistic.EmployerCountry"
  52. title="就业单位所属县"
  53. />
  54. <l-textarea
  55. @input="setValue('StuGraduateStatistic.Remark', $event)"
  56. :value="getValue('StuGraduateStatistic.Remark')"
  57. :disabled="!edit"
  58. title="备注"
  59. >
  60. </l-textarea>
  61. </view>
  62. <view v-if="ready" class="bg-white margin-tb padding" style="padding-top: 0; overflow: hidden;">
  63. <l-button v-if="edit" @click="action('save')" size="lg" color="green" class="block margin-top" block>
  64. 提交保存
  65. </l-button>
  66. <l-button v-if="edit && mode !== 'create'" @click="action('reset')" size="lg" line="red" class="block margin-top" block>
  67. 取消编辑
  68. </l-button>
  69. </view>
  70. </view>
  71. </template>
  72. <script>
  73. /*
  74. * 版 本 Learun-ADMS V7.0.3 力软敏捷开发框架(http://www.learun.cn)
  75. * Copyright (c) 2013-2020 上海力软信息技术有限公司
  76. * 创建人:超级管理员
  77. * 日 期:2022-09-23 15:16
  78. * 描 述:毕业信息统计
  79. */
  80. /**
  81. * 本段代码由移动端代码生成器输出,移动端须 2.2.0 版本及以上可以使用
  82. * 请在移动端 /pages.json 中的 pages 字段中添加一条记录:
  83. * { "path": "pages/EducationalAdministration/StuGraduateStatistic/single", "style": { "navigationBarTitleText": "表单详情页" } }
  84. *
  85. * (navigationBarTitleText 字段为本页面的标题文本,可以修改)
  86. * (必须自行操作该步骤,力软代码生成器不会自动帮您修改 /pages.json 文件)
  87. */
  88. import get from 'lodash/get'
  89. import set from 'lodash/set'
  90. import moment from 'moment'
  91. import customPageMixins from '@/common/custompage.js'
  92. export default {
  93. mixins: [customPageMixins],
  94. data() {
  95. return {
  96. // 页面相关参数
  97. id: null,
  98. mode: null,
  99. edit: null,
  100. ready: false,
  101. // 表单数据
  102. current: {},
  103. origin: {},
  104. // 表单项数据结构
  105. scheme: {
  106. StuGraduateStatistic: {
  107. GraduateGo: { type: 'select', title: '毕业去向', itemCode: 'GraduateGo', dataSource: '0', verify: 'NotNull' },
  108. EnterUniversityName: { type: 'text', title: '升入高校名称' },
  109. UniversityLevel: { type: 'select', title: '大学层次', itemCode: 'UniversityLevel', dataSource: '0' },
  110. EmployerName: { type: 'text', title: '就业单位名称' },
  111. EmployerProvince: { type: 'select', title: '就业单位所属省', dataSource: '1', dataSourceId: 'DIC_PROVINCE,pname,pcode' },
  112. EmployerCity: { type: 'select', title: '就业单位所属市', dataSource: '1', dataSourceId: 'DIC_CITY,cname,ccode' },
  113. EmployerCountry: { type: 'select', title: '就业单位所属县(区)', dataSource: '1', dataSourceId: 'DIC_AREA,aname,acode' },
  114. Remark: { type: 'textarea' , title: '备注'},
  115. },
  116. },
  117. // 数据源
  118. dataSource: {
  119. StuGraduateStatistic: {
  120. GraduateGo: Object.values(this.GET_GLOBAL('dataDictionary').GraduateGo).map(t => ({ value: t.value, text: t.text })),
  121. UniversityLevel: Object.values(this.GET_GLOBAL('dataDictionary').GraduateLevel).map(t => ({ value: t.value, text: t.text })),
  122. EmployerProvince: [],
  123. EmployerCity: [],
  124. EmployerCountry: [],
  125. },
  126. }
  127. }
  128. },
  129. async onLoad({ type, id }) {
  130. await this.init(type, id)
  131. },
  132. methods: {
  133. // 页面初始化
  134. async init(type, id) {
  135. this.LOADING('加载数据中...')
  136. this.id = id
  137. this.mode = type
  138. this.edit = ['create', 'edit'].includes(this.mode)
  139. // 拉取表单数据,同时拉取所有来自数据源的选单数据
  140. await Promise.all([
  141. this.FETCH_DATASOURCE('DIC_PROVINCE').then(result => {
  142. this.dataSource.StuGraduateStatistic.EmployerProvince = result.data.map(t => ({ text: t.pname, value: t.pcode }))
  143. }),
  144. this.FETCH_DATASOURCE('DIC_CITY').then(result => {
  145. this.dataSource.StuGraduateStatistic.EmployerCity = result.data.map(t => ({ text: t.cname, value: t.ccode }))
  146. }),
  147. this.FETCH_DATASOURCE('DIC_AREA').then(result => {
  148. this.dataSource.StuGraduateStatistic.EmployerCountry = result.data.map(t => ({ text: t.aname, value: t.acode }))
  149. }),
  150. () => {}
  151. ])
  152. await this.fetchForm()
  153. this.ready = true
  154. this.HIDE_LOADING()
  155. },
  156. // 加载表单数据
  157. async fetchForm() {
  158. if (this.mode === 'create') {
  159. this.origin = await this.getDefaultForm()
  160. } else {
  161. const result = await this.HTTP_GET('learun/adms/EducationalAdministration/StuGraduateStatistic/form', this.id)
  162. this.origin = await this.formatFormData(result)
  163. }
  164. this.current = this.COPY(this.origin)
  165. },
  166. // 点击 「编辑」、「重置」、「保存」、「删除」 按钮
  167. async action(type) {
  168. switch (type) {
  169. case 'edit':
  170. this.edit = true
  171. break
  172. case 'reset':
  173. this.current = this.COPY(this.origin)
  174. this.edit = false
  175. break
  176. case 'save':
  177. const verifyResult = this.verifyForm()
  178. if (verifyResult.length > 0) {
  179. this.CONFIRM('表单验证失败', verifyResult.join('\n'))
  180. return
  181. }
  182. if (!(await this.CONFIRM('提交确认', '确定要提交本页表单内容吗?', true))) {
  183. return
  184. }
  185. this.LOADING('正在提交...')
  186. const postData = await this.getPostData(this.id)
  187. this.HTTP_POST('learun/adms/EducationalAdministration/StuGraduateStatistic/save', postData, '表单提交保存失败').then(success => {
  188. this.HIDE_LOADING()
  189. if (!success) {
  190. return
  191. }
  192. this.EMIT('EducationalAdministrationStuGraduateStatistic-list-change')
  193. this.NAV_BACK()
  194. this.TOAST('提交保存成功')
  195. })
  196. break
  197. case 'delete':
  198. if (!(await this.CONFIRM('删除项目', '确定要删除本项吗?', true))) {
  199. return
  200. }
  201. this.LOADING('提交删除中...')
  202. this.HTTP_POST('learun/adms/EducationalAdministration/StuGraduateStatistic/delete', this.id, '删除失败').then(success => {
  203. this.HIDE_LOADING()
  204. if (!success) {
  205. return
  206. }
  207. this.EMIT('EducationalAdministrationStuGraduateStatistic-list-change')
  208. this.NAV_BACK()
  209. this.this.TOAST('删除成功', 'success')
  210. })
  211. break
  212. default: break
  213. }
  214. },
  215. // 获取表单值
  216. getValue(path) {
  217. return get(this.current, path)
  218. },
  219. // 设置表单值
  220. setValue(path, val) {
  221. set(this.current, path, val)
  222. },
  223. //多条件查询:省改变事件
  224. async EmployerProvinceChange(){
  225. if (this.getValue('StuGraduateStatistic.EmployerProvince') != null && this.getValue('StuGraduateStatistic.EmployerProvince') !=undefined && this.getValue('StuGraduateStatistic.EmployerProvince') != "") {
  226. this.FETCH_DATASOURCE('DIC_CITY').then(result => {
  227. this.dataSource.StuGraduateStatistic.EmployerCity = result.data.filter(t=>t.cparent===this.getValue('StuGraduateStatistic.EmployerProvince') ).map(t => ({ text: t.cname, value: t.ccode }))
  228. })
  229. }else{
  230. this.FETCH_DATASOURCE('DIC_CITY').then(result => {
  231. this.dataSource.StuGraduateStatistic.EmployerCity = result.data.map(t => ({ text: t.cname, value: t.ccode }))
  232. })
  233. }
  234. },
  235. //多条件查询:市改变事件
  236. async EmployerCityChange(){
  237. if (this.getValue('StuGraduateStatistic.EmployerCity') != null && this.getValue('StuGraduateStatistic.EmployerCity')!=undefined && this.getValue('StuGraduateStatistic.EmployerCity')!= "") {
  238. this.FETCH_DATASOURCE('DIC_AREA').then(result => {
  239. this.dataSource.StuGraduateStatistic.EmployerCountry = result.data.filter(t=>t.aparent===this.getValue('StuGraduateStatistic.EmployerCity')).map(t => ({ text: t.aname, value: t.acode }))
  240. })
  241. }else{
  242. this.FETCH_DATASOURCE('DIC_AREA').then(result => {
  243. this.dataSource.StuGraduateStatistic.EmployerCountry = result.data.map(t => ({ text: t.aname, value: t.acode }))
  244. })
  245. }
  246. },
  247. }
  248. }
  249. </script>