Ei kuvausta

personInfo.js 9.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379
  1. const app = getApp()
  2. import { chineseToPinYin } from "../../utils/china"
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. user: {},
  9. workTypeList: [], // 所有 工种
  10. array: [], // 所有 工种文字
  11. index: 0, // 当前 工种
  12. YhdwList: [], // 养护单位 列表
  13. array1: [], // 养护单位 名字列表
  14. index1: 0, //当前养护单位
  15. checked1: false, // 选择男
  16. checked2: false, // 选择女
  17. checked3: false,
  18. checked4: true, // 默认选择 不开启账号
  19. isWorkCode: null, // 是否存在 账号
  20. flag: true,
  21. },
  22. // 更换图片
  23. toggleImg() {
  24. let that = this
  25. let url = app.globalData.httpsUrlServer + "/file/uploadUserFile"
  26. wx.chooseImage({
  27. success(res) {
  28. const tempFilePaths = res.tempFilePaths
  29. ////console.log(tempFilePaths)
  30. that.data.user.fPhoto = tempFilePaths[0]
  31. that.setData({
  32. user: that.data.user,
  33. })
  34. wx.uploadFile({
  35. url: url,
  36. filePath: tempFilePaths[0],
  37. name: "file",
  38. formData: {
  39. user: "test",
  40. },
  41. success(res) {
  42. const data = res.data
  43. that.data.user.fPhoto = JSON.parse(data).data[0].fFileurl
  44. that.setData({
  45. user: that.data.user,
  46. })
  47. },
  48. })
  49. },
  50. })
  51. },
  52. // 修改姓名
  53. EditfRealname(val) {
  54. this.data.user.fRealname = val.detail.value
  55. this.setData({
  56. user: this.data.user,
  57. })
  58. ////console.log("当前", this.data.user)
  59. },
  60. // 修改性别
  61. toggleSex(val) {
  62. ////console.log(val)
  63. this.data.user.fSex = val.detail.value
  64. this.setData({
  65. user: this.data.user,
  66. })
  67. },
  68. // 修改手机号
  69. EditfPhone(val) {
  70. this.data.user.fPhone = val.detail.value
  71. this.setData({
  72. user: this.data.user,
  73. })
  74. ////console.log("当前", this.data.user)
  75. },
  76. // 修改电话
  77. EditfLinkphone(val) {
  78. this.data.user.fLinkphone = val.detail.value
  79. this.setData({
  80. user: this.data.user,
  81. })
  82. ////console.log("当前", this.data.user)
  83. },
  84. // 修改身份号
  85. EditfIdcard(val) {
  86. this.data.user.fIdcard = val.detail.value
  87. this.setData({
  88. user: this.data.user,
  89. })
  90. ////console.log("当前", this.data.user)
  91. },
  92. // 修改 工种
  93. bindPickerChange(val) {
  94. let temp = val.detail.value // 下标
  95. let temp1 = this.data.array[temp]
  96. let obj = this.data.workTypeList.find((v, i) => {
  97. return v.fName == temp1
  98. })
  99. this.data.user.fExpand4 = obj.fValuecode
  100. this.setData({
  101. index: temp,
  102. user: this.data.user,
  103. })
  104. },
  105. // 修改养护单位
  106. bindPickerChange1(val) {
  107. let temp = val.detail.value
  108. // let temp1 = this.data.array1[temp]
  109. // let obj = this.data.YhdwList.find((v, i) => {
  110. // return v.fDeptname == temp1
  111. // })
  112. // ////console.log(obj)
  113. // this.data.user.fYhcompanyid = obj.fYhcompanyid
  114. this.setData({
  115. index1: temp,
  116. // user: this.data.user,
  117. })
  118. },
  119. // 修改职务
  120. EditfDuty(val) {
  121. this.data.user.fDuty = val.detail.value
  122. this.setData({
  123. user: this.data.user,
  124. })
  125. ////console.log("当前", this.data.user)
  126. },
  127. // 修改描述
  128. EditfExpand3(val) {
  129. this.data.user.fExpand3 = val.detail.value
  130. this.setData({
  131. user: this.data.user,
  132. })
  133. },
  134. // 修改 开启账户
  135. toggleZH(val) {
  136. if (this.data.user.fRealname == "") {
  137. return app.toast("请输入姓名")
  138. }
  139. ////console.log("val", val)
  140. if (val.detail.value == "1") {
  141. this.data.user.isAddUser = 1
  142. this.data.user.fWorkingcode = chineseToPinYin(this.data.user.fRealname)
  143. this.setData({
  144. user: this.data.user,
  145. flag: false,
  146. })
  147. } else {
  148. this.data.user.isAddUser = null
  149. this.data.user.fWorkingcode = null
  150. this.setData({
  151. user: this.data.user,
  152. flag: true,
  153. })
  154. }
  155. },
  156. // 修改用户名
  157. codeInput(val) {
  158. this.data.user.fWorkingcode = val.detail.value
  159. this.setData({
  160. user: this.data.user,
  161. })
  162. },
  163. // 保存方法
  164. baocun() {
  165. if (this.data.user.fRealname == "") {
  166. return app.toast("职务不能为空")
  167. }
  168. if (this.data.user.fDuty == "") {
  169. return app.toast("职务不能为空")
  170. }
  171. if (this.data.user.fPhone == "" || this.data.user.fPhone == null) {
  172. return app.toast("请填写手机号")
  173. }
  174. if (!app.checkPhone(this.data.user.fPhone.trim())) {
  175. return app.toast("手机号格式错误")
  176. }
  177. if (this.data.user.fLinkphone) {
  178. if (!app.checkTel(this.data.user.fLinkphone.trim())) {
  179. return app.toast("电话号格式错误")
  180. }
  181. }
  182. if (this.data.user.fIdcard) {
  183. if (this.data.user.fIdcard.trim().length != 18) {
  184. return app.toast("身份证格式错误")
  185. }
  186. }
  187. // if (this.data.user.fWorkingcode != null) {
  188. // if (this.data.user.isAddUser == null) {
  189. // this.data.user.fWorkingcode = null
  190. // this.setData({
  191. // user: this.data.user,
  192. // })
  193. // return app.toast("修改用户名前,需开启账号")
  194. // }
  195. // }
  196. this.data.user.fLinkphone == "" ? null : this.data.user.fLinkphone
  197. this.data.user.fIdcard == "" ? null : this.data.user.fIdcard
  198. this.data.user.fExpand3 == "" ? null : this.data.user.fExpand3
  199. this.setData({
  200. user: this.data.user,
  201. })
  202. let that = this
  203. ////console.log(that.data.user)
  204. wx.showModal({
  205. title: "提示",
  206. content: "确定要修改吗",
  207. success(res) {
  208. if (res.confirm) {
  209. let url =
  210. app.globalData.httpsUrlServer + "/baseemployeeinfo/saveEmployeeinfo"
  211. app.postReq(url, that.data.user, (res) => {
  212. ////console.log("res", res)
  213. if (res.status == 200) {
  214. // wx.navigateTo({
  215. // url: "../parkStaff/parkStaff",
  216. // })
  217. let pages = getCurrentPages() //页面栈
  218. ////console.log(pages)
  219. let beforePage = pages[2]
  220. ////console.log(beforePage.route)
  221. wx.navigateBack({
  222. url: "/" + beforePage.route,
  223. success: function () {
  224. if (
  225. beforePage.route ==
  226. "packagePersonnel/pages/parkStaff/parkStaff"
  227. ) {
  228. ////console.log(1111111)
  229. beforePage.onPullDownRefresh("toast")
  230. }
  231. },
  232. })
  233. } else {
  234. app.toast("操作失败")
  235. return
  236. }
  237. })
  238. } else if (res.cancel) {
  239. ////console.log("用户点击取消")
  240. }
  241. },
  242. })
  243. },
  244. // 查看大图
  245. showImg(val) {
  246. let url = val.currentTarget.dataset.url
  247. ////console.log(url)
  248. wx.previewImage({
  249. current: url, // 当前显示图片的http链接
  250. urls: [url],
  251. })
  252. },
  253. // 获得所有工种
  254. getWorkType() {
  255. let that = this
  256. let data = {
  257. fDictionaryflag: "POSITIONTYPE",
  258. }
  259. app.getDictionaries(data, (res) => {
  260. if (res.status == 200) {
  261. that.setData({
  262. workTypeList: res.data,
  263. })
  264. ////console.log("所有工种", that.data.workTypeList)
  265. let arr = that.data.workTypeList.map((item) => {
  266. return item.fName
  267. })
  268. ////console.log(arr)
  269. that.setData({
  270. array: arr,
  271. index: that.data.user.fExpand4 - 1,
  272. })
  273. ////console.log("array", that.data.array)
  274. ////console.log(that.data.user.fExpand4)
  275. }
  276. })
  277. },
  278. // 获得所有养护单位
  279. getYhdwList() {
  280. let that = this
  281. let url =
  282. app.globalData.httpsUrlServer + "/tbaseyhcompany/selectYhCompanyList"
  283. app.getReq(url, (res) => {
  284. if (res.status == 200) {
  285. that.setData({
  286. YhdwList: res.data,
  287. })
  288. ////console.log("养护单位", that.data.YhdwList)
  289. let index = that.data.YhdwList.findIndex((item) => item.fYhcompanyid == this.data.user.fYhcompanyid);
  290. that.setData({
  291. // array1: arr,
  292. index1: index,
  293. })
  294. ////console.log("养护单位名字", that.data.array1)
  295. }
  296. })
  297. },
  298. onLoad: function (options) {
  299. let obj = JSON.parse(options.info)
  300. this.setData({
  301. user: obj,
  302. })
  303. if (obj.fSex == "男") {
  304. this.setData({
  305. checked1: true,
  306. })
  307. } else {
  308. this.setData({
  309. checked2: true,
  310. })
  311. }
  312. if (obj.fWorkingcode != null) {
  313. this.setData({
  314. isWorkCode: true,
  315. })
  316. } else {
  317. this.setData({
  318. isWorkCode: false,
  319. })
  320. }
  321. this.getWorkType()
  322. this.getYhdwList()
  323. ////console.log("用户数据", this.data.user)
  324. },
  325. toast() {
  326. if (this.data.flag == true) {
  327. app.toast("请先开启账号")
  328. }
  329. },
  330. /**
  331. * 生命周期函数--监听页面初次渲染完成
  332. */
  333. onReady: function () {},
  334. /**
  335. * 生命周期函数--监听页面显示
  336. */
  337. onShow: function () {},
  338. /**
  339. * 生命周期函数--监听页面隐藏
  340. */
  341. onHide: function () {},
  342. /**
  343. * 生命周期函数--监听页面卸载
  344. */
  345. onUnload: function () {},
  346. /**
  347. * 页面相关事件处理函数--监听用户下拉动作
  348. */
  349. onPullDownRefresh: function () {},
  350. /**
  351. * 页面上拉触底事件的处理函数
  352. */
  353. onReachBottom: function () {},
  354. /**
  355. * 用户点击右上角分享
  356. */
  357. onShareAppMessage: function () {},
  358. })