index.js 64 KB

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