123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299 |
- 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 {studentTypes} from "../../model/enum";
- Page({
- data: {
- logicData: [
- {dictLabel: '是', dictValue: '1'},
- {dictLabel: '否', dictValue: '0'}
- ],
- studentTypesEnum: studentTypes,
- sexData: [],
- eduExpData: [],
- nationData: [],
- specialtyData: [],
- socialWorkLevelData: [],
- advantageData: [],
- socialWorkYearData: [],
- studentTypeData: [],
- parentIds: '',
- errMsg: '',
- sexIndex: -1,
- eduExpIndex: -1,
- famousSchoolIndex: -1,
- nationIndex: -1,
- specialtyIndex: -1,
- isFullTimeIndex: -1,
- socialWorkLevelIndex: -1,
- ispartyIndex: -1,
- ishonorIndex: -1,
- socialWorkYearIndex: -1,
- gridLeaderIndex: -1,
- buildLeaderIndex: -1,
- unitLeaderIndex: -1,
- welFareIndex: -1,
- formData: {
- teamId: '',
- id: '',
- idCard: '',
- picUrl: '',
- name: '',
- sex: '',
- education: '',
- graduate: '',
- isEmphasis: '',
- nation: '',
- specialtyId: '',
- isFullTime: '',
- jobTime: '',
- socialWorkLevel: '',
- advantage: '',
- isParty: '',
- isReceiveHonor: '',
- code: '',
- perType: -1,
- jobId: -1,
- socialWorkYear: '',
- isGridLeader: '',
- isBuildLeader: '',
- isUnitLeader: '',
- isWelfare: '',
- }
- },
- async onLoad(options) {
- const teamId = options.teamId;
- const eduStuId = options.eduStuId;
- const user = User.getUserInfoByLocal();
- showLoading();
- const [res1, res2, res3, res4, res5, res6, res7, res8] = 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),
- ])
- 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;
- this.setData({
- 'formData.teamId': teamId,
- 'formData.id': eduStuId,
- 'formData.idCard': user.idCard,
- 'formData.picUrl': user.picUrl,
- 'formData.name': user.name,
- 'formData.sex': user.sex,
- 'formData.education': user.education,
- 'formData.graduate': user.graduate,
- 'formData.isEmphasis': user.isEmphasis,
- 'formData.nation': user.nation,
- 'formData.specialtyId': user.specialtyId,
- 'formData.isFullTime': user.isFullTime,
- 'formData.jobTime': user.jobTime,
- 'formData.socialWorkLevel': user.socialWorkLevel,
- 'formData.advantage': user.advantage,
- 'formData.isParty': user.isParty,
- 'formData.isReceiveHonor': user.isReceiveHonor,
- 'formData.code': user.code,
- 'formData.perType': user.perType,
- 'formData.jobId': user.jobId,
- 'formData.socialWorkYear': user.socialWorkYear,
- 'formData.isGridLeader': user.isGridLeader,
- 'formData.isBuildLeader': user.isBuildLeader,
- 'formData.isUnitLeader': user.isUnitLeader,
- 'formData.isWelfare': user.isWelfare,
- 'sexIndex': this.findIndex(sexData, user.sex),
- 'eduExpIndex': this.findIndex(eduExpData, user.education),
- 'famousSchoolIndex': this.findIndex(this.data.logicData, user.isEmphasis),
- 'nationIndex': this.findIndex(nationData, user.nation),
- 'specialtyIndex': this.findIndex(specialtyData, user.specialtyId),
- 'isFullTimeIndex': this.findIndex(this.data.logicData, user.isFullTime),
- 'socialWorkLevelIndex': this.findIndex(socialWorkLevelData, user.socialWorkLevel),
- 'ispartyIndex': this.findIndex(this.data.logicData, user.isParty),
- 'ishonorIndex': this.findIndex(this.data.logicData, user.isReceiveHonor),
- 'socialWorkYearIndex': this.findIndex(socialWorkYearData, user.socialWorkYear),
- 'gridLeaderIndex': this.findIndex(this.data.logicData, user.isGridLeader),
- 'buildLeaderIndex': this.findIndex(this.data.logicData, user.isBuildLeader),
- 'unitLeaderIndex': this.findIndex(this.data.logicData, user.isUnitLeader),
- 'welFareIndex': this.findIndex(this.data.logicData, user.isWelfare),
- 'parentIds': user.parentIds,
- sexData, eduExpData, nationData, specialtyData,
- socialWorkLevelData, advantageData, socialWorkYearData,
- studentTypeData,
- })
- },
- onChange(e) {
- const field = getDataSet(e, "field");
- this.setData({
- [field]: getEventParam(e)
- })
- },
- bindChange(e) {
- const field = getDataSet(e, "field");
- const key = getDataSet(e, "key");
- const arr = getDataSet(e, "arr");
- const value = getEventParam(e, 'value');
- let obj = {};
- if (arr && value) {
- obj = {[key]: this.data[arr][value].dictValue}
- }
- this.setData({
- [field]: value,
- ...obj
- })
- },
- 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
- })
- },
- async changeStuAreaInfo(e) {
- const {perType, code, jobId, errMsg} = getEventParam(e);
- let obj = {}
- if (jobId) {
- obj["formData.jobId"] = jobId;
- }
- this.setData({
- "formData.perType": perType,
- "formData.code": code || '',
- ...obj,
- errMsg
- })
- },
- changeInfo(e) {
- let eventParam = getEventParam(e);
- this.setData({
- ...eventParam
- })
- },
- // 提交
- submit: throttle(async function (e) {
- if (!this.data.formData.picUrl.trim()) {
- toast('请上传头像')
- return;
- }
- if (!this.data.formData.name.trim()) {
- toast('请输入姓名')
- return;
- }
- if (this.data.sexIndex == -1) {
- toast('请选择性别')
- return;
- }
- if (this.data.eduExpIndex == -1) {
- toast('请选择文化程度')
- return;
- }
- if (!this.data.formData.graduate.trim()) {
- toast('请输入毕业院校')
- return;
- }
- if (this.data.famousSchoolIndex == -1) {
- toast('请选择是否211.985')
- return;
- }
- if (this.data.nationIndex == -1) {
- toast('请选择民族')
- return;
- }
- if (this.data.specialtyIndex == -1) {
- toast('请选择专业')
- return;
- }
- if (this.data.isFullTimeIndex == -1) {
- toast('请选择是否全日制')
- return;
- }
- if (!this.data.formData.jobTime.trim()) {
- toast('请选择任职时间')
- return;
- }
- if (this.data.socialWorkLevelIndex == -1) {
- toast('请选择社工证等级')
- return;
- }
- if (!this.data.formData.advantage.trim()) {
- toast('请选择特长优势')
- return;
- }
- if (this.data.ispartyIndex == -1) {
- toast('请选择是否中共党员')
- return;
- }
- if (this.data.ishonorIndex == -1) {
- toast('请选择是否有市级以上荣誉')
- return;
- }
- if (this.data.formData.perType == -1) {
- toast('请选择学员类别')
- return;
- }
- if (!this.data.formData.code.trim()) {
- let errMsg = this.data.errMsg;
- toast(errMsg || '请选择单位所在的行政区域')
- return;
- }
- if (this.data.formData.jobId == -1) {
- toast('请选择现任职务')
- return;
- }
- if (this.data.socialWorkYearIndex == -1) {
- toast('请选择社区工作年限')
- return;
- }
- if (this.data.gridLeaderIndex == -1) {
- toast('请选择是否网格长')
- return;
- }
- if (this.data.buildLeaderIndex == -1) {
- toast('请选择是否楼栋长')
- return;
- }
- if (this.data.unitLeaderIndex == -1) {
- toast('请选择是否单元长')
- return;
- }
- if (this.data.welFareIndex == -1) {
- toast('请选择是否公益岗')
- return;
- }
- showLoading();
- await Api.submitStudentForm(this.data.formData);
- await User.updateUserInfo();
- await User.bindWechat();
- wx.hideLoading();
- toast("提交成功")
- wx.navigateBack();
- }),
- findIndex(arr, value) {
- return arr.findIndex(item => item.dictValue == value);
- },
- });
|