const app = getApp() import { chineseToPinYin } from "../../utils/china" Page({ /** * 页面的初始数据 */ data: { user: {}, bmList: [], // 所有部门 array: [], // 所有部门 名字 index: null, // 当前 部门 jsList: [], // 所有角色 array1: [], // 所有角色 名字 index1: null, // 当前 角色 checked1: false, // 选择男 checked2: false, // 选择女 checked3: false, checked4: true, // 默认选择 不开启账号 isWorkCode: null, // 是否存在 账号 flag: true, }, // 修改姓名 EditfRealname(val) { this.data.user.fUsername = val.detail.value this.setData({ user: this.data.user, }) }, // 修改性别 toggleSex(val) { this.data.user.fSexflag = val.detail.value this.setData({ user: this.data.user, }) }, // 修改手机号 EditfPhone(val) { this.data.user.fMobile = val.detail.value this.setData({ user: this.data.user, }) }, // 修改电话 EditfLinkphone(val) { this.data.user.fTelephone = val.detail.value this.setData({ user: this.data.user, }) }, // 修改 部门 bindPickerChange(val) { let temp = val.detail.value // 下标 let temp1 = this.data.array[temp] let obj = this.data.bmList.find((v, i) => { return v.fDeptname == temp1 }) ////console.log(obj) this.data.user.deptName = obj.fDeptname this.data.user.fDeptid = obj.fDeptid this.setData({ index: temp, user: this.data.user, }) }, // 修改养护单位 bindPickerChange1(val) { let temp = val.detail.value let temp1 = this.data.array1[temp] let obj = this.data.jsList.find((v, i) => { return v.fRemark == temp1 }) ////console.log(obj) this.data.user.fRemark = obj.fRemark this.data.user.fRoleid = obj.fRoleid this.setData({ index1: temp, user: this.data.user, }) }, // 保存方法 baocun() { // 姓名不能为空 if (this.data.user.fUsername == "" || this.data.user == null) { return app.toast("姓名不能为空") } // 手机号不能为空 if (this.data.user.fMobile == "" || this.data.user.fMobile == null) { return app.toast("请填写手机号") } // 手机号格式判断 if (!app.checkPhone(this.data.user.fMobile.trim())) { return app.toast("手机号格式错误") } // 没电话号 变成null this.data.user.fTelephone == "" ? null : this.data.user.fTelephone // 有电话 验证格式 if (this.data.user.fTelephone) { if (!app.checkTel(this.data.user.fTelephone.trim())) { return app.toast("电话号格式错误") } } this.data.user.roleList = [] this.setData({ user: this.data.user, }) ////console.log(this.data.user) let that = this wx.showModal({ title: "提示", content: "确定要修改吗", success(res) { if (res.confirm) { let url = app.globalData.httpsUrlServer + "/sysuseraccount/saveUserAccount" app.postReq(url, that.data.user, (res) => { ////console.log("res", res) if (res.status == 200) { let pages = getCurrentPages() //页面栈 ////console.log(pages) let beforePage = pages[2] ////console.log(beforePage.route) wx.navigateBack({ url: "/" + beforePage.route, success: function () { if ( beforePage.route == "packagePersonnel/pages/parkStaff/parkStaff" ) { ////console.log(1111111) beforePage.onShow() } }, }) } else { app.toast("操作失败") return } }) } else if (res.cancel) { ////console.log("用户点击取消") } }, }) }, // 获得所有 部门 getbmList() { var that = this let url = app.globalData.httpsUrlServer + "/sysdepartment/selectDepartmentByList" app.postReq(url, {}, (res) => { ////console.log(res) if (res.status == 200) { that.setData({ bmList: res.data, }) let arr = that.data.bmList.map((v) => { return v.fDeptname }) this.setData({ array: arr, }) let nums = that.data.array.findIndex((v, i) => { return v == that.data.user.deptName }) that.setData({ index: nums, }) } }) }, // 获得所有 角色 getJSlist() { let that = this let url = app.globalData.httpsUrlServer + "/sysroleinfo/selectRoleInfoList" let data = {} app.postReq(url, data, (res) => { if (res.status == 200) { that.setData({ jsList: res.data, }) let arr = that.data.jsList.map((v) => { return v.fRemark }) that.setData({ array1: arr, }) let nums = that.data.array1.findIndex((v, i) => { return v == this.data.user.fRemark }) ////console.log(that.data.array1, this.data.user) this.setData({ index1: nums, }) ////console.log("jslist", that.data.jsList) } }) // let url = // app.globalData.httpsUrlServer + "/tbaseyhcompany/selectYhCompanyList" // app.getReq(url, (res) => { // if (res.status == 200) { // that.setData({ // YhdwList: res.data, // }) // ////console.log("养护单位", that.data.YhdwList) // let arr = that.data.YhdwList.map((item) => { // return item.fDeptname // }) // that.setData({ // array1: arr, // index1: this.data.user.fYhcompanyid, // }) // ////console.log("养护单位名字", that.data.array1) // } // }) }, onLoad: function (options) { let obj = JSON.parse(options.info) this.setData({ user: obj, }) if (obj.fSexflag == "男") { this.setData({ checked1: true, }) } else { this.setData({ checked2: true, }) } if (obj.fWorkingcode != null) { this.setData({ isWorkCode: true, }) } else { this.setData({ isWorkCode: false, }) } this.getbmList() //获得所有部门 this.getJSlist() ////console.log("用户数据", this.data.user) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () {}, /** * 生命周期函数--监听页面显示 */ onShow: function () {}, /** * 生命周期函数--监听页面隐藏 */ onHide: function () {}, /** * 生命周期函数--监听页面卸载 */ onUnload: function () {}, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () {}, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () {}, /** * 用户点击右上角分享 */ onShareAppMessage: function () {}, })