batchComputedV2.vue 36 KB

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