batchComputedV2.vue 40 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073
  1. <template>
  2. <el-dialog
  3. :visible.sync="isShow"
  4. :close-on-click-modal="false"
  5. :modal-append-to-body="false"
  6. @close="handleClose"
  7. custom-class="batch-computed-dialog fit-screen-dialog"
  8. center
  9. top="5vh"
  10. v-dialogDrag
  11. :title="showSave ? $t('EtaBasePage.title_batch_save') : $t('EtaBasePage.title_batch_calc')"
  12. >
  13. <div class="batch-computed-wrap" v-if="!showSave">
  14. <el-form inline :disabled="operationForm.view">
  15. <div class="type-wrap">
  16. <div style="margin-right:50px">
  17. <span><!-- 计算公式 -->{{$t('EtaBasePage.calculate_formula')}}</span>
  18. <el-select :disabled="isEdit" v-model="computedType" @change="handleComputedTypeChange" :placeholder="$t('Edb.please_select')">
  19. <el-option
  20. v-for="opt in computedBatchTypes"
  21. :key="opt.type"
  22. :label="opt.name"
  23. :value="opt.type"
  24. />
  25. </el-select>
  26. </div>
  27. <div style="flex:1">
  28. <!-- 累计值转月/季值 -->
  29. <el-form-item v-if="computedType=='toMonthSeason'">
  30. <el-radio-group v-model="subComputedType" @change="handleComputedSubTypeChange">
  31. <el-radio :label="5">
  32. <!-- 转月值 -->
  33. {{$t('Edb.CalculatesAll.to_monthly_v2')}}
  34. </el-radio>
  35. <el-radio :label="61">
  36. <!-- 转季值 -->
  37. {{$t('Edb.CalculatesAll.to_quarterly_v2')}}
  38. </el-radio>
  39. </el-radio-group>
  40. </el-form-item>
  41. <!-- N期移动均值、N期环比值、N期环差值 -->
  42. <el-form-item required v-if="[8,12,13].includes(computedType)" :label="$t('EtaBasePage.label_n_val')" style="width:280px">
  43. <el-input v-model="formData.nNum" :placeholder="$t('Edb.InputHolderAll.input_n_value')" type="number" style="width:200px"></el-input>
  44. </el-form-item>
  45. <!-- 超级季节性 -->
  46. <template v-if="computedType==35">
  47. <el-form-item required :label="$t('EtaBasePage.label_n_val')" style="width:280px">
  48. <el-input v-model="formData.nNum" :placeholder="$t('Edb.InputHolderAll.input_n_value')" type="number" style="width:200px"></el-input>
  49. </el-form-item>
  50. <el-form-item :label="$t('EtaBasePage.label_calendar')" style="width:180px">
  51. <el-select v-model="formData.calendarType" style="width:120px">
  52. <el-option :label="$t('Chart.calendar_gre')" value="公历"></el-option>
  53. <el-option :label="$t('Chart.calendar_lunar')" value="农历"></el-option>
  54. </el-select>
  55. </el-form-item>
  56. </template>
  57. <!-- 降频 -->
  58. <template v-if="computedType==51">
  59. <el-form-item required :label="$t('Edb.Detail.e_fre')" style="width:180px">
  60. <el-select v-model="formData.frequency" style="width:120px">
  61. <el-option v-for="opt in frequencyArr" :key="opt.value" :label="opt.label" :value="opt.value"></el-option>
  62. </el-select>
  63. </el-form-item>
  64. <el-form-item :label="$t('EtaBasePage.label_val_type')" style="width:200px">
  65. <el-select v-model="formData.valueType" style="width:120px">
  66. <el-option key="期末值" :label="$t('EtaBasePage.val_type_end')" value="期末值"/>
  67. <el-option key="平均值" :label="$t('EtaBasePage.val_type_average')" value="平均值"/>
  68. </el-select>
  69. </el-form-item>
  70. </template>
  71. <!-- 累计值 -->
  72. <template v-if="computedType=='accumulate'">
  73. <el-form-item>
  74. <el-radio v-model="subComputedType" :label="62">
  75. <!-- 累计值 -->
  76. {{$t('Edb.CalculatesAll.cumulate')}}
  77. </el-radio>
  78. </el-form-item>
  79. <el-form-item required :label="$t('Edb.Detail.e_fre')" style="width:180px" v-if="subComputedType==62">
  80. <el-select v-model="formData.frequency" style="width:120px">
  81. <el-option v-for="opt in frequencyArr" :key="opt.value" :label="opt.label" :value="opt.value"></el-option>
  82. </el-select>
  83. </el-form-item>
  84. <el-form-item :label="$t('Edb.CalculatesAll.latest_processing')" style="width:210px" v-if="subComputedType==62">
  85. <el-select v-model="formData.newValue" style="width:120px">
  86. <el-option :label="$t('EtaBasePage.default_select_text')" :value="0"/>
  87. <el-option :label="$t('EtaBasePage.mean_imputation_select_text')" :value="1"/>
  88. </el-select>
  89. </el-form-item>
  90. <el-form-item>
  91. <el-radio v-model="subComputedType" :label="63">
  92. <!-- /* '年初至今累计值' */ -->
  93. {{$t('Edb.CalculatesAll.cumulate_oneyear')}}
  94. </el-radio>
  95. </el-form-item>
  96. </template>
  97. <!-- 指数修匀 -->
  98. <template v-if="computedType==72">
  99. <el-form-item required :label="$t('EtaBasePage.alpha_value_lable')" style="width:220px">
  100. <el-input v-model.trim="formData.alphaValue" style="width:140px" :placeholder="$t('Edb.InputHolderAll.input_alpha_val')"></el-input>
  101. </el-form-item>
  102. </template>
  103. <!-- 与常数计算 -->
  104. <template v-if="computedType=='withNum'">
  105. <el-form-item required :label="$t('EtaBasePage.formula_lable')">
  106. <el-input v-model="formData.formula" :placeholder="$t('EtaBasePage.input_formula_msg')" clearable style="width: 200px"/>
  107. <span>
  108. <!-- 公式示例:A+100,或A*2 -->
  109. {{$t('EtaBasePage.formula_example_text')}}
  110. </span>
  111. </el-form-item>
  112. </template>
  113. <!-- 与单指标计算 -->
  114. <template v-if="computedType=='withEDB'">
  115. <el-form-item required :label="$t('EtaBasePage.metric_label_b')">
  116. <el-select
  117. v-model="select_target"
  118. v-loadMore="searchLoad"
  119. :filterable="!select_target"
  120. clearable
  121. :placeholder="$t('Edb.InputHolderAll.input_name')"
  122. style="width: 250px"
  123. remote
  124. :remote-method="getTarget"
  125. @click.native="inputFocusHandle"
  126. @change="chooseTarget"
  127. @blur="search_have_more = false"
  128. >
  129. <i slot="prefix" class="el-input__icon el-icon-search"></i>
  130. <el-option
  131. v-for="item in searchOptions"
  132. :key="item.EdbInfoId"
  133. :label="$parent.currentLang==='en'?(item.EdbNameEn||item.EdbName):item.EdbName"
  134. :value="item.EdbInfoId"
  135. :disabled="!item.HaveOperaAuth"
  136. >
  137. <div>
  138. <img
  139. :src="$icons.lock_ico2"
  140. width="18"
  141. height="18"
  142. style="vertical-align:middle"
  143. v-if="!item.HaveOperaAuth"
  144. />
  145. {{$parent.currentLang==='en'?(item.EdbNameEn||item.EdbName):item.EdbName}}
  146. </div>
  147. </el-option>
  148. </el-select>
  149. </el-form-item>
  150. <el-form-item required :label="$t('EtaBasePage.formula_lable')">
  151. <el-input v-model="formData.formula" :placeholder="$t('EtaBasePage.input_formula_msg')" clearable style="width: 200px"/>
  152. <span>
  153. <!-- 公式示例:A+B,或A/B,A/(A+B) -->
  154. {{$t('EtaBasePage.formula_example_text_a_b')}}
  155. </span>
  156. </el-form-item>
  157. <el-form-item :label="$t('EtaBasePage.create_edb_time_index')">
  158. <el-cascader
  159. v-model="formData.timeSeriesVal"
  160. style="width:180px"
  161. :options="timeSeriesOpt"
  162. :props="{emitPath:false}"
  163. :show-all-levels="false"
  164. :placeholder="$t('Edb.please_select')"
  165. ></el-cascader>
  166. </el-form-item>
  167. <el-form-item :label="$t('EtaBasePage.null_val_deal')">
  168. <el-select
  169. v-model="formData.nullValueWay"
  170. :placeholder="$t('Edb.please_select')"
  171. style="width:180px"
  172. >
  173. <el-option
  174. v-for="item in nullWayOptions"
  175. :key="item.value"
  176. :label="item.label"
  177. :value="item.value"
  178. >
  179. </el-option>
  180. </el-select>
  181. </el-form-item>
  182. <el-form-item :label="$t('EtaBasePage.max_null_val')" v-if="showMaxNullDeal">
  183. <el-select
  184. v-model="formData.maxNullWay"
  185. :placeholder="$t('Edb.please_select')"
  186. >
  187. <el-option :label="$t('EtaBasePage.equal_zeto')" :value="1" />
  188. <el-option label="跳过空值" :value="2" />
  189. </el-select>
  190. </el-form-item>
  191. </template>
  192. <!-- 多指标求和/平均 -->
  193. <template v-if="computedType=='multipleEDB'">
  194. <el-form-item style="margin-right:30px">
  195. <el-radio-group :disabled="isEdit" v-model="subComputedType">
  196. <el-radio :label="81"><!-- -->{{$t('EtaBasePage.sum_radio_label')}}</el-radio>
  197. <el-radio :label="82"><!-- 求平均 -->{{$t('EtaBasePage.average_radio_label')}}</el-radio>
  198. </el-radio-group>
  199. </el-form-item>
  200. <el-form-item :label="$t('EtaBasePage.create_edb_time_index')">
  201. <el-cascader
  202. v-model="formData.timeSeriesVal"
  203. style="width:180px"
  204. :options="timeSeriesOpt"
  205. :props="{emitPath:false}"
  206. :show-all-levels="false"
  207. :placeholder="$t('Edb.please_select')"
  208. ></el-cascader>
  209. </el-form-item>
  210. <el-form-item :label="$t('EtaBasePage.null_val_deal')">
  211. <el-select
  212. v-model="formData.nullValueWay"
  213. :placeholder="$t('Edb.please_select')"
  214. style="width:180px"
  215. >
  216. <el-option
  217. v-for="item in nullWayOptions"
  218. :key="item.value"
  219. :label="item.label"
  220. :value="item.value"
  221. >
  222. </el-option>
  223. </el-select>
  224. </el-form-item>
  225. </template>
  226. </div>
  227. </div>
  228. </el-form>
  229. <div class="filter-wrap" style="margin-top:20px">
  230. <p style="margin-bottom:10px">
  231. <!-- 待选指标(选择指标数量不超过{{MAXAddNUM}}) -->
  232. {{$t('EtaBasePage.pending_metrics',{num:MAXAddNUM})}}
  233. </p>
  234. <div>
  235. <el-cascader
  236. v-model="filter.classify"
  237. :options="classifyOpt"
  238. :props="classifyProps"
  239. clearable
  240. collapse-tags
  241. :placeholder="$t('EtaBasePage.label_classify')"
  242. style="width: 240px"
  243. @change="handleFilter"
  244. />
  245. <el-select
  246. v-model="filter.frequency"
  247. :placeholder="$t('EtaBasePage.select_frequency')"
  248. style="width: 140px"
  249. clearable
  250. multiple
  251. collapse-tags
  252. @change="handleFilter"
  253. :disabled="[5,61].includes(subComputedType)"
  254. >
  255. <el-option
  256. v-for="item in frequencyArr"
  257. :key="item.value"
  258. :label="item.label"
  259. :value="item.value"
  260. >
  261. </el-option>
  262. </el-select>
  263. <el-cascader
  264. v-model="filter.user"
  265. :placeholder="$t('EtaBasePage.table_col_creator')"
  266. :options="sysUserOpts"
  267. :props="sysUserProps"
  268. collapse-tags
  269. :show-all-levels="false"
  270. clearable
  271. filterable
  272. style="width:240px"
  273. @change="handleFilter"
  274. />
  275. <el-input
  276. :placeholder="$t('Edb.InputHolderAll.input_name_orid')"
  277. v-model="filter.keyword"
  278. style="width: 200px"
  279. @keydown.enter.native="handleFilter"
  280. >
  281. <i slot="prefix" class="el-input__icon el-icon-search"></i>
  282. </el-input>
  283. <el-checkbox
  284. :label="$t('EtaBasePage.label_all_check')"
  285. v-model="isCheckAll"
  286. :indeterminate="isCheckIndeterminate"
  287. style="margin-left:10px"
  288. @change="listCheckAllChange"
  289. :disabled="operationForm.view"
  290. />
  291. </div>
  292. </div>
  293. <div class="table-wrap">
  294. <div class="left-box">
  295. <el-table
  296. :data="list"
  297. border
  298. @sort-change="sortChange"
  299. @selection-change="selectionChange"
  300. ref="edbDataRef"
  301. @select="selectHandle"
  302. @select-all="selectAllHandle"
  303. height="500px"
  304. v-loading="listLoading"
  305. >
  306. <el-table-column type="selection" min-width="50" align="center" :selectable="filterEdbAuth"/>
  307. <el-table-column :label="$t('EtaBasePage.full_metric_name')" show-overflow-tooltip align="center" prop="EdbName"/>
  308. <el-table-column :label="$t('Edb.Detail.e_latest_date')" align="center" prop="EndDate" width="120px" />
  309. <el-table-column :label="$t('Edb.Detail.e_latest_value')" align="center" show-overflow-tooltip prop="EndValue" width="80px"/>
  310. <el-table-column :label="$t('EtaBasePage.table_col_creator')" align="center" show-overflow-tooltip prop="SysUserRealName" width="80px"/>
  311. <el-table-column :label="$t('Edb.Detail.e_fre')" align="center" prop="Frequency" width="50px"/>
  312. <el-table-column :label="$t('Edb.Detail.e_unit')" show-overflow-tooltip align="center" prop="Unit" width="50px"/>
  313. </el-table>
  314. <m-page
  315. style="margin-top:10px"
  316. class="table-page"
  317. v-show="total"
  318. :total="total"
  319. :pageSize="pageSize"
  320. :page_no="page"
  321. :pagercount="5"
  322. @handleCurrentChange="pageNumberChange"
  323. />
  324. </div>
  325. <div style="padding-top:200px;margin:0 30px">
  326. <el-button type="primary" :disabled="operationForm.view" :loading="addLoading" @click="getAddEdbListData">
  327. <!-- 加入已选指标 -->
  328. {{$t('EtaBasePage.add_to_selections')}}
  329. </el-button>
  330. </div>
  331. <div class="right-box">
  332. <el-table
  333. :data="selectList"
  334. border
  335. height="500px"
  336. >
  337. <el-table-column :label="$t('EtaBasePage.serial_num')" width="50px" align="center" prop="No" v-if="computedType=='multipleEDB'">
  338. <template slot-scope="scope">
  339. {{scope.$index|getNoText}}
  340. </template>
  341. </el-table-column>
  342. <el-table-column :label="$t('EtaBasePage.full_metric_name')" show-overflow-tooltip align="center" prop="EdbName"/>
  343. <el-table-column width="50px" align="center" v-if="!operationForm.view">
  344. <template slot="header" slot-scope="scope">
  345. <img @click="handleDelSelect('all')" style="width:15px;height:15px;cursor: pointer;" src="~@/assets/img/ai_m/delete.png" alt="">
  346. </template>
  347. <template slot-scope="scope">
  348. <img @click="handleDelSelect(scope)" style="width:15px;height:15px;cursor: pointer;" src="~@/assets/img/ai_m/delete.png" alt="">
  349. </template>
  350. </el-table-column>
  351. </el-table>
  352. </div>
  353. </div>
  354. <div style="text-align:center;margin:60px 0 40px 0">
  355. <el-button type="primary" plain @click="handleCloseSelf">{{$t('Dialog.cancel_btn')}}</el-button>
  356. <el-button type="primary" @click="handleNextStep">{{$t('Dialog.next_step')}}</el-button>
  357. </div>
  358. </div>
  359. <!-- 结果保存 -->
  360. <batchComputedSave
  361. :select_target="select_target"
  362. :computedType="computedType"
  363. :subComputedType="subComputedType"
  364. :selectList="selectList"
  365. :formData="formData"
  366. :isEdit="isEdit"
  367. :operationForm="operationForm"
  368. @close="showSave=false"
  369. @addCallBack="handleAddSuccess"
  370. v-else
  371. />
  372. </el-dialog>
  373. </template>
  374. <script>
  375. import mPage from '@/components/mPage.vue'
  376. import {computedBatchTypesV2} from './util'
  377. import { dataBaseInterface,departInterence } from '@/api/api.js';
  378. import batchComputedSave from './batchComputedSave.vue';
  379. import {generateSeriesArray} from './util'
  380. const tag_arr = generateSeriesArray();
  381. export default {
  382. components:{mPage,batchComputedSave},
  383. props:{
  384. isShow:{
  385. type: Boolean
  386. },
  387. operationForm: {
  388. type: Object,
  389. },
  390. type: {
  391. type: Number
  392. },
  393. },
  394. filters:{
  395. getNoText(e){
  396. return tag_arr[e]
  397. }
  398. },
  399. computed:{
  400. // 最大添加指标的上限
  401. MAXAddNUM(){
  402. let num=50
  403. if(this.computedType=='multipleEDB'){
  404. num=100
  405. }
  406. return num
  407. },
  408. /* max空值处理显示 当输入的公式包含MAX、MIN且空值处理为0时,输入公式失焦后出现右侧选项; */
  409. showMaxNullDeal() {
  410. let haveMaxOrMin = this.formData.formula.toUpperCase().includes('MAX') || this.formData.formula.toUpperCase().includes('MIN')
  411. return haveMaxOrMin && this.formData.nullValueWay===4
  412. },
  413. timeSeriesOpt(){
  414. let arr=[
  415. {
  416. // label:`指标A`,
  417. label:this.$t('EtaBasePage.edbTagA'),
  418. value:'A'
  419. },
  420. {
  421. // label:`指标B`,
  422. label:this.$t('EtaBasePage.edbTagB'),
  423. value:'B'
  424. }
  425. ]
  426. if(this.computedType=='multipleEDB'){
  427. arr=this.selectList.map((item,index)=>{
  428. return{
  429. label:`指标${tag_arr[index]}`,
  430. value:tag_arr[index]
  431. }
  432. })
  433. }
  434. return [
  435. {
  436. // label:'指定指标时间序列',
  437. lable:this.$t('EtaBasePage.specify_series_label'),
  438. value:'0',
  439. children:arr
  440. },
  441. {
  442. // label:'所有指标时间序列并集',
  443. lable:this.$t('EtaBasePage.union_series_label'),
  444. value:'all',
  445. }
  446. ]
  447. },
  448. frequencyArr(){
  449. if(this.computedType==75){
  450. return [
  451. {
  452. value: '周度',
  453. label: /* '周度' */this.$t('Edb.FreAll.week'),
  454. },
  455. {
  456. value: '旬度',
  457. label: /* '旬度' */this.$t('Edb.FreAll.dekad'),
  458. },
  459. {
  460. value: '月度',
  461. label: /* '月度' */this.$t('Edb.FreAll.month'),
  462. },
  463. {
  464. value: '季度',
  465. label: /* '季度' */ this.$t('Edb.FreAll.quarter'),
  466. },
  467. {
  468. value: '年度',
  469. label: /* '年度' */ this.$t('Edb.FreAll.year'),
  470. }]
  471. }
  472. return [
  473. {
  474. value: '日度',
  475. label: /* '日度' */this.$t('Edb.FreAll.day'),
  476. },
  477. {
  478. value: '周度',
  479. label: /* '周度' */this.$t('Edb.FreAll.week'),
  480. },
  481. {
  482. value: '旬度',
  483. label: /* '旬度' */this.$t('Edb.FreAll.dekad'),
  484. },
  485. {
  486. value: '月度',
  487. label: /* '月度' */this.$t('Edb.FreAll.month'),
  488. },
  489. {
  490. value: '季度',
  491. label: /* '季度' */ this.$t('Edb.FreAll.quarter'),
  492. },
  493. {
  494. value: '年度',
  495. label: /* '年度' */ this.$t('Edb.FreAll.year'),
  496. }]
  497. }
  498. },
  499. watch: {
  500. isShow(n){
  501. if(!n){
  502. this.subComputedType=''
  503. this.select_target=''
  504. this.selectList=[]
  505. this.tableDataCheckedList=[]
  506. this.tableDataIds=[]
  507. this.isCheckAll=false
  508. this.isCheckIndeterminate=false
  509. this.checkAllStatus=false
  510. this.selectionReactCancel=false
  511. this.isEdit=false
  512. this.showSave=false
  513. this.computedType=computedBatchTypesV2[0].type
  514. this.filter={
  515. classify:'',
  516. frequency:'',
  517. user:'',
  518. keyword:''
  519. }
  520. this.formData={
  521. nNum:1,
  522. calendarType:'公历',
  523. frequency:'',
  524. valueType:'期末值',
  525. newValue:0,
  526. alphaValue:'',
  527. formula:'',
  528. timeSeriesVal:'A',
  529. nullValueWay:0,
  530. maxNullWay:1,
  531. }
  532. }else{
  533. // 编辑多指标求和\平均
  534. if([81,82].includes(this.type)){
  535. this.initData()
  536. }
  537. this.handleFilter()
  538. }
  539. }
  540. },
  541. data() {
  542. return {
  543. showSave:false,//显示结果保存模块
  544. computedBatchTypes:computedBatchTypesV2,//计算类型筛选项
  545. computedType:computedBatchTypesV2[0].type,//当前选中的计算类型
  546. subComputedType:'',//二级计算类型
  547. formData:{
  548. nNum:1,
  549. calendarType:'公历',
  550. frequency:'',
  551. valueType:'期末值',
  552. newValue:0,
  553. alphaValue:'',
  554. formula:'',
  555. timeSeriesVal:'A',
  556. nullValueWay:0,
  557. maxNullWay:1,
  558. },
  559. select_target:'',
  560. searchOptions:[],//指标列表
  561. search_have_more:false,
  562. search_page: 1,
  563. current_search: '',
  564. filter:{
  565. classify:'',
  566. frequency:'',
  567. user:'',
  568. keyword:''
  569. },
  570. classifyOpt: [],
  571. classifyProps: {
  572. label: 'ClassifyName',
  573. value: 'ClassifyId',
  574. children: 'Children',
  575. multiple: true,
  576. emitPath:false
  577. },
  578. sysUserOpts:[],
  579. sysUserProps:{
  580. value: "AdminId",
  581. label: "RealName",
  582. children: "ChildrenList",
  583. multiple: true,
  584. emitPath:false
  585. },
  586. nullWayOptions: [
  587. { label: /* '查找前后35天最近值' */ this.$t('EtaBasePage.EtaBasePage'),value: 0 },
  588. { label: /* '不计算' */ this.$t('EtaBasePage.not_alculate_options'),value: 1 },
  589. { label: /* '前值填充' */this.$t('EtaBasePage.forward_fill_options'),value: 2 },
  590. { label: /* '后值填充' */this.$t('EtaBasePage.backward_fill_options') ,value: 3 },
  591. { label: /* '等于0' */this.$t('EtaBasePage.equal_zeto') ,value: 4 },
  592. ],
  593. isCheckAll:false,//是否全选
  594. isCheckIndeterminate:false,// 标志列表当前是全选状态还是不是全选状态和 isCheckAll不一样
  595. checkAllStatus:false,
  596. selectionReactCancel:false,// 是否不触发 selection的逻辑
  597. listLoading:false,
  598. page:1,
  599. pageSize:20,
  600. total:0,
  601. list:[],
  602. tableDataCheckedList:[],
  603. tableDataIds:[],
  604. selectList:[],//添加到右侧的数据
  605. addLoading:false,
  606. isEdit:false,//是否为多指标求和等编辑
  607. }
  608. },
  609. mounted() {
  610. this.getClassifyOpt()
  611. this.getEDBList()
  612. this.getSysUserList()
  613. },
  614. methods: {
  615. // 编辑时初始化数据
  616. initData(){
  617. this.isEdit=true
  618. const arr=this.operationForm.CalculateList||[]
  619. this.selectList=arr.map(item=>{
  620. return {
  621. ClassifyId:item.ClassifyId,
  622. EdbInfoId:item.FromEdbInfoId,
  623. EdbName:item.FromEdbName,
  624. Frequency:item.Frequency,
  625. Unit:item.Unit
  626. }
  627. })
  628. this.computedType='multipleEDB'
  629. this.subComputedType=this.type
  630. this.formData.timeSeriesVal=this.operationForm.EdbInfoDetail.Extra?JSON.parse(this.operationForm.EdbInfoDetail.Extra).DateTag:'A'
  631. this.formData.nullValueWay=this.operationForm.EdbInfoDetail.EmptyType||0
  632. },
  633. //批量计算成功回调
  634. handleAddSuccess(type,params){
  635. this.$emit('addCallBack',type,params)
  636. },
  637. // 跳转下一步
  638. handleNextStep(){
  639. if(this.selectList.length===0){
  640. this.$message.warning(/* "请选择指标" */this.$t('Edb.InputHolderAll.input_select_edb'))
  641. return
  642. }
  643. if([8,12,13,35].includes(this.computedType) && !this.formData.nNum){
  644. this.$message.warning(/* "请输入N数值" */ this.$t('Edb.InputHolderAll.input_n_value'))
  645. return
  646. }
  647. if([51].includes(this.computedType)&& !this.formData.frequency){
  648. this.$message.warning(/*'请选择频度'*/this.$t('Edb.InputHolderAll.input_fre'))
  649. return
  650. }
  651. if(['accumulate'].includes(this.computedType)&&this.subComputedType==62&& !this.formData.frequency){
  652. this.$message.warning(/*'请选择频度'*/this.$t('Edb.InputHolderAll.input_fre'))
  653. return
  654. }
  655. if(this.computedType==72&&!this.formData.alphaValue){
  656. this.$message.warning(/*'请输入alpha值'*/this.$t('Edb.InputHolderAll.input_alpha_val'))
  657. return
  658. }
  659. if(this.computedType==72&&(Number(this.formData.alphaValue)<=0||Number(this.formData.alphaValue)>=1)){
  660. this.$message.warning(/*''请输入>0,<1的数值的alpha值''*/ this.$t('EtaBasePage.numeric_greater_msg'))
  661. return
  662. }
  663. if(this.computedType=='withEDB'&&!this.select_target){
  664. this.$message.warning(/*'请选择指标B'*/this.$t('EtaBasePage.select_indicator_msg'))
  665. return
  666. }
  667. if(['withNum','withEDB'].includes(this.computedType)&&!this.formData.formula){
  668. this.$message.warning(/*'请输入公式'8*/this.$t('EtaBasePage.input_formula_msg'))
  669. return
  670. }
  671. this.isCheckAll=false
  672. this.isCheckIndeterminate=false
  673. this.checkAllStatus=false
  674. this.tableDataCheckedList=[]
  675. this.tableDataIds=[]
  676. this.showSave=true
  677. },
  678. // 点击加入已选指标库
  679. async getAddEdbListData(){
  680. if(!(this.isCheckAll || this.isCheckIndeterminate ) || (!(this.list && this.list.length>0))){
  681. this.$message.warning(/* "请选择指标" */this.$t('Edb.InputHolderAll.input_select_edb'))
  682. return
  683. }
  684. if(this.selectList.length>=this.MAXAddNUM){
  685. this.$message.warning(/* "已达批量添加指标数量上限" */this.$t('EtaBasePage.limit_indicators_msg'))
  686. return
  687. }
  688. const params={
  689. SysUserIds:this.filter.user?this.filter.user.join(','):'',
  690. ClassifyIds:this.filter.classify?this.filter.classify.join(','):'',
  691. Keyword:this.filter.keyword,
  692. Frequency:this.filter.frequency?this.filter.frequency.join(','):'',
  693. SelectAll:this.checkAllStatus,
  694. EdbInfoIds:this.tableDataCheckedList.join(',')
  695. }
  696. this.addLoading=true
  697. const res=await dataBaseInterface.getBatchFilterAddEdbList(params)
  698. this.addLoading=false
  699. if(res.Ret!=200) return
  700. // 加入到已选指标中 要去重
  701. const arr=res.Data.SearchItem||[]
  702. const temArr=this.mergeAndDistinct(this.selectList,arr)
  703. // 截取数组 防止数量溢出
  704. this.selectList=temArr.filter(_ =>_.HaveOperaAuth).slice(0,this.MAXAddNUM)
  705. },
  706. mergeAndDistinct(arr1, arr2) {
  707. // 合并两个数组
  708. const mergedArray = arr1.concat(arr2);
  709. // 根据 EdbInfoId 字段进行去重
  710. const distinctArray = mergedArray.filter((item, index, self) => {
  711. return index === self.findIndex(t => t.EdbInfoId === item.EdbInfoId);
  712. });
  713. return distinctArray;
  714. },
  715. // 删除已选指标库指标
  716. handleDelSelect(e){
  717. if(this.operationForm.view) return
  718. if(e==='all'){
  719. this.selectList=[]
  720. return
  721. }
  722. const index=e.$index
  723. this.selectList.splice(index,1)
  724. },
  725. // 切换计算类型
  726. handleComputedTypeChange(){
  727. this.subComputedType=''
  728. this.select_target=''
  729. this.formData={
  730. nNum:1,
  731. calendarType:'公历',
  732. frequency:'',
  733. valueType:'期末值',
  734. newValue:0,
  735. alphaValue:'',
  736. formula:'',
  737. timeSeriesVal:'A',
  738. nullValueWay:0,
  739. maxNullWay:1,
  740. }
  741. this.filter={
  742. classify:'',
  743. frequency:'',
  744. user:'',
  745. keyword:''
  746. }
  747. this.selectList=[]
  748. if(this.computedType=='toMonthSeason'){
  749. this.subComputedType=5
  750. this.filter.frequency=['月度']
  751. }else if(this.computedType=='accumulate'){
  752. this.subComputedType=62
  753. }else if(this.computedType=='multipleEDB'){
  754. this.subComputedType=81
  755. }
  756. this.handleFilter()
  757. },
  758. handleComputedSubTypeChange(){
  759. if(this.subComputedType==61){
  760. this.filter.frequency=['季度']
  761. }
  762. if(this.subComputedType==5){
  763. this.filter.frequency=['月度']
  764. }
  765. this.selectList=[]
  766. this.handleFilter()
  767. },
  768. /* 指标列表 */
  769. getTarget(query) {
  770. this.search_page = 1;
  771. this.current_search = query;
  772. this.searchApi(this.current_search);
  773. },
  774. /* 聚焦获取当前检索 */
  775. inputFocusHandle(e) {
  776. this.search_page = 1;
  777. this.current_search = e.target.value;
  778. this.searchApi(this.current_search);
  779. },
  780. searchApi(query,page=1) {
  781. dataBaseInterface.targetSearchByPage({
  782. KeyWord:query,
  783. CurrentIndex: page,
  784. FilterSource: 1,
  785. Frequency: ''
  786. }).then(res => {
  787. if(res.Ret !== 200) return
  788. const { List,Paging } = res.Data;
  789. this.search_have_more = page < Paging.Pages;
  790. let arr = page === 1 ? List : this.searchOptions.concat(List);
  791. this.searchOptions = arr;
  792. })
  793. },
  794. searchLoad() {
  795. if(!this.search_have_more) return;
  796. this.searchApi(this.current_search,++this.search_page)
  797. },
  798. handleClose(){
  799. this.showSave=false
  800. this.$emit('close')
  801. },
  802. handleCloseSelf(){//仅仅关闭批量计算弹窗
  803. this.$emit('closeSelf')
  804. },
  805. filterNodes(arr) {
  806. arr.length &&
  807. arr.forEach((item) => {
  808. item.Children.length && this.filterNodes(item.Children);
  809. if (!item.Children.length) {
  810. delete item.Children;
  811. }
  812. });
  813. },
  814. // 获取指标分类
  815. async getClassifyOpt(){
  816. const res=await dataBaseInterface.menuListV3()
  817. if (res.Ret !== 200) return
  818. this.filterNodes(res.Data.AllNodes||[]);
  819. this.classifyOpt = res.Data.AllNodes || [];
  820. },
  821. // 获取所有系统用户
  822. async getSysUserList() {
  823. const res = await departInterence.getQuestionAdminList();
  824. if (res.Ret === 200) {
  825. this.sysUserOpts = res.Data.List||[];
  826. }
  827. },
  828. // 获取指标列表
  829. async getEDBList(type){
  830. this.listLoading=true
  831. const res=await dataBaseInterface.getBatchAddEdbSearchList({
  832. CurrentIndex:this.page,
  833. PageSize: this.pageSize,
  834. SysUserIds:this.filter.user?this.filter.user.join(','):'',
  835. ClassifyIds:this.filter.classify?this.filter.classify.join(','):'',
  836. Keyword:this.filter.keyword,
  837. Frequency:this.filter.frequency?this.filter.frequency.join(','):'',
  838. NotFrequency:this.computedType==75?'日度':''
  839. })
  840. this.listLoading=false
  841. if(res.Ret===200){
  842. this.list=res.Data.SearchItem||[]
  843. this.total=res.Data.Paging.Totals||0
  844. if(this.list.length>0){
  845. this.tableDataIds = this.list.map(it => it.EdbInfoId)
  846. }else{
  847. this.tableDataIds = []
  848. }
  849. if(type == 'adjustSelection'){
  850. this.adjustSelection()
  851. }else{
  852. this.isCheckAll=false
  853. this.checkAllStatus=false
  854. this.isCheckIndeterminate=false
  855. this.listCheckAllChange(this.isCheckAll)
  856. }
  857. }
  858. },
  859. pageNumberChange(e){
  860. this.page=e
  861. this.getEDBList('adjustSelection')
  862. },
  863. handleFilter(e){
  864. this.page=1
  865. this.list=[]
  866. this.getEDBList()
  867. },
  868. // 切换列表全选按钮状态
  869. listCheckAllChange(check){
  870. this.tableDataCheckedList=[]
  871. this.checkAllStatus=check
  872. if(check){
  873. // 全选
  874. this.$refs.edbDataRef && this.$refs.edbDataRef.clearSelection()
  875. this.$refs.edbDataRef && this.$refs.edbDataRef.toggleAllSelection()
  876. }else{
  877. //全不选
  878. this.$refs.edbDataRef && this.$refs.edbDataRef.clearSelection()
  879. }
  880. },
  881. selectionChange(val){
  882. if(this.selectionReactCancel) return
  883. // selectAllHandle的触发在selectionChange后面,将selectionChange的逻辑延迟一下
  884. setTimeout(()=>{
  885. // 去重
  886. let duplicateArr = Array.from(new Set(this.tableDataCheckedList))
  887. if((duplicateArr.length == this.total && (!this.checkAllStatus))
  888. || (duplicateArr.length == 0 && this.checkAllStatus)){
  889. this.isCheckAll = true
  890. this.isCheckIndeterminate=false
  891. }else if((duplicateArr.length == 0 && (!this.checkAllStatus))
  892. || (duplicateArr.length == this.total && this.checkAllStatus)){
  893. this.isCheckAll = false
  894. this.isCheckIndeterminate=false
  895. }else{
  896. this.isCheckAll = false
  897. this.isCheckIndeterminate=true
  898. }
  899. },1)
  900. },
  901. //用户手动勾选数据行的 Checkbox 时触发的事件
  902. selectHandle(selection, row){
  903. if(this.selectionReactCancel) return
  904. let check=false
  905. if(selection.some(it => it.EdbInfoId == row.EdbInfoId)){
  906. // 勾选
  907. // 勾选
  908. if(this.checkAllStatus){
  909. check=false
  910. }else{
  911. check=true
  912. }
  913. }else{
  914. // 取消勾选
  915. if(this.checkAllStatus){
  916. check=true
  917. }else{
  918. check=false
  919. }
  920. }
  921. if(check){
  922. this.tableDataCheckedList.push(row.EdbInfoId)
  923. }else{
  924. this.tableDataCheckedList=this.tableDataCheckedList.filter(it => it!=row.EdbInfoId)
  925. }
  926. },
  927. // 用户手动勾选全选 Checkbox 时触发的事件
  928. selectAllHandle(selection){
  929. if(this.selectionReactCancel) return
  930. let check = false; // 从tableDataCheckedList 添加还是删除
  931. if(selection && selection.length>0){
  932. // 全选
  933. if(this.checkAllStatus){
  934. check=false
  935. }else{
  936. check=true
  937. }
  938. }else{
  939. // 全不选
  940. if(this.checkAllStatus){
  941. check=true
  942. }else{
  943. check=false
  944. }
  945. }
  946. if(check){
  947. this.tableDataCheckedList = [...this.tableDataCheckedList,...this.tableDataIds]
  948. }else{
  949. this.tableDataCheckedList = this.tableDataCheckedList.filter(it => !this.tableDataIds.includes(it))
  950. }
  951. },
  952. adjustSelection(){
  953. this.selectionReactCancel=true
  954. if(!this.checkAllStatus){
  955. this.tableDataCheckedList.map(it =>{
  956. let row = this.list.find(da => da.EdbInfoId==it)
  957. if(row){
  958. setTimeout(()=>{
  959. this.$refs.edbDataRef.toggleRowSelection(row,true)
  960. },10)
  961. }
  962. })
  963. }else{
  964. this.$refs.edbDataRef.toggleAllSelection()
  965. this.tableDataCheckedList.map(it =>{
  966. let row = this.list.find(da => da.EdbInfoId==it)
  967. if(row){
  968. setTimeout(()=>{
  969. this.$refs.edbDataRef.toggleRowSelection(row,false)
  970. },50)
  971. }
  972. })
  973. }
  974. setTimeout(()=>{
  975. this.selectionReactCancel=false
  976. },50)
  977. },
  978. filterEdbAuth(row) {
  979. return row.HaveOperaAuth
  980. }
  981. },
  982. }
  983. </script>
  984. <style lang="scss">
  985. .batch-computed-dialog{
  986. max-width: 1200px;
  987. width:90vw;
  988. overflow: hidden;
  989. }
  990. .batch-computed-wrap{
  991. .type-wrap{
  992. display: flex;
  993. }
  994. .table-wrap{
  995. margin-top: 20px;
  996. display: flex;
  997. justify-content: space-between;
  998. .left-box{
  999. width: 50%;
  1000. }
  1001. .right-box{
  1002. flex: 1;
  1003. flex-shrink: 0;
  1004. }
  1005. }
  1006. }
  1007. </style>