report_analysis.js 67 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052
  1. function dateFormatter (date, pattern) {
  2. return new Date(date).pattern(pattern)
  3. }
  4. var vm = new Vue({
  5. delimiters: ['${', '}'],
  6. el: '#analysis',
  7. components: {
  8. keywordComponent: keywordComponent,
  9. areaCityMobile: areaCityMobileComponent,
  10. areaComponent: areaComponent,
  11. industryComponent: industryComponent,
  12. cateComponent: cateComponent,
  13. dateComponent: dateComponent,
  14. chartExample: chartExample,
  15. projectHeader: projectHeaderComponent,
  16. // 图表
  17. projectScatter: projectScatter,
  18. marketTimeScatter: marketTimeScatter,
  19. marketAreaScatter: marketAreaScatter,
  20. marketTop3Table: marketTop3Table,
  21. marketUserScatter: marketUserScatter,
  22. marketSegment: marketSegment,
  23. lineChartScatter: lineChartScatter,
  24. },
  25. data: {
  26. sessStorageKey: '$data-report_analysis',
  27. tabActiveName: 'analysis', // analysis/history
  28. tabList: [
  29. {
  30. label: '市场分析报告',
  31. name: 'analysis'
  32. },
  33. {
  34. label: '历史报告',
  35. name: 'history'
  36. }
  37. ],
  38. tabConf: {
  39. titleActiveColor: '#2ABED1',
  40. titleInactiveColor: '#5F5E64',
  41. lineWidth: '24',
  42. color: '#2ABED1'
  43. },
  44. timeOptions: [
  45. {
  46. name: '近3个月',
  47. value: 'lately90',
  48. selected: false
  49. },
  50. {
  51. name: '近半年',
  52. value: 'lately180',
  53. selected: false
  54. },
  55. {
  56. name: '今年全年',
  57. value: 'thisYear',
  58. selected: false
  59. },
  60. {
  61. name: '去年至今',
  62. value: 'sinceLastYear',
  63. selected: false
  64. },
  65. {
  66. name: '前年至今',
  67. value: 'sinceYearBeforeLast',
  68. selected: false
  69. }
  70. ],
  71. scrollTop: 0,
  72. filtersPageShow: true,
  73. filters: {
  74. selectKeysArr: [], // 关键词简单数组,用于恢复选择状态
  75. keys: [], // 关键词详细数组,用于提交数据
  76. area: {},
  77. industry: [],
  78. industryDetail: {},
  79. buyerclass: [],
  80. rangeTime: {
  81. start: '',
  82. end: '',
  83. exact: 'sinceYearBeforeLast',
  84. },
  85. },
  86. filterDialogShow: {
  87. keys: false,
  88. area: false,
  89. industry: false,
  90. buyerclass: false,
  91. rangeTime: false
  92. },
  93. // 分析结果页面数据
  94. activeDimension: 'market',
  95. dimensionList: [
  96. {
  97. id: 'market',
  98. name: '市场规模',
  99. top: 0,
  100. anchor: 'market-overview'
  101. },
  102. {
  103. id: 'buyer',
  104. name: '采购单位',
  105. top: 0,
  106. anchor: 'buyerclass-scatter'
  107. },
  108. {
  109. id: 'bidder',
  110. name: '中标单位',
  111. top: 0,
  112. anchor: 'winner-scatter'
  113. },
  114. ],
  115. analysis: { // 开始分析请求的loaed和loading
  116. loaded: false,
  117. loading: false
  118. },
  119. rid: '', // reportId
  120. reportFilters: {
  121. keys: [],
  122. selectTime: '',
  123. selectTimeExtra: '',
  124. area: {},
  125. industry: {},
  126. buyerclass: []
  127. },
  128. sections: {
  129. market: {
  130. overview: [],
  131. refine: {
  132. dataAlready: false,
  133. projectCountData: null,
  134. projectAmountData: null,
  135. // 项目数量Top3
  136. projectCountTop3: null,
  137. // 项目金额Top3
  138. projectAmountTop3: null
  139. }
  140. },
  141. projectScatter: {
  142. dataAlready: false,
  143. chartData: null,
  144. tableData: [
  145. // {
  146. // projectname: 'xxxx',
  147. // area: 'xx',
  148. // city: 'xxx',
  149. // sortprice: 'zzz',
  150. // jgtime: 'zzzz',
  151. // winner_s: [
  152. // {
  153. // name: 'w1',
  154. // id: '33'
  155. // },
  156. // {
  157. // name: 'w2',
  158. // id: '33'
  159. // }
  160. // ]
  161. // },
  162. // {
  163. // projectname: 'xxxx',
  164. // area: 'xx',
  165. // city: 'xxx',
  166. // sortprice: 'zzz',
  167. // jgtime: 'zzzz',
  168. // winner_s: [
  169. // {
  170. // name: 'w1',
  171. // id: '33'
  172. // },
  173. // {
  174. // name: 'w2',
  175. // id: '33'
  176. // }
  177. // ]
  178. // }
  179. ]
  180. },
  181. timeScatter: {
  182. dataAlready: false, // 数据准备好之后才能开始渲染
  183. activeAction: 'month',
  184. actionList: [
  185. {
  186. label: '月度数据',
  187. value: 'month'
  188. },
  189. {
  190. label: '年度数据',
  191. value: 'year'
  192. }
  193. ],
  194. month: {
  195. count: {},
  196. amount: {}
  197. },
  198. year: {
  199. count: {},
  200. amount: {}
  201. }
  202. },
  203. areaScatter: {
  204. dataAlready: false,
  205. chartData: null,
  206. // 地区信息接口返回的原始数据
  207. originAreaData: [],
  208. showAreaPopup: false,
  209. setCityList: [],
  210. selectArea: {},
  211. sortType: 0,
  212. showAreaCityListBtn: false,
  213. // 项目数量Top3
  214. projectCountTop3: null,
  215. // 项目金额Top3
  216. projectAmountTop3: null
  217. },
  218. userScatter: {
  219. list: [],
  220. // 项目数量Top3
  221. projectCountTop3: null,
  222. // 项目金额Top3
  223. projectAmountTop3: null
  224. },
  225. buyerclass: {
  226. dataAlready: false,
  227. chartData: null,
  228. // 项目数量Top3
  229. projectCountTop3: null,
  230. showCountAllBtn: false,
  231. // 项目金额Top3
  232. projectAmountTop3: null,
  233. showAmoutAllBtn: false
  234. },
  235. winner: {
  236. dataAlready: false,
  237. chartData: null,
  238. // 项目数量Top3
  239. projectCountTop3: null,
  240. showCountAllBtn: false,
  241. // 项目金额Top3
  242. projectAmountTop3: null,
  243. showAmoutAllBtn: false
  244. }
  245. },
  246. empty: {
  247. defaultMsg: '对不起,没有匹配到相关信息<br />请修改您的分析条件',
  248. msg: ''
  249. },
  250. stickyOffset: 0,
  251. notSetKey: false, // 未设置关键词
  252. isSubCount: false, // 是否子账号
  253. powerInfo: {},
  254. isWeixin: false,
  255. sortOptionTitle: '项目数量由大到小排序',
  256. sortOptionContent: [
  257. { text: '项目数量由大到小排序', value: 0, active: true },
  258. { text: '项目金额由大到小排序', value: 1, active: false }
  259. ]
  260. },
  261. computed: {
  262. showBuyerBtn: function () {
  263. return this.sections.buyerclass.showCountAllBtn ? this.sections.buyerclass.projectCountTop3.slice(0, 3) : this.sections.buyerclass.projectCountTop3
  264. },
  265. showAmoutBtn: function () {
  266. return this.sections.buyerclass.showAmoutAllBtn ? this.sections.buyerclass.projectAmountTop3.slice(0, 3) : this.sections.buyerclass.projectAmountTop3
  267. },
  268. showWinnerCountBtn: function () {
  269. return this.sections.winner.showCountAllBtn ? this.sections.winner.projectCountTop3.slice(0, 3) : this.sections.winner.projectCountTop3
  270. },
  271. showWinnerAmoutBtn: function () {
  272. return this.sections.winner.showAmoutAllBtn ? this.sections.winner.projectAmountTop3.slice(0, 3) : this.sections.winner.projectAmountTop3
  273. },
  274. showAreaCityBtn: function () {
  275. return this.sections.areaScatter.showAreaCityListBtn ? this.sections.areaScatter.setCityList.slice(0, 5) : this.sections.areaScatter.setCityList
  276. },
  277. getStatus: function () {
  278. if (JSON.stringify(this.powerInfo) !== '{}') {
  279. return this.powerInfo.power.indexOf(10) !== -1
  280. }
  281. },
  282. anchorTopList: function () {
  283. var arr = []
  284. this.dimensionList.forEach(function (item) {
  285. arr.push(item.top)
  286. })
  287. return arr
  288. },
  289. // 报告详情筛选条件只有一个省份
  290. // 此时不显示地区分布chart
  291. notOneAreaFilter () {
  292. var area = this.reportFilters.area
  293. var showArea = area && (Object.keys(area).length > 1 || Object.keys(area).length === 0)
  294. return showArea
  295. },
  296. notOneAreaCityFilter () {
  297. var area = this.reportFilters.area
  298. if (!this.notOneAreaFilter) {
  299. var showCity = area && (area[Object.keys(area)].length >=2 || area[Object.keys(area)].length === 0)
  300. return showCity
  301. } else {
  302. return this.notOneAreaFilter
  303. }
  304. },
  305. emptyShow () {
  306. return !this.rid && this.analysis.loaded
  307. },
  308. tabActive: function () {
  309. var _this = this
  310. var active = {}
  311. this.tabList.some(function (item) {
  312. var findThis = item.name === _this.tabActiveName
  313. if (findThis) {
  314. active = item
  315. return findThis
  316. }
  317. })
  318. return active
  319. },
  320. buyerclassSectionShow () {
  321. const winnerState = this.sections.buyerclass
  322. return winnerState.dataAlready && winnerState.projectCountTop3 && winnerState.projectAmountTop3
  323. },
  324. winnerSectionShow () {
  325. const winnerState = this.sections.winner
  326. return winnerState.dataAlready && winnerState.projectCountTop3 && winnerState.projectAmountTop3
  327. },
  328. overviewRateTotal: function () {
  329. var total = 0
  330. this.sections.market.overview.forEach(function (item) {
  331. if (item.ringRatio !== undefined && item.ringRatio !== null) {
  332. total += item.ringRatio
  333. }
  334. })
  335. return total
  336. }
  337. },
  338. watch: {
  339. filtersPageShow (newVal) {
  340. if (!newVal) {
  341. this.isWeixin = utils.isWeiXinBrowser
  342. if (!this.isWeixin) {
  343. this.calcStickyOffset()
  344. }
  345. }
  346. }
  347. },
  348. created () {
  349. this.calcLastTimeText()
  350. this.getPower()
  351. var id = utils.getParam('id')
  352. if (id) {
  353. this.rid = decodeURIComponent(id)
  354. this.filtersPageShow = false
  355. }
  356. },
  357. mounted: function () {
  358. setTimeout(() => {
  359. var restored = this.reStoreState()
  360. if (!restored) {
  361. if (this.rid) {
  362. this.getReportResult()
  363. }
  364. } else {
  365. this.$nextTick(this.calcOffsetTop)
  366. if (utils.isIos) {
  367. setTimeout(this.calcOffsetTop, 1000)
  368. }
  369. }
  370. }, 0)
  371. this.addEventListeners()
  372. utils.iosBackRefresh()
  373. },
  374. methods: {
  375. // 设置排序方式
  376. setsortType (data) {
  377. this.sections.areaScatter.sortType = data
  378. const type = data===0 ? 'total' : 'amount'
  379. // const list = this.setCitySort(this.sections.areaScatter.setCityList, type)
  380. let newArr = []
  381. if(data === 0) {
  382. newArr = this.sections.areaScatter.setCityList.sort((a, b) => b.total - a.total)
  383. } else {
  384. newArr = this.sections.areaScatter.setCityList.sort((a, b) => b.amount - a.amount)
  385. }
  386. this.sections.areaScatter.setCityList = this.formatterWinData(newArr, type)
  387. this.sortOptionTitle = this.sortOptionContent[data].text
  388. this.sections.areaScatter.setCityList = newArr
  389. },
  390. cancelSelectArea () {
  391. this.sections.areaScatter.showAreaPopup = false
  392. },
  393. // 城市排序
  394. setCitySort (list, type) {
  395. return list.sort((a, b) => {
  396. a[type] - b[type]
  397. })
  398. },
  399. // 选择省份展示城市分布(单选)
  400. confirmSelectArea (data) {
  401. console.log(data)
  402. if(this.sections.areaScatter.originAreaData.length > 0) {
  403. this.sections.areaScatter.originAreaData.forEach(item => {
  404. if(item.area == data.data[0]) {
  405. this.sections.areaScatter.selectArea = item
  406. const areaSort = this.sections.areaScatter.sortType === 0 ? 'total' : 'amount'
  407. let newArr = []
  408. if(this.sections.areaScatter.sortType === 0) {
  409. newArr = item.areaDetails.sort((a, b) => b.total - a.total)
  410. } else {
  411. newArr = item.areaDetails.sort((a, b) => b.amount - a.amount)
  412. }
  413. this.sections.areaScatter.setCityList = this.formatterWinData(newArr, areaSort)
  414. this.sections.areaScatter.setCityList = this.sections.areaScatter.setCityList.sort((a, b) => b[areaSort] - a[areaSort])
  415. if(this.sections.areaScatter.setCityList.length > 5) {
  416. this.sections.areaScatter.showAreaCityListBtn = true
  417. } else {
  418. this.sections.areaScatter.showAreaCityListBtn = false
  419. }
  420. }
  421. })
  422. }
  423. this.sections.areaScatter.showAreaPopup = false
  424. },
  425. showCountAmount (data) {
  426. return (data.amount / 10000).toFixed(2)
  427. },
  428. inProList () {
  429. this.saveState()
  430. if(utils.$envs.inWX){
  431. if(!this.getStatus) {
  432. location.href = '/weixin/frontPage/bigmember/free/perfect_info?source=wx_analysis_ProjectDetails'
  433. } else {
  434. window.location.href='/big/wx/page/report_analysis_pro_list?id=' + this.rid
  435. }
  436. } else {
  437. if(!this.getStatus) {
  438. location.href = '/jyapp/frontPage/bigmember/free/perfect_info?source=app_analysis_ProjectDetails'
  439. } else {
  440. window.location.href='/jyapp/big/page/report_analysis_pro_list?id=' + this.rid
  441. }
  442. }
  443. },
  444. gotable () {
  445. this.saveState()
  446. if(utils.$envs.inWX){
  447. window.location.href='/big/wx/page/report_table?source=analysis'+'&flag=3'+'&rid='+this.rid+'&header=客户类型分布详情'
  448. } else {
  449. window.location.href='/jyapp/big/page/report_table?source=analysis'+'&flag=3'+'&rid='+this.rid+'&header=客户类型分布详情'
  450. }
  451. },
  452. isWeiXinBrower() {
  453. var ua = navigator.userAgent.toLowerCase();
  454. if(ua.match(/MicroMessenger/i) == 'micromessenger') {
  455. return true;
  456. } else {
  457. return false;
  458. }
  459. },
  460. showLoading: function () {
  461. return this.$toast.loading({
  462. duration: 0,
  463. forbidClick: true,
  464. message: 'loading...',
  465. })
  466. },
  467. showToast: function (message) {
  468. return this.$toast({
  469. duration: 1500,
  470. forbidClick: true,
  471. message: message,
  472. })
  473. },
  474. showDialog: function (conf) {
  475. var defaultConf = {
  476. title: '提示',
  477. message: 'message',
  478. className: 'j-confirm-dialog',
  479. showConfirmButton: true,
  480. showCancelButton: true,
  481. confirmButtonText: '确定',
  482. confirmButtonColor: '#2abed1'
  483. }
  484. if (conf) {
  485. Object.assign(defaultConf, conf)
  486. }
  487. return this.$dialog.confirm(defaultConf)
  488. },
  489. calcOffsetTop: function () {
  490. var sticky = $('.van-sticky')
  491. var stickyHeight = 0
  492. if (sticky.length) {
  493. stickyHeight = sticky[0].clientHeight
  494. }
  495. this.dimensionList.forEach(function (item) {
  496. var anchor = $('.' + item.anchor)
  497. var offsetTop = 0
  498. if (anchor.length) {
  499. offsetTop = parseInt(anchor[0].offsetTop - stickyHeight)
  500. }
  501. item.top = offsetTop
  502. })
  503. },
  504. addEventListeners: function () {
  505. this.scrollToTop()
  506. },
  507. scrollToTop: function () {
  508. var $scrollDOM = $('.j-container.search-result > .j-main')
  509. // 1. 检查当前高度是否满足显示快速滚动到顶部
  510. this.checkScrollTopButtonShow()
  511. // 2. 具体逻辑
  512. $scrollDOM.on('scroll', this.checkScrollTopButtonShow)
  513. setTimeout(function () {
  514. // 2s后绑定(尽可能保证top能够被计算完)
  515. $scrollDOM.on('scroll', this.checkAnchorItemActive)
  516. }.bind(this), 2500)
  517. $('.scroll-to-top').on('click', function () {
  518. $scrollDOM.animate({ scrollTop: 0 })
  519. })
  520. },
  521. checkAnchorItemActive: function () {
  522. var $scrollDOM = $('.j-container.search-result > .j-main')
  523. var anchorTopList = this.anchorTopList
  524. var scrollTop = parseInt($scrollDOM.scrollTop()) + 3 // (误差校正)
  525. var i = 0
  526. if (scrollTop >= anchorTopList[1] && scrollTop < anchorTopList[2]) {
  527. i = 1
  528. } else if (scrollTop > anchorTopList[2] && scrollTop > anchorTopList[1] && scrollTop > anchorTopList[0]) { //逻辑上多余判断条件 ,为了处理高度还没有计算出起始的 anchorTopList[2]为0 tab回显错误问题
  529. i = 2
  530. } else if (scrollTop < anchorTopList[1]) {
  531. i = 0
  532. }
  533. this.activeDimension = this.dimensionList[i].id
  534. },
  535. checkScrollTopButtonShow: function () {
  536. var showButtonHeight = 300
  537. var $scrollDOM = $('.j-container.search-result > .j-main')
  538. var button = $('.scroll-to-top')
  539. var scrollTop = $scrollDOM.scrollTop()
  540. if (scrollTop > showButtonHeight) {
  541. button.show()
  542. } else {
  543. button.hide()
  544. }
  545. },
  546. calcStickyOffset: function () {
  547. setTimeout(function () {
  548. var headerHeight = $('.jy-app-header')[0].clientHeight
  549. var tabHeight = $('.analysis-tab')[0].clientHeight
  550. this.stickyOffset = headerHeight + tabHeight - 5
  551. }.bind(this), 1000)
  552. },
  553. setScrollTop: function (scrollTop) {
  554. this.$nextTick(function () {
  555. var wrapper = document.querySelector('.j-container.search-result > .j-main')
  556. wrapper.scrollTop = scrollTop
  557. })
  558. },
  559. saveScrollTop: function () {
  560. var wrapper = document.querySelector('.j-container.search-result > .j-main')
  561. if (wrapper.scrollTop) {
  562. this.scrollTop = parseInt(wrapper.scrollTop)
  563. }
  564. },
  565. beforeTabChange: function (name) {
  566. if (name !== this.tabActiveName) {
  567. this.goToAnalysisHistory()
  568. }
  569. return false
  570. },
  571. goToAnalysisHistory: function () {
  572. location.href = './report_analysis_history'
  573. },
  574. formatSelectTime (value) {
  575. if (!value) return '-'
  576. const timeArr = value.split('-')
  577. return `${dateFormatter(timeArr[0] * 1000, 'yyyy/MM/dd')}-${dateFormatter(timeArr[1] * 1000, 'yyyy/MM/dd')}`
  578. },
  579. getPower:function () {
  580. var _this = this
  581. $.ajax({
  582. type:'POST',
  583. url:'/bigmember/use/isAdd',
  584. success:function(res) {
  585. _this.powerInfo = res.data
  586. if (res.data && res.data.isSubCount){
  587. _this.isSubCount = true
  588. }
  589. }
  590. })
  591. },
  592. init: function () {
  593. // 初始化页面数据
  594. this.initDateTimeSelector('sinceYearBeforeLast')
  595. },
  596. // 时间选择器选中状态
  597. initDateTimeSelector: function (exact) {
  598. if (exact === 'exact') {
  599. this.$refs.dateSelector.setState(this.filters.rangeTime)
  600. } else {
  601. this.$refs.dateSelector.setTimeSelectListState(exact)
  602. this.$refs.dateSelector.dateStyle = false
  603. }
  604. },
  605. resolveSelected: function (type) {
  606. var filters = this.filters
  607. var prefix = '已选:'
  608. var text = ''
  609. if (type === 'keys') {
  610. if (this.notSetKey) return '请设置'
  611. text = this.resolveSelectKeysText(filters.keys)
  612. } else if (type === 'area') {
  613. text = this.resolveSelectAreaText(filters.area)
  614. } else if (type === 'industry') {
  615. text = this.resolveSelectIndustryText(filters.industryDetail)
  616. } else if (type === 'buyerclass') {
  617. text = this.resolveSelectBuyerclassText(filters.buyerclass)
  618. }
  619. return prefix + text
  620. },
  621. resolveSelectKeysText: function (keys) {
  622. if (Array.isArray(keys)) {
  623. if (keys.length === 0) {
  624. return '全部'
  625. } else {
  626. var count = 0
  627. var arr = []
  628. keys.forEach(function (classify) {
  629. if (Array.isArray(classify.a_key) && classify.a_key.length) {
  630. count += classify.a_key.length
  631. classify.a_key.forEach(function (item) {
  632. arr.push(item.key.join(' '))
  633. })
  634. }
  635. })
  636. if (count <= 0) {
  637. return '全部'
  638. } else {
  639. return arr.join(',')
  640. }
  641. }
  642. } else {
  643. return '全部'
  644. }
  645. },
  646. resolveSelectAreaText: function (area) {
  647. if (!area || Object.keys(area).length === 0) return '全国'
  648. var areaArr = []
  649. var cityArr = []
  650. for (var key in area) {
  651. if (area[key].length === 0) {
  652. areaArr.push(key)
  653. } else {
  654. cityArr = cityArr.concat(area[key])
  655. }
  656. }
  657. return areaArr.concat(cityArr).join(',')
  658. },
  659. resolveSelectIndustryText: function (industry) {
  660. if (!industry || Object.keys(industry).length === 0) return '全部'
  661. var keyArr = []
  662. var valueArr = []
  663. for (var key in industry) {
  664. if (industry[key].length === 0) {
  665. keyArr.push(key)
  666. } else {
  667. valueArr = valueArr.concat(industry[key])
  668. }
  669. }
  670. return keyArr.concat(valueArr).join(',')
  671. },
  672. resolveSelectBuyerclassText: function (buyerclass) {
  673. if (!Array.isArray(buyerclass)) return '全部'
  674. if (buyerclass.length === 0) return '全部'
  675. return buyerclass.join(',')
  676. },
  677. calcLastTimeText: function () {
  678. const renameList = [
  679. 'thisYear', // 今年全年
  680. 'sinceLastYear', // 去年至今
  681. 'sinceYearBeforeLast' // 前年至今
  682. ]
  683. const thisYear = new Date().getFullYear()
  684. this.timeOptions.forEach(item => {
  685. if (renameList.indexOf(item.value) !== -1) {
  686. if (item.value === renameList[0]) {
  687. item.name = `${thisYear}年全年`
  688. } else if (item.value === renameList[1]) {
  689. item.name = `${thisYear - 1}年至今`
  690. } else if (item.value === renameList[2]) {
  691. item.name = `${thisYear - 2}年至今`
  692. }
  693. }
  694. })
  695. },
  696. // 重置
  697. resetFilter: function (type) {
  698. var filters = this.filters
  699. if (type === 'keys') {
  700. filters.keys = []
  701. filters.selectKeysArr = []
  702. try {
  703. this.$refs.keywordSelector.resetAllNoSelect()
  704. } catch (error) {}
  705. } else if (type === 'area') {
  706. filters.area = {}
  707. } else if (type === 'industry') {
  708. filters.industry = []
  709. filters.industryDetail = {}
  710. } else if (type === 'buyerclass') {
  711. filters.buyerclass = []
  712. } else if (type === 'date') {
  713. this.filters.rangeTime.start = ''
  714. this.filters.rangeTime.edd = ''
  715. this.filters.rangeTime.exact = 'sinceYearBeforeLast'
  716. this.initDateTimeSelector(this.filters.rangeTime.exact)
  717. } else {
  718. this.resetFilter('keys')
  719. this.resetFilter('area')
  720. this.resetFilter('industry')
  721. this.resetFilter('buyerclass')
  722. this.resetFilter('date')
  723. }
  724. },
  725. clickCell: function (key) {
  726. var _this = this
  727. var dialog = this.filterDialogShow
  728. if (key === 'keys') {
  729. if (this.notSetKey) {
  730. return this.setKeyTip()
  731. }
  732. } else if (key === 'area') {
  733. setTimeout(function () {
  734. _this.$refs.areaCitySelector.setState(_this.filters.area)
  735. }, 0)
  736. } else if (key === 'buyerclass') {
  737. setTimeout(function () {
  738. _this.$refs.buyerclassSelector.setState()
  739. }, 0)
  740. } else if (key === 'industry') {
  741. setTimeout(function () {
  742. _this.$refs.industrySelector.setState()
  743. }, 0)
  744. }
  745. dialog[key] = true
  746. },
  747. cancel: function (e, key) {
  748. var dialog = this.filterDialogShow
  749. this.resetFilter(key)
  750. dialog[key] = false
  751. },
  752. confirm: function (e, key) {
  753. var dialog = this.filterDialogShow
  754. var filters = this.filters
  755. if (key === 'keys') {
  756. filters.keys = e.detail
  757. filters.selectKeysArr = e.data
  758. } else if (key === 'area') {
  759. filters.area = e.data
  760. } else if (key === 'industry') {
  761. filters.industry = e.data
  762. filters.industryDetail = e.detail
  763. } else if (key === 'buyerclass') {
  764. filters.buyerclass = e.data
  765. console.log(e.data)
  766. }
  767. dialog[key] = false
  768. },
  769. dateTimeSelectorConfirm () {
  770. var result = this.$refs.dateSelector.getState()
  771. this.filters.rangeTime.start = result.start
  772. this.filters.rangeTime.end = result.end
  773. this.filters.rangeTime.exact = result.exact
  774. },
  775. resetAllFilters: function () {
  776. this.analysis.loaded = false
  777. this.resetFilter('all')
  778. },
  779. getReportResult () {
  780. this.sendRequest()
  781. },
  782. getSelectedKeys () {
  783. const keys = this.filters.keys
  784. if (Array.isArray(keys) && keys.length) {
  785. return JSON.stringify(keys)
  786. } else {
  787. var allKeys = this.$refs.keywordSelector.keywordGroupList
  788. return JSON.stringify(allKeys)
  789. }
  790. },
  791. startAnalysis: function () {
  792. this.dateTimeSelectorConfirm()
  793. const query = {
  794. keysItems: this.getSelectedKeys(),
  795. rangeTime: `${parseInt(this.filters.rangeTime.start / 1000)}-${parseInt(this.filters.rangeTime.end / 1000)}`,
  796. rangeTimeExtra: this.filters.rangeTime.exact,
  797. area: JSON.stringify(this.filters.area),
  798. industry: JSON.stringify(this.filters.industryDetail),
  799. buyerclass: this.filters.buyerclass.join(',')
  800. }
  801. this.analysis.loaded = false
  802. this.analysis.loading = true
  803. this.showLoading()
  804. $.ajax({
  805. type: 'POST',
  806. url: '/bigmember/marketAnalysis/doAnalysis',
  807. data: query,
  808. success: function (res) {
  809. if (res && res.error_code === 0 && res.data) {
  810. this.rid = res.data
  811. this.analysis.loaded = true
  812. // location.replace('./report_analysis?id=' + res.data)
  813. this.rid = res.data
  814. history.replaceState({}, null, '?id=' + this.rid)
  815. this.getReportResult()
  816. } else {
  817. this.$toast(res.error_msg)
  818. }
  819. }.bind(this),
  820. complete: function () {
  821. this.analysis.loading = false
  822. }.bind(this)
  823. })
  824. },
  825. // 保存页面状态
  826. saveState: function () {
  827. this.saveScrollTop()
  828. this.dateTimeSelectorConfirm()
  829. var $data = {
  830. analysis: this.analysis,
  831. filters: this.filters,
  832. scrollTop: this.scrollTop,
  833. filtersPageShow: this.filtersPageShow,
  834. reportFilters: this.reportFilters,
  835. sections: this.sections,
  836. isSubCount: this.isSubCount
  837. }
  838. sessionStorage.setItem(this.sessStorageKey, JSON.stringify($data))
  839. },
  840. reStoreState: function () {
  841. var $data = sessionStorage.getItem(this.sessStorageKey)
  842. if ($data) {
  843. $data = JSON.parse($data)
  844. this.isSubCount = $data.isSubCount
  845. this.scrollTop = $data.scrollTop
  846. this.filtersPageShow = $data.filtersPageShow
  847. Object.assign(this.analysis, $data.analysis)
  848. this.$set(this, 'filters', $data.filters)
  849. this.$set(this, 'reportFilters', $data.reportFilters)
  850. this.$set(this, 'sections', $data.sections)
  851. setTimeout(function () {
  852. // 恢复滚动高度
  853. this.setScrollTop(this.scrollTop)
  854. this.initDateTimeSelector(this.filters.rangeTime.exact)
  855. }.bind(this), 0)
  856. sessionStorage.removeItem(this.sessStorageKey)
  857. } else {
  858. this.init()
  859. }
  860. return $data
  861. },
  862. onEmpty (info) {
  863. if (this.loading) {
  864. this.loading.clear()
  865. }
  866. this.filtersPageShow = true
  867. this.analysis.loaded = true
  868. this.rid = ''
  869. if (info && info.msg) {
  870. this.empty.msg = info.msg
  871. } else {
  872. this.empty.msg = this.empty.defaultMsg
  873. }
  874. },
  875. sendRequest () {
  876. let _this = this
  877. // 先请求概况(1),判断报告是否为空
  878. const query = {
  879. rid: this.rid,
  880. flag: 1
  881. }
  882. if (!query.rid) {
  883. return
  884. }
  885. this.loading = this.showLoading()
  886. $.ajax({
  887. type: 'POST',
  888. async: false,
  889. url: '/bigmember/marketAnalysis/getAnalysisResult',
  890. data: query,
  891. success: function(res) {
  892. if (res && res.error_code === 0 && res.data) {
  893. var empty = _this.formatterData(query.flag, res.data)
  894. if (empty) {
  895. return _this.onEmpty()
  896. }
  897. } else {
  898. if (res.error_msg.indexOf('项目数量超出上限') === -1) {
  899. return _this.onEmpty()
  900. } else {
  901. return _this.onEmpty({ msg: '当前分析条件涉及项目数量已超过最大限制,请修改分析条件进行精确分析' })
  902. }
  903. }
  904. }
  905. }).responseJSON
  906. this.filtersPageShow = false
  907. const flagArr = [
  908. 0, // 筛选条件
  909. // 1, // 市场概括与时间分布
  910. 2, // 项目规模Top10
  911. 3, // 项目规模分布/地区规模分布/客户分布/地区分布及客户分布&Top3(table+chart)
  912. 4, // 细分市场
  913. 5 // 采购单位/中标单位&Top3(table+chart)
  914. ]
  915. flagArr.forEach(this.getReport)
  916. if (this.loading) {
  917. this.loading.clear()
  918. }
  919. },
  920. getReport (flag) {
  921. const query = {
  922. rid: this.rid,
  923. flag
  924. }
  925. if (!query.rid) {
  926. return
  927. }
  928. $.ajax({
  929. type: 'POST',
  930. url: '/bigmember/marketAnalysis/getAnalysisResult',
  931. data: query,
  932. success: function (res) {
  933. if (res && res.error_code === 0 && res.data) {
  934. if(flag==3){
  935. sessionStorage.setItem('getAnalysisResult_',JSON.stringify(res))
  936. }
  937. this.formatterData(flag, res.data)
  938. } else {
  939. this.$toast('请求失败')
  940. }
  941. }.bind(this)
  942. })
  943. },
  944. formatterData (flag, data) {
  945. if (flag === 0) {
  946. this.sortReportFilters(data)
  947. } else if (flag === 1) {
  948. // 市场概况
  949. const totalCount = this.sortMarketOverview(data.market_profile)
  950. if (!totalCount) {
  951. return true
  952. }
  953. // 时间分布
  954. this.sortTimeScatter(data)
  955. } else if (flag === 2) {
  956. // 项目规模Top10
  957. this.sortProjectTop10(data.ProjectTop10)
  958. } else if (flag === 3) {
  959. // 项目规模分布/地区规模分布/客户分布/地区分布及客户分布&Top3(table+chart)
  960. // 项目规模分布
  961. this.sortProjectScatter(data.projectScale)
  962. // 地区规模分布
  963. this.sections.areaScatter.originAreaData = data.area_infos
  964. this.sortAreaScatter(data.area_infos)
  965. // 城市分布
  966. this.sortAreaCityScatter(data.area_infos)
  967. // 客户分布
  968. if(data.customer_scale){
  969. if(data.customer_scale.length!=0){
  970. let data_=data.customer_scale.slice(0,10)
  971. this.sortUserScatter(data_)
  972. }
  973. }
  974. // 地区分布及客户分布Top3
  975. this.sortAreaUserTop3(data)
  976. } else if (flag === 4) {
  977. // 细分市场
  978. this.sortMarketRefineData(data)
  979. } else if (flag === 5) {
  980. // 采购单位/中标单位&Top3(table+chart)
  981. this.sortBuyerclassData(data)
  982. // 中标单位分析
  983. this.sortWinnerData(data)
  984. }
  985. this.$nextTick(this.calcOffsetTop)
  986. },
  987. formatSelectTime (value) {
  988. if (!value) return '-'
  989. const timeArr = value.split('-')
  990. return `${dateFormatter(timeArr[0] * 1000, 'yyyy/MM/dd')}-${dateFormatter(timeArr[1] * 1000, 'yyyy/MM/dd')}`
  991. },
  992. // 整理数据,并赋值给filters
  993. sortReportFilters (data) {
  994. if (data.keysItems && data.keysItems !== '[]') {
  995. this.reportFilters.keys = JSON.parse(data.keysItems)
  996. this.filters.keys = this.reportFilters.keys
  997. var keyArr = []
  998. this.filters.keys.forEach(function (classify) {
  999. if(Array.isArray(classify.a_key)) {
  1000. classify.a_key.forEach(function (item) {
  1001. keyArr.push(item.key.join(' '))
  1002. })
  1003. }
  1004. })
  1005. this.filters.selectKeysArr = keyArr
  1006. }
  1007. // if (data.s_rangeTimeExtra) {
  1008. // this.reportFilters.selectTimeExtra = data.s_rangeTimeExtra
  1009. // this.filters.rangeTime.exact = this.reportFilters.selectTimeExtra
  1010. // } else {
  1011. // this.filters.rangeTime.exact = 'exact'
  1012. // }
  1013. this.filters.rangeTime.exact = 'exact'
  1014. if (data.rangeTime) {
  1015. this.reportFilters.selectTime = data.rangeTime
  1016. var arr = data.rangeTime.split('-')
  1017. this.filters.rangeTime.start = arr[0] * 1000
  1018. this.filters.rangeTime.end = arr[1] * 1000
  1019. if (this.filters.rangeTime.exact === 'exact') {
  1020. var date = new Date(this.filters.rangeTime.end)
  1021. var timeString = date.pattern('yyyy/MM/dd')
  1022. this.filters.rangeTime.end = new Date(timeString).getTime()
  1023. }
  1024. }
  1025. this.$refs.dateSelector.setState(this.filters.rangeTime)
  1026. if (data.area && data.area !== '{}') {
  1027. this.reportFilters.area = JSON.parse(data.area)
  1028. this.filters.area = this.reportFilters.area
  1029. }
  1030. if (data.industry && data.industry !== '{}') {
  1031. this.reportFilters.industry = JSON.parse(data.industry)
  1032. this.$set(this.filters, 'industryDetail', this.reportFilters.industry)
  1033. var industry = []
  1034. for (var key in this.reportFilters.industry) {
  1035. this.reportFilters.industry[key].forEach(function (item) {
  1036. industry.push(key + '_' + item)
  1037. })
  1038. }
  1039. this.filters.industry = industry
  1040. }
  1041. if (data.buyerclass) {
  1042. this.reportFilters.buyerclass = data.buyerclass.split(',')
  1043. this.filters.buyerclass = this.reportFilters.buyerclass
  1044. }
  1045. },
  1046. // 市场概况
  1047. sortMarketOverview (profile) {
  1048. if (!profile) return
  1049. const list = [
  1050. {
  1051. label: '项目总数',
  1052. unit: '个',
  1053. count: 0,
  1054. ringRatio: 0
  1055. },
  1056. {
  1057. label: '项目总金额',
  1058. unit: '万元',
  1059. count: 0,
  1060. ringRatio: 0
  1061. },
  1062. {
  1063. label: '项目平均金额',
  1064. unit: '万元',
  1065. count: 10.04,
  1066. ringRatio: 0
  1067. },
  1068. {
  1069. label: '中标单位数',
  1070. unit: '家',
  1071. count: 10628,
  1072. ringRatio: 0
  1073. },
  1074. {
  1075. label: '采购单位数',
  1076. unit: '家',
  1077. count: 16215,
  1078. ringRatio: 0
  1079. }
  1080. ]
  1081. // 项目总数
  1082. list[0].count = profile.project_count ? profile.project_count : 0
  1083. list[0].ringRatio = profile.project_count_ratio ? (profile.project_count_ratio * 100).toFixed(2) : 0
  1084. // 项目总金额
  1085. const projectTotalMoney = this.moneyUnit(profile.projctamout ? profile.projctamout : 0)
  1086. list[1].count = projectTotalMoney.count || 0
  1087. list[1].unit = projectTotalMoney.unit || '万元'
  1088. list[1].ringRatio = profile.projctamount_ratio ? (profile.projctamount_ratio * 100).toFixed(2) : 0
  1089. // 项目平均金额
  1090. const projectAvgMoney = this.moneyUnit(profile.projectavgmoney ? profile.projectavgmoney : 0)
  1091. list[2].count = projectAvgMoney.count || 0
  1092. list[2].unit = projectAvgMoney.unit || '万元'
  1093. list[2].ringRatio = profile.projectavgmoney_ratio ? (profile.projectavgmoney_ratio * 100).toFixed(2) : 0
  1094. // 中标单位数
  1095. list[3].count = profile.winnercount ? profile.winnercount : 0
  1096. list[3].ringRatio = profile.winnercount_ratio ? (profile.winnercount_ratio * 100).toFixed(2) : 0
  1097. // 采购单位数
  1098. list[4].count = profile.buyercount ? profile.buyercount : 0
  1099. list[4].ringRatio = profile.winnercount_ratio ? (profile.winnercount_ratio * 100).toFixed(2) : 0
  1100. var totalCount = list.reduce((total, item) => item.count + total, 0)
  1101. if (totalCount) {
  1102. this.sections.market.overview = list
  1103. }
  1104. return totalCount
  1105. },
  1106. // 时间分布
  1107. sortTimeScatter (data) {
  1108. const hasDataM = this.sortTimeScatterData('month', data.month_distribution)
  1109. const hasDataY = this.sortTimeScatterData('year', data.year_distribution)
  1110. const hasData = hasDataM && hasDataY
  1111. this.sections.timeScatter.dataAlready = hasData
  1112. },
  1113. sortTimeScatterData (type, data) {
  1114. // columns: ['日期', '项目规模', '环比增长率(%)'],
  1115. // rows: [
  1116. // {
  1117. // 日期: '6月',
  1118. // 项目规模: 0,
  1119. // '环比增长率(%)': -99
  1120. // },
  1121. // {
  1122. // 日期: '7月',
  1123. // 项目规模: 736325,
  1124. // '环比增长率(%)': 0
  1125. // },
  1126. // ]
  1127. if (!data) return
  1128. // 项目数量
  1129. const mDCount = {
  1130. columns: ['日期', '项目数量(个)', '项目数量环比'],
  1131. rows: []
  1132. }
  1133. let mDCountTotal = 0
  1134. if (Array.isArray(data.project_count)) {
  1135. const field = {
  1136. [mDCount.columns[0]]: 'minth',
  1137. [mDCount.columns[1]]: 'value',
  1138. [mDCount.columns[2]]: 'ratio'
  1139. }
  1140. data.project_count.forEach(item => {
  1141. const row = {}
  1142. mDCount.columns.forEach(column => {
  1143. var value = item[field[column]]
  1144. if (value) {
  1145. if (field[column] === 'ratio') {
  1146. row[column] = utils.formatMoney(value * 100, undefined, true) - 0
  1147. } else {
  1148. row[column] = value
  1149. }
  1150. } else {
  1151. row[column] = null
  1152. }
  1153. if (typeof value === 'number') {
  1154. mDCountTotal += value
  1155. }
  1156. })
  1157. mDCount.rows.push(row)
  1158. })
  1159. }
  1160. if (mDCountTotal || isNaN(mDCountTotal)) {
  1161. this.$set(this.sections.timeScatter[type], 'count', mDCount)
  1162. }
  1163. // 项目规模
  1164. const mDAmount = {
  1165. columns: ['日期', '项目金额(万元)', '项目金额环比'],
  1166. rows: []
  1167. }
  1168. let mDAmuntTotal = 0
  1169. if (Array.isArray(data.project_amount)) {
  1170. const field = {
  1171. [mDAmount.columns[0]]: 'minth',
  1172. [mDAmount.columns[1]]: 'value',
  1173. [mDAmount.columns[2]]: 'ratio'
  1174. }
  1175. data.project_amount.forEach(item => {
  1176. const row = {}
  1177. mDAmount.columns.forEach(column => {
  1178. const value = item[field[column]]
  1179. if (value) {
  1180. if (field[column] === 'value') {
  1181. row[column] = utils.formatMoney(value / 10000, undefined, true) - 0
  1182. } else if (field[column] === 'ratio') {
  1183. row[column] = utils.formatMoney(value * 100, undefined, true)
  1184. } else {
  1185. row[column] = value
  1186. }
  1187. } else {
  1188. row[column] = null
  1189. }
  1190. if (typeof value === 'number') {
  1191. mDAmuntTotal += value
  1192. }
  1193. })
  1194. mDAmount.rows.push(row)
  1195. })
  1196. }
  1197. if (mDAmuntTotal || !isNaN(mDAmuntTotal)) {
  1198. this.$set(this.sections.timeScatter[type], 'amount', mDAmount)
  1199. }
  1200. const r = !!(mDCountTotal + mDAmuntTotal)
  1201. const hasOneNaN = isNaN(mDCountTotal) || isNaN(mDAmuntTotal)
  1202. return hasOneNaN || r
  1203. },
  1204. // 项目规模分布
  1205. sortProjectScatter (data) {
  1206. // const chartData = {
  1207. // columns: ['项目规模', '项目总金额占比', '项目总数占比'],
  1208. // rows: [
  1209. // {
  1210. // 项目规模: '≥1亿',
  1211. // 项目总金额占比: 20,
  1212. // 项目总数占比: 10
  1213. // },
  1214. // {
  1215. // 项目规模: '1000万-1亿',
  1216. // 项目总金额占比: 50,
  1217. // 项目总数占比: 40
  1218. // },
  1219. // {
  1220. // 项目规模: '500万-1000万',
  1221. // 项目总金额占比: 20,
  1222. // 项目总数占比: 30
  1223. // },
  1224. // {
  1225. // 项目规模: '100万-500万',
  1226. // 项目总金额占比: 20,
  1227. // 项目总数占比: 30
  1228. // }
  1229. // ]
  1230. // }
  1231. const scaleList = data
  1232. const scaleData = {
  1233. columns: ['项目规模', '项目总金额占比', '项目总数占比'],
  1234. rows: []
  1235. }
  1236. let total = 0
  1237. if (scaleList && Array.isArray(scaleList)) {
  1238. const field = {
  1239. [scaleData.columns[0]]: 'Name',
  1240. [scaleData.columns[1]]: 'Persent_c',
  1241. [scaleData.columns[2]]: 'Persent_a'
  1242. }
  1243. scaleList.forEach(item => {
  1244. const row = {}
  1245. scaleData.columns.forEach(column => {
  1246. if (field[column] === 'Persent_c' || field[column] === 'Persent_a') {
  1247. row[column] = (item[field[column]] * 100).toFixed(2)
  1248. total += (item[field[column]] - 0)
  1249. } else {
  1250. row[column] = item[field[column]]
  1251. }
  1252. })
  1253. scaleData.rows.push(row)
  1254. })
  1255. }
  1256. if (total) {
  1257. scaleData.rows.reverse()
  1258. this.$set(this.sections.projectScatter, 'chartData', scaleData)
  1259. if (this.sections.projectScatter.tableData.length) {
  1260. this.sections.projectScatter.dataAlready = true
  1261. }
  1262. }
  1263. },
  1264. // 项目规模Top10
  1265. sortProjectTop10 (top10List) {
  1266. if (!Array.isArray(top10List)) return
  1267. this.sections.projectScatter.tableData = top10List.map(top => {
  1268. let winners = top.winner_s ? top.winner_s.join(',') : ''
  1269. if (!winners) {
  1270. winners = []
  1271. } else {
  1272. winners = top.winner_s
  1273. }
  1274. winners = winners.map((item, index) => {
  1275. return {
  1276. name: item,
  1277. id: Array.isArray(top.eidlist) ? top.eidlist[index] : null
  1278. }
  1279. })
  1280. top.area = top.area ? top.area : ''
  1281. top.city = top.city ? top.city : ''
  1282. top.sortprice = top.sortprice ? utils.formatMoney(top.sortprice / 10000, undefined, true) : ''
  1283. top.jgtime = top.jgtime ? dateFormatter(top.jgtime * 1000, 'yyyy-MM-dd') : ''
  1284. top.winner_s = winners
  1285. return top
  1286. })
  1287. if (this.sections.projectScatter.chartData) {
  1288. this.sections.projectScatter.dataAlready = true
  1289. }
  1290. },
  1291. // 地区规模分布
  1292. sortAreaScatter (areaList) {
  1293. // const chartData = {
  1294. // columns: ['项目所在地', '项目数量', '项目金额'],
  1295. // rows: [
  1296. // {
  1297. // 项目所在地: '河南',
  1298. // 项目数量: 2,
  1299. // 项目金额: 2222
  1300. // },
  1301. // {
  1302. // 项目所在地: '北京',
  1303. // 项目数量: 22,
  1304. // 项目金额: 565666
  1305. // },
  1306. // {
  1307. // 项目所在地: '浙江',
  1308. // 项目数量: 22,
  1309. // 项目金额: 765666
  1310. // }
  1311. // ]
  1312. // }
  1313. const areaChartData = {
  1314. columns: ['项目所在地', '项目数量'],
  1315. sColumns: ['项目金额'],
  1316. rows: []
  1317. }
  1318. let total = 0
  1319. if (areaList && Array.isArray(areaList)) {
  1320. const field = {
  1321. [areaChartData.columns[0]]: 'area',
  1322. [areaChartData.columns[1]]: 'total',
  1323. [areaChartData.sColumns[0]]: 'amount'
  1324. }
  1325. areaList.forEach(item => {
  1326. const row = {}
  1327. areaChartData.columns.concat(areaChartData.sColumns).forEach(column => {
  1328. if (field[column] === 'amount') {
  1329. row[column] = utils.formatMoney(item[field[column]] / 10000, undefined, true) - 0
  1330. } else {
  1331. row[column] = item[field[column]]
  1332. }
  1333. if (field[column] === 'amount' || field[column] === 'total') {
  1334. total += (item[field[column]] - 0)
  1335. }
  1336. })
  1337. areaChartData.rows.push(row)
  1338. })
  1339. }
  1340. if (total) {
  1341. this.$set(this.sections.areaScatter, 'chartData', areaChartData)
  1342. this.sections.areaScatter.dataAlready = true
  1343. }
  1344. },
  1345. setAreaCity () {
  1346. this.sections.areaScatter.showAreaPopup = true
  1347. const selectAreaArr = [this.sections.areaScatter.selectArea.area]
  1348. this.$refs.areaSelector.setState(selectAreaArr)
  1349. },
  1350. // 城市分布
  1351. sortAreaCityScatter (areacitylist) {
  1352. const list = areacitylist
  1353. const ZXS = ['北京', '天津', '上海', '重庆', '台湾', '澳门', '香港']
  1354. const result = list.reduce((max, item) => {
  1355. const isMaxZXS = ZXS.includes(max.area)
  1356. const isZXS = ZXS.includes(item.area);
  1357. const isMaxTotal = item.total > max.total;
  1358. const isNotZXSMaxTotal = (isMaxTotal && !isZXS) || isMaxZXS;
  1359. return isNotZXSMaxTotal ? item : max
  1360. })
  1361. if (result.areaDetails.length > 5) {
  1362. this.sections.areaScatter.showAreaCityListBtn = true
  1363. } else {
  1364. this.sections.areaScatter.showAreaCityListBtn = false
  1365. }
  1366. this.sections.areaScatter.setCityList = this.formatterWinData(result.areaDetails, 'total')
  1367. this.sections.areaScatter.selectArea = result
  1368. },
  1369. // 格式化进度条图表数据
  1370. formatterWinData: function(data,type) {
  1371. data.forEach(function(v,i){
  1372. // v.bidamount = (v.bidamount / 10000).fixed(2);
  1373. // v.average = (v.average / 10000).fixed(2);
  1374. switch (type) {
  1375. case 'total':
  1376. v.parent = v.total / data[0].total*100 + "%";
  1377. break;
  1378. case 'amount':
  1379. v.parent = v.amount / data[0].amount*100 + "%";
  1380. break;
  1381. }
  1382. })
  1383. return data;
  1384. },
  1385. // 客户分布
  1386. sortUserScatter (userList) {
  1387. if (Array.isArray(userList)) {
  1388. this.sections.userScatter.list = userList.map(item => {
  1389. item.name = item.buyclass
  1390. item.value = item.total
  1391. item.amount = utils.formatMoney(item.amount / 10000, undefined, true)
  1392. return item
  1393. })
  1394. }
  1395. },
  1396. // 地区分布及客户分布Top3
  1397. sortAreaUserTop3 (data) {
  1398. if (data.scaleAreaCountTop || data.scaleAreaAmountTop) {
  1399. this.sorAreaTop3(data)
  1400. } else {
  1401. this.sections.areaScatter.projectCountTop3 = null
  1402. this.sections.areaScatter.projectAmountTop3 = null
  1403. }
  1404. if (data.scaleBuyclassCountTop || data.scaleBuyclassAmountTop) {
  1405. this.sorUserTop3(data)
  1406. }
  1407. },
  1408. sorAreaTop3 (data) {
  1409. const tableDataCount = {
  1410. columns: ['序号', '地区:项目数量(个),占比', '前3中标单位:中标数量(个)'], // ,该地区占比
  1411. rows: []
  1412. }
  1413. const tableDataAmount = {
  1414. columns: ['序号', '地区:项目金额(万元),占比', '前3中标单位:中标金额(万元)'], // ,该地区占比
  1415. rows: []
  1416. }
  1417. const scaleAreaCountTop3 = data.scaleAreaCountTop
  1418. if (Array.isArray(scaleAreaCountTop3)) {
  1419. scaleAreaCountTop3.forEach((item, index) => {
  1420. item.name = item.name
  1421. item.subInfo1 = item.area_count ? `项目数量:${item.area_count}个` : ''
  1422. item.subInfo2 = item.area_scale ? `全国占比:${utils.formatMoney(item.area_scale * 100, undefined, true)}%` : ''
  1423. item.actionText = `中标单位 TOP3`
  1424. item.childrenShow = true
  1425. item.children = []
  1426. if (Array.isArray(item.winner)) {
  1427. item.winner.forEach((w, i) => {
  1428. const row = {
  1429. name: w.winner,
  1430. id: w.id,
  1431. type: 'winner',
  1432. subInfo1: w.winner_total ? `中标个数:${w.winner_total}个` : '',
  1433. // subInfo2: w.total_scale ? `地区占比:${utils.formatMoney(w.total_scale * 100, undefined, true)}%` : 0
  1434. }
  1435. item.children.push(row)
  1436. })
  1437. }
  1438. })
  1439. tableDataCount.rows = scaleAreaCountTop3
  1440. }
  1441. const scaleAreaAmountTop3 = data.scaleAreaAmountTop
  1442. if (Array.isArray(scaleAreaAmountTop3)) {
  1443. scaleAreaAmountTop3.forEach((item, index) => {
  1444. item.name = item.name
  1445. item.subInfo1 = item.area_amount ? `中标金额:${utils.formatMoney(item.area_amount / 10000, undefined, true)}万元` : ''
  1446. item.subInfo2 = item.area_scale ? `全国占比:${utils.formatMoney(item.area_scale * 100, undefined, true)}%` : ''
  1447. item.actionText = `中标单位 TOP3`
  1448. item.childrenShow = true
  1449. item.children = []
  1450. if (Array.isArray(item.winner)) {
  1451. item.winner.forEach((w, i) => {
  1452. const row = {
  1453. name: w.winner,
  1454. id: w.id,
  1455. type: 'winner',
  1456. subInfo1: w.winner_amount ? `中标金额:${utils.formatMoney(w.winner_amount / 10000, undefined, true)}万元` : '',
  1457. // subInfo2: w.amount_scale ? `地区占比:${utils.formatMoney(w.amount_scale * 100, undefined, true)}%` : ''
  1458. }
  1459. item.children.push(row)
  1460. })
  1461. }
  1462. })
  1463. tableDataAmount.rows = scaleAreaAmountTop3
  1464. }
  1465. if (tableDataCount.rows.length) {
  1466. this.$set(this.sections.areaScatter, 'projectCountTop3', tableDataCount.rows)
  1467. }
  1468. if (tableDataAmount.rows.length) {
  1469. this.$set(this.sections.areaScatter, 'projectAmountTop3', tableDataAmount.rows)
  1470. }
  1471. },
  1472. sorUserTop3 (data) {
  1473. const tableDataCount = {
  1474. columns: ['序号', '客户类型:项目数量(个),占比', '前3中标单位:中标数量(个)'], // ,该客户类型占比
  1475. rows: []
  1476. }
  1477. const tableDataAmount = {
  1478. columns: ['序号', '客户类型:项目金额(万元),占比', '前3中标单位:中标金额(万元)'], // ,该客户类型占比
  1479. rows: []
  1480. }
  1481. const countTop3 = data.scaleBuyclassCountTop
  1482. if (Array.isArray(countTop3)) {
  1483. countTop3.forEach((item, index) => {
  1484. item.name = item.name
  1485. item.subInfo1 = item.buyclass_count ? `项目数量:${item.buyclass_count}个` : ''
  1486. item.subInfo2 = item.buyclass_scale ? `全部占比:${utils.formatMoney(item.buyclass_scale * 100, undefined, true)}%` : ''
  1487. item.actionText = `中标单位 TOP3`
  1488. item.childrenShow = true
  1489. item.children = []
  1490. if (Array.isArray(item.winner)) {
  1491. item.winner.forEach((w, i) => {
  1492. const row = {
  1493. name: w.winner,
  1494. id: w.id,
  1495. type: 'winner',
  1496. subInfo1: w.winner_total ? `中标个数:${w.winner_total}个` : '',
  1497. // subInfo2: w.total_scale ? `该行业占比:${utils.formatMoney(w.total_scale * 100, undefined, true)}%` : ''
  1498. }
  1499. item.children.push(row)
  1500. })
  1501. }
  1502. })
  1503. tableDataCount.rows = countTop3
  1504. }
  1505. const amountTop3 = data.scaleBuyclassAmountTop
  1506. if (Array.isArray(amountTop3)) {
  1507. amountTop3.forEach((item, index) => {
  1508. item.name = item.name
  1509. item.subInfo1 = item.buyclass_amount ? `项目金额:${utils.formatMoney(item.buyclass_amount / 10000, undefined, true)}万元` : ''
  1510. item.subInfo2 = item.buyclass_scale ? `全部占比:${utils.formatMoney(item.buyclass_scale * 100, undefined, true)}%` : 0
  1511. item.actionText = `中标单位 TOP3`
  1512. item.childrenShow = true
  1513. item.children = []
  1514. if (Array.isArray(item.winner)) {
  1515. item.winner.forEach((w, i) => {
  1516. const row = {
  1517. name: w.winner,
  1518. id: w.id,
  1519. type: 'winner',
  1520. subInfo1: w.winner_amount ? `中标金额:${utils.formatMoney(w.winner_amount / 10000, undefined, true)}万元` : '',
  1521. // subInfo2: w.amount_scale ? `该行业占比:${utils.formatMoney(w.amount_scale * 100, undefined, true)}%` : ''
  1522. }
  1523. item.children.push(row)
  1524. })
  1525. }
  1526. })
  1527. tableDataAmount.rows = amountTop3
  1528. }
  1529. if (tableDataCount.rows.length) {
  1530. this.$set(this.sections.userScatter, 'projectCountTop3', tableDataCount.rows)
  1531. }
  1532. if (tableDataAmount.rows.length) {
  1533. this.$set(this.sections.userScatter, 'projectAmountTop3', tableDataAmount.rows)
  1534. }
  1535. },
  1536. // 细分市场
  1537. sortMarketRefineData (data) {
  1538. const refineCount = {
  1539. columns: ['行业', '项目数量'],
  1540. rows: []
  1541. }
  1542. const refineAmount = {
  1543. columns: ['行业', '项目金额'],
  1544. rows: []
  1545. }
  1546. let total = 0
  1547. const refineAll = data.scaleRefineAll
  1548. if (Array.isArray(refineAll)) {
  1549. const field = {
  1550. 行业: 'name',
  1551. 项目数量: 'total',
  1552. 项目金额: 'amount'
  1553. }
  1554. refineAll.forEach(item => {
  1555. const row = {}
  1556. for (const key in field) {
  1557. if (field[key] === 'amount') {
  1558. row[key] = utils.formatMoney(item[field[key]] / 10000, undefined, true)
  1559. } else {
  1560. row[key] = item[field[key]]
  1561. }
  1562. if (field[key] === 'total' || field[key] === 'amount') {
  1563. total += (item[field[key]] - 0)
  1564. }
  1565. }
  1566. refineCount.rows.push(row)
  1567. refineAmount.rows.push(row)
  1568. })
  1569. }
  1570. if (total) {
  1571. this.$set(this.sections.market.refine, 'projectCountData', refineCount)
  1572. this.$set(this.sections.market.refine, 'projectAmountData', refineAmount)
  1573. this.sections.market.refine.dataAlready = true
  1574. }
  1575. this.sortRefineTop3(data)
  1576. },
  1577. sortRefineTop3 (data) {
  1578. const tableDataCount = {
  1579. columns: ['序号', '细分市场:项目数量(个)', '前3中标单位:中标数量(个)'], // ,占比,该细分市场占比
  1580. rows: []
  1581. }
  1582. const tableDataAmount = {
  1583. columns: ['序号', '细分市场:项目金额(万元)', '前3中标单位:中标金额(万元)'], // ,占比,该细分市场占比
  1584. rows: []
  1585. }
  1586. const countTop3 = data.scaleRefineTotalTop
  1587. if (Array.isArray(countTop3)) {
  1588. countTop3.forEach((item, index) => {
  1589. item.name = item.name
  1590. item.subInfo1 = item.value ? `项目数量:${item.value}个` : ''
  1591. // item.subInfo2 = item.prop ? `全部占比:${utils.formatMoney(item.prop * 100, undefined, true)}%` : 0
  1592. item.actionText = `中标单位 TOP3`
  1593. item.childrenShow = true
  1594. item.children = []
  1595. if (Array.isArray(item.topList)) {
  1596. item.topList.forEach((w, i) => {
  1597. const row = {
  1598. name: w.name,
  1599. id: w.id,
  1600. type: 'winner',
  1601. subInfo1: w.value ? `中标个数:${w.value}个` : '',
  1602. // subInfo2: w.prop ? `该细分市场占比:${utils.formatMoney(w.prop * 100, undefined, true)}%` : ''
  1603. }
  1604. item.children.push(row)
  1605. })
  1606. }
  1607. })
  1608. tableDataCount.rows = countTop3
  1609. }
  1610. const amountTop3 = data.scaleRefineAmountTop
  1611. if (Array.isArray(amountTop3)) {
  1612. amountTop3.forEach((item, index) => {
  1613. item.name = item.name
  1614. item.subInfo1 = item.value ? `项目金额:${utils.formatMoney(item.value / 10000, undefined, true)}万元` : ''
  1615. // item.subInfo2 = item.prop ? `全部占比:${utils.formatMoney(item.prop * 100, undefined, true)}%` : 0
  1616. item.actionText = `中标单位 TOP3`
  1617. item.childrenShow = true
  1618. item.children = []
  1619. if (Array.isArray(item.topList)) {
  1620. item.topList.forEach((w, i) => {
  1621. const row = {
  1622. name: w.name,
  1623. id: w.id,
  1624. type: 'winner',
  1625. subInfo1: w.value ? `中标金额:${utils.formatMoney(w.value / 10000, undefined, true)}万元` : '',
  1626. // subInfo2: w.prop ? `该细分市场占比:${utils.formatMoney(w.prop * 100, undefined, true)}%`: ''
  1627. }
  1628. item.children.push(row)
  1629. })
  1630. }
  1631. })
  1632. tableDataAmount.rows = amountTop3
  1633. }
  1634. if (tableDataCount.rows.length) {
  1635. this.$set(this.sections.market.refine, 'projectCountTop3', tableDataCount.rows)
  1636. }
  1637. if (tableDataAmount.rows.length) {
  1638. this.$set(this.sections.market.refine, 'projectAmountTop3', tableDataAmount.rows)
  1639. }
  1640. },
  1641. // 采购单位
  1642. sortBuyerclassData (data) {
  1643. const buyerclassChartData = {
  1644. columns: ['金额区间', '采购总金额占比', '采购单位数量占比'],
  1645. rows: []
  1646. }
  1647. let total = 0
  1648. const buyerclassList = data.buyer_time_distribution
  1649. if (Array.isArray(buyerclassList)) {
  1650. const field = {
  1651. [buyerclassChartData.columns[0]]: 'key',
  1652. [buyerclassChartData.columns[1]]: 'total_amount',
  1653. [buyerclassChartData.columns[2]]: 'total_number'
  1654. }
  1655. buyerclassList.forEach(item => {
  1656. const row = {}
  1657. buyerclassChartData.columns.forEach(column => {
  1658. if (field[column] === 'total_amount' || field[column] === 'total_number') {
  1659. row[column] = (item[field[column]] * 100).toFixed(2)
  1660. total += (item[field[column]] - 0)
  1661. } else {
  1662. row[column] = item[field[column]]
  1663. }
  1664. })
  1665. buyerclassChartData.rows.push(row)
  1666. })
  1667. }
  1668. if (total) {
  1669. buyerclassChartData.rows.reverse()
  1670. this.$set(this.sections.buyerclass, 'chartData', buyerclassChartData)
  1671. this.sections.buyerclass.dataAlready = true
  1672. }
  1673. this.sortBuyerclassTableData(data)
  1674. },
  1675. sortBuyerclassTableData (data) {
  1676. const dataCount = {
  1677. columns: ['序号', '采购单位:采购数量(个)', '前3中标单位:中标数量(个)'], //,占比 | ,占该采购单位
  1678. rows: []
  1679. }
  1680. const dataAmount = {
  1681. columns: ['序号', '采购单位:采购金额(万元)', '前3中标单位:中标金额(万元)'], //,占比 | ,占该采购单位
  1682. rows: []
  1683. }
  1684. const countTop3 = data.buyer_count_top3
  1685. if (Array.isArray(countTop3)) {
  1686. countTop3.forEach((item, index) => {
  1687. item.name = item.name
  1688. item.type = 'buyer'
  1689. item.id = item.name
  1690. item.subInfo1 = item.number ? `项目数量:${item.number}个` : ''
  1691. // item.subInfo2 = item.accounted ? `全部占比:${utils.formatMoney(item.accounted * 100, undefined, true)}%` : ''
  1692. item.actionText = `中标单位 TOP3`
  1693. item.childrenShow = true
  1694. item.children = []
  1695. if (Array.isArray(item.winnertop3)) {
  1696. item.winnertop3.forEach((w, i) => {
  1697. const row = {
  1698. name: w.name,
  1699. id: w.id,
  1700. type: 'winner',
  1701. subInfo1: w.number ? `中标个数:${w.number}个` : '',
  1702. // subInfo2: w.accounted ? `占该采购单位:${utils.formatMoney(w.accounted * 100, undefined, true)}%` : ''
  1703. }
  1704. item.children.push(row)
  1705. })
  1706. }
  1707. })
  1708. dataCount.rows = countTop3
  1709. }
  1710. const amountTop3 = data.buyer_amount_top3
  1711. if (Array.isArray(amountTop3)) {
  1712. amountTop3.forEach((item, index) => {
  1713. item.name = item.name
  1714. item.type = 'buyer'
  1715. item.id = item.name
  1716. item.subInfo1 = item.amount ? `采购金额:${utils.formatMoney(item.amount / 10000, undefined, true)}万元` : ''
  1717. // item.subInfo2 = item.accounted ? `全部占比:${utils.formatMoney(item.accounted * 100, undefined, true)}%` : ''
  1718. item.actionText = `中标单位 TOP3`
  1719. item.childrenShow = true
  1720. item.children = []
  1721. if (Array.isArray(item.winnertop3)) {
  1722. item.winnertop3.forEach((w, i) => {
  1723. const row = {
  1724. name: w.name,
  1725. id: w.id,
  1726. type: 'winner',
  1727. subInfo1: w.amount ? `中标金额:${utils.formatMoney(w.amount / 10000, undefined, true)}万元` : '',
  1728. // subInfo2: w.accounted ? `该行业占比:${utils.formatMoney(w.accounted * 100, undefined, true)}%` : ''
  1729. }
  1730. item.children.push(row)
  1731. })
  1732. }
  1733. })
  1734. dataAmount.rows = amountTop3
  1735. }
  1736. if (dataCount.rows.length) {
  1737. if (dataCount.rows.length > 3) {
  1738. this.sections.buyerclass.showCountAllBtn = true
  1739. } else {
  1740. this.sections.buyerclass.showCountAllBtn = false
  1741. }
  1742. this.$set(this.sections.buyerclass, 'projectCountTop3', dataCount.rows)
  1743. }
  1744. if (dataAmount.rows.length) {
  1745. if (dataAmount.rows.length > 3) {
  1746. this.sections.buyerclass.showAmoutAllBtn = true
  1747. } else {
  1748. this.sections.buyerclass.showAmoutAllBtn = false
  1749. }
  1750. this.$set(this.sections.buyerclass, 'projectAmountTop3', dataAmount.rows)
  1751. }
  1752. },
  1753. // 中标单位
  1754. sortWinnerData (data) {
  1755. const chartData = {
  1756. columns: ['金额区间', '中标总金额占比', '中标单位数量占比'],
  1757. rows: []
  1758. }
  1759. let total = 0
  1760. const chartLIst = data.winner_time_distribution
  1761. if (Array.isArray(chartLIst)) {
  1762. const field = {
  1763. [chartData.columns[0]]: 'key',
  1764. [chartData.columns[1]]: 'total_amount',
  1765. [chartData.columns[2]]: 'total_number'
  1766. }
  1767. chartLIst.forEach(item => {
  1768. const row = {}
  1769. chartData.columns.forEach(column => {
  1770. if (field[column] === 'total_amount' || field[column] === 'total_number') {
  1771. row[column] = (item[field[column]] * 100).toFixed(2)
  1772. total += (item[field[column]] - 0)
  1773. } else {
  1774. row[column] = item[field[column]]
  1775. }
  1776. })
  1777. chartData.rows.push(row)
  1778. })
  1779. }
  1780. if (total) {
  1781. chartData.rows.reverse()
  1782. this.$set(this.sections.winner, 'chartData', chartData)
  1783. this.sections.winner.dataAlready = true
  1784. }
  1785. this.sortWinnerTableData(data)
  1786. },
  1787. sortWinnerTableData (data) {
  1788. const dataCount = {
  1789. columns: ['序号', '中标单位:中标数量(个)', '前3采购单位:采购数量(个)'], // ,占比 | ,占该中标单位
  1790. rows: []
  1791. }
  1792. const dataAmount = {
  1793. columns: ['序号', '中标单位:中标金额(万元),占比', '前3采购单位:采购金额(万元),占该中标单位'], // ,占比 | ,占该中标单位
  1794. rows: []
  1795. }
  1796. const countTop3 = data.winner_count_top3
  1797. if (Array.isArray(countTop3)) {
  1798. countTop3.forEach((item, index) => {
  1799. item.name = item.name
  1800. item.type = 'winner'
  1801. item.id = item.id
  1802. item.subInfo1 = item.number ? `中标数量:${item.number}个` : ''
  1803. // item.subInfo2 = item.accounted ? `全部占比:${utils.formatMoney(item.accounted * 100, undefined, true)}%` : ''
  1804. item.actionText = `采购单位 TOP3`
  1805. item.childrenShow = true
  1806. item.children = []
  1807. if (Array.isArray(item.buyertop3)) {
  1808. item.buyertop3.forEach((w, i) => {
  1809. const row = {
  1810. name: w.name,
  1811. id: w.name,
  1812. type: 'buyer',
  1813. subInfo1: w.number ? `采购数量:${w.number}个` : '',
  1814. // subInfo2: w.accounted ? `占该中标单位:${utils.formatMoney(w.accounted * 100, undefined, true)}%` : ''
  1815. }
  1816. item.children.push(row)
  1817. })
  1818. }
  1819. })
  1820. dataCount.rows = countTop3
  1821. }
  1822. const amountTop3 = data.winner_amount_top3
  1823. if (Array.isArray(amountTop3)) {
  1824. amountTop3.forEach((item, index) => {
  1825. item.name = item.name
  1826. item.type = 'winner'
  1827. item.id = item.id
  1828. item.subInfo1 = item.amount ? `中标金额:${utils.formatMoney(item.amount / 10000, undefined, true)}万元` : ''
  1829. // item.subInfo2 = item.accounted ? `全部占比:${utils.formatMoney(item.accounted * 100, undefined, true)}%` : ''
  1830. item.actionText = `采购单位 TOP3`
  1831. item.childrenShow = true
  1832. item.children = []
  1833. if (Array.isArray(item.buyertop3)) {
  1834. item.buyertop3.forEach((w, i) => {
  1835. const row = {
  1836. name: w.name,
  1837. id: w.name,
  1838. type: 'buyer',
  1839. subInfo1: w.amount ? `采购金额:${utils.formatMoney(w.amount / 10000, undefined, true)}万元` : '',
  1840. // subInfo2: w.accounted ? `占该中标单位:${utils.formatMoney(w.accounted * 100, undefined, true)}%` : ''
  1841. }
  1842. item.children.push(row)
  1843. })
  1844. }
  1845. })
  1846. dataAmount.rows = amountTop3
  1847. }
  1848. if (dataCount.rows.length) {
  1849. if (dataCount.rows.length > 3) {
  1850. this.sections.winner.showCountAllBtn = true
  1851. } else {
  1852. this.sections.winner.showCountAllBtn = false
  1853. }
  1854. this.$set(this.sections.winner, 'projectCountTop3', dataCount.rows)
  1855. }
  1856. if (dataAmount.rows.length) {
  1857. if (dataAmount.rows.length > 3) {
  1858. this.sections.winner.showAmoutAllBtn = true
  1859. } else {
  1860. this.sections.winner.showAmoutAllBtn = false
  1861. }
  1862. this.$set(this.sections.winner, 'projectAmountTop3', dataAmount.rows)
  1863. }
  1864. },
  1865. toAnalysisPage: function () {
  1866. this.rid = ''
  1867. this.analysis.loaded = false
  1868. this.filtersPageShow = true
  1869. },
  1870. moneyUnit (num, type, lv) {
  1871. const m = utils.moneyUnit(num, type, lv)
  1872. let unit = String(m).match(/[\u4e00-\u9fa5]/g)
  1873. if (unit && Array.isArray(unit)) {
  1874. unit = unit.join('')
  1875. } else {
  1876. unit = ''
  1877. }
  1878. let count = ''
  1879. if (unit) {
  1880. count = m.replace(unit, '') - 0
  1881. }
  1882. return {
  1883. unit,
  1884. count
  1885. }
  1886. },
  1887. anchorTo (item) {
  1888. // if (!item.top) return
  1889. var offsetTop = item.top || 0
  1890. this.activeDimension = item.id
  1891. this.$nextTick(function () {
  1892. $('.search-result > .j-main')[0].scrollTop = offsetTop
  1893. })
  1894. },
  1895. showSetKeyTip: function () {
  1896. this.notSetKey = true
  1897. },
  1898. setKeyTip: function () {
  1899. this.showDialog({
  1900. title: '',
  1901. message: '分析内容为您订阅的关键词组,您<br />当前尚未订阅,请前往完善',
  1902. className: 'j-confirm-dialog text-center',
  1903. showConfirmButton: true,
  1904. showCancelButton: true,
  1905. confirmButtonText: '订阅管理',
  1906. confirmButtonColor: '#2abed1'
  1907. }).then(() => {
  1908. if (this.isSubCount) {
  1909. // 提示联系管理员
  1910. this.showToast('请联系管理员完善订阅的关键词')
  1911. // this.showDialog({
  1912. // title: '',
  1913. // message: '请联系管理员完善订阅的关键词',
  1914. // className: 'j-confirm-dialog text-center',
  1915. // showConfirmButton: true,
  1916. // showCancelButton: false,
  1917. // confirmButtonText: '我知道了',
  1918. // confirmButtonColor: '#2abed1'
  1919. // })
  1920. } else {
  1921. this.toSubManage()
  1922. }
  1923. })
  1924. },
  1925. toSubManageButtonClick: function () {
  1926. if (this.isSubCount) {
  1927. this.showToast('请联系管理员完善订阅的关键词')
  1928. } else {
  1929. this.toSubManage()
  1930. }
  1931. },
  1932. toSubManage: function () {
  1933. this.isWeixin = utils.isWeiXinBrowser
  1934. let rootlink = 'f'
  1935. if (this.powerInfo.memberStatus > 0) {
  1936. rootlink = 'm'
  1937. } else if (this.powerInfo.vipStatus > 0) {
  1938. rootlink = 'v'
  1939. } else {
  1940. rootlink = 'f'
  1941. }
  1942. if(utils.$envs.inWX) {
  1943. location.href = '/front/vipsubscribe/toSetKeyWordPage?vSwitch=' + rootlink
  1944. } else {
  1945. location.href = '/jyapp/vipsubscribe/toSetKeyWordPage?vSwitch=' + rootlink
  1946. }
  1947. },
  1948. toArticleContent (item) {
  1949. this.saveState()
  1950. if (utils.$envs.inWX) {
  1951. location.href = `/article/content/${item._id}.html`
  1952. } else {
  1953. location.href = `/jyapp/article/content/${item._id}.html`
  1954. }
  1955. },
  1956. toPortrait (id, type) {
  1957. if (!type || !id) return
  1958. this.saveState()
  1959. if (type === 'winner') {
  1960. if (utils.$envs.inWX) {
  1961. location.href = `/weixin/frontPage/collection/sess/ent_portrait?eId=${id}`
  1962. } else {
  1963. location.href = `./ent_portrait?eId=${id}`
  1964. }
  1965. } else if (type === 'buyer') {
  1966. if (utils.$envs.inWX) {
  1967. location.href = `/big/wx/page/unit_portrayal?entName=${id}`
  1968. } else {
  1969. location.href = `./unit_portrayal?entName=${id}`
  1970. }
  1971. }
  1972. }
  1973. }
  1974. })