selectTarget.vue 8.0 KB

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