123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277 |
- function dateFormatter (date, pattern) {
- return new Date(date).pattern(pattern)
- }
- function subscribeRequestSuccess (res) {
- vm.subscribeInfo = res
- }
- var vm = new Vue({
- delimiters: ['${', '}'],
- el: '#analysis',
- components: {
- keywordComponent: keywordComponent,
- areaCityMobile: areaCityMobileComponent,
- areaComponent: areaComponent,
- industryComponent: industryComponent,
- cateComponent: cateComponent,
- dateComponent: dateComponent,
- chartExample: chartExample,
- projectHeader: projectHeaderComponent,
- downloadpopup: downloadpopup,
- // 图表
- projectScatter: projectScatter,
- marketTimeScatter: marketTimeScatter,
- marketAreaScatter: marketAreaScatter,
- marketTop3Table: marketTop3Table,
- marketUserScatter: marketUserScatter,
- marketSegment: marketSegment,
- lineChartScatter: lineChartScatter,
- },
- data: {
- sessStorageKey: '$data-report_analysis',
- tabActiveName: 'analysis', // analysis/history
- subscribeInfo: {},
- projectCount: 0,//项目总数
- projectTotalMoney:0, // 项目总金额
- winnercount: 0,//中标单位数
- buyercount:0,//采购单位数
- balance: 0,// 定制下载余额
- tabList: [
- {
- label: '市场分析定制报告',
- name: 'analysis'
- },
- {
- label: '历史报告',
- name: 'history'
- },
- {
- label: '下载记录',
- name: 'downloadRecord'
- }
- ],
- matchWayList: [
- {
- name: '按标题匹配',
- label: 'title'
- },
- {
- name: '按全文匹配',
- label: 'content'
- }
- ],
- 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,
- filtersCache: {
- matchway: 'title'
- },
- filters: {
- selectKeysArr: [], // 关键词简单数组,用于恢复选择状态
- matchway: 'title',
- keys: [], // 关键词详细数组,用于提交数据
- area: {},
- industry: [],
- industryDetail: {},
- buyerclass: [],
- rangeTime: {
- start: '',
- end: '',
- exact: 'sinceYearBeforeLast',
- },
- },
- filterDialogShow: {
- keys: false,
- matchway: 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,
- projectAmountMorebtn: false,
- projectCountMorebtn: false,
- }
- },
- 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,
- // 地区信息接口返回的原始数据
- originAreaData: [],
- showAreaPopup: false,
- setCityList: [],
- selectArea: {},
- sortType: 0,
- showAreaCityListBtn: false,
- // 项目数量Top3
- projectCountTop3: null,
- // 项目金额Top3
- projectAmountTop3: null,
- projectCountMorebtn: false,
- projectAmountMorebtn: false,
- },
- userScatter: {
- list: [],
- // 项目数量Top3
- projectCountTop3: null,
- // 项目金额Top3
- projectAmountTop3: null,
- projectAmountMorebtn: false,
- projectCountMorebtn: false
- },
- buyerclass: {
- dataAlready: false,
- chartData: null,
- // 项目数量Top3
- projectCountTop3: null,
- showCountAllBtn: false,
- // 项目金额Top3
- projectAmountTop3: null,
- showAmoutAllBtn: false
- },
- winner: {
- dataAlready: false,
- chartData: null,
- // 项目数量Top3
- projectCountTop3: null,
- showCountAllBtn: false,
- // 项目金额Top3
- projectAmountTop3: null,
- showAmoutAllBtn: false
- }
- },
- empty: {
- defaultMsg: '对不起,没有匹配到相关信息<br />请修改您的分析条件',
- msg: ''
- },
- stickyOffset: 0,
- notSetKey: false, // 未设置关键词
- isSubCount: false, // 是否子账号
- powerInfo: {},
- isWeixin: false,
- sortOptionTitle: '项目数量由大到小排序',
- sortOptionContent: [
- { text: '项目数量由大到小排序', value: 0, active: true },
- { text: '项目金额由大到小排序', value: 1, active: false }
- ],
- },
- computed: {
- showdownFooter: function () {
- return this.projectCount > 0 && this.rid// 项目总数大于零&&rid已生成
- },
- downFootertitle: function () {
- return !this.getStatus?'如需查看详细市场分析报告,您可选择:' : '如您对以上分析满意,可点击:'
- },
- isbigmemerOrEnt:function(){
- return this.powerInfo.memberStatus > 0 || this.powerInfo.entIsNew || this.powerInfo.entniche || this.powerInfo.isEntService
- },
- showBuyerBtn: function () {
- return this.sections.buyerclass.showCountAllBtn ? this.sections.buyerclass.projectCountTop3.slice(0, 3) : this.sections.buyerclass.projectCountTop3
- },
- showAmoutBtn: function () {
- return this.sections.buyerclass.showAmoutAllBtn ? this.sections.buyerclass.projectAmountTop3.slice(0, 3) : this.sections.buyerclass.projectAmountTop3
- },
- showWinnerCountBtn: function () {
- return this.sections.winner.showCountAllBtn ? this.sections.winner.projectCountTop3.slice(0, 3) : this.sections.winner.projectCountTop3
- },
- showWinnerAmoutBtn: function () {
- return this.sections.winner.showAmoutAllBtn ? this.sections.winner.projectAmountTop3.slice(0, 3) : this.sections.winner.projectAmountTop3
- },
- showAreaCityBtn: function () {
- return this.sections.areaScatter.showAreaCityListBtn ? this.sections.areaScatter.setCityList.slice(0, 5) : this.sections.areaScatter.setCityList
- },
- getStatus: function () { // 市场定制分析权限
- if (JSON.stringify(this.powerInfo) !== '{}') {
- return this.powerInfo.power.indexOf(26) !== -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
- },
- notOneAreaCityFilter () {
- var area = this.reportFilters.area
- if (!this.notOneAreaFilter) {
- var showCity = area && (area[Object.keys(area)].length >=2 || area[Object.keys(area)].length === 0)
- return showCity
- } else {
- return this.notOneAreaFilter
- }
- },
- 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
- return winnerState.dataAlready && winnerState.chartData
- },
- winnerSectionShow () {
- const winnerState = this.sections.winner
- // return winnerState.dataAlready && winnerState.projectCountTop3 && winnerState.projectAmountTop3
- return winnerState.dataAlready && winnerState.chartData
- },
- 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()
- // }
- this.calcStickyOffset()
- }
- },
- subscribeInfo (n) {
- if (!this.rid && n && n.member_jy && n.member_jy.i_matchway) {
- this.setDefaultMatchWay(n.member_jy.i_matchway)
- }
- },
- },
- 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: {
- goDown () {// 报告下载
- console.log(this.$refs)
- this.$refs.downloadpopup.show({id:this.rid})
- },
- freeGolink () {
- if (this.isbigmemerOrEnt) {
- this.showDialog({
- title: '申请免费体验',
- message: '您可联系客服,申请体验查看完整报告内容。',
- className: 'j-confirm-dialog down-dialog',
- confirmButtonText: '联系客服',
- cancelButtonText: '我再想想',
- }).then(res=>{
- if (utils.$envs.inWX) { // 客服
- window.location.href = '/big/wx/page/customer'
- } else {
- window.location.href = '/jyapp/free/customer'
- }
- })
- } else { // 留资
- if (utils.$envs.inWX) {
- location.href = '/weixin/frontPage/bigmember/free/perfect_info?source=wx_dzbg_fullreport'
- } else if (utils.$envs.inApp){
- location.href = '/jyapp/frontPage/bigmember/free/perfect_info?source=app_dzbg_fullreport'
- }else{
- location.href = '/jyapp/frontPage/bigmember/free/perfect_info?source=h5_dzbg_fullreport'
- }
- }
- },
- goAlldetail(type,title){ // top3 全量列表
- this.saveState()
- location.href = `/jy_mobile/reportanalysis/rankingDetail?title=${title}&type=${type}&id=${this.rid}`
- },
- setDefaultMatchWay: function (matchWay) {
- // matchWay 1按标题匹配title 2按全文匹配content
- var map = {
- 1: 'title',
- 2: 'content'
- }
- var defaultMatchWay = map[matchWay]
- if (defaultMatchWay) {
- this.filters.matchway = defaultMatchWay
- }
- },
- // 设置排序方式
- setsortType (data) {
- this.sections.areaScatter.sortType = data
- const type = data===0 ? 'total' : 'amount'
- // const list = this.setCitySort(this.sections.areaScatter.setCityList, type)
- let newArr = []
- if(data === 0) {
- newArr = this.sections.areaScatter.setCityList.sort((a, b) => b.total - a.total)
- } else {
- newArr = this.sections.areaScatter.setCityList.sort((a, b) => b.amount - a.amount)
- }
- this.sections.areaScatter.setCityList = this.formatterWinData(newArr, type)
- this.sortOptionTitle = this.sortOptionContent[data].text
- this.sections.areaScatter.setCityList = newArr
- },
- cancelSelectArea () {
- this.sections.areaScatter.showAreaPopup = false
- },
- // 城市排序
- setCitySort (list, type) {
- return list.sort((a, b) => {
- a[type] - b[type]
- })
- },
- // 选择省份展示城市分布(单选)
- confirmSelectArea (data) {
- console.log(data)
- if(this.sections.areaScatter.originAreaData.length > 0) {
- this.sections.areaScatter.originAreaData.forEach(item => {
- if(item.area == data.data[0]) {
- this.sections.areaScatter.selectArea = item
- const areaSort = this.sections.areaScatter.sortType === 0 ? 'total' : 'amount'
- let newArr = []
- if(this.sections.areaScatter.sortType === 0) {
- newArr = item.areaDetails.sort((a, b) => b.total - a.total)
- } else {
- newArr = item.areaDetails.sort((a, b) => b.amount - a.amount)
- }
- this.sections.areaScatter.setCityList = this.formatterWinData(newArr, areaSort)
- this.sections.areaScatter.setCityList = this.sections.areaScatter.setCityList.sort((a, b) => b[areaSort] - a[areaSort])
- if(this.sections.areaScatter.setCityList.length > 5) {
- this.sections.areaScatter.showAreaCityListBtn = true
- } else {
- this.sections.areaScatter.showAreaCityListBtn = false
- }
- }
- })
- }
- this.sections.areaScatter.showAreaPopup = false
- },
- showCountAmount (data) {
- return (data.amount / 10000).toFixed(2)
- },
- inProList () {
- this.saveState()
- if(utils.$envs.inWX){
- if(!this.getStatus) {
- location.href = '/weixin/frontPage/bigmember/free/perfect_info?source=wx_analysis_ProjectDetails'
- } else {
- window.location.href='/big/wx/page/report_analysis_pro_list?id=' + this.rid
- }
- } else {
- if(!this.getStatus) {
- location.href = '/jyapp/frontPage/bigmember/free/perfect_info?source=app_analysis_ProjectDetails'
- } else {
- window.location.href='/jyapp/big/page/report_analysis_pro_list?id=' + this.rid
- }
- }
- },
- gotable () {
- this.saveState()
- if(utils.$envs.inWX){
- 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 = 0
- try{
- headerHeight = $('.jy-app-header')[0].clientHeight // 微信端没有header
- }catch(e){
- }
- 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 == 'history') {
- this.goToAnalysisHistory()
- }else if(name == 'downloadRecord'){
- location.href = '/jy_mobile/reportanalysis/reportDownload'
- }
- 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)
- } else if (type === 'matchway') {
- text = this.resolveSelectMatchWayText(filters.matchway)
- }
- return prefix + text
- },
- resolveSelectMatchWayText: function (m) {
- var map = {
- title: '按标题匹配',
- content: '按全文匹配'
- }
- return map[m]
- },
- 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)
- } else if (key = 'matchway') {
- this.filtersCache[key] = this.filters[key]
- }
- 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(),
- matchingMode: this.filters.matchway,
- 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
- var loading = this.showLoading()
- /*
- 1.如该用户当前身份下存在“生成中”的报告 则弹框提示报告生成中等等。。。
- 2.该用户不存在“生成中”的报告,且该报告需要离线生成
- 2-1:【消息-服务通知】APP、微信提醒均未开启 则弹框提示去开启
- 2-2:【消息-服务通知】APP或微信提醒已开启 则弹框提示我知道了
- */
- $.ajax({
- type: 'POST',
- url: '/bigmember/marketAnalysis/doAnalysis',
- data: query,
- success: function (res) {
- loading.clear()
- if (res && res.error_code === 0 && res.data) {
- // id:报告id
- // msgOpen:微信或APP提醒是否打开(离线生成时会返回该字段)
- // status:0-在线生成 走原逻辑 1-离线生成 (判断msgOpen出提示文案) 2-存在正在生成的报告(需要出弹出提示,由用户确认,id为需要取消的报告id,如果用户确认,则传该id调用取消接口后再次调用分析接口)
- if (res.data.status === 0) {
- this.rid = res.data.id
- this.analysis.loaded = true
- // location.replace('./report_analysis?id=' + res.data)
- this.rid = res.data.id
- history.replaceState({}, null, '?id=' + this.rid)
- this.getReportResult()
- } else if (res.data.status === 1) {
- return this.showDialog({
- allowHtml: true,
- title: '报告生成中',
- message: res.data.msgOpen ? '由于您的分析内容较多,报告正在努力生成中,生成成功后将会通过微信、APP给您发送1消息通知,届时您再前往查看此报告。' : '由于您的分析内容较多,报告正在努力生成中。建议您前往开启“<span class="highlight-text">消息-服务通知</span>”提醒,报告生成成功后可通过微信或APP给您发送1消息通知,届时您可前往查看此报告。',
- className: 'j-confirm-dialog text-justify',
- showCancelButton: !res.data.msgOpen,
- confirmButtonText: res.data.msgOpen ? '我知道了' : '去开启',
- cancelButtonText: res.data.msgOpen ? '' : '暂不开启',
- beforeClose: (action, done) => {
- if (action === 'confirm') {
- if (!res.data.msgOpen) {
- // 去开启 进到推送设置页面
- location.href = '/jy_mobile/push/pushsetting?active=1'
- } else {
- // 我知道了 回到历史报告页面
- this.goToAnalysisHistory()
- }
- } else {
- // 暂不开启 回到历史报告页面
- this.goToAnalysisHistory()
- }
- done()
- }
- })
- } else if (res.data.status === 2) {
- return this.showDialog({
- title: '报告生成确认',
- message: '您有1份报告正在“生成中”,请确定是否按照此条件重新生成,注:如确定则原状态为“生成中”的报告将被自动取消。',
- className: 'j-confirm-dialog text-justify',
- beforeClose: (action, done) => {
- if (action === 'confirm') {
- this.reportCancel(res.data.id)
- done()
- } else {
- done()
- }
- }
- })
- } else if (res.data.status === -1) {
- return this.$toast(res.data.msg)
- }
- } else {
- loading.clear()
- this.$toast(res.error_msg)
- }
- }.bind(this),
- complete: function () {
- loading.clear()
- 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,
- projectCount:this.projectCount,
- projectTotalMoney:this.projectTotalMoney, // 项目总金额
- winnercount: this.winnercount,//中标单位数
- buyercount:this.buyercount,//采购单位数
- }
- sessionStorage.setItem(this.sessStorageKey, JSON.stringify($data))
- },
- reStoreState: function () {
- var $data = sessionStorage.getItem(this.sessStorageKey)
- if ($data) {
- $data = JSON.parse($data)
- this.projectCount = $data.projectCount
- this.projectTotalMoney = $data.projectTotalMoney
- this.winnercount = $data.winnercount
- this.buyercount = $data.buyercount
- 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.sections.areaScatter.originAreaData = data.area_infos
- this.sortAreaScatter(data.area_infos)
- // 城市分布
- this.sortAreaCityScatter(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
- }
- console.log(data)
- this.filters.matchway = data.matchingMode || 'content'
- },
- // 市场概况
- 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
- this.projectCount = 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)
- this.projectTotalMoney = projectTotalMoney.count || 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
- this.winnercount = 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
- this.buyercount = 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
- }
- },
- setAreaCity () {
- this.sections.areaScatter.showAreaPopup = true
- const selectAreaArr = [this.sections.areaScatter.selectArea.area]
- this.$refs.areaSelector.setState(selectAreaArr)
- },
- // 城市分布
- sortAreaCityScatter (areacitylist) {
- if(!areacitylist) return
- const list = areacitylist
- const ZXS = ['北京', '天津', '上海', '重庆', '台湾', '澳门', '香港']
- const result = list.reduce((max, item) => {
- const isMaxZXS = ZXS.includes(max.area)
- const isZXS = ZXS.includes(item.area);
- const isMaxTotal = item.total > max.total;
- const isNotZXSMaxTotal = (isMaxTotal && !isZXS) || isMaxZXS;
- return isNotZXSMaxTotal ? item : max
- })
- if (result.areaDetails.length > 5) {
- this.sections.areaScatter.showAreaCityListBtn = true
- } else {
- this.sections.areaScatter.showAreaCityListBtn = false
- }
- this.sections.areaScatter.setCityList = this.formatterWinData(result.areaDetails, 'total')
- this.sections.areaScatter.selectArea = result
- },
- // 格式化进度条图表数据
- formatterWinData: function(data,type) {
- data.forEach(function(v,i){
- // v.bidamount = (v.bidamount / 10000).fixed(2);
- // v.average = (v.average / 10000).fixed(2);
- switch (type) {
- case 'total':
- v.parent = v.total / data[0].total*100 + "%";
- break;
- case 'amount':
- v.parent = v.amount / data[0].amount*100 + "%";
- break;
- }
- })
- return data;
- },
- // 客户分布
- 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)
- } else {
- this.sections.areaScatter.projectCountTop3 = null
- this.sections.areaScatter.projectAmountTop3 = null
- }
- if (data.scaleBuyclassCountTop || data.scaleBuyclassAmountTop) {
- this.sorUserTop3(data)
- }
- },
- sorAreaTop3 (data) {
- const tableDataCount = {
- columns: ['序号', '地区:项目数量(个),占比', '前3中标单位:中标数量(个)'], // ,该地区占比
- rows: []
- }
- const tableDataAmount = {
- columns: ['序号', '地区:项目金额(万元),占比', '前3中标单位:中标金额(万元)'], // ,该地区占比
- rows: []
- }
- if(data.scaleAreaCountTop&&data.scaleAreaCountTop.length>3){
- this.$set(this.sections.areaScatter, 'projectCountMorebtn', true)
- }
- const scaleAreaCountTop3 =data.scaleAreaCountTop?data.scaleAreaCountTop.slice(0,3) : []
- 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
- }
- if(data.scaleAreaAmountTop&&data.scaleAreaAmountTop.length>3){
- this.$set(this.sections.areaScatter, 'projectAmountMorebtn', true)
- }
- const scaleAreaAmountTop3 =data.scaleAreaAmountTop? data.scaleAreaAmountTop.slice(0,3) : []
- 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: []
- }
- if(data.scaleBuyclassCountTop&&data.scaleBuyclassCountTop.length>3){
- this.$set(this.sections.userScatter, 'projectCountMorebtn', true)
- }
- const countTop3 =data.scaleBuyclassCountTop?data.scaleBuyclassCountTop.slice(0,3) : []
- 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
- }
- if(data.scaleBuyclassAmountTop && data.scaleBuyclassAmountTop.length>3){
- this.$set(this.sections.userScatter, 'projectAmountMorebtn', true)
- }
- const amountTop3 = data.scaleBuyclassAmountTop?data.scaleBuyclassAmountTop.slice(0,3) : []
- 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: []
- }
- if(data.scaleRefineTotalTop&&data.scaleRefineTotalTop.length>3){
- this.$set(this.sections.market.refine, 'projectCountMorebtn', true)
- }
- const countTop3 =data.scaleRefineTotalTop? data.scaleRefineTotalTop.slice(0,3) : []
- 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
- }
- if(data.scaleRefineAmountTop&&data.scaleRefineAmountTop.length>3){
- this.$set(this.sections.market.refine, 'projectAmountMorebtn', true)
- }
- const amountTop3 =data.scaleRefineAmountTop? data.scaleRefineAmountTop.slice(0,3) : []
- 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) {
- if (dataCount.rows.length > 3) {
- this.sections.buyerclass.showCountAllBtn = true
- } else {
- this.sections.buyerclass.showCountAllBtn = false
- }
- this.$set(this.sections.buyerclass, 'projectCountTop3', dataCount.rows)
- }
- if (dataAmount.rows.length) {
- if (dataAmount.rows.length > 3) {
- this.sections.buyerclass.showAmoutAllBtn = true
- } else {
- this.sections.buyerclass.showAmoutAllBtn = false
- }
- 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) {
- if (dataCount.rows.length > 3) {
- this.sections.winner.showCountAllBtn = true
- } else {
- this.sections.winner.showCountAllBtn = false
- }
- this.$set(this.sections.winner, 'projectCountTop3', dataCount.rows)
- }
- if (dataAmount.rows.length) {
- if (dataAmount.rows.length > 3) {
- this.sections.winner.showAmoutAllBtn = true
- } else {
- this.sections.winner.showAmoutAllBtn = false
- }
- 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) {
- console.log(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(utils.$envs.inWX) {
- location.href = '/front/vipsubscribe/toSetKeyWordPage?vSwitch=' + rootlink
- } else {
- location.href = '/jyapp/vipsubscribe/toSetKeyWordPage?vSwitch=' + rootlink
- }
- },
- clickTOP10ProjectName (item) {
- this.saveState()
- const payload = {
- fid: '',
- sid: item._id,
- }
- sessionStorage.setItem('bigvip-fid', JSON.stringify(payload))
- if (utils.$envs.inWX) {
- // location.href = `/article/content/${item._id}.html`
- location.href = '/big/wx/page/pro_follow_detail'
- } else {
- // location.href = `/jyapp/article/content/${item._id}.html`
- location.href = '/jyapp/big/page/pro_follow_detail'
- }
- },
- toPortrait (id, type) {
- if (!type || !id) return
- this.saveState()
- if (type === 'winner') {
- if (utils.$envs.inWX) {
- location.href = `/weixin/frontPage/collection/sess/ent_portrait?eId=${id}`
- } else {
- location.href = `./ent_portrait?eId=${id}`
- }
- } else if (type === 'buyer') {
- if (utils.$envs.inWX) {
- location.href = `/big/wx/page/unit_portrayal?entName=${id}`
- } else {
- location.href = `./unit_portrayal?entName=${id}`
- }
- }
- },
- // 报告取消
- reportCancel: function (id) {
- var _this = this
- $.ajax({
- type: 'POST',
- url: '/bigmember/marketAnalysis/cancel',
- data: {
- rid: id
- },
- success: function (res) {
- if (res.data) {
- _this.startAnalysis()
- } else {
- _this.showToast(res.error_msg)
- }
- },
- error: function (error) {
- console.error(error)
- }
- })
- }
- }
- })
|