index.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. const _Http = getApp().globalData.http;
  2. Page({
  3. data: {
  4. navList: [{
  5. label: "我负责的",
  6. icon: "icon-webxialaxuanxiangjiantou",
  7. color: "",
  8. width: "",
  9. id: "1"
  10. }, {
  11. label: "排序",
  12. icon: "icon-jiangxu1",
  13. color: "",
  14. width: "",
  15. id: "sort"
  16. }, {
  17. label: "筛选",
  18. icon: "icon-shaixuan",
  19. color: "",
  20. width: "",
  21. id: "2"
  22. }],
  23. content: {
  24. "type": 99,
  25. "pageNumber": 1,
  26. "pageSize": 20,
  27. "where": {
  28. "status": "",
  29. "type": "",
  30. "begindate": "",
  31. "enddate": "",
  32. "condition": ""
  33. }
  34. },
  35. filtratelist: [],
  36. list: []
  37. },
  38. async onLoad(options) {
  39. getApp().globalData.Language.getLanguagePackage(this);
  40. let templetList = wx.getStorageSync('templetList')
  41. this.setData({
  42. insert: wx.getStorageSync('auth').wcontract.options.some(v => v == 'insert'), //查询新增权限
  43. classActions: templetList.map((v, i) => {
  44. return {
  45. name: v.templetname,
  46. index: v.templetid,
  47. color: i == 0 ? '#3874F6' : '',
  48. i: i,
  49. }
  50. }),
  51. 'navList[0].label': templetList[0].templetname,
  52. "content.type": templetList[0].templetid,
  53. });
  54. this.getList(true)
  55. getApp().globalData.Language.getLanguagePackage(this);
  56. let filtratelist = [{
  57. label: "状态",
  58. index: null,
  59. showName: "value", //显示字段
  60. valueKey: "status", //返回Key
  61. selectKey: "value", //传参 代表选着字段 不传参返回整个选择对象
  62. value: "", //选中值
  63. list: [{
  64. value: '生效'
  65. }, {
  66. value: '未生效'
  67. }, {
  68. value: '结束'
  69. }]
  70. }, {
  71. label: "合同类型",
  72. index: null,
  73. showName: "value", //显示字段
  74. valueKey: "type", //返回Key
  75. selectKey: "value", //传参 代表选着字段 不传参返回整个选择对象
  76. value: "", //选中值
  77. list: await _Http.getTypes('contracttype', _Http)
  78. }]
  79. this.setData({
  80. filtratelist
  81. })
  82. },
  83. getList(init = false) {
  84. _Http.init(this.data.content, init).then(content => {
  85. _Http.basic({
  86. "id": 20221121201502,
  87. content
  88. }).then(res => {
  89. console.log("合同列表", res)
  90. this.selectComponent('#ListBox').RefreshToComplete();
  91. if (res.code != '1') return wx.showToast({
  92. title: res.msg,
  93. icon: "none"
  94. })
  95. this.setData({
  96. content: _Http.paging(content, res),
  97. list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data)
  98. })
  99. })
  100. })
  101. },
  102. /* 处理筛选 */
  103. handleFilter({
  104. detail
  105. }) {
  106. detail.condition = this.data.content.where.condition;
  107. detail.begindate = detail.startdate;
  108. delete detail.startdate;
  109. this.data.content.where = detail;
  110. this.data.content.where = detail;
  111. this.getList(true);
  112. },
  113. /* 顶部条件导航回调 */
  114. navClick({
  115. detail
  116. }) {
  117. switch (detail.id) {
  118. case '1':
  119. this.setData({
  120. classShow: true
  121. })
  122. break;
  123. case '2':
  124. this.setData({
  125. 'filterShow': true
  126. })
  127. break;
  128. case '3':
  129. this.setData({
  130. 'content.sort[0].reversed': this.data.content.sort[0].reversed == 0 ? 1 : 0
  131. });
  132. this.getList(true)
  133. break;
  134. }
  135. },
  136. /* 处理搜索 */
  137. onSearch({
  138. detail
  139. }) {
  140. this.data.content.where.condition = detail;
  141. this.getList(true);
  142. },
  143. classClose() {
  144. this.setData({
  145. classShow: false
  146. })
  147. },
  148. classSelect({
  149. detail
  150. }) {
  151. if (this.data.content.type == detail.index) return this.classClose();
  152. this.setData({
  153. "content.type": detail.index,
  154. 'navList[0].label': detail.name,
  155. classActions: this.data.classActions.map(v => {
  156. v.color = detail.i == v.i ? '#3874F6' : ''
  157. return v
  158. })
  159. })
  160. this.classClose();
  161. this.getList(true)
  162. }
  163. })