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.
 
 
 
 
 
 

260 lines
6.5 KiB

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