Browse Source

联调中

hbchen 1 year ago
parent
commit
847b89505d

+ 7 - 1
src/api/modules/chartApi.js

@@ -403,7 +403,13 @@ const dataBaseInterface = {
 	edbExistCheck: params => {
 		return http.get('/datamanage/edb_info/exist/check',params)
 	},
-
+	/**
+	 * 批量新增指标
+	 * @param {*} params BatchList[{Source,EdbName,Frequency,Unit,ClassifyId,StockCode,EdbCode}]
+	 */
+	edbAddBatch: params => {
+		return http.post('/datamanage/edb_info/batch/add',params)
+	},
 	//========================================chart
 	// /**
 	//  * 

+ 120 - 74
src/views/dataEntry_manage/databaseComponents/addTargetDiaBase.vue

@@ -6,8 +6,8 @@
 				<img :src="$icons.add" style="color:#fff;width:16px;height:16px;marginRight:5px;">
 				<span style="fontSize:16px;">添加指标</span>
 			</div>
-			<template v-if="wsdAddStep==1">
-				<div class="dialog-top">
+			<template v-if="wsdAddStep==1" >
+				<div class="dialog-top" v-loading="isLoadingData">
 					<div>
 						<span>数据来源</span>
 						<el-select v-model="fromType" placeholder="请选择来源" style="width:240px;margin-left:10px" @change="changeTrade"
@@ -31,17 +31,18 @@
 						<i slot="prefix" class="el-input__icon el-icon-search"></i>
 					</el-input>
 				</div>
-				<template v-if="this.fromType=='wind' && this.fromDatabase=='1'">
+				<div v-if="this.fromType=='wind' && this.fromDatabase=='1'">
 					<div class="wsd-index-box">
-						<el-input placeholder="请输入证券代码" v-model.trim="securityCodeText" class="wsd-index-input" @blur="codeInputBlur('security')"></el-input>
-						<div class="wsd-code-row">
+						<el-input placeholder="请输入证券代码,每次只查询一个证券代码" v-model.trim="securityCodeText" class="wsd-index-input" 
+						@blur="codeInputBlur('security')" style="margin-bottom: 20px;"></el-input>
+						<!-- <div class="wsd-code-row">
 							<div class="wsd-code-item" v-for="item in securityCode" :key="item">
 								<div class="wsd-code-item-text">{{ item }}</div>
 								<img src="~@/assets/img/icons/close_icon_black.png" @click="deleteCode('security',item)" />
 							</div>
-						</div>
+						</div> -->
 						<div class="wsd-index-code">
-							<el-input placeholder="请输入指标代码" v-model.trim="indexCodeText" class="wsd-index-input" @blur="codeInputBlur('index')"></el-input>
+							<el-input placeholder="请输入指标代码,多个指标代码用英文逗号分隔" v-model.trim="indexCodeText" class="wsd-index-input" @blur="codeInputBlur('index')"></el-input>
 							<div class="index-code-hint">Wind金融终端输入“CG”会弹出代码生成器,可在代码生成器上获取其他指标的代码</div>
 						</div>
 						<el-checkbox-group v-model="indexCodeSelected">
@@ -55,10 +56,11 @@
 						</div>
 					</div>
 					<div class="dia-bot">
-						<el-button type="primary" @click="wsdNextHandle" :disabled="!isCodeComplete" style="width: 120px;">下一步
+						<el-button type="primary" @click="wsdNextHandle" :disabled="!isCodeComplete" 
+						style="width: 120px;" :loading="isLoadingData" >下一步
 						</el-button>
 					</div>
-				</template>
+				</div>
 				<template v-else>
 					<div class="warn_txt" v-if="status === 1">
 						该数据已存在数据库,名称为:{{have_edbobj.edb_name}},目录为:{{ have_edbobj.warnTip }},如需重新添加,请删除原指标
@@ -93,7 +95,8 @@
 						</ul>
 					</div>
 					<div class="dia-bot">
-						<el-button type="primary" v-if="status === 2" @click="addTargtHandler" :disabled="!tableData.length">下一步
+						<el-button type="primary" v-if="status === 2" @click="addTargtHandler" 
+						:disabled="!tableData.length">下一步
 						</el-button>
 						<el-button type="primary" v-else-if="[1,3].includes(status)" @click="cancelHandle">知道了</el-button>
 					</div>
@@ -108,12 +111,13 @@
                   {{ edbTableHeadData.get(item) }}
                 </td>
                 <td v-for="(data, sub_index) in edbIndexDatas" :key="sub_index" :colspan="2">
-									<template v-if="item === 'Catalogue'">
+									<template v-if="item === 'ClassifyId'">
 										<el-cascader :options="options" v-model="data[item]" placeholder="请选择所属目录"
 										size="mini" :props="{label: 'ClassifyName',
 											value: 'ClassifyId',
 											children: 'Children',
-											checkStrictly: true}">
+											checkStrictly: true,
+											emitPath:false}">
 										</el-cascader>
 									</template>
 									<template v-else-if="item === 'Unit'">
@@ -131,7 +135,7 @@
 											v-for="item in frequencyArr" :key="item"></el-option>
 										</el-select>
 									</template>
-									<template v-else-if="item === 'SecName'">
+									<template v-else-if="item === 'EdbName'">
 										<el-input v-model.trim="data[item]" placeholder="请输入指标名称" size="mini"></el-input>
 									</template>
 									<template v-else>
@@ -147,8 +151,8 @@
 									数据详情
 								</td>
 								<template v-for="(item1,index1) in edbIndexDatas.length">
-									<td>{{ edbIndexDatas[index1].DataList[index].Dt }}</td>
-									<td>{{ edbIndexDatas[index1].DataList[index].Close }}</td>
+									<td>{{ edbIndexDatas[index1].DataList[index].DataTime }}</td>
+									<td>{{ edbIndexDatas[index1].DataList[index].Value }}</td>
 								</template>
               </tr>
             </tbody>
@@ -190,7 +194,9 @@ export default {
 	},
 	computed:{
 		isCodeComplete(){
-			return this.securityCode.length>0 && (this.indexCode.length>0 || this.indexCodeSelected.length>0)
+			// return this.securityCode.length>0 && (this.indexCode.length>0 || this.indexCodeSelected.length>0)
+			return this.securityCodeText && (this.indexCode.length>0 || this.indexCodeSelected.length>0)
+			
 		}
 	},
 	data() {
@@ -201,19 +207,19 @@ export default {
 			fromArr,
 			indexCodeSelected:[],
 			indexCodeArr:[
-				{value:1,label:"前收盘价"},
+				{value:'pre_close',label:"前收盘价"},
 				{value:'open',label:"开盘价"},
-				{value:3,label:"最高价"},
-				{value:4,label:"最低价"},
+				{value:'high',label:"最高价"},
+				{value:'low',label:"最低价"},
 				{value:'close',label:"收盘价"},
-				{value:6,label:"结算价"},
-				{value:7,label:"成交量"},
-				{value:8,label:"成交额"},
-				{value:9,label:"涨跌幅"},
-				{value:10,label:"振幅"},
-				{value:11,label:"换手率"},
-				{value:12,label:"持仓量"},
-				{value:13,label:"持仓额"},
+				{value:'settle',label:"结算价"},
+				{value:'volume',label:"成交量"},
+				{value:'amt',label:"成交额"},
+				{value:'pct_chg',label:"涨跌幅"},
+				{value:'swing',label:"振幅"},
+				{value:'turn',label:"换手率"},
+				{value:'oi',label:"持仓量"},
+				{value:'oiamount',label:"持仓额"},
 			], // 常用的指标代码
 			databaseType:[
 				{value:'0',label:'经济数据库'},
@@ -247,7 +253,7 @@ export default {
 			isCompanyCode: false,
 			search_company_txt: '',
 			securityCodeText:"",
-			securityCode:[],
+			// securityCode:[],
 			indexCodeText:'',
 			indexCode:[],
 			edbIndexDatas:[
@@ -277,26 +283,28 @@ export default {
 				{Close: "632107.0000",Dt: "2023-09-07"},{Close: "632107.0000",Dt: "2023-09-07"},{Close: "632107.0000",Dt: "2023-09-07"}]}
 			],
 			edbTableHeadKey: [
-        "Catalogue",
+        "ClassifyId",
         "Unit",
         "Frequency",
-        "SecName",
-        "SecurityCode",
-        "IndexCode",
+        "EdbName",
+        "StockCode",
+        "EdbCode",
       ],
 			edbTableHeadData:new Map([
-				["Catalogue", "所属目录"],
+				["ClassifyId", "所属目录"],
 				["Unit", "单位"],
 				["Frequency", "频度"],
-				["SecName", "指标名称"],
-				["SecurityCode", "证券代码"],
-				["IndexCode", "指标代码"],
+				["EdbName", "指标名称"],
+				["StockCode", "证券代码"],
+				["EdbCode", "指标代码"],
 			]),
+			BatchList:[],
 			options:[],
 			unitList:[],
 			frequencyArr,
 			checkFailShow:false,
-			existIndexList:[]
+			existIndexList:[],
+			isLoadingData:false
 		};
 	},
 	watch:{
@@ -433,7 +441,7 @@ export default {
 		changeDatabase(e){
 			this.fromDatabase=e
 			this.securityCodeText=""
-			this.securityCode=[]
+			// this.securityCode=[]
 			this.indexCodeText=''
 			this.indexCode=[]
 			this.indexCodeSelected=[]
@@ -455,20 +463,22 @@ export default {
 		},
 		codeInputBlur(type){
 			if(type == 'security'){
-				if(!this.securityCodeText) return  
-				if(!(this.securityCode.length<5)){
-					this.$message.warning('证券代码一次最多输入5个')
-					this.securityCodeText=''
-					return
-				}
-				this.securityCode=Array.from(new Set([...this.securityCode,...this.securityCodeText.split(',')])).filter(Boolean)
-				if(this.securityCode.length>5){
-					this.securityCode = this.securityCode.slice(0,5)
-					this.$message.warning('证券代码一次最多输入5个')
-				}
-				this.securityCodeText=''
+				this.securityCodeText=this.securityCodeText.replaceAll(' ','')
+				// if(!this.securityCodeText) return  
+				// if(!(this.securityCode.length<5)){
+				// 	this.$message.warning('证券代码一次最多输入5个')
+				// 	this.securityCodeText=''
+				// 	return
+				// }
+				// this.securityCode=Array.from(new Set([...this.securityCode,...this.securityCodeText.split(',')])).filter(Boolean)
+				// if(this.securityCode.length>5){
+				// 	this.securityCode = this.securityCode.slice(0,5)
+				// 	this.$message.warning('证券代码一次最多输入5个')
+				// }
+				// this.securityCodeText=''
 			}else if(type == 'index'){
 				if(!this.indexCodeText) return  
+				this.indexCodeText=this.indexCodeText.replaceAll(' ','')
 				this.indexCode=Array.from(new Set([...this.indexCode,...this.indexCodeText.split(',')]))
 
 				this.indexCodeText=''
@@ -477,7 +487,7 @@ export default {
 		},
 		deleteCode(type,code){
 			if(type == 'security'){
-				this.securityCode = this.securityCode.filter(it => it!=code)
+				// this.securityCode = this.securityCode.filter(it => it!=code)
 			}else if(type == 'index'){
 				this.indexCode = this.indexCode.filter(it => it!=code)
 			}
@@ -518,41 +528,68 @@ export default {
 		wsdNextHandle(){
 			this.getMenu()
 			setTimeout(()=>{
-				console.log(this.securityCode,this.indexCode,this.indexCodeSelected,'wsdNextHandle',
-				[...this.securityCode,...this.indexCodeSelected].join(','));
-				// return
 				if(this.isCodeComplete){
 					let params={
 						Source:Number(this.fromCode.get(this.fromType)),
 						SubSource:this.fromDatabase,
-						EdbCode:this.indexCode.join(','),
-						StockCode:this.securityCode.join(',')
+						EdbCode:[...this.indexCode,...this.indexCodeSelected].join(','),
+						// StockCode:this.securityCode.join(',')
+						StockCode:this.securityCodeText
 					}
-					console.log(params,'params');
 					dataBaseInterface.edbExistCheck(params).then(res=>{
-						console.log(res);
 						if(res.Ret == 200){
 							if(res.Data.IndexExist){
-								console.log('重复');
+								// 有重复
 								this.existIndexList=[]
-								let ExistEdbCodeArr=['close','open']
-								let ExistStockCodeArr=['CU2403.SHF','FD78ES.FF']
+								let ExistEdbCodeArr=res.Data.ExistEdbCodeArr
+								// let ExistStockCodeArr=res.Data.ExistStockCodeArr
 								let text=''
-								ExistStockCodeArr.map(item =>{
+								// ExistStockCodeArr.map(item =>{
 									ExistEdbCodeArr.map(item1 =>{
 										let isCommon = this.indexCodeArr.find(it => it.value == item1)
 										if(isCommon){
-											text=`${item}${isCommon.label}(wsd${item}${isCommon.value})`
+											text=`${this.securityCodeText}${isCommon.label}(wsd${this.securityCodeText}${isCommon.value})`
 										}else{
-											text=`${item}${item1}(wsd${item}${item1})`
+											text=`${this.securityCodeText}${item1}(wsd${this.securityCodeText}${item1})`
 										}
 										this.existIndexList.push(text)
 									})
-								})
+								// })
 								this.checkFailShow=true
 							}else{
-								// this.wsdAddStep=2
-								console.log('没有重复');
+								// 没有重复
+								this.isLoadingData=true
+								dataBaseInterface.getTarget(params).then(res => {
+									if(res.Ret == 200){
+										let stockList = res.Data.SearchItem.StockList || []
+										this.edbIndexDatas=[]
+										let Source = Number(this.fromCode.get(this.fromType))
+										stockList.map((item,index) =>{
+											let isCommon = this.indexCodeArr.find(it => it.value == item.EdbCode)
+											let params={
+												Source,
+												ClassifyId:0,
+												Unit:'',
+												Frequency:'日度',
+												EdbName:isCommon?`${item.StockCode}${isCommon.label}`:`${item.StockCode}${item.EdbCode}`,
+												EdbCode:item.EdbCode,
+												StockCode:item.StockCode
+											}
+											this.BatchList.push(params)
+											let datas = item.DataList || []
+											let datasLength = datas.length
+											if( datasLength<10){
+												for (let i = datasLength; i < 10; i++) {
+													datas.push({DataTime:'',Value:''})													
+												}
+											}
+											this.edbIndexDatas.push({...this.BatchList[index],DataList:datas})
+										})
+										this.wsdAddStep=2
+									}
+								}).finally(()=>{
+									this.isLoadingData=false
+								})
 							}
 						}
 					})
@@ -564,18 +601,27 @@ export default {
 		},
 		wsdSaveHandle(){
 			 let flag = this.edbIndexDatas.some(it => {
-				console.log(it,'ittititti');
-				return (!it.Catalogue) || (!it.Unit) || (!it.Frequency) || (!it.SecName)
+				return (!it.ClassifyId) || (!it.Unit) || (!it.Frequency) || (!it.EdbName)
 			})
 			if(flag){
 				this.$message.warning("指标信息未填写完整")
 				return 
 			}
-			// TODO: 保存接口对接
-			this.$message.success("添加指标成功")
-			// { code:res.Data.UniqueCode,id:res.Data.EdbInfoId,classifyId:params.ClassifyId }
-			this.$emit('addSuccessHandle')	
-			this.$emit('cancelHandle')	
+			this.BatchList.map((it,ind) => {
+				it.ClassifyId = this.edbIndexDatas[ind].ClassifyId
+				it.EdbCode = this.edbIndexDatas[ind].EdbCode
+				it.EdbName = this.edbIndexDatas[ind].EdbName
+				it.Frequency = this.edbIndexDatas[ind].Frequency
+				it.StockCode = this.edbIndexDatas[ind].StockCode
+				it.Unit = this.edbIndexDatas[ind].Unit
+			})
+			dataBaseInterface.edbAddBatch({BatchList:this.BatchList}).then(res=>{
+				if(res.Ret == 200){
+					this.$message.success("添加指标成功")
+					this.$emit('addSuccessHandle',{ code:res.Data.UniqueCode,id:res.Data.EdbInfoId,classifyId:res.Data.ClassifyId })	
+					this.cancelHandle()	
+				}
+			})
 		}
 	},
 	created() { },

+ 2 - 2
src/views/dataEntry_manage/databaseList.vue

@@ -1949,9 +1949,9 @@ export default {
 			this.select_classifyId = 0;
 		},
 		// 添加wind wsd指标成功
-		addTargetSuccess(){
+		addTargetSuccess(params){
 			// TODO: 定位
-			
+			this.getTreeData(params);
 		}
 	},
 	//离开页面时保存标签