databaseList.vue 67 KB

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