| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379 |
- const app = getApp()
- import { chineseToPinYin } from "../../utils/china"
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- user: {},
- workTypeList: [], // 所有 工种
- array: [], // 所有 工种文字
- index: 0, // 当前 工种
- YhdwList: [], // 养护单位 列表
- array1: [], // 养护单位 名字列表
- index1: 0, //当前养护单位
- checked1: false, // 选择男
- checked2: false, // 选择女
- checked3: false,
- checked4: true, // 默认选择 不开启账号
- isWorkCode: null, // 是否存在 账号
- flag: true,
- },
- // 更换图片
- toggleImg() {
- let that = this
- let url = app.globalData.httpsUrlServer + "/file/uploadUserFile"
- wx.chooseImage({
- success(res) {
- const tempFilePaths = res.tempFilePaths
- ////console.log(tempFilePaths)
- that.data.user.fPhoto = tempFilePaths[0]
- that.setData({
- user: that.data.user,
- })
- wx.uploadFile({
- url: url,
- filePath: tempFilePaths[0],
- name: "file",
- formData: {
- user: "test",
- },
- success(res) {
- const data = res.data
- that.data.user.fPhoto = JSON.parse(data).data[0].fFileurl
- that.setData({
- user: that.data.user,
- })
- },
- })
- },
- })
- },
- // 修改姓名
- EditfRealname(val) {
- this.data.user.fRealname = val.detail.value
- this.setData({
- user: this.data.user,
- })
- ////console.log("当前", this.data.user)
- },
- // 修改性别
- toggleSex(val) {
- ////console.log(val)
- this.data.user.fSex = val.detail.value
- this.setData({
- user: this.data.user,
- })
- },
- // 修改手机号
- EditfPhone(val) {
- this.data.user.fPhone = val.detail.value
- this.setData({
- user: this.data.user,
- })
- ////console.log("当前", this.data.user)
- },
- // 修改电话
- EditfLinkphone(val) {
- this.data.user.fLinkphone = val.detail.value
- this.setData({
- user: this.data.user,
- })
- ////console.log("当前", this.data.user)
- },
- // 修改身份号
- EditfIdcard(val) {
- this.data.user.fIdcard = val.detail.value
- this.setData({
- user: this.data.user,
- })
- ////console.log("当前", this.data.user)
- },
- // 修改 工种
- bindPickerChange(val) {
- let temp = val.detail.value // 下标
- let temp1 = this.data.array[temp]
- let obj = this.data.workTypeList.find((v, i) => {
- return v.fName == temp1
- })
- this.data.user.fExpand4 = obj.fValuecode
- 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.YhdwList.find((v, i) => {
- // return v.fDeptname == temp1
- // })
- // ////console.log(obj)
- // this.data.user.fYhcompanyid = obj.fYhcompanyid
- this.setData({
- index1: temp,
- // user: this.data.user,
- })
- },
- // 修改职务
- EditfDuty(val) {
- this.data.user.fDuty = val.detail.value
- this.setData({
- user: this.data.user,
- })
- ////console.log("当前", this.data.user)
- },
- // 修改描述
- EditfExpand3(val) {
- this.data.user.fExpand3 = val.detail.value
- this.setData({
- user: this.data.user,
- })
- },
- // 修改 开启账户
- toggleZH(val) {
- if (this.data.user.fRealname == "") {
- return app.toast("请输入姓名")
- }
- ////console.log("val", val)
- if (val.detail.value == "1") {
- this.data.user.isAddUser = 1
- this.data.user.fWorkingcode = chineseToPinYin(this.data.user.fRealname)
- this.setData({
- user: this.data.user,
- flag: false,
- })
- } else {
- this.data.user.isAddUser = null
- this.data.user.fWorkingcode = null
- this.setData({
- user: this.data.user,
- flag: true,
- })
- }
- },
- // 修改用户名
- codeInput(val) {
- this.data.user.fWorkingcode = val.detail.value
- this.setData({
- user: this.data.user,
- })
- },
- // 保存方法
- baocun() {
- if (this.data.user.fRealname == "") {
- return app.toast("职务不能为空")
- }
- if (this.data.user.fDuty == "") {
- return app.toast("职务不能为空")
- }
- if (this.data.user.fPhone == "" || this.data.user.fPhone == null) {
- return app.toast("请填写手机号")
- }
- if (!app.checkPhone(this.data.user.fPhone.trim())) {
- return app.toast("手机号格式错误")
- }
- if (this.data.user.fLinkphone) {
- if (!app.checkTel(this.data.user.fLinkphone.trim())) {
- return app.toast("电话号格式错误")
- }
- }
- if (this.data.user.fIdcard) {
- if (this.data.user.fIdcard.trim().length != 18) {
- return app.toast("身份证格式错误")
- }
- }
- // if (this.data.user.fWorkingcode != null) {
- // if (this.data.user.isAddUser == null) {
- // this.data.user.fWorkingcode = null
- // this.setData({
- // user: this.data.user,
- // })
- // return app.toast("修改用户名前,需开启账号")
- // }
- // }
- this.data.user.fLinkphone == "" ? null : this.data.user.fLinkphone
- this.data.user.fIdcard == "" ? null : this.data.user.fIdcard
- this.data.user.fExpand3 == "" ? null : this.data.user.fExpand3
- this.setData({
- user: this.data.user,
- })
- let that = this
- ////console.log(that.data.user)
- wx.showModal({
- title: "提示",
- content: "确定要修改吗",
- success(res) {
- if (res.confirm) {
- let url =
- app.globalData.httpsUrlServer + "/baseemployeeinfo/saveEmployeeinfo"
- app.postReq(url, that.data.user, (res) => {
- ////console.log("res", res)
- if (res.status == 200) {
- // wx.navigateTo({
- // url: "../parkStaff/parkStaff",
- // })
- 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.onPullDownRefresh("toast")
- }
- },
- })
- } else {
- app.toast("操作失败")
- return
- }
- })
- } else if (res.cancel) {
- ////console.log("用户点击取消")
- }
- },
- })
- },
- // 查看大图
- showImg(val) {
- let url = val.currentTarget.dataset.url
- ////console.log(url)
- wx.previewImage({
- current: url, // 当前显示图片的http链接
- urls: [url],
- })
- },
- // 获得所有工种
- getWorkType() {
- let that = this
- let data = {
- fDictionaryflag: "POSITIONTYPE",
- }
- app.getDictionaries(data, (res) => {
- if (res.status == 200) {
- that.setData({
- workTypeList: res.data,
- })
- ////console.log("所有工种", that.data.workTypeList)
- let arr = that.data.workTypeList.map((item) => {
- return item.fName
- })
- ////console.log(arr)
- that.setData({
- array: arr,
- index: that.data.user.fExpand4 - 1,
- })
- ////console.log("array", that.data.array)
- ////console.log(that.data.user.fExpand4)
- }
- })
- },
- // 获得所有养护单位
- getYhdwList() {
- let that = this
- 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 index = that.data.YhdwList.findIndex((item) => item.fYhcompanyid == this.data.user.fYhcompanyid);
- that.setData({
- // array1: arr,
- index1: index,
- })
- ////console.log("养护单位名字", that.data.array1)
- }
- })
- },
- onLoad: function (options) {
- let obj = JSON.parse(options.info)
- this.setData({
- user: obj,
- })
- if (obj.fSex == "男") {
- this.setData({
- checked1: true,
- })
- } else {
- this.setData({
- checked2: true,
- })
- }
- if (obj.fWorkingcode != null) {
- this.setData({
- isWorkCode: true,
- })
- } else {
- this.setData({
- isWorkCode: false,
- })
- }
- this.getWorkType()
- this.getYhdwList()
- ////console.log("用户数据", this.data.user)
- },
- toast() {
- if (this.data.flag == true) {
- app.toast("请先开启账号")
- }
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {},
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {},
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {},
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {},
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {},
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {},
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {},
- })
|