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.3 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.   
  88.   
  89. <script>
  90. /*
  91. * 版 本 Learun-ADMS V7.0.3 力软敏捷开发框架(http://www.learun.cn)
  92. * Copyright (c) 2013-2020 上海力软信息技术有限公司
  93. * 创建人:超级管理员
  94. * 日  期:2020-10-19 11:55
  95. * 描  述:个人信息
  96. */
  97. /**
  98. * 本段代码由移动端代码生成器输出,移动端须 2.2.0 版本及以上可以使用
  99. * 请在移动端 /pages.json 中的 pages 字段中添加一条记录:
  100. * { "path": "pages/EducationalAdministration/EmpRegister/single", "style": { "navigationBarTitleText": "表单详情页" } }
  101. *
  102. * (navigationBarTitleText 字段为本页面的标题文本,可以修改)
  103. * (必须自行操作该步骤,力软代码生成器不会自动帮您修改 /pages.json 文件)
  104. */
  105. import get from "lodash/get";
  106. import set from "lodash/set";
  107. import moment from "moment";
  108. import customPageMixins from "@/common/custompage.js";
  109. export default {
  110. mixins: [customPageMixins],
  111. data() {
  112. return {
  113. // 页面相关参数
  114. id: null,
  115. mode: null,
  116. edit: null,
  117. ready: false, // 表单数据
  118. current: {},
  119. origin: {}, // 表单项数据结构
  120. scheme: {
  121. EmpInfo: {
  122. Birthday: { type: "datetime", title: "出生日期", dateformat: "0" },
  123. PartyFaceNo: { type: "select", title: "政治面貌", dataSource: "0" },
  124. NationalityNo: { type: "select", title: "民族", dataSource: "0" },
  125. Photo: { type: "upload", title: "附件上传" },
  126. mobile: { type: "text", title: "电话", verify: "MobileOrNull" },
  127. EMail: { type: "text", title: "邮箱", verify: "EmailOrNull" },
  128. },
  129. }, // 数据源
  130. dataSource: {
  131. EmpInfo: {
  132. PartyFaceNo: [],
  133. NationalityNo: [],
  134. },
  135. },
  136. };
  137. },
  138. async onLoad({ type, id }) {
  139. let userInfo = this.GET_GLOBAL("loginUser");
  140. if(userInfo.Description!="教师"){
  141. this.TOAST('请使用教师账号登录!');
  142. return;
  143. }
  144. await this.init("", userInfo.account);
  145. },
  146. methods: {
  147. // 页面初始化
  148. async init(type, id) {
  149. this.LOADING("加载数据中...");
  150. this.id = id;
  151. this.mode = type;
  152. this.edit = ["create", "edit"].includes(this.mode); // 拉取表单数据,同时拉取所有来自数据源的选单数据
  153. await Promise.all([() => {}]);
  154. await this.fetchForm();
  155. this.ready = true;
  156. this.HIDE_LOADING();
  157. }, // 加载表单数据
  158. async fetchForm() {
  159. if (this.mode === "create") {
  160. this.origin = await this.getDefaultForm();
  161. } else {
  162. const result = await this.HTTP_GET(
  163. "/EducationalAdministration/EmpRegister/formForNo",
  164. this.id
  165. );
  166. this.id=result.EmpInfo.EmpId;
  167. console.log(result);
  168. this.origin = await this.formatFormData(result);
  169. }
  170. this.current = this.COPY(this.origin);
  171. }, // 点击 「编辑」、「重置」、「保存」、「删除」 按钮
  172. async action(type) {
  173. switch (type) {
  174. case "edit":
  175. this.edit = true;
  176. break;
  177. case "reset":
  178. this.current = this.COPY(this.origin);
  179. this.edit = false;
  180. break;
  181. case "save":
  182. const verifyResult = this.verifyForm();
  183. if (verifyResult.length > 0) {
  184. this.CONFIRM("表单验证失败", verifyResult.join("\n"));
  185. return;
  186. }
  187. if (
  188. !(await this.CONFIRM(
  189. "提交确认",
  190. "确定要提交本页表单内容吗?",
  191. true
  192. ))
  193. ) {
  194. return;
  195. }
  196. this.LOADING("正在提交...");
  197. const postData = await this.getPostData(this.id);
  198. this.HTTP_POST(
  199. "/EducationalAdministration/EmpRegister/save",
  200. postData,
  201. "表单提交保存失败"
  202. ).then((success) => {
  203. this.HIDE_LOADING();
  204. if (!success) {
  205. return;
  206. }
  207. this.EMIT("EducationalAdministrationEmpInfo-list-change");
  208. this.NAV_BACK();
  209. this.TOAST("提交保存成功");
  210. });
  211. break;
  212. case "delete":
  213. if (!(await this.CONFIRM("删除项目", "确定要删除本项吗?", true))) {
  214. return;
  215. }
  216. this.LOADING("提交删除中...");
  217. this.HTTP_POST(
  218. "/EducationalAdministration/EmpRegister/delete",
  219. this.id,
  220. "删除失败"
  221. ).then((success) => {
  222. this.HIDE_LOADING();
  223. if (!success) {
  224. return;
  225. }
  226. this.EMIT("EducationalAdministrationEmpInfo-list-change");
  227. this.NAV_BACK();
  228. this.this.TOAST("删除成功", "success");
  229. });
  230. break;
  231. default:
  232. break;
  233. }
  234. }, // 获取表单值
  235. getValue(path) {
  236. return get(this.current, path);
  237. }, // 设置表单值
  238. setValue(path, val) {
  239. set(this.current, path, val);
  240. },
  241. },
  242. };
  243. </script>