index.js 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. const _Http = getApp().globalData.http;
  2. import {
  3. getTypes
  4. } from "./modules/query";
  5. Page({
  6. data: {
  7. loading: true,
  8. navList: [{
  9. label: "我负责的",
  10. icon: "icon-webxialaxuanxiangjiantou",
  11. color: "",
  12. width: "",
  13. id: "1"
  14. }, {
  15. label: "排序",
  16. icon: "icon-jiangxu1",
  17. color: "",
  18. width: "",
  19. id: "sort"
  20. }, {
  21. label: "筛选",
  22. icon: "icon-shaixuan",
  23. color: "",
  24. width: "",
  25. id: "2"
  26. }],
  27. content: {
  28. isend: 0,
  29. nocache: true,
  30. "type": 1,
  31. deleted: 0,
  32. "pageNumber": 1,
  33. "pageSize": 20,
  34. "isExport": 0,
  35. "where": {},
  36. "sort": [{
  37. sortname: "默认",
  38. sorted: 1,
  39. sortid: 67,
  40. reversed: 0
  41. }]
  42. },
  43. list: [],
  44. classShow: false, //type类型
  45. },
  46. /* 去添加 */
  47. toAdd() {
  48. wx.navigateTo({
  49. url: './addAndEditor'
  50. })
  51. },
  52. async onLoad(options) {
  53. getApp().globalData.Language.getLanguagePackage(this, '医院管理');
  54. this.setData({
  55. insert: wx.getStorageSync('auth').wCustomer.options.some(v => v == 'insert'), //查询新增权限
  56. classActions: wx.getStorageSync('templetList').map((v, i) => {
  57. return {
  58. name: v.templetname,
  59. index: v.templetid,
  60. color: i == 0 ? '#3874F6' : '',
  61. i: i,
  62. }
  63. }),
  64. 'navList[0].label': wx.getStorageSync('templetList')[0].templetname,
  65. "content.type": wx.getStorageSync('templetList')[0].templetid,
  66. });
  67. this.getList()
  68. let filtratelist = [{
  69. label: "部门",
  70. index: null,
  71. showName: "depname", //显示字段
  72. valueKey: "sa_saleareaid", //返回Key
  73. selectKey: "sa_saleareaid", //传参 代表选着字段 不传参返回整个选择对象
  74. value: "", //选中值
  75. type: 'multilevelClass',
  76. list: await _Http.basic({
  77. "id": 20230620102004,
  78. "content": {},
  79. }).then(res => {
  80. console.log("获取部门", res)
  81. return res.data.dep
  82. })
  83. }, {
  84. label: "医院类型",
  85. index: null,
  86. showName: "value", //显示字段
  87. valueKey: "type", //返回Key
  88. selectKey: "value", //传参 代表选着字段 不传参返回整个选择对象
  89. value: "", //选中值
  90. list: await getTypes('customertypemx')
  91. }, {
  92. label: "合作状态",
  93. index: null,
  94. showName: "value", //显示字段
  95. valueKey: "status", //返回Key
  96. selectKey: "value", //传参 代表选着字段 不传参返回整个选择对象
  97. value: "", //选中值
  98. list: [{
  99. value: "潜在"
  100. }, {
  101. value: "合作中"
  102. }, {
  103. value: "已终止"
  104. }, {
  105. value: "暂缓"
  106. }]
  107. }, {
  108. label: "成交状态",
  109. index: null,
  110. showName: "value", //显示字段
  111. valueKey: "tradingstatus", //返回Key
  112. selectKey: "value", //传参 代表选着字段 不传参返回整个选择对象
  113. value: "", //选中值
  114. list: [{
  115. value: "未成交"
  116. }, {
  117. value: "已成交"
  118. }, {
  119. value: "多次成交"
  120. }]
  121. }, {
  122. label: "标签",
  123. index: null,
  124. type: "checkbox",
  125. showName: "tag", //显示字段
  126. valueKey: "tag", //返回Key
  127. selectKey: "tag", //传参 代表选着字段 不传参返回整个选择对象
  128. value: "", //选中值
  129. list: await getTypes('tags')
  130. }]
  131. this.setData({
  132. filtratelist
  133. })
  134. },
  135. /* 处理筛选 */
  136. handleFilter({
  137. detail
  138. }) {
  139. detail.condition = this.data.content.where.condition;
  140. this.data.content.where = detail;
  141. this.getList(true);
  142. },
  143. getList(init = false) {
  144. _Http.init(this.data.content, init).then(content => {
  145. _Http.basic({
  146. "id": 20221012164402,
  147. content
  148. }).then(res => {
  149. console.log("客户列表", res)
  150. this.selectComponent('#ListBox').RefreshToComplete();
  151. if (res.code != '1') return wx.showToast({
  152. title: res.msg,
  153. icon: "none"
  154. })
  155. this.setData({
  156. loading: false,
  157. content: _Http.paging(content, res),
  158. list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data)
  159. })
  160. this.getTags();
  161. })
  162. })
  163. },
  164. /* 获取列表标签 */
  165. getTags() {
  166. let list = this.data.list,
  167. ownerids = list.map(v => v.sa_customersid)
  168. _Http.basic({
  169. "id": 20221018102001,
  170. "content": {
  171. "ownertable": "sa_customers",
  172. ownerids
  173. }
  174. }).then(res => {
  175. for (let key in res.data) {
  176. let index = list.findIndex(v => v.sa_customersid == key);
  177. list[index].tags = res.data[key]
  178. };
  179. this.setData({
  180. list
  181. })
  182. })
  183. },
  184. /* 顶部条件导航回调 */
  185. navClick({
  186. detail
  187. }) {
  188. switch (detail.id) {
  189. case '1':
  190. this.setData({
  191. classShow: true
  192. })
  193. break;
  194. case '2':
  195. this.setData({
  196. 'filterShow': true
  197. })
  198. break;
  199. case '3':
  200. this.setData({
  201. 'content.sort[0].reversed': this.data.content.sort[0].reversed == 0 ? 1 : 0
  202. });
  203. this.getList(true)
  204. break;
  205. default:
  206. break;
  207. }
  208. },
  209. /* 处理搜索 */
  210. onSearch({
  211. detail
  212. }) {
  213. this.data.content.where.condition = detail;
  214. this.getList(true);
  215. },
  216. classClose() {
  217. this.setData({
  218. classShow: false
  219. })
  220. },
  221. classSelect({
  222. detail
  223. }) {
  224. if (this.data.content.type == detail.index) return this.classClose();
  225. this.setData({
  226. "content.type": detail.index,
  227. 'navList[0].label': detail.name,
  228. classActions: this.data.classActions.map(v => {
  229. v.color = detail.i == v.i ? '#3874F6' : ''
  230. return v
  231. })
  232. })
  233. this.classClose();
  234. this.getList(true)
  235. }
  236. })