databaseList.vue 66 KB

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