| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290 |
- 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 () {},
- })
|