123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500 |
- <template>
- <div class="sectionalCombination-option-wrap">
- <div class="sort-wrap">
- <div>
- <el-tooltip
- effect="dark"
- :content="$t('EtaChartAddPage.sort_tips')"
- placement="top-start"
- >
- <span>
- <span>{{ $t('EtaChartAddPage.label_sort_rule')}}</span>
- <i class="el-icon-info"></i>
- </span>
- </el-tooltip>
- <el-radio-group v-model="sortType" style="margin-left: 20px" @change="handleGetChartData">
- <el-radio :label="0">{{$t('EtaBasePage.default_select_text')}}</el-radio>
- <el-radio :label="1">{{$t('EtaChartAddPage.option_sort_up')}}</el-radio>
- <el-radio :label="2">{{$t('EtaChartAddPage.option_sort_low')}}</el-radio>
- </el-radio-group>
- </div>
- <el-select
- class="select-box"
- v-model="sortBasisEdb"
- :placeholder="$t('EtaChartAddPage.select_base_placehold')"
- @change="handleGetChartData"
- >
- <el-option
- v-for="item in seriesData"
- :key="item.seriesName"
- :label="item.seriesName"
- :value="item.seriesName"
- >
- </el-option>
- </el-select>
- </div>
- <div class="date-set-wrap">
- <span @click="handleShowRefrenceDate">{{$t('EtaChartAddPage.reference_date_set')}}</span>
- <span @click="handleShowAxis">{{$t('EtaChartAddPage.axis_set')}}</span>
- </div>
- <!-- 系列数据模块 -->
- <div class="series-data-wrap" v-if="seriesData.length">
- <el-collapse class="series-list">
- <el-collapse-item v-for="(item, index) in seriesData" :key="index">
- <template slot="title">
- <span class="text_oneLine" @click.stop="handleShowEditSeries(index)">{{
- currentLang === "en"?item.seriesNameEn||item.seriesName:item.seriesName
- }}</span>
- <img class="copy-icon" src="~@/assets/img/icons/copy-active.png" alt="" @click.stop="copySeries(item)">
- <i
- class="el-icon-delete del-icon"
- @click.stop="handleDelSeries(item,index)"
- ></i>
- </template>
- <ul class="set-box">
- <li>
- <el-radio-group
- v-model="item.IsAxis"
- size="mini"
- @input="handleChartUpdate('isAxis')"
- >
- <el-radio-button :label="1"
- ><!-- 左轴 -->{{ $t("Chart.Detail.l_axis") }}</el-radio-button
- >
- <el-radio-button :label="0"
- ><!-- 右轴 -->{{ $t("Chart.Detail.r_axis") }}</el-radio-button
- >
- <!-- 指标有右轴时才可以选右2轴 不然没有右2这个概念的意义 -->
- <el-radio-button
- :label="2"
- :disabled="
- seriesData.findIndex((_) => _.IsAxis === 0) === -1 ||
- (seriesData.findIndex((_) => _.IsAxis === 0) === index &&
- seriesData.filter((_) => _.IsAxis === 0).length === 1)
- "
- ><!-- 右2轴 -->{{
- $t("Chart.Detail.rtwo_axis")
- }}</el-radio-button
- >
- </el-radio-group>
- </li>
- <li>
- <div style="display: flex">
- <span style="margin-right: 3px"
- ><!-- 生成样式 -->{{ $t("Chart.label_create_sty") }}:</span
- >
- <el-select
- v-model="item.seriesChartType"
- placeholder="请选择生成样式"
- style="width: 50%"
- class="edb-item-style"
- @change="handleChartUpdate('chartType')"
- >
- <el-option
- v-for="item in chartItemStyleArr"
- :key="item.key"
- :label="item.label"
- :value="item.value"
- >
- </el-option>
- </el-select>
- </div>
- </li>
- <!-- 数据点展示 -->
- <li>
- <div style="display: flex; align-items: center" v-if="item.seriesChartType!='column'">
- <span>{{$t('EtaChartAddPage.show_data_point')}}</span>
- <el-tooltip
- :content="$t('EtaChartAddPage.show_data_point_tips')"
- placement="top"
- >
- <i class="el-icon-info"></i>
- </el-tooltip>
- <el-switch
- style="margin-left: 20px"
- v-model="item.showDataPoint"
- @change="handleChartUpdate('dataPoint')"
- >
- </el-switch>
- </div>
- </li>
- <!-- 数值展示 -->
- <li>
- <div style="display: flex; align-items: center">
- <span>{{$t('EtaChartAddPage.show_data_value')}}</span>
- <el-tooltip :content="$t('EtaChartAddPage.show_data_value_tips')" placement="top">
- <i class="el-icon-info"></i>
- </el-tooltip>
- <el-switch
- style="margin-left: 33px"
- v-model="item.showDataValue"
- @change="handleChartUpdate('dataValue')"
- >
- </el-switch>
- </div>
- </li>
- <li>
- <div style="display: flex">
- <span style="margin-right: 3px"
- ><!-- 线条颜色 -->{{ $t("Chart.Detail.line_color") }}:</span
- >
- <el-color-picker
- v-model="item.ChartColor"
- size="mini"
- show-alpha
- :predefine="predefineColors"
- @change="handleChartUpdate('ChartColor')"
- ></el-color-picker>
- </div>
- <div style="margin-top: 12px" v-if="item.seriesChartType!='column'">
- <!-- 线条粗细 -->{{ $t("Chart.Detail.line_size") }}:
- <el-input
- style="width: 60px"
- size="mini"
- type="number"
- :min="1"
- v-model="item.ChartWidth"
- @change="handleChartUpdate('ChartWidth')"
- />
- </div>
- </li>
- </ul>
- </el-collapse-item>
- </el-collapse>
- </div>
- <div class="add-cont" @click="showSeriesEdit = true">
- <img
- src="~@/assets/img/set_m/add_ico.png"
- alt=""
- style="width: 16px; height: 16px; margin-right: 10px"
- />
- <span>{{$t('EtaChartAddPage.add_series_btn')}}</span>
- </div>
- <!-- 引用日期设置 -->
- <referenceDateSet :show.sync="showReferenceDate" :defaultDate="referenceDateOpts" @change="handleUpdateRefrenceDate"/>
- <!-- 添加系列 -->
- <seriesEdit
- ref="seriesEditIns"
- :show.sync="showSeriesEdit"
- :chartInfo="chartInfo"
- :defaultData="seriesData"
- :referenceDateOpts="referenceDateOpts"
- @change="handleSeriesChange"
- />
- <!-- 横纵轴设置 -->
- <axisSet
- :show.sync="showAxisSet"
- :XDataList="XDataList"
- :UnitList="UnitList"
- :seriesData="seriesData"
- @change="handleAxisChange"
- />
- </div>
- </template>
- <script>
- import axisSet from './axisSet.vue'
- import referenceDateSet from './referenceDateSet.vue'
- import seriesEdit from './seriesEdit.vue'
- import { defaultOpts } from '@/utils/defaultOptions';
- export default {
- components: { referenceDateSet, seriesEdit, axisSet },
- props:{
- defaultData:{},
- chartInfo: {
- type: Object
- },
- },
- data() {
- return {
- chartItemStyleArr: [
- { label: '曲线图', key: 1, value: 'spline' },
- { label: '折线图', key: 2, value: 'line' },
- { label: '柱状图', key: 4, value: 'column' },
- ],//可选样式
- predefineColors: defaultOpts.colors.slice(0, 2), //定义颜色蓝,红 默认颜色
- seriesData: [],
- sortType: 0,//排序类型,0默认,1升序,2降序
- sortBasisEdb: '',//基准
- referenceDateOpts:[],//引用日期选择项
- showReferenceDate: false,
- showSeriesEdit: false,
- XDataList:[],//横轴配置
- UnitList:{
- LeftName:'',
- RightName:'',
- RightTwoName:''
- },//纵轴单位配置
- showAxisSet: false
- }
- },
- mounted(){
- this.initData()
- },
- methods: {
- handleShowEditSeries(index){
- this.showSeriesEdit=true
- this.$nextTick(()=>{
- this.$refs.seriesEditIns.activeIndex=index
- })
- },
- initData(){
- if(this.defaultData&&Object.keys(this.defaultData).length !== 0){
- this.sortType=this.defaultData.SortType
- this.sortBasisEdb=this.defaultData.BaseChartSeriesName
- const arr=this.defaultData.SeriesList||[]
- this.seriesData=arr.map(item=>{
- const _arr=item.EdbInfoList||[]
- return {
- seriesName: item.SeriesName,
- seriesNameEn: item.SeriesNameEn,
- seriesChartType: item.ChartStyle,//系列图表展示类型
- IsAxis: item.IsAxis,
- ChartColor: item.ChartColor,
- ChartWidth: item.ChartWidth,
- showDataPoint: item.IsPoint?true:false,
- showDataValue: item.IsNumber?true:false,
- edbList: _arr.map(i=>{
- return {
- ChartSeriesEdbMappingId:i.ChartSeriesEdbMappingId,
- ChartSeriesId:i.ChartSeriesId,
- dateType: i.DateConfType,//0指标最新日期 1引用日期
- edbType:i.EdbInfoType,
- selectEdbData: i,
- MoveForward: i.DateConf.MoveForward,//期数前移
- dateTransfData: i.DateConf.DateChange,//日期变换数据
- refrenceDateName: i.DateConfName,//选择的引用日期
- }
- })
- }
- })
-
- const arr2=this.defaultData.XDataList||[]
- this.XDataList=arr2.map(item=>{
- return {Name:this.$i18nt.locale==='zh'?item.Name:item.NameEn}
- })
- this.UnitList=this.defaultData.UnitList
- this.referenceDateOpts=this.defaultData.DateConfList.map(item=>{
- return {
- name: item.DateConfName,
- dateType: item.DateType||0,//0指标最新日期 1系统日期
- selectEdbData: item.EdbInfoId?{
- EdbInfoId:item.EdbInfoId,
- EdbName:item.EdbName,
- EdbNameEn:item.EdbNameEn,
- EndDate:item.EndDate,
- Frequency:item.Frequency
- }:null,
- MoveForward: item.MoveForward||0,//期数前移
- dateTransfData: item.DateChange||[],//日期变换数据
- }
- })
-
- }
- console.log('初始化后截面组合图数据:',this.defaultData, this.$data);
- },
- // 获取图表数据
- handleGetChartData(){
- this.$emit('getData',this.$data)
- },
- // 图表配置更新
- handleChartUpdate(type){
- const params={
- type,
- data:this.$data
- }
- this.$emit('updateChart',params)
- },
- //设置横纵轴回调
- handleAxisChange(e){
- this.XDataList=e.XDataList
- this.UnitList=e.UnitList
- this.handleGetChartData()
- },
- // 显示设置横纵轴
- handleShowAxis(){
- if(this.defaultData&&Object.keys(this.defaultData).length !== 0){
- const arr=this.defaultData.XDataList||[]
- this.XDataList=arr.map(item=>{
- return {Name:this.$i18nt.locale==='zh'?item.Name:item.NameEn}
- })
- this.UnitList=this.defaultData.UnitList
- }
- this.showAxisSet=true
- },
- // 删除系列
- async handleDelSeries(item,index){
- if(this.seriesData.length===1){
- await this.$confirm(this.$t('EtaChartAddPage.series_del_tips'),this.$t('Dialog.warn_tit'))
- }
- this.seriesData.splice(index,1)
- // 删完了
- if(this.seriesData.length===0){
- this.sortBasisEdb=''
- this.XDataList=[]
- this.UnitList={
- LeftName:'',
- RightName:'',
- RightTwoName:''
- }
- this.$emit('hideChart')
- }else{
- // 删除的是基准
- if(item.seriesName===this.sortBasisEdb){
- this.sortBasisEdb=this.seriesData[0].seriesName
- }
- // 判断是否还有右轴 如果没了则要将右二轴换成右轴
- const hasRightTwo=this.seriesData.some(i=>i.IsAxis===2)
- const hasRight=this.seriesData.some(i=>i.IsAxis===0)
- if(hasRightTwo&&!hasRight){
- this.seriesData.forEach(i=>{
- if(i.IsAxis===2){
- i.IsAxis=0
- }
- })
- }
- this.handleGetChartData()
- }
- },
- //复制系列
- copySeries(item){
- this.seriesData.push(JSON.parse(JSON.stringify(item)))
- this.$refs.seriesEditIns.handleCopySeries()
- this.showSeriesEdit=true
- },
- handleSeriesChange(data) {
- console.log('系列数据改变',data);
- this.seriesData = JSON.parse(JSON.stringify(data))
- // 设置基准为第一个系列
- if(!this.sortBasisEdb){
- this.sortBasisEdb=data[0].seriesName
- }
-
- this.handleGetChartData()
- },
- handleUpdateRefrenceDate(e){
- console.log('更新引用日期',e);
- this.referenceDateOpts=e
- },
- handleShowRefrenceDate(){
- console.log('展示引用日期',this.referenceDateOpts);
- this.showReferenceDate=true
- }
- },
- }
- </script>
- <style lang="scss">
- .sectionalCombination-option-wrap {
- .sort-wrap {
- width: 90%;
- .el-radio {
- margin-right: 10px;
- }
- }
- .select-box {
- display: block;
- margin-top: 10px;
- .el-input__inner {
- height: 40px !important;
- line-height: 40px !important;
- padding: 0 15px !important;
- }
- }
- .date-set-wrap {
- width: 90%;
- margin-top: 10px;
- display: flex;
- justify-content: space-between;
- color: #409eff;
- font-size: 15px;
- cursor: pointer;
- }
- .add-cont {
- margin-top: 10px;
- color: #409eff;
- font-size: 16px;
- cursor: pointer;
- display: flex;
- align-items: center;
- }
- .series-data-wrap {
- padding: 30px 0 20px;
- .el-input__inner {
- height: 27px;
- line-height: 27px;
- padding: 0 4px;
- }
- .series-list {
- border: 1px solid #dcdfe6;
- .del-icon {
- position: absolute;
- right: 10px;
- font-size: 16px;
- color: #f00;
- cursor: pointer;
- }
- .copy-icon {
- position: absolute;
- right: 30px;
- font-size: 16px;
- color: #409eff;
- cursor: pointer;
- }
- .text_oneLine {
- color: #409eff;
- }
- .set-box {
- padding: 20px 20px 0;
- li {
- padding-bottom: 20px;
- &:last-child {
- padding-bottom: 0;
- margin-bottom: 0;
- border-bottom: none;
- }
- }
- }
- }
- .el-collapse-item__header {
- background-color: #f0f2f5;
- margin-bottom: 0;
- border-bottom: 1px solid #dcdfe6;
- padding: 0 30px;
- .el-collapse-item__arrow {
- position: absolute;
- left: 8px;
- }
- }
- .scatter-setting {
- display: flex;
- margin-bottom: 20px;
- }
- }
- }
- </style>
|