sectionalCombinationOption.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500
  1. <template>
  2. <div class="sectionalCombination-option-wrap">
  3. <div class="sort-wrap">
  4. <div>
  5. <el-tooltip
  6. effect="dark"
  7. :content="$t('EtaChartAddPage.sort_tips')"
  8. placement="top-start"
  9. >
  10. <span>
  11. <span>{{ $t('EtaChartAddPage.label_sort_rule')}}</span>
  12. <i class="el-icon-info"></i>
  13. </span>
  14. </el-tooltip>
  15. <el-radio-group v-model="sortType" style="margin-left: 20px" @change="handleGetChartData">
  16. <el-radio :label="0">{{$t('EtaBasePage.default_select_text')}}</el-radio>
  17. <el-radio :label="1">{{$t('EtaChartAddPage.option_sort_up')}}</el-radio>
  18. <el-radio :label="2">{{$t('EtaChartAddPage.option_sort_low')}}</el-radio>
  19. </el-radio-group>
  20. </div>
  21. <el-select
  22. class="select-box"
  23. v-model="sortBasisEdb"
  24. :placeholder="$t('EtaChartAddPage.select_base_placehold')"
  25. @change="handleGetChartData"
  26. >
  27. <el-option
  28. v-for="item in seriesData"
  29. :key="item.seriesName"
  30. :label="item.seriesName"
  31. :value="item.seriesName"
  32. >
  33. </el-option>
  34. </el-select>
  35. </div>
  36. <div class="date-set-wrap">
  37. <span @click="handleShowRefrenceDate">{{$t('EtaChartAddPage.reference_date_set')}}</span>
  38. <span @click="handleShowAxis">{{$t('EtaChartAddPage.axis_set')}}</span>
  39. </div>
  40. <!-- 系列数据模块 -->
  41. <div class="series-data-wrap" v-if="seriesData.length">
  42. <el-collapse class="series-list">
  43. <el-collapse-item v-for="(item, index) in seriesData" :key="index">
  44. <template slot="title">
  45. <span class="text_oneLine" @click.stop="handleShowEditSeries(index)">{{
  46. currentLang === "en"?item.seriesNameEn||item.seriesName:item.seriesName
  47. }}</span>
  48. <img class="copy-icon" src="~@/assets/img/icons/copy-active.png" alt="" @click.stop="copySeries(item)">
  49. <i
  50. class="el-icon-delete del-icon"
  51. @click.stop="handleDelSeries(item,index)"
  52. ></i>
  53. </template>
  54. <ul class="set-box">
  55. <li>
  56. <el-radio-group
  57. v-model="item.IsAxis"
  58. size="mini"
  59. @input="handleChartUpdate('isAxis')"
  60. >
  61. <el-radio-button :label="1"
  62. ><!-- 左轴 -->{{ $t("Chart.Detail.l_axis") }}</el-radio-button
  63. >
  64. <el-radio-button :label="0"
  65. ><!-- 右轴 -->{{ $t("Chart.Detail.r_axis") }}</el-radio-button
  66. >
  67. <!-- 指标有右轴时才可以选右2轴 不然没有右2这个概念的意义 -->
  68. <el-radio-button
  69. :label="2"
  70. :disabled="
  71. seriesData.findIndex((_) => _.IsAxis === 0) === -1 ||
  72. (seriesData.findIndex((_) => _.IsAxis === 0) === index &&
  73. seriesData.filter((_) => _.IsAxis === 0).length === 1)
  74. "
  75. ><!-- 右2轴 -->{{
  76. $t("Chart.Detail.rtwo_axis")
  77. }}</el-radio-button
  78. >
  79. </el-radio-group>
  80. </li>
  81. <li>
  82. <div style="display: flex">
  83. <span style="margin-right: 3px"
  84. ><!-- 生成样式 -->{{ $t("Chart.label_create_sty") }}:</span
  85. >
  86. <el-select
  87. v-model="item.seriesChartType"
  88. placeholder="请选择生成样式"
  89. style="width: 50%"
  90. class="edb-item-style"
  91. @change="handleChartUpdate('chartType')"
  92. >
  93. <el-option
  94. v-for="item in chartItemStyleArr"
  95. :key="item.key"
  96. :label="item.label"
  97. :value="item.value"
  98. >
  99. </el-option>
  100. </el-select>
  101. </div>
  102. </li>
  103. <!-- 数据点展示 -->
  104. <li>
  105. <div style="display: flex; align-items: center" v-if="item.seriesChartType!='column'">
  106. <span>{{$t('EtaChartAddPage.show_data_point')}}</span>
  107. <el-tooltip
  108. :content="$t('EtaChartAddPage.show_data_point_tips')"
  109. placement="top"
  110. >
  111. <i class="el-icon-info"></i>
  112. </el-tooltip>
  113. <el-switch
  114. style="margin-left: 20px"
  115. v-model="item.showDataPoint"
  116. @change="handleChartUpdate('dataPoint')"
  117. >
  118. </el-switch>
  119. </div>
  120. </li>
  121. <!-- 数值展示 -->
  122. <li>
  123. <div style="display: flex; align-items: center">
  124. <span>{{$t('EtaChartAddPage.show_data_value')}}</span>
  125. <el-tooltip :content="$t('EtaChartAddPage.show_data_value_tips')" placement="top">
  126. <i class="el-icon-info"></i>
  127. </el-tooltip>
  128. <el-switch
  129. style="margin-left: 33px"
  130. v-model="item.showDataValue"
  131. @change="handleChartUpdate('dataValue')"
  132. >
  133. </el-switch>
  134. </div>
  135. </li>
  136. <li>
  137. <div style="display: flex">
  138. <span style="margin-right: 3px"
  139. ><!-- 线条颜色 -->{{ $t("Chart.Detail.line_color") }}:</span
  140. >
  141. <el-color-picker
  142. v-model="item.ChartColor"
  143. size="mini"
  144. show-alpha
  145. :predefine="predefineColors"
  146. @change="handleChartUpdate('ChartColor')"
  147. ></el-color-picker>
  148. </div>
  149. <div style="margin-top: 12px" v-if="item.seriesChartType!='column'">
  150. <!-- 线条粗细 -->{{ $t("Chart.Detail.line_size") }}:
  151. <el-input
  152. style="width: 60px"
  153. size="mini"
  154. type="number"
  155. :min="1"
  156. v-model="item.ChartWidth"
  157. @change="handleChartUpdate('ChartWidth')"
  158. />
  159. </div>
  160. </li>
  161. </ul>
  162. </el-collapse-item>
  163. </el-collapse>
  164. </div>
  165. <div class="add-cont" @click="showSeriesEdit = true">
  166. <img
  167. src="~@/assets/img/set_m/add_ico.png"
  168. alt=""
  169. style="width: 16px; height: 16px; margin-right: 10px"
  170. />
  171. <span>{{$t('EtaChartAddPage.add_series_btn')}}</span>
  172. </div>
  173. <!-- 引用日期设置 -->
  174. <referenceDateSet :show.sync="showReferenceDate" :defaultDate="referenceDateOpts" @change="handleUpdateRefrenceDate"/>
  175. <!-- 添加系列 -->
  176. <seriesEdit
  177. ref="seriesEditIns"
  178. :show.sync="showSeriesEdit"
  179. :chartInfo="chartInfo"
  180. :defaultData="seriesData"
  181. :referenceDateOpts="referenceDateOpts"
  182. @change="handleSeriesChange"
  183. />
  184. <!-- 横纵轴设置 -->
  185. <axisSet
  186. :show.sync="showAxisSet"
  187. :XDataList="XDataList"
  188. :UnitList="UnitList"
  189. :seriesData="seriesData"
  190. @change="handleAxisChange"
  191. />
  192. </div>
  193. </template>
  194. <script>
  195. import axisSet from './axisSet.vue'
  196. import referenceDateSet from './referenceDateSet.vue'
  197. import seriesEdit from './seriesEdit.vue'
  198. import { defaultOpts } from '@/utils/defaultOptions';
  199. export default {
  200. components: { referenceDateSet, seriesEdit, axisSet },
  201. props:{
  202. defaultData:{},
  203. chartInfo: {
  204. type: Object
  205. },
  206. },
  207. data() {
  208. return {
  209. chartItemStyleArr: [
  210. { label: '曲线图', key: 1, value: 'spline' },
  211. { label: '折线图', key: 2, value: 'line' },
  212. { label: '柱状图', key: 4, value: 'column' },
  213. ],//可选样式
  214. predefineColors: defaultOpts.colors.slice(0, 2), //定义颜色蓝,红 默认颜色
  215. seriesData: [],
  216. sortType: 0,//排序类型,0默认,1升序,2降序
  217. sortBasisEdb: '',//基准
  218. referenceDateOpts:[],//引用日期选择项
  219. showReferenceDate: false,
  220. showSeriesEdit: false,
  221. XDataList:[],//横轴配置
  222. UnitList:{
  223. LeftName:'',
  224. RightName:'',
  225. RightTwoName:''
  226. },//纵轴单位配置
  227. showAxisSet: false
  228. }
  229. },
  230. mounted(){
  231. this.initData()
  232. },
  233. methods: {
  234. handleShowEditSeries(index){
  235. this.showSeriesEdit=true
  236. this.$nextTick(()=>{
  237. this.$refs.seriesEditIns.activeIndex=index
  238. })
  239. },
  240. initData(){
  241. if(this.defaultData&&Object.keys(this.defaultData).length !== 0){
  242. this.sortType=this.defaultData.SortType
  243. this.sortBasisEdb=this.defaultData.BaseChartSeriesName
  244. const arr=this.defaultData.SeriesList||[]
  245. this.seriesData=arr.map(item=>{
  246. const _arr=item.EdbInfoList||[]
  247. return {
  248. seriesName: item.SeriesName,
  249. seriesNameEn: item.SeriesNameEn,
  250. seriesChartType: item.ChartStyle,//系列图表展示类型
  251. IsAxis: item.IsAxis,
  252. ChartColor: item.ChartColor,
  253. ChartWidth: item.ChartWidth,
  254. showDataPoint: item.IsPoint?true:false,
  255. showDataValue: item.IsNumber?true:false,
  256. edbList: _arr.map(i=>{
  257. return {
  258. ChartSeriesEdbMappingId:i.ChartSeriesEdbMappingId,
  259. ChartSeriesId:i.ChartSeriesId,
  260. dateType: i.DateConfType,//0指标最新日期 1引用日期
  261. edbType:i.EdbInfoType,
  262. selectEdbData: i,
  263. MoveForward: i.DateConf.MoveForward,//期数前移
  264. dateTransfData: i.DateConf.DateChange,//日期变换数据
  265. refrenceDateName: i.DateConfName,//选择的引用日期
  266. }
  267. })
  268. }
  269. })
  270. const arr2=this.defaultData.XDataList||[]
  271. this.XDataList=arr2.map(item=>{
  272. return {Name:this.$i18nt.locale==='zh'?item.Name:item.NameEn}
  273. })
  274. this.UnitList=this.defaultData.UnitList
  275. this.referenceDateOpts=this.defaultData.DateConfList.map(item=>{
  276. return {
  277. name: item.DateConfName,
  278. dateType: item.DateType||0,//0指标最新日期 1系统日期
  279. selectEdbData: item.EdbInfoId?{
  280. EdbInfoId:item.EdbInfoId,
  281. EdbName:item.EdbName,
  282. EdbNameEn:item.EdbNameEn,
  283. EndDate:item.EndDate,
  284. Frequency:item.Frequency
  285. }:null,
  286. MoveForward: item.MoveForward||0,//期数前移
  287. dateTransfData: item.DateChange||[],//日期变换数据
  288. }
  289. })
  290. }
  291. console.log('初始化后截面组合图数据:',this.defaultData, this.$data);
  292. },
  293. // 获取图表数据
  294. handleGetChartData(){
  295. this.$emit('getData',this.$data)
  296. },
  297. // 图表配置更新
  298. handleChartUpdate(type){
  299. const params={
  300. type,
  301. data:this.$data
  302. }
  303. this.$emit('updateChart',params)
  304. },
  305. //设置横纵轴回调
  306. handleAxisChange(e){
  307. this.XDataList=e.XDataList
  308. this.UnitList=e.UnitList
  309. this.handleGetChartData()
  310. },
  311. // 显示设置横纵轴
  312. handleShowAxis(){
  313. if(this.defaultData&&Object.keys(this.defaultData).length !== 0){
  314. const arr=this.defaultData.XDataList||[]
  315. this.XDataList=arr.map(item=>{
  316. return {Name:this.$i18nt.locale==='zh'?item.Name:item.NameEn}
  317. })
  318. this.UnitList=this.defaultData.UnitList
  319. }
  320. this.showAxisSet=true
  321. },
  322. // 删除系列
  323. async handleDelSeries(item,index){
  324. if(this.seriesData.length===1){
  325. await this.$confirm(this.$t('EtaChartAddPage.series_del_tips'),this.$t('Dialog.warn_tit'))
  326. }
  327. this.seriesData.splice(index,1)
  328. // 删完了
  329. if(this.seriesData.length===0){
  330. this.sortBasisEdb=''
  331. this.XDataList=[]
  332. this.UnitList={
  333. LeftName:'',
  334. RightName:'',
  335. RightTwoName:''
  336. }
  337. this.$emit('hideChart')
  338. }else{
  339. // 删除的是基准
  340. if(item.seriesName===this.sortBasisEdb){
  341. this.sortBasisEdb=this.seriesData[0].seriesName
  342. }
  343. // 判断是否还有右轴 如果没了则要将右二轴换成右轴
  344. const hasRightTwo=this.seriesData.some(i=>i.IsAxis===2)
  345. const hasRight=this.seriesData.some(i=>i.IsAxis===0)
  346. if(hasRightTwo&&!hasRight){
  347. this.seriesData.forEach(i=>{
  348. if(i.IsAxis===2){
  349. i.IsAxis=0
  350. }
  351. })
  352. }
  353. this.handleGetChartData()
  354. }
  355. },
  356. //复制系列
  357. copySeries(item){
  358. this.seriesData.push(JSON.parse(JSON.stringify(item)))
  359. this.$refs.seriesEditIns.handleCopySeries()
  360. this.showSeriesEdit=true
  361. },
  362. handleSeriesChange(data) {
  363. console.log('系列数据改变',data);
  364. this.seriesData = JSON.parse(JSON.stringify(data))
  365. // 设置基准为第一个系列
  366. if(!this.sortBasisEdb){
  367. this.sortBasisEdb=data[0].seriesName
  368. }
  369. this.handleGetChartData()
  370. },
  371. handleUpdateRefrenceDate(e){
  372. console.log('更新引用日期',e);
  373. this.referenceDateOpts=e
  374. },
  375. handleShowRefrenceDate(){
  376. console.log('展示引用日期',this.referenceDateOpts);
  377. this.showReferenceDate=true
  378. }
  379. },
  380. }
  381. </script>
  382. <style lang="scss">
  383. .sectionalCombination-option-wrap {
  384. .sort-wrap {
  385. width: 90%;
  386. .el-radio {
  387. margin-right: 10px;
  388. }
  389. }
  390. .select-box {
  391. display: block;
  392. margin-top: 10px;
  393. .el-input__inner {
  394. height: 40px !important;
  395. line-height: 40px !important;
  396. padding: 0 15px !important;
  397. }
  398. }
  399. .date-set-wrap {
  400. width: 90%;
  401. margin-top: 10px;
  402. display: flex;
  403. justify-content: space-between;
  404. color: #409eff;
  405. font-size: 15px;
  406. cursor: pointer;
  407. }
  408. .add-cont {
  409. margin-top: 10px;
  410. color: #409eff;
  411. font-size: 16px;
  412. cursor: pointer;
  413. display: flex;
  414. align-items: center;
  415. }
  416. .series-data-wrap {
  417. padding: 30px 0 20px;
  418. .el-input__inner {
  419. height: 27px;
  420. line-height: 27px;
  421. padding: 0 4px;
  422. }
  423. .series-list {
  424. border: 1px solid #dcdfe6;
  425. .del-icon {
  426. position: absolute;
  427. right: 10px;
  428. font-size: 16px;
  429. color: #f00;
  430. cursor: pointer;
  431. }
  432. .copy-icon {
  433. position: absolute;
  434. right: 30px;
  435. font-size: 16px;
  436. color: #409eff;
  437. cursor: pointer;
  438. }
  439. .text_oneLine {
  440. color: #409eff;
  441. }
  442. .set-box {
  443. padding: 20px 20px 0;
  444. li {
  445. padding-bottom: 20px;
  446. &:last-child {
  447. padding-bottom: 0;
  448. margin-bottom: 0;
  449. border-bottom: none;
  450. }
  451. }
  452. }
  453. }
  454. .el-collapse-item__header {
  455. background-color: #f0f2f5;
  456. margin-bottom: 0;
  457. border-bottom: 1px solid #dcdfe6;
  458. padding: 0 30px;
  459. .el-collapse-item__arrow {
  460. position: absolute;
  461. left: 8px;
  462. }
  463. }
  464. .scatter-setting {
  465. display: flex;
  466. margin-bottom: 20px;
  467. }
  468. }
  469. }
  470. </style>