Nav apraksta

parkStaff.js 9.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  1. // packagePersonnel/pages/parkStaff/parkStaff.js
  2. const app = getApp();
  3. var startPoint;
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. listData: [], // 人员数据
  10. parkList: [], //公园列表
  11. array: [], //公园名字列表
  12. index: 0, //当前公园下标
  13. current: 1,
  14. size: 15,
  15. parkId: '', // 公园id
  16. parkName: '', // 公园名称
  17. workTypeList: [], //工种列表
  18. array1: [], //工种名字列表
  19. index1: null, //当前工种 下标
  20. // 公园 权限
  21. iSdisabled: false,
  22. flag: true,
  23. Scaling: false, // 筛选框
  24. userName: null, // 姓名
  25. fdyname: null, //职务
  26. fYhcompanyid: null,
  27. },
  28. bindPickerChange: function (e) {
  29. this.setData({
  30. listData: [],
  31. current: 1,
  32. flag: true,
  33. });
  34. // ////console.log("picker发送选择改变,携带值为", this.data.array[e.detail.value])
  35. let obj = this.data.parkList.find((v) => {
  36. return v.fParkname == this.data.array[e.detail.value];
  37. });
  38. let parkId = obj.fParkid;
  39. let parkName = obj.fParkname;
  40. this.setData({
  41. index: e.detail.value,
  42. parkId: parkId,
  43. parkName: parkName,
  44. });
  45. ////console.log("公园id", parkId)
  46. // 获得当前 公园 人员列表
  47. this.getInfoById(parkId);
  48. // let data1 = {
  49. // fDictionaryFlag: "POSITIONTYPE",
  50. // }
  51. // app.getDictionaries(data1, (res) => {
  52. // ////console.log("res", res)
  53. // })
  54. },
  55. // 点击新增按钮
  56. buttontap(e) {
  57. let id = this.data.parkId;
  58. let name = this.data.parkName;
  59. wx.navigateTo({
  60. url: `/packagePersonnel/pages/personAdd/personAdd?id=${id}&name=${name}&fYhcompanyid=${this.data.fYhcompanyid}`,
  61. });
  62. },
  63. // 公园接口----------------start
  64. getAllParkData() {
  65. var that = this;
  66. let url =
  67. app.globalData.httpsUrlServer + '/parkInfoApp/selectAppParkInfoList';
  68. app.getReq(url, (res) => {
  69. ////console.log("res", res)
  70. if (res.status == 200) {
  71. that.setData({
  72. parkList: res.data,
  73. });
  74. let arr = that.data.parkList.map((v) => {
  75. return v.fParkname;
  76. });
  77. // ////console.log("公园名字列表", arr)
  78. that.setData({
  79. array: arr,
  80. });
  81. let obj = that.data.parkList.find((v) => {
  82. return v.fParkname == that.data.array[that.data.index];
  83. });
  84. let parkId = obj.fParkid;
  85. let parkName = obj.fParkname;
  86. ////console.log("养护oid", obj)
  87. that.setData({
  88. parkId: parkId,
  89. parkName: parkName,
  90. fYhcompanyid: obj.fYhcompanyid,
  91. });
  92. that.getInfoById(parkId);
  93. }
  94. });
  95. },
  96. // 获得 所有 工种接口
  97. getInfoGZ() {
  98. let that = this;
  99. let data = {
  100. fDictionaryflag: 'POSITIONTYPE',
  101. };
  102. app.getDictionaries(data, (res) => {
  103. ////console.log("所有工种", res)
  104. if (res.status == 200) {
  105. that.setData({
  106. workTypeList: res.data,
  107. });
  108. ////console.log("所有工种", that.data.workTypeList)
  109. let arr = that.data.workTypeList.map((item) => {
  110. return item.fName;
  111. });
  112. that.setData({
  113. array1: arr,
  114. });
  115. ////console.log("array", that.data.array1)
  116. }
  117. });
  118. },
  119. // 修改 查看
  120. nav(e) {
  121. ////console.log("e", e)
  122. var info = JSON.stringify(e.currentTarget.dataset.val);
  123. ////console.log(info)
  124. wx.navigateTo({
  125. url: `/packagePersonnel/pages/personInfo/personInfo?info=${info}`,
  126. });
  127. },
  128. // 删除
  129. remove(e) {
  130. ////console.log("e", e.currentTarget.dataset.val)
  131. let data = e.currentTarget.dataset.val;
  132. var that = this;
  133. ////console.log()
  134. wx.showModal({
  135. title: '温馨提示',
  136. content: '确定要删除该成员吗',
  137. success(res) {
  138. if (res.confirm) {
  139. ////console.log("删除")
  140. let url =
  141. app.globalData.httpsUrlServer +
  142. '/baseemployeeinfo/deleteEmployeeinfo';
  143. app.postReq(url, data, (res) => {
  144. ////console.log("res", res)
  145. if (res.status == 200) {
  146. that.setData({
  147. listData: [],
  148. current: 1,
  149. flag: true,
  150. });
  151. that.getInfoById(that.data.parkId);
  152. } else {
  153. return app.toast(res.message);
  154. }
  155. });
  156. ////console.log("用户点击确定")
  157. } else if (res.cancel) {
  158. ////console.log("用户点击取消")
  159. }
  160. },
  161. });
  162. },
  163. // 通过 公园Id 获得 所有人员
  164. getInfoById(parkId) {
  165. wx.showLoading({
  166. title: '加载中',
  167. });
  168. let that = this;
  169. let url =
  170. app.globalData.httpsUrlServer +
  171. '/baseemployeeinfo/selectEmployeeinfoByPageList';
  172. let data = {
  173. fParkid: parkId,
  174. current: this.data.current,
  175. size: this.data.size,
  176. };
  177. app.postReq(url, data, (res) => {
  178. ////console.log("res", res)
  179. if (res.status == 200) {
  180. const { data } = res.data;
  181. if (data.length < 15) {
  182. that.setData({
  183. flag: false,
  184. });
  185. }
  186. this.setData({
  187. listData: [...that.data.listData, ...data],
  188. });
  189. wx.hideLoading();
  190. }
  191. });
  192. },
  193. // 拨打电话
  194. freeTell(e) {
  195. let phoneNumber = e.currentTarget.dataset.num;
  196. wx.makePhoneCall({
  197. phoneNumber: phoneNumber,
  198. });
  199. },
  200. // 显示筛选框
  201. showScaling() {
  202. this.setData({
  203. Scaling: true,
  204. });
  205. },
  206. // 关闭筛选框
  207. close() {
  208. this.setData({
  209. Scaling: false,
  210. });
  211. },
  212. // 筛选工种
  213. bindPickerChange1(e) {
  214. this.setData({
  215. index1: e.detail.value,
  216. });
  217. let name = this.data.array1[this.data.index1];
  218. let obj = this.data.workTypeList.find((v) => {
  219. return v.fName == name;
  220. });
  221. this.setData({
  222. fValuecode: obj.fValuecode,
  223. });
  224. ////console.log("obj", obj.fValuecode)
  225. },
  226. // 筛选姓名
  227. IptuserName(e) {
  228. this.setData({
  229. userName: e.detail.value,
  230. });
  231. },
  232. // 筛选职务
  233. Iptfdyname(e) {
  234. this.setData({
  235. fdyname: e.detail.value,
  236. });
  237. },
  238. // 重置筛选
  239. czScaling() {
  240. this.setData({
  241. index1: null,
  242. userName: null,
  243. fValuecode: null,
  244. fdyname: null,
  245. });
  246. },
  247. // 确定筛选
  248. qdScaling() {
  249. if (!this.data.fValuecode && !this.data.userName && !this.data.fdyname) {
  250. this.setData({
  251. current: 1,
  252. listData: [],
  253. });
  254. this.getInfoById(this.data.parkId);
  255. this.setData({
  256. Scaling: false,
  257. });
  258. return;
  259. }
  260. wx.showLoading({
  261. title: '加载中',
  262. });
  263. let that = this;
  264. let url =
  265. app.globalData.httpsUrlServer +
  266. '/baseemployeeinfo/selectEmployeeinfoByPageList';
  267. let data = {
  268. current: 1,
  269. size: 10000,
  270. fParkid: this.data.parkId, // 公园id
  271. fExpand4: this.data.fValuecode, // 工种id
  272. fRealname: this.data.userName, // 人员名称
  273. fDuty: this.data.fdyname, // 职务
  274. };
  275. app.postReq(url, data, (res) => {
  276. if (res.status == 200) {
  277. let { data } = res.data;
  278. that.setData({
  279. listData: data,
  280. Scaling: false,
  281. });
  282. wx.hideLoading();
  283. }
  284. ////console.log("res", res)
  285. });
  286. },
  287. //所有公园-----------------end
  288. onLoad: function (options) {
  289. var that = this;
  290. let position = wx.getStorageSync('position');
  291. this.getInfoGZ(); // 获取所有工种留做筛选
  292. // if (position == '中心') {
  293. this.setData({
  294. iSdisabled: true,
  295. });
  296. this.getAllParkData(); // 获取公园数据
  297. // return;
  298. // }
  299. /* 判断是否是中心人员 还是园长 */
  300. let url =
  301. app.globalData.httpsUrlServer +
  302. '/sysuseraccount/selectEmployeeinfoByUserId';
  303. app.getReq(url, (res) => {
  304. ////console.log("res", res)
  305. if (res.status == 200) {
  306. if (res.data == null) {
  307. // 没有data 是中心人员
  308. that.setData({
  309. iSdisabled: true,
  310. });
  311. } else {
  312. // 没有公园id 是中心人员
  313. if (!res.data.fParkid) {
  314. that.setData({
  315. iSdisabled: true,
  316. });
  317. } else {
  318. console.log('res', res);
  319. // ////console.log(that.data.array)
  320. that.setData({
  321. parkId: res.data.fParkid,
  322. parkName: res.data.fNativeplace,
  323. iSdisabled: false,
  324. fYhcompanyid: res.data.fYhcompanyid,
  325. });
  326. ////console.log(that.data.parkId)
  327. that.getInfoById(that.data.parkId);
  328. return;
  329. }
  330. }
  331. } else {
  332. ////console.log("请求失败")
  333. }
  334. });
  335. },
  336. onReady: function () {},
  337. /**
  338. * 生命周期函数--监听页面显示
  339. */
  340. onShow: function () {},
  341. /**
  342. * 生命周期函数--监听页面隐藏
  343. */
  344. onHide: function () {},
  345. /**
  346. * 生命周期函数--监听页面卸载
  347. */
  348. onUnload: function () {},
  349. /**
  350. * 页面相关事件处理函数--监听用户下拉动作
  351. */
  352. onPullDownRefresh: function (e) {
  353. if (e == 'toast') {
  354. app.toast('保存成功');
  355. }
  356. this.setData({
  357. listData: [],
  358. current: 1,
  359. flag: true,
  360. });
  361. this.getInfoById(this.data.parkId);
  362. wx.stopPullDownRefresh();
  363. },
  364. /**
  365. * 页面上拉触底事件的处理函数
  366. */
  367. onReachBottom: function () {
  368. ////console.log("触底")
  369. this.setData({
  370. current: this.data.current + 1,
  371. });
  372. if (this.data.flag) {
  373. this.getInfoById(this.data.parkId);
  374. }
  375. },
  376. /**
  377. * 用户点击右上角分享
  378. */
  379. onShareAppMessage: function () {},
  380. });