pptMixins.js 49 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276
  1. /** 图库9.0(智能PPT) 共通逻辑 */
  2. import Highcharts from "highcharts/highstock";
  3. import HighchartsMore from 'highcharts/highcharts-more';
  4. import HighchartszhCN from '@/utils/highcahrts-zh_CN'
  5. HighchartszhCN(Highcharts)
  6. HighchartsMore(Highcharts)
  7. import { dataBaseInterface,pptInterface } from "@/api/api.js";
  8. import {etaBaseConfigInterence} from '@/api/modules/etaBaseConfigApi.js';
  9. import {pptEnInterface} from '@/api/modules/pptEnApi.js';
  10. import * as sheetInterface from '@/api/modules/sheetApi.js';
  11. import futuresInterface from '@/api/modules/futuresBaseApi';
  12. import { fittingEquationInterface,statisticFeatureInterface,crossVarietyInterface } from '@/api/modules/chartRelevanceApi';
  13. import chartRelevanceApi from '@/api/modules/chartRelevanceApi.js';
  14. import { defaultOpts } from '@/utils/defaultOptions';
  15. import {formatPPTDate,checkPPTpageElemant,getStrSize,isShowPPTTitle,toTextProps,toJson,rgbaToHex,getChartInfo} from '../newVersion/utils/untils.js';
  16. import FormatOne from '../newVersion/components/formatPage/FormatOne.vue';
  17. import FormatTwo from '../newVersion/components/formatPage/FormatTwo.vue';
  18. import FormatThree from '../newVersion/components/formatPage/FormatThree.vue';
  19. import FormatFour from '../newVersion/components/formatPage/FormatFour.vue';
  20. import FormatFive from '../newVersion/components/formatPage/FormatFive.vue';
  21. import FormatSix from '../newVersion/components/formatPage/FormatSix.vue';
  22. import FormatSeven from '../newVersion/components/formatPage/FormatSeven.vue';
  23. import FormatEight from '../newVersion/components/formatPage/FormatEight.vue';
  24. import FormatNine from '../newVersion/components/formatPage/FormatNine.vue';
  25. import FormatTen from '../newVersion/components/formatPage/FormatTen.vue';
  26. import FormatEle from '../newVersion/components/formatPage/FormatEle.vue';
  27. import FormatTwelve from '../newVersion/components/formatPage/FormatTwelve.vue';
  28. import FormatThirteen from '../newVersion/components/formatPage/FormatThirteen.vue';
  29. import FormatFourteen from '../newVersion/components/formatPage/FormatFourteen.vue';
  30. const chunkArray = (array, chunkSize)=>{
  31. let result = [];
  32. for (let i = 0; i < array.length; i += chunkSize) {
  33. result.push(array.slice(i, i + chunkSize));
  34. }
  35. return result;
  36. }
  37. export default {
  38. components:{ FormatOne,FormatTwo,FormatThree,
  39. FormatFour,FormatFive,FormatSix,FormatSeven,FormatEight,FormatNine,FormatTen,FormatEle,FormatTwelve,FormatThirteen,FormatFourteen},
  40. computed: {
  41. globalLang() { //全局语言版本 中文ppt可用 英文ppt固定en忽视
  42. return this.$store.state.lang
  43. }
  44. },
  45. data(){
  46. return{
  47. chartInfo:null,
  48. dataList:[],
  49. optionMap:{},
  50. options:{},
  51. sheetDataMap:{},//表格Table数据
  52. sheetHeightMap:{},//表格iframe的高
  53. pptInitType:'edit',//ppt模式,编辑页为edit,其他页面为show
  54. result:{
  55. status:''
  56. },//getpptDataById的结果
  57. dataLoading:null,//getPptData loading
  58. pageLoading:null,//演示时,切换page需要加载图表数据
  59. publishLoading:null,//发布时loading
  60. pptCoverList:[],//配置ppt封面
  61. pptBgImage:'',//ppt背景图
  62. pptBackImage:'',//ppt封底
  63. pptCoverCompenyName:'',//封面公司名称 ETA1.4.9后不再使用
  64. pptCoverDepartName:'',//封面部门名称 ETA1.4.9后不再使用
  65. pptCoverTextColor:'',//控制上面两个字段展示的颜色 ETA1.4.9后不再使用
  66. pptCoverContent:'',//自定义封面页的内容
  67. pptSheetSize:'',//ppt内嵌表格的字号
  68. setEnName:false,
  69. // 传入的formItem所需内容
  70. formItemArray:[],
  71. addMyChartShow:false,//控制添加到 我的图库 弹窗是否显示
  72. addChartInfoId:0,//当前选择的图表InfoId,
  73. addChartClassifyIds:[],//当前选择的图表所在我的图库目录id
  74. addChartId:'',//当前选择的图表UnicodeId
  75. //截面散点设置英文props
  76. enChartInfo: {},
  77. enEdblist:[],
  78. chartSVGDataMap:{}
  79. }
  80. },
  81. methods: {
  82. getBasePosition(titleDetail){
  83. const {top=6.6,left=10,width=68,height=5} = titleDetail
  84. const baseWidth = 900
  85. const baseHeight = 630
  86. return {
  87. baseTop:baseHeight*top/100,
  88. baseLeft:baseWidth*left/100,
  89. baseWidth:baseWidth*width/100,
  90. baseHeight:baseHeight*height/100,
  91. }
  92. },
  93. //配置自定义标题内容
  94. setPPTTitle(slide,page){
  95. const {titleDetail,title} = page
  96. //兼容之前的ppt
  97. if(!titleDetail){
  98. slide.addText(title, {
  99. /* placeholder:"slideTitle", */
  100. x:'10%',
  101. y:'5.5%',
  102. w:'68%',
  103. h:'7%',
  104. color:'333333'
  105. });
  106. }else{
  107. const {left,top,width,height,color='#333',fontSize=24,fontFamily} = titleDetail
  108. const text = toTextProps(toJson(title))
  109. const colorObj = color.includes('#')?{color:'333333',transparency:0}:rgbaToHex(color)
  110. slide.addText(text,{
  111. /* placeholder:"slideTitle", //加上后会走母版slideTitle的设置 */
  112. x:left+'%',
  113. y:top+'%',
  114. w:width+'%',
  115. h:height+'%',
  116. color:colorObj.color,
  117. transparency:colorObj.transparency,
  118. fontSize:fontSize*0.7,
  119. fontFace:fontFamily,
  120. })
  121. }
  122. return slide
  123. },
  124. //配置自定义封面内容
  125. setPPTCover(cover,pptCoverContent='',title=''){
  126. let contentList = []
  127. try{
  128. contentList = JSON.parse(pptCoverContent)
  129. }catch(e){
  130. contentList=[]
  131. }
  132. //将contentList的内容通过addText写入,方法与图层写入文字一致
  133. for(let i=0;i<contentList.length;i++){
  134. const {
  135. percentageTop,
  136. percentageLeft,
  137. percentageWidth,
  138. percentageHeight,
  139. richContent
  140. } = contentList[i]
  141. const position = {
  142. x:percentageLeft*100+'%',
  143. y:percentageTop*100+'%',
  144. w:percentageWidth*100+'%',
  145. h:percentageHeight*100+'%'
  146. }
  147. let textData = toTextProps(toJson(richContent))
  148. cover.addText(textData,{
  149. ...position,
  150. margin:10,
  151. fontSize:16*0.75,
  152. valign:'top'
  153. })
  154. }
  155. //不需要显示了
  156. //若contentList为空,则在右下的位置显示标题
  157. /* if(!contentList.length){
  158. cover.addText(
  159. [{text:title,options:{fontSize:28*0.75,breakLine:true}}],
  160. {
  161. x:'38%',
  162. y:'50%',
  163. w:'60%',
  164. h:'28%',
  165. color:'ffffff',
  166. align:'center',
  167. fontFace:'SimHei'
  168. })
  169. } */
  170. return cover
  171. },
  172. //获取基本配置-ppt配置
  173. async getpptConfig(){
  174. const res = await etaBaseConfigInterence.getBaseConfig()
  175. if(res.Ret!==200) return
  176. const {CnPptCoverImgs,CnPptBackgroundImg,CnPptBottomImg,PptCompanyName,PptTeamName,PptFontColor,CnPptSheetSize,
  177. EnPptCoverImgs,EnPptBackgroundImg,EnPptBottomImg,PptCompanyNameEn,PptTeamNameEn,PptFontColorEn,EnPptSheetSize
  178. } = res.Data
  179. if(this.currentLang==='en'){
  180. this.pptCoverList = EnPptCoverImgs.split(',')
  181. this.pptBgImage = EnPptBackgroundImg
  182. this.pptBackImage = EnPptBottomImg
  183. this.pptCoverCompenyName = PptCompanyNameEn
  184. this.pptCoverDepartName = PptTeamNameEn
  185. this.pptCoverTextColor = PptFontColorEn
  186. this.pptSheetSize = EnPptSheetSize
  187. }else{
  188. this.pptCoverList = CnPptCoverImgs.split(',')
  189. this.pptBgImage = CnPptBackgroundImg
  190. this.pptBackImage = CnPptBottomImg
  191. this.pptCoverCompenyName = PptCompanyName
  192. this.pptCoverDepartName = PptTeamName
  193. this.pptCoverTextColor = PptFontColor
  194. this.pptSheetSize = CnPptSheetSize
  195. }
  196. },
  197. //获取ppt详情
  198. async getpptDataById(id){
  199. let res = null
  200. if (this.$route.query.isVersionRecord === 'true') {
  201. res = await pptInterface.getPptHistoryDetail({
  202. Id:id
  203. })
  204. } else {
  205. res = this.currentLang!=='en'?await pptInterface.getpptDetail({
  206. PptId:id
  207. }):await pptEnInterface.getpptDetail({PptId:id})
  208. }
  209. if(res.Ret===200){
  210. const {
  211. Content,
  212. Title,
  213. ReportType,
  214. BackgroundImg,
  215. PptDate,
  216. TemplateType,
  217. ReportId,
  218. ModifyTime,
  219. PublishTime,
  220. Editor,
  221. CoverContent,
  222. TitleSetting,
  223. AdminId,
  224. ReportSource
  225. } = res.Data
  226. const pptDate = formatPPTDate(this.currentLang, PptDate)
  227. let legalContent = Content ? JSON.parse(Content) : []
  228. legalContent = legalContent.map(page => {
  229. page.elements = checkPPTpageElemant(page)
  230. return page
  231. })
  232. let legalTitleSetting = null
  233. try{
  234. legalTitleSetting = TitleSetting ? JSON.parse(TitleSetting) : null
  235. }catch(e){
  236. console.log(e)
  237. legalTitleSetting = null
  238. }
  239. this.pptCoverContent = CoverContent
  240. this.result = {
  241. status: 200,
  242. content: legalContent,
  243. FirstPage: {
  244. Title,
  245. ReportType,
  246. BackgroundImg,
  247. PptDate: pptDate,
  248. TemplateType,
  249. },
  250. ReportId,
  251. ModifyTime,
  252. PublishTime,
  253. Editor,
  254. CoverContent,
  255. TitleSetting:legalTitleSetting,
  256. AdminId,
  257. ReportSource
  258. }
  259. }else{
  260. this.result = {status:'',content:'获取ppt数据失败!'}
  261. }
  262. },
  263. //ppt设置相关,引用mixins.js里的setOptions chartType只有source是1才有用
  264. /* Source 1 ; chartType 1曲线 2季节 3面积 4堆积柱 5散点 6组合 7柱形 8截面散点
  265. * 2 商品价格
  266. * 3 相关性
  267. * 4 滚动相关性
  268. * 5 商品利润
  269. * 6 拟合方程
  270. * 7 统计特征/标准差
  271. * 8 统计特征/百分位
  272. * 9 统计特征/频率
  273. * 10 跨品种分析
  274. */
  275. //获取图表数据
  276. async getchartData(id,lang='zh') {
  277. console.log('getChartData')
  278. const currentLang = this.currentLang==='en'?'en':this.globalLang;
  279. const res = await dataBaseInterface.getChartByCode({
  280. UniqueCode: id,
  281. IsCache:true
  282. });
  283. const { Data } = res;
  284. if(!Data) return
  285. this.chartInfo = Data.ChartInfo;
  286. if(!this.chartInfo) return
  287. if([1,11,12].includes(this.chartInfo.Source)) { //常规图
  288. //处理下历史默认来源
  289. this.setDefaultSourceFrom();
  290. //季节性图处理SeasonAverageConfig,SeasonRightEdbConfig
  291. if(this.chartInfo.ChartType===2){
  292. const {MaxMinLimits={},SamePeriodAverage={},SamePeriodStandardDeviation={},RightAxis={}} = Data.DataResp||{}
  293. this.chartInfo.SeasonAverageConfig = {MaxMinLimits,SamePeriodAverage,SamePeriodStandardDeviation}
  294. this.chartInfo.SeasonRightConfig = RightAxis
  295. }
  296. this.dataList = Data.EdbInfoList;
  297. //初始化上下限
  298. this.setLimitData(this.dataList)
  299. //柱形图独立数据
  300. this.chartInfo.ChartType === 7 && this.initBarData(res.Data);
  301. //截面散点图
  302. this.chartInfo.ChartType === 10 && this.initSectionScatterData(res.Data);
  303. //雷达图
  304. this.chartInfo.ChartType === 11 && this.initRadarData(res.Data);
  305. //截面组合图
  306. this.chartInfo.ChartType===14 && this.initSectionalCombinationChart(res.Data)
  307. // 区间分析
  308. this.chartInfo.Source===12&&this.initIntervalAnalysisChartData(res.Data)
  309. // 时序组合图控制是否堆叠
  310. if(this.chartInfo.ChartType===6){
  311. this.IsHeap=res.Data.DataResp.IsHeap===1?true:false
  312. }
  313. Data.Status && ![7,10,14].includes(this.chartInfo.ChartType) && this.setOptions();
  314. Data.Status&&this.setOptionsLang(currentLang)
  315. }else if([2,5].includes(this.chartInfo.Source)) { //商品价格图
  316. this.chartInfo = Data.ChartInfo.Source===5 ? {
  317. ...Data.ChartInfo,
  318. ProfitNameEn: Data.DataResp.ProfitNameEn,
  319. ProfitName: Data.DataResp.ProfitName,
  320. } : Data.ChartInfo;
  321. this.dataList = [Data.EdbInfoList[0]];
  322. this.initCommodityData(res.Data)
  323. this.setCommodityLang(currentLang)
  324. }else if([3].includes(this.chartInfo.Source)){//相关性
  325. this.relevanceChartData={
  326. ChartInfo:res.Data.ChartInfo,
  327. EdbInfoList:res.Data.EdbInfoList,
  328. XEdbIdValue:this.chartInfo.Source === 3 ? res.Data.XEdbIdValue : res.Data.DataResp.XDateTimeValue,
  329. CorrelationChartInfo:res.Data.CorrelationChartInfo,
  330. YDataList:[
  331. {
  332. Value:this.chartInfo.Source === 3 ? res.Data.YDataList[0].Value : res.Data.DataResp.YDataList[0].Value,
  333. Color:res.Data.YDataList[0].Color||'#00f',
  334. Name:res.Data.YDataList[0].Name||res.Data.ChartInfo.ChartName,
  335. NameEn:res.Data.YDataList[0].NameEn||res.Data.ChartInfo.ChartNameEn
  336. }
  337. ]
  338. }
  339. //多因子重新赋值YDataList
  340. if(res.Data.CorrelationChartInfo.AnalysisMode===1){
  341. this.relevanceChartData.YDataList = res.Data.YDataList
  342. }
  343. this.initRelevanceChartData()
  344. this.changeRelevanceOptions(currentLang)
  345. }else if(this.chartInfo.Source===4) {//滚动相关性换成曲线图绘图
  346. this.dataList = [res.Data.DataResp];
  347. this.relevanceChartData = {
  348. CorrelationChartInfo: res.Data.CorrelationChartInfo
  349. }
  350. this.setDefaultChart([res.Data.DataResp]);
  351. this.changeRelevanceOptions(currentLang)
  352. }else if([6,7,8].includes(this.chartInfo.Source)) {
  353. //拟合方程 标准差 百分比
  354. this.dataList = [res.Data.DataResp];
  355. this.setDefaultChart([res.Data.DataResp]);
  356. }else if(this.chartInfo.Source===9) { //统计频率
  357. this.dataList = res.Data.EdbInfoList;
  358. this.statisticFrequencyData = res.Data.DataResp;
  359. this.setStatisticFrequency();
  360. }else if(this.chartInfo.Source===10) {
  361. this.dataList = res.Data.EdbInfoList;
  362. this.crossVarietyChartData = res.Data.DataResp;
  363. /* 历史数据chartInfo里全是空 兼容下历史数据不崩 */
  364. this.chartLimit = {
  365. min: res.Data.ChartInfo.LeftMin?Number(res.Data.ChartInfo.LeftMin):Number(res.Data.DataResp.YMinValue),
  366. max: res.Data.ChartInfo.LeftMax?Number(res.Data.ChartInfo.LeftMax):Number(res.Data.DataResp.YMaxValue),
  367. x_min: res.Data.ChartInfo.XMin?Number(res.Data.ChartInfo.XMin):Number(res.Data.DataResp.XMinValue),
  368. x_max: res.Data.ChartInfo.XMax?Number(res.Data.ChartInfo.XMax):Number(res.Data.DataResp.XMaxValue),
  369. }
  370. this.setCrossVarietyChart();
  371. this.changeRelevanceOptions(currentLang);//更改英文一样
  372. }
  373. //根据图表数据获取配置项
  374. if(Data.Status){
  375. const chartTitle = currentLang==='zh'?this.chartInfo.ChartName
  376. :this.chartInfo.ChartNameEn?this.chartInfo.ChartNameEn
  377. :this.chartInfo.ChartName
  378. //由于英文PPT复制图表名称时,使用MyChartTitle字段会复制英文名称(如果有),现需要复制中文名称,遂增加了chartTitleCN存储中文名称
  379. const otherOpts = {
  380. MyChartType:this.chartInfo.ChartType,//图表类型,和Source一起确定是什么图
  381. MyChartTitle:chartTitle,//ppt复制时的图表标题(个别类型图表渲染时也需要展示图表标题)
  382. chartTitleCN:this.chartInfo.ChartName,//英文ppt复制时,需要使用中文的图表标题......
  383. chartInfoId:this.chartInfo.ChartInfoId,//添加到我的图库,图表id
  384. MyChartClassifyId:this.chartInfo.MyChartClassifyId,//添加到我的图库,图库Id
  385. Source:this.chartInfo.Source,//图表来源,和MyChartType一起确定是什么图
  386. Instructions: this.chartInfo.Instructions,
  387. SourcesFrom: this.chartInfo.SourcesFrom,
  388. ChartThemeStyle: this.chartInfo.ChartThemeStyle,
  389. ChartAlias:this.chartInfo.ChartAlias||'',//图表别名
  390. }
  391. this.optionMap[id] = { ...defaultOpts, ...this.options,...otherOpts };
  392. }else{
  393. this.optionMap[id] = 'noSource'
  394. }
  395. //console.log("?", this.optionMap);
  396. },
  397. //设置图表中英文
  398. setOptionsLang(lang){
  399. console.log(lang)
  400. //中文图表不需要下面的设置
  401. if(lang==='zh') return
  402. //当 图表名称、指标名称、指标单位 有其一没有英文名称时,也不需要下面的设置
  403. // if(!this.checkChartEnData()) return
  404. const {ChartType} = this.chartInfo
  405. if(ChartType!=5){
  406. this.options.yAxis.forEach(item=>{
  407. item.title.text = item.title.textEn?item.title.textEn:item.title.textCh
  408. })
  409. if(ChartType!=2)
  410. this.options.series.forEach(item=>{
  411. item.name = item.nameEn?item.nameEn:item.nameCh
  412. })
  413. if(ChartType === 7) this.options.xAxis.categories = this.barXIdData.map(_ => this.barEdbData.find(edb => edb.EdbInfoId===_).EdbNameEn);
  414. //截面散点 x轴标题
  415. if(ChartType === 10){
  416. this.options.xAxis.title.text = this.options.xAxis.title.textEn || this.options.xAxis.title.textCh;
  417. this.options.tooltip.formatter = this.options.tooltip.formatterEn || this.options.tooltip.formatterCh;
  418. this.options.series.forEach(item => {
  419. if(!item.linkedTo) {
  420. item.data.forEach(point => {
  421. point.dataLabels.format = point.dataLabels.formatEn || point.dataLabels.formatCh;
  422. })
  423. }
  424. });
  425. }
  426. }
  427. //散点图
  428. if(ChartType==5){
  429. this.options.yAxis.title.text = this.options.yAxis.title.textEn
  430. this.options.yAxis.title.style = this.options.yAxis.title.styleEn||{}
  431. this.options.xAxis.title.text = this.options.xAxis.title.textEn
  432. this.options.xAxis.title.style = this.options.xAxis.title.styleEn||{}
  433. this.options.series.forEach(item => {
  434. item.name = item.nameEn
  435. });
  436. this.options.tooltip.formatter = this.options.tooltip.formatterEn
  437. }
  438. },
  439. /* 设置价格曲线英文 */
  440. setCommodityLang(lang) {
  441. if(lang==='zh') return
  442. //当 图表名称、指标名称、指标单位 有其一没有英文名称时,也不需要下面的设置
  443. // if(!this.checkChartEnData()) return
  444. this.options.yAxis.forEach(item => {
  445. item.title.text = item.title.textEn || item.title.textCh
  446. });
  447. //图例
  448. this.options.series.forEach(item => {
  449. item.name = item.nameEn || item.nameCh
  450. });
  451. //tooltip
  452. this.options.tooltip.formatter = this.options.tooltip.formatterEn
  453. //x轴
  454. this.options.xAxis.categories = this.commodityXData.map(_ => _.NameEn);
  455. },
  456. /* 切换相关性图中英文 */
  457. changeRelevanceOptions(lang){
  458. if(lang==='zh') return
  459. // if(!this.checkChartEnData()) return
  460. console.log(this.options)
  461. this.options.yAxis.forEach(item => {
  462. item.title.text = item.title.textEn || item.title.textCh
  463. });
  464. //图例
  465. this.options.series.forEach(item => {
  466. item.name = item.nameEn || item.nameCh
  467. });
  468. //tooltip
  469. this.options.tooltip.formatter = this.options.tooltip.formatterEn
  470. this.options.xAxis.title.text=this.options.xAxis.title.textEn
  471. },
  472. /* 历史图表默认显示图表来源 d毛后端不修复只能自己每次详情处理下*/
  473. setDefaultSourceFrom() {
  474. if(!this.chartInfo.SourcesFrom) {
  475. let themeOpt = JSON.parse(this.chartInfo.ChartThemeStyle);
  476. this.chartInfo.SourcesFrom = JSON.stringify({
  477. isShow: true,
  478. text: this.chartInfo.ChartSource,
  479. color: themeOpt&&themeOpt.markerOptions.style.color,
  480. fontSize: themeOpt&&themeOpt.markerOptions.style.fontSize
  481. });
  482. }
  483. },
  484. //检查图表英文配置是否完整
  485. checkChartEnData(){
  486. let result = true
  487. //图表名称:this.chartInfo.ChartNameEn
  488. if(!this.chartInfo.ChartNameEn){
  489. result = false
  490. }
  491. if(this.chartInfo.Source === 10) {
  492. const { XNameEn,YNameEn,DataList } = this.crossVarietyChartData;
  493. let haveOneNoEn = DataList.some(_ =>!_.NameEn);
  494. if(haveOneNoEn || !XNameEn || !YNameEn) result = false
  495. }else {
  496. //指标名称:this.dataList[].EdbNameEn
  497. //指标单位:this.dataList[].UnitEn
  498. this.dataList.forEach(item=>{
  499. if(!item.EdbNameEn){
  500. result = false
  501. }
  502. if(this.chartInfo.ChartType!==10&&item.Unit&&!item.UnitEn){
  503. result = false
  504. }
  505. })
  506. }
  507. return result
  508. },
  509. //刷新图表数据
  510. async getRefreshChart(id){
  511. const res = await dataBaseInterface.chartRefresh({
  512. UniqueCode:id
  513. })
  514. if(res.Ret!==200){
  515. return
  516. }
  517. },
  518. //打开添加到我的图库弹窗
  519. async handleAddChartToGallery(chartId){
  520. const chartInfo = this.$store.state.ppt.chartInfoMap[chartId]
  521. this.addChartId = chartId
  522. this.addChartInfoId = chartInfo.chartInfoId
  523. this.addChartClassifyIds = chartInfo.MyChartClassifyId ? chartInfo.MyChartClassifyId.split(',').map(item => Number(item)) : [];
  524. this.addMyChartShow = true
  525. },
  526. //添加到我的图库,就是改一下chartInfo的MyChartClassifyId
  527. addChartToGallery({MyChartClassifyId}){
  528. let chartInfoMap = _.cloneDeep(this.$store.state.ppt.chartInfoMap)
  529. chartInfoMap[this.addChartId].MyChartClassifyId = MyChartClassifyId
  530. this.$store.commit('SET_CHART_INFO_MAP',chartInfoMap)
  531. this.addMyChartShow = false
  532. },
  533. //编辑ppt时,按页初始化相关
  534. async initPageElements(page,type="edit",only=false) {
  535. this.pptInitType = type
  536. const chartElements = page.elements.filter((item) => {
  537. return item.type === "chart";
  538. });
  539. const imageElements = page.elements.filter((item) => {
  540. return item.type === "image";
  541. });
  542. const textElements = page.elements.filter((item)=>{
  543. return item.type === 'text'
  544. })
  545. const sheetElements = page.elements.filter((item)=>{
  546. return item.type === 'sheet'
  547. })
  548. this.initPageTitle(page)
  549. if(type==='edit'){
  550. this.initTexts(textElements,page)
  551. }
  552. this.initImages(imageElements,page);
  553. await this.sheetListHandle(sheetElements);
  554. this.initSheets(sheetElements,page,only)
  555. await this.listHandle(chartElements);
  556. this.initCharts(chartElements, page);
  557. },
  558. //初始化内页标题
  559. initPageTitle(page){
  560. const index = this.pageList.findIndex((i) => i.id === page.id)
  561. this.$nextTick(()=>{
  562. const dom = document.getElementById(`page_title__${index}`)
  563. if(dom){
  564. dom.innerHTML = page.title
  565. }
  566. })
  567. },
  568. //图表,表格数据统一加载,不按照页
  569. async initPPTAllPage(pageList){
  570. let chartElements = []
  571. let sheetElements = []
  572. pageList.forEach(page=>{
  573. const pageChartElements = page.elements.filter((item) => {
  574. return item.type === "chart";
  575. });
  576. const pageSheetElements = page.elements.filter((item)=>{
  577. return item.type === 'sheet'
  578. })
  579. chartElements.push(...pageChartElements)
  580. sheetElements.push(...pageSheetElements)
  581. })
  582. await this.sheetListHandle(sheetElements);
  583. await this.listHandle(chartElements);
  584. },
  585. async listHandle(chartElements,fromType='') {
  586. let needGetDataArr = []
  587. for(let i=0;i<chartElements.length;i++) {
  588. if(!this.optionMap[chartElements[i].chartId]&&!needGetDataArr.includes(chartElements[i].chartId)){
  589. /* needGetDataArr.push(new Promise((res,rej)=>{
  590. res(this.getchartData(chartElements[i].chartId))
  591. })) */
  592. needGetDataArr.push(chartElements[i].chartId)
  593. }
  594. }
  595. if(needGetDataArr.length){
  596. //由于存在加载过程中会切换PPT/页面的情况,不能一股脑加载
  597. //将需要加载的数据分组
  598. const chunkedArray = chunkArray(needGetDataArr, 6);
  599. for(let i=0;i<chunkedArray.length;i++){
  600. if(!chunkedArray[i].length) continue //如果组内无数据,跳过
  601. if(this.interruptLoad) return //若需要中断加载,返回
  602. const promisesList = chunkedArray[i].map(chartId=>{
  603. return new Promise((res,rej)=>{
  604. res(this.getchartData(chartId))
  605. })
  606. })
  607. await Promise.all(promisesList).then(()=>{}).catch((e)=>{
  608. console.log('catch',e)
  609. })
  610. console.log(`第${i}组chart加载完成`)
  611. }
  612. console.log('全部chart加载完成')
  613. if(fromType==='present'){
  614. for(let i=0;i<chartElements.length;i++) {
  615. let temp = getChartInfo(this.optionMap[chartElements[i].chartId])
  616. this.$store.commit('SET_CHART_INFO',{chartId:chartElements[i].chartId,chartInfo:temp})
  617. }
  618. }
  619. }
  620. },
  621. async sheetListHandle(sheetElements){
  622. let needGetDataArr = []
  623. for(let i=0;i<sheetElements.length;i++){
  624. if( (!this.sheetDataMap[sheetElements[i].sheetId] || !this.sheetDataMap[sheetElements[i].sheetId].list)
  625. && !needGetDataArr.includes(sheetElements[i].sheetId)){
  626. needGetDataArr.push(sheetElements[i].sheetId)
  627. }
  628. }
  629. if(needGetDataArr.length){
  630. //由于存在加载过程中会切换PPT/页面的情况,不能一股脑加载
  631. //将需要加载的数据分组
  632. const chunkedArray = chunkArray(needGetDataArr, 6);
  633. for(let i=0;i<chunkedArray.length;i++){
  634. if(!chunkedArray[i].length) continue //如果组内无数据,跳过
  635. if(this.interruptLoad) return //若需要中断加载,返回
  636. const promisesList = chunkedArray[i].map(sheetId=>{
  637. return new Promise((res,rej)=>{
  638. res(this.getsheetData(sheetId))
  639. })
  640. })
  641. await Promise.all(promisesList).then(()=>{}).catch((e)=>{
  642. console.log('catch',e)
  643. })
  644. console.log(`第${i}组sheet加载完成`)
  645. }
  646. console.log('全部sheet加载完成')
  647. }
  648. },
  649. async getsheetData(id){
  650. const res = await sheetInterface.getSheetData({
  651. UniqueCode: id
  652. })
  653. if(res.Ret !== 200) return 0
  654. const {TableInfo,SourcesFrom,ExcelSource} = res.Data
  655. //console.log('get')
  656. this.sheetDataMap[id] ={
  657. list:_.cloneDeep(TableInfo.TableDataList),
  658. otherParams:{
  659. SourcesFrom:SourcesFrom?SourcesFrom:
  660. ExcelSource?this.setDefaultSource(ExcelSource):''
  661. }
  662. }
  663. return 1
  664. },
  665. setDefaultSource(sourceText){
  666. return JSON.stringify({
  667. isShow: true,
  668. text: sourceText,
  669. color: "#606266",
  670. fontSize: 9
  671. })
  672. },
  673. initCharts(elements, page) {
  674. const index = this.pageList.findIndex((i) => i.id === page.id)
  675. if(index===-1) return
  676. elements.forEach((item) => {
  677. if (this.optionMap[item.chartId] instanceof Object){
  678. this.initChart(
  679. `chart_${index}_${item.position}`,
  680. this.optionMap[item.chartId],
  681. page,
  682. item.chartId
  683. )
  684. }else{
  685. //显示图表已被删除
  686. this.initImage(
  687. `#img_${index}_${item.position}`,
  688. "https://hzstatic.hzinsights.com/static/ppt_default.png"
  689. )
  690. }
  691. });
  692. },
  693. initChart(refName, options, page,chartId="") {
  694. console.log("refName", refName);
  695. const index = this.pageList.findIndex((i) => i.id === page.id)
  696. if(index===-1) return
  697. //if(!this.$refs[`pptPage_${index}`]||!this.$refs[`pptPage_${index}`][0]) return
  698. /* if(!$(`#${refName}`)[0]) return */
  699. /*
  700. Source:1
  701. MyChartType: 2 季节性图,7 柱形图, 10 截面散点图,11 雷达图
  702. Source:2
  703. MyChartType: 8 商品价格曲线图
  704. Source:5
  705. MyChartType: 8 利润曲线
  706. Source:6 拟合方程曲线
  707. Source:7 统计特征
  708. 以上图表需要显示标题
  709. Source:1
  710. MyChartType:1 曲线图 5 散点图 6组合图
  711. 以上图表需要显示别名
  712. 后端控制->通过新字段来判断是否显示标题/别名
  713. */
  714. const {Source,MyChartType,ChartThemeStyle} = options
  715. const isShowTitle = isShowPPTTitle(Source,MyChartType)
  716. const isShowOtherTitle = Source===1&&[1,4,5,6,11,14].includes(MyChartType)
  717. /* 主题样式*/
  718. const chartTheme = ChartThemeStyle ? JSON.parse(ChartThemeStyle) : null;
  719. console.log('chartTheme',chartTheme)
  720. //console.log(options)
  721. this.$nextTick(() => {
  722. let is_linear = options.series
  723. ? options.series.some(_ => _.chartType === 'linear')
  724. : false ;
  725. /* 根据板式控制的季节图x轴的刻度数
  726. 板式1 不管 其余3个
  727. 板式10 12的曲线,堆积柱,组合 也固定3个 其余板式不管
  728. */
  729. const { modelId } = this.pageList[index];
  730. let minData=[],maxData=[];
  731. if([1,2,4,6].includes(MyChartType)) {
  732. options.series.forEach(item => {
  733. if(item.data&&item.data.length) {
  734. minData.push(item.data[0][0])
  735. maxData.push(item.data[item.data.length-1][0])
  736. }
  737. })
  738. }
  739. let tickInterval = undefined;
  740. if((modelId!==1&&MyChartType===2)
  741. || ([1,4,6].includes(MyChartType)&&[10,12].includes(modelId))) {
  742. tickInterval = (Math.max(...maxData)-Math.min(...minData))/6;
  743. }
  744. //y轴也要刻度数量固定...
  745. let tickAmount = [3,4,5,10,11,12].includes(modelId)?6:undefined;
  746. //title样式
  747. let titleHTML = null
  748. //中英文发布页需设置title换行
  749. //一行可容纳的中文字体数
  750. const fontSize = chartTheme?chartTheme.titleOptions.style.fontSize:16
  751. let count = parseInt($(`#${refName}`)[0].offsetWidth / fontSize)*1.75
  752. let {total,newStr} = getStrSize(isShowTitle?options.MyChartTitle:isShowOtherTitle?options.ChartAlias:'',count)
  753. const isPublish = this.$route.path==='/pptpublish'||this.$route.path==='/pptenpublish'
  754. if(isShowTitle||(isShowOtherTitle&&options.ChartAlias.length)){
  755. titleHTML = `<div style="
  756. text-align:${chartTheme&&chartTheme.titleOptions.align};
  757. font-size:${chartTheme&&chartTheme.titleOptions.style.fontSize}px;
  758. color:${chartTheme&&chartTheme.titleOptions.style.color};
  759. min-height:18px;word-break: break-all;
  760. ">
  761. ${isShowTitle?options.MyChartTitle:isShowOtherTitle?options.ChartAlias:''}
  762. </div>`
  763. }
  764. let SpecialOption = {
  765. chart: {
  766. ...defaultOpts.chart,
  767. ...chartTheme&&chartTheme.drawOption,
  768. spacing: chartTheme.legendOptions.verticalAlign==='bottom' ? [25,10,2,10] : [2,10,2,10],//图例在底部顶部空间留大点给单位
  769. animation: false,
  770. backgroundColor: "rgba(0,0,0,0)",
  771. renderTo:$(`#${refName}`)[0],
  772. polar: (MyChartType===11&&Source===1) ? true :false
  773. },
  774. legend: {
  775. ...defaultOpts.legend,
  776. ...chartTheme&&chartTheme.legendOptions
  777. },
  778. colors: options.colors||chartTheme&&chartTheme.colorsOptions||defaultOpts.colors,
  779. title: isPublish?{
  780. text: (isShowTitle||(isShowOtherTitle&&options.ChartAlias.length))?newStr:null,
  781. margin:5,
  782. useHTML:false,
  783. style:{...chartTheme&&chartTheme.titleOptions.style},
  784. align: (chartTheme&&chartTheme.titleOptions.align) || (total>count?'left':'center'),
  785. }:{
  786. text: titleHTML,
  787. useHTML:true,
  788. margin:0,
  789. style:{textAlign:chartTheme&&chartTheme.titleOptions.align,left:0,width:'100%'}
  790. },
  791. plotOptions: {
  792. ...defaultOpts.plotOptions,
  793. series: {
  794. animation: false,
  795. turboThreshold: 0, //不限制数据点个数
  796. dataGrouping: {
  797. enabled: false,
  798. }
  799. },
  800. },
  801. xAxis: {
  802. ...options.xAxis,
  803. tickInterval: is_linear ? undefined : tickInterval
  804. },
  805. yAxis: options.yAxis.map(_ => ({
  806. ..._,
  807. tickAmount
  808. }))
  809. }
  810. //奇怪柱不堆叠
  811. let secialBarOpt = (options.series.some(_ => _.chartType === 'linear') && options.series.some(_ => _.chartType === 'linear')) ? {
  812. plotOptions: {
  813. ...defaultOpts.plotOptions,
  814. column:{
  815. stacking: null,
  816. },
  817. },
  818. } : {};
  819. if(!$(`#${refName}`)[0]) return
  820. let chart = null
  821. if(is_linear)
  822. chart = Highcharts.chart({
  823. // Highcharts 配置
  824. ...options,
  825. ...SpecialOption,
  826. ...secialBarOpt
  827. });
  828. else
  829. chart = Highcharts.stockChart({
  830. // Highcharts 配置
  831. ...options,
  832. ...SpecialOption,
  833. ...secialBarOpt
  834. });
  835. if(isPublish&&chartId){
  836. const {clientWidth,clientHeight} = $(`#${refName}`)[0]
  837. const {plotBackgroundColor} = chartTheme&&chartTheme.drawOption||{}
  838. const svgData = chart.getSVG({
  839. chart:{
  840. width:clientWidth,
  841. height:clientHeight,
  842. backgroundColor:null,
  843. plotBorderColor:null,
  844. plotBackgroundColor:null,
  845. plotBackgroundImage:null,
  846. plotBorderWidth:null,
  847. plotShadow:false,
  848. animation: false,
  849. }
  850. })
  851. let parser = new DOMParser();
  852. let svgDoc = parser.parseFromString(svgData, 'image/svg+xml');
  853. //console.log('plotBackgroundColor',plotBackgroundColor)
  854. // 查找class为'background'的rect元素并修改fill属性
  855. let rectElement = svgDoc.querySelector('rect.highcharts-plot-background');
  856. if (rectElement) {
  857. //transparent(生成的图表背景会变黑) -> rgba(255, 255, 255, 0)
  858. let currentColor = plotBackgroundColor==='transparent'?'rgba(255, 255, 255, 0)':plotBackgroundColor
  859. rectElement.setAttribute('fill', currentColor);
  860. }
  861. // 将修改后的SVG文档转换回字符串
  862. let serializer = new XMLSerializer();
  863. let updatedSvgCode = serializer.serializeToString(svgDoc);
  864. this.chartSVGDataMap[`${refName}_${chartId}`] = updatedSvgCode
  865. }
  866. });
  867. },
  868. initImages(elements,page){
  869. const index = this.pageList.findIndex((i) => i.id === page.id)
  870. elements.forEach((item)=>{
  871. this.initImage(`#image_${index}_${item.position}`,item.src)
  872. })
  873. },
  874. initImage(idName,url){
  875. //console.log('idName',idName,'url',url)
  876. $(`${idName}`).hide()
  877. this.$nextTick(()=>{
  878. $(`${idName}`).attr('src',url).attr('object-fit','scale-down')
  879. $(`${idName}`).show()
  880. })
  881. },
  882. initTexts(elements,page){
  883. const index = this.pageList.findIndex((i) => i.id === page.id)
  884. elements.forEach((item)=>{
  885. this.initText(index,`text_${index}_${item.position}`)
  886. })
  887. },
  888. initText(pageindex,refName){
  889. console.log(`pptPage_${pageindex}`,refName)
  890. this.$nextTick(()=>{
  891. this.$refs[`pptPage_${pageindex}`][0].$refs[refName].initTiny()
  892. })
  893. },
  894. initSheets(elements,page,only){
  895. const index = this.pageList.findIndex((i) => i.id === page.id)
  896. this.$nextTick(()=>{
  897. const formatRef = only?this.$refs[`pptPage_${index}`]:this.$refs[`pptPage_${index}`][0]
  898. elements.forEach((item)=>{
  899. this.initSheet(formatRef,`sheet_${index}_${item.position}`,item.sheetId)
  900. })
  901. })
  902. },
  903. initSheet($parent,refName,sheetId,type='init'){
  904. console.log('init sheet',refName)
  905. const $children = $parent.$children
  906. /* console.log('children',$children) */
  907. this.$nextTick(()=>{
  908. const sheet = $children.find(i=>i.$data.type==='sheet'&&i.item.sheetId===sheetId)
  909. sheet&&sheet.getSheetData(sheetId,this.sheetDataMap[sheetId])
  910. })
  911. if(this.pptInitType!=='edit'||refName.includes('preview')) return
  912. this.$nextTick(()=>{
  913. if(type==='init')
  914. !this.sheetHeightMap[sheetId]&&this.initSheetIframe(refName,sheetId)
  915. else
  916. this.initSheetIframe(refName,sheetId)
  917. this.sheetHeightMap[sheetId]&&this.setSheetElHeight(refName,sheetId)
  918. })
  919. },
  920. //加载iframe
  921. initSheetIframe(idName,sheetId){
  922. console.log('init sheet iframe',idName)
  923. const LINK_URL = this.$setting.dynamicOutLinks.ChartViewUrl+'/sheetshow';
  924. $(`#${idName}`).append(`<iframe
  925. src='${LINK_URL}?code=${sheetId}'
  926. width='100%'
  927. height='0'
  928. class='sheet-iframe-box'
  929. style='border-width:0px;'
  930. />
  931. `)
  932. },
  933. //获取表格iframe的高度,用于ppt转报告
  934. reInitIframe(e) {
  935. const LINK_URLS=[this.$setting.dynamicOutLinks.ChartViewUrl+'/chartshow',this.$setting.dynamicOutLinks.ChartViewUrl+'/sheetshow']
  936. if(!LINK_URLS.includes(e.origin)) return
  937. /* console.log('iframe加载完成',e.data) */
  938. const { height,code } = e.data;
  939. this.sheetHeightMap[code] = height
  940. this.pageList.forEach((page,pageIndex)=>{
  941. page.elements.map(el=>{
  942. if(el.type==='sheet'&&el.sheetId===code){
  943. el.sheetHeight = height+45+'px'
  944. //sheet_pageIndex_el.position
  945. const sheet = document.getElementById(`sheet_${pageIndex}_${el.position}`)
  946. //console.log(sheet.childNodes)
  947. sheet.childNodes&&sheet.childNodes.forEach(node=>{
  948. //iframe获取完高度就可以删除 留着占内存
  949. if(node.nodeName.toLocaleLowerCase()==='iframe'){
  950. sheet.removeChild(node)
  951. }
  952. })
  953. }
  954. })
  955. })
  956. },
  957. //设置表格元素的高,用于ppt转报告
  958. setSheetElHeight(idName,sheetId){
  959. const arr = idName.split('_')
  960. const pageIndex = arr[1],position = arr[2]
  961. this.pageList[pageIndex].elements.map(i=>{
  962. if(i.position==position){
  963. i.sheetHeight = this.sheetHeightMap[sheetId]+45+'px'
  964. }
  965. })
  966. },
  967. /* 设置英文配置 */
  968. async setEnHandle({UniqueCode}) {
  969. this.formItemArray={ chartInfo: [],chartsList: [] }
  970. const { Ret,Data } = await dataBaseInterface.getChartByCode({UniqueCode});
  971. if (Ret !== 200) return;
  972. let chartInfo = Data.ChartInfo;
  973. let tableData = chartInfo.Source===1 ? Data.EdbInfoList : [Data.EdbInfoList[0]];
  974. this.enChartInfo = chartInfo;
  975. this.enEdblist = tableData;
  976. this.formItemArray.chartInfo.push({
  977. label:/* "图表名称" */this.$t('Chart.Detail.chart_name'),
  978. value:chartInfo.ChartName,
  979. key:'ChartName',
  980. id:chartInfo.ChartInfoId,
  981. source: chartInfo.Source,
  982. notEdit:true
  983. },
  984. {
  985. label:/* "英文图表名称" */this.$t('Chart.Detail.chart_en_name'),
  986. value:chartInfo.ChartNameEn,
  987. key:'ChartNameEn',
  988. id:chartInfo.ChartInfoId,
  989. placeholder:/* "请输入英文图表名称" */ this.$t('Chart.InputHolderAll.input_en_name')
  990. })
  991. if([1,2,5].includes(chartInfo.Source)){
  992. this.formItemArray.chartsList = tableData.map(item => {
  993. return item.Unit
  994. ? [
  995. {
  996. label:/* "指标名称" */this.$t('Edb.Detail.e_name'),
  997. value:item.EdbName,
  998. key:'EdbName',
  999. id:item.EdbInfoId,
  1000. notEdit:true
  1001. },
  1002. {
  1003. label:/* "单位" */this.$t('Edb.Detail.e_unit'),
  1004. value:item.Unit,
  1005. key:'Unit',
  1006. id:item.EdbInfoId,
  1007. notEdit:true
  1008. },
  1009. {
  1010. label:/* "英文指标名称" */this.$t('Edb.Detail.e_en_name'),
  1011. value:item.EdbNameEn,
  1012. key:'EdbNameEn',
  1013. id:item.EdbInfoId,
  1014. placeholder:/* "请输入英文指标名称" */this.$t('Edb.InputHolderAll.input_common',{label:this.$t('Edb.Detail.e_en_name')})
  1015. },
  1016. {
  1017. label:/* "英文单位" */this.$t('Edb.Detail.e_en_unit'),
  1018. value:item.UnitEn,
  1019. key:'UnitEn',
  1020. id:item.EdbInfoId,
  1021. placeholder:/* "请输入英文单位" */this.$t('Edb.InputHolderAll.input_common',{label:this.$t('Edb.Detail.e_en_unit')})
  1022. }
  1023. ]
  1024. : [
  1025. {
  1026. label:/* "指标名称" */this.$t('Edb.Detail.e_name'),
  1027. value:item.EdbName,
  1028. key:'EdbName',
  1029. id:item.EdbInfoId,
  1030. notEdit:true
  1031. },
  1032. {
  1033. label:/* "英文指标名称" */this.$t('Edb.Detail.e_en_name'),
  1034. value:item.EdbNameEn,
  1035. key:'EdbNameEn',
  1036. id:item.EdbInfoId,
  1037. placeholder:/* "请输入英文指标名称" */this.$t('Edb.InputHolderAll.input_common',{label:this.$t('Edb.Detail.e_en_name')})
  1038. }
  1039. ]
  1040. })
  1041. }
  1042. //价格曲线
  1043. if(chartInfo.Source===2) {
  1044. this.formItemArray.chartInfo.push({
  1045. label:/* "期货名称" */this.$t('Chart.Detail.good_name'),
  1046. value:Data.EdbInfoList[1].EdbName,
  1047. key:'FutureGoodName',
  1048. id:chartInfo.ChartInfoId,
  1049. notEdit:true
  1050. },
  1051. {
  1052. label:/* "英文期货名称" */this.$t('Chart.Detail.good_en_name'),
  1053. value:Data.EdbInfoList[1].EdbNameEn,
  1054. key:'FutureGoodNameEn',
  1055. id:chartInfo.ChartInfoId,
  1056. placeholder:/* "请输入英文期货名称" */this.$t('Chart.InputHolderAll.input_common',{label:this.$t('Chart.Detail.good_en_name')})
  1057. })
  1058. }
  1059. //利润曲线
  1060. else if(chartInfo.Source===5) {
  1061. this.formItemArray.chartInfo.push({
  1062. label:/* "盘面利润名称" */this.$t('Chart.Detail.profit_name'),
  1063. value:Data.DataResp.ProfitName,
  1064. key:'ProfitName',
  1065. id:chartInfo.ChartInfoId,
  1066. notEdit:true
  1067. },
  1068. {
  1069. label:/* "英文盘面利润名称" */this.$t('Chart.Detail.profit_en_name'),
  1070. value:Data.DataResp.ProfitNameEn,
  1071. key:'ProfitNameEn',
  1072. id:chartInfo.ChartInfoId,
  1073. placeholder:/* "请输入英文盘面利润名称" */this.$t('Chart.InputHolderAll.input_common',{label:this.$t('Chart.Detail.profit_en_name')})
  1074. })
  1075. }
  1076. //跨品种分析
  1077. else if(chartInfo.Source===10) {
  1078. let res = await crossVarietyInterface.chartLangOption({ChartInfoId: chartInfo.ChartInfoId})
  1079. const { TagList,VarietyList } = res.Data;
  1080. this.formItemArray.chartInfo.push({
  1081. label:/* 'X轴名称' */this.$t('Chart.Detail.x_name'),
  1082. value:Data.DataResp.XName,
  1083. key:'XName',
  1084. id:TagList[0].ChartTagId,
  1085. notEdit:true
  1086. },
  1087. {
  1088. label:/* '英文X轴名称' */this.$t('Chart.Detail.x_en_name'),
  1089. value:Data.DataResp.XNameEn,
  1090. key:'XNameEn',
  1091. id:TagList[0].ChartTagId,
  1092. placeholder:/* '请输入英文X轴名称' */this.$t('Chart.InputHolderAll.input_common',{label:this.$t('Chart.Detail.x_en_name')})
  1093. },{
  1094. label:/* 'Y轴名称' */this.$t('Chart.Detail.y_name'),
  1095. value:Data.DataResp.YName,
  1096. key:'YName',
  1097. id:TagList[1].ChartTagId,
  1098. notEdit:true
  1099. },
  1100. {
  1101. label:/* '英文Y轴名称' */this.$t('Chart.Detail.y_en_name'),
  1102. value:Data.DataResp.YNameEn,
  1103. key:'YNameEn',
  1104. id:TagList[1].ChartTagId,
  1105. placeholder:/* '请输入英文Y轴名称' */this.$t('Chart.InputHolderAll.input_common',{label:this.$t('Chart.Detail.y_en_name')})
  1106. })
  1107. VarietyList.forEach(item => {
  1108. this.formItemArray.chartsList.push([
  1109. {
  1110. label:/* '品种名称' */this.$t('Chart.Detail.variety_name'),
  1111. value:item.ChartVarietyName,
  1112. key:'ChartVarietyName',
  1113. id:item.ChartVarietyId,
  1114. notEdit:true
  1115. },
  1116. {
  1117. label:/* '英文品种名称' */this.$t('Chart.Detail.variety_en_name'),
  1118. value:item.ChartVarietyNameEn,
  1119. key:'ChartVarietyNameEn',
  1120. id:item.ChartVarietyId,
  1121. placeholder:/* '请输入英文品种名称' */this.$t('Chart.InputHolderAll.input_common',{label:this.$t('Chart.Detail.variety_en_name')})
  1122. }
  1123. ])
  1124. })
  1125. }
  1126. this.setEnName = true
  1127. },
  1128. // 更新英文信息
  1129. async updateEnName(enNameData){
  1130. let res=null
  1131. if(this.chart_source === 1){
  1132. res=await dataBaseInterface.chartInfoEditEn(enNameData)
  1133. }else if([2,5].includes(this.chart_source)){
  1134. res=await futuresInterface.editChartEn({
  1135. ChartInfoId: enNameData.ChartInfoId,
  1136. ChartNameEn: enNameData.ChartNameEn,
  1137. UnitEn: enNameData.ChartEdbInfoList[0].UnitEn || '',
  1138. EdbNameEn: enNameData.ChartEdbInfoList[0].EdbNameEn || '',
  1139. FutureGoodNameEn: enNameData.FutureGoodNameEn || '',
  1140. ProfitNameEn: enNameData.ProfitNameEn || ''
  1141. })
  1142. }else if(this.chart_source === 3){
  1143. res=await chartRelevanceApi.editChartEn({
  1144. ChartInfoId: enNameData.ChartInfoId,
  1145. ChartNameEn: enNameData.ChartNameEn
  1146. })
  1147. }else if(this.chart_source===6){//拟合方程
  1148. res=await fittingEquationInterface.editChartEn({
  1149. ChartInfoId: enNameData.ChartInfoId,
  1150. ChartNameEn: enNameData.ChartNameEn
  1151. })
  1152. }else if(this.chart_source===7){//统计特征
  1153. res=await statisticFeatureInterface.editChartEn({
  1154. ChartInfoId: enNameData.ChartInfoId,
  1155. ChartNameEn: enNameData.ChartNameEn
  1156. })
  1157. }else if(this.chart_source===10) {//跨品种分析
  1158. res=await crossVarietyInterface.editChartEn(enNameData)
  1159. }
  1160. if(res.Ret !==200) return
  1161. this.$message({
  1162. message:res.Msg,
  1163. type:"success"
  1164. })
  1165. this.setEnName = false
  1166. },
  1167. /* 生成ppt时 图表、表格 追加底部文字 来源/说明 */
  1168. transBottomInfo(slide,{x,y,width,height},data) {
  1169. let chartData = data;
  1170. let yPercent = Number(Math.ceil(height.replace(/%/,''))+Math.ceil(y.replace(/%/,'')))+'%';
  1171. // console.log(yPercent)
  1172. if(chartData.SourcesFrom&&JSON.parse(chartData.SourcesFrom).isShow) {
  1173. let sourceObj = JSON.parse(chartData.SourcesFrom);
  1174. //pptx 只接受6bit的颜色格式,用333警告太多了 优化下
  1175. const color = sourceObj.color.includes('rgb') ? rgbaToHex(sourceObj.color).color.substring(1)
  1176. : sourceObj.color.indexOf('#')===0
  1177. ? sourceObj.color.substring(1).length<6
  1178. ? '000000':sourceObj.color.substring(1)
  1179. : '666666'
  1180. slide.addText(`${this.$t('ETable.Common.source')}:${sourceObj.text}`,{
  1181. x:x,
  1182. y: yPercent,
  1183. w: width,
  1184. margin:10,
  1185. fontSize: sourceObj.fontSize*0.75,
  1186. color,
  1187. })
  1188. }
  1189. if(chartData.Instructions&&JSON.parse(chartData.Instructions).isShow) {
  1190. let instructObj = JSON.parse(chartData.Instructions);
  1191. const color = instructObj.color.includes('rgb') ? rgbaToHex(instructObj.color).color.substring(1)
  1192. : instructObj.color.indexOf('#')===0
  1193. ? instructObj.color.substring(1).length<6
  1194. ? '000000':instructObj.color.substring(1)
  1195. : '666666'
  1196. slide.addText(instructObj.text,{
  1197. x:x,
  1198. y: yPercent,
  1199. w: width,
  1200. align:'right',
  1201. margin:10,
  1202. fontSize: instructObj.fontSize*0.75,
  1203. color,
  1204. })
  1205. }
  1206. }
  1207. },
  1208. mounted(){
  1209. this.getpptConfig()
  1210. }
  1211. }