selectTarget.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. <template>
  2. <div style="flex: 1">
  3. <el-select
  4. style="width: 100%"
  5. v-model="targetType"
  6. :placeholder="$t('StatisticAnalysis.StatisticFeatureChart.selecr_indicator_pld')"
  7. :disabled="isDisabled"
  8. @change="targetTypeChange"
  9. v-if="selectStyleType===1&&filter"
  10. >
  11. <el-option
  12. v-for="item in etaTypeOpt"
  13. :key="item.val"
  14. :label="item.label"
  15. :value="item.val"
  16. />
  17. </el-select>
  18. <div v-else-if="selectStyleType===2&&filter">
  19. <label>{{$t('StatisticAnalysis.StatisticFeatureChart.select_edb')}}:</label>
  20. <el-radio-group v-model="targetType" @change="targetTypeChange">
  21. <el-radio
  22. v-for="item in etaTypeOpt"
  23. :key="item.val"
  24. :label="item.val"
  25. >{{item.label}}</el-radio>
  26. </el-radio-group>
  27. </div>
  28. <div v-else-if="selectStyleType===3&&filter" style="display:flex;align-items:center">
  29. <el-select
  30. v-model="targetType"
  31. :placeholder="$t('StatisticAnalysis.StatisticFeatureChart.selecr_indicator_pld')"
  32. @change="targetTypeChange"
  33. :style="{'width': selectBoxWidth?selectBoxWidth:'150px'}"
  34. >
  35. <el-option
  36. v-for="item in etaTypeOpt"
  37. :key="item.val"
  38. :label="item.label"
  39. :value="item.val"
  40. />
  41. </el-select>
  42. <el-select
  43. v-model="search_txt"
  44. v-loadMore="searchLoad"
  45. :filterable="!search_txt"
  46. remote
  47. clearable
  48. :placeholder="$t('Edb.InputHolderAll.select_edb_name')"
  49. style="flex: 1;margin-left: 15px"
  50. :remote-method="searchHandle"
  51. @click.native="inputFocusHandle"
  52. @change="handleSelectTarget"
  53. >
  54. <i slot="prefix" class="el-input__icon el-icon-search"></i>
  55. <el-option
  56. v-for="item in searchOptions"
  57. :key="item.EdbInfoId"
  58. :label="currentLang==='en'?(item.EdbNameEn||item.EdbName):item.EdbName"
  59. :value="item.EdbInfoId"
  60. :disabled="!item.HaveOperaAuth"
  61. >
  62. <edbDetailPopover :info="item">
  63. <div slot="reference">
  64. <img
  65. :src="$icons.lock_ico2"
  66. width="18"
  67. height="18"
  68. style="vertical-align:middle"
  69. v-if="!item.HaveOperaAuth"
  70. />
  71. {{currentLang==='en'?(item.EdbNameEn||item.EdbName):item.EdbName}}
  72. </div>
  73. </edbDetailPopover>
  74. </el-option>
  75. </el-select>
  76. <slot name="setDecimal"></slot>
  77. </div>
  78. <el-select
  79. v-model="search_txt"
  80. v-loadMore="searchLoad"
  81. v-if="selectStyleType!==3"
  82. :filterable="!search_txt"
  83. remote
  84. clearable
  85. :disabled="isDisabled"
  86. :placeholder="$t('Edb.InputHolderAll.select_edb_name')"
  87. :style="`width: ${showMoreBtn?'auto':width}; ${filter?'margin-top: 20px':''}`"
  88. :remote-method="searchHandle"
  89. @click.native="inputFocusHandle"
  90. @change="handleSelectTarget"
  91. >
  92. <i slot="prefix" class="el-input__icon el-icon-search"></i>
  93. <el-option
  94. v-for="item in searchOptions"
  95. :key="item.EdbInfoId"
  96. :label="currentLang==='en'?(item.EdbNameEn||item.EdbName):item.EdbName"
  97. :value="item.EdbInfoId"
  98. :disabled="!item.HaveOperaAuth"
  99. >
  100. <edbDetailPopover :info="item">
  101. <div slot="reference">
  102. <img
  103. :src="$icons.lock_ico2"
  104. width="18"
  105. height="18"
  106. style="vertical-align:middle"
  107. v-if="!item.HaveOperaAuth"
  108. />
  109. {{currentLang==='en'?(item.EdbNameEn||item.EdbName):item.EdbName}}
  110. </div>
  111. </edbDetailPopover>
  112. </el-option>
  113. </el-select>
  114. <slot name="moreBtn"></slot>
  115. </div>
  116. </template>
  117. <script>
  118. import { dataBaseInterface } from '@/api/api.js';
  119. import * as preDictEdbInterface from '@/api/modules/predictEdbApi.js';
  120. import * as sheetInterface from "@/api/modules/sheetApi.js";
  121. export default {
  122. props:{
  123. defaultId:{
  124. default:''
  125. },
  126. defaultOpt:{
  127. default:()=>[]
  128. },
  129. defaultType:{
  130. default:''
  131. },
  132. selectStyleType: {
  133. default: 1
  134. },
  135. filter: { //是否要预测和eta的筛选
  136. default: true
  137. },
  138. width: {
  139. default:'100%'
  140. },
  141. isDisabled:{
  142. default:false
  143. },
  144. selectBoxWidth:{
  145. default:''
  146. },
  147. showMoreBtn:{
  148. default:false
  149. }
  150. },
  151. watch:{
  152. defaultId(){
  153. this.search_txt=this.defaultId||''
  154. this.searchOptions=this.defaultOpt||[]
  155. this.current_search=this.defaultOpt[0]?this.defaultOpt[0].EdbName:''
  156. this.targetType=this.defaultType==1?'2':'1' //EdbInfoCategoryType 0普通 1预测
  157. }
  158. },
  159. computed:{
  160. etaTypeOpt(){
  161. return [
  162. {
  163. label:this.$t('Edb.eta_name'),
  164. val:'1'
  165. },
  166. {
  167. label:this.$t('Edb.eta_predictor_name'),
  168. val:'2'
  169. },
  170. ]
  171. },
  172. currentLang() {
  173. return this.$store.state.lang
  174. }
  175. },
  176. data() {
  177. return {
  178. targetType:'1',//1:ETA指标 2:ETA预测指标
  179. search_txt: this.defaultId||'',
  180. searchOptions: this.defaultOpt||[],
  181. search_have_more: true,
  182. search_page: 1,
  183. current_search: this.defaultOpt[0]?this.defaultOpt[0].EdbName:'',
  184. }
  185. },
  186. methods: {
  187. /* 搜索 */
  188. searchHandle(query) {
  189. this.search_page = 1;
  190. this.current_search = query;
  191. this.searchApi(this.current_search)
  192. },
  193. async searchApi(query, page = 1) {
  194. let params = {
  195. KeyWord: query,
  196. CurrentIndex: page,
  197. }
  198. let res;
  199. if(this.filter) {
  200. res = this.targetType=='1'?await dataBaseInterface.targetSearchByPage(params):await preDictEdbInterface.edbSearch(params)
  201. }else {
  202. const filterMap = {
  203. 1: 2,
  204. 8: 3,
  205. 14: 6
  206. }
  207. let FilterSource = (['/addMixedSheet','/editBalanceSheet'].includes(this.$route.path) && this.$parent.isCalculateDia)
  208. ? filterMap[this.$parent.formData.source]||1
  209. : 1;
  210. let Frequency = (['/addMixedSheet','/editBalanceSheet'].includes(this.$route.path) && this.$parent.isCalculateDia && this.$parent.formData.source===2)
  211. ? '季度'
  212. : ''
  213. res = await sheetInterface.searchTarget({
  214. ...params,
  215. FilterSource,
  216. Frequency
  217. })
  218. }
  219. if (res.Ret !== 200) return
  220. const { List, Paging } = res.Data;
  221. this.search_have_more = page < Paging.Pages;
  222. this.searchOptions = page === 1 ? List : this.searchOptions.concat(List);
  223. },
  224. /* 聚焦获取当前检索 */
  225. inputFocusHandle(e) {
  226. this.search_page = 1;
  227. this.current_search = e.target.value;
  228. this.searchApi(this.current_search);
  229. },
  230. searchLoad() {
  231. if (!this.search_have_more) return;
  232. this.searchApi(this.current_search, ++this.search_page);
  233. },
  234. //要搜索的指标类型变化
  235. targetTypeChange(){
  236. this.searchOptions=[]
  237. this.search_page = 1;
  238. this.search_txt=''
  239. this.$emit('select','')
  240. this.$emit('edbTypeChange',this.targetType=='1'?0:1)
  241. },
  242. // 指标选择
  243. handleSelectTarget(e){
  244. let arr=this.searchOptions.filter(_item=>_item.EdbInfoId==e)
  245. this.$emit('select',arr[0])
  246. this.$emit('edbTypeChange',this.targetType=='1'?0:1)
  247. },
  248. },
  249. }
  250. </script>
  251. <style>
  252. </style>