Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.
 
 
 
 
 
 

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