report_analysis.js 76 KB

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