selfDataBase.vue 15 KB

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