selectTarget.vue 6.8 KB

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