index.js 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. const _Http = getApp().globalData.http;
  2. Page({
  3. data: {
  4. tabs: [{
  5. title: "我收到的",
  6. id: "Receive"
  7. }, {
  8. title: "我发出的",
  9. id: "SendOut"
  10. }],
  11. active: "Receive",
  12. filterShow: false,
  13. filtratelist: [{
  14. label: "模板类型",
  15. index: null,
  16. showName: "reportname", //显示字段
  17. valueKey: "sys_workreportmodelid", //返回Key
  18. selectKey: "sys_workreportmodelid", //传参 代表选着字段 不传参返回整个选择对象
  19. value: "", //选中值
  20. list: []
  21. }, {
  22. label: "阅读状态",
  23. index: null,
  24. showName: "name", //显示字段
  25. valueKey: "readstatus", //返回Key
  26. selectKey: "value", //传参 代表选着字段 不传参返回整个选择对象
  27. value: "", //选中值
  28. list: [{
  29. name: "全部",
  30. value: ""
  31. }, {
  32. name: "已读",
  33. value: "1"
  34. }, {
  35. name: "未读",
  36. value: "0"
  37. }]
  38. }, {
  39. label: "时间筛选",
  40. index: null,
  41. showName: "name", //显示字段
  42. valueKey: "date", //返回Key
  43. selectKey: "value", //传参 代表选着字段 不传参返回整个选择对象
  44. value: "", //选中值
  45. list: [{
  46. name: "今日",
  47. value: "today"
  48. }, {
  49. name: "最近三天",
  50. value: "lastthreedays"
  51. }, {
  52. name: "最近一周",
  53. value: "lastWeek"
  54. }]
  55. }],
  56. isread: {
  57. label: "阅读状态",
  58. index: null,
  59. showName: "name", //显示字段
  60. valueKey: "readstatus", //返回Key
  61. selectKey: "value", //传参 代表选着字段 不传参返回整个选择对象
  62. value: "", //选中值
  63. list: [{
  64. name: "全部",
  65. value: ""
  66. }, {
  67. name: "已读",
  68. value: "1"
  69. }, {
  70. name: "未读",
  71. value: "0"
  72. }]
  73. },
  74. where: {
  75. condition: "",
  76. }
  77. },
  78. onLoad(options) {
  79. this.getList();
  80. },
  81. onChange(e) {
  82. let list = this.selectComponent("#Yl_Filtrate1").data.list;
  83. if (e.detail.name == 'SendOut') {
  84. this.data.isread = list[1];
  85. this.setData({
  86. filtratelist: list.filter(v => v.label != '阅读状态')
  87. })
  88. } else {
  89. list.splice(1, 0, this.data.isread)
  90. this.setData({
  91. filtratelist: list
  92. })
  93. }
  94. this.setData({
  95. active: e.detail.name
  96. });
  97. this.getList();
  98. },
  99. getList(init = false) {
  100. if (init.detail != undefined) init = init.detail;
  101. this.selectComponent("#" + this.data.active).getList(init);
  102. this.getModel();
  103. },
  104. updateList() {
  105. let Receive = this.selectComponent("#Receive");
  106. if (Receive) {
  107. let content = JSON.parse(JSON.stringify(Receive.data.content))
  108. content.pageSize = (content.pageNumber - 1) * content.pageSize;
  109. content.pageNumber = 1;
  110. _Http.basic({
  111. "id": '20230524103102',
  112. content
  113. }).then(res => {
  114. console.log("Receive更新列表", res)
  115. if (res.msg != '失败') Receive.setData({
  116. list: res.data
  117. })
  118. })
  119. }
  120. let SendOut = this.selectComponent("#SendOut");
  121. if (SendOut) {
  122. let Scontent = JSON.parse(JSON.stringify(SendOut.data.content))
  123. Scontent.pageSize = (Scontent.pageNumber - 1) * Scontent.pageSize;
  124. Scontent.pageNumber = 1;
  125. _Http.basic({
  126. "id": "20230524102802",
  127. content: Scontent
  128. }).then(res => {
  129. console.log("SendOut更新列表", res)
  130. if (res.msg != '失败') SendOut.setData({
  131. list: res.data
  132. })
  133. })
  134. }
  135. },
  136. /* 获取模版列表 */
  137. getModel() {
  138. _Http.basic({
  139. "id": "20230524091902",
  140. "content": {
  141. "hrid": wx.getStorageSync('userMsg').hrid
  142. }
  143. }).then(res => {
  144. console.log("可创建模版列表", res)
  145. if (res.msg != '成功') return wx.showToast({
  146. title: res.msg,
  147. icon: 'none',
  148. mask: true
  149. })
  150. this.setData({
  151. modelList: res.data,
  152. "filtratelist[0].list": res.data
  153. })
  154. })
  155. },
  156. onReady() {
  157. this.selectComponent("#ListBox").setHeight(".head", this);
  158. },
  159. /* 新建汇报 */
  160. newData(e, i = 0) {
  161. wx.navigateTo({
  162. url: '/packageA/report/insert?model=' + JSON.stringify(this.data.modelList[i]),
  163. })
  164. },
  165. /* Picker选择器选择新建模版 */
  166. onPickerSelected(e) {
  167. this.newData("", e.detail.value)
  168. },
  169. /* 搜索 */
  170. onSearch({
  171. detail
  172. }) {
  173. if (this.data.where.condition == detail) return;
  174. this.data.where.condition = detail;
  175. this.selectComponent("#" + this.data.active).getList(true);
  176. },
  177. /* 筛选 */
  178. handleFilter({
  179. detail
  180. }) {
  181. detail.condition = this.data.where.condition;
  182. detail.today = 0
  183. detail.lastthreedays = 0
  184. detail.lastWeek = 0
  185. if (detail.date) detail[detail.date] = 1;
  186. detail.begindate = detail.startdate || ''
  187. this.data.where = detail;
  188. this.selectComponent("#" + this.data.active).getList(true);
  189. },
  190. onClick() {
  191. this.setData({
  192. filterShow: true
  193. })
  194. }
  195. })