123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267 |
- <template>
- <div style="flex: 1">
- <el-select
- style="width: 100%"
- v-model="targetType"
- :placeholder="$t('StatisticAnalysis.StatisticFeatureChart.selecr_indicator_pld')"
- :disabled="isDisabled"
- @change="targetTypeChange"
- v-if="selectStyleType===1&&filter"
- >
- <el-option
- v-for="item in etaTypeOpt"
- :key="item.val"
- :label="item.label"
- :value="item.val"
- />
- </el-select>
- <div v-else-if="selectStyleType===2&&filter">
- <label>{{$t('StatisticAnalysis.StatisticFeatureChart.select_edb')}}:</label>
- <el-radio-group v-model="targetType" @change="targetTypeChange">
- <el-radio
- v-for="item in etaTypeOpt"
- :key="item.val"
- :label="item.val"
- >{{item.label}}</el-radio>
- </el-radio-group>
- </div>
- <div v-else-if="selectStyleType===3&&filter" style="display:flex;align-items:center">
- <el-select
- v-model="targetType"
- :placeholder="$t('StatisticAnalysis.StatisticFeatureChart.selecr_indicator_pld')"
- @change="targetTypeChange"
- :style="{'width': selectBoxWidth?selectBoxWidth:'150px'}"
- >
- <el-option
- v-for="item in etaTypeOpt"
- :key="item.val"
- :label="item.label"
- :value="item.val"
- />
- </el-select>
- <el-select
- v-model="search_txt"
- v-loadMore="searchLoad"
- :filterable="!search_txt"
- remote
- clearable
- :placeholder="$t('Edb.InputHolderAll.select_edb_name')"
- style="flex: 1;margin-left: 15px"
- :remote-method="searchHandle"
- @click.native="inputFocusHandle"
- @change="handleSelectTarget"
- >
- <i slot="prefix" class="el-input__icon el-icon-search"></i>
- <el-option
- v-for="item in searchOptions"
- :key="item.EdbInfoId"
- :label="currentLang==='en'?(item.EdbNameEn||item.EdbName):item.EdbName"
- :value="item.EdbInfoId"
- :disabled="!item.HaveOperaAuth"
- >
- <edbDetailPopover :info="item">
- <div slot="reference">
- <img
- :src="$icons.lock_ico2"
- width="18"
- height="18"
- style="vertical-align:middle"
- v-if="!item.HaveOperaAuth"
- />
- {{currentLang==='en'?(item.EdbNameEn||item.EdbName):item.EdbName}}
- </div>
- </edbDetailPopover>
- </el-option>
- </el-select>
- <slot name="setDecimal"></slot>
- </div>
- <el-select
- v-model="search_txt"
- v-loadMore="searchLoad"
- v-if="selectStyleType!==3"
- :filterable="!search_txt"
- remote
- clearable
- :disabled="isDisabled"
- :placeholder="$t('Edb.InputHolderAll.select_edb_name')"
- :style="`width: ${showMoreBtn?'auto':width}; ${filter?'margin-top: 20px':''}`"
- :remote-method="searchHandle"
- @click.native="inputFocusHandle"
- @change="handleSelectTarget"
- >
- <i slot="prefix" class="el-input__icon el-icon-search"></i>
- <el-option
- v-for="item in searchOptions"
- :key="item.EdbInfoId"
- :label="currentLang==='en'?(item.EdbNameEn||item.EdbName):item.EdbName"
- :value="item.EdbInfoId"
- :disabled="!item.HaveOperaAuth"
- >
- <edbDetailPopover :info="item">
- <div slot="reference">
- <img
- :src="$icons.lock_ico2"
- width="18"
- height="18"
- style="vertical-align:middle"
- v-if="!item.HaveOperaAuth"
- />
- {{currentLang==='en'?(item.EdbNameEn||item.EdbName):item.EdbName}}
- </div>
- </edbDetailPopover>
- </el-option>
- </el-select>
- <slot name="moreBtn"></slot>
- </div>
- </template>
- <script>
- import { dataBaseInterface } from '@/api/api.js';
- import * as preDictEdbInterface from '@/api/modules/predictEdbApi.js';
- import * as sheetInterface from "@/api/modules/sheetApi.js";
- export default {
- props:{
- defaultId:{
- default:''
- },
- defaultOpt:{
- default:()=>[]
- },
- defaultType:{
- default:''
- },
- selectStyleType: {
- default: 1
- },
- filter: { //是否要预测和eta的筛选
- default: true
- },
- width: {
- default:'100%'
- },
- isDisabled:{
- default:false
- },
- selectBoxWidth:{
- default:''
- },
- showMoreBtn:{
- default:false
- }
- },
- watch:{
- defaultId(){
- this.search_txt=this.defaultId||''
- this.searchOptions=this.defaultOpt||[]
- this.current_search=this.defaultOpt[0]?this.defaultOpt[0].EdbName:''
- this.targetType=this.defaultType==1?'2':'1' //EdbInfoCategoryType 0普通 1预测
- }
- },
- computed:{
- etaTypeOpt(){
- return [
- {
- label:this.$t('Edb.eta_name'),
- val:'1'
- },
- {
- label:this.$t('Edb.eta_predictor_name'),
- val:'2'
- },
- ]
- },
- currentLang() {
- return this.$store.state.lang
- }
- },
- data() {
- return {
- targetType:'1',//1:ETA指标 2:ETA预测指标
- search_txt: this.defaultId||'',
- searchOptions: this.defaultOpt||[],
- search_have_more: true,
- search_page: 1,
- current_search: this.defaultOpt[0]?this.defaultOpt[0].EdbName:'',
- }
- },
- methods: {
- /* 搜索 */
- searchHandle(query) {
- this.search_page = 1;
- this.current_search = query;
- this.searchApi(this.current_search)
- },
- async searchApi(query, page = 1) {
- let params = {
- KeyWord: query,
- CurrentIndex: page,
- }
- let res;
- if(this.filter) {
- res = this.targetType=='1'?await dataBaseInterface.targetSearchByPage(params):await preDictEdbInterface.edbSearch(params)
- }else {
- const filterMap = {
- 1: 2,
- 8: 3,
- 14: 6
- }
- let FilterSource = (['/addMixedSheet','/editBalanceSheet'].includes(this.$route.path) && this.$parent.isCalculateDia)
- ? filterMap[this.$parent.formData.source]||1
- : 1;
- let Frequency = (['/addMixedSheet','/editBalanceSheet'].includes(this.$route.path) && this.$parent.isCalculateDia && this.$parent.formData.source===2)
- ? '季度'
- : ''
- res = await sheetInterface.searchTarget({
- ...params,
- FilterSource,
- Frequency
- })
- }
-
- if (res.Ret !== 200) return
- const { List, Paging } = res.Data;
- this.search_have_more = page < Paging.Pages;
- this.searchOptions = page === 1 ? List : this.searchOptions.concat(List);
- },
- /* 聚焦获取当前检索 */
- inputFocusHandle(e) {
- this.search_page = 1;
- this.current_search = e.target.value;
- this.searchApi(this.current_search);
- },
- searchLoad() {
- if (!this.search_have_more) return;
- this.searchApi(this.current_search, ++this.search_page);
- },
- //要搜索的指标类型变化
- targetTypeChange(){
- this.searchOptions=[]
- this.search_page = 1;
- this.search_txt=''
- this.$emit('select','')
- this.$emit('edbTypeChange',this.targetType=='1'?0:1)
- },
- // 指标选择
- handleSelectTarget(e){
- let arr=this.searchOptions.filter(_item=>_item.EdbInfoId==e)
- this.$emit('select',arr[0])
- this.$emit('edbTypeChange',this.targetType=='1'?0:1)
- },
- },
- }
- </script>
- <style>
- </style>
|