瀏覽代碼

接口联调

cxmo 1 年之前
父節點
當前提交
445c9067c2
共有 3 個文件被更改,包括 287 次插入87 次删除
  1. 4 2
      src/api/api.js
  2. 58 1
      src/api/modules/thirdBaseApi.js
  3. 225 84
      src/views/dataEntry_manage/thirdBase/bloombergSource.vue

+ 4 - 2
src/api/api.js

@@ -15,7 +15,8 @@ import {
   fwmtInterface,
   fwmtInterface,
   guangqiInterface,
   guangqiInterface,
   icpiInterface,
   icpiInterface,
-  coalWordInterface
+  coalWordInterface,
+  bloombergInterface
 } from './modules/thirdBaseApi';
 } from './modules/thirdBaseApi';
 
 
 //手工指标 手工数据 手工数据权限
 //手工指标 手工数据 手工数据权限
@@ -122,7 +123,8 @@ export {
   fwmtInterface,
   fwmtInterface,
   guangqiInterface,
   guangqiInterface,
   icpiInterface,
   icpiInterface,
-  coalWordInterface
+  coalWordInterface,
+  bloombergInterface
 };
 };
 
 
 //老接口 研报 ppt等
 //老接口 研报 ppt等

+ 58 - 1
src/api/modules/thirdBaseApi.js

@@ -910,6 +910,62 @@ const coalWordInterface={
 		return http.get('/entry/data/mtjh/frequency',params)
 		return http.get('/entry/data/mtjh/frequency',params)
 	},
 	},
 }
 }
+/* 彭博数据源 */
+const bloombergInterface={
+    /**
+     * 数据列表
+     * @param {Object} params 
+     * @param {Number} params.PageSize
+     * @param {Number} params.CurrentIndex
+     * @param {String} params.Frequency
+     * @param {String} params.Keywords
+     * @param {Boolean} params.ListAll
+     * @param {Number} params.SortField
+     * @param {Number} params.SortRule
+     * @returns 
+     */
+    getTableList:params=>{
+        return http.get('/datamanage/bloomberg_source/list',params)
+    },
+    /**
+     * 指标重名校验
+     * @param {Object[]} params
+     * @param {String} params[].EdbCode //指标编码
+     * @param {String} params[].EdbName //指标名称
+     * @returns 
+     */
+    edbNameCheck:params=>{
+        return http.post('/datamanage/bloomberg_source/name_check',params)
+    },
+    /**
+     * 添加指标校验
+     * @param {Object} params 
+     * @param {Object} params.Frequency
+     * @param {Object} params.Keywords
+     * @param {Object} params.SortField
+     * @param {Object} params.SortRule
+     * @param {Boolean} params.ListAll
+     * @param {String[]} params.IndexCodes
+     * @returns 
+     */
+    edbAddCheck:params=>{
+        return http.post('/datamanage/bloomberg_source/add_check',params)
+    },
+    /**
+     * 批量新增指标
+     * @param {Object[]} params 
+     * @param {String} params[].EdbCode
+     * @param {String} params[].EdbName
+     * @param {String} params[].Frequency
+     * @param {String} params[].Unit
+     * @param {Number} params[].ClassifyId
+     * @returns 
+     */
+    edbBatchAdd:params=>{
+        return http.post('/datamanage/bloomberg_source/batch_add',params)
+    },
+
+}
 
 
 export { 
 export { 
 	lzDataInterface,
 	lzDataInterface,
@@ -926,5 +982,6 @@ export {
   fwmtInterface,
   fwmtInterface,
 	guangqiInterface,
 	guangqiInterface,
 	icpiInterface,
 	icpiInterface,
-	coalWordInterface
+	coalWordInterface,
+    bloombergInterface
 }
 }

+ 225 - 84
src/views/dataEntry_manage/thirdBase/bloombergSource.vue

@@ -3,14 +3,22 @@
         <div class="page-header">
         <div class="page-header">
             <div class="header-select-box">
             <div class="header-select-box">
                 <!-- 频度 -->
                 <!-- 频度 -->
-                <el-select v-model="frequenceSelect" :placeholder="$t('Edb.InputHolderAll.input_fre')" style="width:240px">
-                  <el-option label="日度" value="日度"></el-option>
+                <el-select v-model="selectOption.frequenceSelect" 
+                    :placeholder="$t('Edb.InputHolderAll.input_fre')" 
+                    @change="selectOptionChange"
+                    clearable 
+                    style="width:240px">
+                    <el-option v-for="i in frequencyList" :key="i"
+                            :label="i" :value="i"
+                        />
                 </el-select>
                 </el-select>
                 <!-- 指标ID/名称 -->
                 <!-- 指标ID/名称 -->
                 <el-input 
                 <el-input 
-                    v-model="keywordSelect" 
+                    v-model="selectOption.keywordSelect" 
                     prefix-icon="el-icon-search"
                     prefix-icon="el-icon-search"
                     :placeholder="$t('Edb.InputHolderAll.input_name_orid')" 
                     :placeholder="$t('Edb.InputHolderAll.input_name_orid')" 
+                    @input="selectOptionChange"
+                    clearable 
                     style="width:360px"></el-input>
                     style="width:360px"></el-input>
                 <!-- 列表全选 -->
                 <!-- 列表全选 -->
                 <el-checkbox 
                 <el-checkbox 
@@ -19,7 +27,7 @@
                     @change="listCheckAllChange">{{ $t('YsDataPage.label_all_check') }}</el-checkbox>
                     @change="listCheckAllChange">{{ $t('YsDataPage.label_all_check') }}</el-checkbox>
             </div>
             </div>
             <!-- 添加到指标库 -->
             <!-- 添加到指标库 -->
-            <el-button type="primary" @click="isHintDialogShow=true">{{ $t('YsDataPage.add_base_btn') }}</el-button>
+            <el-button type="primary" @click="handleCheckDialogShow">{{ $t('YsDataPage.add_base_btn') }}</el-button>
         </div>
         </div>
         <div class="page-table">
         <div class="page-table">
             <el-table :data="tableData" border
             <el-table :data="tableData" border
@@ -44,7 +52,7 @@
                 </el-table-column>
                 </el-table-column>
                 <el-table-column :label="$t('Table.column_operations')" align="center">
                 <el-table-column :label="$t('Table.column_operations')" align="center">
                     <template slot-scope="{row}">
                     <template slot-scope="{row}">
-                        <el-button type="text">{{ $t('YsDataPage.add_base_btn') }}</el-button>
+                        <el-button type="text" v-if="!row.EdbExist">{{ $t('YsDataPage.add_base_btn') }}</el-button>
                     </template>
                     </template>
                 </el-table-column>
                 </el-table-column>
             </el-table>
             </el-table>
@@ -68,8 +76,8 @@
             <div class="hint-dialog-wrap">
             <div class="hint-dialog-wrap">
                 <p style="margin-bottom: 20px;">{{ hintText }}</p>
                 <p style="margin-bottom: 20px;">{{ hintText }}</p>
                 <ul>
                 <ul>
-                    <li v-for="(item,index) in hintList" :key="index" class="hint-item">
-                        {{ index+1 }}、{{ item.name }}({{ item.id }})
+                    <li v-for="(item,index) in afterAddList" :key="index" class="hint-item">
+                        {{ index+1 }}、{{ item.IndexName }}({{ item.IndexCode }})
                     </li>
                     </li>
                 </ul>
                 </ul>
             </div>
             </div>
@@ -89,55 +97,68 @@
             v-dialogDrag
             v-dialogDrag
             center>
             center>
             <div class="add-dialog-wrap">
             <div class="add-dialog-wrap">
-                <el-form :model="addForm">
+                <el-form :model="addForm" ref="addFormRef">
                     <div class="group" v-for="(item,index) in addForm.list" :key="index">
                     <div class="group" v-for="(item,index) in addForm.list" :key="index">
-                        <el-form-item :prop="`list[${index}].name`">
-                            <el-input v-model="item.name"></el-input>
-                        </el-form-item>
-                        <el-form-item :prop="`list[${index}].unit`">
-                            <el-input v-model="item.unit"></el-input>
-                        </el-form-item>
-                        <el-form-item :prop="`list[${index}].frequency`">
-                            <el-select></el-select>
-                        </el-form-item>
-                        <el-form-item :prop="`list[${index}].catalog`">
-                            <el-select></el-select>
-                        </el-form-item>
+                        <div class="item-header">
+                            <span @click="item.expand=!item.expand">
+                                {{ item.IndexCode }}
+                                <i :class="item.expand?'el-icon-arrow-up':'el-icon-arrow-down'"></i>
+                            </span>
+                        </div>
+                        <div class="form-wrap" v-show="item.expand">
+                            <el-form-item 
+                                :prop="`list[${index}].IndexName`" 
+                                :rules="[
+                                    {required:true,message:'请输入指标名称',trigger: 'blur'},
+                                    {validator:edbNameCheck}
+                                ]">
+                                <el-input v-model="item.IndexName"></el-input>
+                            </el-form-item>
+                            <el-form-item :prop="`list[${index}].Unit`" :rules="{required:true,message:'请输入指标单位',trigger: 'blur'}">
+                                <el-input v-model="item.Unit"></el-input>
+                            </el-form-item>
+                            <el-form-item :prop="`list[${index}].Frequency`" :rules="{required:true,message:'请选择指标频度',trigger: 'blur'}">
+                                <el-select v-model="item.Frequency"></el-select>
+                            </el-form-item>
+                            <el-form-item :prop="`list[${index}].ClassifyId`" :rules="{required:true,message:'请选择指标目录',trigger: 'blur'}">
+                                <el-cascader v-model="item.ClassifyId"
+                                :options="edbCatalogList" 
+                                :props="{
+                                    label: 'ClassifyName',
+                                    value: 'ClassifyId',
+                                    children: 'Children',
+                                    checkStrictly: true,
+                                    emitPath:false
+                                }"
+                                ></el-cascader>
+                            </el-form-item>
+                        </div>
+                        
                     </div>
                     </div>
                 </el-form>
                 </el-form>
             </div>
             </div>
             <div style="text-align: center;margin-bottom: 30px;">
             <div style="text-align: center;margin-bottom: 30px;">
                     <el-button @click="isAddDialogShow=false">{{$t('Dialog.cancel_btn')}}</el-button>
                     <el-button @click="isAddDialogShow=false">{{$t('Dialog.cancel_btn')}}</el-button>
-                    <el-button type="primary" @click="handleCloseDialog">{{$t('Dialog.confirm_save_btn')}}</el-button>
+                    <el-button type="primary" @click="handleSaveCheck" :loading="btnLoading">{{$t('Dialog.confirm_save_btn')}}</el-button>
                 </div>
                 </div>
         </el-dialog>
         </el-dialog>
     </div>
     </div>
 </template>
 </template>
 
 
 <script>
 <script>
+import {bloombergInterface,dataBaseInterface} from '@/api/api.js'
 export default {
 export default {
     data() {
     data() {
         return {
         return {
-            frequenceSelect:'',
-            keywordSelect:'',
-            tableData:[
-                {
-                    'EdbInfoId':12345,
-                    'name':'指标名称aa',
-                    'frequence':'日度',
-                    'startDate':'2022-01-01',
-                    'endDate':'2024-04-10',
-                    'updateDate':'2024-04-10 02:00:00'
-                },
-                {
-                    'EdbInfoId':54321,
-                    'name':'指标名称bb',
-                    'frequence':'日度',
-                    'startDate':'2022-01-01',
-                    'endDate':'2024-04-10',
-                    'updateDate':'2024-04-10 02:00:00'
-                }
-            ],
+            selectOption:{
+                frequenceSelect:'',
+                keywordSelect:'',
+                sortParam:'',
+                sortType:''
+            },
+            frequencyList:['日度','周度','旬度','月度','季度','半年度','年度'],
+            tableData:[],
+            tableDataIds:[],
             currentPage:1,
             currentPage:1,
             pageSize:10,
             pageSize:10,
             total:2,
             total:2,
@@ -149,67 +170,104 @@ export default {
             selectionReactCancel:false,//select-事件触发时,为true;该事件触发完成后,为false;
             selectionReactCancel:false,//select-事件触发时,为true;该事件触发完成后,为false;
             
             
             isHintDialogShow:false,
             isHintDialogShow:false,
-            hintList:[{
-                name:'中国金属硅分省份月度开工',
-                id:'a10123431'
-            }],
+            afterAddList:[],//已添加进指标库的指标
+            beforeAddList:[],//需要添加进指标库的指标
+            edbCatalogList:[],//指标库目录数据
             isAddDialogShow:false,
             isAddDialogShow:false,
             addForm:{
             addForm:{
                 list:[
                 list:[
-                    {
-                        name:'aaa',
-                        unit:'',
-                        frequency:'',
-                        catalog:''
-                    }
+                    /* {
+                        IndexName:'',
+                        Unit:'',
+                        Frequency:'',
+                        ClassifyId:''
+                    } */
                 ]
                 ]
-            }
+            },
+            checkedList:[],//重名的指标code
+            btnLoading:false,
 
 
         };
         };
     },
     },
     computed:{
     computed:{
         tableColumns(){
         tableColumns(){
             return [
             return [
-                    {key:'EdbInfoId',label:this.$t('Edb.Detail.e_id')}, //指标ID
-                    {key:'name',label:this.$t('Edb.Detail.e_name')},//指标名称
-                    {key:'frequence',label:this.$t('Edb.Detail.e_fre')},//频度
-                    {key:'startDate',label:this.$t('DataBankPage.table_col_start_time'),sortable:true},//指标开始时间
-                    {key:'endDate',label:this.$t('DataBankPage.table_col_newest_time'),sortable:true},//指标最新时间
-                    {key:'updateDate',label:this.$t('Edb.Detail.e_update_time'),sortable:true} //更新时间
+                    {key:'IndexCode',label:this.$t('Edb.Detail.e_id')}, //指标ID
+                    {key:'IndexName',label:this.$t('Edb.Detail.e_name')},//指标名称
+                    {key:'Frequency',label:this.$t('Edb.Detail.e_fre')},//频度
+                    {key:'StartDate',label:this.$t('DataBankPage.table_col_start_time'),sortable:true},//指标开始时间
+                    {key:'EndDate',label:this.$t('DataBankPage.table_col_newest_time'),sortable:true},//指标最新时间
+                    {key:'ModifyTime',label:this.$t('Edb.Detail.e_update_time'),sortable:true} //更新时间
                 ]
                 ]
         },
         },
         hintText(){
         hintText(){
+            let key = 0
+            if(this.afterAddList.length) key++
+            if(!this.beforeAddList.length) key++
             return {
             return {
+                0:'',
                 1:this.$t('YsDataPage.haved_all_msg'),//本次添加的指标均已在指标库中,请勿重复添加!
                 1:this.$t('YsDataPage.haved_all_msg'),//本次添加的指标均已在指标库中,请勿重复添加!
                 2:this.$t('YsDataPage.haved_some_msg'),//指标库中已存在以下指标,会自动过滤!
                 2:this.$t('YsDataPage.haved_some_msg'),//指标库中已存在以下指标,会自动过滤!
-            }[2]
+            }[key]
         }
         }
     },
     },
     methods: {
     methods: {
-        getTableData(type){
-            if(type==='optionChange'){
-                //如果是表格筛选项改变导致重新请求数据
-                //数据获取完成后,列表全选,表格全选
-                this.selectList = []
-                this.listCheckAllChange(true)
-            }else{
-                //若不是,数据获取完成后,查询列表全选的值
-                //若当页有数据在selectList内,则勾选/剔除
-                this.adjustSelection()
+        getEdbCatalog() {
+            dataBaseInterface.menuListV3().then(res => {
+            if(res.Ret === 200) {
+                this.edbCatalogList = res.Data.AllNodes || [];
+                this.filterNodes(this.edbCatalogList);
+            }
+            })
+        },
+        // 递归改变目录结构
+        filterNodes(arr) {
+            arr.length && arr.forEach(item => {
+            item.Children.length && this.filterNodes(item.Children)
+            if(!item.Children.length) {
+                item.Children=null
             }
             }
+            })
+        },
+        getTableData(type){
+            const {frequenceSelect,keywordSelect,sortParam,sortType} = this.selectOption
+            bloombergInterface.getTableList({
+                PageSize:this.pageSize,
+                CurrentIndex:this.currentPage,
+                Frequency:frequenceSelect,
+                Keywords:keywordSelect,
+                SortField:sortParam,
+                SortRule:sortType
+            }).then(res=>{
+                if(res.Ret!==200) return 
+                this.tableData = res.Data.List||[]
+                this.total = res.Data.Paging.Totals
+                if(type==='optionChange'){
+                    //如果是表格筛选项改变导致重新请求数据
+                    //数据获取完成后,列表全选,表格全选
+                    this.selectList = []
+                    this.listCheckAllChange(true)
+                }else{
+                    //若不是,数据获取完成后,查询列表全选的值
+                    //若当页有数据在selectList内,则勾选/剔除
+                    this.adjustSelection()
+                }
+            })
+            
         },
         },
         handleCurrentChange(page){
         handleCurrentChange(page){
             this.currentPage = page
             this.currentPage = page
             this.getTableData()
             this.getTableData()
         },
         },
         handleSortChange({prop,order}){
         handleSortChange({prop,order}){
-            if(order){
-                this.selectOption.sortParam = 'end_date'
-                this.selectOption.sortType = order==='ascending'?'asc':'desc'
-            }else{
-                this.selectOption.sortParam = ''
-                this.selectOption.sortType = ''
+            console.log('prop',prop,'order',order)
+            const propMap={
+                'StartDate':1,
+                'EndDate':2,
+                'ModifyTime':3
             }
             }
+            this.selectOption.sortParam = order?propMap[prop]||'':''
+            this.selectOption.sortType = order?order==='ascending'?1:2:''
             this.selectOptionChange()
             this.selectOptionChange()
         },
         },
         //表格筛选项改变时触发
         //表格筛选项改变时触发
@@ -252,7 +310,7 @@ export default {
         selectHandle(selection,row){
         selectHandle(selection,row){
             if(this.selectionReactCancel) return 
             if(this.selectionReactCancel) return 
             let check = false; 
             let check = false; 
-            if(selection.some(it => it.EdbInfoId == row.EdbInfoId)){
+            if(selection.some(it => it.IndexCode == row.IndexCode)){
                 // 勾选
                 // 勾选
                 if(this.isSelectAll){
                 if(this.isSelectAll){
                     check=false
                     check=false
@@ -268,9 +326,9 @@ export default {
                 }
                 }
             }
             }
             if(check){
             if(check){
-                this.selectList.push(row.EdbInfoId)
+                this.selectList.push(row.IndexCode)
                 }else{
                 }else{
-                this.selectList=this.selectList.filter(it => it!=row.EdbInfoId)
+                this.selectList=this.selectList.filter(it => it!=row.IndexCode)
             }
             }
         },
         },
         selectAllHandle(selection){
         selectAllHandle(selection){
@@ -297,12 +355,11 @@ export default {
                 this.selectList = this.selectList.filter(it => !this.tableDataIds.includes(it))
                 this.selectList = this.selectList.filter(it => !this.tableDataIds.includes(it))
             }
             }
         },
         },
-        handleSortChange(){},
         adjustSelection(){
         adjustSelection(){
             this.selectionReactCancel=true
             this.selectionReactCancel=true
             if(!this.isSelectAll){
             if(!this.isSelectAll){
                 this.selectList.map(it =>{
                 this.selectList.map(it =>{
-                    let row = this.tableData.find(da => da.EdbInfoId==it)
+                    let row = this.tableData.find(da => da.IndexCode==it)
                     if(row){
                     if(row){
                         setTimeout(()=>{
                         setTimeout(()=>{
                             this.$refs.edbDataRef.toggleRowSelection(row,true)
                             this.$refs.edbDataRef.toggleRowSelection(row,true)
@@ -313,7 +370,7 @@ export default {
                 this.$refs.edbDataRef && this.$refs.edbDataRef.clearSelection()
                 this.$refs.edbDataRef && this.$refs.edbDataRef.clearSelection()
                 this.$refs.edbDataRef &&this.$refs.edbDataRef.toggleAllSelection()
                 this.$refs.edbDataRef &&this.$refs.edbDataRef.toggleAllSelection()
                 this.selectList.map(it =>{
                 this.selectList.map(it =>{
-                    let row = this.tableData.find(da => da.EdbInfoId==it)
+                    let row = this.tableData.find(da => da.IndexCode==it)
                     if(row){
                     if(row){
                         setTimeout(()=>{
                         setTimeout(()=>{
                             this.$refs.edbDataRef.toggleRowSelection(row,false)
                             this.$refs.edbDataRef.toggleRowSelection(row,false)
@@ -325,15 +382,90 @@ export default {
                 this.selectionReactCancel=false
                 this.selectionReactCancel=false
             },50)
             },50)
         },
         },
+        handleCheckDialogShow(){
+            //check
+            console.log('choosed',this.isSelectAll,this.selectList)
+            const {frequenceSelect,keywordSelect,sortParam,sortType} = this.selectOption
+            bloombergInterface.edbAddCheck({
+                Frequency:frequenceSelect,
+                Keywords:keywordSelect,
+                SortField:sortParam||0,
+                SortRule:sortType||0,
+                ListAll:this.isSelectAll,
+                IndexCodes:this.selectList
+            }).then(res=>{
+                if(res.Ret!==200) return 
+                const edbList = res.Data||[]
+                this.afterAddList = edbList.filter(i=>i.EdbExist===1)
+                this.beforeAddList = edbList.filter(i=>i.EdbExist===0).map(i=>{return{...i,expand:true}})
+                this.afterAddList.length&&(this.isHintDialogShow=true)
+                !this.afterAddList.length&&this.handleCloseDialog()
+            })
+        },
         //操作提示弹窗关闭
         //操作提示弹窗关闭
         handleCloseDialog(){
         handleCloseDialog(){
-            //判断是否要展示下一个弹窗
             this.isHintDialogShow = false
             this.isHintDialogShow = false
-            this.isAddDialogShow = true
+            //判断是否要展示下一个弹窗
+            if(this.beforeAddList.length){
+                this.addForm.list = this.beforeAddList
+                this.isAddDialogShow = true
+            }
+        },
+        //重名校验
+        edbNameCheck(rule,value,callback){
+            if(this.checkedList.includes(value)){
+                callback("指标名称已存在,请重新填写")
+            }else{
+                callback()
+            }
+        },
+        //保存前校验
+        async handleSaveCheck(){
+            //表单校验
+            try{
+                await this.$refs.addFormRef.validate()
+            }catch(e){
+                return
+            }
+            //重名校验
+            this.checkedList = []
+            bloombergInterface.edbNameCheck(
+                this.addForm.list.map(i=>{return{EdbCode:i.IndexCode,EdbName:i.IndexName}})
+            ).then(res=>{
+                if(res.Ret!==200) return 
+                this.checkedList = res.Data.filter(i=>i.Exist).map(i=>i.EdbName)
+                if(this.checkedList.length){
+                    this.$refs.addFormRef.validate()
+                }else{
+                    this.saveEdb()
+                }
+            })
+        },
+        //批量新增
+        saveEdb(){
+            this.btnLoading = true
+            bloombergInterface.edbBatchAdd(
+                this.addForm.list.map(i=>{
+                    return {
+                        EdbCode:i.IndexCode,
+                        EdbName:i.IndexName,
+                        Frequency:i.Frequency,
+                        Unit:i.Unit,
+                        ClassifyId:i.ClassifyId
+                    }
+                })
+            ).then(res=>{
+                this.btnLoading = false
+                if(res.Ret!==200) return 
+                this.$message.success("添加指标库成功")
+                this.isAddDialogShow = false
+                this.handleCurrentChange(1)
+            })
         }
         }
     },
     },
     mounted(){
     mounted(){
         this.getTableData('optionChange')
         this.getTableData('optionChange')
+        this.getEdbCatalog()
     },
     },
 };
 };
 </script>
 </script>
@@ -343,7 +475,16 @@ export default {
     .add-dialog-wrap{
     .add-dialog-wrap{
         .el-form{
         .el-form{
             .group{
             .group{
-                display: flex;
+                .item-header{
+                    margin-bottom: 20px;
+                }
+                .form-wrap{
+                    display: flex;
+                    gap:10px;
+                    .el-input{
+                        width: 100%;
+                    }
+                }
             }
             }
         }
         }
     }
     }