databaseList.vue 68 KB

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