databaseList.vue 65 KB

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