databaseList.vue 62 KB

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