index.js 70 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543
  1. // index.js
  2. // 获取应用实例
  3. import * as echarts from '../../ec-canvas/echarts' // 这个是自己实际的目录
  4. import {path} from '../../utils/circle';
  5. const app = getApp()
  6. Page({
  7. data: {
  8. showRight:false,
  9. polyline:[],
  10. tempList:[],
  11. hisLocal:[],
  12. ossPath: app.globalData.$filePath,
  13. title: '冷链追溯系统',
  14. token: '',
  15. mapCtx: '',
  16. latitude: '', //纬度
  17. longitude: '', //经度
  18. navbarData: {
  19. title: app.globalData.title,
  20. showCapsule: true,
  21. share: false
  22. },
  23. llzsEc: {
  24. lazyLoad: true,
  25. },
  26. tempList:[],
  27. Ec: {
  28. lazyLoad: true,
  29. },
  30. pieEc: {
  31. lazyLoad: true,
  32. },
  33. labelNum: {
  34. lazyLoad: true,
  35. },
  36. latitude: 40,
  37. longitude: 116,
  38. status: {
  39. checkedMap:true,
  40. statisticsInfo:true,
  41. statusLabelTest:true,
  42. statusLabelNum:true,
  43. statusLabelType:true,
  44. expressStatu:true,
  45. transportStatus:true,
  46. tempChart:true,
  47. onlineNum:true,
  48. packageStatu:true,
  49. onlineSituat:true,
  50. newSituat:true
  51. },
  52. CustomBar: app.globalData.CustomBar,
  53. StatusBar: app.globalData.StatusBar,
  54. systemMenu: [{
  55. menuName: '查一查',
  56. icon: '/img/idx_img2.png',
  57. path: 'find',
  58. },
  59. {
  60. menuName: '监测列表',
  61. icon: '/img/dev_img4.png',
  62. path: 'coldChain'
  63. },
  64. {
  65. menuName: '激活锁闭',
  66. icon: 'http://oss.zhongyihz.cn/group156/default/20220815/17/51/6/4dcc7eb59450f00227dd7e20380f9c94.png',
  67. path: 'onAndOff'
  68. },
  69. ],
  70. isAuth: false,
  71. modalHidden: true,
  72. scrollTop:0,//滚动监听
  73. // 沃森新
  74. cardIndex:0,
  75. tabLeftTop:[
  76. {name:'新冠',remark:'本公司现有100个产品温度正常温度不正常0个,原料辅料20种状态正常,产品有100种,所有产品状态全部正常'},
  77. {name:'肺炎',remark:'本公司现有100个产品温度正常温度不正常0个,原料辅料20种状态正常,产品有100种,所有产品状态全部正常'},
  78. {name:'流感',remark:'本公司现有100个产品温度正常温度不正常0个,原料辅料20种状态正常,产品有100种,所有产品状态全部正常'}
  79. ],
  80. tabLeftTop_remark:'本公司现有100个产品温度正常温度不正常0个,原料辅料20种状态正常,产品有100种,所有产品状态全部正常',
  81. orderCardList:[{city:'泰州市',used:50,stack: 2},{city:'北京市',used:50,stack: 2},{city:'西安市',used:50,stack: 2},{city:'天津市',stack: 2,used:50},{city:'廊坊市',stack: 2,used:50},{city:'广州市',used:50,stack: 2},{city:'郑州市',used:50,stack: 2}]
  82. },
  83. // 事件处理函数
  84. onLoad() {
  85. var that = this;
  86. if (!wx.getStorageSync('status')) {
  87. wx.setStorageSync('status', JSON.stringify(that.data.status));
  88. }
  89. },
  90. showRight(){
  91. this.setData({
  92. showRight:true,
  93. })
  94. },
  95. gopage1(){
  96. this.setData({
  97. showRight:false,
  98. },()=>{
  99. this.setCardLeft();
  100. })
  101. },
  102. onReady: function () {
  103. },
  104. onShow: function (options) {
  105. var that = this;
  106. var status = JSON.parse(wx.getStorageSync('status')) || '';
  107. var title = wx.getStorageSync('title') || ''
  108. var status =status ? status:that.data.status;
  109. title = title ? title : '冷链追溯系统'
  110. this.setData({
  111. status,
  112. title
  113. })
  114. //获取新闻
  115. this.getNewsList();
  116. // 加载
  117. this.setCardLeft();
  118. },
  119. setCardLeft(){
  120. var diagamList = [
  121. {name: "标签1",value: 0,unNormalTotal:0,symbolSize:40},
  122. {name: "标签2",value: 0,unNormalTotal:0,symbolSize:40},
  123. {name: "标签3",value: 1,unNormalTotal:2,symbolSize:40},
  124. {name: "标签4",value: 3,unNormalTotal:1,symbolSize:40},
  125. {name: "标签5",value: 3,unNormalTotal:1,symbolSize:40},
  126. ]
  127. this.setCardDiagram(diagamList);
  128. // this.setCardFivePie();
  129. this.setCardXuTuOption({normalTotal:15});
  130. // this.setCardFivePie_rght();
  131. var sixRightBarList = [{data:[120, 132, 101, 134, 90, 230, 210]},{data:[220, 182, 191, 234, 290, 330, 310]},{data:[150, 232, 201, 154, 190, 330, 410]}]
  132. this.setCardSixRightBar(sixRightBarList);
  133. var sevenCardPieList = [
  134. {data:[{ name: "标签1", value: 50 },{ name: "标签2", value: 20 },{ name: "标签3", value: 10 }]},
  135. {data:[{ name: "标签1", value: 50 },{ name: "标签2", value: 20 },{ name: "标签3", value: 10 }]},
  136. {data:[{ name: "标签1", value: 50 },{ name: "标签2", value: 20 },{ name: "标签3", value: 10 }]},
  137. {data:[{ name: "标签1", value: 50 },{ name: "标签2", value: 20 },{ name: "标签3", value: 10 }]},
  138. ]
  139. this.setSevenCardPie(sevenCardPieList);
  140. /**沃森新 */
  141. //获取token,若无则判定用户是游客访问,不进行任何请求
  142. var token = wx.getStorageSync('token');
  143. this.setData({
  144. token,
  145. tempList:[]
  146. })
  147. var that = this;
  148. if (!token) {
  149. setTimeout(function () {
  150. that.noLogin()
  151. }, 500)
  152. return;
  153. }
  154. // 主产品查询
  155. this.getsignProduct();
  156. //主产品使用、库存、总数统计
  157. this.getSignProductUseAndStackState();
  158. //单一主产品不同地区使用情况
  159. this.getSingleProductUseZoneStat();
  160. // 获取按钮
  161. this.getUserDefaultMenuList();
  162. // 图5 主产品在库、在途、结束统计
  163. this.getSignProductState();
  164. // 主产品正常、预警统计
  165. this.getSignPorductNormalWarningState();
  166. // 主产品使用量、生产量统计
  167. this.getSignProductUsedProduceState();
  168. // 主产品不同年度 使用量统计
  169. this.getSignPrroductYearUsedProduceState();
  170. // 主产品在不同地区库存、使用数据统计
  171. this.getSignProductCityState();
  172. // 主产品最近一周每一天的使用量统计
  173. this.getSignProductEveryWeekState();
  174. },
  175. getCysOrderOption(list){
  176. var fontSize=8;
  177. return {
  178. color:["#7190F6","#FF723A","#EA1C43"],
  179. title: {
  180. show:false
  181. },
  182. grid:{
  183. top:"5%",
  184. left:"8%",
  185. right:"5%",
  186. bottom:"14%",
  187. },
  188. xAxis: {
  189. type: 'category',
  190. axisTick:{show:false,},
  191. axisLine:{lineStyle:{color:"#DEE3FF",}},
  192. axisLabel:{color:"#999999", fontSize,interval: 0},
  193. data: list.map(item=>item.name),
  194. },
  195. yAxis: {
  196. type: 'value',
  197. splitLine:{lineStyle:{color:"#DEE3FF",}},
  198. axisLabel:{color:"#999999", fontSize,},
  199. },
  200. series: [
  201. {
  202. type: 'bar',
  203. barMaxWidth:30,
  204. barMinHeight:10,
  205. data: list.map(item=>item.orderNum),
  206. },
  207. ]
  208. }
  209. },
  210. setTemp(temperature) {
  211. var that = this;
  212. that.ecWen = that.selectComponent('#ecDomWen');
  213. that.ecWen.init((canvas, width, height, dpr) => {
  214. const chart = echarts.init(canvas, null, {
  215. width: width,
  216. height: height,
  217. devicePixelRatio: dpr // new
  218. });
  219. var option = that.getTempOption();
  220. option.xAxis.data = temperature.map(v => v.createTime.replace(" ", "\n"));
  221. option.series[0].data = temperature.map(v => v.temp);
  222. chart.setOption(option);
  223. that.wenChart = chart;
  224. return chart;
  225. });
  226. },
  227. showMap(markers) {
  228. var that = this;
  229. var token = wx.getStorageSync('token');
  230. this.mapCtx = wx.createMapContext('home_map');
  231. var points = []
  232. for (var i in markers) {
  233. if(i==0){
  234. points.push({
  235. width:35,
  236. height:35,
  237. latitude:Number(markers[i].lat),
  238. longitude:Number(markers[i].lng),
  239. iconPath:"/img/map_icon1.png",
  240. })
  241. }
  242. else if(i == markers.length-1){
  243. points.push({
  244. width:54,
  245. height:54,
  246. latitude:Number(markers[i].lat),
  247. longitude:Number(markers[i].lng),
  248. iconPath:"/img/index_icon_1000.png",
  249. })
  250. }
  251. markers[i].latitude = Number(markers[i].lat)
  252. markers[i].longitude = Number(markers[i].lng)
  253. delete markers[i].lat
  254. delete markers[i].lng
  255. }
  256. that.setData({
  257. markers:points,
  258. polyline: [{
  259. color: '#2D59E6',
  260. width: 2,
  261. points: markers,
  262. }],
  263. latitude:markers.length != 0 ? markers[0].latitude : '',
  264. longitude:markers.length != 0 ? markers[0].longitude : ''
  265. });
  266. that.mapCtx.includePoints({
  267. points: markers || [],
  268. padding: [50, 50, 50, 50]
  269. })
  270. },
  271. noLogin() {
  272. var temp = [
  273. {temp: '23.3',createTime: "2021-12-03 17:06:40"},
  274. {temp: '23.2', createTime: "2021-12-03 17:08:10"},
  275. {temp: '23.1', createTime: "2021-12-03 17:09:40"},
  276. {temp: '23.1', createTime: "2021-12-03 17:11:10"},
  277. {temp: '23.3', createTime: "2021-12-03 17:12:40"},
  278. {temp:' 23.2', createTime: "2021-12-03 17:14:10"},
  279. {temp: '23.3', createTime: "2021-12-03 17:15:40"},
  280. {temp: '23.3', createTime: "2021-12-03 17:18:40"},
  281. {temp: '23.2', createTime: "2021-12-03 17:26:10"},
  282. {temp: '23.2', createTime: "2021-12-03 17:32:10"}
  283. ]
  284. //设备定位列表
  285. var markerList = [{
  286. id: 1,
  287. lat: "49.828921",
  288. lng: "122.956163",
  289. lastTemp: 29.2,
  290. transportType: '10',
  291. status: '10',
  292. },
  293. {
  294. id: 2,
  295. lat: "39.898959",
  296. lng: "116.188584",
  297. lastTemp: 19.2,
  298. transportType: '40',
  299. status: '00',
  300. },
  301. {
  302. id: 3,
  303. lat: "29.828457",
  304. lng: "120.495225",
  305. lastTemp: 29.3,
  306. transportType: '40',
  307. status: '10',
  308. },
  309. {
  310. id: 4,
  311. lat: "21.358161",
  312. lng: "111.003038",
  313. lastTemp: 29.5,
  314. transportType: '30',
  315. status: '20',
  316. },
  317. {
  318. id: 5,
  319. lat: "38.948484",
  320. lng: "120.846788",
  321. lastTemp: 29.8,
  322. transportType: '20',
  323. status: '10',
  324. },
  325. {
  326. id: 6,
  327. lat: "33.785733",
  328. lng: "104.850694",
  329. lastTemp: 28.2,
  330. transportType: '10',
  331. status: '00',
  332. },
  333. {
  334. id: 7,
  335. lat: "29.225357",
  336. lng: "121.306968",
  337. lastTemp: 27.2,
  338. transportType: '30',
  339. status: '00',
  340. },
  341. ]
  342. this.showMap(markerList);
  343. this.setCard_top_right_butChart([
  344. {total:10,city:'河北省'},
  345. {total:25,city:'河南省'},
  346. {total:27,city:'广东省'},
  347. {total:32,city:'江苏省'},
  348. ])
  349. var klineList = [{
  350. maps:[{total:10,},{total:15,},{total:19,},{total:13,},{total:18,},],
  351. productInfo:{name:'阿莫西林'}
  352. },{
  353. maps:[{total:16,},{total:11,},{total:14,},{total:13,},{total:18,},],
  354. productInfo:{name:'红霉素'}
  355. },{
  356. maps:[{total:18,},{total:14,},{total:11,},{total:8,},{total:17,},],
  357. productInfo:{name:'新型冠状病毒疫苗'}
  358. }
  359. ];
  360. this.setKLine(klineList);
  361. this.setData({
  362. tempList:temp,
  363. },()=>{
  364. this.setTemp(temp);
  365. })
  366. this.setData({
  367. statisticSproductList:[
  368. {product_name: "阿莫西林",data:[{data: 1,index: 39,color:"#2D59E6"},{data:1,index:872,color:"#71CCFF"}]},
  369. {product_name: "红霉素",data:[{data:1,index: 266,color: "#2D59E6"},{data: 1,index: 862,color:"#71CCFF"}]},
  370. {product_name: "新型冠状病毒疫苗",data:[{data:10,index: 555, color: "#2D59E6"},{data:1,index:200,color:"#71CCFF"}]},
  371. ]
  372. },()=>{
  373. var list1 = this.data.statisticSproductList;
  374. for (let index = 0; index < list1.length; index++) {
  375. for (let lindex = 0; lindex < list1[index].data.length; lindex++) {
  376. var color = list1[index].data[lindex].color;
  377. var total = list1[index].data[lindex].data;
  378. var itemIndex = list1[index].data[lindex].index;
  379. this.setCardFivePie_rght(color,total,itemIndex);
  380. }
  381. }
  382. })
  383. const rawData = [
  384. ['2021/12/31', '25.8', '26.8', '-33.69', '-0.94%', '24.5', '27.2', '176963664', '25403106', '-'],
  385. ['2021/12/30', '28.2', '26.3', '9.14', '0.26%', '25', '27.3', '26778766', '26778766', '-'],
  386. ['2021/12/29', '32.4', '28.74', '29.96', '0.85%', '26.2', '28.2', '182551920', '25093890', '-'],
  387. ['2021/12/28', '36.3', '35.3', '-94.13', '-2.59%', '35.3', '36.4', '269983264', '36904280', '-'],
  388. ['2021/12/25', '36.1', '36.2', '15.43', '0.43%', '36', '36.35', '198451120', '27466004', '-'],
  389. ['2021/12/24', '36.3', '36.1', '-23.6', '-0.65%', '35.7', '36.4', '227785216', '31542126', '-'],
  390. ['2021/12/23', '36.5', '36.3', '-15.68', '-0.43%', '36.3', '36.8', '298201792', '41990292', '-'],
  391. ['2021/12/22', '36.4', '36.5', '9.3', '0.26%', '36.1', '36.5', '261178752', '36084604', '-'],
  392. ['2021/12/21', '35.6', '36.4', '63.51', '1.77%', '35.6', '36.50', '299849280', '39831696', '-'],
  393. ['2021/12/18', '35.70', '35.90', '-1.03', '-0.03%', '35.60', '36.10', '273707904', '36538580', '-'],
  394. ['2021/12/17', '35.30', '35.80', '63.81', '1.81%', '35.30', '35.80', '283856480', '38143960', '-'],
  395. ['2021/12/16', '35.20', '35.10', '5.83', '0.17%', '35.00', '35.30', '193482304', '26528864', '-'],
  396. ['2021/12/15', '35.18', '35.10', '-10.31', '-0.29%', '34.90', '35.20', '200471344', '27627494', '-'],
  397. ['2021/12/14', '34.00', '35.20', '86.09', '2.51%', '33.90', '35.20', '215374624', '27921354', '-'],
  398. ['2021/12/11', '34.40', '34.30', '-20.91', '-0.61%', '34.0', '34.50', '182908880', '24507642', '-'],
  399. ['2021/12/10', '34.60', '34.50', '-16.94', '-0.49%', '34.40', '35.0', '200427520', '27949970', '-'],
  400. ['2021/12/9', '34.60', '34.70', '2.37', '0.07%', '34.50', '34.90', '195698848', '26785488', '-'],
  401. ['2021/12/8', '35.10', '34.70', '-66.86', '-1.89%', '34.60', '35.10', '224367312', '29782174', '-'],
  402. ['2021/12/7', '35.20', '35.30', '11.94', '0.34%', '35.00', '35.40', '208302576', '28056158', '-'],
  403. ['2021/12/4', '35.50', '35.20', '-59.83', '-1.67%', '35.10', '35.60', '251736416', '31976682', '-'],
  404. ['2021/12/3', '35.20', '35.80', '47.92', '1.35%', '35.10', '35.90', '281111232', '33885908', '-'],
  405. ['2021/12/2', '34.50', '35.30', '80.6', '2.33%', '34.20', '35.30', '301491488', '36918304', '-'],
  406. ['2021/12/1', '34.40', '34.50', '10.9', '0.32%', '34.10', '34.80', '252390752', '33025674', '-']
  407. ];
  408. this.setEchartkline(rawData);
  409. //地区产品统计
  410. this.setCardLeftFive({
  411. name:['北京', '云南', '广州', '辽宁', '山东', '重庆'],
  412. data:[
  413. {name:'2022',data:[18203, 23489, 29034, 104970, 131744, 630230]},
  414. {name:'2012',data:[19325, 23438, 31000, 121594, 134141, 681807]},
  415. ]
  416. });
  417. const cardTwo_leftOne = [
  418. {stack: 0, end: 1, productName: "阿莫西林", trans: 0},
  419. {stack: 0, end: 1, productName: "红霉素", trans: 0},
  420. {stack: 0, end: 1, productName: "红霉素", trans: 0},
  421. ]
  422. this.setCard_two_left_one(cardTwo_leftOne);
  423. // 主产品正常、预警统计
  424. this.setCardEightBar([
  425. {normal: 1, warning: 0, product_name: "阿莫西林"},
  426. {normal: 0, warning: 1, product_name: "红霉素"},
  427. {normal: 1, warning: 9, product_name: "新型冠状病毒疫苗"}
  428. ]);
  429. var seriesSixBar = [
  430. {name: 2022, type: "line", stack: "Total",data:[1, 1, 6]},
  431. {name: 2021, type: "line", stack: "Total",data:[4, 0,0]},
  432. ]
  433. var cardSixLineList = ["阿莫西林", "红霉素", "新型冠状病毒疫苗"];
  434. this.setCardSixBar(seriesSixBar,cardSixLineList);
  435. //地区产品统计
  436. this.setCardLeftFive({
  437. name:['北京', '云南', '广州', '辽宁', '山东', '重庆'],
  438. data:[
  439. {name:'2022',data:[18203, 23489, 29034, 104970, 131744, 630230]},
  440. {name:'2012',data:[19325, 23438, 31000, 121594, 134141, 681807]},
  441. ]
  442. });
  443. },
  444. showMap1(markers) {
  445. var that = this;
  446. var token = wx.getStorageSync('token');
  447. this.mapCtx = wx.createMapContext('home_map');
  448. for (var i in markers) {
  449. markers[i].bId = markers[i].id
  450. markers[i].id = Number(i)
  451. markers[i].width = 54
  452. markers[i].height = 54
  453. markers[i].iconPath = "/img/index_icon_" + markers[i].transportType + '' + markers[i].status + ".png"
  454. markers[i].latitude = Number(markers[i].lat)
  455. markers[i].longitude = Number(markers[i].lng)
  456. delete markers[i].lat
  457. delete markers[i].lng
  458. }
  459. that.setData({
  460. markers,
  461. latitude:markers.length != 0 ? markers[0].latitude : '',
  462. longitude:markers.length != 0 ? markers[0].longitude : ''
  463. },()=>{
  464. if(markers.length!=0 && token){
  465. //地图数据加载完成后,获取第一条数据的详情
  466. that.getListChainTemperature(markers[0].bId);
  467. }else{
  468. var temp = [
  469. {temp: '23.3',createTime: "2021-12-03 17:06:40"},
  470. {temp: '23.2', createTime: "2021-12-03 17:08:10"},
  471. {temp: '23.1', createTime: "2021-12-03 17:09:40"},
  472. {temp: '23.1', createTime: "2021-12-03 17:11:10"},
  473. {temp: '23.3', createTime: "2021-12-03 17:12:40"},
  474. {temp:' 23.2', createTime: "2021-12-03 17:14:10"},
  475. {temp: '23.3', createTime: "2021-12-03 17:15:40"},
  476. {temp: '23.3', createTime: "2021-12-03 17:18:40"},
  477. {temp: '23.2', createTime: "2021-12-03 17:26:10"},
  478. {temp: '23.2', createTime: "2021-12-03 17:32:10"}
  479. ]
  480. that.setTemp(temp)
  481. }
  482. });
  483. that.mapCtx.includePoints({
  484. points: markers,
  485. padding: [50, 50, 50, 50]
  486. })
  487. },
  488. getMapInfo(e) {
  489. var that = this;
  490. var index = e.detail.markerId;
  491. if (that.data.token) {
  492. for (var i in that.data.markers) {
  493. if (that.data.markers[i].id == index) {
  494. return;
  495. }
  496. }
  497. } else {
  498. wx.navigateTo({
  499. url: '/pages/login/login',
  500. })
  501. }
  502. },
  503. onPageScroll:function(e){
  504. this.setData({
  505. scrollTop:e.scrollTop
  506. })
  507. },
  508. getList() {
  509. var that = this;
  510. app.requestP({
  511. url: '/index/listChainLocal',
  512. method: 'post',
  513. contentType: ' application/json'
  514. }).then(res => {
  515. var result = []
  516. res.data.data && res.data.data.map(item=>{
  517. if(item.lng != 0 && item.lat != 0){
  518. result.push(item)
  519. }
  520. })
  521. that.showMap(result);
  522. }).catch(err=>{
  523. app.showToptip(that,'error',err.data.msg)
  524. })
  525. },
  526. getTempOption() {
  527. return {
  528. title: {
  529. text: '温度:℃',
  530. textStyle: {
  531. color: '#999',
  532. fontSize: 6,
  533. }
  534. },
  535. grid: {
  536. top: "20%",
  537. left: "4%",
  538. right: "5%",
  539. bottom: "3%",
  540. containLabel: true
  541. },
  542. xAxis: {
  543. type: 'category',
  544. // boundaryGap: false,
  545. nameTextStyle: {
  546. color: "#77869E",
  547. fontSize: 4
  548. },
  549. axisLine: {
  550. onZero: false,
  551. lineStyle: {
  552. color: "#cccccc"
  553. }
  554. },
  555. axisTick: {
  556. show: false
  557. },
  558. splitLine: {
  559. show: false,
  560. },
  561. axisLabel: {
  562. show: true,
  563. textStyle: {
  564. color: '#999', //更改坐标轴文字颜色
  565. fontSize: 5, //更改坐标轴文字大小
  566. }
  567. },
  568. data: ['16:00 \n 2021-06-30', '16:00 \n 2021-06-30', '16:00 \n 2021-06-30', '16:00 \n 2021-06-30', '16:00 \n 2021-06-30', '16:00 \n 2021-06-30', '16:00 \n 2021-06-30'],
  569. // show: false
  570. },
  571. yAxis: {
  572. type: 'value',
  573. splitNumber: 10,
  574. max: 40,
  575. axisLine: {
  576. lineStyle: {
  577. color: "#cccccc",
  578. },
  579. show: true
  580. },
  581. axisLabel: {
  582. show: true,
  583. textStyle: {
  584. color: '#999', //更改坐标轴文字颜色
  585. fontSize: 5, //更改坐标轴文字大小
  586. }
  587. },
  588. splitLine: {
  589. show: false
  590. }
  591. },
  592. series: [{
  593. type: 'line',
  594. showSymbol: false,
  595. smooth: true,
  596. lineStyle: {
  597. width: 1,
  598. color: "#328EFD", //#D4D4D4
  599. },
  600. areaStyle: {
  601. origin: "start",
  602. color: {
  603. type: 'linear',
  604. x: 0,
  605. y: 0,
  606. x2: 0,
  607. y2: 1,
  608. colorStops: [{
  609. offset: 0,
  610. color: '#FFFFFF' //
  611. }, {
  612. offset: 1,
  613. color: '#4C96FE' //#D4D4D4
  614. }],
  615. global: false
  616. }
  617. },
  618. data: [18, 36, 25, 30, -20, 40, 33]
  619. }]
  620. }
  621. },
  622. setPieChart(temperature) {
  623. var that = this;
  624. var num = 0;
  625. var color = ['#45C2E0', '#C1EBDD', '#FFC851','#5A5476','#1869A0','#FF9393'];
  626. temperature.map(v => num += v.num);
  627. that.ecWen = that.selectComponent('#pieDom');
  628. that.ecWen.init((canvas, width, height, dpr) => {
  629. const chart = echarts.init(canvas, null, {
  630. width: width,
  631. height: height,
  632. devicePixelRatio: dpr
  633. });
  634. var option = that.getPieChartOption();
  635. option.color = color;
  636. option.series[0].data = temperature.map(v => {
  637. var per = v.num / num * 100;
  638. return {
  639. value:v.num,
  640. name: v.productTypeName+':'+ v.num + ' 占比' + per.toFixed(2) + '%'
  641. }
  642. });
  643. chart.setOption(option);
  644. that.wenChart = chart;
  645. return chart;
  646. });
  647. },
  648. getPieChartOption() {
  649. return {
  650. legend: {
  651. top: 'bottom',
  652. show: false,
  653. },
  654. grid: {
  655. left: '0%',
  656. right: '0%',
  657. bottom: '3%',
  658. containLabel: true
  659. },
  660. // color:['#45C2E0', '#C1EBDD', '#FFC851','#5A5476','#1869A0','#FF9393'],
  661. series: [{
  662. type: 'pie',
  663. radius: [30, 60],
  664. center: ['50%', '50%'],
  665. itemStyle: {
  666. normal: {
  667. label: {
  668. formatter: function (v) {
  669. //文字中遇到空格就换行
  670. let text = v.name.split(" ").join("\n");
  671. return text;
  672. },
  673. show: true,
  674. },
  675. labelLine: {
  676. show: true,
  677. color:''
  678. }
  679. },
  680. },
  681. emphasis: {
  682. itemStyle: {
  683. shadowBlur: 10,
  684. shadowOffsetX: 0,
  685. shadowColor: 'rgba(0, 0, 0, 0.5)'
  686. },
  687. },
  688. data: [{
  689. value: 40,
  690. itemStyle:{
  691. normal:{
  692. color:'#45C2E0'
  693. }
  694. }
  695. },
  696. {
  697. value: 38,
  698. },
  699. {
  700. value: 32,
  701. },
  702. {
  703. value: 30,
  704. },
  705. ]
  706. }]
  707. }
  708. },
  709. setMapCenter() {
  710. var that = this;
  711. var locations = that.data.markers;
  712. that.mapCtx.includePoints({
  713. points: locations,
  714. padding: [50, 50, 50, 50]
  715. })
  716. },
  717. getUserInfo() {
  718. var that = this;
  719. app.requestP({
  720. method: "post",
  721. url: "/user/getUserInfo",
  722. }).then(function (res) {
  723. var userId = res.data.data.userId;
  724. // that.getProductChipState();
  725. }).catch(err => {
  726. app.showToptip(that, 'error', '请刷新重试');
  727. })
  728. },
  729. packageInfo(){
  730. var token = wx.getStorageSync('token');
  731. if(!token){
  732. wx.navigateTo({
  733. url: '/pages/login/login',
  734. })
  735. return;
  736. }
  737. var packageList = JSON.stringify(this.data.packageList);
  738. wx.navigateTo({
  739. url: '/pages/index/packageInfo/packageinfo?list=' + packageList,
  740. })
  741. },
  742. getNewsList() {
  743. var that = this;
  744. app.requestP({
  745. url: '/query/news',
  746. method: 'post',
  747. needToken: false,
  748. data: {
  749. keyword: '',
  750. pageNum: '1',
  751. pageSize: '5'
  752. }
  753. }).then(res => {
  754. that.setData({
  755. newsList: res.data.data.map(item => {
  756. return {
  757. ...item,
  758. createTime: item.createTime.substring(item.createTime.length - 8)
  759. }
  760. })
  761. })
  762. }).catch(err => {
  763. app.showToptip(that, 'error', err.data.msg)
  764. })
  765. },
  766. goNewsInfo(e) {
  767. var id = e.currentTarget.dataset.id;
  768. wx.navigateTo({
  769. url: '/pages/index/newsInfo/newsInfo?id=' + id,
  770. })
  771. },
  772. goNewsList() {
  773. wx.navigateTo({
  774. url: '/pages/index/newList/newList',
  775. })
  776. },
  777. getUserDefaultMenuList() {
  778. var that = this;
  779. app.requestP({
  780. url: '/userDeaultMenu/list',
  781. method: 'post',
  782. }).then(res => {
  783. that.setData({
  784. systemMenu: res.data.data
  785. })
  786. }).catch(err => {
  787. app.showToptip(that, 'error', err.data.msg)
  788. })
  789. },
  790. tapMenu(e) {
  791. let type = e.currentTarget.dataset.type
  792. let path = e.currentTarget.dataset.path;
  793. //判断token,若有则假设已经登录
  794. if (!wx.getStorageSync('token')) {
  795. wx.redirectTo({
  796. url: '/pages/login/login',
  797. })
  798. return;
  799. }
  800. //获取用户信息,判断userInfo是否过期
  801. let userInfo = wx.getStorageSync('userInfo');
  802. const {
  803. loginRole,
  804. ifOverFlow,
  805. status
  806. } = userInfo;
  807. // this.matchPage(loginRole, ifOverFlow, status, path);
  808. app.globalData.tabarData = {loginRole, ifOverFlow, status, path};
  809. wx.switchTab({
  810. url: '/pages/workbench/workbench',
  811. })
  812. },
  813. goMessage:function(){
  814. if(this.data.token){
  815. wx.navigateTo({
  816. url: '/pages/news/newList',
  817. })
  818. }else{
  819. wx.redirectTo({
  820. url: '/pages/login/login',
  821. })
  822. }
  823. },
  824. // 沃森新
  825. // 主产品查询
  826. getsignProduct(){
  827. app.requestP({
  828. url: '/daping/signProduct',
  829. method: 'post',
  830. }).then(res => {
  831. this.setData({
  832. tabLeftTop:res.data.data
  833. })
  834. }).catch(err => {
  835. app.showToptip(this,'err',err.data.msg)
  836. })
  837. },
  838. // 主产品使用、库存、总数统计
  839. getSignProductUseAndStackState(){
  840. app.requestP({
  841. url: '/daping/signProductUseAndStackState',
  842. method: 'post',
  843. }).then(res => {
  844. this.setPie4Chart(res.data.data)
  845. }).catch(err => {
  846. app.showToptip(this,'err',err.data.msg)
  847. })
  848. },
  849. setCard(e){
  850. var index = e.currentTarget.dataset.index;
  851. this.setData({
  852. cardIndex:index,
  853. // tabLeftTop_remark:this.data.tabLfeftTop[index].remark
  854. })
  855. },
  856. //单一主产品不同地区使用情况
  857. getSingleProductUseZoneStat(){
  858. app.requestP({
  859. url: '/daping/singleProductUseZoneState',
  860. method: 'post',
  861. }).then(res=>{
  862. this.setCard_top_right_butChart(res.data.data);
  863. }).catch(err=>{
  864. app.showToptip(this,'err',err.data.msg)
  865. })
  866. },
  867. setPie4Chart(list){
  868. var that = this;
  869. var series = [];
  870. list.map((item,index)=>{
  871. series.push(...that.pice4Chart("#23D9E9",index == 0 ? "20%" :index == 1 ? '50%':'80%',item.total,item.use_num,item.stack_num,item.name,'45%',))
  872. });
  873. that.pie4ChartConDom = that.selectComponent('#pie4ChartConDom');
  874. that.pie4ChartConDom.init((canvas, width, height, dpr) => {
  875. const chart = echarts.init(canvas, null, {
  876. width: width,
  877. height: height,
  878. devicePixelRatio: dpr
  879. });
  880. chart.setOption({
  881. title: {
  882. show:false
  883. },
  884. grid:{
  885. top:"0%",
  886. left:"0%",
  887. right:"0%",
  888. bottom:"0%",
  889. },
  890. color: ["red", "rgb(10,92,170)", "rgb(114,205,255)"],
  891. legend: {
  892. icon:"rect",
  893. top:10,
  894. right:0,
  895. itemWidth:20,
  896. itemHeight:20,
  897. textStyle:{
  898. fontSize:16,
  899. color: "#D1E9F5",
  900. },
  901. },
  902. series:series,
  903. });
  904. return chart;
  905. })
  906. },
  907. pice4Chart(color,pos,total,use_num,stack_num,name,top){
  908. var that = this;
  909. var placeHolderStyle = {
  910. normal: {
  911. label: {
  912. show: false,
  913. formatter: function (v) {
  914. //文字中遇到空格就换行
  915. let text = v.value;
  916. return text;
  917. },
  918. },
  919. labelLine: {
  920. show: true,
  921. },
  922. },
  923. };
  924. const pieValue1 = {
  925. value1:(stack_num+use_num) / total,
  926. value2: 1 - (stack_num+use_num) / total
  927. };
  928. const pieValue2 = {
  929. value1:use_num / total,
  930. value2:1 - use_num / total
  931. };
  932. const pieValue3 = {
  933. value1: stack_num / total,
  934. value2: 1 - stack_num / total
  935. };
  936. return [{
  937. type: "pie",
  938. clockWise: true, //顺时加载
  939. hoverAnimation: false, //鼠标移入变大
  940. silent:false,
  941. radius: [20, 23],
  942. center: [pos, top],
  943. itemStyle: placeHolderStyle,
  944. data: [
  945. {
  946. value: pieValue1.value1,
  947. itemStyle:{
  948. normal:{
  949. color:'#0e74ff'
  950. }
  951. }
  952. },
  953. {
  954. value: pieValue1.value2,
  955. itemStyle:{
  956. normal:{
  957. color:"rgb(243,243,251)"
  958. }
  959. }
  960. }
  961. ],
  962. },{
  963. type: "pie",
  964. clockWise: true, //顺时加载
  965. hoverAnimation: false, //鼠标移入变大
  966. radius: [15, 18],
  967. silent:false,
  968. center: [pos, top],
  969. itemStyle: placeHolderStyle,
  970. data: [
  971. {
  972. value: pieValue2.value1,
  973. itemStyle:{
  974. normal:{
  975. color:'#64a6ff'
  976. }
  977. }
  978. },
  979. {
  980. value: pieValue2.value2,
  981. itemStyle:{
  982. normal:{
  983. color:"rgb(243,243,251)"
  984. }
  985. }
  986. }
  987. ],
  988. },
  989. {
  990. type: "pie",
  991. clockWise: true, //顺时加载
  992. hoverAnimation: false, //鼠标移入变大
  993. silent:false,
  994. radius: [10, 13],
  995. center: [pos, top],
  996. itemStyle: placeHolderStyle,
  997. data: [
  998. {
  999. value: pieValue3.value1,
  1000. itemStyle:{
  1001. normal:{
  1002. color:'red'
  1003. }
  1004. }
  1005. },
  1006. {
  1007. value: pieValue3.value2,
  1008. itemStyle:{
  1009. normal:{
  1010. color:"rgb(243,243,251)"
  1011. }
  1012. }
  1013. }
  1014. ],
  1015. }]
  1016. },
  1017. setCard_top_right_butChart(list){
  1018. var that = this;
  1019. that.selectComponent('#cardBarChartConDom').init((canvas, width, height, dpr) => {
  1020. const chart = echarts.init(canvas, null, {
  1021. width: width,
  1022. height: height,
  1023. devicePixelRatio: dpr
  1024. });
  1025. list = list.map(item=>{
  1026. return {orderNum:item.total,name:item.city || 'N/A'}
  1027. })
  1028. var option = that.getCysOrderOption(list);
  1029. option.series = [{
  1030. type:'bar',
  1031. barMaxWidth: 15,
  1032. barMinHeight: 10,
  1033. data:list.map(item=>item.orderNum),
  1034. label: {
  1035. show: true,
  1036. position: 'inside'
  1037. },
  1038. itemStyle:{
  1039. normal:{color:'#333FFF'}
  1040. }
  1041. }]
  1042. chart.setOption(option);
  1043. return chart;
  1044. });
  1045. },
  1046. // 图5 主产品在库、在途、结束统计
  1047. getSignProductState(){
  1048. app.requestP({
  1049. url: '/daping/signProductState',
  1050. method: 'post',
  1051. }).then(res=>{
  1052. this.setCard_two_left_one(res.data.data);
  1053. }).catch(err=>{
  1054. app.showToptip(this,'err',err.data.msg)
  1055. })
  1056. },
  1057. setCard_two_left_one(list){
  1058. var that = this;
  1059. that.selectComponent('#product_two_left_one').init((canvas, width, height, dpr) => {
  1060. const chart = echarts.init(canvas, null, {
  1061. width: width,
  1062. height: height,
  1063. devicePixelRatio: dpr
  1064. });
  1065. var option = that.getStaticBarChart();
  1066. option.legend = {
  1067. data:['在库','在途','结束'],
  1068. icon:"circle",
  1069. top:"2%",
  1070. right:"auto",
  1071. itemWidth:8,
  1072. itemHeight:8,
  1073. textStyle:{
  1074. fontSize:8,
  1075. color:'#485465',
  1076. },
  1077. }
  1078. option.color = ['#2D59E6','#FFAF36','#7FD1FF']
  1079. option.grid.top='20%';
  1080. option.grid.bottom='13%';
  1081. option.series = [];
  1082. option.xAxis.data = [];
  1083. const echartsData = [
  1084. {name:'在库',data:list.map(item=>item.stack)},
  1085. {name:'结束',data:list.map(item=>item.end)},
  1086. {name:'在途',data:list.map(item=>item.trans)}
  1087. ]
  1088. option.xAxis.data = list.map(item=>item.productName);
  1089. echartsData.map((item,index)=>{
  1090. option.series.push({
  1091. name:item.name,
  1092. type: "bar",
  1093. stack: "Ad",
  1094. emphasis: {
  1095. focus: "series",
  1096. },
  1097. data:item.data
  1098. })
  1099. })
  1100. chart.setOption(option);
  1101. return chart;
  1102. })
  1103. },
  1104. product_two_left_two(list){
  1105. var that = this;
  1106. that.selectComponent('#product_two_left_two').init((canvas, width, height, dpr) => {
  1107. const chart = echarts.init(canvas, null, {
  1108. width: width,
  1109. height: height,
  1110. devicePixelRatio: dpr
  1111. });
  1112. var option = this.getStaticBarChart();
  1113. option.series = [];
  1114. option.legend = {
  1115. data:list.map(item=>item.name),
  1116. icon:"circle",
  1117. top:"2%",
  1118. right:"auto",
  1119. itemWidth:8,
  1120. itemHeight:8,
  1121. textStyle:{
  1122. fontSize:8,
  1123. color:'#485465',
  1124. },
  1125. }
  1126. option.grid.top='20%';
  1127. option.grid.bottom='13%';
  1128. list.map((item,index)=>{
  1129. option.series.push({
  1130. name:item.name,
  1131. type: index != list.length -1 ? 'bar' :'line',
  1132. // yAxisIndex: 1,
  1133. data:item.data
  1134. });
  1135. // if(index != list.length-1){
  1136. // delete option.series[index].yAxisIndex;
  1137. // }
  1138. })
  1139. chart.setOption(option);
  1140. return chart;
  1141. })
  1142. },
  1143. getStaticBarChart(){
  1144. return {
  1145. xAxis: {
  1146. type: "category",
  1147. axisTick:{show:false,},
  1148. nameTextStyle: {
  1149. color: "#77869E",
  1150. fontSize: 8,
  1151. },
  1152. axisLabel: {
  1153. color: '#999999',
  1154. fontSize: 8,
  1155. },
  1156. axisLine: {
  1157. onZero: false,
  1158. lineStyle: {
  1159. color: "#cccccc",
  1160. },
  1161. },
  1162. data: ["Mon", "Tue", "Wed", "Thu",],
  1163. },
  1164. yAxis: {
  1165. type: "value",
  1166. minInterval: 1,
  1167. axisLine: {
  1168. lineStyle: {
  1169. color: "#cccccc",
  1170. },
  1171. show: false,
  1172. },
  1173. axisLabel: {
  1174. color: "#999999",
  1175. fontSize: 8,
  1176. },
  1177. },
  1178. color: ["#7661FF", "#5AC8FA", "#00B972"],
  1179. grid: {
  1180. left: "3%",
  1181. top: "8%",
  1182. right: "4%",
  1183. bottom: "3%",
  1184. containLabel: true,
  1185. },
  1186. series: [
  1187. {
  1188. data: [120, 200, 150, 80, 70, 110, 130, 110],
  1189. type: "bar",
  1190. },
  1191. ],
  1192. };
  1193. },
  1194. setCardPieTwo(list){
  1195. var that = this;
  1196. that.selectComponent('#product_three_left_one').init((canvas, width, height, dpr) => {
  1197. const chart = echarts.init(canvas, null, {
  1198. width: width,
  1199. height: height,
  1200. devicePixelRatio: dpr
  1201. });
  1202. var option = this.getStaticPieChart();
  1203. var itemStyle = {
  1204. normal: {
  1205. label: {
  1206. show: true,
  1207. formatter: function (v) {
  1208. //文字中遇到空格
  1209. let text = v.name+'\n'+v.value;
  1210. return text;
  1211. },
  1212. },
  1213. labelLine: {
  1214. show: true,
  1215. length:4,
  1216. length2:4,
  1217. },
  1218. },
  1219. }
  1220. option.series = [
  1221. {
  1222. type: "pie",
  1223. radius: "40%",
  1224. center: ["50%", "25%"],
  1225. itemStyle,
  1226. label: {
  1227. position: "inside",
  1228. formatter: "{d}%",
  1229. fontSize: 8,
  1230. color: '#fff',
  1231. },
  1232. data: [
  1233. { name: "标签1", value: 50 },
  1234. { name: "标签2", value: 20 },
  1235. { name: "标签3", value: 10 },
  1236. ],
  1237. },
  1238. {
  1239. type: "pie",
  1240. radius: "40%",
  1241. center: ["50%", "75%"],
  1242. percentPrecision:0,
  1243. minShowLabelAngle:30,
  1244. itemStyle,
  1245. label: {
  1246. position: "inside",
  1247. formatter: "{d}%",
  1248. fontSize: 8,
  1249. color: '#fff',
  1250. },
  1251. data: [
  1252. { name: "标签1", value: 50 },
  1253. { name: "标签2", value: 20 },
  1254. { name: "标签3", value: 10 },
  1255. ],
  1256. },
  1257. ]
  1258. chart.setOption(option);
  1259. return chart;
  1260. })
  1261. },
  1262. getStaticPieChart(){
  1263. return {
  1264. color: ["#964CC4", "#04A3CC", "#3B6AD5"],
  1265. title: {
  1266. show: false,
  1267. },
  1268. grid: {
  1269. top: "12%",
  1270. left: "5%",
  1271. right: "5%",
  1272. bottom: "12%",
  1273. },
  1274. series: [
  1275. // {
  1276. // type: "pie",
  1277. // radius: "50%",
  1278. // center: ["50%", "25%"],
  1279. // label: {
  1280. // position: "inside",
  1281. // formatter: "{d}%",
  1282. // fontSize: 8,
  1283. // color: '#fff',
  1284. // },
  1285. // data: [
  1286. // { name: "在途", value: 50 },
  1287. // { name: "完成", value: 20 },
  1288. // { name: "待发运", value: 10 },
  1289. // ],
  1290. // },
  1291. // {
  1292. // type: "pie",
  1293. // radius: "50%",
  1294. // center: ["50%", "75%"],
  1295. // percentPrecision:0,
  1296. // minShowLabelAngle:30,
  1297. // label: {
  1298. // position: "inside",
  1299. // formatter: "{d}%",
  1300. // fontSize: 8,
  1301. // color: '#fff',
  1302. // },
  1303. // data: [
  1304. // { name: "在途", value: 50 },
  1305. // { name: "完成", value: 20 },
  1306. // { name: "待发运", value: 10 },
  1307. // ],
  1308. // },
  1309. ]
  1310. }
  1311. },
  1312. setCardFivePie(){
  1313. var that = this;
  1314. that.selectComponent('#product_five_left_one').init((canvas, width, height, dpr) => {
  1315. const chart = echarts.init(canvas, null, {
  1316. width: width,
  1317. height: height,
  1318. devicePixelRatio: dpr
  1319. });
  1320. var option = this.getStaticPieChart();
  1321. option.color = ['rgb(91,132,206)','rgb(127,210,255)','rgb(44,87,226)'];
  1322. var itemStyle = {
  1323. normal: {
  1324. label: {
  1325. show: false,
  1326. formatter: function (v) {
  1327. //文字中遇到空格
  1328. let text = v.name+'\n'+v.value;
  1329. return text;
  1330. },
  1331. },
  1332. labelLine: {
  1333. show: true,
  1334. length:4,
  1335. length2:4,
  1336. },
  1337. },
  1338. }
  1339. option.series = [
  1340. {
  1341. type: "pie",
  1342. radius: "80%",
  1343. center: ["50%", "30%"],
  1344. itemStyle,
  1345. label: {
  1346. position: "inside",
  1347. formatter: "{d}%",
  1348. fontSize: 8,
  1349. color: '#fff',
  1350. },
  1351. data: [
  1352. { name: "标签1", value: 50 },
  1353. { name: "标签2", value: 20 },
  1354. { name: "标签3", value: 10 },
  1355. ],
  1356. },
  1357. {
  1358. type: "pie",
  1359. radius: "80%",
  1360. center: ["50%", "53%"],
  1361. itemStyle,
  1362. data: [
  1363. { name: "标签1", value: 50 },
  1364. { name: "标签2", value: 20 },
  1365. { name: "标签3", value: 10 },
  1366. ],
  1367. },
  1368. {
  1369. type: "pie",
  1370. radius: "80%",
  1371. itemStyle,
  1372. center: ["50%", "77%"],
  1373. data: [
  1374. { name: "标签1", value: 50 },
  1375. { name: "标签2", value: 20 },
  1376. { name: "标签3", value: 10 },
  1377. ],
  1378. },
  1379. ]
  1380. option.grid = {
  1381. top: "12%",
  1382. left: "10%",
  1383. right: "0%",
  1384. bottom: "12%",
  1385. },
  1386. chart.setOption(option);
  1387. return chart;
  1388. })
  1389. },
  1390. setCard3dBar(){
  1391. var that = this;
  1392. that.selectComponent('#product_three_left_two').init((canvas, width, height, dpr) => {
  1393. const chart = echarts.init(canvas, null, {
  1394. width: width,
  1395. height: height,
  1396. devicePixelRatio: dpr
  1397. });
  1398. var data = [[0, 0, 5], [0, 1, 1], [0, 2, 0], [0, 3, 0], [0, 4, 0], [0, 5, 0], [0, 6, 0], [0, 7, 0], [0, 8, 0], [0, 9, 0], [0, 10, 0], [0, 11, 2], [0, 12, 4], [0, 13, 1], [0, 14, 1], [0, 15, 3], [0, 16, 4], [0, 17, 6], [0, 18, 4], [0, 19, 4], [0, 20, 3], [0, 21, 3], [0, 22, 2], [0, 23, 5], [1, 0, 7], [1, 1, 0], [1, 2, 0], [1, 3, 0], [1, 4, 0], [1, 5, 0], [1, 6, 0], [1, 7, 0], [1, 8, 0], [1, 9, 0], [1, 10, 5], [1, 11, 2], [1, 12, 2], [1, 13, 6], [1, 14, 9], [1, 15, 11], [1, 16, 6], [1, 17, 7], [1, 18, 8], [1, 19, 12], [1, 20, 5], [1, 21, 5], [1, 22, 7], [1, 23, 2], [2, 0, 1], [2, 1, 1], [2, 2, 0], [2, 3, 0], [2, 4, 0], [2, 5, 0], [2, 6, 0], [2, 7, 0], [2, 8, 0], [2, 9, 0], [2, 10, 3], [2, 11, 2], [2, 12, 1], [2, 13, 9], [2, 14, 8], [2, 15, 10], [2, 16, 6], [2, 17, 5], [2, 18, 5], [2, 19, 5], [2, 20, 7], [2, 21, 4], [2, 22, 2], [2, 23, 4], [3, 0, 7], [3, 1, 3], [3, 2, 0], [3, 3, 0], [3, 4, 0], [3, 5, 0], [3, 6, 0], [3, 7, 0], [3, 8, 1], [3, 9, 0], [3, 10, 5], [3, 11, 4], [3, 12, 7], [3, 13, 14], [3, 14, 13], [3, 15, 12], [3, 16, 9], [3, 17, 5], [3, 18, 5], [3, 19, 10], [3, 20, 6], [3, 21, 4], [3, 22, 4], [3, 23, 1], [4, 0, 1], [4, 1, 3], [4, 2, 0], [4, 3, 0], [4, 4, 0], [4, 5, 1], [4, 6, 0], [4, 7, 0], [4, 8, 0], [4, 9, 2], [4, 10, 4], [4, 11, 4], [4, 12, 2], [4, 13, 4], [4, 14, 4], [4, 15, 14], [4, 16, 12], [4, 17, 1], [4, 18, 8], [4, 19, 5], [4, 20, 3], [4, 21, 7], [4, 22, 3], [4, 23, 0], [5, 0, 2], [5, 1, 1], [5, 2, 0], [5, 3, 3], [5, 4, 0], [5, 5, 0], [5, 6, 0], [5, 7, 0], [5, 8, 2], [5, 9, 0], [5, 10, 4], [5, 11, 1], [5, 12, 5], [5, 13, 10], [5, 14, 5], [5, 15, 7], [5, 16, 11], [5, 17, 6], [5, 18, 0], [5, 19, 5], [5, 20, 3], [5, 21, 4], [5, 22, 2], [5, 23, 0], [6, 0, 1], [6, 1, 0], [6, 2, 0], [6, 3, 0], [6, 4, 0], [6, 5, 0], [6, 6, 0], [6, 7, 0], [6, 8, 0], [6, 9, 0], [6, 10, 1], [6, 11, 0], [6, 12, 2], [6, 13, 1], [6, 14, 3], [6, 15, 4], [6, 16, 0], [6, 17, 0], [6, 18, 0], [6, 19, 0], [6, 20, 1], [6, 21, 2], [6, 22, 2], [6, 23, 6]]
  1399. chart.setOption({
  1400. tooltip: {},
  1401. xAxis3D: {
  1402. type: 'category',
  1403. data: ['12a', '1a', '2a', '3a', '4a', '5a', '6a','7a', '8a', '9a', '10a', '11a','12p', '1p', '2p', '3p', '4p', '5p','6p', '7p', '8p', '9p', '10p', '11p']
  1404. },
  1405. yAxis3D: {
  1406. type: 'category',
  1407. data: ['Saturday', 'Friday', 'Thursday','Wednesday', 'Tuesday', 'Monday', 'Sunday']
  1408. },
  1409. zAxis3D: {
  1410. type: 'value'
  1411. },
  1412. grid3D: {
  1413. boxWidth: 200,
  1414. boxDepth: 80,
  1415. viewControl: {
  1416. // projection: 'orthographic'
  1417. },
  1418. light: {
  1419. main: {
  1420. intensity: 1.2,
  1421. shadow: true
  1422. },
  1423. ambient: {
  1424. intensity: 0.3
  1425. }
  1426. }
  1427. },
  1428. series: [
  1429. {
  1430. type: 'bar3D',
  1431. data: data.map(function (item) {
  1432. return {
  1433. value: [item[1], item[0], item[2]]
  1434. };
  1435. }),
  1436. shading: 'lambert',
  1437. label: {
  1438. fontSize: 16,
  1439. borderWidth: 1
  1440. },
  1441. emphasis: {
  1442. label: {
  1443. fontSize: 20,
  1444. color: '#900'
  1445. },
  1446. itemStyle: {
  1447. color: '#900'
  1448. }
  1449. }
  1450. }
  1451. ]
  1452. });
  1453. return chart;
  1454. })
  1455. },
  1456. setKLine(list){
  1457. var that = this;
  1458. that.selectComponent('#product_four').init((canvas, width, height, dpr) => {
  1459. const chart = echarts.init(canvas, null, {
  1460. width: width,
  1461. height: height,
  1462. devicePixelRatio: dpr
  1463. });
  1464. var option = that.getStaticBarChart();
  1465. option.color = ['#2D59E6','#FFAF36','#7FD1FF']
  1466. option.grid.top='20%';
  1467. option.grid.bottom='13%';
  1468. option.series = [];
  1469. option.xAxis.data = [];
  1470. const echartsData = [];
  1471. list.map(item=>{
  1472. echartsData.push({
  1473. name:item.productInfo.name,data:item.maps.map(itemChild=>itemChild.total)
  1474. })
  1475. })
  1476. option.xAxis.data = list.map(item=>item.productInfo.name);
  1477. echartsData.map((item,index)=>{
  1478. option.series.push({
  1479. name:item.name,
  1480. type: "bar",
  1481. stack: "Ad",
  1482. barMaxWidth: 25,
  1483. // barMinHeight: 10,
  1484. emphasis: {
  1485. focus: "series",
  1486. },
  1487. data:item.data
  1488. })
  1489. })
  1490. chart.setOption(option);
  1491. return chart;
  1492. })
  1493. },
  1494. calculateMA(dayCount, data) {
  1495. var result = [];
  1496. for (var i = 0, len = data.length; i < len; i++) {
  1497. if (i < dayCount) {
  1498. result.push('-');
  1499. continue;
  1500. }
  1501. var sum = 0;
  1502. for (var j = 0; j < dayCount; j++) {
  1503. sum += +data[i - j][1];
  1504. }
  1505. result.push(sum / dayCount);
  1506. }
  1507. return result;
  1508. },
  1509. setCardDiagram(list){
  1510. var that = this;
  1511. that.selectComponent('#product_four_left_two').init((canvas, width, height, dpr) => {
  1512. const chart = echarts.init(canvas, null, {
  1513. width: width,
  1514. height: height,
  1515. devicePixelRatio: dpr
  1516. });
  1517. chart.setOption({
  1518. backgroundColor: "transparent",
  1519. tooltip: {
  1520. formatter:function(params){
  1521. const {data:{name,value,unNormalTotal}} = params;
  1522. return `${name}\n正常: ${value}\n预警: ${unNormalTotal}`
  1523. }
  1524. },
  1525. grid: {},
  1526. animationDurationUpdate: function (idx) {
  1527. // 越往后的数据延迟越大
  1528. return idx * 100;
  1529. },
  1530. color: ["red", "rgb(10,92,170)", "rgb(114,205,255)"],
  1531. animationEasingUpdate: "bounceIn",
  1532. series: [
  1533. {
  1534. type: "graph",
  1535. layout: "force",
  1536. force: {
  1537. repulsion: 100, //越大斥力越大
  1538. gravity: 0.05, //越大节点越往中心靠拢
  1539. edgeLength: 20, //值越小则长度越长
  1540. },
  1541. roam: true,
  1542. draggable: true,
  1543. symbolSize: 1,
  1544. itemStyle: {
  1545. // opacity: 0.9,
  1546. color: () => {
  1547. return (
  1548. 'red',
  1549. 'rgb(114,205,255)',
  1550. 'rgb(10,92,170)'
  1551. );
  1552. },
  1553. },
  1554. label: {
  1555. normal: {
  1556. show: true,
  1557. fontSize: 10,
  1558. },
  1559. },
  1560. data: list
  1561. },
  1562. ],
  1563. })
  1564. return chart;
  1565. })
  1566. },
  1567. setCardXuTuOption(testNum){
  1568. var that = this;
  1569. let icon =
  1570. "path://M512.584639,219.893708c40.41173,0.258019,73.19961-32.274913,73.199609-72.557634,0-40.025725-32.78788-72.559681-73.199609-72.559681-40.473163,0-73.196538,32.533956-73.196538,72.559681,0,40.089206,32.723375,72.557634,73.196538,72.557634z,m73.330666,16.396499H439.129058c-55.266258,0-91.39098,48.28336-91.390981,94.203594v220.945238c0,42.847553,60.780905,42.847553,60.780905,0V347.144224h11.782872v555.564273c0,59.179548,82.417649,57.316077,84.337434,0V582.569248h15.696162V902.96754c3.391108,60.650871,84.340506,54.817796,84.340506-0.258019V347.144224h9.800631v204.234406c0,42.837314,62.696594,42.837314,62.696594,0V330.433391c0.126962-45.72979-36.116531-94.143184-91.257876-94.143184z";
  1571. for (var index = 0; index < 4; index++) {
  1572. that.selectComponent('#product_five_right_one'+index).init((canvas, width, height, dpr) => {
  1573. const chart = echarts.init(canvas, null, {
  1574. width: width,
  1575. height: height,
  1576. devicePixelRatio: dpr
  1577. });
  1578. chart.setOption({
  1579. backgroundColor: "transparent",
  1580. tooltip: {
  1581. trigger: "axis",
  1582. axisPointer: {
  1583. type: "shadow",
  1584. },
  1585. formatter: "{b0}: {c0}%",
  1586. },
  1587. grid: {
  1588. containLabel: true,
  1589. height: "200px",
  1590. width: "auto",
  1591. left: "0",
  1592. top: "center",
  1593. },
  1594. xAxis: {
  1595. max: 100,
  1596. splitLine: {
  1597. show: false,
  1598. },
  1599. axisLine: {
  1600. show: false,
  1601. },
  1602. axisLabel: {
  1603. show: false,
  1604. },
  1605. axisTick: {
  1606. show: false,
  1607. },
  1608. },
  1609. yAxis: {
  1610. type: "category",
  1611. inverse: true,
  1612. axisLine: {
  1613. show: false,
  1614. },
  1615. axisTick: {
  1616. show: false,
  1617. },
  1618. axisLabel: {
  1619. // margin: 10,
  1620. fontSize: 20,
  1621. color: "white",
  1622. },
  1623. axisPointer: {
  1624. label: {
  1625. show: true,
  1626. margin: 100,
  1627. },
  1628. },
  1629. },
  1630. series: [
  1631. {
  1632. type: "pictorialBar",
  1633. symbolRepeat: "fixed",
  1634. symbolMargin: "6!",
  1635. label: {
  1636. normal: {
  1637. show: false,
  1638. position: "right",
  1639. offset: [3, 0],
  1640. formatter: (param) => {
  1641. return param.value.toFixed(0) + "%";
  1642. },
  1643. textStyle: {
  1644. fontSize: 20,
  1645. color: "white",
  1646. },
  1647. },
  1648. },
  1649. symbolClip: true,
  1650. symbolSize: [22, 30],
  1651. symbolPosition: "start",
  1652. symbolBoundingData: 100,
  1653. data: [
  1654. {
  1655. value: testNum.normalTotal,
  1656. symbol: icon,
  1657. itemStyle: {
  1658. color: "#1DDBF9",
  1659. },
  1660. },
  1661. ],
  1662. z: 10,
  1663. },
  1664. {
  1665. type: "pictorialBar",
  1666. itemStyle: {
  1667. normal: {
  1668. opacity: 0.2,
  1669. },
  1670. },
  1671. animationDuration: 0,
  1672. symbolRepeat: "fixed",
  1673. symbolMargin: "6!",
  1674. symbolSize: [22, 30],
  1675. symbolBoundingData: 100,
  1676. symbolPosition: "start",
  1677. // symbolOffset: [
  1678. // 10,
  1679. // 0
  1680. // ],
  1681. data: [
  1682. {
  1683. value: 100,
  1684. symbol: icon,
  1685. itemStyle: {
  1686. color: "#1DDBF9",
  1687. },
  1688. },
  1689. ],
  1690. z: 5,
  1691. },
  1692. ],
  1693. })
  1694. return chart
  1695. })
  1696. }
  1697. },
  1698. // 主产品使用量、生产量统计
  1699. getSignProductUsedProduceState(){
  1700. var that = this;
  1701. app.requestP({
  1702. url: '/daping/signProductUsedProduceState',
  1703. method: 'post',
  1704. }).then(res=>{
  1705. this.setData({
  1706. statisticSproductList:res.data.data.map(item=>{
  1707. return {
  1708. product_name:item.product_name,
  1709. data:[
  1710. {data:item.produce,index:Math.floor(Math.random()*1000),color:'#2D59E6'},
  1711. {data:item.end,index:Math.floor(Math.random()*1000),color:'#71CCFF'},
  1712. ]
  1713. }
  1714. }),
  1715. },()=>{
  1716. var list = that.data.statisticSproductList;
  1717. for (let index = 0; index < list.length; index++) {
  1718. for (let lindex = 0; lindex < list[index].data.length; lindex++) {
  1719. var color = list[index].data[lindex].color;
  1720. var total = list[index].data[lindex].data;
  1721. var itemIndex = list[index].data[lindex].index;
  1722. that.setCardFivePie_rght(color,total,itemIndex);
  1723. }
  1724. }
  1725. })
  1726. }).catch(err=>{
  1727. app.showToptip(this,'err',err.data.msg)
  1728. })
  1729. },
  1730. setCardFivePie_rght(color,total,itemIndex){
  1731. console.log(color,total,itemIndex);
  1732. var that = this;
  1733. var placeHolderStyle = {
  1734. normal: {
  1735. label: {
  1736. show: false,
  1737. formatter: function (v) {
  1738. //文字中遇到空格就换行
  1739. let text = v.value;
  1740. return text;
  1741. },
  1742. },
  1743. labelLine: {
  1744. show: true,
  1745. },
  1746. },
  1747. };
  1748. that.selectComponent('#product_five_right'+itemIndex).init((canvas, width, height, dpr) => {
  1749. const chart = echarts.init(canvas, null, {
  1750. width: width,
  1751. height: height,
  1752. devicePixelRatio: dpr
  1753. });
  1754. var option = that.getStaticPieChart();
  1755. option.series = [];
  1756. option.color = [color];
  1757. option.series.push({
  1758. type: "pie",
  1759. silent: 1,
  1760. radius: ["65%", "80%"],
  1761. label: {
  1762. show: false,
  1763. },
  1764. labelLine: 0,
  1765. emphasis: {
  1766. label: {
  1767. show: true,
  1768. fontSize: "40",
  1769. fontWeight: "bold",
  1770. },
  1771. },
  1772. data: [
  1773. {
  1774. value:total,
  1775. label: {
  1776. show: true,
  1777. fontSize: 8 * 1.5,
  1778. color: '#485465',
  1779. position: "center",
  1780. formatter: "{c}",
  1781. },
  1782. },
  1783. // { value: 55 ,},
  1784. ],
  1785. })
  1786. chart.setOption(option);
  1787. return chart;
  1788. })
  1789. },
  1790. // 主产品不同年度 使用量统计
  1791. getSignPrroductYearUsedProduceState(){
  1792. app.requestP({
  1793. url: '/daping/signPrroductYearUsedProduceState',
  1794. method: 'post',
  1795. }).then(res=>{
  1796. var xAxisName = [];
  1797. var seriesYear = [];
  1798. var series = [];
  1799. res.data.data.map((item,index)=>{
  1800. item.map((itemChild)=>{
  1801. if(xAxisName.indexOf(itemChild.productName) == -1){
  1802. xAxisName.push(itemChild.productName);
  1803. }
  1804. if(seriesYear.indexOf(itemChild.year) == -1){
  1805. seriesYear.push(itemChild.year);
  1806. series.push({
  1807. name:itemChild.year,
  1808. type: "line",
  1809. stack: "Total",
  1810. data:[itemChild.produce]
  1811. })
  1812. }else{
  1813. series.map((serItem,i)=>{
  1814. if(serItem.name == itemChild.year){
  1815. series[i].data.push(itemChild.produce)
  1816. }
  1817. if(serItem.name != itemChild.year){
  1818. series[i].data.push(0);
  1819. }
  1820. })
  1821. }
  1822. })
  1823. if(index == res.data.data.length-1){
  1824. this.setCardSixBar(series,xAxisName);
  1825. this.setCardSixRightBar(series,xAxisName)
  1826. }
  1827. })
  1828. }).catch(err=>{
  1829. app.showToptip(this,'err',err.data.msg)
  1830. })
  1831. },
  1832. setCardSixBar(lineList,xAxisName){
  1833. var that = this;
  1834. that.selectComponent('#product_six_left').init((canvas, width, height, dpr) => {
  1835. const chart = echarts.init(canvas, null, {
  1836. width: width,
  1837. height: height,
  1838. devicePixelRatio: dpr
  1839. });
  1840. var colors = ['#F71404','#2D59E6','#71CCFF']
  1841. var option = that.getStaticBarChart();
  1842. option.color = ['#F71404','#2D59E6','#71CCFF'];
  1843. option.grid.top = '26%'
  1844. option.series = [];
  1845. option.xAxis.data = xAxisName;
  1846. option.title={
  1847. text: '单位:支',
  1848. left: 'right',
  1849. top:'15%',
  1850. textStyle: {
  1851. color: '#666',
  1852. fontSize: 12,
  1853. }
  1854. },
  1855. option.legend = {
  1856. data:lineList.map(item=>item.name+''),
  1857. icon:"circle",
  1858. top:"10%",
  1859. right:"auto",
  1860. itemWidth:8,
  1861. itemHeight:8,
  1862. textStyle:{
  1863. fontSize:8,
  1864. color:'#485465',
  1865. },
  1866. }
  1867. lineList.map((item,index)=>{
  1868. option.series.push({
  1869. name:item.name+'',
  1870. type:'line',
  1871. data:item.data,
  1872. lineStyle:{
  1873. normal:{
  1874. color:colors[index]
  1875. }
  1876. },
  1877. itemStyle:{
  1878. normal:{
  1879. color:colors[index]
  1880. }
  1881. }
  1882. })
  1883. })
  1884. chart.setOption(option);
  1885. return chart
  1886. })
  1887. },
  1888. setCardSixRightBar(lineList,xAxisName){
  1889. var that = this;
  1890. that.selectComponent('#product_six_right').init((canvas, width, height, dpr) => {
  1891. const chart = echarts.init(canvas, null, {
  1892. width: width,
  1893. height: height,
  1894. devicePixelRatio: dpr
  1895. });
  1896. var option = this.setCardLineTotal();
  1897. option.series = [];
  1898. var colors = ['#F71404','#2D59E6','#71CCFF'];
  1899. option.color = ['#F71404','#2D59E6','#71CCFF'];
  1900. option.grid.top = '26%'
  1901. option.xAxis.data = xAxisName;
  1902. option.title={
  1903. text: '单位:支',
  1904. left: 'right',
  1905. top:'15%',
  1906. textStyle: {
  1907. color: '#666',
  1908. fontSize: 12,
  1909. }
  1910. },
  1911. option.legend = {
  1912. data:lineList.map(item=>item.name+''),
  1913. icon:"circle",
  1914. top:"10%",
  1915. right:"auto",
  1916. itemWidth:8,
  1917. itemHeight:8,
  1918. textStyle:{
  1919. fontSize:8,
  1920. color:'#485465',
  1921. },
  1922. }
  1923. lineList.map((item,index)=>{
  1924. option.series.push({
  1925. name:item.name+'',
  1926. type:'line',
  1927. data:item.data,
  1928. areaStyle: {},
  1929. lineStyle:{
  1930. normal:{
  1931. color:colors[index]
  1932. }
  1933. },
  1934. itemStyle:{
  1935. normal:{
  1936. color:colors[index]
  1937. }
  1938. }
  1939. })
  1940. })
  1941. chart.setOption(option)
  1942. return chart;
  1943. })
  1944. },
  1945. setCardLineTotal(){
  1946. return {
  1947. xAxis: {
  1948. type: "category",
  1949. axisTick:{show:false,},
  1950. nameTextStyle: {
  1951. color: "#77869E",
  1952. fontSize: 8,
  1953. },
  1954. axisLabel: {
  1955. color: '#999999',
  1956. fontSize: 8,
  1957. },
  1958. axisLine: {
  1959. onZero: false,
  1960. lineStyle: {
  1961. color: "#cccccc",
  1962. },
  1963. },
  1964. data: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
  1965. },
  1966. yAxis: {
  1967. type: "value",
  1968. minInterval: 1,
  1969. axisLabel:{color:"#000", fontSize:8,},
  1970. axisLine: {
  1971. lineStyle: {
  1972. color: "#cccccc",
  1973. },
  1974. show: true,
  1975. },
  1976. },
  1977. color: ["#7661FF", "#5AC8FA", "#00B972"],
  1978. grid: {
  1979. left: "3%",
  1980. top: "5%",
  1981. right: "4%",
  1982. bottom: "3%",
  1983. containLabel: true,
  1984. },
  1985. series: [
  1986. {
  1987. data: [120, 200, 150, 80, 70, 110, 130, 110],
  1988. type: "line",
  1989. },
  1990. ]
  1991. }
  1992. },
  1993. setSevenCardPie(list){
  1994. var that = this;
  1995. that.selectComponent('#product_seven_left').init((canvas, width, height, dpr) => {
  1996. const chart = echarts.init(canvas, null, {
  1997. width: width,
  1998. height: height,
  1999. devicePixelRatio: dpr
  2000. });
  2001. var itemStyle = {
  2002. normal: {
  2003. label: {
  2004. show: false,
  2005. formatter: function (v) {
  2006. //文字中遇到空格
  2007. let text = v.name+'\n'+v.value;
  2008. return text;
  2009. },
  2010. },
  2011. labelLine: {
  2012. show: true,
  2013. length:4,
  2014. length2:4,
  2015. },
  2016. },
  2017. }
  2018. var option = this.getStaticPieChart();
  2019. option.color = ['rgb(127,210,255)','rgb(44,88,288)','rgb(247,20,4)',];
  2020. var center = [["50%", "12%"],["50%", "35%"],["50%", "60%"],["50%", "85%"]];
  2021. option.series = [];
  2022. list.map((item,index)=>{
  2023. option.series.push({
  2024. type: "pie",
  2025. radius: ['40%','70%'],
  2026. center: center[index],
  2027. itemStyle,
  2028. label: {
  2029. position: "inside",
  2030. formatter: "{d}%",
  2031. fontSize: 8,
  2032. color: '#fff',
  2033. },
  2034. data: item.data,
  2035. })
  2036. })
  2037. chart.setOption(option)
  2038. return chart
  2039. })
  2040. },
  2041. setCardSenvenPie(list){
  2042. var that = this;
  2043. that.selectComponent('#product_seven_right').init((canvas, width, height, dpr) => {
  2044. const chart = echarts.init(canvas, null, {
  2045. width: width,
  2046. height: height,
  2047. devicePixelRatio: dpr
  2048. });
  2049. var option = this.getStaticPieChart();
  2050. option.series = [];
  2051. option.color = ['#FFAF36','#7A4AFE']
  2052. option.legend = {
  2053. data:list.map(item=>item.name),
  2054. icon:"circle",
  2055. top:"2%",
  2056. right:"auto",
  2057. itemWidth:8,
  2058. itemHeight:8,
  2059. textStyle:{
  2060. fontSize:8,
  2061. color:'#485465',
  2062. },
  2063. }
  2064. option.series = [{
  2065. type: "pie",
  2066. radius: "80%",
  2067. center: ["50%", "50%"],
  2068. label: {
  2069. show:false,
  2070. position: "inside",
  2071. formatter: "{d}%",
  2072. fontSize: 8,
  2073. color: '#fff',
  2074. },
  2075. data:list,
  2076. }]
  2077. chart.setOption(option);
  2078. return chart;
  2079. })
  2080. },
  2081. // 主产品正常、预警统计
  2082. getSignPorductNormalWarningState(){
  2083. app.requestP({
  2084. url: '/daping/signPorductNormalWarningState',
  2085. method: 'post',
  2086. }).then(res=>{
  2087. this.setCardEightBar(res.data.data)
  2088. }).catch(err=>{
  2089. app.showToptip(this,'err',err.data.msg)
  2090. })
  2091. },
  2092. setCardEightBar(list){
  2093. var that = this;
  2094. that.selectComponent('#product_eight_left').init((canvas, width, height, dpr) => {
  2095. const chart = echarts.init(canvas, null, {
  2096. width: width,
  2097. height: height,
  2098. devicePixelRatio: dpr
  2099. });
  2100. var option = that.getStaticBarChart();
  2101. option.series = [];
  2102. option.grid.top='20%';
  2103. option.grid.bottom='13%';
  2104. option.xAxis.data = list.map(item=>item.product_name);
  2105. const echartsData = [
  2106. {name:'正常',data:list.map(item=>item.normal)},
  2107. {name:'报警',data:list.map(item=>item.warning)},
  2108. ]
  2109. option.color = ['#2D59E6','#E1291C']
  2110. option.legend = {
  2111. data:echartsData.map(item=>item.name),
  2112. icon:"circle",
  2113. top:"2%",
  2114. right:"auto",
  2115. itemWidth:8,
  2116. itemHeight:8,
  2117. textStyle:{
  2118. fontSize:8,
  2119. color:'#485465',
  2120. },
  2121. }
  2122. echartsData.map((item,index)=>{
  2123. option.series.push({
  2124. name: item.name,
  2125. type: 'bar',
  2126. emphasis: {
  2127. focus: "series",
  2128. },
  2129. data:item.data,
  2130. });
  2131. })
  2132. chart.setOption(option);
  2133. return chart;
  2134. });
  2135. },
  2136. setCardEightRightBar(list){
  2137. var that = this;
  2138. that.selectComponent('#product_eight_right').init((canvas, width, height, dpr) => {
  2139. const chart = echarts.init(canvas, null, {
  2140. width: width,
  2141. height: height,
  2142. devicePixelRatio: dpr
  2143. });
  2144. var option = that.getStaticBarChart();
  2145. option.title = {
  2146. show:false,
  2147. text: '',
  2148. top:'10%',
  2149. textStyle: {
  2150. color: '#999',
  2151. fontSize: 6,
  2152. }
  2153. }
  2154. option.legend = {
  2155. data:list.map(item=>item.name),
  2156. icon:"circle",
  2157. top:"2%",
  2158. right:"auto",
  2159. itemWidth:8,
  2160. itemHeight:8,
  2161. textStyle:{
  2162. fontSize:8,
  2163. color:'#485465',
  2164. },
  2165. }
  2166. option.grid = {
  2167. top:'20%',
  2168. bottom:'15%',
  2169. right:'15%',
  2170. left:'15%'
  2171. }
  2172. option.color = ['#26E657','#FFAF36','#F71404'];
  2173. option.yAxis = [
  2174. {
  2175. type: 'value',
  2176. // min: 0,
  2177. // max: 250,
  2178. interval: 50,
  2179. minInterval: 1,
  2180. axisLine: {
  2181. lineStyle: {
  2182. color: "#cccccc",
  2183. },
  2184. show: false,
  2185. },
  2186. axisLabel: {
  2187. color: "#999999",
  2188. fontSize: 8,
  2189. },
  2190. },
  2191. {
  2192. type: 'value',
  2193. min: 0,
  2194. max:25,
  2195. interval: 5,
  2196. // minInterval: 1,
  2197. axisLine: {
  2198. lineStyle: {
  2199. // color: "",
  2200. },
  2201. show: false,
  2202. },
  2203. axisLabel: {
  2204. color: "#999999",
  2205. fontSize: 8,
  2206. },
  2207. }
  2208. ];
  2209. option.series = [];
  2210. list.map((item,index)=>{
  2211. option.series.push({
  2212. name: item.name,
  2213. type: 'bar',
  2214. stack: "Ad",
  2215. emphasis: {
  2216. focus: "series",
  2217. },
  2218. data:item.data,
  2219. })
  2220. })
  2221. chart.setOption(option);
  2222. return chart;
  2223. })
  2224. },
  2225. setCardNineBar(list){
  2226. var that = this;
  2227. that.selectComponent('#product_nine_left').init((canvas, width, height, dpr) => {
  2228. const chart = echarts.init(canvas, null, {
  2229. width: width,
  2230. height: height,
  2231. devicePixelRatio: dpr
  2232. });
  2233. var option = that.getCysOrderOption(list);
  2234. option.title = {
  2235. text: '产品分类信息',
  2236. top:'10%',
  2237. textStyle: {
  2238. color: '#999',
  2239. fontSize: 6,
  2240. }
  2241. }
  2242. option.grid = {
  2243. top:"25%",
  2244. left:"13%",
  2245. right:"15%",
  2246. bottom:"14%",
  2247. }
  2248. option.yAxis = [
  2249. {
  2250. type: 'value',
  2251. // min: 0,
  2252. // max: 250,
  2253. // interval: 50,
  2254. minInterval: 1,
  2255. axisLine: {
  2256. lineStyle: {
  2257. color: "#cccccc",
  2258. },
  2259. show: false,
  2260. },
  2261. axisLabel: {
  2262. color: "#999999",
  2263. fontSize: 8,
  2264. },
  2265. },
  2266. {
  2267. type: 'value',
  2268. min: 0,
  2269. max:25,
  2270. interval: 5,
  2271. // minInterval: 1,
  2272. axisLine: {
  2273. lineStyle: {
  2274. // color: "",
  2275. },
  2276. show: false,
  2277. },
  2278. axisLabel: {
  2279. color: "#999999",
  2280. fontSize: 8,
  2281. },
  2282. }
  2283. ];
  2284. chart.setOption(option);
  2285. return chart;
  2286. })
  2287. },
  2288. setCardNineRightBar(list){
  2289. var that = this;
  2290. that.selectComponent('#product_nine_right').init((canvas, width, height, dpr) => {
  2291. const chart = echarts.init(canvas, null, {
  2292. width: width,
  2293. height: height,
  2294. devicePixelRatio: dpr
  2295. });
  2296. var option = that.setCardLineTotal();
  2297. option.series = [];
  2298. option.legend = {
  2299. data:list.map(item=>item.name),
  2300. icon:"circle",
  2301. top:"5%",
  2302. right:"auto",
  2303. itemWidth:8,
  2304. itemHeight:8,
  2305. textStyle:{
  2306. fontSize:8,
  2307. color:'#485465',
  2308. },
  2309. }
  2310. option.yAxis = {
  2311. type: "value",
  2312. // minInterval: 1,
  2313. axisLine: {
  2314. lineStyle: {
  2315. color: "#cccccc",
  2316. },
  2317. },
  2318. axisLabel: {
  2319. color: "#999999",
  2320. fontSize: 8,
  2321. },
  2322. },
  2323. option.grid.top = '20%';
  2324. option.grid.right = '10%';
  2325. list.map(item=>{
  2326. option.series.push({
  2327. name:item.name,
  2328. type: 'line',
  2329. stack: 'Total',
  2330. areaStyle: {},
  2331. showSymbol:false,
  2332. emphasis: {
  2333. focus: 'series'
  2334. },
  2335. data: item.data,
  2336. })
  2337. })
  2338. chart.setOption(option)
  2339. return chart;
  2340. })
  2341. },
  2342. // 地区产品统计
  2343. setCardLeftFive(list){
  2344. var that = this;
  2345. that.selectComponent('#product_five').init((canvas, width, height, dpr) => {
  2346. const chart = echarts.init(canvas, null, {
  2347. width: width,
  2348. height: height,
  2349. devicePixelRatio: dpr
  2350. });
  2351. var option = {
  2352. xAxis: {
  2353. type: 'value',
  2354. axisLabel: {
  2355. show: false
  2356. }
  2357. },
  2358. grid:{
  2359. top:0,
  2360. left: '3%',
  2361. right: '4%',
  2362. bottom: '3%',
  2363. containLabel: true
  2364. },
  2365. yAxis: {
  2366. type: 'category',
  2367. data: list.name.map(item=>item),
  2368. axisTick: { show: false },
  2369. axisLabel:{color:"#999999", fontSize:9,},
  2370. axisLine: { lineStyle: { color: '#DEE3FF' } },
  2371. },
  2372. series:list.data.map(item=>{
  2373. return{ name:item.name,type:'bar',data:item.data }
  2374. })
  2375. }
  2376. chart.setOption(option);
  2377. return chart;
  2378. })
  2379. },
  2380. // 图15 主产品在不同地区库存、使用数据统计 /daping/signProductCityState
  2381. getSignProductCityState(){
  2382. app.requestP({
  2383. url: '/daping/signProductCityState',
  2384. method: 'post',
  2385. }).then(res=>{
  2386. this.setData({
  2387. orderCardList:res.data.data,
  2388. })
  2389. var sevenCardPieNum = [];
  2390. res.data.data.map(item=>{
  2391. sevenCardPieNum.push({
  2392. data:[{name:item.city,value:item.stack},{name:item.city+'1',value:item.used}]
  2393. })
  2394. })
  2395. this.setSevenCardPie(sevenCardPieNum);
  2396. }).catch(err=>{
  2397. app.showToptip(this,'err',err.data.msg)
  2398. })
  2399. },
  2400. // 主产品最近一周每一天的使用量统计
  2401. getSignProductEveryWeekState(){
  2402. app.requestP({
  2403. url: '/daping/signProductEveryWeekState',
  2404. method: 'post',
  2405. }).then(res=>{
  2406. this.setKLine(res.data.data);
  2407. }).catch(err=>{
  2408. app.showToptip(this,'err',err.data.msg)
  2409. })
  2410. },
  2411. setEchartkline(rawData){
  2412. var that = this;
  2413. const dates = rawData.map(function (item) {
  2414. return item[0];
  2415. });
  2416. const data = rawData.map(function (item) {
  2417. return [+item[1], +item[2], +item[5], +item[6]];
  2418. });
  2419. that.selectComponent('#kline').init((canvas, width, height, dpr) => {
  2420. const chart = echarts.init(canvas, null, {
  2421. width: width,
  2422. height: height,
  2423. devicePixelRatio: dpr
  2424. });
  2425. var option = {
  2426. legend: {
  2427. data: ['日K', 'MA5', 'MA10', 'MA20', 'MA30'],
  2428. inactiveColor: '#777'
  2429. },
  2430. tooltip: {
  2431. trigger: 'axis',
  2432. axisPointer: {
  2433. animation: false,
  2434. type: 'cross',
  2435. lineStyle: {
  2436. color: '#376df4',
  2437. width: 2,
  2438. opacity: 1
  2439. }
  2440. }
  2441. },
  2442. xAxis: {
  2443. type: 'category',
  2444. data: dates,
  2445. axisLabel: {
  2446. color: 'white',
  2447. fontSize: 8,
  2448. },
  2449. axisLine: { lineStyle: { color: '#8392A5' } }
  2450. },
  2451. yAxis: {
  2452. scale: true,
  2453. axisLabel: {
  2454. color: 'white',
  2455. fontSize: 8,
  2456. },
  2457. axisLine: { lineStyle: { color: '#8392A5' } },
  2458. splitLine: { show: false }
  2459. },
  2460. grid: {
  2461. bottom: "20",
  2462. left: "1%",
  2463. right: "5%",
  2464. top:'5%',
  2465. containLabel: true,
  2466. },
  2467. dataZoom:{show:false,},
  2468. series: [
  2469. {
  2470. type: 'candlestick',
  2471. data: data,
  2472. itemStyle: {
  2473. color: '#FD1050',
  2474. color0: '#0CF49B',
  2475. borderColor: '#FD1050',
  2476. borderColor0: '#0CF49B'
  2477. }
  2478. },
  2479. {
  2480. type: 'line',
  2481. data: this.calculateMA(5, data),
  2482. smooth: true,
  2483. showSymbol: false,
  2484. lineStyle: {
  2485. width: 1
  2486. }
  2487. },
  2488. {
  2489. type: 'line',
  2490. data: this.calculateMA(10, data),
  2491. smooth: true,
  2492. showSymbol: false,
  2493. lineStyle: {
  2494. width: 1
  2495. }
  2496. },
  2497. {
  2498. type: 'line',
  2499. data: this.calculateMA(20, data),
  2500. smooth: true,
  2501. showSymbol: false,
  2502. lineStyle: {
  2503. width: 1
  2504. }
  2505. },
  2506. {
  2507. type: 'line',
  2508. data: this.calculateMA(30, data),
  2509. smooth: true,
  2510. showSymbol: false,
  2511. lineStyle: {
  2512. width: 1
  2513. }
  2514. }
  2515. ]
  2516. }
  2517. chart.setOption(option);
  2518. return chart;
  2519. })
  2520. },
  2521. calculateMA(dayCount, data) {
  2522. var result = [];
  2523. for (var i = 0, len = data.length; i < len; i++) {
  2524. if (i < dayCount) {
  2525. result.push('-');
  2526. continue;
  2527. }
  2528. var sum = 0;
  2529. for (var j = 0; j < dayCount; j++) {
  2530. sum += +data[i - j][1];
  2531. }
  2532. result.push(sum / dayCount);
  2533. }
  2534. return result;
  2535. }
  2536. })