123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337 |
- import Api from "../../model/api";
- import User from "../../model/user";
- import {getDataSet, getEventParam, showLoading, throttle, toast} from "../../utils/utils";
- import Config from "../../model/config";
- import Upload from "../../model/upload";
- import {logicStatus, studentTypes} from "../../model/enum";
- Page({
- data: {
- studentTypesEnum: studentTypes,
- logicStateEnum: logicStatus,
- sexData: [],
- eduExpData: [],
- nationData: [],
- specialtyData: [],
- socialWorkLevelData: [],
- advantageData: [],
- socialWorkYearData: [],
- studentTypeData: [],
- jobData: [],
- communityJobData: [],
- otherJobData: [],
- parentIds: '',
- formData: {
- teamId: '',
- id: '',
- idCard: '',
- picUrl: '',
- name: '',
- sex: '',
- education: '',
- graduate: '',
- nation: '',
- jobTime: '',
- socialWorkYear: '',
- advantage: '',
- //是否提任
- isPromote: -1,
- //原任职务
- formerPost: "",
- code: '',
- perType: -1,
- isEmphasis: -1,
- specialtyId: -1,
- isFullTime: -1,
- socialWorkLevel: -1,
- isParty: -1,
- isReceiveHonor: -1,
- jobId: -1,
- isGridLeader: -1,
- isBuildLeader: -1,
- isUnitLeader: -1,
- isWelfare: -1,
- }
- },
- async onLoad(options) {
- const {teamId, eduStuId} = options;
- showLoading();
- const {
- data: user
- } = await Api.getUserInfoByTeam({
- teamId
- });
- const [res1, res2, res3, res4, res5, res6, res7, res8, res9, res10] = await Api.promiseAllSettled([
- Api.getPulishDict(Config.DICT.SEX),
- Api.getPulishDict(Config.DICT.EDU_EXP),
- Api.getPulishDict(Config.DICT.NATION),
- Api.getPulishDict(Config.DICT.SPECIALTY),
- Api.getPulishDict(Config.DICT.SOCIAL_WORK_LEVEL),
- Api.getPulishDict(Config.DICT.ADVANTAGE),
- Api.getPulishDict(Config.DICT.SOCIAL_WORK_YEAR),
- Api.getPulishDict(Config.DICT.STUDENT_TYPE),
- Api.getPulishDict(Config.DICT.COMMUNITY_WORKER_TYPE),
- Api.getPulishDict(Config.DICT.OTHER_WORKER_TYPE),
- ])
- wx.hideLoading()
- const sexData = res1.data;
- const eduExpData = res2.data;
- const nationData = res3.data;
- const specialtyData = res4.data;
- const socialWorkLevelData = res5.data;
- const advantageData = res6.data;
- const socialWorkYearData = res7.data;
- const studentTypeData = res8.data;
- const communityJobData = res9.data;
- const otherJobData = res10.data;
- let arrays;
- if (user.perType == studentTypes.COMMUNITY_WORKER && user.code.startsWith('22')) {
- arrays = user.parentIds.split(",").filter((item, index) => index > 1);
- arrays.push(user.code);
- }else{
- arrays = user.parentIds.split(",").filter((item, index) => index > 0);
- arrays.push(user.regionId);
- }
- let parentIds = arrays.join(",");
- const {
- idCard,
- picUrl,
- name,
- sex,
- education,
- graduate,
- nation,
- jobTime,
- socialWorkYear,
- advantage,
- isPromote,
- formerPost,
- code,
- perType,
- isEmphasis,
- specialtyId,
- isFullTime,
- socialWorkLevel,
- isParty,
- isReceiveHonor,
- jobId,
- isGridLeader,
- isBuildLeader,
- isUnitLeader,
- isWelfare
- } = user;
- this.setData({
- formData: {
- idCard,
- picUrl,
- name,
- sex,
- education,
- graduate,
- nation,
- jobTime,
- socialWorkYear,
- advantage,
- isPromote,
- formerPost,
- code,
- perType,
- isEmphasis,
- specialtyId,
- isFullTime,
- socialWorkLevel,
- isParty,
- isReceiveHonor,
- jobId,
- isGridLeader,
- isBuildLeader,
- isUnitLeader,
- isWelfare,
- teamId,
- id: eduStuId,
- },
- sexData,
- eduExpData,
- nationData,
- specialtyData,
- socialWorkLevelData,
- advantageData,
- socialWorkYearData,
- studentTypeData,
- communityJobData,
- otherJobData,
- parentIds
- })
- },
- onChange(e) {
- const field = getDataSet(e, "field");
- const value = getDataSet(e, "value");
- this.setData({
- [field]: getEventParam(e, value)
- })
- },
- async chooseImg(e) {
- const img = await wx.chooseImage({
- count: 1
- });
- const file = {
- url: img.tempFilePaths[0]
- };
- await Upload.uploadRes(Config.UPLOAD_PATH.AVATER, file);
- this.setData({
- 'formData.picUrl': file.url
- })
- },
- changeInfo(e) {
- let eventParam = getEventParam(e);
- //额外处理一下联动
- if (eventParam['formData.perType'] && eventParam['formData.perType'] != this.data.formData.perType) {
- this.setData({
- 'formData.jobId': -1,
- 'formData.code': '',
- parentIds:'',
- })
- }
- this.setData({
- ...eventParam
- })
- },
- // 提交
- submit: throttle(async function (e) {
- let perType = this.data.formData.perType;
- let isCommunityWorker = perType == studentTypes.COMMUNITY_WORKER;
- if (!this.data.formData.picUrl.trim()) {
- toast('请上传头像')
- return;
- }
- if (!this.data.formData.name.trim()) {
- toast('请输入姓名')
- return;
- }
- if (!this.data.formData.sex.trim()) {
- toast('请选择性别')
- return;
- }
- if (!this.data.formData.education.trim()) {
- toast('请选择文化程度')
- return;
- }
- if (!this.data.formData.graduate.trim()) {
- toast('请输入毕业院校')
- return;
- }
- if (this.data.formData.isEmphasis == -1) {
- toast('请选择是否211、985')
- return;
- }
- if (!this.data.formData.nation.trim()) {
- toast('请选择民族')
- return;
- }
- if (this.data.formData.specialtyId == -1) {
- toast('请选择专业')
- return;
- }
- if (this.data.formData.isFullTime == -1) {
- toast('请选择是否全日制')
- return;
- }
- if (!this.data.formData.jobTime.trim()) {
- toast('请选择任职时间')
- return;
- }
- if (!this.data.formData.advantage.trim()) {
- toast('请选择特长优势')
- return;
- }
- if (this.data.formData.isParty == -1) {
- toast('请选择是否中共党员')
- return;
- }
- if (this.data.formData.isReceiveHonor == -1) {
- toast('请选择是否有区级以上荣誉')
- return;
- }
- if (this.data.formData.perType == -1) {
- toast('请选择学员类别')
- return;
- }
- //社区工作者相关内容 start
- if (isCommunityWorker && this.data.formData.socialWorkLevel == -1) {
- toast('请选择社工证等级')
- return;
- }
- if (isCommunityWorker && !this.data.formData.socialWorkYear.trim()) {
- toast('请选择社区工作年限')
- return;
- }
- if (isCommunityWorker && (this.data.formData.isPromote == -1 || this.data.formData.isPromote == null)) {
- toast('请选择是否在本年度提任社区书记')
- return;
- }
- if (isCommunityWorker && this.data.formData.isPromote == logicStatus.YES &&
- (this.data.formData.isPromote == null || !this.data.formData.formerPost.trim())) {
- toast('请输入原职务')
- return;
- }
- if (!this.data.formData.code || !this.data.formData.code.trim()) {
- wx.showModal({
- title: "单位所在的行政区域提示",
- content: "吉林省社区工作者必须选择到社区一级,非吉林省社区工作者必须选择到市一级!",
- showCancel: false
- })
- return;
- }
- if (this.data.formData.jobId == -1) {
- toast('请选择现任职务')
- return;
- }
- if (this.data.formData.isGridLeader == -1) {
- toast('请选择是否网格长')
- return;
- }
- if (this.data.formData.isBuildLeader == -1) {
- toast('请选择是否楼栋长')
- return;
- }
- if (this.data.formData.isUnitLeader == -1) {
- toast('请选择是否单元长')
- return;
- }
- if (this.data.formData.isWelfare == -1) {
- toast('请选择是否公益岗')
- return;
- }
- if (!isCommunityWorker) {
- //如果是非社区工作者 将社区工作者相关字段置空
- this.data.formData.socialWorkLevel = '';
- this.data.formData.socialWorkYear = '';
- this.data.formData.isPromote = '';
- this.data.formData.formerPost = '';
- }
- if (this.data.formData.isPromote == logicStatus.NO) {
- this.data.formData.formerPost = '';
- }
- console.log(this.data.formData);
- showLoading();
- await Api.submitStudentForm(this.data.formData);
- // await User.updateUserInfo();
- await User.bindWechat();
- wx.hideLoading();
- toast("提交成功", "success");
- setTimeout(() => {
- wx.navigateBack();
- }, 300);
- }),
- });
|