detail.js 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. /*******************************************************************************
  2. * Copyright(c) 2024 dongke All rights reserved. / Confidential
  3. * 类的信息:
  4. *      1.程序名称:续费明细 
  5. * 编辑履历:
  6. *      作者              日期                  版本              修改内容
  7. *      周兴             2024-5-23                1.00               新建 
  8. *******************************************************************************/
  9. const Constants = require('@/utils/Constants.js');
  10. const util = require('@/utils/util.js')
  11. const mixins = require('@/mixins/index.js');
  12. const app = getApp()
  13. Page({
  14. mixins: [mixins],
  15. /**
  16. * 页面的初始数据
  17. */
  18. data: {
  19. // 企业名称
  20. staffInfo: null,
  21. saveParams: null,
  22. staffService: app.globalData['staffService'],
  23. routeObjName: 'company',
  24. active: 0,
  25. pageFlag: false,
  26. tableDataSocial: null,
  27. tagList: [{ title: mixins.$t('wxRight'), code: 'wx' }, { title: mixins.$t('webRight'), code: 'web' }],
  28. contentList: [
  29. { name: 'staffCode', title: mixins.$t('staffCode') },
  30. { name: 'staffPhone', title: mixins.$t('staffPhone') },
  31. { name: 'orgName', title: mixins.$t('orgId') },
  32. { name: 'roleNames', title: mixins.$t('roleName') },
  33. ],
  34. //按钮
  35. buttonSaveList: [
  36. { code: 'save', title: mixins.$t('save') }
  37. ],
  38. // 取消授权的staffid
  39. delStaffIds:[],
  40. },
  41. /**
  42. * @desc : 给参数赋值
  43. * @date : 2024/5/30 15:49
  44. * @author : 周兴
  45. */
  46. setSearchParams(params) {
  47. params.flgCanLogin = true;
  48. params.flgValid = true;
  49. params.currentPage = 1;
  50. params.pageSize = Constants.MAX_PAGE_SIZE;
  51. if (this.data.gradeCode == Constants.gradeCode.STD) {
  52. // 标准版需要排除掉 企业授权的那个用户
  53. // params.flgInit = false;
  54. }
  55. return params;
  56. },
  57. /**
  58. * @desc : 查询
  59. * @date : 2024/5/30 15:49
  60. * @author : 周兴
  61. */
  62. getData(params) {
  63. return this.excute(this.data.staffService, this.data.staffService.selectByCond, params);
  64. },
  65. /**
  66. * @desc : 处理数据
  67. * @date : 2024/5/30 15:49
  68. * @author : 周兴
  69. */
  70. handleSearchData(tableData) {
  71. this.setData({
  72. tableDataSocial: [...tableData]
  73. })
  74. // 过滤出手机授权(默认展示)
  75. tableData = tableData.filter(it => it.loginType == Constants.loginType.loginTypeWx
  76. || it.loginType == Constants.loginType.loginTypeWxPc);
  77. this.setData({
  78. tableData: tableData
  79. })
  80. // 刷新数量
  81. this.refreshTag();
  82. },
  83. /**
  84. * @desc : 刷新量
  85. * @date : 2024/5/23 15:49
  86. * @author : 周兴
  87. */
  88. refreshTag() {
  89. if (this.data.gradeCode == Constants.gradeCode.STD) {
  90. let staffInfo = this.data.staffInfo;
  91. let filters = staffInfo.filter(it => it.code == 'current');
  92. if (filters && filters.length > 0) {
  93. let tableData = [...this.data.tableDataSocial]
  94. tableData = tableData.filter(it => it.loginType == Constants.loginType.loginTypeWx
  95. || it.loginType == Constants.loginType.loginTypeWxPc);
  96. filters[0].userCount = tableData.length;
  97. this.setData({
  98. staffInfo: staffInfo
  99. })
  100. }
  101. } else {
  102. let tagList = this.data.tagList
  103. let tableData = [...this.data.tableDataSocial]
  104. tableData = tableData.filter(it => it.loginType == Constants.loginType.loginTypeWx
  105. || it.loginType == Constants.loginType.loginTypeWxPc);
  106. let filters = tagList.filter(it => it.code == 'wx');
  107. if (filters && filters.length > 0) {
  108. filters[0].title = mixins.$t('wxRight') + '【' + tableData.length + '】'
  109. }
  110. let webData = [...this.data.tableDataSocial]
  111. // 电脑端授权
  112. webData = webData.filter(it => it.loginType == Constants.loginType.loginTypePc
  113. || it.loginType == Constants.loginType.loginTypeWxPc);
  114. filters = tagList.filter(it => it.code == 'web');
  115. if (filters && filters.length > 0) {
  116. filters[0].title = mixins.$t('webRight') + '【' + webData.length + '】'
  117. }
  118. this.setData({
  119. tagList: tagList
  120. })
  121. }
  122. },
  123. /**
  124. * @desc : 停用用户,不再续费
  125. * @date : 2024/5/23 15:49
  126. * @author : 周兴
  127. */
  128. handleStaff(e) {
  129. let item = e.detail.item
  130. if (item.flgInit) {
  131. util.showToast('责任人不能取消授权')
  132. return
  133. }
  134. let staffId = item.staffId
  135. let delStaffIds = this.data.delStaffIds
  136. delStaffIds.push(staffId)
  137. // 过滤掉停用的这条数据
  138. let tableDataSocial = this.data.tableDataSocial
  139. tableDataSocial = tableDataSocial.filter(it => it.staffId != staffId)
  140. let tableData = this.data.tableData
  141. tableData = tableData.filter(it => it.staffId != staffId)
  142. this.setData({
  143. tableDataSocial: tableDataSocial,
  144. tableData: tableData,
  145. delStaffIds,
  146. })
  147. // 刷新数量
  148. this.refreshTag();
  149. // 不调用接口 240718
  150. // return this.excute(this.data.staffService, this.data.staffService.disable, staffId).then(res => {
  151. // if (res.data.code == Constants.SUCESS_CODE) {
  152. // wx.showToast({
  153. // title: '操作成功',
  154. // image: '/static/image/success.png',
  155. // duration: 2000
  156. // })
  157. // // 过滤掉停用的这条数据
  158. // let tableDataSocial = this.data.tableDataSocial
  159. // tableDataSocial = tableDataSocial.filter(it => it.staffId != staffId)
  160. // let tableData = this.data.tableData
  161. // tableData = tableData.filter(it => it.staffId != staffId)
  162. // this.setData({
  163. // tableDataSocial: tableDataSocial,
  164. // tableData: tableData
  165. // })
  166. // // 刷新数量
  167. // this.refreshTag();
  168. // }
  169. // });
  170. },
  171. /**
  172. * @desc : 校验数据
  173. * @date : 2024/5/30 15:49
  174. * @author : 周兴
  175. */
  176. validData() {
  177. // 校验现在的用户数是否超过续费授权数
  178. let tableDataSocial = this.data.tableDataSocial
  179. let staffInfo = this.data.staffInfo
  180. let staffFilters = staffInfo.filter(it => it.code == 'renew');
  181. // 判断手机授权
  182. let wxFilters = tableDataSocial.filter(it => it.loginType == Constants.loginType.loginTypeWx
  183. || it.loginType == Constants.loginType.loginTypeWxPc);
  184. if (wxFilters.length > staffFilters[0].wxMaxNum) {
  185. util.showToast('当前手机授权数超过续费手机授权数')
  186. return false;
  187. }
  188. // 判断电脑授权
  189. let webFilters = tableDataSocial.filter(it => it.loginType == Constants.loginType.loginTypePc
  190. || it.loginType == Constants.loginType.loginTypeWxPc);
  191. if (webFilters.length > staffFilters[0].webMaxNum) {
  192. util.showToast('当前电脑授权数超过续费电脑授权数')
  193. return false;
  194. }
  195. return true;
  196. },
  197. /**
  198. * @desc : 设置保存参数
  199. * @author : 周兴
  200. * @date : 2024/4/1
  201. */
  202. setParams(params) {
  203. params = this.data.saveParams
  204. // 取消授权的staffid
  205. if (this.data.delStaffIds.length > 0 && params.reNew!=null){
  206. params.reNew.del_staff_ids = this.data.delStaffIds
  207. }
  208. return params;
  209. },
  210. /**
  211. * @desc : 保存数据
  212. * @author : 周兴
  213. * @date : 2024/5/17
  214. */
  215. saveData(params) {
  216. return this.excute(this.data.service, this.data.service.reNewCompany, params).then(res => {
  217. if (res.data.code == Constants.SUCESS_CODE) {
  218. // 成功后跳转支付
  219. this.toPay(res.data.data);
  220. }else {
  221. // 调转主页
  222. wx.reLaunch({
  223. url: '/pages/welcome/welcome',
  224. })
  225. }
  226. })
  227. },
  228. /**
  229. * @desc : 切换,查询用户
  230. * @date : 2024/5/23 15:49
  231. * @author : 周兴
  232. */
  233. onChangeTabs(e) {
  234. let code = e.detail.detail.code
  235. let tableDataSocial = [...this.data.tableDataSocial];
  236. let tableData = null;
  237. let tagList = this.data.tagList
  238. let filters = []
  239. if (code == 'web') {
  240. // 过滤出电脑授权
  241. tableData = tableDataSocial.filter(it => it.loginType == Constants.loginType.loginTypePc
  242. || it.loginType == Constants.loginType.loginTypeWxPc);
  243. filters = tagList.filter(it => it.code == 'web');
  244. if (filters && filters.length > 0) {
  245. filters[0].title = mixins.$t('webRight') + '【' + tableData.length + '】'
  246. }
  247. } else {
  248. // 过滤出手机授权
  249. tableData = tableDataSocial.filter(it => it.loginType == Constants.loginType.loginTypeWx
  250. || it.loginType == Constants.loginType.loginTypeWxPc);
  251. filters = tagList.filter(it => it.code == 'wx');
  252. if (filters && filters.length > 0) {
  253. filters[0].title = mixins.$t('wxRight') + '【' + tableData.length + '】'
  254. }
  255. }
  256. this.setData({
  257. tableData: tableData,
  258. tagList: tagList
  259. })
  260. },
  261. /**
  262. * @desc : 初始加载
  263. * @date : 2024/5/23 15:49
  264. * @author : 周兴
  265. */
  266. loadInit() {
  267. this.setData({
  268. saveParams: { ...this.data.params }
  269. })
  270. },
  271. /**
  272. * @desc : 初始加载(生命周期函数)
  273. * @date : 2024/5/23 15:49
  274. * @author : 周兴
  275. */
  276. onLoad(options) {
  277. this.setData({
  278. staffInfo: JSON.parse(options.staffInfo)
  279. })
  280. }
  281. })