batchComputedV2.vue 41 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084
  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_text')" 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="$parent.currentLang==='en'?'EdbNameEn':'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. <template slot-scope="scope">
  313. <span>{{ getFrequencyTrans(scope.row.Frequency) }}</span>
  314. </template>
  315. </el-table-column>
  316. <el-table-column :label="$t('Edb.Detail.e_unit')" show-overflow-tooltip align="center" :prop="$parent.currentLang==='en'?'UnitEn':'Unit'" width="50px">
  317. <template slot-scope="scope">
  318. <span>{{ getUnitTrans(scope.row.Unit) }}</span>
  319. </template>
  320. </el-table-column>
  321. </el-table>
  322. <m-page
  323. style="margin-top:10px"
  324. class="table-page"
  325. v-show="total"
  326. :total="total"
  327. :pageSize="pageSize"
  328. :page_no="page"
  329. :pagercount="5"
  330. @handleCurrentChange="pageNumberChange"
  331. />
  332. </div>
  333. <div style="padding-top:200px;margin:0 30px">
  334. <el-button type="primary" :disabled="operationForm.view" :loading="addLoading" @click="getAddEdbListData">
  335. <!-- 加入已选指标 -->
  336. {{$t('EtaBasePage.add_to_selections')}}
  337. </el-button>
  338. </div>
  339. <div class="right-box">
  340. <el-table
  341. :data="selectList"
  342. border
  343. height="500px"
  344. >
  345. <el-table-column :label="$t('EtaBasePage.serial_num')" width="50px" align="center" prop="No" v-if="computedType=='multipleEDB'">
  346. <template slot-scope="scope">
  347. {{scope.$index|getNoText}}
  348. </template>
  349. </el-table-column>
  350. <el-table-column :label="$t('EtaBasePage.full_metric_name')" show-overflow-tooltip align="center" :prop="$parent.currentLang==='en'?'EdbNameEn':'EdbName'"/>
  351. <el-table-column width="50px" align="center" v-if="!operationForm.view">
  352. <template slot="header" slot-scope="scope">
  353. <img @click="handleDelSelect('all')" style="width:15px;height:15px;cursor: pointer;" src="~@/assets/img/ai_m/delete.png" alt="">
  354. </template>
  355. <template slot-scope="scope">
  356. <img @click="handleDelSelect(scope)" style="width:15px;height:15px;cursor: pointer;" src="~@/assets/img/ai_m/delete.png" alt="">
  357. </template>
  358. </el-table-column>
  359. </el-table>
  360. </div>
  361. </div>
  362. <div style="text-align:center;margin:60px 0 40px 0">
  363. <el-button type="primary" plain @click="handleCloseSelf">{{$t('Dialog.cancel_btn')}}</el-button>
  364. <el-button type="primary" @click="handleNextStep">{{$t('Dialog.next_step')}}</el-button>
  365. </div>
  366. </div>
  367. <!-- 结果保存 -->
  368. <batchComputedSave
  369. :select_target="select_target"
  370. :computedType="computedType"
  371. :subComputedType="subComputedType"
  372. :selectList="selectList"
  373. :formData="formData"
  374. :isEdit="isEdit"
  375. :operationForm="operationForm"
  376. @close="showSave=false"
  377. @addCallBack="handleAddSuccess"
  378. v-else
  379. />
  380. </el-dialog>
  381. </template>
  382. <script>
  383. import mPage from '@/components/mPage.vue'
  384. import {computedBatchTypesV2,getBatchComputedTypesV2} from './util'
  385. import { dataBaseInterface,departInterence } from '@/api/api.js';
  386. import batchComputedSave from './batchComputedSave.vue';
  387. import {generateSeriesArray} from './util'
  388. const tag_arr = generateSeriesArray();
  389. export default {
  390. components:{mPage,batchComputedSave},
  391. props:{
  392. isShow:{
  393. type: Boolean
  394. },
  395. operationForm: {
  396. type: Object,
  397. },
  398. type: {
  399. type: Number
  400. },
  401. },
  402. filters:{
  403. getNoText(e){
  404. return tag_arr[e]
  405. }
  406. },
  407. computed:{
  408. // 最大添加指标的上限
  409. MAXAddNUM(){
  410. let num=50
  411. if(this.computedType=='multipleEDB'){
  412. num=100
  413. }
  414. return num
  415. },
  416. /* max空值处理显示 当输入的公式包含MAX、MIN且空值处理为0时,输入公式失焦后出现右侧选项; */
  417. showMaxNullDeal() {
  418. let haveMaxOrMin = this.formData.formula.toUpperCase().includes('MAX') || this.formData.formula.toUpperCase().includes('MIN')
  419. return haveMaxOrMin && this.formData.nullValueWay===4
  420. },
  421. timeSeriesOpt(){
  422. let arr=[
  423. {
  424. // label:`指标A`,
  425. label:this.$t('EtaBasePage.edbTagA'),
  426. value:'A'
  427. },
  428. {
  429. // label:`指标B`,
  430. label:this.$t('EtaBasePage.edbTagB'),
  431. value:'B'
  432. }
  433. ]
  434. if(this.computedType=='multipleEDB'){
  435. arr=this.selectList.map((item,index)=>{
  436. return{
  437. label:`指标${tag_arr[index]}`,
  438. value:tag_arr[index]
  439. }
  440. })
  441. }
  442. return [
  443. {
  444. // label:'指定指标时间序列',
  445. lable:this.$t('EtaBasePage.specify_series_label'),
  446. value:'0',
  447. children:arr
  448. },
  449. {
  450. // label:'所有指标时间序列并集',
  451. lable:this.$t('EtaBasePage.union_series_label'),
  452. value:'all',
  453. }
  454. ]
  455. },
  456. frequencyArr(){
  457. if(this.computedType==75){
  458. return [
  459. {
  460. value: '周度',
  461. label: /* '周度' */this.$t('Edb.FreAll.week'),
  462. },
  463. {
  464. value: '旬度',
  465. label: /* '旬度' */this.$t('Edb.FreAll.dekad'),
  466. },
  467. {
  468. value: '月度',
  469. label: /* '月度' */this.$t('Edb.FreAll.month'),
  470. },
  471. {
  472. value: '季度',
  473. label: /* '季度' */ this.$t('Edb.FreAll.quarter'),
  474. },
  475. {
  476. value: '年度',
  477. label: /* '年度' */ this.$t('Edb.FreAll.year'),
  478. }]
  479. }
  480. return [
  481. {
  482. value: '日度',
  483. label: /* '日度' */this.$t('Edb.FreAll.day'),
  484. },
  485. {
  486. value: '周度',
  487. label: /* '周度' */this.$t('Edb.FreAll.week'),
  488. },
  489. {
  490. value: '旬度',
  491. label: /* '旬度' */this.$t('Edb.FreAll.dekad'),
  492. },
  493. {
  494. value: '月度',
  495. label: /* '月度' */this.$t('Edb.FreAll.month'),
  496. },
  497. {
  498. value: '季度',
  499. label: /* '季度' */ this.$t('Edb.FreAll.quarter'),
  500. },
  501. {
  502. value: '年度',
  503. label: /* '年度' */ this.$t('Edb.FreAll.year'),
  504. }]
  505. },
  506. computedBatchTypes(){
  507. return getBatchComputedTypesV2()
  508. }
  509. },
  510. watch: {
  511. isShow(n){
  512. if(!n){
  513. this.subComputedType=''
  514. this.select_target=''
  515. this.selectList=[]
  516. this.tableDataCheckedList=[]
  517. this.tableDataIds=[]
  518. this.isCheckAll=false
  519. this.isCheckIndeterminate=false
  520. this.checkAllStatus=false
  521. this.selectionReactCancel=false
  522. this.isEdit=false
  523. this.showSave=false
  524. this.computedType=computedBatchTypesV2[0].type
  525. this.filter={
  526. classify:'',
  527. frequency:'',
  528. user:'',
  529. keyword:''
  530. }
  531. this.formData={
  532. nNum:1,
  533. calendarType:'公历',
  534. frequency:'',
  535. valueType:'期末值',
  536. newValue:0,
  537. alphaValue:'',
  538. formula:'',
  539. timeSeriesVal:'A',
  540. nullValueWay:0,
  541. maxNullWay:1,
  542. }
  543. }else{
  544. // 编辑多指标求和\平均
  545. if([81,82].includes(this.type)){
  546. this.initData()
  547. }
  548. this.handleFilter()
  549. }
  550. }
  551. },
  552. data() {
  553. return {
  554. showSave:false,//显示结果保存模块
  555. /* computedBatchTypes:computedBatchTypesV2,//计算类型筛选项 */
  556. computedType:computedBatchTypesV2[0].type,//当前选中的计算类型
  557. subComputedType:'',//二级计算类型
  558. formData:{
  559. nNum:1,
  560. calendarType:'公历',
  561. frequency:'',
  562. valueType:'期末值',
  563. newValue:0,
  564. alphaValue:'',
  565. formula:'',
  566. timeSeriesVal:'A',
  567. nullValueWay:0,
  568. maxNullWay:1,
  569. },
  570. select_target:'',
  571. searchOptions:[],//指标列表
  572. search_have_more:false,
  573. search_page: 1,
  574. current_search: '',
  575. filter:{
  576. classify:'',
  577. frequency:'',
  578. user:'',
  579. keyword:''
  580. },
  581. classifyOpt: [],
  582. classifyProps: {
  583. label: 'ClassifyName',
  584. value: 'ClassifyId',
  585. children: 'Children',
  586. multiple: true,
  587. emitPath:false
  588. },
  589. sysUserOpts:[],
  590. sysUserProps:{
  591. value: "AdminId",
  592. label: "RealName",
  593. children: "ChildrenList",
  594. multiple: true,
  595. emitPath:false
  596. },
  597. nullWayOptions: [
  598. { label: /* '查找前后35天最近值' */ this.$t('EtaBasePage.null_val_deal_0'),value: 0 },
  599. { label: /* '不计算' */ this.$t('EtaBasePage.not_alculate_options'),value: 1 },
  600. { label: /* '前值填充' */this.$t('EtaBasePage.forward_fill_options'),value: 2 },
  601. { label: /* '后值填充' */this.$t('EtaBasePage.backward_fill_options') ,value: 3 },
  602. { label: /* '等于0' */this.$t('EtaBasePage.equal_zeto') ,value: 4 },
  603. ],
  604. isCheckAll:false,//是否全选
  605. isCheckIndeterminate:false,// 标志列表当前是全选状态还是不是全选状态和 isCheckAll不一样
  606. checkAllStatus:false,
  607. selectionReactCancel:false,// 是否不触发 selection的逻辑
  608. listLoading:false,
  609. page:1,
  610. pageSize:20,
  611. total:0,
  612. list:[],
  613. tableDataCheckedList:[],
  614. tableDataIds:[],
  615. selectList:[],//添加到右侧的数据
  616. addLoading:false,
  617. isEdit:false,//是否为多指标求和等编辑
  618. }
  619. },
  620. mounted() {
  621. this.getClassifyOpt()
  622. this.getEDBList()
  623. this.getSysUserList()
  624. },
  625. methods: {
  626. // 编辑时初始化数据
  627. initData(){
  628. this.isEdit=true
  629. const arr=this.operationForm.CalculateList||[]
  630. this.selectList=arr.map(item=>{
  631. return {
  632. ClassifyId:item.ClassifyId,
  633. EdbInfoId:item.FromEdbInfoId,
  634. EdbName:item.FromEdbName,
  635. Frequency:item.Frequency,
  636. Unit:item.Unit
  637. }
  638. })
  639. this.computedType='multipleEDB'
  640. this.subComputedType=this.type
  641. this.formData.timeSeriesVal=this.operationForm.EdbInfoDetail.Extra?JSON.parse(this.operationForm.EdbInfoDetail.Extra).DateTag:'A'
  642. this.formData.nullValueWay=this.operationForm.EdbInfoDetail.EmptyType||0
  643. },
  644. //批量计算成功回调
  645. handleAddSuccess(type,params){
  646. this.$emit('addCallBack',type,params)
  647. },
  648. // 跳转下一步
  649. handleNextStep(){
  650. if(this.selectList.length===0){
  651. this.$message.warning(/* "请选择指标" */this.$t('Edb.InputHolderAll.input_select_edb'))
  652. return
  653. }
  654. if([8,12,13,35].includes(this.computedType) && !this.formData.nNum){
  655. this.$message.warning(/* "请输入N数值" */ this.$t('Edb.InputHolderAll.input_n_value'))
  656. return
  657. }
  658. if([51].includes(this.computedType)&& !this.formData.frequency){
  659. this.$message.warning(/*'请选择频度'*/this.$t('Edb.InputHolderAll.input_fre'))
  660. return
  661. }
  662. if(['accumulate'].includes(this.computedType)&&this.subComputedType==62&& !this.formData.frequency){
  663. this.$message.warning(/*'请选择频度'*/this.$t('Edb.InputHolderAll.input_fre'))
  664. return
  665. }
  666. if(this.computedType==72&&!this.formData.alphaValue){
  667. this.$message.warning(/*'请输入alpha值'*/this.$t('Edb.InputHolderAll.input_alpha_val'))
  668. return
  669. }
  670. if(this.computedType==72&&(Number(this.formData.alphaValue)<=0||Number(this.formData.alphaValue)>=1)){
  671. this.$message.warning(/*''请输入>0,<1的数值的alpha值''*/ this.$t('EtaBasePage.numeric_greater_msg'))
  672. return
  673. }
  674. if(this.computedType=='withEDB'&&!this.select_target){
  675. this.$message.warning(/*'请选择指标B'*/this.$t('EtaBasePage.select_indicator_msg'))
  676. return
  677. }
  678. if(['withNum','withEDB'].includes(this.computedType)&&!this.formData.formula){
  679. this.$message.warning(/*'请输入公式'8*/this.$t('EtaBasePage.input_formula_msg'))
  680. return
  681. }
  682. this.isCheckAll=false
  683. this.isCheckIndeterminate=false
  684. this.checkAllStatus=false
  685. this.tableDataCheckedList=[]
  686. this.tableDataIds=[]
  687. this.showSave=true
  688. },
  689. // 点击加入已选指标库
  690. async getAddEdbListData(){
  691. if(!(this.isCheckAll || this.isCheckIndeterminate ) || (!(this.list && this.list.length>0))){
  692. this.$message.warning(/* "请选择指标" */this.$t('Edb.InputHolderAll.input_select_edb'))
  693. return
  694. }
  695. if(this.selectList.length>=this.MAXAddNUM){
  696. this.$message.warning(/* "已达批量添加指标数量上限" */this.$t('EtaBasePage.limit_indicators_msg'))
  697. return
  698. }
  699. const params={
  700. SysUserIds:this.filter.user?this.filter.user.join(','):'',
  701. ClassifyIds:this.filter.classify?this.filter.classify.join(','):'',
  702. Keyword:this.filter.keyword,
  703. Frequency:this.filter.frequency?this.filter.frequency.join(','):'',
  704. SelectAll:this.checkAllStatus,
  705. EdbInfoIds:this.tableDataCheckedList.join(',')
  706. }
  707. this.addLoading=true
  708. const res=await dataBaseInterface.getBatchFilterAddEdbList(params)
  709. this.addLoading=false
  710. if(res.Ret!=200) return
  711. // 加入到已选指标中 要去重
  712. const arr=res.Data.SearchItem||[]
  713. const temArr=this.mergeAndDistinct(this.selectList,arr)
  714. // 截取数组 防止数量溢出
  715. this.selectList=temArr.filter(_ =>_.HaveOperaAuth).slice(0,this.MAXAddNUM)
  716. },
  717. mergeAndDistinct(arr1, arr2) {
  718. // 合并两个数组
  719. const mergedArray = arr1.concat(arr2);
  720. // 根据 EdbInfoId 字段进行去重
  721. const distinctArray = mergedArray.filter((item, index, self) => {
  722. return index === self.findIndex(t => t.EdbInfoId === item.EdbInfoId);
  723. });
  724. return distinctArray;
  725. },
  726. // 删除已选指标库指标
  727. handleDelSelect(e){
  728. if(this.operationForm.view) return
  729. if(e==='all'){
  730. this.selectList=[]
  731. return
  732. }
  733. const index=e.$index
  734. this.selectList.splice(index,1)
  735. },
  736. // 切换计算类型
  737. handleComputedTypeChange(){
  738. this.subComputedType=''
  739. this.select_target=''
  740. this.formData={
  741. nNum:1,
  742. calendarType:'公历',
  743. frequency:'',
  744. valueType:'期末值',
  745. newValue:0,
  746. alphaValue:'',
  747. formula:'',
  748. timeSeriesVal:'A',
  749. nullValueWay:0,
  750. maxNullWay:1,
  751. }
  752. this.filter={
  753. classify:'',
  754. frequency:'',
  755. user:'',
  756. keyword:''
  757. }
  758. this.selectList=[]
  759. if(this.computedType=='toMonthSeason'){
  760. this.subComputedType=5
  761. this.filter.frequency=['月度']
  762. }else if(this.computedType=='accumulate'){
  763. this.subComputedType=62
  764. }else if(this.computedType=='multipleEDB'){
  765. this.subComputedType=81
  766. }
  767. this.handleFilter()
  768. },
  769. handleComputedSubTypeChange(){
  770. if(this.subComputedType==61){
  771. this.filter.frequency=['季度']
  772. }
  773. if(this.subComputedType==5){
  774. this.filter.frequency=['月度']
  775. }
  776. this.selectList=[]
  777. this.handleFilter()
  778. },
  779. /* 指标列表 */
  780. getTarget(query) {
  781. this.search_page = 1;
  782. this.current_search = query;
  783. this.searchApi(this.current_search);
  784. },
  785. /* 聚焦获取当前检索 */
  786. inputFocusHandle(e) {
  787. this.search_page = 1;
  788. this.current_search = e.target.value;
  789. this.searchApi(this.current_search);
  790. },
  791. searchApi(query,page=1) {
  792. dataBaseInterface.targetSearchByPage({
  793. KeyWord:query,
  794. CurrentIndex: page,
  795. FilterSource: 1,
  796. Frequency: ''
  797. }).then(res => {
  798. if(res.Ret !== 200) return
  799. const { List,Paging } = res.Data;
  800. this.search_have_more = page < Paging.Pages;
  801. let arr = page === 1 ? List : this.searchOptions.concat(List);
  802. this.searchOptions = arr;
  803. })
  804. },
  805. searchLoad() {
  806. if(!this.search_have_more) return;
  807. this.searchApi(this.current_search,++this.search_page)
  808. },
  809. handleClose(){
  810. this.showSave=false
  811. this.$emit('close')
  812. },
  813. handleCloseSelf(){//仅仅关闭批量计算弹窗
  814. this.$emit('closeSelf')
  815. },
  816. filterNodes(arr) {
  817. arr.length &&
  818. arr.forEach((item) => {
  819. item.Children.length && this.filterNodes(item.Children);
  820. if (!item.Children.length) {
  821. delete item.Children;
  822. }
  823. });
  824. },
  825. // 获取指标分类
  826. async getClassifyOpt(){
  827. const res=await dataBaseInterface.menuListV3()
  828. if (res.Ret !== 200) return
  829. this.filterNodes(res.Data.AllNodes||[]);
  830. this.classifyOpt = res.Data.AllNodes || [];
  831. },
  832. // 获取所有系统用户
  833. async getSysUserList() {
  834. const res = await departInterence.getQuestionAdminList();
  835. if (res.Ret === 200) {
  836. this.sysUserOpts = res.Data.List||[];
  837. }
  838. },
  839. // 获取指标列表
  840. async getEDBList(type){
  841. this.listLoading=true
  842. const res=await dataBaseInterface.getBatchAddEdbSearchList({
  843. CurrentIndex:this.page,
  844. PageSize: this.pageSize,
  845. SysUserIds:this.filter.user?this.filter.user.join(','):'',
  846. ClassifyIds:this.filter.classify?this.filter.classify.join(','):'',
  847. Keyword:this.filter.keyword,
  848. Frequency:this.filter.frequency?this.filter.frequency.join(','):'',
  849. NotFrequency:this.computedType==75?'日度':''
  850. })
  851. this.listLoading=false
  852. if(res.Ret===200){
  853. this.list=res.Data.SearchItem||[]
  854. this.total=res.Data.Paging.Totals||0
  855. if(this.list.length>0){
  856. this.tableDataIds = this.list.map(it => it.EdbInfoId)
  857. }else{
  858. this.tableDataIds = []
  859. }
  860. if(type == 'adjustSelection'){
  861. this.adjustSelection()
  862. }else{
  863. this.isCheckAll=false
  864. this.checkAllStatus=false
  865. this.isCheckIndeterminate=false
  866. this.listCheckAllChange(this.isCheckAll)
  867. }
  868. }
  869. },
  870. pageNumberChange(e){
  871. this.page=e
  872. this.getEDBList('adjustSelection')
  873. },
  874. handleFilter(e){
  875. this.page=1
  876. this.list=[]
  877. this.getEDBList()
  878. },
  879. // 切换列表全选按钮状态
  880. listCheckAllChange(check){
  881. this.tableDataCheckedList=[]
  882. this.checkAllStatus=check
  883. if(check){
  884. // 全选
  885. this.$refs.edbDataRef && this.$refs.edbDataRef.clearSelection()
  886. this.$refs.edbDataRef && this.$refs.edbDataRef.toggleAllSelection()
  887. }else{
  888. //全不选
  889. this.$refs.edbDataRef && this.$refs.edbDataRef.clearSelection()
  890. }
  891. },
  892. selectionChange(val){
  893. if(this.selectionReactCancel) return
  894. // selectAllHandle的触发在selectionChange后面,将selectionChange的逻辑延迟一下
  895. setTimeout(()=>{
  896. // 去重
  897. let duplicateArr = Array.from(new Set(this.tableDataCheckedList))
  898. if((duplicateArr.length == this.total && (!this.checkAllStatus))
  899. || (duplicateArr.length == 0 && this.checkAllStatus)){
  900. this.isCheckAll = true
  901. this.isCheckIndeterminate=false
  902. }else if((duplicateArr.length == 0 && (!this.checkAllStatus))
  903. || (duplicateArr.length == this.total && this.checkAllStatus)){
  904. this.isCheckAll = false
  905. this.isCheckIndeterminate=false
  906. }else{
  907. this.isCheckAll = false
  908. this.isCheckIndeterminate=true
  909. }
  910. },1)
  911. },
  912. //用户手动勾选数据行的 Checkbox 时触发的事件
  913. selectHandle(selection, row){
  914. if(this.selectionReactCancel) return
  915. let check=false
  916. if(selection.some(it => it.EdbInfoId == row.EdbInfoId)){
  917. // 勾选
  918. // 勾选
  919. if(this.checkAllStatus){
  920. check=false
  921. }else{
  922. check=true
  923. }
  924. }else{
  925. // 取消勾选
  926. if(this.checkAllStatus){
  927. check=true
  928. }else{
  929. check=false
  930. }
  931. }
  932. if(check){
  933. this.tableDataCheckedList.push(row.EdbInfoId)
  934. }else{
  935. this.tableDataCheckedList=this.tableDataCheckedList.filter(it => it!=row.EdbInfoId)
  936. }
  937. },
  938. // 用户手动勾选全选 Checkbox 时触发的事件
  939. selectAllHandle(selection){
  940. if(this.selectionReactCancel) return
  941. let check = false; // 从tableDataCheckedList 添加还是删除
  942. if(selection && selection.length>0){
  943. // 全选
  944. if(this.checkAllStatus){
  945. check=false
  946. }else{
  947. check=true
  948. }
  949. }else{
  950. // 全不选
  951. if(this.checkAllStatus){
  952. check=true
  953. }else{
  954. check=false
  955. }
  956. }
  957. if(check){
  958. this.tableDataCheckedList = [...this.tableDataCheckedList,...this.tableDataIds]
  959. }else{
  960. this.tableDataCheckedList = this.tableDataCheckedList.filter(it => !this.tableDataIds.includes(it))
  961. }
  962. },
  963. adjustSelection(){
  964. this.selectionReactCancel=true
  965. if(!this.checkAllStatus){
  966. this.tableDataCheckedList.map(it =>{
  967. let row = this.list.find(da => da.EdbInfoId==it)
  968. if(row){
  969. setTimeout(()=>{
  970. this.$refs.edbDataRef.toggleRowSelection(row,true)
  971. },10)
  972. }
  973. })
  974. }else{
  975. this.$refs.edbDataRef.toggleAllSelection()
  976. this.tableDataCheckedList.map(it =>{
  977. let row = this.list.find(da => da.EdbInfoId==it)
  978. if(row){
  979. setTimeout(()=>{
  980. this.$refs.edbDataRef.toggleRowSelection(row,false)
  981. },50)
  982. }
  983. })
  984. }
  985. setTimeout(()=>{
  986. this.selectionReactCancel=false
  987. },50)
  988. },
  989. filterEdbAuth(row) {
  990. return row.HaveOperaAuth
  991. }
  992. },
  993. }
  994. </script>
  995. <style lang="scss">
  996. .batch-computed-dialog{
  997. max-width: 1200px;
  998. width:90vw;
  999. overflow: hidden;
  1000. }
  1001. .batch-computed-wrap{
  1002. .type-wrap{
  1003. display: flex;
  1004. }
  1005. .table-wrap{
  1006. margin-top: 20px;
  1007. display: flex;
  1008. justify-content: space-between;
  1009. .left-box{
  1010. width: 50%;
  1011. }
  1012. .right-box{
  1013. flex: 1;
  1014. flex-shrink: 0;
  1015. }
  1016. }
  1017. }
  1018. </style>