index.js 72 KB

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