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.
 
 
 
 
 
 

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