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.
 
 
 
 
 
 

199 lines
6.2 KiB

  1. <template>
  2. <view class="page">
  3. <view v-if="ready">
  4. <l-input
  5. @input="setValue('Sys_ReceiveFile.Sender', $event)"
  6. :value="getValue('Sys_ReceiveFile.Sender')"
  7. :disabled="!edit"
  8. title="发送人"
  9. />
  10. <l-input
  11. @input="setValue('Sys_ReceiveFile.Title', $event)"
  12. :value="getValue('Sys_ReceiveFile.Title')"
  13. :disabled="!edit"
  14. title="主题"
  15. />
  16. <l-date-picker
  17. @input="setValue('Sys_ReceiveFile.SendTime', $event)"
  18. :value="getValue('Sys_ReceiveFile.SendTime')"
  19. :disabled="!edit"
  20. title="发送时间"
  21. />
  22. <l-select
  23. @input="setValue('Sys_ReceiveFile.SendType', $event)"
  24. :value="getValue('Sys_ReceiveFile.SendType')"
  25. :disabled="!edit"
  26. :range="dataSource.Sys_ReceiveFile.SendType"
  27. title="接收对象"
  28. />
  29. <l-textarea
  30. @input="setValue('Sys_ReceiveFile.Contents', $event)"
  31. :value="getValue('Sys_ReceiveFile.Contents')"
  32. :disabled="!edit"
  33. readonly="readonly"
  34. :range="dataSource.Sys_ReceiveFile.Contents"
  35. title="内容"
  36. />
  37. </view
  38. >
  39. </view
  40. >
  41. </template>
  42. <script>
  43. /*
  44. * 版 本 Learun-ADMS V7.0.3 力软敏捷开发框架(http://www.learun.cn)
  45. * Copyright (c) 2013-2020 上海力软信息技术有限公司
  46. * 创建人:超级管理员
  47. * 日 期:2020-10-19 09:24
  48. * 描 述:公文查看
  49. */
  50. /**
  51. * 本段代码由移动端代码生成器输出,移动端须 2.2.0 版本及以上可以使用
  52. * 请在移动端 /pages.json 中的 pages 字段中添加一条记录:
  53. * { "path": "pages/EducationalAdministration/Sys_ReceiveFile/single", "style": { "navigationBarTitleText": "表单详情页" } }
  54. *
  55. * (navigationBarTitleText 字段为本页面的标题文本,可以修改)
  56. * (必须自行操作该步骤,力软代码生成器不会自动帮您修改 /pages.json 文件)
  57. */
  58. import get from "lodash/get";
  59. import set from "lodash/set";
  60. import moment from "moment";
  61. import customPageMixins from "@/common/custompage.js";
  62. export default {
  63. mixins: [customPageMixins],
  64. data() {
  65. return {
  66. // 页面相关参数
  67. id: null,
  68. mode: null,
  69. edit: null,
  70. ready: false, // 表单数据
  71. current: {},
  72. origin: {}, // 表单项数据结构
  73. scheme: {
  74. Sys_ReceiveFile: {
  75. Sender: { type: "text", title: "发送人" },
  76. Title: { type: "text", title: "主题" },
  77. SendTime: { type: "datetime", title: "发送时间", dateformat: "0" },
  78. SendType: {
  79. type: "select",
  80. title: "接收对象",
  81. itemCode: "FileSendType",
  82. dataSource: "0",
  83. },
  84. Contents: { type: "textarea", title: "内容" },
  85. ReadFlag: { type: "select", title: "状态", dataSource: "0" },
  86. ReadTime: { type: "datetime", title: "查阅时间", dateformat: "0" },
  87. },
  88. }, // 数据源
  89. dataSource: {
  90. Sys_ReceiveFile: {
  91. SendType: Object.values(
  92. this.GET_GLOBAL("dataDictionary").FileSendType
  93. ).map((t) => ({ value: t.value, text: t.text })),
  94. ReadFlag: [],
  95. },
  96. },
  97. };
  98. },
  99. async onLoad({ type, id }) {
  100. await this.init(type, id);
  101. },
  102. methods: {
  103. // 页面初始化
  104. async init(type, id) {
  105. this.LOADING("加载数据中...");
  106. this.id = id;
  107. this.mode = type;
  108. this.edit = ["create", "edit"].includes(this.mode); // 拉取表单数据,同时拉取所有来自数据源的选单数据
  109. await Promise.all([() => {}]);
  110. await this.fetchForm();
  111. this.ready = true;
  112. this.HIDE_LOADING();
  113. }, // 加载表单数据
  114. async fetchForm() {
  115. if (this.mode === "create") {
  116. this.origin = await this.getDefaultForm();
  117. } else {
  118. const result = await this.HTTP_GET(
  119. "learun/adms/EducationalAdministration/Sys_ReceiveFile/form",
  120. this.id
  121. );
  122. this.origin = await this.formatFormData(result);
  123. }
  124. this.current = this.COPY(this.origin);
  125. }, // 点击 「编辑」、「重置」、「保存」、「删除」 按钮
  126. async action(type) {
  127. switch (type) {
  128. case "edit":
  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 (
  142. !(await this.CONFIRM(
  143. "提交确认",
  144. "确定要提交本页表单内容吗?",
  145. true
  146. ))
  147. ) {
  148. return;
  149. }
  150. this.LOADING("正在提交...");
  151. const postData = await this.getPostData(this.id);
  152. adms(
  153. "learun/adms/EducationalAdministration/Sys_ReceiveFile/save",
  154. postData,
  155. "表单提交保存失败"
  156. ).then((success) => {
  157. this.HIDE_LOADING();
  158. if (!success) {
  159. return;
  160. }
  161. this.EMIT("EducationalAdministrationSys_ReceiveFile-list-change");
  162. this.NAV_BACK();
  163. this.TOAST("提交保存成功");
  164. });
  165. break;
  166. case "delete":
  167. if (!(await this.CONFIRM("删除项目", "确定要删除本项吗?", true))) {
  168. return;
  169. }
  170. this.LOADING("提交删除中...");
  171. this.HTTP_POST(
  172. "learun/adms/EducationalAdministration/Sys_ReceiveFile/delete",
  173. this.id,
  174. "删除失败"
  175. ).then((success) => {
  176. this.HIDE_LOADING();
  177. if (!success) {
  178. return;
  179. }
  180. this.EMIT("EducationalAdministrationSys_ReceiveFile-list-change");
  181. this.NAV_BACK();
  182. this.this.TOAST("删除成功", "success");
  183. });
  184. break;
  185. default:
  186. break;
  187. }
  188. }, // 获取表单值
  189. getValue(path) {
  190. return get(this.current, path);
  191. }, // 设置表单值
  192. setValue(path, val) {
  193. set(this.current, path, val);
  194. },
  195. },
  196. };
  197. </script>