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.
 
 
 
 
 
 

215 line
6.6 KiB

  1. <template>
  2. <view class="page">
  3. <view v-if="ready">
  4. <l-input
  5. @input="setValue('Sys_SendComplaint.ComplaintCode', $event)"
  6. :value="getValue('Sys_SendComplaint.ComplaintCode')"
  7. disabled="disabled"
  8. title="投诉编号"
  9. />
  10. <l-input
  11. @input="setValue('Sys_SendComplaint.Title', $event)"
  12. :value="getValue('Sys_SendComplaint.Title')"
  13. disabled="disabled"
  14. title="主题"
  15. />
  16. <l-textarea
  17. @input="setValue('Sys_SendComplaint.Contents', $event)"
  18. :value="getValue('Sys_SendComplaint.Contents')"
  19. disabled="disabled"
  20. title="投诉意见"
  21. />
  22. <l-organize-picker
  23. @input="setValue('Sys_SendComplaint.ReceiverId', $event)"
  24. :value="getValue('Sys_SendComplaint.ReceiverId')"
  25. :readonly="!edit"
  26. type="user"
  27. title="接收人"
  28. />
  29. </view>
  30. <view v-if="ready" class="bg-white margin-tb padding" style="padding-top: 0; overflow: hidden;">
  31. <l-button v-if="edit" @click="action('save')" size="lg" color="green" class="block margin-top" block>
  32. 提交保存
  33. </l-button>
  34. <l-button v-if="!edit && mode !== 'create'" @click="action('edit')" size="lg" line="orange" class="block margin-top" block>
  35. 编辑本页
  36. </l-button>
  37. <l-button v-if="edit && mode !== 'create'" @click="action('reset')" size="lg" line="red" class="block margin-top" block>
  38. 取消编辑
  39. </l-button>
  40. </view>
  41. </view>
  42. </template>
  43. <script>
  44. /*
  45. * 版 本 Learun-ADMS V7.0.3 力软敏捷开发框架(http://www.learun.cn)
  46. * Copyright (c) 2013-2020 上海力软信息技术有限公司
  47. * 创建人:超级管理员
  48. * 日 期:2020-10-14 12:15
  49. * 描 述:校长信箱
  50. */
  51. /**
  52. * 本段代码由移动端代码生成器输出,移动端须 2.2.0 版本及以上可以使用
  53. * 请在移动端 /pages.json 中的 pages 字段中添加一条记录:
  54. * { "path": "pages/EducationalAdministration/Sys_SendComplaint/Assign/single", "style": { "navigationBarTitleText": "表单详情页" } }
  55. *
  56. * (navigationBarTitleText 字段为本页面的标题文本,可以修改)
  57. * (必须自行操作该步骤,力软代码生成器不会自动帮您修改 /pages.json 文件)
  58. */
  59. import get from 'lodash/get'
  60. import set from 'lodash/set'
  61. import moment from 'moment'
  62. import customPageMixins from '@/common/custompage.js'
  63. export default {
  64. mixins: [customPageMixins],
  65. data() {
  66. return {
  67. // 页面相关参数
  68. id: null,
  69. assignFlag:null,
  70. mode: null,
  71. edit: null,
  72. ready: false,
  73. // 表单数据
  74. current: {},
  75. origin: {},
  76. // 表单项数据结构
  77. scheme: {
  78. Sys_SendComplaint: {
  79. ComplaintCode: { type: 'text', title: '投诉编号',verify:'NotNull' },
  80. Title: { type: 'text', title: '主题',verify:'NotNull' },
  81. Contents: { type: 'textarea', title: '投诉意见',verify:'NotNull' },
  82. ReceiverId: { type: 'organize', title: '接收人', dataType: 'user',verify:'NotNull' },
  83. },
  84. },
  85. // 数据源
  86. dataSource: {
  87. Sys_SendComplaint: {
  88. },
  89. }
  90. }
  91. },
  92. async onLoad({ type, id ,assignFlag}) {
  93. await this.init(type, id,assignFlag)
  94. },
  95. methods: {
  96. // 页面初始化
  97. async init(type, id,assignFlag) {
  98. this.LOADING('加载数据中...')
  99. this.id = id
  100. this.assignFlag=assignFlag
  101. this.mode = type
  102. this.edit = ['create', 'edit'].includes(this.mode)
  103. // 拉取表单数据,同时拉取所有来自数据源的选单数据
  104. await Promise.all([
  105. () => {}
  106. ])
  107. await this.fetchForm()
  108. this.ready = true
  109. this.HIDE_LOADING()
  110. },
  111. // 加载表单数据
  112. async fetchForm() {
  113. if (this.mode === 'create') {
  114. this.origin = await this.getDefaultForm()
  115. } else {
  116. const result = await this.HTTP_GET('learun/adms/EducationalAdministration/Sys_SendComplaint/form', this.id)
  117. this.origin = await this.formatFormData(result)
  118. }
  119. this.current = this.COPY(this.origin)
  120. },
  121. // 点击 「编辑」、「重置」、「保存」、「删除」 按钮
  122. async action(type) {
  123. switch (type) {
  124. case 'edit':
  125. if(this.assignFlag !== '0'){
  126. this.TOAST("当前投诉意见已指派!");
  127. return
  128. }
  129. this.edit = true
  130. break
  131. case 'reset':
  132. this.current = this.COPY(this.origin)
  133. this.edit = false
  134. break
  135. case 'save':
  136. const verifyResult = this.verifyForm()
  137. if (verifyResult.length > 0) {
  138. this.CONFIRM('表单验证失败', verifyResult.join('\n'))
  139. return
  140. }
  141. if (!(await this.CONFIRM('提交确认', '确定要提交本页表单内容吗?', true))) {
  142. return
  143. }
  144. this.LOADING('正在提交...')
  145. const postData = await this.getPostData(this.id)
  146. const strEntity = JSON.parse(postData.strEntity)
  147. const Receiver = get(this.GET_GLOBAL(this.scheme.Sys_SendComplaint.ReceiverId.dataType), `${strEntity.ReceiverId}.name`, '')
  148. strEntity.Receiver=Receiver
  149. postData.strEntity=JSON.stringify(strEntity)
  150. this.HTTP_POST('learun/adms/EducationalAdministration/Sys_SendComplaint/saveAssign', postData, '表单提交保存失败').then(success => {
  151. this.HIDE_LOADING()
  152. if (!success) {
  153. return
  154. }
  155. this.EMIT('EducationalAdministrationSys_SendComplaintAssign-list-change')
  156. this.NAV_BACK()
  157. this.TOAST('提交保存成功')
  158. })
  159. break
  160. default: break
  161. }
  162. },
  163. // 获取表单值
  164. getValue(path) {
  165. return get(this.current, path)
  166. },
  167. // 设置表单值
  168. setValue(path, val) {
  169. set(this.current, path, val)
  170. } ,
  171. //生成随机数
  172. getCode () {
  173. var a = parseInt(Math.random() * (10000 - 1000 + 1) + 1000);
  174. var now = new Date();
  175. var b = now.getFullYear() + "" + ((now.getMonth() + 1) < 10 ? ("0" + (now.getMonth() + 1)) : (now.getMonth() + 1)) + "" + (now.getDate() < 10 ? ("0" + now.getDate()) : now.getDate()) + "" + (now.getHours() < 10 ? ("0" + now.getHours()) : now.getHours()) + "" + (now.getMinutes() < 10 ? ("0" + now.getMinutes()) : now.getMinutes()) + "" + (now.getSeconds() < 10 ? ("0" + now.getSeconds) : now.getSeconds());
  176. return b + a;
  177. }
  178. }
  179. }
  180. </script>