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
12 KiB

  1. <template>
  2. <view class="page">
  3. <view v-if="ready">
  4. <l-select
  5. @input="setValue('StuLeaveManagement.CheckStatus', $event)"
  6. :value="getValue('StuLeaveManagement.CheckStatus')"
  7. :range="dataSource.StuLeaveManagement.CheckStatus"
  8. title="审核状态"
  9. :disabled="!edit"
  10. required
  11. />
  12. <l-textarea
  13. @input="setValue('StuLeaveManagement.CheckRemark', $event)"
  14. :value="getValue('StuLeaveManagement.CheckRemark')"
  15. title="审核备注"
  16. :readonly="!edit"
  17. />
  18. <l-input
  19. @input="setValue('StuLeaveManagement.CheckTime', $event)"
  20. :value="getValue('StuLeaveManagement.CheckTime')"
  21. title="审核时间"
  22. v-if="!edit"
  23. :disabled="!edit"
  24. />
  25. <l-select
  26. @input="setValue('StuLeaveManagement.CheckUserNo', $event)"
  27. :value="getValue('StuLeaveManagement.CheckUserNo')"
  28. :range="dataSource.StuLeaveManagement.CheckUserNo"
  29. title="审核人"
  30. v-if="!edit"
  31. :disabled="!edit"
  32. />
  33. <l-select
  34. @input="setValue('StuLeaveManagement.LeaveType', $event)"
  35. :value="getValue('StuLeaveManagement.LeaveType')"
  36. :range="dataSource.StuLeaveManagement.LeaveType"
  37. title="请假类型"
  38. required
  39. disabled
  40. />
  41. <l-datetime-picker
  42. @input="setValue('StuLeaveManagement.StartTime', $event)"
  43. :value="getValue('StuLeaveManagement.StartTime')"
  44. title="开始时间"
  45. required
  46. disabled
  47. />
  48. <l-datetime-picker
  49. @input="setValue('StuLeaveManagement.EndTime', $event)"
  50. :value="getValue('StuLeaveManagement.EndTime')"
  51. title="结束时间"
  52. required
  53. disabled
  54. />
  55. <l-input
  56. @input="setValue('StuLeaveManagement.LeaveDay', $event)"
  57. :value="getValue( String('StuLeaveManagement.LeaveDay'))"
  58. type="number"
  59. title="请假天数"
  60. disabled
  61. />
  62. <l-textarea
  63. @input="setValue('StuLeaveManagement.LeaveReason', $event)"
  64. :value="getValue('StuLeaveManagement.LeaveReason')"
  65. title="请假事由"
  66. readonly
  67. />
  68. <l-input
  69. @input="setValue('StuLeaveManagement.CreateUserNo', $event)"
  70. :value="getValue('StuLeaveManagement.CreateUserNo')"
  71. :readonly="!edit"
  72. title="学号"
  73. disabled
  74. v-if="!edit"
  75. />
  76. <l-input
  77. @input="setValue('StuLeaveManagement.CreateUserName', $event)"
  78. :value="getValue('StuLeaveManagement.CreateUserName')"
  79. title="姓名"
  80. disabled
  81. v-if="!edit"
  82. />
  83. <l-input
  84. @input="setValue('StuLeaveManagement.CreateTime', $event)"
  85. :value="getValue('StuLeaveManagement.CreateTime')"
  86. title="申请时间"
  87. disabled
  88. v-if="!edit"
  89. />
  90. <l-select
  91. @input="setValue('StuLeaveManagement.ClassNo', $event)"
  92. :value="getValue('StuLeaveManagement.ClassNo')"
  93. :range="dataSource.StuLeaveManagement.ClassNo"
  94. title="班级"
  95. disabled
  96. v-if="!edit"
  97. />
  98. <l-select
  99. @input="setValue('StuLeaveManagement.DeptNo', $event)"
  100. :value="getValue('StuLeaveManagement.DeptNo')"
  101. :range="dataSource.StuLeaveManagement.DeptNo"
  102. title="系部"
  103. disabled
  104. v-if="!edit"
  105. />
  106. <l-select
  107. @input="setValue('StuLeaveManagement.MajorNo', $event)"
  108. :value="getValue('StuLeaveManagement.MajorNo')"
  109. :range="dataSource.StuLeaveManagement.MajorNo"
  110. title="专业"
  111. disabled
  112. v-if="!edit"
  113. />
  114. <l-select
  115. @input="setValue('StuLeaveManagement.ClassDiredctorNo', $event)"
  116. :value="getValue('StuLeaveManagement.ClassDiredctorNo')"
  117. :range="dataSource.StuLeaveManagement.ClassDiredctorNo"
  118. title="班主任"
  119. disabled
  120. v-if="!edit"
  121. />
  122. <l-input
  123. :value="displayListItem(getValue('StuLeaveManagement.ClassTutorNo'),'ClassTutorNo')"
  124. readonly
  125. title="辅导员"
  126. disabled
  127. v-if="!edit"
  128. />
  129. </view>
  130. <view v-if="ready&&(origin.StuLeaveManagement.CheckStatus=='0'||edit)" class="bg-white margin-tb padding" style="padding-top: 0; overflow: hidden;">
  131. <l-button v-if="edit" @click="action('save')" size="lg" color="green" class="block margin-top" block>
  132. 保存草稿
  133. </l-button>
  134. <l-button v-if="!edit && mode !== 'create'" @click="action('edit')" size="lg" line="orange" class="block margin-top" block>
  135. 编辑本页
  136. </l-button>
  137. <l-button v-if="edit && mode !== 'create'" @click="action('reset')" size="lg" line="red" class="block margin-top" block>
  138. 取消编辑
  139. </l-button>
  140. <l-button v-if="!edit && mode !== 'create'" @click="action('delete')" size="lg" line="red" class="block margin-top" block>
  141. 删除
  142. </l-button>
  143. </view>
  144. </view>
  145. </template>
  146. <script>
  147. /*
  148. * 版 本 Learun-ADMS V7.0.3 力软敏捷开发框架(http://www.learun.cn)
  149. * Copyright (c) 2013-2021 上海力软信息技术有限公司
  150. * 创建人:超级管理员
  151. * 日 期:2021-02-21 10:07
  152. * 描 述:会议管理
  153. */
  154. /**
  155. * 本段代码由移动端代码生成器输出,移动端须 2.2.0 版本及以上可以使用
  156. * 请在移动端 /pages.json 中的 pages 字段中添加一条记录:
  157. * { "path": "pages/PersonnelManagement/StuLeaveManagement/single", "style": { "navigationBarTitleText": "表单详情页" } }
  158. *
  159. * (navigationBarTitleText 字段为本页面的标题文本,可以修改)
  160. * (必须自行操作该步骤,力软代码生成器不会自动帮您修改 /pages.json 文件)
  161. */
  162. import get from 'lodash/get'
  163. import set from 'lodash/set'
  164. import moment from 'moment'
  165. import customPageMixins from '@/common/custompage.js'
  166. export default {
  167. mixins: [customPageMixins],
  168. data() {
  169. return {
  170. // 页面相关参数
  171. id: null,
  172. mode: null,
  173. edit: null,
  174. ready: false,
  175. // 表单数据
  176. current: {},
  177. origin: {},
  178. // 表单项数据结构
  179. scheme: {
  180. StuLeaveManagement: {
  181. CheckStatus: { type: 'select', title: '审核状态', dataSource: '0',verify:"NotNull" },
  182. CheckRemark: { type: 'texteditor', title: '审核备注', },
  183. CheckTime:{ type: 'text', title: '审核人' },
  184. CheckUserNo: { type: 'select', title: '审核人',dataSource: '1' },
  185. LeaveType: { type: 'select', title: '请假类型', dataSource: '0' },
  186. StartTime: { type: 'datetime', title: '开始时间', dateformat: '0' },
  187. EndTime: { type: 'datetime', title: '结束时间', dateformat: '0' },
  188. LeaveDay: { type: 'number', title: '请假天数',verify:"NumOrNull" },
  189. LeaveReason: { type: 'texteditor', title: '请假事由' },
  190. CreateUserNo: { type: 'text', title: '学号' },
  191. CreateUserName: { type: 'text', title: '姓名' },
  192. CreateTime: { type: 'text', title: '申请时间' },
  193. ClassNo: { type: 'select', title: '班级', dataSource: '1', dataSourceId: 'bjsj,classname,classno' },
  194. DeptNo: { type: 'select', title: '系部', dataSource: '1', },
  195. MajorNo: { type: 'select', title: '专业', dataSource: '1', },
  196. ClassDiredctorNo: { type: 'select', title: '班主任',dataSource: '1', },
  197. ClassTutorNo: { type: 'text', title: '辅导员',dataSource: '1', },
  198. },
  199. },
  200. // 数据源
  201. dataSource: {
  202. StuLeaveManagement:{
  203. ClassNo:[],
  204. DeptNo:[],
  205. MajorNo:[],
  206. ClassTutorNo:[],
  207. ClassDiredctorNo:[],
  208. CheckUserNo:[],
  209. LeaveType: Object.values(this.GET_GLOBAL('dataDictionary').LeaveType).map(t => ({ value: t.value, text: t.text })),
  210. CheckStatus: Object.values(this.GET_GLOBAL('dataDictionary').LeaveCheck).map(t => ({ value: t.value, text: t.text }))
  211. }
  212. }
  213. }
  214. },
  215. async onLoad({ type, id }) {
  216. await this.init(type, id)
  217. },
  218. methods: {
  219. // 页面初始化
  220. async init(type, id) {
  221. this.LOADING('加载数据中...')
  222. this.id = id
  223. this.mode = type
  224. this.edit = ['create', 'edit'].includes(this.mode)
  225. // 拉取表单数据,同时拉取所有来自数据源的选单数据
  226. await Promise.all([
  227. this.FETCH_DATASOURCE('bjsj').then(result => {
  228. console.log(result)
  229. this.dataSource.StuLeaveManagement.ClassNo = result.data.sort((a,b)=>{return b.classno-a.classno}).map(t => ({ text: t.classname, value: t.classno }))
  230. }),
  231. this.FETCH_DATASOURCE('EmpInfo').then(result => {
  232. this.dataSource.StuLeaveManagement.ClassDiredctorNo = result.data.sort((a,b)=>{return b.classno-a.classno}).map(t => ({ text: t.empname, value: t.empno }));
  233. }),
  234. this.FETCH_DATASOURCE('EmpInfo').then(result => {
  235. this.dataSource.StuLeaveManagement.ClassTutorNo = result.data.sort((a,b)=>{return b.classno-a.classno}).map(t => ({ text: t.empname, value: t.empno }));
  236. }),
  237. this.FETCH_DATASOURCE('EmpInfo').then(result => {
  238. this.dataSource.StuLeaveManagement.CheckUserNo = result.data.sort((a,b)=>{return b.classno-a.classno}).map(t => ({ text: t.empname, value: t.empno }));
  239. }),
  240. this.FETCH_DATASOURCE('CdDeptInfo').then(result => {
  241. this.dataSource.StuLeaveManagement.DeptNo = result.data.map(t => ({ text: t.deptname, value: t.deptno }));
  242. }),
  243. this.FETCH_DATASOURCE('CdMajorInfo').then(result => {
  244. console.log()
  245. this.dataSource.StuLeaveManagement.MajorNo = result.data.map(t => ({ text: t.majorname, value: t.majorno }));
  246. }),
  247. ])
  248. await this.fetchForm()
  249. this.ready = true
  250. this.HIDE_LOADING()
  251. },
  252. // 加载表单数据
  253. async fetchForm() {
  254. if (this.mode === 'create') {
  255. this.origin = await this.getDefaultForm()
  256. } else {
  257. const result = await this.HTTP_GET('/Learun/adms/EducationalAdministration/StuLeaveManagement/form', this.id)
  258. this.origin = await this.formatFormData(result)
  259. // console.log(this.origin,this.origin.prototype)
  260. }
  261. this.current = this.COPY(this.origin)
  262. },
  263. // 点击 「编辑」、「重置」、「保存」、「删除」 按钮
  264. async action(type) {
  265. switch (type) {
  266. case 'edit':
  267. this.edit = true
  268. break
  269. case 'reset':
  270. this.current = this.COPY(this.origin)
  271. this.edit = false
  272. break
  273. case 'save':
  274. // console.log(this.current)
  275. const verifyResult = this.verifyForm()
  276. if (verifyResult.length > 0) {
  277. this.CONFIRM('表单验证失败', verifyResult.join('\n'))
  278. return
  279. }
  280. if (!(await this.CONFIRM('提交确认', '确定要提交本页表单内容吗?', true))) {
  281. return
  282. }
  283. this.LOADING('正在提交...')
  284. const postData = await this.getPostData(this.id)
  285. this.HTTP_POST('/Learun/adms/EducationalAdministration/StuLeaveManagement/savecheck', postData, '表单提交保存失败').then(success => {
  286. this.HIDE_LOADING()
  287. if (!success) {
  288. return
  289. }
  290. this.EMIT('EducationalAdministrationStuLeaveManagementCheck-list-change')
  291. // this.NAV_BACK()
  292. uni.navigateBack({})
  293. this.TOAST('提交保存成功')
  294. })
  295. break
  296. case 'delete':
  297. if (!(await this.CONFIRM('删除项目', '确定要删除本项吗?', true))) {
  298. return
  299. }
  300. this.LOADING('提交删除中...')
  301. this.HTTP_POST('/Learun/adms/EducationalAdministration/StuLeaveManagement/delete', this.id, '删除失败').then(success => {
  302. this.HIDE_LOADING()
  303. if (!success) {
  304. return
  305. }
  306. this.EMIT('EducationalAdministrationStuLeaveManagementCheck-list-change')
  307. this.NAV_BACK()
  308. this.this.TOAST('删除成功', 'success')
  309. })
  310. break
  311. default: break
  312. }
  313. },
  314. // 获取表单值
  315. getValue(path) {
  316. return get(this.current, path)
  317. },
  318. // 设置表单值
  319. setValue(path, val) {
  320. set(this.current, path, val)
  321. },
  322. displayListItem(value, field) {
  323. const fieldItem = this.scheme[field];
  324. if (!value || value.split(",").length <= 0) {
  325. return "";
  326. }
  327. const checkboxItems = value.split(",");
  328. return this.dataSource.StuLeaveManagement[field]
  329. .filter((t) => checkboxItems.includes(t.value))
  330. .map((t) => t.text)
  331. .join(",");
  332. },
  333. }
  334. }
  335. </script>