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.
 
 
 
 
 
 

243 lines
7.2 KiB

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