selfDataBase.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542
  1. <template>
  2. <div class="selfData-page">
  3. <div class="header">
  4. <div class="left">
  5. <el-select
  6. v-model="filterObj.source"
  7. @change="filterChange"
  8. :placeholder="$t('SelftDataPage.ph_channel')"
  9. clearable
  10. >
  11. <el-option
  12. v-for="item in sourceOptions"
  13. :key="item.EdbBusinessSourceId"
  14. :label="item.SourceName"
  15. :value="item.EdbBusinessSourceId"
  16. />
  17. </el-select>
  18. <el-select
  19. v-model="filterObj.frequency"
  20. @change="filterChange"
  21. :placeholder="$t('Edb.InputHolderAll.input_fre')"
  22. clearable
  23. >
  24. <el-option v-for="item in frequencyOptions" :key="item.val" :label="item.label" :value="item.val"/>
  25. </el-select>
  26. <el-input
  27. v-model="filterObj.keyWord"
  28. :placeholder="$t('Edb.InputHolderAll.input_name_orid')"
  29. style="width: 250px;"
  30. @change="filterChange"
  31. clearable
  32. >
  33. <i slot="prefix" class="el-input__icon el-icon-search"/>
  34. </el-input>
  35. <el-checkbox
  36. v-model="filterObj.checkAll"
  37. :indeterminate="filterObj.checkSome"
  38. :disabled="tableData.length===0"
  39. style="margin-left:20px"
  40. @change="listCheckAllChange"
  41. ><!-- 列表全选 -->{{$t('SystemManage.OperateAuth.all_select')}}</el-checkbox>
  42. </div>
  43. <el-button
  44. v-permission="permissionBtn.dataSourcePermission.selfData_addEdb"
  45. type="primary"
  46. @click="handleCheckEdb('multiple')"
  47. ><!-- 添加到指标库 -->{{$t('YsDataPage.add_base_btn')}}</el-button>
  48. </div>
  49. <div class="main">
  50. <el-table
  51. :data="tableData"
  52. ref="table"
  53. element-loading-text="加载中..."
  54. v-loading="tableLoading"
  55. border
  56. style="margin:20px 0"
  57. @selection-change="selectionChange"
  58. @select="selectHandle"
  59. @select-all="selectAllPageHandle"
  60. @sort-change="handleSortChange"
  61. >
  62. <el-table-column
  63. type="selection"
  64. width="55"
  65. />
  66. <el-table-column
  67. v-for="item in tableColums"
  68. :key="item.label"
  69. :label="item.label"
  70. :prop="item.key"
  71. :width="item.widthsty"
  72. :min-width="item.minwidthsty"
  73. :sortable="item.sortable?true:false"
  74. align="center"
  75. >
  76. <template slot-scope="{row}">
  77. <template v-if="item.key==='handle'">
  78. <span v-permission="permissionBtn.dataSourcePermission.selfData_detail"
  79. class="editsty"
  80. @click="lookDataHandle(row)"
  81. >
  82. <!-- 查看详情 -->{{$t('Edb.detail_lookdata2_btn')}}
  83. </span>
  84. <span
  85. class="editsty"
  86. v-if="!row.EdbInfoId"
  87. @click="handleCheckEdb('single',row)"
  88. >
  89. <!-- 添加到指标库 -->{{$t('YsDataPage.add_base_btn')}}
  90. </span>
  91. </template>
  92. <template v-else-if="item.key==='IndexName'">
  93. <span style="white-space: pre-wrap;">{{ row.IndexName }}</span>
  94. </template>
  95. <span v-else>{{ row[item.key] }}</span>
  96. </template>
  97. </el-table-column>
  98. <div slot="empty" style="padding: 100px 0">
  99. <tableNoData :text="$t('Table.prompt_slogan')" size="mini"/>
  100. </div>
  101. </el-table>
  102. <div style="height:35px;margin: 20px 0;">
  103. <m-page
  104. :page_no="page_no"
  105. :pageSize="pageSize"
  106. :total="total"
  107. @handleCurrentChange="pageChange"
  108. />
  109. </div>
  110. </div>
  111. <!-- 查看数据弹窗 -->
  112. <lookEdbDataDia
  113. :isShow.sync="isLookDataDia"
  114. :edbInfo="lookEdbInfo"
  115. />
  116. <!-- 加入指标库弹窗 -->
  117. <addToBaseDia
  118. :isShow.sync="isAddToBaseDia"
  119. :list="addToBaseList"
  120. @success="pageChange(1)"
  121. />
  122. <!-- 操作提示弹窗 -->
  123. <el-dialog
  124. :title="$t('BloombergPage.operation_prompt')"
  125. :visible.sync="isHintDialogShow"
  126. :close-on-click-modal="false"
  127. :modal-append-to-body="false"
  128. @close="isHintDialogShow=false"
  129. width="578px"
  130. v-dialogDrag
  131. center>
  132. <div class="hint-dialog-wrap">
  133. <p style="margin-bottom: 20px;">{{ hintText }}</p>
  134. <ul>
  135. <li v-for="(item,index) in existEdbList" :key="index" class="hint-item" @click="goToEdbBase(item)">
  136. {{ index+1 }}、{{ item.IndexName }}({{ item.IndexCode }})
  137. </li>
  138. </ul>
  139. </div>
  140. <div style="text-align: center;margin-bottom: 30px;">
  141. <el-button type="primary" @click="handleCloseHintDia">{{$t('Dialog.known')}}</el-button>
  142. </div>
  143. </el-dialog>
  144. </div>
  145. </template>
  146. <script>
  147. import { selfDataInterface } from '@/api/modules/dataSource';
  148. import mPage from '@/components/mPage.vue';
  149. import lookEdbDataDia from './components/lookEdbDataDia.vue';
  150. import addToBaseDia from './components/addToBaseDia.vue';
  151. export default {
  152. components: { mPage,lookEdbDataDia,addToBaseDia },
  153. computed: {
  154. tableColums() {
  155. return [
  156. {
  157. label: this.$t('Edb.Detail.e_id'),
  158. key: 'IndexCode',
  159. },
  160. {
  161. label: this.$t('Edb.Detail.e_name'),
  162. key: 'IndexName',
  163. },
  164. {
  165. label: this.$t('Edb.Detail.e_fre'),
  166. key: 'Frequency',
  167. },
  168. {
  169. label: this.$t('Edb.Detail.e_unit'),
  170. key: 'Unit',
  171. },
  172. {
  173. label: /* '渠道' */this.$t('SelftDataPage.col_channel'),
  174. key: 'SourceName',
  175. },
  176. {
  177. label: /* '指标开始时间' */this.$t('SelftDataPage.col_start_time'),
  178. key: 'StartDate',
  179. sortable:true,
  180. },
  181. {
  182. label: /* '指标最新时间' */this.$t('SelftDataPage.col_newest_time'),
  183. key: 'EndDate',
  184. sortable:true,
  185. },
  186. {
  187. label: /* '入库时间' */this.$t('SelftDataPage.col_create'),
  188. sortable:true,
  189. key: 'CreateTime'
  190. },
  191. {
  192. label: this.$t('Table.column_operations'),
  193. key: 'handle'
  194. },
  195. ]
  196. },
  197. frequencyOptions(){
  198. return [
  199. { label:'日度',val: '日度' },
  200. { label:'周度',val: '周度' },
  201. { label:'旬度',val: '旬度' },
  202. { label:'月度',val: '月度' },
  203. { label:'季度',val: '季度' },
  204. { label:'半年度',val: '半年度' },
  205. { label:'年度',val: '年度' },
  206. ]
  207. },
  208. hintText(){
  209. let key = 0
  210. if(this.existEdbList.length) key++
  211. if(!this.addToBaseList.length) key++
  212. return {
  213. 0:'',
  214. 1:this.$t('YsDataPage.haved_all_msg'),//本次添加的指标均已在指标库中,请勿重复添加!
  215. 2:this.$t('YsDataPage.haved_some_msg'),//指标库中已存在以下指标,会自动过滤!
  216. }[key]
  217. }
  218. },
  219. data() {
  220. return {
  221. tableLoading: false,
  222. total: 0,
  223. tableData: [],
  224. sourceOptions: [],
  225. isSelectAll: false, //真正意义上的全选或不全选
  226. checkedList: [], //不全选勾选中的 或 全选取消勾的
  227. selectionReactCancel:false,//手动设置选中中
  228. filterObj: {
  229. page_no: 1,
  230. pageSize: 10,
  231. source: '',
  232. frequency: '',
  233. keyWord: '',
  234. sortParam:'',
  235. sortType:'',
  236. checkAll: false, //控制全选显示状态
  237. checkSome: false
  238. },
  239. /* 查看数据弹窗 */
  240. isLookDataDia: false,
  241. lookEdbInfo: {},
  242. /* 加入指标库弹窗 */
  243. isAddToBaseDia: false,
  244. addToType: 'multiple',
  245. addToBaseList: [],//可加入的指标
  246. existEdbList: [],//已存在的指标
  247. /* 提示弹窗 */
  248. isHintDialogShow: false,
  249. }
  250. },
  251. mounted(){
  252. this.getSource();
  253. this.getTableData('init');
  254. },
  255. methods:{
  256. getSource() {
  257. selfDataInterface.getSourceList().then(res => {
  258. if(res.Ret!==200 ) return
  259. this.sourceOptions = res.Data || [];
  260. })
  261. },
  262. getTableData(type='pageChange') {
  263. this.tableLoading = true;
  264. const { frequency,page_no,pageSize,keyWord,source,sortParam,sortType } = this.filterObj;
  265. let params = {
  266. Frequency: frequency,
  267. CurrentIndex: page_no,
  268. PageSize: pageSize,
  269. Keywords: keyWord,
  270. Source: source,
  271. SortField: sortParam,
  272. SortRule: sortType
  273. }
  274. selfDataInterface.getEdbList(params).then(res => {
  275. this.tableLoading = false;
  276. if( res.Ret!==200 )return
  277. const { Data } = res;
  278. this.tableData = Data.List || [];
  279. this.total = Data.Paging.Totals;
  280. if(type==='filter'){
  281. this.listCheckAllChange(true)
  282. }else {
  283. //页码变化 选中项不做清空
  284. this.checkedSomeSelection()
  285. }
  286. });
  287. },
  288. /* 设置当页数据勾选状态 */
  289. checkedSomeSelection() {
  290. this.selectionReactCancel=true
  291. if(!this.isSelectAll){
  292. this.checkedList.map(_ =>{
  293. let row = this.tableData.find(item => item.IndexCode==_.IndexCode)
  294. if(row){ //设置部分选中
  295. setTimeout(()=>{
  296. this.$refs.table.toggleRowSelection(row,true)
  297. },20)
  298. }
  299. })
  300. }else{
  301. this.$refs.table &&this.$refs.table.toggleAllSelection()
  302. this.checkedList.map(_ =>{
  303. let row = this.tableData.find(item => item.IndexCode==_.IndexCode)
  304. if(row){ //设置部分不勾选
  305. setTimeout(()=>{
  306. this.$refs.table.toggleRowSelection(row,false)
  307. },20)
  308. }
  309. })
  310. }
  311. setTimeout(()=>{
  312. this.selectionReactCancel=false
  313. },30)
  314. },
  315. //列表全选或全不选
  316. listCheckAllChange(value){
  317. this.checkedList = []
  318. this.isSelectAll = value
  319. this.$refs.table && this.$refs.table.clearSelection()
  320. value && this.$refs.table && this.$refs.table.toggleAllSelection()
  321. },
  322. selectionChange() {
  323. if(this.selectionReactCancel) return
  324. //设置全选框状态 选中 半选 不选
  325. setTimeout(()=>{
  326. let filterChecked = Array.from(new Set(this.checkedList))
  327. //全选
  328. if(
  329. (filterChecked.length===this.total&&this.total>0 && (!this.isSelectAll))
  330. || (filterChecked.length === 0 && this.isSelectAll)
  331. ){
  332. this.filterObj.checkAll = true
  333. this.filterObj.checkSome = false
  334. //不选
  335. }else if(
  336. (filterChecked.length === 0 && (!this.isSelectAll))
  337. || (filterChecked.length === this.total && this.isSelectAll)
  338. ){
  339. this.filterObj.checkAll = false
  340. this.filterObj.checkSome = false
  341. //半选
  342. }else{
  343. this.filterObj.checkAll = false
  344. this.filterObj.checkSome=true
  345. }
  346. },1)
  347. },
  348. //单选
  349. selectHandle(selection,row){ //当前选中的项是进选中还是取消选中中
  350. if(this.selectionReactCancel) return
  351. //当前项是选中还是取消选
  352. let haveChecked = selection.some(_ => _.IndexCode === row.IndexCode);
  353. //全选取消选和不全选选中才有意义
  354. if((haveChecked&&!this.isSelectAll) || (!haveChecked&&this.isSelectAll)) {
  355. this.checkedList.push(row)
  356. }else {
  357. this.checkedList=this.checkedList.filter(_ => _.IndexCode!==row.IndexCode)
  358. }
  359. },
  360. //整列选
  361. selectAllPageHandle(selection){
  362. if(this.selectionReactCancel) return
  363. //当前页是选中还是取消
  364. let haveChecked = selection && selection.length>0;
  365. //全选取消选和不全选选中才有意义
  366. if((haveChecked&&!this.isSelectAll) || (!haveChecked&&this.isSelectAll)) {
  367. this.checkedList = [...this.checkedList,...this.tableData]
  368. }else {
  369. let pageIds = this.tableData.map(_ => _.IndexCode);
  370. this.checkedList = this.checkedList.filter(_ => !pageIds.includes(_.IndexCode))
  371. }
  372. },
  373. handleSortChange({prop,order}) {
  374. const propMap={
  375. 'StartDate':1,
  376. 'EndDate':2,
  377. 'ModifyTime':3
  378. }
  379. this.filterObj.sortParam = order?propMap[prop]||'':''
  380. this.filterObj.sortType = order?order==='ascending'?1:2:''
  381. this.filterChange()
  382. },
  383. // 页码改变
  384. pageChange(page) {
  385. this.filterObj.page_no = page;
  386. this.getTableData('pageChange')
  387. },
  388. filterChange(val) {
  389. this.filterObj.page_no = 1;
  390. if(!val) {
  391. this.isSelectAll = false
  392. this.checkedList = []
  393. this.filterObj.checkAll = false
  394. this.filterObj.checkSome = false
  395. }
  396. this.getTableData(val?'filter':'')
  397. },
  398. /* 查看数据 */
  399. lookDataHandle(item) {
  400. this.lookEdbInfo = item;
  401. this.isLookDataDia = true
  402. },
  403. handleCheckEdb(type='multiple',data={}){
  404. if(type==='multiple' && !this.checkedList.length && !this.isSelectAll) return this.$message.warning('请选择指标')
  405. const {frequence,keyWord,sortParam,sortType} = this.filterObj
  406. selfDataInterface.checkEdb({
  407. Frequency:frequence,
  408. Keywords:keyWord,
  409. SortField:sortParam||0,
  410. SortRule:sortType||0,
  411. ListAll:type==='single'?false:this.isSelectAll,
  412. IndexCodes:type==='single'?[data.IndexCode]:this.checkedList.map(_=>_.IndexCode)
  413. }).then(res=>{
  414. if(res.Ret!==200) return
  415. const edbList = res.Data||[]
  416. this.existEdbList = edbList.filter(i=>i.EdbExist===1)
  417. this.addToBaseList = edbList.filter(i=>i.EdbExist===0)
  418. this.existEdbList.length&&(this.isHintDialogShow=true)
  419. !this.existEdbList.length&&this.handleCloseHintDia()
  420. })
  421. },
  422. //提示弹窗关闭
  423. handleCloseHintDia(){
  424. this.isHintDialogShow = false
  425. //判断是否要展示下一个弹窗
  426. if(!this.addToBaseList.length) return
  427. if(this.addToBaseList.length>100) return this.$message.warning('批量添加指标数量不得超过100个!')
  428. this.isAddToBaseDia = true
  429. },
  430. //跳转至指标详情
  431. goToEdbBase(data){
  432. const {EdbClassifyId,EdbInfoId,EdbUniqueCode} = data||{}
  433. const { href } = this.$router.resolve({
  434. path:'/database',
  435. query:{
  436. code:EdbUniqueCode,
  437. id:EdbInfoId,
  438. classifyId:EdbClassifyId,
  439. }
  440. })
  441. window.open(href,"_blank")
  442. }
  443. },
  444. }
  445. </script>
  446. <style scoped lang='scss'>
  447. .selfData-page {
  448. min-height: calc(100vh - 120px);
  449. display: flex;
  450. flex-direction: column;
  451. background-color: #fff;
  452. border: 1px solid #c8cdd9;
  453. border-radius: 4px;
  454. box-shadow: 0 3px 6px rgba(0, 0, 0, .05);
  455. padding: 20px;
  456. box-sizing: border-box;
  457. .header {
  458. display: flex;
  459. justify-content: space-between;
  460. .left {
  461. display: flex;
  462. align-items: center;
  463. gap: 10px;
  464. }
  465. }
  466. }
  467. .hint-dialog-wrap{
  468. padding-bottom:30px;
  469. .hint-item{
  470. cursor: pointer;
  471. margin-bottom: 10px;
  472. &:hover{
  473. color:#409EFF;
  474. text-decoration: underline;
  475. }
  476. }
  477. }
  478. </style>