updateDialog.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503
  1. <template>
  2. <el-dialog :visible.sync="isUpdate" :close-on-click-modal="false" :modal-append-to-body="false" :append-to-body="true"
  3. @close="cancelHandle" custom-class="update-dialog" :show-close="false" center width="1230px" top="8vh" v-dialogDrag>
  4. <i class="el-icon-close close-icon" @click="cancelHandle"></i>
  5. <div class="dialog-header">
  6. <h3 class="title">当前更新情况:</h3>
  7. <ul class="total-source" v-if="totalUpdateData">
  8. <li class="source-item" v-for="item in updateOptons" :key="item.name">
  9. <span class="source-name">{{ item.name }}</span>
  10. <span><strong class="large_txt">{{ Number(totalUpdateData[item.update] + totalUpdateData[item.noupdate])||0
  11. }}</strong>个指标</span>
  12. <span>今日已更新<strong class="large_txt">{{
  13. totalUpdateData[item.update]||0
  14. }}</strong></span>
  15. <span class="deletesty">未更新<strong class="large_txt deletesty">{{
  16. totalUpdateData[item.noupdate]||0
  17. }}</strong></span>
  18. </li>
  19. </ul>
  20. </div>
  21. <div class="dialog-main">
  22. <div class="main-top">
  23. <el-form ref="diaForm" label-position="left" label-width="80px" inline :model="filterForm">
  24. <el-form-item label="更新状态" prop="state">
  25. <el-select v-model="filterForm.state" placeholder="更新状态" style="width: 250px">
  26. <el-option v-for="item in stateArr" :key="item.label" :label="item.label" :value="item.value">
  27. </el-option>
  28. </el-select>
  29. </el-form-item>
  30. <el-form-item label="数据来源" prop="source">
  31. <el-select v-model="filterForm.source" placeholder="数据来源" style="width: 250px" clearable>
  32. <el-option v-for="item in sourceArr" :key="item.label" :label="item.label" :value="item.value">
  33. </el-option>
  34. </el-select>
  35. </el-form-item>
  36. </el-form>
  37. <el-button type="primary" @click="updateHandle">一键更新</el-button>
  38. </div>
  39. <div class="main-bottom">
  40. <h3 class="editsty" style="margin-bottom: 10px;">共筛选出{{ total }}个指标</h3>
  41. <el-table ref="updateTable" :data="tableData" height="450" @scroll.native="scrollHandle" border>
  42. <el-table-column v-for="item in tableColums" :key="item.label" :label="item.label" align="center">
  43. <template slot-scope="scope">
  44. <span v-if="item.key == 'IsUpdate'" :class="{ 'deletesty': scope.row[item.key] === 1 }">{{
  45. scope.row[item.key]
  46. === 1 ? '未更新' : '已更新'
  47. }}</span>
  48. <span v-else>{{ scope.row[item.key] }}</span>
  49. </template>
  50. </el-table-column>
  51. <div slot="empty" style="padding:40px 0 120px;">
  52. <tableNoData text="暂无指标" size="mini"/>
  53. </div>
  54. </el-table>
  55. </div>
  56. </div>
  57. </el-dialog>
  58. </template>
  59. <script>
  60. import { dataBaseInterface } from '@/api/api.js';
  61. export default {
  62. name: '',
  63. props: {
  64. isUpdate: {
  65. type: Boolean,
  66. },
  67. },
  68. watch: {
  69. isUpdate(newval) {
  70. if (newval) {
  71. this.getTotal();
  72. this.getDataList();
  73. this.getTargetSource();
  74. this.$nextTick(() => {
  75. this.loadMoveHandler();
  76. })
  77. };
  78. },
  79. filterForm: {
  80. handler() {
  81. this.page_no = 1;
  82. this.$refs.updateTable.bodyWrapper.scrollTop = 0;
  83. this.getDataList();
  84. },
  85. deep: true
  86. }
  87. },
  88. data() {
  89. return {
  90. updateOptons: [
  91. {
  92. name: 'wind',
  93. update: 'WindUpdate',
  94. noupdate: 'WindNotUpdate',
  95. },
  96. {
  97. name: '隆众',
  98. update: 'LzUpdate',
  99. noupdate: 'LzNotUpdate',
  100. },
  101. {
  102. name: '计算指标',
  103. update: 'CalculateUpdate',
  104. noupdate: 'CalculateNotUpdate',
  105. },
  106. {
  107. name: '同花顺',
  108. update: 'ThsUpdate',
  109. noupdate: 'ThsNotUpdate',
  110. },
  111. {
  112. name: 'SMM',
  113. update: 'SmmUpdate',
  114. noupdate: 'SmmNotUpdate',
  115. },
  116. {
  117. name: '手工指标',
  118. update: 'ManualUpdate',
  119. noupdate: 'ManualNotUpdate',
  120. },
  121. {
  122. name: '彭博',
  123. update: 'PbUpdate',
  124. noupdate: 'PbNotUpdate',
  125. },
  126. {
  127. name: "彭博财务",
  128. update: 'PbFinanceUpdate',
  129. noupdate: 'PbFinanceNotUpdate',
  130. },
  131. {
  132. name: 'Mysteel',
  133. update: 'MysteelUpdate',
  134. noupdate: 'MysteelNotUpdate',
  135. },
  136. {
  137. name: '路透',
  138. update: 'LtUpdate',
  139. noupdate: 'LtNotUpdate',
  140. },
  141. {
  142. name: "郑商所",
  143. update: 'ZzUpdate',
  144. noupdate: 'ZzNotUpdate',
  145. },
  146. {
  147. name: "大商所",
  148. update: 'DlUpdate',
  149. noupdate: 'DlNotUpdate',
  150. },
  151. {
  152. name: "上期所",
  153. update: 'ShUpdate',
  154. noupdate: 'ShNotUpdate',
  155. },
  156. {
  157. name: "中金所",
  158. update: 'CffexUpdate',
  159. noupdate: 'CffexNotUpdate',
  160. },
  161. {
  162. name: "上期能源",
  163. update: 'ShfeUpdate',
  164. noupdate: 'ShfeNotUpdate',
  165. },
  166. {
  167. name: "欧洲天然气",
  168. update: 'GieUpdate',
  169. noupdate: 'GieNotUpdate',
  170. },
  171. {
  172. name: "煤炭市场网",
  173. update: 'CoalUpdate',
  174. noupdate: 'CoalNotUpdate',
  175. },
  176. {
  177. name: "our world in data",
  178. update: 'GoogleTravelUpdate',
  179. noupdate: 'GoogleTravelNotUpdate',
  180. },
  181. {
  182. name: "EIA STEO报告",
  183. update: 'EiaSteoUpdate',
  184. noupdate: 'EiaSteoNotUpdate',
  185. },
  186. {
  187. name:"UN",
  188. update:'UNUpdate',
  189. noupdate:'UNNotUpdate'
  190. },{
  191. name:"卓创数据(红桃3)",
  192. update:'SciUpdate',
  193. noupdate:'SciNotUpdate'
  194. },
  195. {
  196. name:"百川盈孚",
  197. update:'BaiinfoUpdate',
  198. noupdate:'BaiinfoNotUpdate'
  199. },
  200. {
  201. name:"国家统计局",
  202. update:'NationalStatisticsUpdate',
  203. noupdate:'NationalStatisticsNotUpdate'
  204. },
  205. {
  206. name:"富宝数据",
  207. update:'FubaoUpdate',
  208. noupdate:'FubaoNotUpdate'
  209. }
  210. ],
  211. totalUpdateData: null,
  212. total: 0,
  213. filterForm: {
  214. state: 1,
  215. source: ''
  216. },
  217. stateArr: [
  218. {
  219. label: '未更新',
  220. value: 1,
  221. },
  222. {
  223. label: '已更新',
  224. value: 2,
  225. },
  226. ], //状态options
  227. sourceArr: [
  228. {
  229. label: 'wind',
  230. value: 2
  231. },
  232. {
  233. label: '同花顺',
  234. value: 1
  235. },
  236. {
  237. label: '彭博',
  238. value: 3
  239. },
  240. {
  241. label: '彭博财务',
  242. value: 28
  243. },
  244. {
  245. label: '手工指标',
  246. value: 9
  247. },
  248. {
  249. label: '隆众指标',
  250. value: 10
  251. },
  252. {
  253. label: 'SMM',
  254. value: 11
  255. },
  256. {
  257. label: 'Mysteel',
  258. value: 15
  259. },
  260. {
  261. label: '路透',
  262. value: 25
  263. },
  264. {
  265. label: '煤炭市场网',
  266. value: 26
  267. },
  268. {
  269. label: '计算指标',
  270. value: 99
  271. },
  272. {
  273. label: 'our world in data',
  274. value: 29
  275. },
  276. {
  277. label: "EIA STEO报告",
  278. value: '36',
  279. },
  280. {
  281. label:'UN',
  282. value:38
  283. },
  284. {
  285. label:'卓创数据(红桃3)',
  286. value:41
  287. },
  288. {
  289. label:'百川盈孚',
  290. value:57
  291. },
  292. {
  293. label:'国家统计局',
  294. value:60
  295. },
  296. {
  297. label:'富宝数据',
  298. value:71
  299. }
  300. ],
  301. tableData: [],//表格数据
  302. page_no: 1,
  303. tableColums: [
  304. {
  305. label: '指标名称',
  306. key: 'EdbName'
  307. },
  308. {
  309. label: '最新日期',
  310. key: 'LatestDate'
  311. },
  312. {
  313. label: '数据来源',
  314. key: 'SourceName'
  315. },
  316. {
  317. label: '更新状态',
  318. key: 'IsUpdate'
  319. },
  320. {
  321. label: '更新时间',
  322. key: 'ModifyTime'
  323. },
  324. ],//表格列
  325. };
  326. },
  327. methods: {
  328. /* 更新统计 */
  329. getTotal() {
  330. dataBaseInterface.updateStatistical()
  331. .then(res => {
  332. if (res.Ret !== 200) return;
  333. this.totalUpdateData = res.Data;
  334. })
  335. },
  336. /* 获取表格数据 */
  337. getDataList() {
  338. dataBaseInterface.updateData({
  339. Status: this.filterForm.state,
  340. Source: this.filterForm.source,
  341. PageSize: 20,
  342. CurrentIndex: this.page_no
  343. }).then(res => {
  344. if (res.Ret !== 200) return;
  345. res.Data.List = res.Data.List || [];
  346. this.total = res.Data.Total;
  347. this.haveMore = this.page_no < res.Data.Paging.Pages ? true : false;
  348. this.tableData = this.page_no === 1 ? res.Data.List : [...this.tableData, ...res.Data.List];
  349. })
  350. },
  351. async updateHandle() {
  352. const { Data } = await dataBaseInterface.updateCheck();
  353. Data === 2
  354. ? await this.$confirm('本次更新将持续30分钟左右,是否确认更新?', '提示', {
  355. type: 'warning'
  356. }).then(() => {
  357. dataBaseInterface.edbUpdate();
  358. }).catch(() => {
  359. })
  360. : await this.$confirm('当前正在更新中,请勿重复点击', '提示', {
  361. type: 'warning',
  362. showCancelButton: false,
  363. })
  364. },
  365. init() {
  366. this.page_no = 1;
  367. this.filterForm.state = 1;
  368. },
  369. /* 滚动监听 */
  370. loadMoveHandler() {
  371. let dom = this.$refs.updateTable.bodyWrapper;
  372. dom.addEventListener("scroll", _.throttle(() => {
  373. const scroll = dom.scrollHeight - dom.scrollTop - dom.clientHeight;
  374. if (scroll <= 1 && this.haveMore) {
  375. this.page_no++;
  376. this.getDataList();
  377. }
  378. }, 300));
  379. },
  380. cancelHandle() {
  381. this.init();
  382. this.$emit('cancel');
  383. },
  384. getTargetSource(){
  385. this.sourceArr = []
  386. dataBaseInterface.getDataSource({IsBase:1}).then(res=>{
  387. if(res.Ret!==200) return
  388. if(res.Data){
  389. this.sourceArr = res.Data.map(i=>{
  390. return {
  391. label:i.SourceName,
  392. value:i.EdbSourceId
  393. }
  394. })
  395. }
  396. })
  397. }
  398. },
  399. created() { },
  400. mounted() {
  401. //this.getTargetSource()
  402. },
  403. };
  404. </script>
  405. <style lang="scss">
  406. .update-dialog {
  407. border-radius: 10px;
  408. $strong: 18px;
  409. .el-dialog__header {
  410. background-color: #fff;
  411. /* padding: 0; */
  412. }
  413. .el-dialog__body {
  414. padding: 0 25px 30px;
  415. max-height: calc(100vh - 150px);
  416. overflow-y: auto;
  417. }
  418. .el-table th.is-leaf {
  419. background-color: #409EFF !important;
  420. color: #fff;
  421. }
  422. .el-form-item {
  423. margin-bottom: 0;
  424. }
  425. .close-icon {
  426. font-size: 24px;
  427. position: absolute;
  428. right: 30px;
  429. top: 28px;
  430. cursor: pointer;
  431. }
  432. .dialog-header {
  433. display: flex;
  434. padding-bottom: 10px;
  435. border-bottom: 1px solid #dcdfe6;
  436. .title {
  437. width: 120px;
  438. margin-right: 10px;
  439. }
  440. .total-source {
  441. display: flex;
  442. width: 90%;
  443. flex-wrap: wrap;
  444. .large_txt {
  445. font-size: $strong;
  446. color: #3385ff;
  447. &.deletesty {
  448. color: #f00;
  449. }
  450. }
  451. .source-item {
  452. min-width: 300px;
  453. display: flex;
  454. margin-right: 30px;
  455. margin-bottom: 10px;
  456. &:nth-child(2n) {
  457. margin-right: 0;
  458. }
  459. span {
  460. margin-right: 5px;
  461. min-width: 120px;
  462. }
  463. .source-name {
  464. // width: 80px;
  465. font-weight: 600;
  466. }
  467. }
  468. }
  469. }
  470. .dialog-main {
  471. padding: 20px 0 30px;
  472. .main-top {
  473. display: flex;
  474. justify-content: space-between;
  475. margin-bottom: 20px;
  476. }
  477. }
  478. }
  479. </style>