databaseList.vue 64 KB

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