chartDetailDia.vue 62 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757
  1. <template>
  2. <div>
  3. <el-dialog
  4. :visible.sync="isOpenDetail"
  5. :close-on-click-modal="false"
  6. :modal-append-to-body="false"
  7. :append-to-body="false"
  8. @close="close"
  9. custom-class="chart-detail-container"
  10. top="4vh"
  11. center
  12. width="80%"
  13. v-dialogDrag
  14. >
  15. <div slot="title" style="display: flex; align-items: center;padding-right: 40px;">
  16. <span style="font-size: 16px;cursor:pointer" class="my-chart-title" @dblclick.stop="copyTitleText"
  17. :data-clipboard-text="chartInfo.ChartName">{{
  18. isNoChart ? '暂无' : (currentLang==='en'?chartInfo.ChartNameEn||chartInfo.ChartName : chartInfo.ChartName)
  19. }}</span>
  20. </div>
  21. <div class="nodata" v-if="isNoChart">
  22. <tableNoData :text="$t('Common.no_chart_msg')"/>
  23. </div>
  24. <template v-else>
  25. <div class="header">
  26. <div class="top-left">
  27. <!-- 默认曲线图 -->
  28. <template v-if="sameOptionType.includes(chartInfo.ChartType) && chartInfo.Source===1">
  29. <el-button
  30. type="primary"
  31. v-for="item in yearSelector"
  32. :key="item.value"
  33. size="medium"
  34. :plain="item.value !== year_select"
  35. class="year-btn"
  36. @click.native="changeYear(item)"
  37. >{{ item.name }}</el-button
  38. >
  39. <el-button type="text" class="btn-sty" @click="openDateDia">{{
  40. dateTip
  41. }}</el-button>
  42. </template>
  43. <!-- 季节性图选择年份区间 -->
  44. <!-- <date-picker
  45. v-else-if="chartInfo.ChartType === 2"
  46. v-model="season_year"
  47. type="month"
  48. value-type="format"
  49. range
  50. placeholder="年份日期选择"
  51. @change="seasonYearChange"
  52. /> -->
  53. <div v-else-if="chartInfo.ChartType === 2" @click="openDateDia" class="date-setting">
  54. {{ season_year && season_year.length>0 ? season_year[0]+'~'+season_year[1]:"年份日期选择" }}
  55. </div>
  56. </div>
  57. <div class="top-right" v-if="chartInfo.Button">
  58. <span v-permission="permissionBtn.myETAPermission.myChart_move"
  59. class="collected" @click="removeMychart(chartInfo)" v-if="classifyUserId === roleId">
  60. <i class="el-icon-remove-outline"></i><!-- 移出 -->{{$t('Chart.chart_remove_btn')}}
  61. </span>
  62. <el-popover
  63. v-permission="permissionBtn.myETAPermission.myChart_share"
  64. v-if="!chartInfo.Disabled"
  65. placement="top"
  66. width="200"
  67. trigger="manual"
  68. v-model="showPopConfirmMap['url']">
  69. <p>{{hintText}}</p>
  70. <div style="text-align: right; margin: 0">
  71. <el-button size="mini" type="text" @click="closePop('url')"><!-- 取消 -->{{$t('Dialog.cancel_btn')}}</el-button>
  72. <el-button type="primary" size="mini" @click="copyChart('url')"><!-- 确定 -->{{$t('Dialog.confirm_btn')}}</el-button>
  73. </div>
  74. <span class="span-item shareLink" style="margin-left: 7px;" slot="reference"
  75. @click="copyChartConfirm('url')" :data-clipboard-text="linkUrl" v-if="!chartInfo.Disabled">
  76. <i class="el-icon-share"/>&nbsp;<!-- 分享 -->{{$t('Chart.chart_share_btn')}}
  77. </span>
  78. </el-popover>
  79. <span v-permission="permissionBtn.myETAPermission.myChart_copyTo"
  80. class="span-item" @click="$parent.moveMychart(chartInfo.ChartInfoId)" v-if="classifyUserId === roleId">
  81. <img
  82. :src="$icons.chart_move_ico"
  83. alt=""
  84. style="
  85. width: 12px;
  86. height: 12px;
  87. margin-left: 7px;
  88. vertical-align: middle;
  89. "
  90. />
  91. <!-- 复制到 -->{{$t('Chart.chart_copyto_btn')}}
  92. </span>
  93. <span v-permission="permissionBtn.myETAPermission.myChart_refresh"
  94. class="span-item" @click="refreshHandle" style="margin-left: 7px;">
  95. <span><i class="el-icon-refresh" style="font-size: 15px;"/>&nbsp;<!-- 刷新 -->{{$t('Edb.detail_refresh_btn')}} </span>
  96. </span>
  97. <span
  98. class="span-item"
  99. style="margin-left: 7px"
  100. @click="$parent.addMychartHandle(chartInfo)"
  101. v-if="['/database'].includes($route.path)"
  102. >
  103. <img
  104. :src="$icons.chart_join_ico"
  105. alt=""
  106. style="width: 13px; height: 12px; vertical-align: middle"
  107. />
  108. <!-- 加入我的图库 -->{{$t('Chart.chart_addmy_btn')}}
  109. </span>
  110. <span
  111. v-permission="permissionBtn.myETAPermission.myChart_edit"
  112. class="span-item"
  113. style="margin-left: 7px"
  114. v-if="chartInfo.Button.IsEdit"
  115. @click="editChartHandle"
  116. >
  117. <span> <i class="el-icon-edit" />&nbsp;<!-- 编辑 -->{{$t('Chart.chart_edit_btn')}} </span>
  118. </span>
  119. <span
  120. v-permission="permissionBtn.myETAPermission.myChart_save"
  121. class="span-item"
  122. style="margin-left: 7px"
  123. @click="saveChartMapHandle"
  124. v-if="[1,2,5,10].includes(chartInfo.Source)"
  125. >
  126. <span> <i class="el-icon-collection" />&nbsp;<!-- 保存 -->{{$t('Chart.chart_save_btn')}} </span>
  127. </span>
  128. <span
  129. v-permission="permissionBtn.myETAPermission.myChart_otherSave"
  130. class="span-item"
  131. style="margin-left: 7px"
  132. v-if="chartInfo.Button.IsCopy"
  133. @click="saveChartOtherHandle"
  134. >
  135. <span> <i class="el-icon-document-add" />&nbsp;<!-- 另存为 -->{{$t('Chart.chart_copy_btn')}} </span>
  136. </span>
  137. <el-popover
  138. v-permission="permissionBtn.myETAPermission.myChart_copyOffice"
  139. v-if="!chartInfo.Disabled"
  140. placement="top"
  141. width="200"
  142. trigger="manual"
  143. v-click-outside="resetShowPopConfirmMap"
  144. v-model="showPopConfirmMap['office']">
  145. <p>{{hintText}}</p>
  146. <div style="text-align: right; margin: 0">
  147. <el-button size="mini" type="text" @click="closePop('office')"><!-- 取消 -->{{$t('Dialog.cancel_btn')}}</el-button>
  148. <el-button type="primary" size="mini" @click="copyChart('office')"><!-- 确定 -->{{$t('Dialog.confirm_btn')}}</el-button>
  149. </div>
  150. <span
  151. slot="reference"
  152. class="span-item copy"
  153. style="margin-left: 7px"
  154. @click="copyChartConfirm('office')"
  155. v-if="!chartInfo.Disabled"
  156. >
  157. <i class="el-icon-document-copy" />&nbsp;<!-- 复制至office -->{{$t('Chart.chart_copyoffice')}}
  158. </span>
  159. </el-popover>
  160. <el-popover
  161. v-permission="permissionBtn.myETAPermission.myChart_copyWechat"
  162. v-if="!chartInfo.Disabled"
  163. placement="top"
  164. width="200"
  165. trigger="manual"
  166. v-click-outside="resetShowPopConfirmMap"
  167. v-model="showPopConfirmMap['微信']">
  168. <p>{{hintText}}</p>
  169. <div style="text-align: right; margin: 0">
  170. <el-button size="mini" type="text" @click="closePop('微信')"><!-- 取消 -->{{$t('Dialog.cancel_btn')}}</el-button>
  171. <el-button type="primary" size="mini" @click="copyChart('微信')"><!-- 确定 -->{{$t('Dialog.confirm_btn')}}</el-button>
  172. </div>
  173. <span
  174. slot="reference"
  175. class="span-item copy"
  176. style="margin: 0 7px"
  177. @click="copyChartConfirm('微信')"
  178. v-if="!chartInfo.Disabled"
  179. >
  180. <img style="width: 13px; height: 12px;vertical-align: middle" src="~@/assets/img/chart_m/WeChat.jpg" />&nbsp;<!-- 复制至微信 -->{{$t('Chart.chart_copywx')}}
  181. </span>
  182. </el-popover>
  183. <span
  184. v-permission="permissionBtn.myETAPermission.myChart_enNameSetting"
  185. class="span-item"
  186. style="margin-left: 7px"
  187. @click="openEnNameDia"
  188. >
  189. <span> <img style="width: 16px;vertical-align: middle" :src="$icons.to_en" />&nbsp;<!-- 设置英文名称 -->{{$t('Edb.detail_en_btn')}} </span>
  190. </span>
  191. <el-popconfirm
  192. v-permission="permissionBtn.myETAPermission.myChart_del"
  193. :title="$t('Chart.OptMsg.chart_del_confirm')"
  194. icon="el-icon-info"
  195. :confirm-button-text="$t('Dialog.confirm_btn')"
  196. :cancel-button-text="$t('Dialog.cancel_btn')"
  197. @onConfirm="delChartHandle"
  198. v-if="chartInfo.Button.IsEdit"
  199. >
  200. <span
  201. slot="reference"
  202. class="span-item"
  203. style="color: #ff4040"
  204. >
  205. <i class="el-icon-delete" style="color: #ff4040" />&nbsp;<!-- 删除 -->{{$t('Chart.chart_del_btn')}}
  206. </span>
  207. </el-popconfirm>
  208. </div>
  209. </div>
  210. <div class="cont-bottom" v-loading="refreshLoading">
  211. <div class="chartEn-mark" v-show="chartInfo.IsEnChart" style="top: unset;left:unset;">En</div>
  212. <div class="chart-show-cont">
  213. <div class="chartWrapper" id="chartWrapper">
  214. <template v-if="!chartInfo.WarnMsg">
  215. <Chart :options="options" :chartInfo="chartInfo" ref="chartRef"/>
  216. <!-- 上下限 -->
  217. <template v-if="chartInfo.Source===1&&![7,10,11].includes(chartInfo.ChartType)">
  218. <div class="range-cont left" v-if="leftIndex !== -1">
  219. <el-input
  220. style="width: 60px; display: block"
  221. size="mini"
  222. type="number"
  223. placeholder="上限"
  224. v-model="chartLimit.max"
  225. @change="changeLimit"
  226. />
  227. <el-input
  228. class="min-data-input"
  229. size="mini"
  230. type="number"
  231. placeholder="下限"
  232. v-model="chartLimit.min"
  233. @change="changeLimit"
  234. />
  235. </div>
  236. <div class="range-cont right" v-if="rightIndex !== -1">
  237. <el-input
  238. style="width: 60px; display: block"
  239. size="mini"
  240. type="number"
  241. placeholder="上限"
  242. v-model="chartLimit.rightMax"
  243. @change="changeLimit"
  244. />
  245. <el-input
  246. class="min-data-input"
  247. size="mini"
  248. type="number"
  249. placeholder="下限"
  250. v-model="chartLimit.rightMin"
  251. @change="changeLimit"
  252. />
  253. </div>
  254. <!-- 右2上下限设置 -->
  255. <div class="range-cont rightTwo" v-if="rightTwoIndex !== -1">
  256. <el-input
  257. style="width: 60px; display: block"
  258. size="mini"
  259. type="number"
  260. placeholder="上限"
  261. v-model="chartLimit.rightTwoMax"
  262. @change="changeLimit"
  263. />
  264. <el-input
  265. class="min-data-input"
  266. size="mini"
  267. type="number"
  268. placeholder="下限"
  269. v-model="chartLimit.rightTwoMin"
  270. @change="changeLimit"
  271. />
  272. </div>
  273. </template>
  274. <!-- 后续新图专用上下限 和其他数据依赖不公用 柱形图 截面散点-->
  275. <template v-if="[7,10,11].includes(chartInfo.ChartType)||[2,5,10].includes(chartInfo.Source)">
  276. <div class="range-cont left">
  277. <el-input
  278. style="width: 60px; display: block"
  279. size="mini"
  280. type="number"
  281. placeholder="上限"
  282. :disabled="!isAllowEditLimit"
  283. v-model="chartLimit.max"
  284. @change="changeLimit"
  285. />
  286. <el-input
  287. class="min-data-input"
  288. size="mini"
  289. type="number"
  290. placeholder="下限"
  291. :disabled="!isAllowEditLimit"
  292. v-model="chartLimit.min"
  293. @change="changeLimit"
  294. />
  295. </div>
  296. <!-- x轴上下限 -->
  297. <div class="range-cont bottom" v-if="chartLimit.x_min||chartLimit.x_max">
  298. <el-input
  299. class="left"
  300. size="mini"
  301. type="number"
  302. placeholder="下限"
  303. :disabled="!isAllowEditLimit"
  304. v-model="chartLimit.x_min"
  305. @change="changeLimit"
  306. />
  307. <el-input
  308. class="left"
  309. size="mini"
  310. type="number"
  311. placeholder="上限"
  312. :disabled="!isAllowEditLimit"
  313. v-model="chartLimit.x_max"
  314. @change="changeLimit"
  315. />
  316. </div>
  317. </template>
  318. </template>
  319. <!-- 异常显示 -->
  320. <p class="error-tip" v-if="chartInfo.WarnMsg">{{chartInfo.WarnMsg}}</p>
  321. <!-- 左右切换按钮 -->
  322. <template v-if="allChart.length > 1">
  323. <img :src="$icons.chart_left_arrow" alt="" class="arrow left" @click="switchChart('prev')">
  324. <img :src="$icons.chart_right_arrow" alt="" class="arrow right" @click="switchChart('next')">
  325. </template>
  326. </div>
  327. <!-- 底部图表说明 -->
  328. <div class="chart-bottom-insruction-info">
  329. <div class="chart-source" v-if="chartInfo.SourcesFrom&&JSON.parse(chartInfo.SourcesFrom).isShow">
  330. <span
  331. :style="`
  332. color: ${ JSON.parse(chartInfo.SourcesFrom).color };
  333. fontSize: ${ JSON.parse(chartInfo.SourcesFrom).fontSize }px;
  334. `"
  335. ><!-- 来源 -->{{$t('Chart.Detail.source')}}:{{JSON.parse(chartInfo.SourcesFrom).text}}</span>
  336. </div>
  337. <!-- 公历农历切换 只用于季节性图 -->
  338. <el-radio-group
  339. v-if="chartInfo.ChartType === 2 && !chartInfo.WarnMsg"
  340. v-model="calendar_type"
  341. class="calendar-cont"
  342. @change="getPreviewChartInfo"
  343. >
  344. <el-radio-button label="公历">{{$t('Chart.calendar_gre')}}</el-radio-button>
  345. <el-radio-button label="农历">{{$t('Chart.calendar_lunar')}}</el-radio-button>
  346. </el-radio-group>
  347. <!-- 图表说明 -->
  348. <div
  349. class="chart-instruction"
  350. v-if="chartInfo.Instructions&&JSON.parse(chartInfo.Instructions).isShow"
  351. v-text="JSON.parse(chartInfo.Instructions).text"
  352. :style="`
  353. color: ${JSON.parse(chartInfo.Instructions).color};
  354. fontSize: ${ JSON.parse(chartInfo.Instructions).fontSize }px
  355. `"
  356. ></div>
  357. <div class="chart-author"><!-- 作者 -->{{$t('Chart.Detail.author')}}:{{chartInfo.SysUserRealName}}</div>
  358. </div>
  359. </div>
  360. <el-table
  361. :data="tableData"
  362. ref="tableRef"
  363. @row-click="rowClickHandle"
  364. @expand-change="expandChangeHandle"
  365. :row-key="getRowKey"
  366. :expand-row-keys="expandKey"
  367. highlight-current-row
  368. border
  369. >
  370. <!-- 可配置展开 只用于默认图 季节性隐藏-->
  371. <!-- <el-table-column type="expand" v-if="sameOptionType.includes(chartInfo.ChartType) && chartInfo.ChartType!==5 && chartInfo.Source===1">
  372. <template slot-scope="props">
  373. <div class="options-cont">
  374. //堆叠图 或组合图中的堆叠类型 非第一项隐藏配置
  375. <template v-if="showYOptionsHandle(props.row,props.$index)">
  376. <el-checkbox v-model="props.row.IsOrder">{{$t('Chart.Detail.re_order')}}</el-checkbox>
  377. <el-radio-group v-model="props.row.IsAxis" size="mini">
  378. <el-radio-button :label="1">{{$t('Chart.Detail.l_axis')}}</el-radio-button></el-radio-button>
  379. <el-radio-button :label="0">{{$t('Chart.Detail.r_axis')}}</el-radio-button>
  380. //指标有右轴时才可以选右2轴 不然没有右2这个概念的意义
  381. <el-radio-button
  382. v-if="[1,6].includes(chartInfo.ChartType)"
  383. :label="2"
  384. :disabled="(tableData.findIndex(_ => _.IsAxis===0) === -1)
  385. || (tableData.findIndex(_ => _.IsAxis===0) === props.$index
  386. && tableData.filter(_ => _.IsAxis===0).length === 1)"
  387. >t('Chart.Detail.rtwo_axis')}}</el-radio-button>
  388. </el-radio-group>
  389. </template>
  390. <div style="min-width: 250px">
  391. <el-radio
  392. v-model="props.row.EdbInfoType"
  393. :label="1"
  394. @change="getPreviewChartInfo"
  395. >{{$t('Chart.Detail.stand_lead')}}</el-radio
  396. >
  397. <div style="margin-top: 22px">
  398. <el-radio
  399. v-model="props.row.EdbInfoType"
  400. :label="0"
  401. style="margin-right: 10px"
  402. @change="getPreviewChartInfo"
  403. >{{$t('Chart.Detail.leading_lead')}}</el-radio
  404. >
  405. <template v-if="props.row.EdbInfoType === 0">
  406. {{$t('EtaChartAddPage.label_lead')}}
  407. <el-input
  408. style="width: 60px"
  409. size="mini"
  410. type="number"
  411. min="0"
  412. v-model="props.row.LeadValue"
  413. @change="getPreviewChartInfo"
  414. @keyup.native="filterCode(props.row)"
  415. ></el-input>
  416. <el-select
  417. v-model="props.row.LeadUnit"
  418. placeholder=""
  419. style="width: 60px"
  420. size="mini"
  421. @change="getPreviewChartInfo"
  422. >
  423. <el-option
  424. v-for="item in fre_options"
  425. :key="item"
  426. :label="item"
  427. :value="item"
  428. >
  429. </el-option>
  430. </el-select>
  431. </template>
  432. </div>
  433. </div>
  434. <div>
  435. <div style="display: flex">
  436. <span style="margin-right: 3px">{{$t('Chart.Detail.line_color')}}:</span>
  437. <el-color-picker
  438. v-model="props.row.ChartColor"
  439. size="mini"
  440. show-alpha
  441. :predefine="predefineColors"
  442. ></el-color-picker>
  443. </div>
  444. <div
  445. style="margin-top: 12px"
  446. v-if="chartInfo.ChartType === 1
  447. || (chartInfo.ChartType === 6 && props.row.ChartStyle==='spline')"
  448. >
  449. {{$t('Chart.Detail.line_size')}}:
  450. <el-input
  451. style="width: 60px"
  452. size="mini"
  453. type="number"
  454. :min="1"
  455. v-model="props.row.ChartWidth"
  456. />
  457. </div>
  458. </div>
  459. <div v-if="chartInfo.ChartType === 6">
  460. <span style="margin-right: 3px"><{{$t('Chart.label_create_sty')}}:</span>
  461. <el-select
  462. v-model="props.row.ChartStyle"
  463. placeholder="请选择生成样式"
  464. style="width: 50%"
  465. class="edb-item-style"
  466. >
  467. <el-option
  468. v-for="item in chartItemStyleArr"
  469. :key="item.key"
  470. :label="item.label"
  471. :value="item.value"
  472. >
  473. </el-option>
  474. </el-select>
  475. </div>
  476. <div class="copy-excel">
  477. <span class="editsty" @click="copyCode(props.row)" v-if="isAllowCopyData">
  478. <i class="el-icon-document-copy" />&nbsp;{{$t('Edb.detail_copydata_btn')}}</span
  479. >
  480. <span
  481. class="editsty" v-if="isAllowCheckData"
  482. @click="viewTarget(props.row)"
  483. style="display:block;margin-top:15px;"
  484. >&nbsp;{{$t('Edb.detail_lookdata_btn')}}</span>
  485. </div>
  486. </div>
  487. </template>
  488. </el-table-column> -->
  489. <el-table-column
  490. v-for="item in tableColums"
  491. :key="item.label"
  492. :label="item.label"
  493. :width="item.widthsty"
  494. :min-width="item.minwidthsty"
  495. align="center"
  496. >
  497. <template slot-scope="scope">
  498. <span v-if="item.key==='SourceName'">
  499. {{scope.row[item.key]}}
  500. <i
  501. class="el-icon-tickets"
  502. style="color:#409EFF;font-size:18px"
  503. @click="toHistoryPage(scope.row.EdbInfoId,$route.matched);lookEdbId=scope.row.EdbInfoId"
  504. v-if="scope.row.EdbType===2"
  505. />
  506. </span>
  507. <span v-else>{{ currentLang==='en' ? (scope.row[item.enKey]||scope.row[item.key]) : scope.row[item.key] }}</span>
  508. </template>
  509. </el-table-column>
  510. <el-table-column
  511. :label="$t('Table.column_operations')"
  512. key="Copy"
  513. align="center"
  514. width="110"
  515. >
  516. <template slot-scope="scope">
  517. <span class="editsty" @click="copyCode(scope.row)" v-if="isAllowCopyData">
  518. <i class="el-icon-document-copy" />&nbsp;<!-- 复制数据 -->{{$t('Edb.detail_copydata_btn')}}</span
  519. >
  520. <span v-if="isAllowCheckData"
  521. class="editsty"
  522. @click="viewTarget(scope.row)"
  523. ><!-- 查看数据 -->{{$t('Edb.detail_lookdata_btn')}}</span>
  524. </template>
  525. </el-table-column>
  526. <div slot="empty">
  527. <tableNoData :text="$t('Table.no_edb_msg')" size="mini"/>
  528. </div>
  529. </el-table>
  530. </div>
  531. </template>
  532. <img :src="drawImg" alt="" class="drawImg" />
  533. </el-dialog>
  534. <!-- 自定义时间段选择弹窗 -->
  535. <DateChooseDia
  536. :isDateDia="isDateDia"
  537. :dateForm="dateForm"
  538. @cancel="isDateDia = false"
  539. @dateBack="dataChangeBack"
  540. />
  541. <!-- 图表另存 -->
  542. <SaveChartOther
  543. :show.sync="isShowSaveOther"
  544. :data="chartInfo"
  545. :source="chartInfo.Source"
  546. />
  547. <!-- 输入英文指标弹窗 -->
  548. <set-en-name-dia
  549. :isOpenDialog="setEnName"
  550. @cancel="setEnName=false"
  551. @updateEnName="updateEnName"
  552. :formData="formItemArray"
  553. :chartType="chartInfo.ChartType"
  554. :datainfo="chartInfo.ChartType===10?JSON.parse(chartInfo.ExtraConfig):null"
  555. :edblist="chartInfo.ChartType===10?tableData:[]"
  556. />
  557. <!-- 指标历史记录 -->
  558. <!-- <edbHistoryDialog
  559. :isOpenDialog.sync="isLookHistory"
  560. :edbId="lookEdbId"
  561. /> -->
  562. </div>
  563. </template>
  564. <script>
  565. import { dataBaseInterface,mychartInterface } from '@/api/api.js';
  566. import futuresInterface from '@/api/modules/futuresBaseApi';
  567. import chartRelevanceApi from '@/api/modules/chartRelevanceApi';
  568. import { fittingEquationInterface,statisticFeatureInterface,crossVarietyInterface } from '@/api/modules/chartRelevanceApi';
  569. import {
  570. seasonOptions,
  571. copyOtherOptions
  572. } from '@/utils/defaultOptions';
  573. import Chart from '@/views/dataEntry_manage/components/chart';
  574. import SaveChartOther from '@/views/dataEntry_manage/components/SaveChartOther';
  575. import DateChooseDia from '@/views/dataEntry_manage/components/DateChooseDia';
  576. import changeLang from "@/views/dataEntry_manage/components/changeLang"
  577. import setEnNameDia from "@/views/dataEntry_manage/components/setEnNameDia"
  578. import { chartSetMixin } from '@/views/dataEntry_manage/mixins/chartPublic'
  579. import { copyFit } from '@/utils/svgToblob.js';
  580. export default {
  581. components: { Chart, DateChooseDia,SaveChartOther,changeLang,setEnNameDia },
  582. mixins: [ chartSetMixin],
  583. directives: {
  584. 'click-outside':{
  585. bind(el, binding) {
  586. const clickHandle = (e)=>{
  587. //console.log(e.target.className)
  588. //如果弹窗没打开就没必要执行了
  589. if(!(this&&this.isOpenDetail)) return
  590. const isCurrentTarget = el.contains(e.target)||e.target.className==='el-popover el-popper'||['shareLink','copy'].some(str => e.target.className.includes(str))
  591. if(isCurrentTarget){
  592. return false
  593. }
  594. if(binding.value && typeof binding.value === 'function'){
  595. //console.log('binding')
  596. binding.value(e)
  597. }
  598. }
  599. el.__click__outside = clickHandle
  600. document.addEventListener('click',clickHandle)
  601. },
  602. unbind(el,binding,vnode){
  603. document.removeEventListener('click',el.__click__outside)
  604. }
  605. },
  606. },
  607. props: {
  608. isOpenDetail: {
  609. type: Boolean,
  610. },
  611. chart_code: {
  612. type: String,
  613. },
  614. allChart: {
  615. type: Array,
  616. },
  617. select_classify: {
  618. type: Number
  619. },
  620. classifyUserId: {
  621. type: Number
  622. }
  623. },
  624. computed: {
  625. role() {
  626. let role = localStorage.getItem('Role') || '';
  627. if (['rai_researcher', 'ficc_researcher', 'researcher','ficc_seller','rai_seller','seller'].includes(role)) {
  628. return 'researcher';
  629. } else if (['rai_admin', 'ficc_admin'].includes(role)) {
  630. return 'admin';
  631. } else {
  632. return role;
  633. }
  634. },
  635. /* 登录角色id */
  636. roleId() {
  637. let id = parseInt(localStorage.getItem('AdminId'));
  638. return id;
  639. },
  640. /* 分享地址 */
  641. linkUrl() {
  642. const LINK_CHART_URL = this.$setting.dynamicOutLinks.ChartViewUrl+'/chartshow';
  643. return `${LINK_CHART_URL}?code=${this.chartInfo.UniqueCode}&fromType=share?&lang=${this.currentLang}`
  644. },
  645. //是否允许编辑上下限
  646. isAllowEditLimit(){
  647. return this.permissionBtn.isShowBtn('myETAPermission','myChart_editLimit')
  648. },
  649. //是否允许复制数据
  650. isAllowCopyData(){
  651. return this.permissionBtn.isShowBtn('myETAPermission','myChart_copyData')
  652. },
  653. //是否允许查看数据
  654. isAllowCheckData(){
  655. return this.permissionBtn.isShowBtn('myETAPermission','myChart_checkData')
  656. }
  657. },
  658. watch: {
  659. isOpenDetail(newval) {
  660. this.isNoChart = false;
  661. this.currentLang=this.$parent.chart_lang;
  662. this.formItemArray=[]
  663. newval && this.getChartDetail();
  664. this.resetShowPopConfirmMap()
  665. },
  666. tableData: {
  667. handler(newval) {
  668. newval.length && !this.chartInfo.WarnMsg && this.chartInfo.Source===1&& this.setChartOptionHandle(newval);
  669. },
  670. deep: true,
  671. },
  672. },
  673. data() {
  674. return {
  675. isNoChart: false, //删完最后一张图展示缺省
  676. refreshLoading: false,//loading
  677. showChart: false,
  678. chartInfo: {},
  679. dateTip: /* '请选择时间段' */ this.$t('Chart.choose_time'),
  680. season_year: [], //季节图时间段
  681. calendar_type: '', //公历农历选择项
  682. drawImg: '', //用于复制后的图标图片存储
  683. expandKey: [], //展开数组
  684. showPopConfirmMap:{
  685. '微信':false,
  686. 'office':false,
  687. 'url':false
  688. },
  689. hintText:/* '英文名称未输入完整,分享图表上可能出现空名称的情况,确定继续分享吗?' */this.$t('Chart.OptMsg.copy_noenough_en'),
  690. /* 查看历史弹窗 */
  691. isLookHistory: false,
  692. lookEdbId: 0
  693. };
  694. },
  695. methods: {
  696. // 配合修改英文信息 chartPublic.js ,防止没有getChartInfo()这个方法
  697. getChartInfo(){
  698. this.getChartDetail(this.chartInfo.UniqueCode)
  699. },
  700. /* 获取详情 */
  701. getChartDetail(code = '') {
  702. this.refreshLoading = true;
  703. dataBaseInterface
  704. .getChartByCode({
  705. UniqueCode: code || this.chart_code,
  706. })
  707. .then((res) => {
  708. this.refreshLoading = false;
  709. if (res.Ret !== 200) return;
  710. this.chartInfo = res.Data.ChartInfo;
  711. if(this.chartInfo.Source===1) {
  712. //处理下历史默认来源
  713. this.setDefaultSourceFrom();
  714. this.tableData = res.Data.EdbInfoList;
  715. //初始化上下限
  716. this.setLimitData(this.tableData)
  717. //eta图
  718. this.setDefaultDateSelect(); //设置默认的日期选中
  719. this.chartInfo.ChartType === 7 && this.initBarData(res.Data);
  720. //截面散点图
  721. this.chartInfo.ChartType === 10 && this.initSectionScatterData(res.Data);
  722. //雷达图
  723. this.chartInfo.ChartType === 11 && this.initRadarData(res.Data);
  724. }else if([2,5].includes(this.chartInfo.Source)) {
  725. this.tableData = [res.Data.EdbInfoList[0]];
  726. this.chartInfo = res.Data.ChartInfo.Source===5 ? {
  727. ...res.Data.ChartInfo,
  728. ProfitNameEn: res.Data.DataResp.ProfitNameEn,
  729. ProfitName: res.Data.DataResp.ProfitName,
  730. } : res.Data.ChartInfo;
  731. //商品价格图
  732. this.initCommodityData(res.Data);
  733. }else if([3].includes(this.chartInfo.Source)){//相关性 滚动相关性
  734. this.relevanceChartData={
  735. ChartInfo:res.Data.ChartInfo,
  736. EdbInfoList:res.Data.EdbInfoList,
  737. XEdbIdValue:res.Data.XEdbIdValue,
  738. CorrelationChartInfo:res.Data.CorrelationChartInfo,
  739. YDataList:[
  740. {
  741. Value: res.Data.YDataList[0].Value,
  742. Color:'#00f',
  743. Name:res.Data.ChartInfo.ChartName,
  744. NameEn:res.Data.ChartInfo.ChartNameEn
  745. }
  746. ]
  747. }
  748. this.initRelevanceChartData()
  749. this.tableData = res.Data.EdbInfoList
  750. }else if(this.chartInfo.Source===4) {//滚动相关性换成曲线图绘图
  751. this.tableData = res.Data.EdbInfoList
  752. this.relevanceChartData = {
  753. CorrelationChartInfo: res.Data.CorrelationChartInfo
  754. }
  755. this.setDefaultChart([res.Data.DataResp]);
  756. }else if([6,7,8].includes(this.chartInfo.Source)){//拟合方程 标准差 百分比
  757. this.tableData = res.Data.EdbInfoList;
  758. this.setDefaultChart([res.Data.DataResp]);
  759. }else if(this.chartInfo.Source===9) { //统计频率
  760. this.tableData = res.Data.EdbInfoList;
  761. this.statisticFrequencyData = res.Data.DataResp;
  762. this.setStatisticFrequency();
  763. }else if(this.chartInfo.Source===10) { //跨品种分析
  764. this.tableData = res.Data.EdbInfoList;
  765. this.crossVarietyChartData = res.Data.DataResp;
  766. /* 历史数据chartInfo里全是空 兼容下历史数据不崩 */
  767. this.chartLimit = {
  768. min: res.Data.ChartInfo.LeftMin?Number(res.Data.ChartInfo.LeftMin):Number(res.Data.DataResp.YMinValue),
  769. max: res.Data.ChartInfo.LeftMax?Number(res.Data.ChartInfo.LeftMax):Number(res.Data.DataResp.YMaxValue),
  770. x_min: res.Data.ChartInfo.XMin?Number(res.Data.ChartInfo.XMin):Number(res.Data.DataResp.XMinValue),
  771. x_max: res.Data.ChartInfo.XMax?Number(res.Data.ChartInfo.XMax):Number(res.Data.DataResp.XMaxValue),
  772. }
  773. this.setCrossVarietyChart();
  774. }
  775. });
  776. },
  777. /* 设置默认时间选中项 */
  778. setDefaultDateSelect() {
  779. this.year_select = this.chartInfo.DateType;
  780. this.count_year = this.chartInfo.StartYear;
  781. this.select_date = [this.chartInfo.StartDate, this.chartInfo.EndDate];
  782. this.calendar_type = this.chartInfo.Calendar; //日历类型
  783. if(this.chartInfo.ChartType==2){
  784. if(this.year_select==20){
  785. let latestYear = parseInt(this.tableData[0].LatestDate.substring(0,4))
  786. this.season_year=[`${latestYear-this.count_year+1}-01-01`,`${latestYear}-12-31`]
  787. }else if(this.year_select==6){
  788. this.season_year = [this.chartInfo.SeasonStartDate,this.tableData[0].LatestDate];
  789. }else{
  790. this.season_year = [this.chartInfo.SeasonStartDate,this.chartInfo.SeasonEndDate]
  791. }
  792. }
  793. this.dateTip =
  794. this.chartInfo.DateType === 5
  795. ? `${this.chartInfo.StartDate}~${this.chartInfo.EndDate}`
  796. : this.chartInfo.DateType === 6
  797. ? `${this.chartInfo.StartDate}~至今`
  798. : this.chartInfo.DateType === 20
  799. ?`最近${this.chartInfo.StartYear}年`
  800. :/* '请选择时间段' */ this.$t('Chart.choose_time');
  801. },
  802. /* 曲线图筛选项发生变化时 非配置项 获取新的图表数据 */
  803. async getPreviewChartInfo() {
  804. let dateArray=this.chartInfo.ChartType==2?this.season_year:this.select_date
  805. let params = {
  806. ChartType: this.chartInfo.ChartType,
  807. DateType: this.year_select,
  808. StartDate: [5 , 6].includes(this.year_select)
  809. ? dateArray[0]
  810. : '',
  811. EndDate: this.year_select === 5 ? dateArray[1] : '',
  812. Calendar: this.calendar_type,
  813. //ETA1.0.5 去除了这两个入参
  814. // SeasonStartDate: this.season_year ? this.season_year[0] : '',
  815. // SeasonEndDate: this.season_year ? this.season_year[1] : '',
  816. SeasonExtraConfig:this.SeasonExtraConfig,
  817. StartYear:this.count_year || 0,
  818. ChartEdbInfoList: this.tableData.map(_ => ({
  819. EdbInfoId: _.EdbInfoId,
  820. EdbInfoType: _.EdbInfoType,
  821. LeadValue: _.EdbInfoType ? 0 : Number(_.LeadValue),
  822. LeadUnit: _.EdbInfoType ? '' : _.LeadUnit,
  823. IsConvert:Number(_.IsConvert),
  824. ConvertType:Number(_.ConvertType),
  825. ConvertValue:Number(_.ConvertValue),
  826. ConvertUnit:Number(_.IsConvert)?_.ConvertUnit:'',
  827. ConvertEnUnit:Number(_.IsConvert)?_.ConvertEnUnit:''
  828. }))
  829. }
  830. const res = await dataBaseInterface.getSplinePreviewData(params)
  831. if(res.Ret !== 200) return
  832. const { EdbInfoList } = res.Data;
  833. this.tableData.forEach((item) => {
  834. let edbData = EdbInfoList.find(_ => _.EdbInfoId===item.EdbInfoId);
  835. item.DataList = edbData.DataList;
  836. //更新起始时间和最近更新时间
  837. item.StartDate = edbData.StartDate;
  838. item.ModifyTime = edbData.ModifyTime;
  839. if(edbData.EdbInfoCategoryType===1) item.MoveLatestDate = edbData.MoveLatestDate;
  840. });
  841. },
  842. /* 打开时间段弹窗 */
  843. openDateDia() {
  844. // 自定义时间段回显
  845. let selectDateStart = this.chartInfo.ChartType === 2?this.season_year[0]:this.select_date[0]
  846. let selectDateEnd = this.chartInfo.ChartType === 2?this.season_year[1]:this.select_date[1]
  847. this.dateForm = {
  848. date_type: this.year_select,
  849. start_date:
  850. this.year_select === 5 || this.year_select === 6
  851. ? selectDateStart
  852. : '',
  853. end_date: this.year_select === 5 ? selectDateEnd : '',
  854. count_year: this.year_select === 20 ? this.count_year : ''
  855. };
  856. this.isDateDia = true;
  857. },
  858. /* 保存完自定义日期 刷新数据 保存当前的图表配置和上下限 只改变图表*/
  859. dataChangeBack(data) {
  860. this.year_select = data.dateType;
  861. this.isDateDia = false;
  862. this.select_date = [data.start_date, data.end_date];
  863. this.count_year = data.count_year
  864. this.dateTip =
  865. data.dateType === 5
  866. ? `${data.start_date}~${data.end_date}`
  867. : data.dateType === 6
  868. ?`${data.start_date}~至今`
  869. :`最近${this.count_year}年`
  870. if(this.chartInfo.ChartType === 2){
  871. let latestYear = parseInt(this.tableData[0].LatestDate.substring(0,4))
  872. let dateStart = data.start_date
  873. let dateEnd = data.end_date
  874. if(data.dateType==20){
  875. dateStart = `${latestYear-this.count_year+1}-01-01`
  876. dateEnd = `${latestYear}-12-31`
  877. }else if(data.dateType==6){
  878. dateEnd = this.tableData[0].LatestDate
  879. }
  880. this.season_year = [dateStart, dateEnd];
  881. }
  882. this.getPreviewChartInfo();
  883. },
  884. /* 季节图切换年份 保持当前配置 */
  885. seasonYearChange() {
  886. this.getPreviewChartInfo();
  887. },
  888. /* 年份改变 重新刷新图表接口 保存当前的图表配置和上下限 只改变图表 */
  889. changeYear(item) {
  890. this.year_select = item.value;
  891. this.select_date = '';
  892. this.dateTip = /* '请选择时间段' */ this.$t('Chart.choose_time');
  893. this.getPreviewChartInfo();
  894. },
  895. /* 一键刷新 超长等待..*/
  896. async refreshHandle() {
  897. // 清除缓存配置项
  898. this.refreshLoading = true;
  899. const { Source,ChartInfoId,UniqueCode,ChartType } = this.chartInfo;
  900. let res=null
  901. if(Source===1){
  902. res= await dataBaseInterface.chartRefresh({ ChartInfoId })
  903. }else if([2,5].includes(Source)){
  904. res=await futuresInterface.refreshChart({ ChartInfoId })
  905. }else if([3,4].includes(Source)){
  906. res=await chartRelevanceApi.refreshChart({ ChartInfoId })
  907. }else if(Source===6){
  908. res=await fittingEquationInterface.refreshChart({ ChartInfoId })
  909. }else if([7,8,9].includes(Source)) {
  910. res=await statisticFeatureInterface.refreshChart({ ChartInfoId })
  911. }else if(Source===10) {
  912. res=await crossVarietyInterface.refreshChart({ ChartInfoId })
  913. }
  914. this.refreshLoading = false;
  915. if (res.Ret !== 200) return
  916. this.$message.success(res.Msg);
  917. Source===1&&![7,10,11].includes(ChartType)
  918. ? this.getPreviewChartInfo()
  919. : this.getChartDetail(UniqueCode);
  920. },
  921. // 英文面板时候的判断
  922. copyChartConfirm(type){
  923. if(this.currentLang=='en'){
  924. // 是否所有数据都填写完
  925. let flag=true
  926. // 是否有英文表格名称
  927. if(!this.chartInfo.ChartNameEn) flag = false
  928. if(flag&&this.chartInfo.Source!=3){
  929. for (const data of this.tableData) {
  930. if(data.EdbNameEn=="" ||data.UnitEn==""){
  931. flag = false
  932. break
  933. }
  934. }
  935. }
  936. if(!flag){
  937. //用Popconfirm替代confirm confirm嵌套:append-to-body="false"的弹窗会有遮罩问题
  938. this.resetShowPopConfirmMap()
  939. this.$set(this.showPopConfirmMap,type,true)
  940. /* this.$confirm('英文名称未输入完整,分享图表上可能出现空名称的情况,确定继续分享吗?', '提示', {
  941. confirmButtonText: '确定',
  942. cancelButtonText: '取消',
  943. type: 'warning',
  944. })
  945. .then(() => {
  946. if(type==='url'){
  947. // this.shareUrl()
  948. const input = document.createElement('input')
  949. input.setAttribute('readonly','readonly')
  950. input.value = this.linkUrl
  951. document.body.appendChild(input)
  952. input.select();
  953. document.execCommand('copy');
  954. document.body.removeChild(input);
  955. this.$message.success('复制链接成功')
  956. }else{
  957. this.copyChartHandle(type)
  958. }
  959. $('body .v-modal').remove()
  960. $('#right > div > div:nth-child(4)').append('<div class="v-modal" tabindex="0"></div>')
  961. })
  962. .catch(() => {
  963. $('body .v-modal').remove()
  964. $('#right > div > div:nth-child(4)').append('<div class="v-modal" tabindex="0"></div>')
  965. }); */
  966. }else{
  967. this.$set(this.showPopConfirmMap,type,false)
  968. if(type=='url'){
  969. this.shareUrl()
  970. }else{
  971. this.copyChartHandle(type)
  972. }
  973. }
  974. }else{
  975. if(type=='url'){
  976. this.shareUrl()
  977. }else{
  978. this.copyChartHandle(type)
  979. }
  980. }
  981. },
  982. copyChart(type){
  983. console.log('复制的是:',type)
  984. if(type==='url'){
  985. const input = document.createElement('input')
  986. input.setAttribute('readonly','readonly')
  987. input.value = this.linkUrl
  988. document.body.appendChild(input)
  989. input.select();
  990. document.execCommand('copy');
  991. document.body.removeChild(input);
  992. // this.$message.success('复制链接成功')
  993. this.$message.success(this.$t('Chart.OptMsg.copy_link_success'))
  994. }else{
  995. this.copyChartHandle(type)
  996. }
  997. this.closePop(type)
  998. },
  999. closePop(type){
  1000. this.$set(this.showPopConfirmMap,type,false)
  1001. },
  1002. resetShowPopConfirmMap(){
  1003. this.showPopConfirmMap={
  1004. '微信':false,
  1005. 'office':false,
  1006. 'url':false
  1007. }
  1008. },
  1009. /* 点击复制先用canvas画出 转成图片在放到粘贴板中 */
  1010. copyChartHandle:_.debounce(function(type){
  1011. let chartsName = this.currentLang=='ch'?this.chartInfo.ChartName:this.chartInfo.ChartNameEn
  1012. let { heightNum, widthNum , newTitle , dynamic_copyOptions} = this.dynamicWidthAndHeight(type,this.chartInfo.ChartType,chartsName, this.chartInfo.Source === 1?this.tableData.length:this.commodityChartData.length)
  1013. const chartType = this.sameOptionType.includes(this.chartInfo.ChartType) ? 'legend' : 'seasonLegend';
  1014. // 英文转SVG设置变动
  1015. if(this.currentLang == 'en'){
  1016. // 散点图 如果横轴单位为'英文单位',表示客户没填,转成svg时置为空
  1017. if(this.chartInfo.ChartType == 5){
  1018. this.$refs.chartRef.chart.options.xAxis.forEach(it => {
  1019. if(it.title.text == '英文单位') it.title.text=''
  1020. });
  1021. }
  1022. // 如果竖轴坐标单位为'英文单位',表示客户没填,转成svg时置为空
  1023. this.$refs.chartRef.chart.options.yAxis.forEach(it => {
  1024. if(it.title.text == '英文单位') it.title.text=''
  1025. });
  1026. }
  1027. let svgObj={
  1028. chart:{
  1029. width:widthNum,
  1030. height:heightNum,
  1031. backgroundColor:"rgba(255, 255, 255, 0)",
  1032. },
  1033. title: {
  1034. text: newTitle,
  1035. margin: 10,
  1036. style: {
  1037. fontSize: '18px'
  1038. }
  1039. },
  1040. legend:{
  1041. ...copyOtherOptions[chartType],
  1042. ...dynamic_copyOptions[chartType]
  1043. },
  1044. }
  1045. let svg = this.$refs.chartRef.chart.getSVG(svgObj);
  1046. this.copyBlobItem(widthNum,heightNum,svg,type);
  1047. },500),
  1048. // 选择
  1049. getSelect(targetNode) {
  1050. if (window.getSelection) {
  1051. //chrome等主流浏览器
  1052. var selection = window.getSelection();
  1053. var range = document.createRange();
  1054. range.selectNode(targetNode);
  1055. selection.removeAllRanges();
  1056. selection.addRange(range);
  1057. } else if (document.body.createTextRange) {
  1058. //ie
  1059. var range = document.body.createTextRange();
  1060. range.moveToElementText(targetNode);
  1061. range.select();
  1062. }
  1063. },
  1064. /* 图表保存 分配 */
  1065. saveChartMapHandle() {
  1066. const sourceMap = {
  1067. 1: this.saveChartHandle,
  1068. 2: this.saveCommodityChart,
  1069. 5: this.saveCommodityChart,//利润曲线
  1070. 10: this.saveCrossVarietyChart
  1071. }
  1072. sourceMap[this.chartInfo.Source]&&sourceMap[this.chartInfo.Source]();
  1073. },
  1074. /* 商品价格图保存 */
  1075. saveCommodityChart: _.debounce(async function() {
  1076. const { Ret } = await futuresInterface.chartSave({
  1077. ChartInfoId: this.chartInfo.ChartInfoId,
  1078. LeftMin: String(this.chartLimit.min),
  1079. LeftMax: String(this.chartLimit.max),
  1080. })
  1081. if(Ret!==200) return
  1082. // this.$message.success('保存成功');
  1083. this.$message.success(this.$t('MsgPrompt.saved_msg'));
  1084. //关联图表和图片
  1085. this.setChartImage();
  1086. },300),
  1087. saveCrossVarietyChart: _.debounce(async function() {
  1088. let { min,max,x_min,x_max } = this.chartLimit;
  1089. let params = {
  1090. ChartInfoId: this.chartInfo.ChartInfoId,
  1091. XMin: String(x_min),
  1092. XMax: String(x_max),
  1093. LeftMin: String(min),
  1094. LeftMax: String(max),
  1095. }
  1096. let res = await crossVarietyInterface.saveChart(params);
  1097. if(res.Ret !== 200) return
  1098. this.$message.success('保存成功')
  1099. //关联图表和图片
  1100. this.setChartImage();
  1101. },300),
  1102. /* 保存当前图表配置 */
  1103. saveChartHandle: _.debounce(function () {
  1104. //遍历每条线的指标配置
  1105. let arr = this.tableData.map((item) => {
  1106. return {
  1107. ChartColor: item.ChartColor,
  1108. ChartStyle: item.ChartStyle,
  1109. ChartWidth: Number(item.ChartWidth),
  1110. EdbInfoId: item.EdbInfoId,
  1111. EdbInfoType: item.EdbInfoType,
  1112. IsAxis: item.IsAxis,
  1113. IsOrder: item.IsOrder,
  1114. LeadUnit: item.EdbInfoType ? '' : item.LeadUnit,
  1115. LeadValue: item.EdbInfoType ? 0 : Number(item.LeadValue),
  1116. MaxData: Number(item.MaxData),
  1117. MinData: Number(item.MinData),
  1118. };
  1119. });
  1120. let public_param = {
  1121. ChartInfoId: this.chartInfo.ChartInfoId || 0,
  1122. ChartEdbInfoList: arr,
  1123. }
  1124. let typeChartParam = {};
  1125. switch(this.chartInfo.ChartType) {
  1126. case 2:
  1127. typeChartParam = {
  1128. ...public_param,
  1129. Calendar: this.calendar_type,
  1130. DateType: this.year_select,
  1131. StartYear:this.count_year || 0,
  1132. StartDate: this.season_year ? this.season_year[0] : '',
  1133. EndDate: this.season_year ? this.season_year[1] : '',
  1134. }
  1135. break
  1136. case 7:
  1137. case 11:
  1138. typeChartParam = {
  1139. ...public_param,
  1140. DateType: 6,
  1141. LeftMin: String(this.chartLimit.min),
  1142. LeftMax: String(this.chartLimit.max),
  1143. }
  1144. break
  1145. case 10:
  1146. typeChartParam = {
  1147. ...public_param,
  1148. DateType: 6,
  1149. Calendar: "公历",
  1150. ExtraConfig: JSON.stringify({
  1151. ...JSON.parse(this.chartInfo.ExtraConfig),
  1152. XMinValue: String(this.chartLimit.x_min),
  1153. XMaxValue: String(this.chartLimit.x_max),
  1154. YMinValue: String(this.chartLimit.min),
  1155. YMaxValue: String(this.chartLimit.max),
  1156. })
  1157. }
  1158. break
  1159. }
  1160. let params = this.sameOptionType.includes(this.chartInfo.ChartType)
  1161. ? {
  1162. ...public_param,
  1163. DateType: this.year_select,
  1164. StartYear:this.count_year || 0,
  1165. StartDate:
  1166. this.year_select === 5 || this.year_select === 6
  1167. ? this.select_date[0]
  1168. : '',
  1169. EndDate: this.year_select === 5 ? this.select_date[1] : '',
  1170. }
  1171. : typeChartParam;
  1172. if(![7,10,11].includes(this.selected_chartType)){
  1173. const {
  1174. min,max,rightMin,rightMax,rightTwoMin,rightTwoMax
  1175. } = this.chartLimit
  1176. params = {
  1177. ...params,
  1178. LeftMin:min+'',
  1179. LeftMax:max+'',
  1180. RightMin:rightMin+'',
  1181. RightMax:rightMax+'',
  1182. Right2Min:rightTwoMin+'',
  1183. Right2Max:rightTwoMax+'',
  1184. //手动保存视为更改过上下限
  1185. MinMaxSave:1
  1186. }
  1187. }
  1188. dataBaseInterface.chartSave(params).then((res) => {
  1189. if (res.Ret === 200) {
  1190. // this.$message.success('保存成功');
  1191. this.$message.success(this.$t('MsgPrompt.saved_msg'));
  1192. sessionStorage.removeItem('myChartbeforeOptions');
  1193. //关联图表和图片
  1194. this.setChartImage();
  1195. }
  1196. });
  1197. }, 500),
  1198. /* 删除图表 */
  1199. delChartHandle() {
  1200. this.delHandle(this.chartInfo.ChartInfoId);
  1201. },
  1202. /* 删除方法 */
  1203. delHandle(ChartInfoId) {
  1204. dataBaseInterface
  1205. .delChartClassify({
  1206. ChartInfoId,
  1207. })
  1208. .then((res) => {
  1209. if (res.Ret !== 200) return;
  1210. this.$message.success(res.Msg);
  1211. sessionStorage.removeItem('myChartbeforeOptions');
  1212. let index = this.allChart.findIndex(
  1213. (item) => item === this.chartInfo.UniqueCode
  1214. );
  1215. this.$emit('remove',this.chartInfo.UniqueCode);
  1216. const newId = index > this.allChart.length - 1 ? this.allChart[0] : this.allChart[index];
  1217. if(this.allChart.length >= 1) this.getChartDetail(newId);
  1218. // //只有一个图表且删除了 则展示缺省
  1219. this.isNoChart = !this.allChart.length ? true : false;
  1220. });
  1221. },
  1222. /* 转base64 */
  1223. svgToBase64(svg) {
  1224. const base64img = `data:image/svg+xml;base64,${window.btoa(
  1225. unescape(encodeURI(svg))
  1226. )}`;
  1227. // console.log(base64img)
  1228. return base64img;
  1229. },
  1230. /* 点击保存时关联图表和截取的图片 */
  1231. setChartImage() {
  1232. let svg = this.$refs.chartRef.chart.getSVG({
  1233. chart:{
  1234. width: 340,
  1235. height: 230,
  1236. }
  1237. });
  1238. let form = new FormData();
  1239. form.append('Img', svg);
  1240. this.setImageHandle(form);
  1241. },
  1242. async setImageHandle(form) {
  1243. let { Data } = await dataBaseInterface.uploadImgSvg(form);
  1244. // let { Data } = await dataBaseInterface.uploadImg(form);
  1245. await dataBaseInterface.setChartImage({
  1246. ChartInfoId: this.chartInfo.ChartInfoId,
  1247. ImageUrl: Data.ResourceUrl,
  1248. });
  1249. },
  1250. /* 点击表格行展开配置项 */
  1251. rowClickHandle(row) {
  1252. this.expandKey =
  1253. this.expandKey.length && this.expandKey[0] === row.EdbCode
  1254. ? []
  1255. : [row.EdbCode];
  1256. // this.$refs.tableRef.toggleRowExpansion(row);
  1257. //曲线图点击行 自动置底
  1258. if (this.sameOptionType.includes(this.chartInfo.ChartType)) {
  1259. this.$nextTick(() => {
  1260. $('.cont-bottom')[0].scrollTop = 10000;
  1261. });
  1262. }
  1263. },
  1264. /* 设置row-key */
  1265. getRowKey(row) {
  1266. return row.EdbCode;
  1267. },
  1268. /* 控制展开一行收起其他行并高亮 */
  1269. expandChangeHandle(row, expandedRows) {
  1270. this.expandKey =
  1271. this.expandKey.length && this.expandKey[0] === row.EdbCode
  1272. ? []
  1273. : [row.EdbCode];
  1274. //曲线图点击行 自动置底
  1275. if (this.selected_chartType === 1) {
  1276. this.$nextTick(() => {
  1277. $('.cont-bottom')[0].scrollTop = 10000;
  1278. });
  1279. }
  1280. this.$refs.tableRef.setCurrentRow(row);
  1281. },
  1282. /* 移出我的图库 */
  1283. removeMychart(item) {
  1284. if (!this.select_classify)
  1285. return this.$message.warning(
  1286. '当前图表所属多个分类,请选中具体分类移出'
  1287. );
  1288. mychartInterface.del({ MyChartId: item.MyChartId,MyChartClassifyId: this.select_classify }).then((res) => {
  1289. if (res.Ret !== 200) return;
  1290. this.$message.success(/* '移出成功' */this.$t('MsgPrompt.move_out_msg'));
  1291. item.IsAdd = false;
  1292. sessionStorage.removeItem('myChartbeforeOptions');
  1293. let index = this.allChart.findIndex(
  1294. (item) => item === this.chartInfo.UniqueCode
  1295. );
  1296. this.$emit('remove',item.UniqueCode);
  1297. const newId = index > this.allChart.length - 1 ? this.allChart[0] : this.allChart[index];
  1298. if(this.allChart.length >= 1) this.getChartDetail(newId);
  1299. // //只有一个图表且删除了 则展示缺省
  1300. this.isNoChart = !this.allChart.length ? true : false;
  1301. });
  1302. },
  1303. /* 上下切换图表 同一分类内 */
  1304. switchChart(type) {
  1305. //判断当前图表在列表中的index pre时为0去最后一个 next时为最后一个取0
  1306. this.formItemArray=[]
  1307. let index = this.allChart.findIndex(
  1308. (item) => item === this.chartInfo.UniqueCode
  1309. );
  1310. let newCode = '';
  1311. if (type === 'prev') {
  1312. newCode =
  1313. index === 0
  1314. ? this.allChart[this.allChart.length - 1]
  1315. : this.allChart[index - 1];
  1316. } else {
  1317. newCode =
  1318. index === this.allChart.length - 1
  1319. ? this.allChart[0]
  1320. : this.allChart[index + 1];
  1321. }
  1322. sessionStorage.removeItem('myChartbeforeOptions');
  1323. this.getChartDetail(newCode);
  1324. this.resetShowPopConfirmMap()
  1325. },
  1326. /* 编辑图表 */
  1327. editChartHandle() {
  1328. let path = '';
  1329. if(this.chartInfo.Source === 1){
  1330. path='/editchart'
  1331. }else if([2,5].includes(this.chartInfo.Source)){
  1332. path='/addCommodityChart'
  1333. }else if([3,4].includes(this.chartInfo.Source)){
  1334. path='/relevancechartEditor'
  1335. }else if(this.chartInfo.Source===6){
  1336. path='/fittingEquationChartEditor'
  1337. }else if([7,8,9].includes(this.chartInfo.Source)) {
  1338. path='/statisticFeatureChartEditor'
  1339. }else if(this.chartInfo.Source===10) {
  1340. path='/crossVarietyChartEditor'
  1341. }
  1342. let { href } = this.$router.resolve({
  1343. path,
  1344. query: {
  1345. code: this.chartInfo.UniqueCode,
  1346. from: 'mychart'
  1347. }
  1348. })
  1349. window.open(href,'_blank');
  1350. },
  1351. /* 分享图表链接 */
  1352. shareUrl() {
  1353. var clipboard = new this.Clipboard('.shareLink')
  1354. clipboard.on('success', e => {
  1355. // this.$message.success('复制链接成功')
  1356. this.$message.success(this.$t('Chart.OptMsg.copy_link_success'))
  1357. e.clearSelection() // 释放内存
  1358. clipboard.destroy()
  1359. })
  1360. // // 浏览器不支持
  1361. clipboard.on('error', e => {
  1362. // this.$message.warning('浏览器暂不支持')
  1363. this.$message.warning(this.$t('MsgPrompt.browser_not_support'))
  1364. // 释放内存
  1365. clipboard.destroy()
  1366. })
  1367. },
  1368. copyTitleText() {
  1369. /* let clipboard = new this.Clipboard('.my-chart-title')
  1370. clipboard.on('success', e => {
  1371. this.$message.success('复制标题成功')
  1372. e.clearSelection() // 释放内存
  1373. clipboard.destroy()
  1374. })
  1375. // // 浏览器不支持
  1376. clipboard.on('error', e => {
  1377. this.$message.warning('浏览器暂不支持')
  1378. // 释放内存
  1379. clipboard.destroy()
  1380. }) */
  1381. try{
  1382. copyFit(this.chartInfo.ChartName||'')
  1383. // this.$message.success("复制标题成功")
  1384. this.$message.success(this.$t('Chart.OptMsg.copy_tit_success'))
  1385. }catch(e){
  1386. // this.$message.warning("复制标题失败")
  1387. this.$message.warning(this.$t('Chart.OptMsg.copy_tit_fail'))
  1388. }
  1389. },
  1390. init() {
  1391. this.dateTip = /* '请选择时间段' */ this.$t('Chart.choose_time');
  1392. sessionStorage.removeItem('myChartbeforeOptions');
  1393. },
  1394. close() {
  1395. this.init();
  1396. this.$emit('close');
  1397. $('#right > div > div:nth-child(4) .v-modal').remove()
  1398. },
  1399. },
  1400. created() {},
  1401. mounted() {},
  1402. };
  1403. </script>
  1404. <style lang="scss">
  1405. .chart-detail-container {
  1406. min-width: 1200px;
  1407. $font_normal: 14px;
  1408. $font_mini: 12px;
  1409. $normal_height: 650px;
  1410. $mini_height: 550px;
  1411. .date-setting{
  1412. border: 1px solid #DCDFE6;
  1413. border-radius: 4px;
  1414. cursor: pointer;
  1415. color: #333333;
  1416. line-height: 16px;
  1417. }
  1418. @media screen and (max-width: 1710px) {
  1419. /* transform: scale(0.8);
  1420. left: 10%;
  1421. top: 5%; */
  1422. .year-btn {
  1423. padding: 8px 20px;
  1424. }
  1425. .year-btn,.btn-sty,.top-right {
  1426. font-size: $font_mini;
  1427. }
  1428. .el-icon-refresh {
  1429. font-size: 14px;
  1430. }
  1431. .el-table {
  1432. font-size: $font_mini;
  1433. td,th {
  1434. padding: 8px 0;
  1435. }
  1436. .el-table__expanded-cell {
  1437. padding: 10px 15px;
  1438. }
  1439. }
  1440. .cont-bottom,.nodata {
  1441. height: $mini_height;
  1442. }
  1443. .min-data-input {
  1444. margin-top: 220px;
  1445. }
  1446. .btn-sty {
  1447. padding: 8px;
  1448. }
  1449. .date-setting{
  1450. width: 180px;
  1451. padding: 10px;
  1452. font-size: 12px;
  1453. }
  1454. }
  1455. @media screen and (min-width: 1711px) {
  1456. .year-btn,.btn-sty,.top-right {
  1457. font-size: $font_normal;
  1458. }
  1459. .cont-bottom,.nodata {
  1460. height: $normal_height;
  1461. }
  1462. .min-data-input {
  1463. margin-top: 308px;
  1464. }
  1465. .btn-sty {
  1466. padding: 10px;
  1467. }
  1468. .date-setting{
  1469. width: 210px;
  1470. padding: 10px;
  1471. border: 1px solid #DCDFE6;
  1472. border-radius: 4px;
  1473. cursor: pointer;
  1474. font-size: 14px;
  1475. color: #333333;
  1476. }
  1477. .el-table__expanded-cell {
  1478. padding: 20px 26px;
  1479. }
  1480. }
  1481. .el-dialog__body {
  1482. padding: 10px 0 20px;
  1483. }
  1484. .nodata {
  1485. text-align: center;
  1486. padding: 40px 0;
  1487. color: #999;
  1488. }
  1489. .my-chart-title:hover {
  1490. text-decoration: underline;
  1491. }
  1492. .header {
  1493. padding: 0 30px 0;
  1494. position: relative;
  1495. display: flex;
  1496. align-items: center;
  1497. justify-content: space-between;
  1498. .close {
  1499. font-size: 26px;
  1500. position: absolute;
  1501. right: 0;
  1502. top: 50%;
  1503. transform: translateY(-50%);
  1504. cursor: pointer;
  1505. }
  1506. .top-left {
  1507. .year-btn {
  1508. min-width: 98px;
  1509. margin-right: 5px;
  1510. margin-bottom: 5px;
  1511. }
  1512. .btn-sty {
  1513. border: 1px solid #409eff;
  1514. }
  1515. }
  1516. .top-right {
  1517. .join_txt {
  1518. color: #409eff;
  1519. cursor: pointer;
  1520. &:hover {
  1521. text-decoration: underline;
  1522. }
  1523. }
  1524. .collected {
  1525. color: #f00;
  1526. cursor: pointer;
  1527. &:hover {
  1528. text-decoration: underline;
  1529. }
  1530. }
  1531. .span-item {
  1532. color: #409eff;
  1533. cursor: pointer;
  1534. &:hover {
  1535. text-decoration: underline;
  1536. }
  1537. .el-icon-collection,
  1538. .el-icon-document-copy {
  1539. color: #409eff;
  1540. }
  1541. }
  1542. }
  1543. }
  1544. .cont-bottom {
  1545. padding: 10px 30px 30px;
  1546. overflow: auto;
  1547. .error-tip{ color: #D03F28; font-size: 16px;padding: 25px 0 0 25px; }
  1548. .el-input__inner {
  1549. height: 27px;
  1550. line-height: 27px;
  1551. padding: 0 4px;
  1552. }
  1553. .el-input-number .el-input__inner {
  1554. padding: 0 34px 0 4px;
  1555. }
  1556. .el-color-picker--mini .el-color-picker__trigger {
  1557. width: 60px;
  1558. height: 25px;
  1559. padding: 0;
  1560. }
  1561. .el-color-picker--mini .el-color-picker__mask {
  1562. width: 60px;
  1563. height: 25px;
  1564. }
  1565. .highcharts-range-selector-group {
  1566. display: none;
  1567. .highcharts-input-group {
  1568. display: none;
  1569. }
  1570. }
  1571. .highcharts-axis-title {
  1572. display: block;
  1573. }
  1574. .calendar-cont {
  1575. display: block;
  1576. margin: 10px auto 0;
  1577. text-align: center;
  1578. }
  1579. /* =================== */
  1580. .chart-show-cont {
  1581. /* margin-bottom: 15px; */
  1582. padding: 0 180px 10px 150px;
  1583. position: relative;
  1584. .chart-title {
  1585. font-size: 16px;
  1586. font-weight: normal;
  1587. text-align: center;
  1588. margin-bottom: 10px;
  1589. }
  1590. .chart-author {
  1591. color: #333;
  1592. position: absolute;
  1593. bottom: 10px;
  1594. right: 38px;
  1595. }
  1596. .chartWrapper {
  1597. position: relative;
  1598. min-height: 300px;
  1599. .range-cont {
  1600. position: absolute;
  1601. top: 10%;
  1602. .min-data-input {
  1603. width: 60px;
  1604. display: block;
  1605. }
  1606. &.left {
  1607. left: -80px;
  1608. }
  1609. &.right {
  1610. right: -65px;
  1611. }
  1612. &.rightTwo {
  1613. right: -140px;
  1614. }
  1615. &.bottom {
  1616. width: 100%;
  1617. display: flex;
  1618. justify-content: space-between;
  1619. top: auto;
  1620. right: 0;
  1621. bottom: -1%;
  1622. .left {
  1623. width: 60px;
  1624. display: block;
  1625. flex-shrink: 0;
  1626. }
  1627. }
  1628. }
  1629. .arrow {
  1630. width: 38px;
  1631. height: 38px;
  1632. position: absolute;
  1633. color: #999;
  1634. top: 50%;
  1635. transform: translateY(-50%);
  1636. cursor: pointer;
  1637. &:hover {
  1638. opacity: 0.7;
  1639. }
  1640. &.left {
  1641. left: -150px;
  1642. }
  1643. &.right {
  1644. right: -180px;
  1645. }
  1646. }
  1647. }
  1648. }
  1649. .options-cont {
  1650. display: flex;
  1651. flex-wrap: wrap;
  1652. justify-content: space-between;
  1653. }
  1654. }
  1655. .drawImg {
  1656. position: absolute;
  1657. top: -999px;
  1658. z-index: -100;
  1659. }
  1660. }
  1661. </style>
  1662. <style lang="scss">
  1663. .el-dialog .el-dialog__header {
  1664. padding: 15px 40px 15px 25px;
  1665. }
  1666. .edb-item-style .el-input__icon {
  1667. line-height: 27px;
  1668. }
  1669. </style>