situationAnalysis.js 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. const _Http = getApp().globalData.http;
  2. import * as echarts from '../../ec-canvas/echarts';
  3. Component({
  4. properties: {
  5. idname: {
  6. type: [String || Number]
  7. }
  8. },
  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. dateTypes: ["全部", "本年"],
  23. "content": {
  24. pageNumber: 1,
  25. pageTotal: 1,
  26. dateType: "本年",
  27. type: 0,
  28. where: {
  29. begdate: "",
  30. enddate: "",
  31. isleave: "1",
  32. istask: ""
  33. }
  34. },
  35. filterShow: false,
  36. filtratelist: [{
  37. label: "项目状态",
  38. index: null,
  39. showName: "value", //显示字段
  40. valueKey: "status", //返回Key
  41. selectKey: "value", //传参 代表选着字段 不传参返回整个选择对象
  42. value: "", //选中值
  43. type: "checkbox",
  44. list: [{
  45. value: "跟进中"
  46. }, {
  47. value: "已成交"
  48. }, {
  49. value: "已失败"
  50. }, {
  51. value: "已结案"
  52. }]
  53. }]
  54. },
  55. methods: {
  56. async getList(init = false) {
  57. console.log(13123)
  58. if (init.detail != undefined) init = init.detail;
  59. let content = this.data.content
  60. const {
  61. dataid,
  62. type,
  63. username,
  64. isleave
  65. } = getCurrentPages()[getCurrentPages().length - 1].data;
  66. if (content.dataid != dataid || content.type != type || isleave != isleave) init = true
  67. content.dataid = dataid;
  68. content.type = type;
  69. content.username = username;
  70. content.where.isleave = isleave;
  71. if (init) {
  72. content.pageNumber = 1;
  73. content.pageTotal = 1;
  74. content.where.istask = "";
  75. }
  76. if (content.pageNumber > content.pageTotal) return;
  77. _Http.basic({
  78. "id": 20231019090104,
  79. content
  80. }).then(res => {
  81. this.selectComponent('#ListBox').RefreshToComplete();
  82. console.log('项目列表', res)
  83. if (res.code != '1') return wx.showToast({
  84. title: res.data,
  85. icon: "none"
  86. })
  87. this.setData({
  88. list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
  89. "content.pageNumber": res.pageNumber + 1,
  90. "content.pageSize": res.pageSize,
  91. })
  92. this.selectComponent("#TimeRange").onCancel()
  93. if (init) _Http.basic({
  94. id: this.data.idname,
  95. content
  96. }).then(res1 => {
  97. console.log("图标", res1)
  98. this.initChart(res1.data, res.total);
  99. })
  100. })
  101. },
  102. initChart(data, total) {
  103. const getMapText = getApp().globalData.Language.getMapText;
  104. let countDown = null,
  105. that = this;
  106. function changeUnwriteoffamounttype(index) {
  107. if (countDown) return;
  108. countDown = setTimeout(() => {
  109. clearTimeout(countDown)
  110. countDown = null;
  111. if (data[index].key != that.data.content.where.istask) that.setData({
  112. "content.where.istask": data[index].key || "",
  113. "content.pageNumber": 1,
  114. });
  115. that.getList()
  116. }, 200)
  117. };
  118. let option = {
  119. tooltip: {
  120. trigger: 'item',
  121. confine: true, // Ensure tooltip stays within chart boundaries
  122. formatter: function (params) {
  123. changeUnwriteoffamounttype(params.dataIndex)
  124. return `${getMapText(params.name)}: ${params.value} (${params.percent}%)`;
  125. },
  126. },
  127. legend: {
  128. type: 'scroll', // Enable scrollable legend
  129. bottom: '5%', // Moved legend to the bottom
  130. left: 'center',
  131. pageIconColor: '#333', // Customize page icon color
  132. pageTextStyle: {
  133. color: '#333' // Customize page text style
  134. }
  135. },
  136. series: [{
  137. type: 'pie',
  138. radius: ['40%', '70%'],
  139. center: ['50%', '42%'], // Adjusted to align with the new legend position
  140. endAngle: 360,
  141. data: data.map(v => {
  142. return {
  143. name: getMapText(v.key),
  144. value: (v.ratio).toFixed(2),
  145. }
  146. }),
  147. label: {
  148. normal: {
  149. show: true,
  150. position: 'outside',
  151. formatter: '{b}: {c} ({d}%)',
  152. textStyle: {
  153. fontSize: 12,
  154. color: '#333'
  155. }
  156. },
  157. emphasis: {
  158. show: true,
  159. textStyle: {
  160. fontSize: 14,
  161. fontWeight: 'bold'
  162. }
  163. },
  164. rich: {
  165. total: {
  166. fontSize: 20,
  167. fontWeight: 'bold',
  168. color: '#333'
  169. },
  170. desc: {
  171. fontSize: 12,
  172. color: '#999'
  173. }
  174. }
  175. },
  176. labelLine: {
  177. normal: {
  178. show: true,
  179. length: 10,
  180. length2: 10
  181. }
  182. }
  183. }]
  184. };
  185. option.graphic = {
  186. type: 'text',
  187. left: 'center',
  188. top: '35%', // Adjusted to align with the new series position
  189. style: {
  190. text: `${getMapText('项目总数')}\n\n${total}`,
  191. textAlign: 'center',
  192. fill: '#333',
  193. fontSize: 16,
  194. fontWeight: 'bold'
  195. }
  196. };
  197. this.chartComponent = this.selectComponent('#mychart');
  198. this.chartComponent.init((canvas, width, height, dpr) => {
  199. const chart = echarts.init(canvas, null, {
  200. width,
  201. height,
  202. devicePixelRatio: dpr
  203. });
  204. chart.setOption(option);
  205. return chart;
  206. });
  207. },
  208. upDateList() {
  209. _Http.updateList = () => {
  210. let content = JSON.parse(JSON.stringify(this.data.content));
  211. console.log("content", content)
  212. try {
  213. content.pageSize = (content.pageNumber - 1) * content.pageSize;
  214. content.pageNumber = 1;
  215. } catch (error) {
  216. console.log("error", error)
  217. }
  218. _Http.basic({
  219. id: '20231019090104',
  220. content
  221. }).then(res => {
  222. console.log("更新列表", res);
  223. if (res.code == '1') {
  224. this.setData({
  225. list: res.data
  226. })
  227. }
  228. })
  229. }
  230. },
  231. toDetail(e) {
  232. console.log(e)
  233. wx.navigateTo({
  234. url: '/packageA/project/detail?id=' + e.currentTarget.dataset.item.sa_projectid,
  235. })
  236. this.upDateList();
  237. },
  238. changeDate({
  239. detail
  240. }) {
  241. this.setData({
  242. "content.dateType": detail.dateType,
  243. "content.where.begdate": detail.begdate || "",
  244. "content.where.enddate": detail.enddate || ""
  245. })
  246. this.getList(true)
  247. },
  248. clickOpen() {
  249. this.setData({
  250. filterShow: true
  251. })
  252. },
  253. /* 处理筛选 */
  254. handleFilter({
  255. detail
  256. }) {
  257. if (detail.name == "confirm") {
  258. this.setData({
  259. "content.where.status": detail.status
  260. })
  261. this.selectComponent('#Filtrate').setShowArrText(detail.status)
  262. this.getList(true)
  263. } else if (detail.name == 'reset') {
  264. this.setData({
  265. "content.where.status": []
  266. })
  267. this.selectComponent('#Filtrate').setShowArrText([])
  268. this.getList(true)
  269. }
  270. },
  271. }
  272. })