pptMixins.js 49 KB

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