databaseList.vue 69 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419
  1. <template>
  2. <div class="database_container">
  3. <div class="database_top">
  4. <div class="top-left">
  5. <el-button v-permission="permissionBtn.edbDataPermission.edbData_addEdb"
  6. type="primary" @click="addHandler">添加指标</el-button>
  7. <el-button v-permission="permissionBtn.edbDataPermission.edbData_calcuEdb"
  8. type="primary" @click="addComputedHandler">计算指标</el-button>
  9. <el-button v-permission="permissionBtn.edbDataPermission.edbData_replaceEdb"
  10. type="primary" @click="replaceEdbHandler">替换指标</el-button>
  11. <el-button v-permission="permissionBtn.edbDataPermission.edbData_codeRun"
  12. type="primary" @click="$router.push({path: '/codecount'})">代码运算</el-button>
  13. <el-button v-permission="permissionBtn.edbDataPermission.edbData_dataAdjust"
  14. type="primary" @click="$router.push({path: '/adjustdata'})">数据调整</el-button>
  15. <!-- <el-button v-permission="permissionBtn.edbDataPermission.edbData_batchUpdate"
  16. type="primary" plain @click="updateHandler">一键刷新</el-button> -->
  17. </div>
  18. <div class="top-right">
  19. <change-lang v-permission="permissionBtn.edbDataPermission.edbData_switchEn"
  20. :lang="currentLang" style="height: 32px;" @changeLang="changeLanguage"/>
  21. <el-select
  22. v-model="search_txt"
  23. v-loadMore="searchLoad"
  24. ref="searchRef"
  25. :filterable="!search_txt"
  26. remote
  27. clearable
  28. placeholder="指标ID/指标名称"
  29. style="width: 260px;"
  30. :remote-method="searchHandle"
  31. @click.native="inputFocusHandle"
  32. >
  33. <i slot="prefix" class="el-input__icon el-icon-search"></i>
  34. <el-option
  35. v-for="item in searchOptions"
  36. :key="item.EdbInfoId"
  37. :label="currentLang==='en'?(item.EdbNameEn||item.EdbName):item.EdbName"
  38. :value="item.EdbInfoId"
  39. >
  40. </el-option>
  41. </el-select>
  42. </div>
  43. </div>
  44. <div class="database-label">
  45. <edb-label-list
  46. :currentLang="currentLang"
  47. :labelList="labelList"
  48. :activeLabelId="select_node"
  49. @clickLabel="changeCurrentLabel"
  50. @deleteLabel="deleteLabel"
  51. @moveLabel="({oldIndex,newIndex})=>{labelList[oldIndex] = labelList.splice(newIndex, 1, labelList[oldIndex])[0];}"
  52. />
  53. </div>
  54. <div class="database_main box" id="box" v-if="showData">
  55. <!-- 展开收起目录按钮 -->
  56. <span
  57. v-show="!isMainLeftShow"
  58. class="slide-btn-icon slide-right"
  59. @click="isMainLeftShow = !isMainLeftShow"
  60. >
  61. <i :class="{'el-icon-d-arrow-left':isMainLeftShow,'el-icon-d-arrow-right':!isMainLeftShow}"></i>
  62. </span>
  63. <!-- <target-tree /> -->
  64. <div class="main-left left" id="left" v-show="isMainLeftShow">
  65. <div class="tree-cont">
  66. <div class="target_tree">
  67. <el-tree
  68. ref="menuTree"
  69. :data="treeData"
  70. node-key="UniqueCode"
  71. :props="defaultProp"
  72. :allow-drag="canDragHandle"
  73. :allow-drop="canDropHandle"
  74. :current-node-key="select_node"
  75. :default-expanded-keys="defaultShowNodes"
  76. :draggable="isEdbBtnShow('moveCatalog')"
  77. :expand-on-click-node="false"
  78. check-strictly
  79. empty-text="暂无目录"
  80. lazy
  81. :load="getLazyTreeData"
  82. @node-expand="handleNodeExpand"
  83. @node-collapse="handleNodeCollapse"
  84. @current-change="nodeChange"
  85. @node-drop="dropOverHandle"
  86. @node-drag-end="dropMouseLeave"
  87. @node-drag-leave="dropMouseLeave"
  88. @node-drag-enter="dropMouseOver"
  89. >
  90. <span
  91. class="custom-tree-node"
  92. slot-scope="{ node, data }"
  93. >
  94. <el-input
  95. ref="editVal"
  96. style="width: 90px"
  97. placeholder="请输入值"
  98. class="label-input"
  99. v-model="new_label"
  100. v-if="data.isEdit&&isEdbBtnShow('editCatalog')"
  101. @blur="changeValue(node, data)"
  102. />
  103. <span
  104. @dblclick.stop="editNodeLabel(node, data)"
  105. v-else
  106. class="text_oneLine node_label"
  107. :style="`width:${(select_node === data.UniqueCode && node.Nodewidth) || ''}`"
  108. :id="`node${data.UniqueCode}`"
  109. >
  110. <span>{{ currentLang==='en' ? (data.ClassifyNameEn||data.ClassifyName) : data.ClassifyName }}</span>
  111. </span>
  112. <span
  113. style="display: flex; align-items: center"
  114. v-if="select_node === data.UniqueCode"
  115. >
  116. <img
  117. src="~@/assets/img/data_m/move_ico.png"
  118. alt=""
  119. style="width: 14px; height: 14px; margin-right: 8px"
  120. v-if="data.Button.MoveButton&&isEdbBtnShow('moveCatalog')"
  121. />
  122. <!-- 添加子项 -->
  123. <img
  124. src="~@/assets/img/set_m/add.png"
  125. alt=""
  126. style="width: 14px; height: 14px; margin-right: 8px"
  127. @click.stop="addNode(node,data)"
  128. v-if="data.Button.AddButton&&isEdbBtnShow('editCatalog')&&node.level<6"
  129. />
  130. <!-- 编辑节点 如果是分类,判断data.Button.OpButton不变;如果是指标,不显示(ETA1.0.3) -->
  131. <img
  132. src="~@/assets/img/set_m/edit.png"
  133. alt=""
  134. style="width: 15px; height: 14px; margin-right: 8px"
  135. @click.stop="editNode(node,data)"
  136. v-if="!data.EdbCode&&(data.Button.OpButton)&&isEdbBtnShow('editCatalog')"
  137. />
  138. <!-- 删除节点 如果是分类,判断data.Button.DeleteButton不变;如果是指标,不显示(ETA1.0.3) -->
  139. <img
  140. slot="reference"
  141. src="~@/assets/img/set_m/del.png"
  142. alt=""
  143. style="width: 14px; height: 14px;"
  144. @click.stop="removeNode(node,data)"
  145. v-if="!data.EdbCode&&(data.Button.DeleteButton)&&isEdbBtnShow('deleteCatalog')"
  146. />
  147. <!-- 查看计算指标 -->
  148. <i class="el-icon-view"
  149. v-if="data.EdbType===2&&![58,59,67,68,74].includes(data.Source)&&isEdbBtnShow('checkCalcChart')"
  150. @click.stop="viewNode(node,data)"></i>
  151. <!-- 查看关联图表 -->
  152. <img
  153. v-if="data.Button.ShowChartRelation&&isEdbBtnShow('checkRelatedChart')"
  154. @click.stop="showAssociateChart=true,showAssociateComputeData=false"
  155. src="~@/assets/img/icons/associate_chart.png"
  156. style="width: 14px; height: 14px;margin-left: 8px"
  157. alt=""
  158. />
  159. <!-- 查看关联指标 -->
  160. <img
  161. v-if="data.Button.ShowEdbRelation&&isEdbBtnShow('checkRelatedEdb')"
  162. @click.stop="showAssociateComputeData=true,showAssociateChart=false"
  163. src="~@/assets/img/icons/associate_data.png"
  164. style="width: 14px; height: 14px;margin-left: 8px"
  165. alt=""
  166. />
  167. </span>
  168. </span>
  169. </el-tree>
  170. </div>
  171. <div class="noDepart" @click="addLevelOneHandle" v-if="CanOpClassify&&isEdbBtnShow('editCatalog')">
  172. <img
  173. src="~@/assets/img/set_m/add_ico.png"
  174. alt=""
  175. style="width: 16px; height: 16px; margin-right: 10px"
  176. />
  177. <span>添加一级目录</span>
  178. </div>
  179. </div>
  180. <span class="move-btn resize" v-drag id="resize" @mousemove="dynamicNode&&resetNodeStyle(dynamicNode)">
  181. </span>
  182. <span
  183. v-show="isMainLeftShow"
  184. class="slide-btn-icon slide-left"
  185. @click="isMainLeftShow = !isMainLeftShow"
  186. >
  187. <i :class="{'el-icon-d-arrow-left':isMainLeftShow,'el-icon-d-arrow-right':!isMainLeftShow}"></i>
  188. </span>
  189. </div>
  190. <!-- 指标关联图模块 -->
  191. <div class="main-right right" id="right" style="background:transparent;border:none;box-shadow:none" v-if="showAssociateChart">
  192. <dataAssociateChart :edbInfoId="selected_edbid"></dataAssociateChart>
  193. </div>
  194. <div class="main-right right" id="right" style="background:transparent;border:none;box-shadow:none;padding-top: 30px;box-sizing: border-box;" v-if="showAssociateComputeData">
  195. <dataAssociateComputeData :edbInfoId="selected_edbid"></dataAssociateComputeData>
  196. </div>
  197. <!-- 指标图表列表 -->
  198. <div class="main-right right list" id="right" v-show="isShowList">
  199. <p>共{{Total||0}}个指标</p>
  200. <div class="list-wrap" ref="listRef" @scroll="loadMoreHandle" v-if="Total">
  201. <div class="chart-list-item-wrap">
  202. <div class="list-item" v-for="item in chartList" :key="item.EdbInfoId">
  203. <div class="header">
  204. <span v-show="currentLang=='ch'">{{ item.EdbName }}</span>
  205. <span v-show="currentLang=='en'">{{ item.EdbNameEn || item.EdbName }}</span>
  206. </div>
  207. <div class="image" @click="detailShowHandle(item)"
  208. :style="item.ChartImage?{background: `no-repeat top/cover url('${item.ChartImage}')`}:{}">
  209. <!-- <img :src="item.ChartImage"/> -->
  210. </div>
  211. <div class="info">
  212. 创建时间:{{item.CreateTime.substring(0,10)}}
  213. </div>
  214. </div>
  215. </div>
  216. </div>
  217. <div v-if="!Total" class="nodata">
  218. <tableNoData text="暂无指标"/>
  219. </div>
  220. </div>
  221. <!-- 指标详情 -->
  222. <div class="main-right right detail-wrap" id="right" v-show="isShowDetail">
  223. <div class="detail">
  224. <div class="header">
  225. <el-tabs v-model="activeTab" @tab-click="rePainChart">
  226. <el-tab-pane label="走势图" name="Chart">
  227. </el-tab-pane>
  228. <el-tab-pane label="数据详情" name="Data">
  229. </el-tab-pane>
  230. </el-tabs>
  231. <div class="edb-tool-icon edb-tool" style="align-items: center;">
  232. <el-button v-if="isEdbBtnShow('update')"
  233. type="text" @click="refreshTargetHandle" >刷新</el-button>
  234. <el-button v-if="isEdbBtnShow('edit')"
  235. type="text" :disabled="!(EdbData.Button.OpButton)"
  236. @click="editNode({},EdbData)">编辑</el-button>
  237. <!-- 指保存指标的上下限,在走势图才显示 -->
  238. <el-button v-if="activeTab==='Chart'&&isEdbBtnShow('saveEdb')"
  239. type="text" @click.stop="saveEdbLimit">保存</el-button>
  240. <el-button v-if="EdbData.EdbType===2&&isEdbBtnShow('toSource')"
  241. type="text" @click="toHistoryPage(selected_edbid,$route.matched);lookEdbId=selected_edbid">指标溯源</el-button>
  242. <el-popover v-if="showPopver"
  243. placement="bottom-end"
  244. trigger="hover"
  245. popper-class="edb-tool-popover"
  246. width="300" style="display: inline-block;">
  247. <div class="edb-tool-wrap">
  248. <el-button v-if="isEdbBtnShow('setEn')"
  249. type="text" @click="openEnNameDia">设置英文名称</el-button>
  250. <el-button v-if="EdbData.Button.InsertNewDataButton&&isEdbBtnShow('newValue')"
  251. type="text" @click.stop="updateNewestDataHandle" >{{(EdbData.DataInsertConfig.Date)?'编辑最新值':'添加最新值'}}</el-button>
  252. <el-button v-if="EdbData.EdbType===2&&isEdbBtnShow('calculateAgain')"
  253. type="text" @click.stop="reCalculateHandler" :loading="calculateLoading">重新计算</el-button>
  254. <el-button v-if="EdbData.EdbType===1&&isEdbBtnShow('refreshAll')"
  255. type="text" @click.stop="refreshBaseHandler" :loading="refreshLoading">全部刷新</el-button>
  256. <el-button v-if="isEdbBtnShow('copyData')"
  257. type="text" @click="copyCode">复制数据</el-button>
  258. <el-button v-if="EdbData.Button.DeleteButton&&isEdbBtnShow('deleteEdb')"
  259. type="text" @click="removeNode(_,EdbData)" style="color:#C54322;">删除</el-button>
  260. </div>
  261. <div class="edb-btn" slot="reference">
  262. <el-button type="text">更多操作</el-button>
  263. <i class="el-icon-more" style="font-size: 14px;transform: rotate(90deg);cursor: pointer;color: #3375e1;"/>
  264. </div>
  265. </el-popover>
  266. </div>
  267. </div>
  268. <div class="container" id="detail-container">
  269. <div class="chart" v-show="activeTab==='Chart'">
  270. <chart-trend-render
  271. :edbid="selected_edbid"
  272. :chartLang="currentLang"
  273. :isShowChartBasis="isEdbBtnShow('showChartBasis')"
  274. :isAllowSwitchSeason="isEdbBtnShow('switchSeason')"
  275. :isAllowEditLimit="isEdbBtnShow('editLimit')"
  276. ref="createChart"
  277. @editEnName="openEnNameDia"/>
  278. <div class="info">
  279. <span>数据来源:{{EdbData.SourceName}}</span>
  280. <span>添加人:{{EdbData.SysUserRealName}}</span>
  281. </div>
  282. <ul class="value-ul"
  283. v-show="showTable&&dataList.length">
  284. <li class="value-item" style="background-color: #EBEFF6;">
  285. <span style="width:240px">日期(频度:{{EdbData.Frequency}})</span>
  286. <span style="flex:1;">值</span>
  287. </li>
  288. <li class="value-item"
  289. v-for="item in dataList.slice(0,3)"
  290. :key="item.EdbDataId">
  291. <span class="value-label date" style="width:240px">
  292. <span style="position: relative;">
  293. <i class="new-tag" v-if="EdbData.LatestDate===item.DataTime"></i>
  294. {{item.DataTime}}
  295. </span>
  296. </span>
  297. <span :class="['value-label',{'predict-act': EdbData.DataInsertConfig.Date===item.DataTime}]" style="flex:1;">
  298. <span :class="['value-style',{'predict-act': EdbData.DataInsertConfig.Date===item.DataTime}]">{{item.Value}}</span>
  299. </span>
  300. </li>
  301. <li class="nodata value-item" v-if="!dataList.length">暂无数据</li>
  302. </ul>
  303. </div>
  304. <div class="list" v-show="activeTab==='Data'">
  305. <edb-detail-data
  306. ref="edb_detail_data"
  307. :current-lang="currentLang"
  308. :table-data="tableData"
  309. :table-colums-one="tableColumsOne"
  310. :table-colums-two="tableColumsTwo"
  311. :data-list="dataList"
  312. :haveMore="haveMore"
  313. @getNextData="()=>{page_no++;getDataList();}"
  314. />
  315. </div>
  316. </div>
  317. </div>
  318. </div>
  319. </div>
  320. <!-- 输入英文指标弹窗 -->
  321. <set-en-name-dia :isOpenDialog="setEnName" @cancel="setEnName=false"
  322. :formData="formItemArray" @updateEnName="updateEnName" cType="ebd" />
  323. <!-- 目录弹窗 -->
  324. <openDialog
  325. :isOpenDialog="isOpenDialog"
  326. :title="dialog_title"
  327. :formData="dialogForm"
  328. @closeDia="isOpenDialog=false"
  329. @sucessCallback="sucessCallback"
  330. />
  331. <!-- 指标弹窗 -->
  332. <addTargetDiaBase
  333. ref="addTargetDiaBase"
  334. :isAddTarget="isAddTarget"
  335. @cancelHandle="isAddTarget = false"
  336. @addSuccessHandle="addTargetSuccess"
  337. />
  338. <!-- 完善指标信息 -->
  339. <completeTargetDia
  340. :isOpenDialog="isComplete"
  341. @cancel="cacelCompleteCallback"
  342. :params="add_params"
  343. @addTargetCallback="addTargetCallback"
  344. />
  345. <!-- 计算指标弹窗 -->
  346. <computedDialog
  347. :isOpenComputed="computed_type === 4"
  348. :title="computedTit"
  349. :calulateForm="calulateForm"
  350. :calulateList="calulateList"
  351. @cancel="computed_type=0"
  352. @addCallBack="addComputedCallBack"
  353. @openPrev="isOpenComputed=true"
  354. @lookHistory="id => {toHistoryPage(id,$route.matched);lookEdbId=id;}"
  355. />
  356. <!-- 计算弹窗控制 -->
  357. <el-dialog
  358. :visible.sync="isOpenComputed"
  359. :close-on-click-modal="false"
  360. :modal-append-to-body='false'
  361. @close="isOpenComputed=false;"
  362. custom-class="dialog-computed"
  363. top="6vh"
  364. center
  365. width="920px"
  366. v-dialogDrag>
  367. <div class="dialog-computed-header">
  368. <el-radio-group v-model="computed_source" size="medium" @change="computed_type = 0">
  369. <el-radio-button :label="1">常规计算</el-radio-button>
  370. <el-radio-button :label="2">批量计算</el-radio-button>
  371. </el-radio-group>
  372. </div>
  373. <ul class="computed-ul">
  374. <li
  375. :class="['cpmputed-li',{'act':item.type === computed_type}]"
  376. v-for="item in computedTypes"
  377. :key="item.type"
  378. @click="changeComputedType(item.type)">
  379. {{item.name}}
  380. <el-popover
  381. placement="top-start"
  382. width="450"
  383. trigger="hover"
  384. v-if="tips.get(item.type)"
  385. >
  386. <p style="padding:20px;line-height:25px;" v-html="tips.get(item.type)"/>
  387. <i slot="reference" class="el-icon-warning-outline"/>
  388. </el-popover>
  389. </li>
  390. </ul>
  391. </el-dialog>
  392. <!-- 转月值 同比 同差 平均值弹窗 -->
  393. <operationDialog
  394. :isOperation="([5,6,7,8,12,13,14,22,35,51,52,61,62,63,75].includes(computed_type) || (computed_type===40&&operationForm.view)) && computed_source===1"
  395. :type="computed_type"
  396. :operationForm="operationForm"
  397. @cancel="computed_type=0"
  398. @addCallBack="addComputedCallBack"
  399. @openPrev="isOpenComputed=true"
  400. @lookHistory="id => {toHistoryPage(id,$route.matched);lookEdbId=id;}"
  401. @changeSource="changeComputedType"
  402. />
  403. <!-- 一键成图弹窗 -->
  404. <!-- <create-chart
  405. :isCreateChart="isCreateChart"
  406. :edbid="selected_edbid"
  407. :chartLang="currentLang"
  408. ref="createChart"
  409. @close="isCreateChart = false"
  410. @editEnName="openEnNameDia"
  411. /> -->
  412. <!-- 一键更新弹窗 -->
  413. <update-dialog
  414. :isUpdate="isUpdate"
  415. @cancel="isUpdate = false"
  416. />
  417. <!-- 替换指标弹窗 -->
  418. <replace-dialog
  419. :isShow="isReplaceDia"
  420. @cancel="isReplaceDia = false"
  421. />
  422. <!-- 拼接弹窗 -->
  423. <joint-target-dia
  424. :isShow="computed_type === 'joint'"
  425. :params="operationForm"
  426. @cancel="computed_type=0"
  427. @addCallBack="addComputedCallBack"
  428. @openPrev="isOpenComputed=true"
  429. />
  430. <!-- 拟合残差弹窗 -->
  431. <fittingResidueDia
  432. :isShow="computed_type === 37 && computed_source===1"
  433. :type="37"
  434. :operationForm="operationForm"
  435. @cancel="computed_type=0"
  436. @addCallBack="addComputedCallBack"
  437. @openPrev="isOpenComputed=true"
  438. />
  439. <!-- 批量计算弹窗 -->
  440. <batchComputedDialog
  441. :isBatchComputed="[6,7,8,12,13,14,5,61,62,63,75].includes(computed_type) && computed_source===2"
  442. :type="computed_type"
  443. @cancel="computed_type=0"
  444. @addCallBack="addComputedCallBack"
  445. @openPrev="isOpenComputed=true"
  446. @lookHistory="id => {toHistoryPage(id,$route.matched);lookEdbId=id;}"
  447. @changeSource="changeComputedType"
  448. />
  449. <!-- 扩散指数弹窗 -->
  450. <diffusionIndexDialog
  451. :isShow="computed_type === 53 && computed_source===1"
  452. :type="computed_type"
  453. :operationForm="operationForm"
  454. @cancel="computed_type=0"
  455. @addCallBack="addComputedCallBack"
  456. @openPrev="isOpenComputed=true"
  457. />
  458. <!-- 添加最新值弹窗 -->
  459. <updateNewestDataDia
  460. :isShow.sync="isUpdateNewestData"
  461. :edbinfo="tableData[0]"
  462. :dataList="dataList"
  463. @success="updateNewest"
  464. />
  465. <!-- 指标历史记录 -->
  466. <!-- <edbHistoryDialog
  467. :isOpenDialog.sync="isLookHistory"
  468. :edbId="lookEdbId"
  469. /> -->
  470. <!-- 指数修匀弹窗 -->
  471. <SmoothEdbDialog
  472. :is-open-smooth="computed_type==='alpha'"
  473. :computed-source="computed_source"
  474. :operationForm="operationForm"
  475. @cancel="computed_type=0"
  476. @openPrev="isOpenComputed=true"
  477. @addCallBack="addComputedCallBack"
  478. @lookHistory="id => {toHistoryPage(id,$route.matched);lookEdbId=id;}"
  479. />
  480. </div>
  481. </template>
  482. <script>
  483. import { dataBaseInterface } from '@/api/api.js';
  484. import { computedTypes,computedBatchTypes,formulaTip } from './databaseComponents/util';
  485. import openDialog from './databaseComponents/openDialog';
  486. import addTargetDiaBase from './databaseComponents/addTargetDiaBase';
  487. import completeTargetDia from './databaseComponents/completeTargetDia'
  488. import computedDialog from './databaseComponents/computedDialog';
  489. import operationDialog from './databaseComponents/operationDialog';
  490. import createChart from './databaseComponents/createChart';
  491. import updateDialog from './databaseComponents/updateDialog';
  492. import replaceDialog from './databaseComponents/replaceDialog';
  493. import jointTargetDia from './databaseComponents/jointTargetDia';
  494. import changeLang from "./components/changeLang.vue"
  495. import setEnNameDia from "./components/setEnNameDia.vue"
  496. import dataAssociateChart from './databaseComponents/dataAssociateChart.vue'
  497. import dataAssociateComputeData from './databaseComponents/dataAssociateComputeData.vue'
  498. import fittingResidueDia from './databaseComponents/fittingResidueDia.vue';
  499. import batchComputedDialog from './databaseComponents/batchComptedDialog.vue';
  500. import diffusionIndexDialog from './databaseComponents/diffusionIndexDia.vue';
  501. import updateNewestDataDia from './databaseComponents/updateNewestDia.vue';
  502. import EdbLabelList from '@/components/edbLabelList.vue';
  503. import chartTrendRender from './databaseComponents/chartTrendRender.vue';
  504. import edbDetailData from './databaseComponents/edbDetailData.vue';
  505. import SmoothEdbDialog from './databaseComponents/smoothEdbDialog.vue';
  506. export default {
  507. name: '',
  508. components: {
  509. openDialog,
  510. addTargetDiaBase,
  511. completeTargetDia,
  512. computedDialog,
  513. operationDialog,
  514. createChart,
  515. updateDialog,
  516. replaceDialog,
  517. jointTargetDia,
  518. changeLang,
  519. setEnNameDia,
  520. dataAssociateChart,
  521. dataAssociateComputeData,
  522. fittingResidueDia,
  523. batchComputedDialog,
  524. diffusionIndexDialog,
  525. updateNewestDataDia,
  526. EdbLabelList,
  527. chartTrendRender,
  528. edbDetailData,
  529. SmoothEdbDialog,
  530. },
  531. directives: {
  532. drag(el, bindings,vnode) {
  533. el.onmousedown = function(e) {
  534. var init = e.clientX;
  535. var box = $("#box")[0]
  536. let total_wid = box.offsetWidth
  537. var left = $("#left")[0];
  538. var right = $("#right")[0];
  539. var initWidth = left.offsetWidth;
  540. document.onmousemove = function(e) {
  541. var end = e.clientX;
  542. if(end > 310){
  543. var newWidth = end - init + initWidth;
  544. right.style.width = total_wid - newWidth + 'px'
  545. left.style.width = newWidth + "px";
  546. }else{
  547. end = 350;
  548. // 最小宽度300
  549. left.style.width = 300 + "px";
  550. // right.style.width = total_wid-300-20 +'px'
  551. }
  552. };
  553. document.onmouseup = function() {
  554. document.onmousemove = document.onmouseup = null;
  555. e.releaseCapture && e.releaseCapture();
  556. //移动结束触发重绘
  557. vnode.context.rePainChart()
  558. };
  559. e.setCapture && e.setCapture();
  560. return false;
  561. };
  562. }
  563. },
  564. data() {
  565. return {
  566. showData: false,
  567. search_txt: '', //搜索词
  568. searchOptions:[],//搜索到的筛选列表
  569. treeData: [], //树形数据
  570. defaultShowNodes:[], //默认展开的节点
  571. defaultProp: {
  572. label: 'ClassifyName',
  573. children: 'Children',
  574. isLeaf:'isLeaf'
  575. },//树结构配置项
  576. tableData: [],
  577. loading:null,
  578. showTable:false,
  579. page_no: 1,
  580. /*表格列 */
  581. tableColumsOne: [
  582. {
  583. label: '指标ID',
  584. key: 'EdbCode',
  585. minwidthsty: '150px'
  586. },
  587. {
  588. label: '指标名称',
  589. key: 'EdbName',
  590. enKey:'EdbNameEn',
  591. inputTip:'点击输入英文指标名称',
  592. minwidthsty: '200px'
  593. },
  594. {
  595. label: '频度',
  596. key: 'Frequency',
  597. enKey:'FrequencyEn',
  598. widthsty: '100px'
  599. },
  600. {
  601. label: '单位',
  602. key: 'Unit',
  603. enKey:'UnitEn',
  604. inputTip:'英文单位',
  605. // minwidthsty: '50px'
  606. widthsty: '100px'
  607. },
  608. {
  609. label: '数据来源',
  610. key: 'SourceName',
  611. widthsty: '160px'
  612. },
  613. ],
  614. tableColumsTwo: [
  615. {
  616. label: '指标目录',
  617. key: 'Menu',
  618. minwidthsty: '150px',
  619. },
  620. {
  621. label: '起始时间',
  622. key: 'StartDate',
  623. minwidthsty: '115px',
  624. },
  625. {
  626. label: '更新时间',
  627. key: 'ModifyTime',
  628. minwidthsty: '120px',
  629. },
  630. {
  631. label: '添加人',
  632. key: 'SysUserRealName',
  633. widthsty: '160px',
  634. }
  635. ],
  636. haveMore: true,
  637. selected_edbid: 0,//选中的指标id
  638. dataList: [],//指标数值
  639. new_label: '',//新的节点label值
  640. select_node:'',//当前选中的节点
  641. /* 新增编辑目录弹窗 */
  642. isOpenDialog:false,
  643. dialog_title: '',
  644. dialogForm:{
  645. level:''
  646. },
  647. /* 新增指标弹窗 */
  648. isAddTarget: false,
  649. /* 完善信息 */
  650. isComplete:false,
  651. add_params:{},
  652. defaultWarn:'请在左侧选择指标',//缺省文字
  653. /* 计算指标弹窗 */
  654. isOpenComputed:false,
  655. computedTit:'',
  656. calulateForm:{},
  657. calulateList:[],
  658. computed_type:0,//打开弹窗的类型
  659. operationForm:{},
  660. dynamicNode:null,
  661. edb_source:0,//指标来源 显示计算按钮
  662. calculateLoading: false,//计算指标刷新loading
  663. refreshLoading: false,//基础指标刷新loading
  664. /* 一键成图弹窗 */
  665. isCreateChart: false,
  666. /* 一键更新弹窗 */
  667. isUpdate:false,
  668. /* 替换指标弹窗 */
  669. isReplaceDia: false,
  670. /* 拼接指标弹窗 */
  671. isJoint: false,
  672. search_page: 1,
  673. search_have_more: false,
  674. current_search:'',
  675. currentLang:'ch', // 语言 ch 中文 en 英文
  676. // -----------------设置英文指标弹窗
  677. setEnName:false,
  678. // 传入的formItem所需内容
  679. formItemArray:[],
  680. // 在哪里更新的英文指标 table(表格上) chart(图表里)
  681. updateType:'table',
  682. // ----------------------
  683. edb_levels:[],//指标的父级分类id
  684. showAssociateChart:false,//显示指标关联的图
  685. showAssociateComputeData:false,//显示指标关联的引用计算指标
  686. tips: formulaTip,//公式说明
  687. computedBatchTypes,
  688. computed_source: 1,//计算类型 1常规 2批量
  689. isBatchComputed: false,//批量计算弹窗
  690. //添加最新值弹窗
  691. isUpdateNewestData: false,
  692. /* 查看历史弹窗 */
  693. isLookHistory: false,
  694. lookEdbId: 0,
  695. labelList:[],//标签列表
  696. CanOpClassify: false,
  697. select_classifyId:0,//指标分类id
  698. PageSize:20,
  699. CurrentIndex:1,
  700. Total:0,
  701. IsListEnd:false,//是不是到底了
  702. chartList:[],
  703. activeTab:'',
  704. activeName:'second',
  705. isMainLeftShow:true,
  706. };
  707. },
  708. watch: {
  709. selected_edbid(newval) {
  710. if(!newval) {
  711. this.tableData = [];
  712. this.dataList = [];
  713. this.defaultWarn = '请在左侧选择指标';
  714. this.activeTab=''
  715. }else {
  716. console.log('new val')
  717. this.activeTab='Chart'
  718. this.initGetData();
  719. }
  720. },
  721. /* 选中搜索指标 展开目录 选中指标 展示数据 */
  722. search_txt(newval) {
  723. if (newval) {
  724. let [search_obj] = this.searchOptions.filter(
  725. (item) => item.EdbInfoId === newval
  726. );
  727. this.page_no = 1;
  728. if(this.$refs.edb_detail_data){
  729. this.$refs.edb_detail_data.$refs.valueUl.scrollTop=0
  730. }
  731. this.select_node = search_obj.UniqueCode;
  732. this.selected_edbid = newval;
  733. }
  734. },
  735. select_classifyId(newval){
  736. if(this.$refs.listRef) this.$refs.listRef.scrollTop = 0;
  737. if(newval){
  738. this.CurrentIndex = 1
  739. this.getEdbChartList()
  740. }
  741. },
  742. isMainLeftShow(newVal){
  743. this.rePainChart()
  744. },
  745. },
  746. computed: {
  747. /* 计算弹窗控制 */
  748. computedTypes() {
  749. return this.computed_source===1 ? computedTypes : computedBatchTypes;
  750. },
  751. role() {
  752. let role = localStorage.getItem('Role') || '';
  753. if (['rai_researcher', 'ficc_researcher', 'researcher','ficc_seller','rai_seller','seller'].includes(role)) {
  754. return 'researcher'
  755. }else if(['rai_admin','ficc_admin'].includes(role)) {
  756. return 'admin'
  757. }
  758. else {
  759. return role;
  760. }
  761. },
  762. /* 登录角色id */
  763. roleId() {
  764. let id = parseInt(localStorage.getItem('AdminId'));
  765. return id;
  766. },
  767. //指标详情,也就是tableData[0]
  768. EdbData(){
  769. return this.tableData[0]?this.tableData[0]:{Button:{},DataInsertConfig:{},DataList:[]}
  770. },
  771. //是否显示指标列表
  772. isShowList(){
  773. return !this.showAssociateChart&&!this.showAssociateComputeData&&!this.selected_edbid
  774. },
  775. //是否显示指标详情
  776. isShowDetail(){
  777. return !this.showAssociateChart&&!this.showAssociateComputeData&&this.selected_edbid
  778. },
  779. //是否显示更多操作
  780. showPopver(){
  781. return this.isEdbBtnShow('setEn')||
  782. this.EdbData.Button.InsertNewDataButton&&this.isEdbBtnShow('newValue')||
  783. this.EdbData.EdbType===2&&this.isEdbBtnShow('calculateAgain')||
  784. this.EdbData.EdbType===1&&this.isEdbBtnShow('refreshAll')||
  785. this.isEdbBtnShow('copyData')||
  786. this.EdbData.Button.DeleteButton&&this.isEdbBtnShow('deleteEdb')
  787. }
  788. },
  789. methods: {
  790. //控制页面按钮权限
  791. isEdbBtnShow(type){
  792. const {edbDataPermission,checkPermissionBtn}=this.permissionBtn
  793. const BtnMap = {
  794. 'update':edbDataPermission.edbData_update,//指标更新
  795. 'edit':edbDataPermission.edbData_edit,//指标编辑
  796. /* 'toImg':edbDataPermission.edbData_toImgs, */
  797. 'copyData':edbDataPermission.edbData_copyData,//复制数据
  798. 'toSource':edbDataPermission.edbData_edbSource,//指标溯源
  799. 'setEn':edbDataPermission.edbData_enNameSetting,//设置英文名称
  800. 'newValue':edbDataPermission.edbData_newestValue,//添加/编辑最新值
  801. 'refreshAll':edbDataPermission.edbData_refreshAll,//全部刷新
  802. 'saveEdb':edbDataPermission.edbData_saveEdb,//保存指标
  803. 'deleteEdb':edbDataPermission.edbData_deleteEdb,//删除指标
  804. 'showChartBasis':edbDataPermission.edbData_showChartBasis,//展示/隐藏同比图
  805. 'switchSeason':edbDataPermission.edbData_switchSeason,//切换季节性图
  806. 'editLimit':edbDataPermission.edbData_editLimit,//编辑上下限
  807. 'calculateAgain':edbDataPermission.edbData_calculateAgain,//重新计算
  808. 'editCatalog':edbDataPermission.edbData_classifyOpt_add,//添加编辑目录
  809. 'deleteCatalog':edbDataPermission.edbData_classifyOpt_delete,//删除目录
  810. 'moveCatalog':edbDataPermission.edbData_classifyOpt_move,//删除目录
  811. 'checkRelatedChart':edbDataPermission.edbData_checkRelatedChart,//查看关联图表
  812. 'checkRelatedEdb':edbDataPermission.edbData_checkRelatedEdb,//查看关联指标
  813. 'checkCalcChart':edbDataPermission.edbData_checkCalcChart,//查看计算指标
  814. }
  815. return checkPermissionBtn(BtnMap[type])
  816. },
  817. /* 获取树分类数据 */
  818. getTreeData(params) {
  819. dataBaseInterface.targetCatalog({ParentId:0}).then(res=>{
  820. if(res.Ret===200){
  821. const arr=res.Data.AllNodes || []
  822. this.treeData=arr.map(item=>{
  823. return {
  824. ...item,
  825. // isLeaf:item.Children.length?false:true
  826. }
  827. })
  828. this.CanOpClassify = res.Data.CanOpClassify;
  829. this.currentLang = res.Data.Language === 'EN' ? 'en' : 'ch';
  830. this.setLangIntoStore()
  831. this.showData = true;
  832. /* 处理树展开和选中图表 */
  833. params && this.selectCurrentNode(params);
  834. !params && this.select_node && this.$refs.menuTree.setCurrentKey(this.select_node);
  835. }
  836. })
  837. },
  838. /* 获取最新的指标 默认展示 */
  839. getNewTargetList: _.throttle(function() {
  840. dataBaseInterface.targetNew().then(res => {
  841. if(res.Ret === 200) {
  842. /* 默认选中 默认指标id */
  843. this.select_node = res.Data ? res.Data.UniqueCode : '';
  844. this.selected_edbid = res.Data ? res.Data.EdbInfoId : 0;
  845. this.getTreeData();
  846. }
  847. })
  848. }),
  849. /* 获取指标数据 */
  850. getDataList: _.throttle(function(type) {
  851. dataBaseInterface.targetList({
  852. PageSize: 20,
  853. CurrentIndex: this.page_no,
  854. EdbInfoId: this.selected_edbid,
  855. // KeyWord: this.search_txt,
  856. }).then(res => {
  857. if(res.Ret === 200) {
  858. this.showTable = true;
  859. if(res.Data) {
  860. // res.Data.Item.ModifyTime = res.Data.Item.ModifyTime.substr(0,10);
  861. let classify_arr = res.Data.ClassifyList || [];
  862. let str = '';
  863. classify_arr.length && classify_arr.reverse().map((item) => str += item.ClassifyName + '/');
  864. this.edb_levels = classify_arr;
  865. this.$set(res.Data.Item,'Menu',str);
  866. this.tableData = [res.Data.Item] || [];
  867. this.edb_source = res.Data.Item.Source;
  868. this.haveMore = this.page_no < res.Data.Paging.Pages ? true : false;
  869. this.dataList = this.page_no === 1 ? (res.Data.Item.DataList || []) : this.dataList.concat(res.Data.Item.DataList);
  870. //将指标添加进标签列表中
  871. const {EdbNameEn,EdbName,EdbInfoId,UniqueCode,ClassifyId}=res.Data.Item
  872. this.addLabel({code:UniqueCode,id:EdbInfoId,classifyId:ClassifyId,EdbName,EdbNameEn})
  873. // 展开目录
  874. this.defaultShowNodes=classify_arr.map(item=>item.UniqueCode)
  875. //设置tree高亮
  876. this.$nextTick(()=>{
  877. setTimeout(() => {
  878. this.$refs.menuTree.setCurrentKey(UniqueCode);
  879. }, 1000);
  880. })
  881. }else {
  882. this.tableData = [];
  883. this.dataList = [];
  884. this.defaultWarn = type=== 'search' ? '未搜索到该指标' : '请在左侧选择指标'
  885. this.$refs.menuTree.setCurrentKey(null)
  886. // 清除当前的label
  887. this.$message.warning('该图表已删除,自动查看下一图表')
  888. this.deleteLabel({code:this.select_node,id:this.selected_edbid,classifyId:''})
  889. }
  890. if(type==='refresh') {
  891. if(this.$refs.edb_detail_data){
  892. this.$refs.edb_detail_data.$refs.valueUl.scrollTop=0
  893. }
  894. }
  895. this.$nextTick(()=>{
  896. const _node = this.$refs.menuTree.getNode(this.select_node)
  897. this.dynamicNode = _node;
  898. this.dynamicNode&&this.resetNodeStyle(this.dynamicNode)
  899. //滚动到高亮位置
  900. setTimeout(() => {
  901. let node = document.getElementById(`node${this.select_node}`)||{}
  902. let parent = document.getElementsByClassName('target_tree')[0];
  903. //parent可视区间:[scrollTop,scrollTop+offsetHeight]
  904. //node位置:node.offsetTop
  905. const overTop = node.offsetTop+node.clientHeight+30<parent.scrollTop
  906. const overBottom = node.offsetTop+node.clientHeight+30>parent.scrollTop+parent.offsetHeight
  907. if(overTop){
  908. parent.scrollTop = node.offsetTop-60
  909. }
  910. if(overBottom){
  911. parent.scrollTop = node.offsetTop - parent.offsetHeight/2
  912. }
  913. },1500)
  914. })
  915. }
  916. })
  917. }),
  918. //获取指标图表列表
  919. getEdbChartList(){
  920. dataBaseInterface.getEdbChartList({
  921. PageSize:this.PageSize,
  922. CurrentIndex:this.CurrentIndex,
  923. ClassifyId:this.select_classifyId,
  924. }).then(res=>{
  925. if(res.Ret!==200) return
  926. if(res.Data){
  927. this.chartList = this.CurrentIndex===1?res.Data.List:[...this.chartList,...res.Data.List]
  928. this.Total = res.Data.Paging.Totals||0
  929. this.IsListEnd = res.Data.Paging.IsEnd
  930. }
  931. })
  932. },
  933. //指标图表列表-加载更多
  934. loadMoreHandle: _.throttle(function() {
  935. let scrollTop = this.$refs.listRef.scrollTop;
  936. let clientHeight = this.$refs.listRef.clientHeight;
  937. let scrollHeight = this.$refs.listRef.scrollHeight;
  938. if(scrollTop + clientHeight >= scrollHeight-210 && !this.IsListEnd){
  939. this.CurrentIndex++;
  940. this.getEdbChartList();
  941. }
  942. },300),
  943. /* 搜索 */
  944. searchHandle(query) {
  945. this.search_page = 1;
  946. this.current_search = query;
  947. this.searchApi(this.current_search)
  948. },
  949. searchApi(query,page=1) {
  950. dataBaseInterface.targetSearchByPage({
  951. KeyWord:query,
  952. CurrentIndex: page
  953. }).then(res => {
  954. if(res.Ret !== 200) return
  955. const { List,Paging } = res.Data;
  956. this.search_have_more = page < Paging.Pages;
  957. this.searchOptions = page === 1 ? List : this.searchOptions.concat(List);
  958. })
  959. },
  960. /* 聚焦获取当前检索 */
  961. inputFocusHandle(e) {
  962. this.search_page = 1;
  963. this.current_search = e.target.value;
  964. this.searchApi(this.current_search);
  965. },
  966. searchLoad() {
  967. if(!this.search_have_more) return;
  968. this.searchApi(this.current_search,++this.search_page);
  969. },
  970. /* 存储中英文状态 */
  971. setLangIntoStore() {
  972. this.$store.commit('edb/SET_LANG',this.currentLang)
  973. },
  974. /* 数值滚动加载 */
  975. scrollHandle: _.throttle(function() {
  976. let scrollTop = this.$refs.valueUl.scrollTop;
  977. let clientHeight = this.$refs.valueUl.clientHeight;
  978. let scrollHeight = this.$refs.valueUl.scrollHeight;
  979. console.log('scrollTop:',scrollTop)
  980. console.log('clientHeight:',clientHeight)
  981. console.log('scrollHeight:',scrollHeight)
  982. if(scrollTop + clientHeight >= scrollHeight-10 && this.haveMore){
  983. this.page_no ++;
  984. this.getDataList();
  985. }
  986. },200),
  987. /* 切换中英文 */
  988. changeLanguage: _.debounce(async function (lang){
  989. this.search_txt = '';
  990. this.currentLang = lang;
  991. await dataBaseInterface.setUserLang({
  992. ConfigCode: 'edb_language',
  993. ConfigValue: lang === 'en' ? 'EN' : 'CN'
  994. })
  995. this.setLangIntoStore()
  996. },200),
  997. // 打开 编辑英文名称弹窗
  998. openEnNameDia(type='table'){
  999. this.updateType = type
  1000. this.formItemArray=[{
  1001. label:'指标名称',
  1002. value:this.tableData[0].EdbName,
  1003. key:'EdbName',
  1004. notEdit:true
  1005. }]
  1006. // 中文单位有 才能编辑英文单位
  1007. if(this.tableData[0].Unit && this.tableData[0].Unit!='无'){
  1008. this.formItemArray.push({
  1009. label:'单位',
  1010. value:this.tableData[0].Unit,
  1011. key:'Unit',
  1012. notEdit:true
  1013. },
  1014. {
  1015. label:'英文指标名称',
  1016. value:this.tableData[0].EdbNameEn,
  1017. key:'EdbNameEn',
  1018. placeholder:'请输入英文指标名称'
  1019. },
  1020. {
  1021. label:'英文单位',
  1022. value:this.tableData[0].UnitEn,
  1023. key:'UnitEn',
  1024. placeholder:'请输入英文单位'
  1025. })
  1026. }else{
  1027. this.formItemArray.push({
  1028. label:'英文指标名称',
  1029. value:this.tableData[0].EdbNameEn,
  1030. key:'EdbNameEn',
  1031. placeholder:'请输入英文指标名称'
  1032. })
  1033. }
  1034. this.setEnName = true
  1035. },
  1036. updateEnName(item){
  1037. let params={
  1038. EdbInfoId: Number(this.selected_edbid),
  1039. ...item
  1040. }
  1041. dataBaseInterface.edbInfoEditEn(params).then(res=>{
  1042. if(res.Ret ==200){
  1043. this.$message({
  1044. message:res.Msg,
  1045. type:"success"
  1046. })
  1047. /* this.tableData[0].EdbNameEn = params.EdbNameEn
  1048. this.tableData[0].UnitEn = params.UnitEn
  1049. // 判断图表英文名称和英文单位是否都有,都有需要打上 英文标记
  1050. console.log(this.tableData[0].EdbNameEn,this.tableData[0].UnitEn);
  1051. if(this.tableData[0].EdbNameEn && (this.tableData[0].UnitEn || this.tableData[0].Unit == '无')){
  1052. this.tableData[0].IsEnEdb=true
  1053. }else{
  1054. this.tableData[0].IsEnEdb=false
  1055. } */
  1056. this.getTreeData()
  1057. this.getDataList()
  1058. if(this.updateType=='chart'){
  1059. // 重绘图表,刷新数据
  1060. this.$refs.createChart.getEdbData()
  1061. }
  1062. this.setEnName = false
  1063. }
  1064. })
  1065. },
  1066. /* 新增指标 */
  1067. addHandler() {
  1068. this.isAddTarget = true;
  1069. },
  1070. /* 完善指标信息 */
  1071. completeTargetHandle(params) {
  1072. this.add_params = params;
  1073. this.isComplete = true;
  1074. },
  1075. /* 新增指标成功回调 */
  1076. addTargetCallback(params) {
  1077. this.$refs.addTargetDiaBase.init();
  1078. this.isComplete = false;
  1079. this.isAddTarget = false;
  1080. this.getTreeData(params);
  1081. this.changeTreeNode()
  1082. // this.getNewTargetList();
  1083. },
  1084. /* 取消新增回调 */
  1085. cacelCompleteCallback() {
  1086. this.isComplete = false
  1087. this.add_params = {}
  1088. },
  1089. /* 节点变化时 */
  1090. nodeChange(data,node) {
  1091. this.search_txt = '';
  1092. this.select_classifyId = !data.EdbInfoId?data.ClassifyId:0;
  1093. this.select_node = data.UniqueCode;
  1094. this.selected_edbid = data.EdbInfoId;
  1095. this.resetNodeStyle(node);
  1096. this.dynamicNode = node;
  1097. this.showAssociateChart=false
  1098. this.showAssociateComputeData=false
  1099. },
  1100. resetNodeStyle: _.debounce(function(node) {
  1101. const tree = $('.target_tree')[0];
  1102. let width = tree.offsetWidth;
  1103. console.log(width)
  1104. // let label_wid = width > 500 ? 'auto' : (width <= 300 && width < 360) ? 100 : 0.7*width;
  1105. let label_wid =
  1106. width > 500
  1107. ? 'auto'
  1108. : width <= 260
  1109. ? 80
  1110. : 0.4 * width;
  1111. this.$set(node, 'Nodewidth', label_wid + 'px');
  1112. },200),
  1113. /* 双击label出现input修改框 */
  1114. editNodeLabel(node, data) {
  1115. //目录名称可以双击修改 指标不能
  1116. if(!data.EdbCode && this.role === 'admin'&&this.isEdbBtnShow('editCatalog')) {
  1117. this.$set(data,'isEdit',true)
  1118. this.new_label = data.ClassifyName;
  1119. this.$nextTick(() => {
  1120. this.$refs.editVal.focus();
  1121. });
  1122. }
  1123. },
  1124. /* input失去焦点恢复node 修改最新的值*/
  1125. changeValue(node, data) {
  1126. if(this.new_label) {
  1127. this.$set(data,'isEdit',false)
  1128. this.new_label !== data.ClassifyName && dataBaseInterface.nodeEdit({
  1129. ClassifyId: data.ClassifyId,
  1130. ClassifyName: this.new_label
  1131. }).then(res => {
  1132. if(res.Ret === 200) {
  1133. this.getTreeData();
  1134. }
  1135. })
  1136. }else {
  1137. this.$message.warning('名称不能为空')
  1138. }
  1139. },
  1140. /* 添加一级目录 */
  1141. addLevelOneHandle() {
  1142. this.dialog_title = '添加';
  1143. this.dialogForm = {
  1144. level_1: '',
  1145. parent_id: '',
  1146. level: 0
  1147. }
  1148. this.isOpenDialog = true;
  1149. },
  1150. // 递归节点
  1151. getNodeParentData(data,arr){
  1152. if(data.level===0) return
  1153. arr.push({classifyName:data.data.ClassifyName,classifyId:data.data.ClassifyId})
  1154. this.getNodeParentData(data.parent,arr)
  1155. return arr
  1156. },
  1157. /* 添加节点 */
  1158. addNode(node,data) {
  1159. console.log(node);
  1160. this.dialog_title = '添加';
  1161. let arr=[]
  1162. arr=this.getNodeParentData(node,arr)
  1163. // console.log(arr);
  1164. /* 添加目录 */
  1165. this.dialogForm = {
  1166. parentArr:arr,
  1167. parent_id: data.ClassifyId,
  1168. level: node.level,
  1169. levelVal:'',
  1170. isEDB:false
  1171. }
  1172. //存储当前要新增子级的目录code
  1173. sessionStorage.setItem('expandCode', data.UniqueCode);
  1174. this.isOpenDialog = true;
  1175. },
  1176. /* 编辑节点 */
  1177. editNode(node,data) {
  1178. // console.log(node);
  1179. this.dialog_title = '编辑';
  1180. if(data.EdbCode) {
  1181. /* 编辑指标 基础弹窗 */
  1182. (data.EdbType===1 || [58,59,67,68,74].includes(data.Source)) && dataBaseInterface.targetDetail({
  1183. EdbInfoId: data.EdbInfoId
  1184. }).then(res => {
  1185. if(res.Ret === 200) {
  1186. // 处理所在目录
  1187. let menuArrId=res.Data.ClassifyList&&res.Data.ClassifyList.map(item=>{
  1188. return item.ClassifyId
  1189. }).reverse()
  1190. this.dialogForm = {
  1191. parentArr:[],
  1192. level: 0,
  1193. levelVal: res.Data.EdbName,
  1194. level_menu:menuArrId||[],
  1195. edbinfo_id: res.Data.EdbInfoId,
  1196. frequency:res.Data.Frequency,
  1197. unit:res.Data.Unit,
  1198. isEDB:true
  1199. }
  1200. this.isOpenDialog = true;
  1201. }
  1202. });
  1203. /* 编辑计算指标 同比同差转月 */
  1204. (data.EdbType === 2 && ![27,40,58,59].includes(data.Source)) && dataBaseInterface.calculateDetail({
  1205. EdbInfoId: data.EdbInfoId
  1206. }).then(res => {
  1207. if(res.Ret === 200) {
  1208. this.setComputedDialogForm(data.Source,res.Data);
  1209. switch (data.Source) {
  1210. case 23:
  1211. case 24:
  1212. this.computed_type = 'joint';
  1213. break
  1214. case 72:
  1215. case 73:
  1216. this.computed_type = 'alpha';
  1217. break
  1218. default:
  1219. this.computed_type = data.Source;
  1220. break
  1221. }
  1222. // this.computed_type = [23,24].includes(data.Source) ? 'joint' : data.Source;
  1223. // this.computed_type = [72,73].includes(data.Source)? 'alpha': data.Source;
  1224. }
  1225. })
  1226. /* 代码运算 */
  1227. data.Source === 27 && this.$router.push({
  1228. path: '/codecount',
  1229. query: {
  1230. edbid: data.EdbInfoId
  1231. }
  1232. })
  1233. /* 数据调整 */
  1234. data.Source === 40 && this.$router.push({
  1235. path: '/adjustdata',
  1236. query: {
  1237. edbid: data.EdbInfoId,
  1238. }
  1239. })
  1240. }else {
  1241. let arr=[]
  1242. arr=this.getNodeParentData(node.parent,arr)
  1243. /* 编辑目录 */
  1244. this.dialogForm = {
  1245. isEDB:false,
  1246. parentArr:arr,
  1247. levelVal: data.ClassifyName||'',
  1248. classify_id: data.ClassifyId,
  1249. level: node.level-1
  1250. }
  1251. this.isOpenDialog = true;
  1252. }
  1253. },
  1254. /* 保存成功 */
  1255. sucessCallback(type) {
  1256. this.isOpenDialog = false;
  1257. this.getTreeData();
  1258. type==='update' && this.getDataList();
  1259. if(type === 'add') {
  1260. //新增分类完成之后,展开父节点显示刚新增的分类,若已展开节点则不做处理
  1261. let code = sessionStorage.getItem('expandCode');
  1262. let flag = this.defaultShowNodes.some((item) => {
  1263. return item === code
  1264. });
  1265. // console.log(flag)
  1266. !flag &&code&& this.defaultShowNodes.push(code);
  1267. sessionStorage.removeItem('expandCode');
  1268. }
  1269. },
  1270. /* 刷新获取指标最新数据 */
  1271. refreshTargetHandle: _.debounce(function() {
  1272. if(this.selected_edbid) {
  1273. this.loading = this.$loading({
  1274. lock: true,
  1275. target:'.detail',
  1276. text: '刷新数据中...',
  1277. spinner: 'el-icon-loading',
  1278. background: 'rgba(255, 255, 255, 0.8)'
  1279. });
  1280. dataBaseInterface.targetRefresh({
  1281. EdbInfoId: this.selected_edbid
  1282. }).then(res => {
  1283. if(res.Ret === 200) {
  1284. this.loading.close();
  1285. this.$message.success(res.Msg);
  1286. this.page_no = 1;
  1287. this.getDataList('refresh')
  1288. }else{
  1289. this.loading.close();
  1290. }
  1291. })
  1292. }
  1293. },500),
  1294. /* 删除节点校验 */
  1295. removeNode(node,data) {
  1296. dataBaseInterface.nodeDelCheck({
  1297. ClassifyId: data.ClassifyId,
  1298. EdbInfoId: data.EdbInfoId
  1299. }).then(res => {
  1300. if(res.Ret === 200) {
  1301. /**
  1302. * 0 可删除
  1303. * 1 关联指标
  1304. * 2 有子目录无指标
  1305. */
  1306. const deleteLabelMap = {
  1307. 1: '该目录关联指标不可删除',
  1308. 2: '确认删除当前目录及包含的子目录吗?',
  1309. 3: '当前指标已用作画图,不可删除',
  1310. 4: res.Data.TipsMsg
  1311. }
  1312. if([1,3,4].includes(res.Data.DeleteStatus)) this.$confirm(
  1313. deleteLabelMap[res.Data.DeleteStatus],
  1314. '删除失败',
  1315. {
  1316. confirmButtonText: '知道了',
  1317. showCancelButton:false,
  1318. type: 'error'
  1319. })
  1320. else if([0,2].includes(res.Data.DeleteStatus)) this.$confirm(
  1321. res.Data.DeleteStatus === 2
  1322. ? deleteLabelMap[res.Data.DeleteStatus]
  1323. : data.EdbCode?'删除后指标和指标值均不可使用,确认删除吗?':'确定删除当前目录吗?',
  1324. '提示',
  1325. {
  1326. confirmButtonText: '确定',
  1327. cancelButtonText: '取消',
  1328. type: 'warning'
  1329. }).then(() => {
  1330. this.delHandle(data.ClassifyId,data.EdbInfoId);
  1331. }).catch(() => {
  1332. });
  1333. }
  1334. })
  1335. },
  1336. /* 删除方法 */
  1337. delHandle(ClassifyId,EdbInfoId) {
  1338. dataBaseInterface.nodeDelete({
  1339. ClassifyId,
  1340. EdbInfoId
  1341. }).then(res => {
  1342. if(res.Ret === 200) {
  1343. this.$message.success(res.Msg);
  1344. this.getTreeData();
  1345. this.selected_edbid = 0;
  1346. this.deleteLabel({code:this.select_node,id:EdbInfoId,classifyId:ClassifyId})
  1347. // this.getNewTargetList();
  1348. }
  1349. })
  1350. },
  1351. /* 判断节点是否能被拖拽 */
  1352. canDragHandle({data}) {
  1353. return data.Button.MoveButton;
  1354. },
  1355. /* 判断节点是否能被拖入 */
  1356. canDropHandle(draggingNode, dropNode, type) {
  1357. let canDrop=false
  1358. // 如果拖动的是指标
  1359. if(draggingNode.data.EdbCode){
  1360. if(!(dropNode.level===1&&type!=='inner')){
  1361. canDrop=true
  1362. }
  1363. }else{//拖动的是目录
  1364. // console.log(dropNode.level,draggingNode.level);
  1365. //目录层级不能改变
  1366. if((dropNode.level+1==draggingNode.level&&type==='inner'&&!dropNode.data.EdbCode)||(dropNode.level===draggingNode.level&&type!=='inner')){
  1367. canDrop=true
  1368. }
  1369. }
  1370. return canDrop
  1371. },
  1372. /* 拖拽完成 */
  1373. dropOverHandle(b,a,i,e) {
  1374. // 被拖拽节点对应的 Node、结束拖拽时最后进入的节点、被拖拽节点的放置位置
  1375. console.log(b,a,i);
  1376. const isEDB=b.data.EdbCode?true:false
  1377. let list=a.parent.childNodes;
  1378. let targetIndex=0,PrevClassifyId=0,NextClassifyId=0,ParentClassifyId=0;
  1379. let ClassifyId=0,EdbInfoId=0,PrevEdbInfoId=0,NextEdbInfoId=0;
  1380. ClassifyId=isEDB?0:b.data.ClassifyId
  1381. EdbInfoId=isEDB?b.data.EdbInfoId:0
  1382. if(i!=='inner'){
  1383. ParentClassifyId=a.parent.data.ClassifyId||0
  1384. list.forEach((item,index)=>{
  1385. if(isEDB){
  1386. if(item.data.EdbInfoId===b.data.EdbInfoId){
  1387. targetIndex=index
  1388. }
  1389. }else{
  1390. if(item.data.ClassifyId===b.data.ClassifyId){
  1391. targetIndex=index
  1392. }
  1393. }
  1394. })
  1395. console.log(targetIndex);
  1396. if(targetIndex===0){
  1397. const data=list[targetIndex+1].data
  1398. NextClassifyId=data.EdbCode?0:data.ClassifyId
  1399. NextEdbInfoId=data.EdbCode?data.EdbInfoId:0
  1400. }else if(targetIndex===list.length-1){
  1401. const data=list[targetIndex-1].data
  1402. PrevClassifyId=data.EdbCode?0:data.ClassifyId
  1403. PrevEdbInfoId=data.EdbCode?data.EdbInfoId:0
  1404. }else{
  1405. const pData=list[targetIndex-1].data
  1406. PrevClassifyId=pData.EdbCode?0:pData.ClassifyId
  1407. PrevEdbInfoId=pData.EdbCode?pData.EdbInfoId:0
  1408. const nData=list[targetIndex+1].data
  1409. NextClassifyId=nData.EdbCode?0:nData.ClassifyId
  1410. NextEdbInfoId=nData.EdbCode?nData.EdbInfoId:0
  1411. }
  1412. }else{
  1413. ParentClassifyId=a.data.ClassifyId||0
  1414. }
  1415. const params={
  1416. ClassifyId,
  1417. ParentClassifyId,
  1418. EdbInfoId,
  1419. PrevClassifyId,
  1420. NextClassifyId,
  1421. PrevEdbInfoId,
  1422. NextEdbInfoId
  1423. }
  1424. console.log(params);
  1425. dataBaseInterface.classifyMoveSort(params).then(res=>{
  1426. if(res.Ret===200){
  1427. this.$message.success('移动成功!')
  1428. }
  1429. this.getTreeData()
  1430. if(this.selected_edbid){
  1431. this.getDataList();
  1432. }
  1433. })
  1434. },
  1435. /* 拖拽覆盖添加背景色 */
  1436. dropMouseOver(node1,node2,e) {
  1437. // console.log(e.layerY);
  1438. // 被拖拽节点对应的 Node、所进入节点对应的 Node、event
  1439. if(!node2.data.EdbInfoId&&(node1.level>node2.level||(node1.data.EdbInfoId>0&&!node2.data.EdbInfoId)) && (e.target.childNodes[0].className.includes('el-tree-node__content')
  1440. || e.target.className.includes('el-tree-node__content'))) {
  1441. // console.log(e.target.childNodes[0])
  1442. e.target.childNodes[0].className.includes('el-tree-node__content')
  1443. ? e.target.childNodes[0].style.backgroundColor = '#409eff'
  1444. : e.target.style.backgroundColor = '#409eff';
  1445. }
  1446. },
  1447. /* 拖拽离开/拖拽完成重置背景色 */
  1448. dropMouseLeave(node1,node2,e) {
  1449. let arrs = $('.el-tree-node__content');
  1450. for( let a of arrs ) {
  1451. a.style.backgroundColor = 'transparent';
  1452. }
  1453. },
  1454. // 树节点展开
  1455. handleNodeExpand (data) {
  1456. // 保存当前展开的节点
  1457. let flag = this.defaultShowNodes.some((item) => item === data.UniqueCode);
  1458. if (!flag) { // 不存在则存到数组里
  1459. this.defaultShowNodes.push(data.UniqueCode)
  1460. }
  1461. },
  1462. // 树节点关闭
  1463. handleNodeCollapse (data) {
  1464. this.defaultShowNodes.some((item, index) => {
  1465. if (item === data.UniqueCode) {
  1466. // 删除关闭节点
  1467. this.defaultShowNodes.length = index
  1468. }
  1469. })
  1470. },
  1471. /* 根据unicode展开树结构并选中指标 */
  1472. selectCurrentNode({ code, id,classifyId }) {
  1473. console.log(code, id,classifyId);
  1474. this.select_node = code;
  1475. this.selected_edbid = id;
  1476. //this.defaultShowNodes=this.findParentNodeForClassifyId(classifyId,code)
  1477. const containerDom = document.getElementById('detail-container')
  1478. containerDom&&(containerDom.scrollTop = 0)
  1479. //滚动到高亮节点位置
  1480. /* this.$nextTick(()=>{
  1481. setTimeout(() => {
  1482. let node = document.getElementById(`node${this.select_node}`)||{}
  1483. let parent = document.getElementsByClassName('tree-cont')[0];
  1484. //console.log('滚动',node,parent);
  1485. if(node.offsetTop > parent.offsetHeight) {
  1486. parent.scrollTop = node.offsetTop - parent.offsetHeight/2
  1487. }
  1488. },400)
  1489. }) */
  1490. },
  1491. // 查找树节点所有父节点
  1492. findParentNodeHandle(arr, id) {
  1493. // 遍历取父级code push数组
  1494. for (let i of arr) {
  1495. if (i.ClassifyId === id) {
  1496. return [i.UniqueCode];
  1497. }
  1498. if (i.Children) {
  1499. let node = this.findParentNodeHandle(i.Children, id);
  1500. if (node) {
  1501. return node.concat(i.UniqueCode);
  1502. }
  1503. }
  1504. }
  1505. },
  1506. // 通过分类id找到指标所属的分类
  1507. findParentNodeForClassifyId(id,code){
  1508. let arr=[]
  1509. this.treeData.forEach(item=>{
  1510. if(item.Children){
  1511. item.Children.forEach(_item=>{
  1512. if(_item.ClassifyId==id){
  1513. arr=[item.UniqueCode,_item.UniqueCode]
  1514. }
  1515. })
  1516. }
  1517. })
  1518. return [...arr,code]
  1519. },
  1520. /* 添加计算指标 */
  1521. addComputedHandler() {
  1522. this.computedTit = '计算指标';
  1523. this.calulateList = [];
  1524. this.calulateForm = {};
  1525. this.operationForm = {};
  1526. this.isOpenComputed = true;
  1527. },
  1528. /* 新增计算指标回调 */
  1529. addComputedCallBack(type, params) {
  1530. this.computed_type = 0;
  1531. this.computed_source = 1;
  1532. this.showAssociateChart=false
  1533. this.showAssociateComputeData=false
  1534. // this.getTreeData();
  1535. type === 'add' ? this.getTreeData(params) : this.getTreeData();
  1536. type === 'edit' && this.initGetData()
  1537. },
  1538. initGetData() {
  1539. this.page_no = 1;
  1540. if(this.$refs.edb_detail_data){
  1541. this.$refs.edb_detail_data.$refs.valueUl.scrollTop=0
  1542. }
  1543. this.getDataList();
  1544. },
  1545. /* 选择计算类型 */
  1546. changeComputedType(type) {
  1547. //保证source的对应关系
  1548. let typeMapSource = {
  1549. 'toMonthSeason': 5,
  1550. 'accumulate': 62
  1551. }
  1552. this.computed_type = typeMapSource[type] || type;
  1553. this.isOpenComputed = false;
  1554. },
  1555. /* 重新计算 */
  1556. reCalculateHandler() {
  1557. this.calculateLoading = true;
  1558. dataBaseInterface.reCalculateTarget({
  1559. EdbInfoId: Number(this.selected_edbid)
  1560. }).then(res => {
  1561. this.calculateLoading = false;
  1562. if(res.Ret !== 200) return;
  1563. this.$message.success(res.Msg);
  1564. this.initDataStatus();
  1565. }).catch(() => {
  1566. this.calculateLoading = false;
  1567. })
  1568. },
  1569. /* 查看计算公式 打开弹窗 */
  1570. viewNode(node,data) {
  1571. const { EdbInfoId,Source } = data;
  1572. //代码运算指标
  1573. if( Source === 27 ) return this.$router.push({
  1574. path: '/codecount',
  1575. query: {
  1576. edbid: EdbInfoId,
  1577. isView: true
  1578. }
  1579. })
  1580. dataBaseInterface.calculateDetail({
  1581. EdbInfoId,
  1582. }).then(res => {
  1583. if(res.Ret !== 200) return
  1584. this.setComputedDialogForm(Source,res.Data,true);
  1585. switch (data.Source) {
  1586. case 23:
  1587. case 24:
  1588. this.computed_type = 'joint';
  1589. break
  1590. case 72:
  1591. case 73:
  1592. this.computed_type = 'alpha';
  1593. break
  1594. default:
  1595. this.computed_type = data.Source;
  1596. break
  1597. }
  1598. })
  1599. },
  1600. /* 设置回显计算指标的表单 */
  1601. setComputedDialogForm(type,res,view=false) {
  1602. //指标运算 or 其他计算类型指标
  1603. // 处理所在目录
  1604. let menuArrId=res.EdbInfoDetail.ClassifyList&&res.EdbInfoDetail.ClassifyList.map(item=>{
  1605. return item.ClassifyId
  1606. }).reverse()
  1607. if( type === 4 ) {
  1608. /* 回显指标和表单 */
  1609. const list = res.CalculateList;
  1610. this.computedTit = view ? '查看计算指标' : '编辑计算指标';
  1611. /* 依赖的指标列表 */
  1612. this.calulateList = list.map(item => {
  1613. return {
  1614. tag: item.FromTag,
  1615. edb_name: item.FromEdbName,
  1616. target: item.FromEdbInfoId,
  1617. start_date: item.StartDate,
  1618. end_date: item.EndDate
  1619. }
  1620. })
  1621. const { EdbInfoId,CalculateFormula,EdbName,Unit,Frequency,EmptyType,MaxEmptyType } = res.EdbInfoDetail;
  1622. /* 公式和表单 */
  1623. this.calulateForm = {
  1624. edb_id: EdbInfoId,
  1625. formula: CalculateFormula,
  1626. menu: menuArrId||[],
  1627. targetName: EdbName,
  1628. unit: Unit,
  1629. frequency: Frequency,
  1630. emptyType: EmptyType,
  1631. maxEmptyType: MaxEmptyType,
  1632. view
  1633. };
  1634. } else {
  1635. let dataInfo = res.EdbInfoDetail;
  1636. let old_edb = res.CalculateList;
  1637. let public_params = {
  1638. edb_id: dataInfo.EdbInfoId,
  1639. targetName: dataInfo.EdbName,
  1640. frequency: dataInfo.Frequency,
  1641. unit: dataInfo.Unit,
  1642. menu: menuArrId||[],
  1643. view
  1644. }
  1645. this.operationForm = [23,24,37,53].includes(type)
  1646. ? {
  1647. ...public_params,
  1648. source: dataInfo.Source,
  1649. date: dataInfo.CalculateFormula,
  1650. pre_edb: type === 23 ? old_edb.find(item => item.FromTag === 'A').FromEdbInfoId : '', //俺也不懂为什么这么定义都是江西老表的锅
  1651. after_edb: type === 23 ? old_edb.find(item => item.FromTag === 'B').FromEdbInfoId : '',
  1652. old_stay_edb: type === 24 ? old_edb.find(item => item.FromTag === 'A').FromEdbInfoId : '',
  1653. concat_edb: type === 24 ? old_edb.find(item => item.FromTag === 'B').FromEdbInfoId : '',
  1654. from_arr: old_edb,
  1655. correlationStr: dataInfo.CorrelationStr
  1656. }
  1657. : {
  1658. ...public_params,
  1659. oldedb_id: old_edb[0].FromEdbInfoId,
  1660. oldEdb_name: old_edb[0].FromEdbName,
  1661. formula: dataInfo.CalculateFormula || '',
  1662. moveType: dataInfo.MoveType,
  1663. moveUnit: dataInfo.MoveFrequency,
  1664. moveVal: type === 22 ? dataInfo.CalculateFormula : '',
  1665. calendar_type: type === 35 ? dataInfo.Calendar : '',
  1666. }
  1667. if([72,73].includes(type)){
  1668. const {EdbName,EdbInfoId,Frequency,Unit,ClassifyId,CalculateFormula} = dataInfo
  1669. this.operationForm = {
  1670. edb_id: EdbInfoId,
  1671. oldedb_id: old_edb[0].FromEdbInfoId,
  1672. oldEdb_name: old_edb[0].FromEdbName,
  1673. EdbName,Frequency,Unit,ClassifyId,Formula:CalculateFormula,
  1674. view
  1675. }
  1676. }
  1677. }
  1678. },
  1679. /* 基础指标刷新 */
  1680. refreshBaseHandler() {
  1681. this.refreshLoading = true;
  1682. this.loading = this.$loading({
  1683. lock: true,
  1684. target:'.detail',
  1685. text: '刷新数据中...',
  1686. spinner: 'el-icon-loading',
  1687. background: 'rgba(255, 255, 255, 0.8)'
  1688. });
  1689. dataBaseInterface.refreshBaseTarget({
  1690. EdbInfoId: Number(this.selected_edbid)
  1691. }).then(res => {
  1692. this.refreshLoading = false;
  1693. this.loading&&this.loading.close()
  1694. if(res.Ret !== 200) return;
  1695. this.$message.success(res.Msg);
  1696. this.initDataStatus();
  1697. }).catch(() => {
  1698. this.refreshLoading = false;
  1699. })
  1700. },
  1701. /* 一键成图 */
  1702. createChartHandle() {
  1703. this.isCreateChart = true;
  1704. },
  1705. /* 重新刷新 重新计算后重置刷数据 */
  1706. initDataStatus() {
  1707. this.page_no = 1;
  1708. if(this.$refs.edb_detail_data){
  1709. this.$refs.edb_detail_data.$refs.valueUl.scrollTop=0
  1710. }
  1711. this.getDataList();
  1712. },
  1713. /* 用于复制指标 */
  1714. async copyCode(){
  1715. const res = await dataBaseInterface.targetList({
  1716. PageSize: 100000,
  1717. CurrentIndex: 1,
  1718. EdbInfoId: this.selected_edbid,
  1719. })
  1720. if (res.Ret===200){
  1721. let arr = res.Data.Item.DataList ||[]
  1722. let str = '日期\t 值\n'
  1723. arr.forEach((item=> str += `${item.DataTime}\t${item.Value}\n`))
  1724. this.$copyText(str).then(
  1725. res => {
  1726. this.$message.success("已成功复制!");
  1727. },
  1728. err => {
  1729. this.$message.error("复制失败!");
  1730. } )
  1731. }
  1732. },
  1733. /* 一键更新 */
  1734. updateHandler() {
  1735. this.isUpdate = true;
  1736. },
  1737. /* 替换指标 */
  1738. async replaceEdbHandler () {
  1739. const { Data } = await dataBaseInterface.replaceCheck();
  1740. Data === 2
  1741. ? this.isReplaceDia = true
  1742. : await this.$confirm('当前正在替换中,请耐心等待', '提示', {
  1743. type: 'warning',
  1744. showCancelButton: false,
  1745. })
  1746. },
  1747. /* 添加最新值 */
  1748. updateNewestDataHandle() {
  1749. this.isUpdateNewestData = true;
  1750. },
  1751. updateNewest(){
  1752. this.initGetData()
  1753. this.rePainChart()
  1754. },
  1755. /* 获取标签列表 */
  1756. getlabelList(){
  1757. const List = JSON.parse(sessionStorage.getItem('database'))||[]
  1758. this.labelList = List
  1759. },
  1760. /* 添加标签 params :{code,id,classifyId,EdbName,EdbNameEn}*/
  1761. addLabel(params){
  1762. const index = this.labelList.findIndex(i=>i.code===params.code)
  1763. //标签已存在列表中,更新标签的值
  1764. if(index!==-1){
  1765. this.labelList.splice(index,1,params)
  1766. return
  1767. }
  1768. //根据页面宽度 判断标签数量是否达到上限
  1769. const listWidth = document.querySelector('.database-label').offsetWidth
  1770. const minWidth=170+20
  1771. const maxNum = Math.floor(listWidth/minWidth)
  1772. if(this.labelList.length>=maxNum){
  1773. //达到上限则挤出第一个,再添加
  1774. this.labelList.shift()
  1775. }
  1776. this.labelList.push(params)
  1777. sessionStorage.setItem('database',JSON.stringify(this.labelList))
  1778. },
  1779. //改变选中标签,
  1780. changeCurrentLabel(params){
  1781. if(params.code!==this.select_node){
  1782. this.selectCurrentNode(params)
  1783. }
  1784. },
  1785. //删除标签
  1786. deleteLabel(params){
  1787. const index = this.labelList.findIndex(i=>i.code===params.code)
  1788. //如果删除的标签是选中状态
  1789. if(this.select_node===params.code){
  1790. //删除的是唯一一个标签
  1791. if(this.labelList.length===1){
  1792. this.selected_edbid=0
  1793. this.select_node = ''
  1794. this.$refs.menuTree.setCurrentKey(null)
  1795. //不是唯一的标签,则默认选中上一个/下一个
  1796. }else{
  1797. index===0&&this.changeCurrentLabel(this.labelList[1])
  1798. index!==0&&index!==-1&&this.changeCurrentLabel(this.labelList[index-1])
  1799. }
  1800. }
  1801. index!==-1&&this.labelList.splice(index,1)
  1802. sessionStorage.setItem('database',JSON.stringify(this.labelList))
  1803. },
  1804. changeTreeNode(){
  1805. this.$refs.menuTree.setCurrentKey(this.select_node);
  1806. this.$nextTick(()=>{
  1807. const _node = this.$refs.menuTree.getCurrentNode()
  1808. this.dynamicNode = _node;
  1809. this.dynamicNode&&this.resetNodeStyle(this.dynamicNode)
  1810. })
  1811. },
  1812. //绑定el-tree的load属性
  1813. async getLazyTreeData (node,resolve){
  1814. if(node.level===0){
  1815. resolve(this.treeData)
  1816. }else{
  1817. let arr=[]
  1818. const res=await dataBaseInterface.targetCatalog({ParentId:node.data.ClassifyId})
  1819. if (res.Ret === 200) {
  1820. const temarr = res.Data.AllNodes || [];
  1821. arr=temarr.map(item=>{
  1822. return {
  1823. ...item,
  1824. isLeaf:item.EdbInfoId?true:false
  1825. }
  1826. })
  1827. }
  1828. resolve(arr)
  1829. }
  1830. },
  1831. //保存指标上下限
  1832. saveEdbLimit(){
  1833. if(!this.$refs.createChart) return
  1834. //获取指标的上下限
  1835. const {MaxValue=0,MinValue=0} = this.$refs.createChart.chartInfo
  1836. dataBaseInterface.saveEdbChartLimit({
  1837. EdbInfoId:this.EdbData.EdbInfoId,
  1838. MaxValue:Number(MaxValue),
  1839. MinValue:Number(MinValue)
  1840. }).then(res=>{
  1841. if(res.Ret!==200) return
  1842. this.$message.success('保存成功')
  1843. this.$refs.createChart.saveEdbImg(this.EdbData)
  1844. this.$refs.createChart.oldOptions = {}
  1845. })
  1846. },
  1847. //重绘指标图表
  1848. rePainChart(){
  1849. if(this.activeTab!=='Chart') return
  1850. this.$nextTick(()=>{
  1851. this.$refs.createChart.getDataByPath()
  1852. })
  1853. },
  1854. /* 展开对应菜单 显示详情 */
  1855. detailShowHandle({ UniqueCode, EdbInfoId,ClassifyId}) {
  1856. let params = {
  1857. code: UniqueCode,
  1858. id: EdbInfoId,
  1859. classifyId:ClassifyId
  1860. };
  1861. this.selectCurrentNode(params);
  1862. this.select_classifyId = 0;
  1863. },
  1864. // 添加wind wsd指标成功
  1865. addTargetSuccess(params){
  1866. this.getTreeData(params);
  1867. }
  1868. },
  1869. //离开页面时保存标签
  1870. beforeRouteLeave(to,from,next){
  1871. sessionStorage.setItem('database',JSON.stringify(this.labelList))
  1872. next()
  1873. },
  1874. mounted() {
  1875. this.getlabelList()
  1876. this.getEdbChartList()
  1877. this.$route.query.code
  1878. ? this.getTreeData({code: this.$route.query.code,id: this.$route.query.id,classifyId:this.$route.query.classifyId})
  1879. : this.getTreeData();
  1880. //离开页面时保存标签
  1881. window.onbeforeunload = ()=>{
  1882. sessionStorage.setItem('database',JSON.stringify(this.labelList))
  1883. }
  1884. },
  1885. destroyed(){
  1886. window.onbeforeunload = null
  1887. }
  1888. };
  1889. </script>
  1890. <style lang="scss">
  1891. @import "~@/styles/theme-vars.scss";
  1892. .database_container {
  1893. $mini_font: 12px;
  1894. $normal_font: 14px;
  1895. .firstColumTable .el-table__empty-block {
  1896. display: none;
  1897. }
  1898. .firstColumTable .el-table__header th:first-child .cell{
  1899. overflow: visible;
  1900. }
  1901. .el-table td,.el-table th {
  1902. padding: 10px 0;
  1903. }
  1904. .el-checkbox__input.is-disabled.is-checked .el-checkbox__inner {
  1905. background-color: $theme-color !important;
  1906. border-color: $theme-color;
  1907. }
  1908. .el-checkbox__input.is-disabled.is-indeterminate .el-checkbox__inner {
  1909. background-color: $theme-color !important;
  1910. border-color: $theme-color;
  1911. }
  1912. .el-icon-refresh {
  1913. font-size: 17px;
  1914. margin-left: 5px;
  1915. cursor: pointer;
  1916. }
  1917. @media screen and (min-width: 1711px) {
  1918. .target_tree {
  1919. font-size: $normal_font;
  1920. }
  1921. }
  1922. @media screen and (max-width: 1710px) {
  1923. .target_tree {
  1924. font-size: $mini_font;
  1925. }
  1926. }
  1927. .database_top {
  1928. display: flex;
  1929. justify-content: space-between;
  1930. align-items: center;
  1931. margin-bottom: 20px;
  1932. padding: 20px 30px;
  1933. background: #fff;
  1934. border: 1px solid #ececec;
  1935. border-radius: 4px;
  1936. box-shadow: 0 3px 6px rgba(0, 0, 0, 0.05);
  1937. .top-right,.top-left{
  1938. display: flex;
  1939. align-items: center;
  1940. gap:20px;
  1941. flex-wrap: wrap;
  1942. .el-button + .el-button{
  1943. margin-left: 0;
  1944. }
  1945. }
  1946. /* .top-left{
  1947. display: flex;
  1948. } */
  1949. }
  1950. .database_main {
  1951. display: flex;
  1952. margin-top: 20px;
  1953. position:relative;
  1954. width:100%;
  1955. overflow-x: auto;
  1956. div::-webkit-scrollbar {
  1957. width: 5px !important;
  1958. }
  1959. .main-left {
  1960. width: 400px;
  1961. min-width: 300px;
  1962. background: #fff;
  1963. margin-right: 20px;
  1964. border: 1px solid #ececec;
  1965. border-radius: 4px;
  1966. box-shadow: 0px 3px 6px rgba(0, 0, 0, 0.05);
  1967. height: calc(100vh - 225px);
  1968. overflow: hidden;
  1969. position: relative;
  1970. box-sizing: border-box;
  1971. .tree-cont {
  1972. padding: 30px 0 30px 30px;
  1973. /* height: calc(100vh - 290px);
  1974. overflow: auto; */
  1975. }
  1976. .target_tree {
  1977. color: #333;
  1978. height: calc(100vh - 350px);
  1979. overflow: auto;
  1980. .label-input .el-input__inner {
  1981. height: 25px;
  1982. line-height: 25px;
  1983. }
  1984. .custom-tree-node {
  1985. display: flex !important;
  1986. justify-content: space-between;
  1987. align-items: center;
  1988. display: block;
  1989. flex: 1;
  1990. .node_label {
  1991. margin-right: 2px;
  1992. }
  1993. .el-icon-view {
  1994. color: #409eff;
  1995. font-size: 18px;
  1996. margin-left: 5px;
  1997. }
  1998. }
  1999. .el-tree__drop-indicator{
  2000. /* position:absolute; */
  2001. /* left:0;
  2002. right:0; */
  2003. height:3px;
  2004. // margin-top: 8px;
  2005. background-color:$theme-color;
  2006. }
  2007. .el-tree-node__content {
  2008. margin-bottom: 14px !important;
  2009. }
  2010. .el-tree-node__children {
  2011. .el-tree-node {
  2012. /* margin-bottom: 8px !important; */
  2013. margin-bottom: 0px !important;
  2014. padding-left: 18px;
  2015. }
  2016. .el-tree-node__content {
  2017. margin-bottom: 5px !important;
  2018. padding-left: 0 !important;
  2019. }
  2020. }
  2021. .expanded.el-icon-caret-right:before {
  2022. content: url('../../assets/img/set_m/down.png') !important;
  2023. }
  2024. .el-icon-caret-right:before {
  2025. content: url('../../assets/img/set_m/slide.png') !important;
  2026. }
  2027. .el-tree-node__expand-icon.is-leaf.el-icon-caret-right:before {
  2028. content: '' !important;
  2029. }
  2030. .el-tree-node__expand-icon.expanded {
  2031. -webkit-transform: rotate(0deg);
  2032. transform: rotate(0deg);
  2033. }
  2034. .el-tree-node.is-current > .el-tree-node__content {
  2035. background-color: #f0f4ff !important;
  2036. }
  2037. .el-tree-node__content {
  2038. padding-right: 10px !important;
  2039. }
  2040. }
  2041. .noDepart {
  2042. margin: 30px 0;
  2043. display: flex;
  2044. align-items: center;
  2045. justify-content: center;
  2046. color: $theme-color;
  2047. font-size: 16px;
  2048. cursor: pointer;
  2049. }
  2050. .move-btn {
  2051. height: 100%;
  2052. width: 4px;
  2053. /* opacity: 0; */
  2054. position: absolute;
  2055. right: 0px;
  2056. top: 0;
  2057. &:hover {
  2058. cursor: col-resize;
  2059. /* background-color: orange */
  2060. }
  2061. }
  2062. }
  2063. .main-right {
  2064. flex: 1;
  2065. /* width:70%; */
  2066. height: calc(100vh - 225px);
  2067. background: #fff;
  2068. border: 1px solid #ececec;
  2069. border-radius: 4px;
  2070. box-shadow: 0px 3px 6px rgba(0, 0, 0, 0.05);
  2071. overflow: hidden;
  2072. .value-ul {
  2073. margin-top: 10px;
  2074. border-bottom: 1px solid #EBEFF6;
  2075. //max-height: calc(100vh - 495px);
  2076. //overflow-y: auto;
  2077. .value-item {
  2078. /* width: 100%; */
  2079. padding: 10px 0;
  2080. border: 1px solid #dcdfe6;
  2081. border-bottom: none;
  2082. display: flex;
  2083. justify-content: space-around;
  2084. >span{
  2085. padding:0 16px;
  2086. box-sizing: border-box;
  2087. }
  2088. .value-label {
  2089. position: relative;
  2090. color: #666;
  2091. .value-style{
  2092. /* background-color: #ECF2FE;
  2093. color: #0052D9; */
  2094. padding:5px;
  2095. border-radius: 4px;
  2096. &.predict-act {
  2097. color: orange;
  2098. }
  2099. }
  2100. &.date{
  2101. &::after{
  2102. content: '';
  2103. position:absolute;
  2104. right:0;
  2105. top:-14px;
  2106. height:calc(100% + 28px);
  2107. width:1px;
  2108. background-color: #dcdfe6;
  2109. }
  2110. }
  2111. }
  2112. .predict-act {
  2113. color: orange;
  2114. }
  2115. .new-tag {
  2116. width: 6px;
  2117. height: 6px;
  2118. display: inline-block;
  2119. position: absolute;
  2120. left: -12px;
  2121. top: 50%;
  2122. transform: translateY(-50%);
  2123. border-radius: 50%;
  2124. background: #f00;
  2125. }
  2126. }
  2127. .nodata {
  2128. text-align: center;
  2129. padding: 40px 0;
  2130. color: #999;
  2131. }
  2132. }
  2133. &.list{
  2134. background-color: transparent;
  2135. box-shadow: none;
  2136. border:none;
  2137. padding-left:30px;
  2138. display: flex;
  2139. flex-direction: column;
  2140. .list-wrap{
  2141. flex: 1;
  2142. margin-top: 20px;
  2143. overflow-y: auto;
  2144. .dragShdow {
  2145. box-shadow: 0 1px 8px rgba(64, 158, 255, 0.8);
  2146. opacity: 0.5;
  2147. }
  2148. .list-item{
  2149. width:23%;
  2150. min-width: 210px;
  2151. background-color: #fff;
  2152. display: flex;
  2153. flex-direction: column;
  2154. box-sizing: border-box;
  2155. border-radius: 4px;
  2156. border:1px solid #DCDFE6;
  2157. box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  2158. .header,.info{
  2159. padding:10px;
  2160. box-sizing: border-box;
  2161. text-align: left;
  2162. }
  2163. .header{
  2164. white-space: nowrap;
  2165. overflow: hidden;
  2166. text-overflow: ellipsis;
  2167. font-size: 16px;
  2168. font-weight: 600;
  2169. box-shadow: 0 3px 6px rgba(37, 37, 239, 0.1);
  2170. }
  2171. .image{
  2172. margin:10px;
  2173. margin-bottom: 0;
  2174. height: 0;
  2175. padding-bottom: 67%;
  2176. cursor: pointer;
  2177. }
  2178. }
  2179. }
  2180. }
  2181. &.detail-wrap{
  2182. overflow-x:auto;
  2183. }
  2184. .detail{
  2185. display: flex;
  2186. flex-direction: column;
  2187. min-width: 780px;
  2188. height:100%;
  2189. >.header{
  2190. display: flex;
  2191. position: relative;
  2192. height: 60px;
  2193. .el-tabs{
  2194. width:200px;
  2195. .el-tabs__header{
  2196. margin-bottom: 0;
  2197. }
  2198. .el-tabs__nav{
  2199. display: flex;
  2200. width: 100%;
  2201. .el-tabs__item{
  2202. flex: 1;
  2203. text-align: center;
  2204. font-size: 16px;
  2205. height: 60px;
  2206. line-height: 60px;
  2207. }
  2208. }
  2209. }
  2210. .edb-tool{
  2211. flex: 1;
  2212. text-align: right;
  2213. display: flex;
  2214. gap: 16px;
  2215. justify-content: flex-end;
  2216. padding-right: 15px;
  2217. position: relative;
  2218. &::after{
  2219. position: absolute;
  2220. content:'';
  2221. width:100%;
  2222. left: 0;
  2223. bottom: 0;
  2224. height:2px;
  2225. background-color: #E4E7ED;
  2226. }
  2227. }
  2228. }
  2229. .container{
  2230. flex: 1;
  2231. overflow-y: auto;
  2232. padding:15px;
  2233. .chart{
  2234. .info{
  2235. display: flex;
  2236. justify-content: space-between;
  2237. }
  2238. .table{
  2239. margin-top: 16px;
  2240. border:1px solid #E7E7E7 ;
  2241. .table-header{
  2242. display: flex;
  2243. padding:6px;
  2244. span{
  2245. flex: 1;
  2246. border-bottom: 1px solid #E7E7E7;
  2247. }
  2248. }
  2249. }
  2250. }
  2251. .list{
  2252. height: 100%;
  2253. }
  2254. }
  2255. }
  2256. }
  2257. .slide-btn-icon{
  2258. &.slide-left{
  2259. right:0;
  2260. }
  2261. &.slide-right{
  2262. left: 0;
  2263. }
  2264. }
  2265. }
  2266. .dialog-computed {
  2267. .el-dialog__header {
  2268. background-color: #fff;
  2269. .el-dialog__close {
  2270. color: #333;
  2271. }
  2272. }
  2273. .computed-ul {
  2274. box-sizing: border-box;
  2275. max-height: 600px;
  2276. height:65vh;
  2277. overflow-y: auto;
  2278. padding: 40px 92px;
  2279. display: flex;
  2280. flex-wrap: wrap;
  2281. .cpmputed-li {
  2282. width: 180px;
  2283. padding: 19px 0;
  2284. height: 60px;
  2285. box-sizing: border-box;
  2286. color: $theme-color;
  2287. font-size: 16px;
  2288. background:#ECF5FF;
  2289. border-radius: 8px;
  2290. border: 1px solid #99baf0;
  2291. text-align: center;
  2292. cursor: pointer;
  2293. margin-right: 65px;
  2294. margin-bottom: 55px;
  2295. &:nth-child(3n) {
  2296. margin-right:0;
  2297. }
  2298. &:hover {
  2299. background: $theme-color;
  2300. color: #fff;
  2301. }
  2302. &.act {
  2303. background: $theme-color;
  2304. color: #fff;
  2305. }
  2306. }
  2307. }
  2308. }
  2309. }
  2310. .edb-tool-popover{
  2311. .edb-tool-wrap{
  2312. display: flex;
  2313. flex-wrap: wrap;
  2314. gap:10px;
  2315. .el-button + .el-button{
  2316. margin-left: 0;
  2317. }
  2318. }
  2319. }
  2320. </style>