Nessuna descrizione

personCenterInfo.js 7.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. const app = getApp()
  2. import { chineseToPinYin } from "../../utils/china"
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. user: {},
  9. bmList: [], // 所有部门
  10. array: [], // 所有部门 名字
  11. index: null, // 当前 部门
  12. jsList: [], // 所有角色
  13. array1: [], // 所有角色 名字
  14. index1: null, // 当前 角色
  15. checked1: false, // 选择男
  16. checked2: false, // 选择女
  17. checked3: false,
  18. checked4: true, // 默认选择 不开启账号
  19. isWorkCode: null, // 是否存在 账号
  20. flag: true,
  21. },
  22. // 修改姓名
  23. EditfRealname(val) {
  24. this.data.user.fUsername = val.detail.value
  25. this.setData({
  26. user: this.data.user,
  27. })
  28. },
  29. // 修改性别
  30. toggleSex(val) {
  31. this.data.user.fSexflag = val.detail.value
  32. this.setData({
  33. user: this.data.user,
  34. })
  35. },
  36. // 修改手机号
  37. EditfPhone(val) {
  38. this.data.user.fMobile = val.detail.value
  39. this.setData({
  40. user: this.data.user,
  41. })
  42. },
  43. // 修改电话
  44. EditfLinkphone(val) {
  45. this.data.user.fTelephone = val.detail.value
  46. this.setData({
  47. user: this.data.user,
  48. })
  49. },
  50. // 修改 部门
  51. bindPickerChange(val) {
  52. let temp = val.detail.value // 下标
  53. let temp1 = this.data.array[temp]
  54. let obj = this.data.bmList.find((v, i) => {
  55. return v.fDeptname == temp1
  56. })
  57. ////console.log(obj)
  58. this.data.user.deptName = obj.fDeptname
  59. this.data.user.fDeptid = obj.fDeptid
  60. this.setData({
  61. index: temp,
  62. user: this.data.user,
  63. })
  64. },
  65. // 修改养护单位
  66. bindPickerChange1(val) {
  67. let temp = val.detail.value
  68. let temp1 = this.data.array1[temp]
  69. let obj = this.data.jsList.find((v, i) => {
  70. return v.fRemark == temp1
  71. })
  72. ////console.log(obj)
  73. this.data.user.fRemark = obj.fRemark
  74. this.data.user.fRoleid = obj.fRoleid
  75. this.setData({
  76. index1: temp,
  77. user: this.data.user,
  78. })
  79. },
  80. // 保存方法
  81. baocun() {
  82. // 姓名不能为空
  83. if (this.data.user.fUsername == "" || this.data.user == null) {
  84. return app.toast("姓名不能为空")
  85. }
  86. // 手机号不能为空
  87. if (this.data.user.fMobile == "" || this.data.user.fMobile == null) {
  88. return app.toast("请填写手机号")
  89. }
  90. // 手机号格式判断
  91. if (!app.checkPhone(this.data.user.fMobile.trim())) {
  92. return app.toast("手机号格式错误")
  93. }
  94. // 没电话号 变成null
  95. this.data.user.fTelephone == "" ? null : this.data.user.fTelephone
  96. // 有电话 验证格式
  97. if (this.data.user.fTelephone) {
  98. if (!app.checkTel(this.data.user.fTelephone.trim())) {
  99. return app.toast("电话号格式错误")
  100. }
  101. }
  102. this.data.user.roleList = []
  103. this.setData({
  104. user: this.data.user,
  105. })
  106. ////console.log(this.data.user)
  107. let that = this
  108. wx.showModal({
  109. title: "提示",
  110. content: "确定要修改吗",
  111. success(res) {
  112. if (res.confirm) {
  113. let url =
  114. app.globalData.httpsUrlServer + "/sysuseraccount/saveUserAccount"
  115. app.postReq(url, that.data.user, (res) => {
  116. ////console.log("res", res)
  117. if (res.status == 200) {
  118. let pages = getCurrentPages() //页面栈
  119. ////console.log(pages)
  120. let beforePage = pages[2]
  121. ////console.log(beforePage.route)
  122. wx.navigateBack({
  123. url: "/" + beforePage.route,
  124. success: function () {
  125. if (
  126. beforePage.route ==
  127. "packagePersonnel/pages/parkStaff/parkStaff"
  128. ) {
  129. ////console.log(1111111)
  130. beforePage.onShow()
  131. }
  132. },
  133. })
  134. } else {
  135. app.toast("操作失败")
  136. return
  137. }
  138. })
  139. } else if (res.cancel) {
  140. ////console.log("用户点击取消")
  141. }
  142. },
  143. })
  144. },
  145. // 获得所有 部门
  146. getbmList() {
  147. var that = this
  148. let url =
  149. app.globalData.httpsUrlServer + "/sysdepartment/selectDepartmentByList"
  150. app.postReq(url, {}, (res) => {
  151. ////console.log(res)
  152. if (res.status == 200) {
  153. that.setData({
  154. bmList: res.data,
  155. })
  156. let arr = that.data.bmList.map((v) => {
  157. return v.fDeptname
  158. })
  159. this.setData({
  160. array: arr,
  161. })
  162. let nums = that.data.array.findIndex((v, i) => {
  163. return v == that.data.user.deptName
  164. })
  165. that.setData({
  166. index: nums,
  167. })
  168. }
  169. })
  170. },
  171. // 获得所有 角色
  172. getJSlist() {
  173. let that = this
  174. let url = app.globalData.httpsUrlServer + "/sysroleinfo/selectRoleInfoList"
  175. let data = {}
  176. app.postReq(url, data, (res) => {
  177. if (res.status == 200) {
  178. that.setData({
  179. jsList: res.data,
  180. })
  181. let arr = that.data.jsList.map((v) => {
  182. return v.fRemark
  183. })
  184. that.setData({
  185. array1: arr,
  186. })
  187. let nums = that.data.array1.findIndex((v, i) => {
  188. return v == this.data.user.fRemark
  189. })
  190. ////console.log(that.data.array1, this.data.user)
  191. this.setData({
  192. index1: nums,
  193. })
  194. ////console.log("jslist", that.data.jsList)
  195. }
  196. })
  197. // let url =
  198. // app.globalData.httpsUrlServer + "/tbaseyhcompany/selectYhCompanyList"
  199. // app.getReq(url, (res) => {
  200. // if (res.status == 200) {
  201. // that.setData({
  202. // YhdwList: res.data,
  203. // })
  204. // ////console.log("养护单位", that.data.YhdwList)
  205. // let arr = that.data.YhdwList.map((item) => {
  206. // return item.fDeptname
  207. // })
  208. // that.setData({
  209. // array1: arr,
  210. // index1: this.data.user.fYhcompanyid,
  211. // })
  212. // ////console.log("养护单位名字", that.data.array1)
  213. // }
  214. // })
  215. },
  216. onLoad: function (options) {
  217. let obj = JSON.parse(options.info)
  218. this.setData({
  219. user: obj,
  220. })
  221. if (obj.fSexflag == "男") {
  222. this.setData({
  223. checked1: true,
  224. })
  225. } else {
  226. this.setData({
  227. checked2: true,
  228. })
  229. }
  230. if (obj.fWorkingcode != null) {
  231. this.setData({
  232. isWorkCode: true,
  233. })
  234. } else {
  235. this.setData({
  236. isWorkCode: false,
  237. })
  238. }
  239. this.getbmList() //获得所有部门
  240. this.getJSlist()
  241. ////console.log("用户数据", this.data.user)
  242. },
  243. /**
  244. * 生命周期函数--监听页面初次渲染完成
  245. */
  246. onReady: function () {},
  247. /**
  248. * 生命周期函数--监听页面显示
  249. */
  250. onShow: function () {},
  251. /**
  252. * 生命周期函数--监听页面隐藏
  253. */
  254. onHide: function () {},
  255. /**
  256. * 生命周期函数--监听页面卸载
  257. */
  258. onUnload: function () {},
  259. /**
  260. * 页面相关事件处理函数--监听用户下拉动作
  261. */
  262. onPullDownRefresh: function () {},
  263. /**
  264. * 页面上拉触底事件的处理函数
  265. */
  266. onReachBottom: function () {},
  267. /**
  268. * 用户点击右上角分享
  269. */
  270. onShareAppMessage: function () {},
  271. })