YXKHWGJTSFX.js 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. const _Http = getApp().globalData.http,
  2. currency = require("../../../utils/currency"),
  3. CNY = (value, symbol = "¥", precision = 2) => currency(value, {
  4. symbol,
  5. precision
  6. }).format();
  7. import * as echarts from '../../ec-canvas/echarts';
  8. Component({
  9. options: {
  10. addGlobalClass: true
  11. },
  12. lifetimes: {
  13. attached: function () {
  14. getApp().globalData.Language.getLanguagePackage(this)
  15. this.setData({
  16. "content.dataid": wx.getStorageSync('userMsg').userid,
  17. "content.username": wx.getStorageSync('userMsg').name,
  18. })
  19. }
  20. },
  21. data: {
  22. year: new Date().getFullYear().toString(),
  23. "content": {
  24. enddate: new Date().toISOString().split('T')[0],
  25. dateType: "15-30天",
  26. dataType: "",
  27. where: {
  28. dateType: "15-30天",
  29. type: "",
  30. tradingstatus: "",
  31. grade: "",
  32. },
  33. pageNumber: 1,
  34. pageSize: 20,
  35. pageTotal: 1
  36. },
  37. types: [],
  38. grades: [],
  39. tradingstatus: [{
  40. remarks: '全部',
  41. value: ''
  42. }, {
  43. remarks: '未成交',
  44. value: '未成交'
  45. }, {
  46. remarks: '已成交',
  47. value: '已成交'
  48. }, {
  49. remarks: '多次成交',
  50. value: '多次成交'
  51. }],
  52. },
  53. methods: {
  54. async getList(init = false) {
  55. if (this.data.grades.length == 0) {
  56. _Http.basic({
  57. "classname": "sysmanage.develop.optiontype.optiontype",
  58. "method": "optiontypeselect",
  59. "content": {
  60. "pageNumber": 1,
  61. "pageSize": 1000,
  62. "typename": "agentgrade",
  63. "parameter": {}
  64. },
  65. }).then(res => {
  66. console.log("客户分类", res)
  67. if (res.code == 1) {
  68. res.data.unshift({
  69. remarks: '全部',
  70. value: ''
  71. })
  72. this.setData({
  73. grades: res.data
  74. })
  75. }
  76. })
  77. }
  78. if (init.detail != undefined) init = init.detail;
  79. let content = this.data.content
  80. const {
  81. dataid,
  82. type,
  83. username,
  84. isleave
  85. } = getCurrentPages()[getCurrentPages().length - 1].data;
  86. if (content.dataid != dataid || content.type != type || isleave != isleave) init = true
  87. content.dataid = dataid;
  88. content.type = type;
  89. content.username = username;
  90. content.where.isleave = isleave;
  91. if (init) {
  92. content.pageNumber = 1;
  93. content.pageSize = 20;
  94. }
  95. if (content.pageNumber > content.pageTotal) return;
  96. _Http.basic({
  97. "id": 20231018093704,
  98. content
  99. }).then(res => {
  100. console.log("有效客户未跟进天数分析", res)
  101. this.selectComponent('#ListBox').automaticSetHei();
  102. this.selectComponent('#ListBox').RefreshToComplete();
  103. if (res.code != '1') return wx.showToast({
  104. title: res.data,
  105. icon: "none"
  106. })
  107. this.setData({
  108. list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
  109. "content.pageNumber": res.pageNumber + 1,
  110. "content.pageSize": res.pageSize,
  111. "content.pageTotal": res.pageTotal,
  112. "total": res.total,
  113. })
  114. try {
  115. this.selectAllComponents("#Filtrate").forEach(v => v.onCancel())
  116. } catch (error) {}
  117. if (init) _Http.basic({
  118. "id": 20231017162504,
  119. content
  120. }).then(res1 => {
  121. console.log("图标", res1)
  122. this.initChart(res1.data)
  123. })
  124. })
  125. },
  126. initChart(data) {
  127. let projecttype = [...new Set(data.map(v => getApp().globalData.Language.getMapText(v.key)))]
  128. let source = [
  129. ['product'].concat(projecttype),
  130. ];
  131. data.forEach(v => {
  132. if (!source.find(item => item[0] === getApp().globalData.Language.getMapText(v.datetype))) {
  133. source.push([getApp().globalData.Language.getMapText(v.datetype)])
  134. }
  135. let index = source.findIndex(item => item[0] === getApp().globalData.Language.getMapText(v.datetype));
  136. source[index].push(v.value);
  137. })
  138. if (this.data.types.length == 0) {
  139. let types = projecttype.map(v => {
  140. return {
  141. remarks: v,
  142. value: v,
  143. }
  144. })
  145. types.unshift({
  146. remarks: '全部',
  147. value: ''
  148. })
  149. this.setData({
  150. types
  151. })
  152. }
  153. let that = this,
  154. countDown = null,
  155. datetypes = [...new Set(data.map(v => v.datetype))];
  156. function changeDateType(params) {
  157. clearTimeout(countDown)
  158. countDown = setTimeout(() => {
  159. if (datetypes[params.dataIndex] === that.data.content.dateType) return;
  160. that.setData({
  161. "content.dateType": datetypes[params.dataIndex],
  162. "content.where.dateType": datetypes[params.dataIndex],
  163. "content.pageNumber": 1,
  164. })
  165. that.getList();
  166. }, 200)
  167. }
  168. let option = {
  169. legend: {
  170. type: 'scroll',
  171. orient: 'horizontal',
  172. top: 10
  173. },
  174. tooltip: {
  175. trigger: 'axis',
  176. axisPointer: {
  177. type: 'shadow'
  178. },
  179. formatter: function (params) {
  180. changeDateType(params[0]);
  181. let filteredParams = params.filter(item => item.value !== 0);
  182. if (filteredParams.length === 0) return '';
  183. let tooltipText = `${params[0].axisValue}\n`;
  184. filteredParams.forEach((item, index) => {
  185. if (item.value[index + 1] != 0) {
  186. tooltipText += `${item.marker} ${item.dimensionNames[index + 1]}: ${item.value[index + 1]}\n`;
  187. }
  188. });
  189. return tooltipText;
  190. }
  191. },
  192. dataset: {
  193. source
  194. },
  195. xAxis: {
  196. type: 'category',
  197. axisLabel: {
  198. interval: 0,
  199. rotate: 30
  200. }
  201. },
  202. yAxis: {
  203. type: 'value'
  204. },
  205. series: projecttype.map(() => ({
  206. type: 'bar',
  207. barMaxWidth: 30
  208. }))
  209. };
  210. this.chartComponent = this.selectComponent('#mychart');
  211. this.chartComponent.init((canvas, width, height, dpr) => {
  212. const chart = echarts.init(canvas, null, {
  213. width,
  214. height,
  215. devicePixelRatio: dpr
  216. });
  217. chart.setOption(option);
  218. return chart;
  219. });
  220. },
  221. changeDate({
  222. detail
  223. }) {
  224. this.setData({
  225. "content.enddate": detail
  226. })
  227. this.getList(true)
  228. },
  229. changeType1({
  230. detail
  231. }) {
  232. console.log(detail)
  233. this.setData({
  234. "content.where.tradingstatus": detail,
  235. })
  236. this.getList(true)
  237. },
  238. changeType2({
  239. detail
  240. }) {
  241. this.setData({
  242. "content.where.type": detail,
  243. })
  244. this.getList(true)
  245. },
  246. changeType3({
  247. detail
  248. }) {
  249. this.setData({
  250. "content.where.grade": detail,
  251. })
  252. this.getList(true)
  253. },
  254. }
  255. })