Quellcode durchsuchen

Merge branch 'ETA_1.4.4'

hbchen vor 11 Monaten
Ursprung
Commit
9deff98770

+ 97 - 104
src/views/dataEntry_manage/databaseComponents/addTargetDiaBase.vue

@@ -15,8 +15,8 @@
 							<el-option v-for="item in fromArr" :key="item" :label="item" :value="item">
 							</el-option>
 						</el-select>
-						<el-select v-model="fromDatabase" placeholder="请选择数据库" style="width:240px;margin-left:10px" @change="changeDatabase"
-							:disabled="haveResult" v-if="fromType=='wind'">
+						<el-select v-model="fromDatabase" placeholder="请选择数据库" style="width:240px;margin-left:10px"
+							:disabled="haveResult" v-if="hasDateSequence">
 							<el-option v-for="item in databaseType" :key="item.value" :label="item.label" :value="item.value">
 							</el-option>
 						</el-select>
@@ -26,32 +26,34 @@
 						<i slot="prefix" class="el-input__icon el-icon-search"></i>
 					</el-input>
 
-					<el-input placeholder="指标ID" v-model="search_txt" style="maxWidth:300px" v-if="!(this.fromType=='wind' && this.fromDatabase=='1')"
+					<el-input placeholder="指标ID" v-model="search_txt" style="maxWidth:300px" v-if="!(hasDateSequence && fromDatabase=='1')"
 						@keyup.enter.native="searchHandle" :disabled="haveResult" clearable>
 						<i slot="prefix" class="el-input__icon el-icon-search"></i>
 					</el-input>
 				</div>
-				<div v-if="this.fromType=='wind' && this.fromDatabase=='1'">
+				<div v-if="hasDateSequence && fromDatabase=='1'">
 					<div class="wsd-index-box">
 						<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 class="wsd-index-code">
-							<el-input placeholder="请输入指标代码,多个指标代码用英文逗号分隔" v-model.trim="indexCodeText" class="wsd-index-input" @blur="codeInputBlur('index')"></el-input>
-							<div class="index-code-hint">Wind金融终端输入“CG”会弹出代码生成器,可在代码生成器上获取其他指标的代码</div>
+							<el-input placeholder="请输入指标代码,多个指标代码用英文逗号分隔" v-model.trim="indexCodeText" 
+							class="wsd-index-input" @blur="codeInputBlur('index')"></el-input>
+							<div class="index-code-hint">
+								{{ indexCodeHintText }}
+							</div>
 						</div>
+						<el-select v-model="THSIndexCodeType" placeholder="请选择常用指标类型" v-if="fromType=='同花顺'"
+						@change="THSIndexCodeTypeChange" style="margin-bottom: 15px;" class="wsd-index-input">
+							<el-option :label="item.label" :value="item.value" 
+							v-for="item in THSIndexCodeTypeArr" :key="item.value"></el-option>
+						</el-select>
 						<el-checkbox-group v-model="indexCodeSelected">
 							<el-checkbox :label="item.value" v-for="item in indexCodeArr" :key="item.value">{{ item.label }}</el-checkbox>
 						</el-checkbox-group>
 						<div class="wsd-code-row" style="margin-top: -10px;">
 							<div class="wsd-code-item" v-for="item in indexCode" :key="item">
 								<div class="wsd-code-item-text">{{ item }}</div>
-								<img src="~@/assets/img/icons/close_icon_black.png" @click="deleteCode('index',item)" />
+								<img src="~@/assets/img/icons/close_icon_black.png" @click="deleteCode(item)" />
 							</div>
 						</div>
 					</div>
@@ -110,7 +112,8 @@
                 <td class="sticky" style="left: 0;text-align: center;">
                   {{ edbTableHeadData.get(item) }}
                 </td>
-                <td v-for="(data, sub_index) in edbIndexDatas" :key="sub_index" :colspan="2">
+                <td v-for="(data, sub_index) in edbIndexDatas" :key="sub_index" :colspan="2" 
+								:class="highLightIndex.includes(data.EdbName) && item=='EdbName' ?'exist-highlight':''">
 									<template v-if="item === 'ClassifyId'">
 										<el-cascader :options="options" v-model="data[item]" placeholder="请选择所属目录"
 										size="mini" :disabled="!data.Source"
@@ -172,8 +175,8 @@
 			<div class="check-fail-box">
 				<div>
 					<div style="margin-bottom: 20px;">指标库中已存在以下指标,请勿重新输入!</div>
-					<div v-for="(item,index) in existIndexList">
-						{{ index+1+'、'+item }}
+					<div v-for="(item,index) in existIndexList" class="exist-index-item" @click="existIndexClick(item)">
+						{{ index+1+'、'+item.text }}
 					</div>
 				</div>
 				<div class="check-fail-button">
@@ -186,7 +189,7 @@
 
 <script>
 import { dataBaseInterface,dataInterence } from '@/api/api.js'
-import { fromArr, fromCode ,frequencyArr} from './util';
+import { fromArr, fromCode ,frequencyArr,windCommonIndexCodeArr,THSCommonIndexStockCodeArr,THSCommonIndexFuturesCodeArr} from './util';
 export default {
 	name: '',
 	props: {
@@ -196,33 +199,44 @@ export default {
 	},
 	computed:{
 		isCodeComplete(){
-			// return this.securityCode.length>0 && (this.indexCode.length>0 || this.indexCodeSelected.length>0)
 			return this.securityCodeText && (this.indexCode.length>0 || this.indexCodeSelected.length>0)
-			
+		},
+		hasDateSequence(){
+			return ["wind","同花顺"].includes(this.fromType)
+		},
+		// 常用的指标代码
+		indexCodeArr(){
+			if(this.fromType=='wind'){
+				return windCommonIndexCodeArr
+			}else if(this.fromType=='同花顺'){
+				if(this.THSIndexCodeType==1){
+					//期货常用
+					return THSCommonIndexFuturesCodeArr
+				}else{
+					//股票常用
+					return THSCommonIndexStockCodeArr
+				}
+			}
+		},
+		indexCodeHintText(){
+			if(this.fromType=='wind'){
+				return 'Wind金融终端输入“CG”会弹出代码生成器,可在代码生成器上获取其他指标的代码'
+			}else if(this.fromType=='同花顺'){
+				return '可用Excel同花顺插件/日期序列功能,根据所选指标获取指标代码,期货和股票常用代码可在下方勾选'
+			}
 		}
 	},
 	data() {
+		this.prefixMap=new Map([
+			["wind","wsd"],
+			["同花顺","thsds"]
+		])
 		return {
 			search_txt: '',//搜素关键词 M001625518 M0001427
 			fromType: 'wind',
 			fromDatabase:'0',
 			fromArr,
 			indexCodeSelected:[],
-			indexCodeArr:[
-				{value:'pre_close',label:"前收盘价"},
-				{value:'open',label:"开盘价"},
-				{value:'high',label:"最高价"},
-				{value:'low',label:"最低价"},
-				{value:'close',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:'经济数据库'},
 				{value:'1',label:'日期序列'}
@@ -255,35 +269,9 @@ export default {
 			isCompanyCode: false,
 			search_company_txt: '',
 			securityCodeText:"",
-			// securityCode:[],
 			indexCodeText:'',
 			indexCode:[],
-			edbIndexDatas:[
-				// {Source:1,Catalogue:'',Unit:"",Frequency:'日度',SecName:'CU2403收盘价',SecurityCode:'CU2403.SHF',IndexCode:'close',
-				// DataList:[{Close: "632107.0000",Dt: "2023-09-07"},{Close: "632107.0000",Dt: "2023-09-07"},{Close: "632107.0000",Dt: "2023-09-07"},
-				// {Close: "632107.0000",Dt: "2023-09-07"},{Close: "632107.0000",Dt: "2023-09-07"},{Close: "632107.0000",Dt: "2023-09-07"},{Close: "632107.0000",Dt: "2023-09-07"},
-				// {Close: "632107.0000",Dt: "2023-09-07"},{Close: "632107.0000",Dt: "2023-09-07"},{Close: "632107.0000",Dt: "2023-09-07"}]},
-				// {Catalogue:'',Unit:"",Frequency:'日度',SecName:'CU2403收盘价',SecurityCode:'CU2403.SHF',IndexCode:'close',
-				// DataList:[{Close: "632107.0000",Dt: "2023-09-07"},{Close: "632107.0000",Dt: "2023-09-07"},{Close: "632107.0000",Dt: "2023-09-07"},
-				// {Close: "632107.0000",Dt: "2023-09-07"},{Close: "632107.0000",Dt: "2023-09-07"},{Close: "632107.0000",Dt: "2023-09-07"},{Close: "632107.0000",Dt: "2023-09-07"},
-				// {Close: "632107.0000",Dt: "2023-09-07"},{Close: "632107.0000",Dt: "2023-09-07"},{Close: "632107.0000",Dt: "2023-09-07"}]},
-				// {Catalogue:'',Unit:"",Frequency:'日度',SecName:'CU2403收盘价',SecurityCode:'CU2403.SHF',IndexCode:'close',
-				// DataList:[{Close: "632107.0000",Dt: "2023-09-07"},{Close: "632107.0000",Dt: "2023-09-07"},{Close: "632107.0000",Dt: "2023-09-07"},
-				// {Close: "632107.0000",Dt: "2023-09-07"},{Close: "632107.0000",Dt: "2023-09-07"},{Close: "632107.0000",Dt: "2023-09-07"},{Close: "632107.0000",Dt: "2023-09-07"},
-				// {Close: "632107.0000",Dt: "2023-09-07"},{Close: "632107.0000",Dt: "2023-09-07"},{Close: "632107.0000",Dt: "2023-09-07"}]},
-				// {Catalogue:'',Unit:"",Frequency:'日度',SecName:'CU2403收盘价',SecurityCode:'CU2403.SHF',IndexCode:'close',
-				// DataList:[{Close: "632107.0000",Dt: "2023-09-07"},{Close: "632107.0000",Dt: "2023-09-07"},{Close: "632107.0000",Dt: "2023-09-07"},
-				// {Close: "632107.0000",Dt: "2023-09-07"},{Close: "632107.0000",Dt: "2023-09-07"},{Close: "632107.0000",Dt: "2023-09-07"},{Close: "632107.0000",Dt: "2023-09-07"},
-				// {Close: "632107.0000",Dt: "2023-09-07"},{Close: "632107.0000",Dt: "2023-09-07"},{Close: "632107.0000",Dt: "2023-09-07"}]},
-				// {Catalogue:'',Unit:"",Frequency:'日度',SecName:'CU2403收盘价',SecurityCode:'CU2403.SHF',IndexCode:'close',
-				// DataList:[{Close: "632107.0000",Dt: "2023-09-07"},{Close: "632107.0000",Dt: "2023-09-07"},{Close: "632107.0000",Dt: "2023-09-07"},
-				// {Close: "632107.0000",Dt: "2023-09-07"},{Close: "632107.0000",Dt: "2023-09-07"},{Close: "632107.0000",Dt: "2023-09-07"},{Close: "632107.0000",Dt: "2023-09-07"},
-				// {Close: "632107.0000",Dt: "2023-09-07"},{Close: "632107.0000",Dt: "2023-09-07"},{Close: "632107.0000",Dt: "2023-09-07"}]},
-				// {Catalogue:'',Unit:"",Frequency:'日度',SecName:'CU2403收盘价',SecurityCode:'CU2403.SHF',IndexCode:'close',
-				// DataList:[{Close: "632107.0000",Dt: "2023-09-07"},{Close: "632107.0000",Dt: "2023-09-07"},{Close: "632107.0000",Dt: "2023-09-07"},
-				// {Close: "632107.0000",Dt: "2023-09-07"},{Close: "632107.0000",Dt: "2023-09-07"},{Close: "632107.0000",Dt: "2023-09-07"},{Close: "632107.0000",Dt: "2023-09-07"},
-				// {Close: "632107.0000",Dt: "2023-09-07"},{Close: "632107.0000",Dt: "2023-09-07"},{Close: "632107.0000",Dt: "2023-09-07"}]}
-			],
+			edbIndexDatas:[],
 			edbTableHeadKey: [
         "ClassifyId",
         "Unit",
@@ -306,7 +294,14 @@ export default {
 			frequencyArr,
 			checkFailShow:false,
 			existIndexList:[],
-			isLoadingData:false
+			isLoadingData:false,
+			highLightIndex:[],
+			// 同花顺常用指标类型
+			THSIndexCodeType:1,
+			THSIndexCodeTypeArr:[
+				{value:1,label:"期货常用指标"},
+				{value:2,label:"股票常用指标"}
+			]
 		};
 	},
 	watch:{
@@ -322,7 +317,6 @@ export default {
 		init() {
 			this.fromType = 'wind'
 			this.fromDatabase='0'
-			this.wsdAddStep=1
 			this.status = ''
 			this.tableData = []
 			this.dataList = []
@@ -330,6 +324,12 @@ export default {
 			this.search_txt = '';
 			this.haveResult = false;
 			this.search_company_txt = '';
+			this.wsdAddStep=1
+			this.securityCodeText=""
+			this.indexCodeText=''
+			this.indexCode=[]
+			this.indexCodeSelected=[]
+			this.THSIndexCodeType=1
 			this.isCompanyCode = false;
 		},
 		cancelHandle() {
@@ -434,18 +434,18 @@ export default {
 				this.isCompanyCode = false;
 			}
 			if(this.fromDatabase=='1'){
-				this.changeDatabase('0')
+				this.fromDatabase='0'
+				this.securityCodeText=""
+				this.indexCodeText=''
+				this.indexCode=[]
+				this.indexCodeSelected=[]
+				this.THSIndexCodeType=1
 			}
 			this.search_txt = '';
 			this.search_company_txt = '';
 			this.loading && this.loading.close();
 		},
-		changeDatabase(e){
-			this.fromDatabase=e
-			this.securityCodeText=""
-			// this.securityCode=[]
-			this.indexCodeText=''
-			this.indexCode=[]
+		THSIndexCodeTypeChange(){
 			this.indexCodeSelected=[]
 		},
 		getTargetSource(){
@@ -466,18 +466,6 @@ export default {
 		codeInputBlur(type){
 			if(type == 'security'){
 				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(' ','')
@@ -487,12 +475,8 @@ export default {
 			}
 
 		},
-		deleteCode(type,code){
-			if(type == 'security'){
-				// this.securityCode = this.securityCode.filter(it => it!=code)
-			}else if(type == 'index'){
-				this.indexCode = this.indexCode.filter(it => it!=code)
-			}
+		deleteCode(code){
+			this.indexCode = this.indexCode.filter(it => it!=code)
 		},
 		/* 获取目录结构 */
 		getMenu() {
@@ -535,28 +519,21 @@ export default {
 						Source:Number(this.fromCode.get(this.fromType)),
 						SubSource:this.fromDatabase,
 						EdbCode:Array.from(new Set([...this.indexCode,...this.indexCodeSelected])).join(','),
-						// StockCode:this.securityCode.join(',')
 						StockCode:this.securityCodeText
 					}
 					dataBaseInterface.edbExistCheck(params).then(res=>{
 						if(res.Ret == 200){
+							// console.log(res,'res');
+							// return 
 							if(res.Data.IndexExist){
 								// 有重复
 								this.existIndexList=[]
-								let ExistEdbCodeArr=res.Data.ExistEdbCodeArr
-								// let ExistStockCodeArr=res.Data.ExistStockCodeArr
+								let existEdbInfo=res.Data.ExistEdbInfo || []
 								let text=''
-								// ExistStockCodeArr.map(item =>{
-									Array.from(new Set(ExistEdbCodeArr)).map(item1 =>{
-										let isCommon = this.indexCodeArr.find(it => it.value == item1)
-										if(isCommon){
-											text=`${this.securityCodeText}${isCommon.label}(wsd${this.securityCodeText}${isCommon.value})`
-										}else{
-											text=`${this.securityCodeText}${item1}(wsd${this.securityCodeText}${item1})`
-										}
-										this.existIndexList.push(text)
-									})
-								// })
+								existEdbInfo.map(item =>{
+									text=`${item.EdbName}(${item.EdbCode})`
+									this.existIndexList.push({text,code:item.UniqueCode,id:item.EdbInfoId,classifyId:item.ClassifyId})
+								})
 								this.checkFailShow=true
 							}else{
 								// 没有重复
@@ -614,6 +591,10 @@ export default {
 				}
 			},50)
 		},
+		existIndexClick({code,id,classifyId}){
+			const { href } = this.$router.resolve({ path: '/database',query:{code,id,classifyId}});
+			window.open(href, '_blank');
+		},
 		wsdPrevHandle(){
 			this.wsdAddStep=1
 		},
@@ -638,6 +619,8 @@ export default {
 					this.$message.success("添加指标成功")
 					this.$emit('addSuccessHandle',{ code:res.Data.UniqueCode,id:res.Data.EdbInfoId,classifyId:res.Data.ClassifyId })	
 					this.cancelHandle()	
+				}else if(res.Ret == 403){
+					this.highLightIndex=res.Data?res.Data.ExistEdbName || []:[]
 				}
 			})
 		}
@@ -695,7 +678,7 @@ export default {
 		.wsd-index-code{
 			display: flex;
 			align-items: center;
-			margin-bottom: 15px;
+			margin-bottom: 20px;
 			.index-code-hint{
 				color: #C0C4CC;
 				font-size: 15px;
@@ -728,7 +711,8 @@ export default {
 			}
 		}
 		.wsd-index-input{
-			width: 400px;
+			min-width: 400px;
+			width:400px;
 			margin-right: 10px;
 		}
 	}
@@ -806,10 +790,19 @@ export default {
       border-top: 1px solid #dcdfe6;
       border-left: 1px solid #dcdfe6;
     }
+		.exist-highlight{
+			border: red solid 1px;
+		}
 	}
 	.check-fail-box{
 		padding: 0 0 15px 40px;	
 		color: #333333;
+		.exist-index-item{
+			cursor: pointer;
+			&:hover{
+				text-decoration: underline;
+			}
+		}
 		.check-fail-button{
 			margin-top: 80px;
 			display: flex;

+ 46 - 0
src/views/dataEntry_manage/databaseComponents/util.js

@@ -437,3 +437,49 @@ export const formulaTip = new Map([
 	5、旬度值转日均值=旬度值/对应旬度天数 <br>
 	6、周度值转日均值=周度值/7`]
 ])
+
+// wind 日期序列常见指标代码
+export const windCommonIndexCodeArr=[
+	{value:'pre_close',label:"前收盘价"},
+	{value:'open',label:"开盘价"},
+	{value:'high',label:"最高价"},
+	{value:'low',label:"最低价"},
+	{value:'close',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:"持仓额"}
+]
+
+// 同花顺 日期序列常见 股票指标代码
+export const THSCommonIndexStockCodeArr=[
+	{value:'ths_pre_close_stock',label:"前收盘价"},
+	{value:'ths_open_price_stock',label:"开盘价"},
+	{value:'ths_high_price_stock',label:"最高价"},
+	{value:'ths_low_stock',label:"最低价"},
+	{value:'ths_close_price_stock',label:"收盘价"},
+	{value:'ths_vol_stock',label:"成交量"},
+	{value:'ths_amt_stock',label:"成交额"},
+	{value:'ths_chg_ratio_stock',label:"涨跌幅"},
+	{value:'ths_swing_stock',label:"振幅"},
+	{value:'ths_turnover_ratio_stock',label:"换手率"},
+]
+
+// 同花顺 日期序列常见 指标代码
+export const THSCommonIndexFuturesCodeArr=[
+	{value:'ths_pre_close_future',label:"前收盘价"},
+	{value:'ths_open_price_future',label:"开盘价"},
+	{value:'ths_high_price_future',label:"最高价"},
+	{value:'ths_low_future',label:"最低价"},
+	{value:'ths_close_price_future',label:"收盘价"},
+	{value:'ths_settle_future',label:"结算价"},
+	{value:'ths_vol_future',label:"成交量"},
+	{value:'ths_amt_future',label:"成交额"},
+	{value:'ths_chg_ratio_future',label:"涨跌幅"},
+	{value:'ths_swing_d_future',label:"日振幅"},
+	{value:'ths_open_interest_future',label:"持仓量"},
+]