1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864 |
- function dateFormatter (date, pattern) {
- return new Date(date).pattern(pattern)
- }
- var vm = new Vue({
- delimiters: ['${', '}'],
- el: '#analysis',
- components: {
- keywordComponent: keywordComponent,
- areaCityMobile: areaCityMobileComponent,
- industryComponent: industryComponent,
- cateComponent: cateComponent,
- dateComponent: dateComponent,
- chartExample: chartExample,
- // 图表
- projectScatter: projectScatter,
- marketTimeScatter: marketTimeScatter,
- marketAreaScatter: marketAreaScatter,
- marketTop3Table: marketTop3Table,
- marketUserScatter: marketUserScatter,
- marketSegment: marketSegment,
- lineChartScatter: lineChartScatter,
- },
- data: {
- sessStorageKey: '$data-report_analysis',
- tabActiveName: 'analysis', // analysis/history
- tabList: [
- {
- label: '定制化市场分析',
- name: 'analysis'
- },
- {
- label: '历史报告',
- name: 'history'
- }
- ],
- tabConf: {
- titleActiveColor: '#2ABED1',
- titleInactiveColor: '#5F5E64',
- lineWidth: '24',
- color: '#2ABED1'
- },
- timeOptions: [
- {
- name: '近3个月',
- value: 'lately90',
- selected: false
- },
- {
- name: '近半年',
- value: 'lately180',
- selected: false
- },
- {
- name: '今年全年',
- value: 'thisYear',
- selected: false
- },
- {
- name: '去年至今',
- value: 'sinceLastYear',
- selected: false
- },
- {
- name: '前年至今',
- value: 'sinceYearBeforeLast',
- selected: false
- }
- ],
- scrollTop: 0,
- filtersPageShow: true,
- filters: {
- selectKeysArr: [], // 关键词简单数组,用于恢复选择状态
- keys: [], // 关键词详细数组,用于提交数据
- area: {},
- industry: [],
- industryDetail: {},
- buyerclass: [],
- rangeTime: {
- start: '',
- end: '',
- exact: 'sinceYearBeforeLast',
- },
- },
- filterDialogShow: {
- keys: false,
- area: false,
- industry: false,
- buyerclass: false,
- rangeTime: false
- },
- // 分析结果页面数据
- activeDimension: 'market',
- dimensionList: [
- {
- id: 'market',
- name: '市场规模',
- top: 0,
- anchor: 'market-overview'
- },
- {
- id: 'buyer',
- name: '采购单位',
- top: 0,
- anchor: 'buyerclass-scatter'
- },
- {
- id: 'bidder',
- name: '中标单位',
- top: 0,
- anchor: 'winner-scatter'
- },
- ],
- analysis: { // 开始分析请求的loaed和loading
- loaded: false,
- loading: false
- },
- rid: '', // reportId
- reportFilters: {
- keys: [],
- selectTime: '',
- selectTimeExtra: '',
- area: {},
- industry: {},
- buyerclass: []
- },
- sections: {
- market: {
- overview: [],
- refine: {
- dataAlready: false,
- projectCountData: null,
- projectAmountData: null,
- // 项目数量Top3
- projectCountTop3: null,
- // 项目金额Top3
- projectAmountTop3: null
- }
- },
- projectScatter: {
- dataAlready: false,
- chartData: null,
- tableData: [
- // {
- // projectname: 'xxxx',
- // area: 'xx',
- // city: 'xxx',
- // sortprice: 'zzz',
- // jgtime: 'zzzz',
- // winner_s: [
- // {
- // name: 'w1',
- // id: '33'
- // },
- // {
- // name: 'w2',
- // id: '33'
- // }
- // ]
- // },
- // {
- // projectname: 'xxxx',
- // area: 'xx',
- // city: 'xxx',
- // sortprice: 'zzz',
- // jgtime: 'zzzz',
- // winner_s: [
- // {
- // name: 'w1',
- // id: '33'
- // },
- // {
- // name: 'w2',
- // id: '33'
- // }
- // ]
- // }
- ]
- },
- timeScatter: {
- dataAlready: false, // 数据准备好之后才能开始渲染
- activeAction: 'month',
- actionList: [
- {
- label: '月度数据',
- value: 'month'
- },
- {
- label: '年度数据',
- value: 'year'
- }
- ],
- month: {
- count: {},
- amount: {}
- },
- year: {
- count: {},
- amount: {}
- }
- },
- areaScatter: {
- dataAlready: false,
- chartData: null,
- // 项目数量Top3
- projectCountTop3: null,
- // 项目金额Top3
- projectAmountTop3: null
- },
- userScatter: {
- list: [],
- // 项目数量Top3
- projectCountTop3: null,
- // 项目金额Top3
- projectAmountTop3: null
- },
- buyerclass: {
- dataAlready: false,
- chartData: null,
- // 项目数量Top3
- projectCountTop3: null,
- // 项目金额Top3
- projectAmountTop3: null
- },
- winner: {
- dataAlready: false,
- chartData: null,
- // 项目数量Top3
- projectCountTop3: null,
- // 项目金额Top3
- projectAmountTop3: null
- }
- },
- empty: {
- defaultMsg: '对不起,没有匹配到相关信息<br />请修改您的分析条件',
- msg: ''
- },
- stickyOffset: 0,
- notSetKey: false, // 未设置关键词
- isSubCount: false, // 是否子账号
- powerInfo: {},
- isWeixin: false
- },
- computed: {
- getStatus: function () {
- if (JSON.stringify(this.powerInfo) !== '{}') {
- return this.powerInfo.power.indexOf(10) !== -1
- }
- },
- anchorTopList: function () {
- var arr = []
- this.dimensionList.forEach(function (item) {
- arr.push(item.top)
- })
- return arr
- },
- // 报告详情筛选条件只有一个省份
- // 此时不显示地区分布chart
- notOneAreaFilter () {
- var area = this.reportFilters.area
- var showArea = area && (Object.keys(area).length > 1 || Object.keys(area).length === 0)
- return showArea
- },
- emptyShow () {
- return !this.rid && this.analysis.loaded
- },
- tabActive: function () {
- var _this = this
- var active = {}
- this.tabList.some(function (item) {
- var findThis = item.name === _this.tabActiveName
- if (findThis) {
- active = item
- return findThis
- }
- })
- return active
- },
- buyerclassSectionShow () {
- const winnerState = this.sections.buyerclass
- return winnerState.dataAlready && winnerState.projectCountTop3 && winnerState.projectAmountTop3
- },
- winnerSectionShow () {
- const winnerState = this.sections.winner
- return winnerState.dataAlready && winnerState.projectCountTop3 && winnerState.projectAmountTop3
- },
- overviewRateTotal: function () {
- var total = 0
- this.sections.market.overview.forEach(function (item) {
- if (item.ringRatio !== undefined && item.ringRatio !== null) {
- total += item.ringRatio
- }
- })
- return total
- }
- },
- watch: {
- filtersPageShow (newVal) {
- if (!newVal) {
- this.isWeixin = utils.isWeiXinBrowser
- if (!this.isWeixin) {
- this.calcStickyOffset()
- }
- }
- }
- },
- created () {
- this.calcLastTimeText()
- this.getPower()
- var id = utils.getParam('id')
- if (id) {
- this.rid = decodeURIComponent(id)
- this.filtersPageShow = false
- }
-
- },
- mounted: function () {
- setTimeout(() => {
- var restored = this.reStoreState()
- if (!restored) {
- if (this.rid) {
- this.getReportResult()
- }
- } else {
- this.$nextTick(this.calcOffsetTop)
- if (utils.isIos) {
- setTimeout(this.calcOffsetTop, 1000)
- }
- }
- }, 0)
- this.addEventListeners()
- utils.iosBackRefresh()
- },
- methods: {
- gotable () {
- this.saveState()
- if(this.isWeiXinBrower()){
- window.location.href='/big/wx/page/report_table?source=analysis'+'&flag=3'+'&rid='+this.rid+'&header=客户类型分布详情'
- } else {
- window.location.href='/jyapp/big/page/report_table?source=analysis'+'&flag=3'+'&rid='+this.rid+'&header=客户类型分布详情'
- }
-
- },
- isWeiXinBrower() {
- var ua = navigator.userAgent.toLowerCase();
- if(ua.match(/MicroMessenger/i) == 'micromessenger') {
- return true;
- } else {
- return false;
- }
- },
- showLoading: function () {
- return this.$toast.loading({
- duration: 0,
- forbidClick: true,
- message: 'loading...',
- })
- },
- showToast: function (message) {
- return this.$toast({
- duration: 1500,
- forbidClick: true,
- message: message,
- })
- },
- showDialog: function (conf) {
- var defaultConf = {
- title: '提示',
- message: 'message',
- className: 'j-confirm-dialog',
- showConfirmButton: true,
- showCancelButton: true,
- confirmButtonText: '确定',
- confirmButtonColor: '#2abed1'
- }
- if (conf) {
- Object.assign(defaultConf, conf)
- }
- return this.$dialog.confirm(defaultConf)
- },
- calcOffsetTop: function () {
- var sticky = $('.van-sticky')
- var stickyHeight = 0
- if (sticky.length) {
- stickyHeight = sticky[0].clientHeight
- }
- this.dimensionList.forEach(function (item) {
- var anchor = $('.' + item.anchor)
- var offsetTop = 0
- if (anchor.length) {
- offsetTop = parseInt(anchor[0].offsetTop - stickyHeight)
- }
- item.top = offsetTop
- })
-
- },
- addEventListeners: function () {
- this.scrollToTop()
- },
- scrollToTop: function () {
- var $scrollDOM = $('.j-container.search-result > .j-main')
- // 1. 检查当前高度是否满足显示快速滚动到顶部
- this.checkScrollTopButtonShow()
- // 2. 具体逻辑
- $scrollDOM.on('scroll', this.checkScrollTopButtonShow)
- setTimeout(function () {
- // 2s后绑定(尽可能保证top能够被计算完)
- $scrollDOM.on('scroll', this.checkAnchorItemActive)
- }.bind(this), 2500)
- $('.scroll-to-top').on('click', function () {
- $scrollDOM.animate({ scrollTop: 0 })
- })
- },
- checkAnchorItemActive: function () {
- var $scrollDOM = $('.j-container.search-result > .j-main')
- var anchorTopList = this.anchorTopList
- var scrollTop = parseInt($scrollDOM.scrollTop()) + 3 // (误差校正)
- var i = 0
- if (scrollTop >= anchorTopList[1] && scrollTop < anchorTopList[2]) {
- i = 1
-
- } else if (scrollTop > anchorTopList[2] && scrollTop > anchorTopList[1] && scrollTop > anchorTopList[0]) { //逻辑上多余判断条件 ,为了处理高度还没有计算出起始的 anchorTopList[2]为0 tab回显错误问题
- i = 2
-
- } else if (scrollTop < anchorTopList[1]) {
- i = 0
- }
- this.activeDimension = this.dimensionList[i].id
- },
- checkScrollTopButtonShow: function () {
- var showButtonHeight = 300
- var $scrollDOM = $('.j-container.search-result > .j-main')
- var button = $('.scroll-to-top')
- var scrollTop = $scrollDOM.scrollTop()
- if (scrollTop > showButtonHeight) {
- button.show()
- } else {
- button.hide()
- }
- },
- calcStickyOffset: function () {
- setTimeout(function () {
- var headerHeight = $('.jy-app-header')[0].clientHeight
- var tabHeight = $('.analysis-tab')[0].clientHeight
- this.stickyOffset = headerHeight + tabHeight - 5
- }.bind(this), 1000)
- },
- setScrollTop: function (scrollTop) {
- this.$nextTick(function () {
- var wrapper = document.querySelector('.j-container.search-result > .j-main')
- wrapper.scrollTop = scrollTop
- })
- },
- saveScrollTop: function () {
- var wrapper = document.querySelector('.j-container.search-result > .j-main')
- if (wrapper.scrollTop) {
- this.scrollTop = parseInt(wrapper.scrollTop)
- }
- },
- beforeTabChange: function (name) {
- if (name !== this.tabActiveName) {
- this.goToAnalysisHistory()
- }
- return false
- },
- goToAnalysisHistory: function () {
- location.href = './report_analysis_history'
- },
- formatSelectTime (value) {
- if (!value) return '-'
- const timeArr = value.split('-')
- return `${dateFormatter(timeArr[0] * 1000, 'yyyy/MM/dd')}-${dateFormatter(timeArr[1] * 1000, 'yyyy/MM/dd')}`
- },
- getPower:function () {
- var _this = this
- $.ajax({
- type:'POST',
- url:'/bigmember/use/isAdd',
- success:function(res) {
- _this.powerInfo = res.data
- if (res.data && res.data.isSubCount){
- _this.isSubCount = true
- }
- }
- })
- },
- init: function () {
- // 初始化页面数据
- this.initDateTimeSelector('sinceYearBeforeLast')
- },
- // 时间选择器选中状态
- initDateTimeSelector: function (exact) {
- if (exact === 'exact') {
- this.$refs.dateSelector.setState(this.filters.rangeTime)
- } else {
- this.$refs.dateSelector.setTimeSelectListState(exact)
- this.$refs.dateSelector.dateStyle = false
- }
- },
- resolveSelected: function (type) {
- var filters = this.filters
- var prefix = '已选:'
- var text = ''
- if (type === 'keys') {
- if (this.notSetKey) return '请设置'
- text = this.resolveSelectKeysText(filters.keys)
- } else if (type === 'area') {
- text = this.resolveSelectAreaText(filters.area)
- } else if (type === 'industry') {
- text = this.resolveSelectIndustryText(filters.industryDetail)
- } else if (type === 'buyerclass') {
- text = this.resolveSelectBuyerclassText(filters.buyerclass)
- }
- return prefix + text
- },
- resolveSelectKeysText: function (keys) {
- if (Array.isArray(keys)) {
- if (keys.length === 0) {
- return '全部'
- } else {
- var count = 0
- var arr = []
- keys.forEach(function (classify) {
- if (Array.isArray(classify.a_key) && classify.a_key.length) {
- count += classify.a_key.length
- classify.a_key.forEach(function (item) {
- arr.push(item.key.join(' '))
- })
- }
- })
- if (count <= 0) {
- return '全部'
- } else {
- return arr.join(',')
- }
- }
- } else {
- return '全部'
- }
- },
- resolveSelectAreaText: function (area) {
- if (!area || Object.keys(area).length === 0) return '全国'
- var areaArr = []
- var cityArr = []
- for (var key in area) {
- if (area[key].length === 0) {
- areaArr.push(key)
- } else {
- cityArr = cityArr.concat(area[key])
- }
- }
- return areaArr.concat(cityArr).join(',')
- },
- resolveSelectIndustryText: function (industry) {
- if (!industry || Object.keys(industry).length === 0) return '全部'
- var keyArr = []
- var valueArr = []
- for (var key in industry) {
- if (industry[key].length === 0) {
- keyArr.push(key)
- } else {
- valueArr = valueArr.concat(industry[key])
- }
- }
- return keyArr.concat(valueArr).join(',')
- },
- resolveSelectBuyerclassText: function (buyerclass) {
- if (!Array.isArray(buyerclass)) return '全部'
- if (buyerclass.length === 0) return '全部'
- return buyerclass.join(',')
- },
- calcLastTimeText: function () {
- const renameList = [
- 'thisYear', // 今年全年
- 'sinceLastYear', // 去年至今
- 'sinceYearBeforeLast' // 前年至今
- ]
- const thisYear = new Date().getFullYear()
- this.timeOptions.forEach(item => {
- if (renameList.indexOf(item.value) !== -1) {
- if (item.value === renameList[0]) {
- item.name = `${thisYear}年全年`
- } else if (item.value === renameList[1]) {
- item.name = `${thisYear - 1}年至今`
- } else if (item.value === renameList[2]) {
- item.name = `${thisYear - 2}年至今`
- }
- }
- })
- },
- // 重置
- resetFilter: function (type) {
- var filters = this.filters
- if (type === 'keys') {
- filters.keys = []
- filters.selectKeysArr = []
- try {
- this.$refs.keywordSelector.resetAllNoSelect()
- } catch (error) {}
- } else if (type === 'area') {
- filters.area = {}
- } else if (type === 'industry') {
- filters.industry = []
- filters.industryDetail = {}
- } else if (type === 'buyerclass') {
- filters.buyerclass = []
- } else if (type === 'date') {
- this.filters.rangeTime.start = ''
- this.filters.rangeTime.edd = ''
- this.filters.rangeTime.exact = 'sinceYearBeforeLast'
- this.initDateTimeSelector(this.filters.rangeTime.exact)
- } else {
- this.resetFilter('keys')
- this.resetFilter('area')
- this.resetFilter('industry')
- this.resetFilter('buyerclass')
- this.resetFilter('date')
- }
- },
- clickCell: function (key) {
- var _this = this
- var dialog = this.filterDialogShow
- if (key === 'keys') {
- if (this.notSetKey) {
- return this.setKeyTip()
- }
- } else if (key === 'area') {
- setTimeout(function () {
- _this.$refs.areaCitySelector.setState(_this.filters.area)
- }, 0)
- } else if (key === 'buyerclass') {
- setTimeout(function () {
- _this.$refs.buyerclassSelector.setState()
- }, 0)
- } else if (key === 'industry') {
- setTimeout(function () {
- _this.$refs.industrySelector.setState()
- }, 0)
- }
- dialog[key] = true
- },
- cancel: function (e, key) {
- var dialog = this.filterDialogShow
- this.resetFilter(key)
- dialog[key] = false
- },
- confirm: function (e, key) {
- var dialog = this.filterDialogShow
- var filters = this.filters
- if (key === 'keys') {
- filters.keys = e.detail
- filters.selectKeysArr = e.data
- } else if (key === 'area') {
- filters.area = e.data
- } else if (key === 'industry') {
- filters.industry = e.data
- filters.industryDetail = e.detail
- } else if (key === 'buyerclass') {
- filters.buyerclass = e.data
- console.log(e.data)
- }
- dialog[key] = false
- },
- dateTimeSelectorConfirm () {
- var result = this.$refs.dateSelector.getState()
- this.filters.rangeTime.start = result.start
- this.filters.rangeTime.end = result.end
- this.filters.rangeTime.exact = result.exact
- },
- resetAllFilters: function () {
- this.analysis.loaded = false
- this.resetFilter('all')
- },
- getReportResult () {
- this.sendRequest()
- },
- getSelectedKeys () {
- const keys = this.filters.keys
- if (Array.isArray(keys) && keys.length) {
- return JSON.stringify(keys)
- } else {
- var allKeys = this.$refs.keywordSelector.keywordGroupList
- return JSON.stringify(allKeys)
- }
- },
- startAnalysis: function () {
- this.dateTimeSelectorConfirm()
- const query = {
- keysItems: this.getSelectedKeys(),
- rangeTime: `${parseInt(this.filters.rangeTime.start / 1000)}-${parseInt(this.filters.rangeTime.end / 1000)}`,
- rangeTimeExtra: this.filters.rangeTime.exact,
- area: JSON.stringify(this.filters.area),
- industry: JSON.stringify(this.filters.industryDetail),
- buyerclass: this.filters.buyerclass.join(',')
- }
- this.analysis.loaded = false
- this.analysis.loading = true
- this.showLoading()
- $.ajax({
- type: 'POST',
- url: '/bigmember/marketAnalysis/doAnalysis',
- data: query,
- success: function (res) {
- if (res && res.error_code === 0 && res.data) {
- this.rid = res.data
- this.analysis.loaded = true
- // location.replace('./report_analysis?id=' + res.data)
- this.rid = res.data
- history.replaceState({}, null, '?id=' + this.rid)
- this.getReportResult()
- } else {
- this.$toast(res.error_msg)
- }
- }.bind(this),
- complete: function () {
- this.analysis.loading = false
- }.bind(this)
- })
- },
- // 保存页面状态
- saveState: function () {
- this.saveScrollTop()
- this.dateTimeSelectorConfirm()
- var $data = {
- analysis: this.analysis,
- filters: this.filters,
- scrollTop: this.scrollTop,
- filtersPageShow: this.filtersPageShow,
- reportFilters: this.reportFilters,
- sections: this.sections,
- isSubCount: this.isSubCount
- }
- sessionStorage.setItem(this.sessStorageKey, JSON.stringify($data))
- },
- reStoreState: function () {
- var $data = sessionStorage.getItem(this.sessStorageKey)
- if ($data) {
- $data = JSON.parse($data)
- this.isSubCount = $data.isSubCount
- this.scrollTop = $data.scrollTop
- this.filtersPageShow = $data.filtersPageShow
- Object.assign(this.analysis, $data.analysis)
- this.$set(this, 'filters', $data.filters)
- this.$set(this, 'reportFilters', $data.reportFilters)
- this.$set(this, 'sections', $data.sections)
- setTimeout(function () {
- // 恢复滚动高度
- this.setScrollTop(this.scrollTop)
- this.initDateTimeSelector(this.filters.rangeTime.exact)
- }.bind(this), 0)
- sessionStorage.removeItem(this.sessStorageKey)
- } else {
- this.init()
- }
- return $data
- },
- onEmpty (info) {
- if (this.loading) {
- this.loading.clear()
- }
- this.filtersPageShow = true
- this.analysis.loaded = true
- this.rid = ''
- if (info && info.msg) {
- this.empty.msg = info.msg
- } else {
- this.empty.msg = this.empty.defaultMsg
- }
- },
- sendRequest () {
- let _this = this
- // 先请求概况(1),判断报告是否为空
- const query = {
- rid: this.rid,
- flag: 1
- }
- if (!query.rid) {
- return
- }
- this.loading = this.showLoading()
- $.ajax({
- type: 'POST',
- async: false,
- url: '/bigmember/marketAnalysis/getAnalysisResult',
- data: query,
- success: function(res) {
- if (res && res.error_code === 0 && res.data) {
- var empty = _this.formatterData(query.flag, res.data)
- if (empty) {
- return _this.onEmpty()
- }
- } else {
- if (res.error_msg.indexOf('项目数量超出上限') === -1) {
- return _this.onEmpty()
- } else {
- return _this.onEmpty({ msg: '当前分析条件涉及项目数量已超过最大限制,请修改分析条件进行精确分析' })
- }
- }
- }
- }).responseJSON
- this.filtersPageShow = false
- const flagArr = [
- 0, // 筛选条件
- // 1, // 市场概括与时间分布
- 2, // 项目规模Top10
- 3, // 项目规模分布/地区规模分布/客户分布/地区分布及客户分布&Top3(table+chart)
- 4, // 细分市场
- 5 // 采购单位/中标单位&Top3(table+chart)
- ]
- flagArr.forEach(this.getReport)
- if (this.loading) {
- this.loading.clear()
- }
- },
- getReport (flag) {
- const query = {
- rid: this.rid,
- flag
- }
- if (!query.rid) {
- return
- }
-
- $.ajax({
- type: 'POST',
- url: '/bigmember/marketAnalysis/getAnalysisResult',
- data: query,
- success: function (res) {
- if (res && res.error_code === 0 && res.data) {
- if(flag==3){
- sessionStorage.setItem('getAnalysisResult_',JSON.stringify(res))
- }
- this.formatterData(flag, res.data)
-
-
- } else {
- this.$toast('请求失败')
- }
- }.bind(this)
- })
- },
- formatterData (flag, data) {
- if (flag === 0) {
- this.sortReportFilters(data)
- } else if (flag === 1) {
- // 市场概况
- const totalCount = this.sortMarketOverview(data.market_profile)
- if (!totalCount) {
- return true
- }
- // 时间分布
- this.sortTimeScatter(data)
- } else if (flag === 2) {
- // 项目规模Top10
- this.sortProjectTop10(data.ProjectTop10)
- } else if (flag === 3) {
- // 项目规模分布/地区规模分布/客户分布/地区分布及客户分布&Top3(table+chart)
- // 项目规模分布
- this.sortProjectScatter(data.projectScale)
- // 地区规模分布
- this.sortAreaScatter(data.area_infos)
- // 客户分布
- if(data.customer_scale){
- if(data.customer_scale.length!=0){
- let data_=data.customer_scale.slice(0,10)
- this.sortUserScatter(data_)
- }
- }
- // 地区分布及客户分布Top3
- this.sortAreaUserTop3(data)
- } else if (flag === 4) {
- // 细分市场
- this.sortMarketRefineData(data)
- } else if (flag === 5) {
- // 采购单位/中标单位&Top3(table+chart)
- this.sortBuyerclassData(data)
- // 中标单位分析
- this.sortWinnerData(data)
- }
- this.$nextTick(this.calcOffsetTop)
- },
- formatSelectTime (value) {
- if (!value) return '-'
- const timeArr = value.split('-')
- return `${dateFormatter(timeArr[0] * 1000, 'yyyy/MM/dd')}-${dateFormatter(timeArr[1] * 1000, 'yyyy/MM/dd')}`
- },
- // 整理数据,并赋值给filters
- sortReportFilters (data) {
- if (data.keysItems && data.keysItems !== '[]') {
- this.reportFilters.keys = JSON.parse(data.keysItems)
- this.filters.keys = this.reportFilters.keys
- var keyArr = []
- this.filters.keys.forEach(function (classify) {
- if(Array.isArray(classify.a_key)) {
- classify.a_key.forEach(function (item) {
- keyArr.push(item.key.join(' '))
- })
- }
- })
- this.filters.selectKeysArr = keyArr
- }
- // if (data.s_rangeTimeExtra) {
- // this.reportFilters.selectTimeExtra = data.s_rangeTimeExtra
- // this.filters.rangeTime.exact = this.reportFilters.selectTimeExtra
- // } else {
- // this.filters.rangeTime.exact = 'exact'
- // }
- this.filters.rangeTime.exact = 'exact'
- if (data.rangeTime) {
- this.reportFilters.selectTime = data.rangeTime
- var arr = data.rangeTime.split('-')
- this.filters.rangeTime.start = arr[0] * 1000
- this.filters.rangeTime.end = arr[1] * 1000
- if (this.filters.rangeTime.exact === 'exact') {
- var date = new Date(this.filters.rangeTime.end)
- var timeString = date.pattern('yyyy/MM/dd')
- this.filters.rangeTime.end = new Date(timeString).getTime()
- }
- }
-
- this.$refs.dateSelector.setState(this.filters.rangeTime)
- if (data.area && data.area !== '{}') {
- this.reportFilters.area = JSON.parse(data.area)
- this.filters.area = this.reportFilters.area
- }
- if (data.industry && data.industry !== '{}') {
- this.reportFilters.industry = JSON.parse(data.industry)
- this.$set(this.filters, 'industryDetail', this.reportFilters.industry)
- var industry = []
- for (var key in this.reportFilters.industry) {
- this.reportFilters.industry[key].forEach(function (item) {
- industry.push(key + '_' + item)
- })
- }
- this.filters.industry = industry
- }
- if (data.buyerclass) {
- this.reportFilters.buyerclass = data.buyerclass.split(',')
- this.filters.buyerclass = this.reportFilters.buyerclass
- }
- },
- // 市场概况
- sortMarketOverview (profile) {
- if (!profile) return
- const list = [
- {
- label: '项目总数',
- unit: '个',
- count: 0,
- ringRatio: 0
- },
- {
- label: '项目总金额',
- unit: '万元',
- count: 0,
- ringRatio: 0
- },
- {
- label: '项目平均金额',
- unit: '万元',
- count: 10.04,
- ringRatio: 0
- },
- {
- label: '中标单位数',
- unit: '家',
- count: 10628,
- ringRatio: 0
- },
- {
- label: '采购单位数',
- unit: '家',
- count: 16215,
- ringRatio: 0
- }
- ]
- // 项目总数
- list[0].count = profile.project_count ? profile.project_count : 0
- list[0].ringRatio = profile.project_count_ratio ? (profile.project_count_ratio * 100).toFixed(2) : 0
- // 项目总金额
- const projectTotalMoney = this.moneyUnit(profile.projctamout ? profile.projctamout : 0)
- list[1].count = projectTotalMoney.count || 0
- list[1].unit = projectTotalMoney.unit || '万元'
- list[1].ringRatio = profile.projctamount_ratio ? (profile.projctamount_ratio * 100).toFixed(2) : 0
- // 项目平均金额
- const projectAvgMoney = this.moneyUnit(profile.projectavgmoney ? profile.projectavgmoney : 0)
- list[2].count = projectAvgMoney.count || 0
- list[2].unit = projectAvgMoney.unit || '万元'
- list[2].ringRatio = profile.projectavgmoney_ratio ? (profile.projectavgmoney_ratio * 100).toFixed(2) : 0
- // 中标单位数
- list[3].count = profile.winnercount ? profile.winnercount : 0
- list[3].ringRatio = profile.winnercount_ratio ? (profile.winnercount_ratio * 100).toFixed(2) : 0
- // 采购单位数
- list[4].count = profile.buyercount ? profile.buyercount : 0
- list[4].ringRatio = profile.winnercount_ratio ? (profile.winnercount_ratio * 100).toFixed(2) : 0
- var totalCount = list.reduce((total, item) => item.count + total, 0)
- if (totalCount) {
- this.sections.market.overview = list
- }
- return totalCount
- },
- // 时间分布
- sortTimeScatter (data) {
- const hasDataM = this.sortTimeScatterData('month', data.month_distribution)
- const hasDataY = this.sortTimeScatterData('year', data.year_distribution)
- const hasData = hasDataM && hasDataY
- this.sections.timeScatter.dataAlready = hasData
- },
- sortTimeScatterData (type, data) {
- // columns: ['日期', '项目规模', '环比增长率(%)'],
- // rows: [
- // {
- // 日期: '6月',
- // 项目规模: 0,
- // '环比增长率(%)': -99
- // },
- // {
- // 日期: '7月',
- // 项目规模: 736325,
- // '环比增长率(%)': 0
- // },
- // ]
- if (!data) return
- // 项目数量
- const mDCount = {
- columns: ['日期', '项目数量(个)', '项目数量环比'],
- rows: []
- }
- let mDCountTotal = 0
- if (Array.isArray(data.project_count)) {
- const field = {
- [mDCount.columns[0]]: 'minth',
- [mDCount.columns[1]]: 'value',
- [mDCount.columns[2]]: 'ratio'
- }
- data.project_count.forEach(item => {
- const row = {}
- mDCount.columns.forEach(column => {
- var value = item[field[column]]
- if (value) {
- if (field[column] === 'ratio') {
- row[column] = utils.formatMoney(value * 100, undefined, true) - 0
- } else {
- row[column] = value
- }
- } else {
- row[column] = null
- }
- if (typeof value === 'number') {
- mDCountTotal += value
- }
- })
- mDCount.rows.push(row)
- })
- }
- if (mDCountTotal || isNaN(mDCountTotal)) {
- this.$set(this.sections.timeScatter[type], 'count', mDCount)
- }
- // 项目规模
- const mDAmount = {
- columns: ['日期', '项目金额(万元)', '项目金额环比'],
- rows: []
- }
- let mDAmuntTotal = 0
- if (Array.isArray(data.project_amount)) {
- const field = {
- [mDAmount.columns[0]]: 'minth',
- [mDAmount.columns[1]]: 'value',
- [mDAmount.columns[2]]: 'ratio'
- }
- data.project_amount.forEach(item => {
- const row = {}
- mDAmount.columns.forEach(column => {
- const value = item[field[column]]
- if (value) {
- if (field[column] === 'value') {
- row[column] = utils.formatMoney(value / 10000, undefined, true) - 0
- } else if (field[column] === 'ratio') {
- row[column] = utils.formatMoney(value * 100, undefined, true)
- } else {
- row[column] = value
- }
- } else {
- row[column] = null
- }
- if (typeof value === 'number') {
- mDAmuntTotal += value
- }
- })
- mDAmount.rows.push(row)
- })
- }
- if (mDAmuntTotal || !isNaN(mDAmuntTotal)) {
- this.$set(this.sections.timeScatter[type], 'amount', mDAmount)
- }
- const r = !!(mDCountTotal + mDAmuntTotal)
- const hasOneNaN = isNaN(mDCountTotal) || isNaN(mDAmuntTotal)
- return hasOneNaN || r
- },
- // 项目规模分布
- sortProjectScatter (data) {
- // const chartData = {
- // columns: ['项目规模', '项目总金额占比', '项目总数占比'],
- // rows: [
- // {
- // 项目规模: '≥1亿',
- // 项目总金额占比: 20,
- // 项目总数占比: 10
- // },
- // {
- // 项目规模: '1000万-1亿',
- // 项目总金额占比: 50,
- // 项目总数占比: 40
- // },
- // {
- // 项目规模: '500万-1000万',
- // 项目总金额占比: 20,
- // 项目总数占比: 30
- // },
- // {
- // 项目规模: '100万-500万',
- // 项目总金额占比: 20,
- // 项目总数占比: 30
- // }
- // ]
- // }
- const scaleList = data
- const scaleData = {
- columns: ['项目规模', '项目总金额占比', '项目总数占比'],
- rows: []
- }
- let total = 0
- if (scaleList && Array.isArray(scaleList)) {
- const field = {
- [scaleData.columns[0]]: 'Name',
- [scaleData.columns[1]]: 'Persent_c',
- [scaleData.columns[2]]: 'Persent_a'
- }
- scaleList.forEach(item => {
- const row = {}
- scaleData.columns.forEach(column => {
- if (field[column] === 'Persent_c' || field[column] === 'Persent_a') {
- row[column] = (item[field[column]] * 100).toFixed(2)
- total += (item[field[column]] - 0)
- } else {
- row[column] = item[field[column]]
- }
- })
- scaleData.rows.push(row)
- })
- }
- if (total) {
- scaleData.rows.reverse()
- this.$set(this.sections.projectScatter, 'chartData', scaleData)
- if (this.sections.projectScatter.tableData.length) {
- this.sections.projectScatter.dataAlready = true
- }
- }
- },
- // 项目规模Top10
- sortProjectTop10 (top10List) {
- if (!Array.isArray(top10List)) return
- this.sections.projectScatter.tableData = top10List.map(top => {
- let winners = top.winner_s ? top.winner_s.join(',') : ''
- if (!winners) {
- winners = []
- } else {
- winners = top.winner_s
- }
- winners = winners.map((item, index) => {
- return {
- name: item,
- id: Array.isArray(top.eidlist) ? top.eidlist[index] : null
- }
- })
- top.area = top.area ? top.area : ''
- top.city = top.city ? top.city : ''
- top.sortprice = top.sortprice ? utils.formatMoney(top.sortprice / 10000, undefined, true) : ''
- top.jgtime = top.jgtime ? dateFormatter(top.jgtime * 1000, 'yyyy-MM-dd') : ''
- top.winner_s = winners
- return top
- })
- if (this.sections.projectScatter.chartData) {
- this.sections.projectScatter.dataAlready = true
- }
- },
- // 地区规模分布
- sortAreaScatter (areaList) {
- // const chartData = {
- // columns: ['项目所在地', '项目数量', '项目金额'],
- // rows: [
- // {
- // 项目所在地: '河南',
- // 项目数量: 2,
- // 项目金额: 2222
- // },
- // {
- // 项目所在地: '北京',
- // 项目数量: 22,
- // 项目金额: 565666
- // },
- // {
- // 项目所在地: '浙江',
- // 项目数量: 22,
- // 项目金额: 765666
- // }
- // ]
- // }
- const areaChartData = {
- columns: ['项目所在地', '项目数量'],
- sColumns: ['项目金额'],
- rows: []
- }
- let total = 0
- if (areaList && Array.isArray(areaList)) {
- const field = {
- [areaChartData.columns[0]]: 'area',
- [areaChartData.columns[1]]: 'total',
- [areaChartData.sColumns[0]]: 'amount'
- }
- areaList.forEach(item => {
- const row = {}
- areaChartData.columns.concat(areaChartData.sColumns).forEach(column => {
- if (field[column] === 'amount') {
- row[column] = utils.formatMoney(item[field[column]] / 10000, undefined, true) - 0
- } else {
- row[column] = item[field[column]]
- }
- if (field[column] === 'amount' || field[column] === 'total') {
- total += (item[field[column]] - 0)
- }
- })
- areaChartData.rows.push(row)
- })
- }
- if (total) {
- this.$set(this.sections.areaScatter, 'chartData', areaChartData)
- this.sections.areaScatter.dataAlready = true
- }
- },
- // 客户分布
- sortUserScatter (userList) {
- if (Array.isArray(userList)) {
- this.sections.userScatter.list = userList.map(item => {
- item.name = item.buyclass
- item.value = item.total
- item.amount = utils.formatMoney(item.amount / 10000, undefined, true)
- return item
- })
- }
- },
- // 地区分布及客户分布Top3
- sortAreaUserTop3 (data) {
- if (data.scaleAreaCountTop || data.scaleAreaAmountTop) {
- this.sorAreaTop3(data)
- }
- if (data.scaleBuyclassCountTop || data.scaleBuyclassAmountTop) {
- this.sorUserTop3(data)
- }
- },
- sorAreaTop3 (data) {
- const tableDataCount = {
- columns: ['序号', '地区:项目数量(个),占比', '前3中标单位:中标数量(个)'], // ,该地区占比
- rows: []
- }
- const tableDataAmount = {
- columns: ['序号', '地区:项目金额(万元),占比', '前3中标单位:中标金额(万元)'], // ,该地区占比
- rows: []
- }
- const scaleAreaCountTop3 = data.scaleAreaCountTop
- if (Array.isArray(scaleAreaCountTop3)) {
- scaleAreaCountTop3.forEach((item, index) => {
- item.name = item.name
- item.subInfo1 = item.area_count ? `项目数量:${item.area_count}个` : ''
- item.subInfo2 = item.area_scale ? `全国占比:${utils.formatMoney(item.area_scale * 100, undefined, true)}%` : ''
- item.actionText = `中标单位 TOP3`
- item.childrenShow = true
- item.children = []
- if (Array.isArray(item.winner)) {
- item.winner.forEach((w, i) => {
- const row = {
- name: w.winner,
- id: w.id,
- type: 'winner',
- subInfo1: w.winner_total ? `中标个数:${w.winner_total}个` : '',
- // subInfo2: w.total_scale ? `地区占比:${utils.formatMoney(w.total_scale * 100, undefined, true)}%` : 0
- }
- item.children.push(row)
- })
- }
- })
- tableDataCount.rows = scaleAreaCountTop3
- }
- const scaleAreaAmountTop3 = data.scaleAreaAmountTop
- if (Array.isArray(scaleAreaAmountTop3)) {
- scaleAreaAmountTop3.forEach((item, index) => {
- item.name = item.name
- item.subInfo1 = item.area_amount ? `中标金额:${utils.formatMoney(item.area_amount / 10000, undefined, true)}万元` : ''
- item.subInfo2 = item.area_scale ? `全国占比:${utils.formatMoney(item.area_scale * 100, undefined, true)}%` : ''
- item.actionText = `中标单位 TOP3`
- item.childrenShow = true
- item.children = []
- if (Array.isArray(item.winner)) {
- item.winner.forEach((w, i) => {
- const row = {
- name: w.winner,
- id: w.id,
- type: 'winner',
- subInfo1: w.winner_amount ? `中标金额:${utils.formatMoney(w.winner_amount / 10000, undefined, true)}万元` : '',
- // subInfo2: w.amount_scale ? `地区占比:${utils.formatMoney(w.amount_scale * 100, undefined, true)}%` : ''
- }
- item.children.push(row)
- })
- }
- })
- tableDataAmount.rows = scaleAreaAmountTop3
- }
- if (tableDataCount.rows.length) {
- this.$set(this.sections.areaScatter, 'projectCountTop3', tableDataCount.rows)
- }
- if (tableDataAmount.rows.length) {
- this.$set(this.sections.areaScatter, 'projectAmountTop3', tableDataAmount.rows)
- }
- },
- sorUserTop3 (data) {
- const tableDataCount = {
- columns: ['序号', '客户类型:项目数量(个),占比', '前3中标单位:中标数量(个)'], // ,该客户类型占比
- rows: []
- }
- const tableDataAmount = {
- columns: ['序号', '客户类型:项目金额(万元),占比', '前3中标单位:中标金额(万元)'], // ,该客户类型占比
- rows: []
- }
- const countTop3 = data.scaleBuyclassCountTop
- if (Array.isArray(countTop3)) {
- countTop3.forEach((item, index) => {
- item.name = item.name
- item.subInfo1 = item.buyclass_count ? `项目数量:${item.buyclass_count}个` : ''
- item.subInfo2 = item.buyclass_scale ? `全部占比:${utils.formatMoney(item.buyclass_scale * 100, undefined, true)}%` : ''
- item.actionText = `中标单位 TOP3`
- item.childrenShow = true
- item.children = []
- if (Array.isArray(item.winner)) {
- item.winner.forEach((w, i) => {
- const row = {
- name: w.winner,
- id: w.id,
- type: 'winner',
- subInfo1: w.winner_total ? `中标个数:${w.winner_total}个` : '',
- // subInfo2: w.total_scale ? `该行业占比:${utils.formatMoney(w.total_scale * 100, undefined, true)}%` : ''
- }
- item.children.push(row)
- })
- }
- })
- tableDataCount.rows = countTop3
- }
- const amountTop3 = data.scaleBuyclassAmountTop
- if (Array.isArray(amountTop3)) {
- amountTop3.forEach((item, index) => {
- item.name = item.name
- item.subInfo1 = item.buyclass_amount ? `项目金额:${utils.formatMoney(item.buyclass_amount / 10000, undefined, true)}万元` : ''
- item.subInfo2 = item.buyclass_scale ? `全部占比:${utils.formatMoney(item.buyclass_scale * 100, undefined, true)}%` : 0
- item.actionText = `中标单位 TOP3`
- item.childrenShow = true
- item.children = []
- if (Array.isArray(item.winner)) {
- item.winner.forEach((w, i) => {
- const row = {
- name: w.winner,
- id: w.id,
- type: 'winner',
- subInfo1: w.winner_amount ? `中标金额:${utils.formatMoney(w.winner_amount / 10000, undefined, true)}万元` : '',
- // subInfo2: w.amount_scale ? `该行业占比:${utils.formatMoney(w.amount_scale * 100, undefined, true)}%` : ''
- }
- item.children.push(row)
- })
- }
- })
- tableDataAmount.rows = amountTop3
- }
- if (tableDataCount.rows.length) {
- this.$set(this.sections.userScatter, 'projectCountTop3', tableDataCount.rows)
- }
- if (tableDataAmount.rows.length) {
- this.$set(this.sections.userScatter, 'projectAmountTop3', tableDataAmount.rows)
- }
- },
- // 细分市场
- sortMarketRefineData (data) {
- const refineCount = {
- columns: ['行业', '项目数量'],
- rows: []
- }
- const refineAmount = {
- columns: ['行业', '项目金额'],
- rows: []
- }
- let total = 0
- const refineAll = data.scaleRefineAll
- if (Array.isArray(refineAll)) {
- const field = {
- 行业: 'name',
- 项目数量: 'total',
- 项目金额: 'amount'
- }
- refineAll.forEach(item => {
- const row = {}
- for (const key in field) {
- if (field[key] === 'amount') {
- row[key] = utils.formatMoney(item[field[key]] / 10000, undefined, true)
- } else {
- row[key] = item[field[key]]
- }
- if (field[key] === 'total' || field[key] === 'amount') {
- total += (item[field[key]] - 0)
- }
- }
- refineCount.rows.push(row)
- refineAmount.rows.push(row)
- })
- }
- if (total) {
- this.$set(this.sections.market.refine, 'projectCountData', refineCount)
- this.$set(this.sections.market.refine, 'projectAmountData', refineAmount)
- this.sections.market.refine.dataAlready = true
- }
-
- this.sortRefineTop3(data)
- },
- sortRefineTop3 (data) {
- const tableDataCount = {
- columns: ['序号', '细分市场:项目数量(个)', '前3中标单位:中标数量(个)'], // ,占比,该细分市场占比
- rows: []
- }
- const tableDataAmount = {
- columns: ['序号', '细分市场:项目金额(万元)', '前3中标单位:中标金额(万元)'], // ,占比,该细分市场占比
- rows: []
- }
- const countTop3 = data.scaleRefineTotalTop
- if (Array.isArray(countTop3)) {
- countTop3.forEach((item, index) => {
- item.name = item.name
- item.subInfo1 = item.value ? `项目数量:${item.value}个` : ''
- // item.subInfo2 = item.prop ? `全部占比:${utils.formatMoney(item.prop * 100, undefined, true)}%` : 0
- item.actionText = `中标单位 TOP3`
- item.childrenShow = true
- item.children = []
- if (Array.isArray(item.topList)) {
- item.topList.forEach((w, i) => {
- const row = {
- name: w.name,
- id: w.id,
- type: 'winner',
- subInfo1: w.value ? `中标个数:${w.value}个` : '',
- // subInfo2: w.prop ? `该细分市场占比:${utils.formatMoney(w.prop * 100, undefined, true)}%` : ''
- }
- item.children.push(row)
- })
- }
- })
- tableDataCount.rows = countTop3
- }
- const amountTop3 = data.scaleRefineAmountTop
- if (Array.isArray(amountTop3)) {
- amountTop3.forEach((item, index) => {
- item.name = item.name
- item.subInfo1 = item.value ? `项目金额:${utils.formatMoney(item.value / 10000, undefined, true)}万元` : ''
- // item.subInfo2 = item.prop ? `全部占比:${utils.formatMoney(item.prop * 100, undefined, true)}%` : 0
- item.actionText = `中标单位 TOP3`
- item.childrenShow = true
- item.children = []
- if (Array.isArray(item.topList)) {
- item.topList.forEach((w, i) => {
- const row = {
- name: w.name,
- id: w.id,
- type: 'winner',
- subInfo1: w.value ? `中标金额:${utils.formatMoney(w.value / 10000, undefined, true)}万元` : '',
- // subInfo2: w.prop ? `该细分市场占比:${utils.formatMoney(w.prop * 100, undefined, true)}%`: ''
- }
- item.children.push(row)
- })
- }
- })
- tableDataAmount.rows = amountTop3
- }
- if (tableDataCount.rows.length) {
- this.$set(this.sections.market.refine, 'projectCountTop3', tableDataCount.rows)
- }
- if (tableDataAmount.rows.length) {
- this.$set(this.sections.market.refine, 'projectAmountTop3', tableDataAmount.rows)
- }
- },
- // 采购单位
- sortBuyerclassData (data) {
- const buyerclassChartData = {
- columns: ['金额区间', '采购总金额占比', '采购单位数量占比'],
- rows: []
- }
- let total = 0
- const buyerclassList = data.buyer_time_distribution
- if (Array.isArray(buyerclassList)) {
- const field = {
- [buyerclassChartData.columns[0]]: 'key',
- [buyerclassChartData.columns[1]]: 'total_amount',
- [buyerclassChartData.columns[2]]: 'total_number'
- }
- buyerclassList.forEach(item => {
- const row = {}
- buyerclassChartData.columns.forEach(column => {
- if (field[column] === 'total_amount' || field[column] === 'total_number') {
- row[column] = (item[field[column]] * 100).toFixed(2)
- total += (item[field[column]] - 0)
- } else {
- row[column] = item[field[column]]
- }
- })
- buyerclassChartData.rows.push(row)
- })
- }
- if (total) {
- buyerclassChartData.rows.reverse()
- this.$set(this.sections.buyerclass, 'chartData', buyerclassChartData)
- this.sections.buyerclass.dataAlready = true
- }
-
- this.sortBuyerclassTableData(data)
- },
- sortBuyerclassTableData (data) {
- const dataCount = {
- columns: ['序号', '采购单位:采购数量(个)', '前3中标单位:中标数量(个)'], //,占比 | ,占该采购单位
- rows: []
- }
- const dataAmount = {
- columns: ['序号', '采购单位:采购金额(万元)', '前3中标单位:中标金额(万元)'], //,占比 | ,占该采购单位
- rows: []
- }
- const countTop3 = data.buyer_count_top3
- if (Array.isArray(countTop3)) {
- countTop3.forEach((item, index) => {
- item.name = item.name
- item.type = 'buyer'
- item.id = item.name
- item.subInfo1 = item.number ? `项目数量:${item.number}个` : ''
- // item.subInfo2 = item.accounted ? `全部占比:${utils.formatMoney(item.accounted * 100, undefined, true)}%` : ''
- item.actionText = `中标单位 TOP3`
- item.childrenShow = true
- item.children = []
- if (Array.isArray(item.winnertop3)) {
- item.winnertop3.forEach((w, i) => {
- const row = {
- name: w.name,
- id: w.id,
- type: 'winner',
- subInfo1: w.number ? `中标个数:${w.number}个` : '',
- // subInfo2: w.accounted ? `占该采购单位:${utils.formatMoney(w.accounted * 100, undefined, true)}%` : ''
- }
- item.children.push(row)
- })
- }
- })
- dataCount.rows = countTop3
- }
- const amountTop3 = data.buyer_amount_top3
- if (Array.isArray(amountTop3)) {
- amountTop3.forEach((item, index) => {
- item.name = item.name
- item.type = 'buyer'
- item.id = item.name
- item.subInfo1 = item.amount ? `采购金额:${utils.formatMoney(item.amount / 10000, undefined, true)}万元` : ''
- // item.subInfo2 = item.accounted ? `全部占比:${utils.formatMoney(item.accounted * 100, undefined, true)}%` : ''
- item.actionText = `中标单位 TOP3`
- item.childrenShow = true
- item.children = []
- if (Array.isArray(item.winnertop3)) {
- item.winnertop3.forEach((w, i) => {
- const row = {
- name: w.name,
- id: w.id,
- type: 'winner',
- subInfo1: w.amount ? `中标金额:${utils.formatMoney(w.amount / 10000, undefined, true)}万元` : '',
- // subInfo2: w.accounted ? `该行业占比:${utils.formatMoney(w.accounted * 100, undefined, true)}%` : ''
- }
- item.children.push(row)
- })
- }
- })
- dataAmount.rows = amountTop3
- }
- if (dataCount.rows.length) {
- this.$set(this.sections.buyerclass, 'projectCountTop3', dataCount.rows)
- }
- if (dataAmount.rows.length) {
- this.$set(this.sections.buyerclass, 'projectAmountTop3', dataAmount.rows)
- }
- },
- // 中标单位
- sortWinnerData (data) {
- const chartData = {
- columns: ['金额区间', '中标总金额占比', '中标单位数量占比'],
- rows: []
- }
- let total = 0
- const chartLIst = data.winner_time_distribution
- if (Array.isArray(chartLIst)) {
- const field = {
- [chartData.columns[0]]: 'key',
- [chartData.columns[1]]: 'total_amount',
- [chartData.columns[2]]: 'total_number'
- }
- chartLIst.forEach(item => {
- const row = {}
- chartData.columns.forEach(column => {
- if (field[column] === 'total_amount' || field[column] === 'total_number') {
- row[column] = (item[field[column]] * 100).toFixed(2)
- total += (item[field[column]] - 0)
- } else {
- row[column] = item[field[column]]
- }
- })
- chartData.rows.push(row)
- })
- }
- if (total) {
- chartData.rows.reverse()
- this.$set(this.sections.winner, 'chartData', chartData)
- this.sections.winner.dataAlready = true
- }
- this.sortWinnerTableData(data)
- },
- sortWinnerTableData (data) {
- const dataCount = {
- columns: ['序号', '中标单位:中标数量(个)', '前3采购单位:采购数量(个)'], // ,占比 | ,占该中标单位
- rows: []
- }
- const dataAmount = {
- columns: ['序号', '中标单位:中标金额(万元),占比', '前3采购单位:采购金额(万元),占该中标单位'], // ,占比 | ,占该中标单位
- rows: []
- }
- const countTop3 = data.winner_count_top3
- if (Array.isArray(countTop3)) {
- countTop3.forEach((item, index) => {
- item.name = item.name
- item.type = 'winner'
- item.id = item.id
- item.subInfo1 = item.number ? `中标数量:${item.number}个` : ''
- // item.subInfo2 = item.accounted ? `全部占比:${utils.formatMoney(item.accounted * 100, undefined, true)}%` : ''
- item.actionText = `采购单位 TOP3`
- item.childrenShow = true
- item.children = []
- if (Array.isArray(item.buyertop3)) {
- item.buyertop3.forEach((w, i) => {
- const row = {
- name: w.name,
- id: w.name,
- type: 'buyer',
- subInfo1: w.number ? `采购数量:${w.number}个` : '',
- // subInfo2: w.accounted ? `占该中标单位:${utils.formatMoney(w.accounted * 100, undefined, true)}%` : ''
- }
- item.children.push(row)
- })
- }
- })
- dataCount.rows = countTop3
- }
- const amountTop3 = data.winner_amount_top3
- if (Array.isArray(amountTop3)) {
- amountTop3.forEach((item, index) => {
- item.name = item.name
- item.type = 'winner'
- item.id = item.id
- item.subInfo1 = item.amount ? `中标金额:${utils.formatMoney(item.amount / 10000, undefined, true)}万元` : ''
- // item.subInfo2 = item.accounted ? `全部占比:${utils.formatMoney(item.accounted * 100, undefined, true)}%` : ''
- item.actionText = `采购单位 TOP3`
- item.childrenShow = true
- item.children = []
- if (Array.isArray(item.buyertop3)) {
- item.buyertop3.forEach((w, i) => {
- const row = {
- name: w.name,
- id: w.name,
- type: 'buyer',
- subInfo1: w.amount ? `采购金额:${utils.formatMoney(w.amount / 10000, undefined, true)}万元` : '',
- // subInfo2: w.accounted ? `占该中标单位:${utils.formatMoney(w.accounted * 100, undefined, true)}%` : ''
- }
- item.children.push(row)
- })
- }
- })
- dataAmount.rows = amountTop3
- }
- if (dataCount.rows.length) {
- this.$set(this.sections.winner, 'projectCountTop3', dataCount.rows)
- }
- if (dataAmount.rows.length) {
- this.$set(this.sections.winner, 'projectAmountTop3', dataAmount.rows)
- }
- },
- toAnalysisPage: function () {
- this.rid = ''
- this.analysis.loaded = false
- this.filtersPageShow = true
- },
- moneyUnit (num, type, lv) {
- const m = utils.moneyUnit(num, type, lv)
- let unit = String(m).match(/[\u4e00-\u9fa5]/g)
- if (unit && Array.isArray(unit)) {
- unit = unit.join('')
- } else {
- unit = ''
- }
- let count = ''
- if (unit) {
- count = m.replace(unit, '') - 0
- }
- return {
- unit,
- count
- }
- },
- anchorTo (item) {
- // if (!item.top) return
- var offsetTop = item.top || 0
- this.activeDimension = item.id
- this.$nextTick(function () {
- $('.search-result > .j-main')[0].scrollTop = offsetTop
- })
- },
- showSetKeyTip: function () {
- this.notSetKey = true
- },
- setKeyTip: function () {
- this.showDialog({
- title: '',
- message: '分析内容为您订阅的关键词组,您<br />当前尚未订阅,请前往完善',
- className: 'j-confirm-dialog text-center',
- showConfirmButton: true,
- showCancelButton: true,
- confirmButtonText: '订阅管理',
- confirmButtonColor: '#2abed1'
- }).then(() => {
- if (this.isSubCount) {
- // 提示联系管理员
- this.showToast('请联系管理员完善订阅的关键词')
- // this.showDialog({
- // title: '',
- // message: '请联系管理员完善订阅的关键词',
- // className: 'j-confirm-dialog text-center',
- // showConfirmButton: true,
- // showCancelButton: false,
- // confirmButtonText: '我知道了',
- // confirmButtonColor: '#2abed1'
- // })
- } else {
- this.toSubManage()
- }
- })
- },
- toSubManageButtonClick: function () {
- if (this.isSubCount) {
- this.showToast('请联系管理员完善订阅的关键词')
- } else {
- this.toSubManage()
- }
- },
- toSubManage: function () {
- this.isWeixin = utils.isWeiXinBrowser
- let rootlink = 'f'
- if (this.powerInfo.memberStatus > 0) {
- rootlink = 'm'
- } else if (this.powerInfo.vipStatus > 0) {
- rootlink = 'v'
- } else {
- rootlink = 'f'
- }
- if(this.isWeixin) {
- location.href = '/front/vipsubscribe/toSetKeyWordPage?vSwitch=' + rootlink
- } else {
- location.href = '/jyapp/vipsubscribe/toSetKeyWordPage?vSwitch=' + rootlink
- }
- },
- toArticleContent (item) {
- this.saveState()
- location.href = `/jyapp/article/content/${item._id}.html`
- },
- toPortrait (id, type) {
- if (!type || !id) return
- this.saveState()
- if (type === 'winner') {
- location.href = `./ent_portrait?eId=${id}`
- } else if (type === 'buyer') {
- location.href = `./unit_portrayal?entName=${id}`
- }
- }
- }
- })
|