company-param-setting.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. const Constants = require('@/utils/Constants.js');
  2. const util = require('@/utils/util.js')
  3. const mixins = require('@/mixins/index.js')
  4. const app = getApp()
  5. Page({
  6. mixins: [mixins],
  7. /**
  8. * 页面的初始数据
  9. */
  10. data: {
  11. routeObjName: 'settingValue',
  12. tableData: [],
  13. formData: {},
  14. cpId: app.globalData.company.cpId,
  15. },
  16. /**
  17. * @desc : 收起展开实践
  18. * @date : 2024/2/1 15:49
  19. * @author : 姜永辉
  20. */
  21. collapseAndExpand(e) {
  22. let index = e.currentTarget.dataset.index
  23. let tableData = this.data.tableData
  24. let item = tableData[index]
  25. item.checked = !item.checked
  26. tableData[index] = item
  27. this.setData({
  28. tableData
  29. })
  30. },
  31. /**
  32. * @desc : 修改输入框的值
  33. * @author : 周兴
  34. * @date : 2024/2/2 11:46
  35. */
  36. changeField(e) {
  37. let ds = e.currentTarget.dataset
  38. let findex = ds.findex
  39. let index = ds.index
  40. let tableData = this.data.tableData
  41. let item = tableData[findex]
  42. item.children[index].settingValue = e.detail
  43. tableData[findex] = item
  44. console.log("changeField", e, tableData, index);
  45. this.setData({
  46. tableData: tableData
  47. })
  48. },
  49. /**
  50. * @desc : 修改Switch的值
  51. * @author : 周兴
  52. * @date : 2024/2/2 11:46
  53. */
  54. onChangeSwitch(e) {
  55. console.log("onChangeSwitch", e);
  56. let ds = e.currentTarget.dataset
  57. let findex = ds.findex
  58. let index = ds.index
  59. let tableData = this.data.tableData
  60. let item = tableData[findex]
  61. item.children[index].settingValue = e.detail
  62. tableData[findex] = item
  63. console.log("onChangeSwitch", tableData, index);
  64. this.setData({
  65. tableData: tableData
  66. })
  67. },
  68. /**
  69. * @desc : 列表交换器选择事件父级
  70. * @date : 2024/2/1 15:49
  71. * @author : 姜永辉
  72. */
  73. onCheckedItem(e) {
  74. console.log(e)
  75. let _that = this
  76. let index = e.currentTarget.dataset.index
  77. let tableData = _that.data.tableData
  78. tableData[index].checked = !tableData[index].checked
  79. if (tableData[index].children && tableData[index].children.length > 0) {
  80. console.log('list[index].children', tableData[index].children)
  81. tableData[index].children.forEach(res => {
  82. res.checked = tableData[index].checked
  83. })
  84. }
  85. _that.setData({
  86. tableData: tableData
  87. })
  88. },
  89. /**
  90. * @desc : 设置额外参数
  91. * @date : 2024/2/1 15:49
  92. * @author : 姜永辉
  93. */
  94. setSearchParams(params) {
  95. params.cpId = this.data.cpId
  96. return params
  97. },
  98. /**
  99. * @desc : 加载数据
  100. * @date : 2024/2/1 15:49
  101. * @author : 姜永辉
  102. */
  103. getData(params) {
  104. return this.excute(this.data.service, this.data.service.getSettingValue, params);
  105. },
  106. /**
  107. * @desc : 处理接口返回数据
  108. * @date : 2024/2/1 15:49
  109. * @author : 姜永辉
  110. */
  111. handleSearchData(tableData) {
  112. this.setData({
  113. tableData: util.convertToChildren(tableData, 'parentCode', 'itemCode')
  114. })
  115. },
  116. /**
  117. * @desc : 折叠面板多选框事件
  118. * @date : 2024/2/1 15:49
  119. * @author : 姜永辉
  120. */
  121. obtainList(e) {
  122. this.setData({
  123. tableData: e.detail.list
  124. })
  125. },
  126. /**
  127. * @desc : 处理数据-保存和查询后的逻辑
  128. * @author : 姜永辉
  129. * @date : 2024/1/26 11:46
  130. */
  131. handleData() {
  132. wx.navigateBack({
  133. data: 1
  134. })
  135. },
  136. /**
  137. * @desc : 保存的參數設置
  138. * @date : 2024/2/1 15:49
  139. * @author : 姜永辉
  140. */
  141. setParams(params) {
  142. console.log("setParams", params, this.data.tableData);
  143. // 修改之后的 值
  144. let tableData = this.data.tableData
  145. let item = {}
  146. let settingValueList = []
  147. //格式化数据
  148. tableData.forEach(res => {
  149. if (res.children && res.children.length > 0) {
  150. res.children.forEach(it => {
  151. item = {
  152. settingCode: it.itemCode,
  153. cpId: this.data.cpId,
  154. settingValue: it.settingValue!=null ? it.settingValue : it.defValue,
  155. }
  156. settingValueList.push(item)
  157. })
  158. }
  159. })
  160. params.settingValueList = settingValueList
  161. params.cpId = this.data.cpId
  162. return params
  163. },
  164. /**
  165. * @desc : 批量修改敏感信息接口
  166. * @date : 2024/2/1 15:49
  167. * @author : 姜永辉
  168. */
  169. saveData(params) {
  170. return this.excute(this.data.service, this.data.service.updateBatch, params);
  171. },
  172. })