function getShortName (comName) { var areaMap = chinaMapJSON || [] var shortname = comName // 1. 循环省份城市进行替换 areaMap.forEach(function (item) { var p = item.name.replace(/[省市]/, '') if (shortname.indexOf(p) !== -1) { shortname = shortname.replace(item.name, '').replace(p, '') console.log(p + ' -> \'\'') } item.city.forEach(function (iitem) { var c = iitem.name.replace(/[省市]/, '') if (shortname.indexOf(c) !== -1) { shortname = shortname.replace(iitem.name, '').replace(c, '') console.log(c + ' -> \'\'') } iitem.area.forEach(function (iiitem) { if (shortname.indexOf(iiitem) !== -1) { shortname = shortname.replace(iiitem, '') console.log(iiitem + ' -> \'\'') } }) }) }) var matchRes = shortname.match(/[\u4e00-\u9fa5]{4}/gm) var shortname = matchRes ? matchRes[0] : shortname.slice(0, 4) if (shortname.length < 4) { shortname = shortname.slice(0, 4) } return shortname } var vm = new Vue({ el: '.see-container', delimiters: ['{', '}'], data () { return { dateVal: '', years: '', months: '', points: [], statusEnum: ['存续', '吊销', '注销', '撤销'], statusColors: ['#2CB7CA', '#F5AF5C', '#58A1E7', '#51CEA2'], listInfo: { value: '', pageNum: 0, pageSize: 10, total: -1, loading: true, finished: false }, seeList: [] } }, created() { this.years = new Date().getFullYear() this.months = parseInt(new Date().getMonth() + 1) // this.dateVal = this.years + '年' + this.months + '月' this.dateVal = new Date() this.subPoint() this.subRecord() }, methods: { subPoint() { $.ajax({ url: '/bigmember/portrait/subVipPortrait/usage', type: 'POST', contentType: 'application/x-www-form-urlencoded', data: '', dataType: 'json' }).done(res => { if (res.error_code == 0) { this.points = res.data } }) }, getDatas() { return { year: this.years, month: this.months, pageSize: this.listInfo.pageSize, pageNum: this.listInfo.pageNum } }, subRecord() { $.ajax({ url: '/bigmember/portrait/subVipPortrait/record', type: 'POST', contentType: 'application/x-www-form-urlencoded', data: this.getDatas(), dataType: 'json' }).done(res => { var _this = this if (res.error_code == 0 && res.data.list) { res.data.list.forEach(v => { const arrs = { name: v.company_name, abbr: getShortName(v.company_name), color: _this.statusColors[Math.floor(Math.random() * _this.statusColors.length)], legal: v.legal_person, money: v.capital, phone: v.company_phone, time: v.establishStamp, address: v.company_address, _id: v.id, status: _this.statusEnum.indexOf(v.company_status) || 0, statusWord: v.company_status, checked: false } this.seeList.push(arrs) }) } }) }, dateHandler(val) { this.years = val.getFullYear() this.months = val.getMonth() + 1 this.listInfo.pageNum = 0 this.seeList = [] this.subRecord() }, detailed(ids) { window.open('/swordfish/page_big_pc/svip/ent_ser_portrait/' + ids, '_blank') } } })