Commit a8139a60 authored by 陶进's avatar 陶进

提交一下

parent 2813d7d8
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<link rel="stylesheet" href="../../../static/plTable/index.css"> <link rel="stylesheet" href="../../../static/plTable/index.css">
<link rel="stylesheet" href="../../../static/element/theme/index.css"> <link rel="stylesheet" href="../../../static/element/theme/index.css">
<link rel="stylesheet" href="../../../static/global/global.css"> <link rel="stylesheet" href="../../../static/global/global.css">
<link rel="stylesheet" href="./indexManage.css"> <link rel="stylesheet" href="./indexManage.css">
</head> </head>
<body> <body>
<div id="app" class="production-line-container" v-cloak> <div id="app" class="production-line-container" v-cloak>
<router-view></router-view> <router-view></router-view>
...@@ -55,9 +57,6 @@ ...@@ -55,9 +57,6 @@
var publicIndex = await getPublicIndex() var publicIndex = await getPublicIndex()
var categoryAudit = await getCategoryAudit() var categoryAudit = await getCategoryAudit()
var indexRecord = await getIndexRecord() var indexRecord = await getIndexRecord()
// var component = await getMain()
// var component = await getMain()
// var component = await getMain()
var routes = [ var routes = [
{ path: '/', component: myIndex }, { path: '/', component: myIndex },
...@@ -66,7 +65,6 @@ ...@@ -66,7 +65,6 @@
{ path: '/categoryAudit', component: categoryAudit }, { path: '/categoryAudit', component: categoryAudit },
{ path: '/indexRecord', component: indexRecord } { path: '/indexRecord', component: indexRecord }
] ]
console.log(routes)
var router = new VueRouter({ routes }) var router = new VueRouter({ routes })
new Vue({ new Vue({
...@@ -87,5 +85,6 @@ ...@@ -87,5 +85,6 @@
} }
init() init()
</script> </script>
</html> </html>
\ No newline at end of file
//有关于条件的一些方法
function getFormatValue (value) {
var unit = '', num = 1
if(value < 10000){
unit = '', num = 1
}else if(10000 <= value && value < 100000000){
unit = '', num = 10000
}else if(100000000 <= value && value < 1000000000000){
unit = '亿', num = 100000000
}else if(value >= 1000000000000){
unit = '万亿', num = 1000000000000
}
return (value/num).toFixed(0) + unit
}
function getInputLength (text) {
var width = 0, span
if(!document.getElementById('invented')){
span = document.createElement('span')
span.id = 'invented'
span.innerHTML = text
document.body.appendChild(span)
}else{
span = document.getElementById('invented')
span.innerHTML = text
}
width = span.offsetWidth
return width + 4
}
exports.getFullIndexName = (index) => {
var indexName = index.name, merge = '', company = '', year = '', quarter = ''
if(index.needMergeType){
merge = '[' + index.mergeType + ']'
}
if(index.needReportData){
if(index.yearType == 1){
year = '[T:' + index.t + ']'
}else{
year = '[T:' + index.inputYear + ']'
}
if(index.quarterType == 1){
quarter = '[Q:' + index.q + ']'
}else{
quarter = '[Q:' + index.inputQuarter + ']'
}
}
if(index.needCompany && index.isAppointCompany){
company = '[' + index.selectedCompany + ']'
}
return indexName + year + quarter + merge + company
}
exports.getIndexType = (obj) => {
var newObj = {
needMergeType: false,
needReportData: false,
needCompany: false
}
if(obj.TypeContent){
obj.TypeContent.Parameters.forEach(item => {
if(item.Encode == 'F91997V'){
newObj.needMergeType = true
}
if(item.Encode == 'F91996D'){
newObj.needReportData = true
}
if(item.Encode == 'F90001V'){
newObj.needCompany = true
}
})
}
return newObj
}
exports.setSaveCondition = (condition)=>{ //格式化保存的条件,原名 getSaveCalCondition
var operands = []
var div = document.createElement('div')
div.innerHTML = condition.params.dom
var inputs = div.getElementsByTagName('input')
//后台的定义 0指标1符号2数字3时间4方法
//前台的定义 1指标2时间3数字4字符5方法
Array.from(inputs).forEach(item => {
var obj = {}, id = item.id
switch (parseInt(item.getAttribute('type'))) {
case 1: //指标
var param = condition.params.indexParams[id]
var dateYear = '1900'
var dateQuater = '06-30'
var evalArray = []
if (param.yearType == 1) {
evalArray.push({
"EvalOption": 1,
"Value": param.t
})
} else if (param.yearType == 2) {
dateYear = param.inputYear
}
if (param.quarterType == 1) {
evalArray.push({
"EvalOption": 2,
"Value": param.q
})
} else if (param.quarterType == 2) {
dateQuater = param.inputQuarter
}
var where = [
{
"State": 1,
"Encode": "F91996D",
"Value": dateYear + '-' + dateQuater,
"Eval": evalArray
},
{
"State": 1,
"Value": param.mergeType,
"Encode": "F91997V",
"Eval": []
}
]
if(param.isAppointCompany){
where.push({
"State": 1,
"Value": param.selectedCompany.split('-')[1],
"Encode": "F90001V",
"Eval": []
})
}
obj = {
"List": [param.code],
"Where": where,
"OperandType": 0,
}
break;
case 2: //时间
obj = {
"Value": item.value,
"OperandType": 3
}
break;
case 3: //数字
obj = {
"Value": item.value.replace(/\[.*?\]/g,''),
"OperandType": 2
}
break;
case 4: //字符
obj = {
"Value": item.value,
"OperandType": 1
}
break;
default:
break;
}
operands.push(obj)
})
return operands
}
exports.getSaveCondition = (
id, conditionContents, conditionSignature, paramsList, initIndexObj,companyNameObj, getEval, initIndex, that
)=>{ //格式化获取的条件原名 setCalCondition, 启动参数中 setEditCondition, 公司名称 searchCompanyName, 所有指标 getIndexCateGory(initIndexObj)
if(conditionSignature && that.conditionIndex < parseInt(conditionSignature)){
that.conditionIndex = parseInt(conditionSignature)
}
if(that){
that.$set(paramsList, id, {
id: id == 'start'?'start':(conditionSignature?conditionSignature:null),
params: {
indexParams: {},
dateParams: {},
numParams: {},
symbolParams: {},
dom: '',
showDom: ''
}
})
}
var param = paramsList[id].params
conditionContents.forEach(item => {
initIndex++
var id = new Date().getTime() + initIndex
var obj = {}
var inputDom = ''
var showDom = ''
var paramsType = ''
switch (item.OperandType) {
case 0: //指标
var index = initIndexObj[item.List[0]]
var condition = this.getIndexType(index)
var evalObj = getEval(item.Where[0])
obj = {
code: item.List[0],
id: id,
inputQuarter: evalObj.selsetQuarter,
inputYear: evalObj.selectYear,
q: evalObj.qQuarter,
t: evalObj.tYear,
quarterType: evalObj.reportQuarterType,
yearType: evalObj.reportYearType,
mergeType: item.Where[1].Value,
type: 1,
isAppointCompany: item.Where[2]?true:false,
selectedCompany: item.Where[2]?(companyNameObj[item.Where[2].Value] + '-' + item.Where[2].Value):'',
mark: index.Mark,
name: index.Name,
needMergeType: condition.needMergeType,
needReportData: condition.needReportData,
needCompany: condition.needCompany,
typeContent: index.TypeContent
}
var text = this.getFullIndexName(obj)
var width = getInputLength(text) + 'px'
inputDom = '<input readonly class="cal-index" type="1" id="'+ id +'" style="width:'+ width +'" value="'+ text +'" />'
showDom = '<span type="1">' + text + '</span>'
paramsType = 'indexParams'
break;
case 1: //符号
obj = {
id: id,
key: item.Value,
type: 4,
value: item.Value
}
var width = getInputLength(item.Value) + 'px'
var moreClass = ''
switch (item.Value) {
case '(': case ')':
moreClass = 'brackets'
break;
default:
break;
}
inputDom = '<input readonly class="cal-index ' + moreClass + '" type="4" id="'+ id +'" style="width:'+ width +'" value="'+ item.Value +'" />'
showDom = '<span type="4">' + item.Value + '</span>'
paramsType = 'symbolParams'
break;
case 2: //数字
obj = {
id: id,
type: 3,
value: item.Value
}
var text = item.Value + "[" + getFormatValue(item.Value) + "]"
var width = getInputLength(text) + 'px'
inputDom = '<input readonly class="cal-index" type="3" id="'+ id +'" style="width:'+ width +'" value="'+ text +'" />'
showDom = '<span type="3">' + text + '</span>'
paramsType = 'numParams'
break;
case 3: //时间
obj = {
id: id,
type: 2,
value: item.Value
}
var text = item.Value
var width = getInputLength(text) + 'px'
inputDom = '<input readonly class="cal-index" type="2" id="'+ id +'" style="width:'+ width +'" value="'+ text +'" />'
showDom = '<span type="2">' + text + '</span>'
paramsType = 'dateParams'
break;
case 4: //方法,暂不做处理
break;
default:
break;
}
// param[paramsType] = {}
param[paramsType][id] = obj
param.dom+=inputDom
param.showDom+=showDom
})
if(!param.showDom){
param.showDom = '<span>暂未设置条件</span>'
}
}
var mergeData = ['合并本期','合并上期','母公司本期','母公司上期']
module.exports = {
mergeData
}
...@@ -125,7 +125,7 @@ ...@@ -125,7 +125,7 @@
detail: '', detail: '',
id: 'smartWords', id: 'smartWords',
name: '智能词管理', name: '智能词管理',
path: './smartWords/index.html', path: '../../main_views/smartWords/smartWords.html',
useful: 1 useful: 1
} }
] ]
......
exports.getFullIndexName = () => {
}
async function getCustomWords() {
var condition = ''
var complexCondition = ''
var companySelector = ''
var indexCondition = ''
var value = await loadComponent('customWords', window.global.urls.loadUrl + '/src/views/main_views/smartWords/routers/customWords/index.vue')
return {
data: function () {
return {
searchInput: '',
defaultProps: {
children: 'children',
label: 'name'
},
detailType: 1, //1详情2编辑3文件夹0空
editWordName: '',
choosedPassCategory: [],
publicCategoryOptions: [],
editPosition: 3,
editConditionList: [],
initIndex: 1,
testSingleVisible: false,
runSingleTableLoading: false,
runSingleTableData: [],
testSearchName: '',
copyConditionHtml: null,
addWordLoading: false,
myTreeData: [],
treeData: [],
cascaderOptions: [],
cascaderProps: {
value: 'Id',
label: 'ArchiveName',
checkStrictly: true
},
detailTitle: '详情',
activeIndex: {},
inputedCategoryName: '',
addOrEditCategoryTitle: '',
addCategoryType: '',
addOrEditCategoryVisible: false,
createOrChangeCategoryLoading: false,
deirectionObj: {
"-1": "负面",
"0": "中性",
"1": "正面",
"2": '不确定',
"3": '未定义'
},
testRunType: 'single',
categoryDic: {},
treeLoading: true,
testTitle: '',
testRunWords: [],
testDirection: null,
testMinRiskLevel: 0,
testMaxRiskLevel: 10,
testMinRiskStrong: 0,
testMaxRiskStrong: 10,
runLoading: false,
initIndexObj: {},
companyNameObj: {},
activeWordConditions: [],
keyboardObj: {},
editWiki: '',
submitCategory: [],
publicProps: {
value: 'Id',
label: 'ArchiveName',
children: 'Children',
checkStrictly: true,
multiple: true
},
submitCategoryVisible: false,
submitLoading: false,
activeIndexStatus: 0,
wordsFilterType: 0,
isWordsDot: false,
IntervalId: 0,
wordsPermission: false
}
},
components: { condition, complexCondition, companySelector, indexCondition },
template: value.template,
mounted() {
var that = this
ipcRenderer.on('copy-multiple-condition-reply', function (event, arg) {
that.copyConditionHtml = arg
})
this.checkPermission(53, 'wordsPermission')
this.getSortBadge()
this.IntervalId = setInterval(() => {
this.getSortBadge()
}, 30000)
this.getIndexs().then(res => {
this.getWordsList()
this.getPublicCategory()
mytools.getKeyboardObj(mytools.getKeyboard(), this.keyboardObj)
})
},
beforeDestroy() {
clearInterval(this.IntervalId)
},
methods: {
checkPermission(id, key) {
return new Promise((resolve, reject) => {
http.netPost('Account/Account/CheckPermission', {
"id": id,
"AccountId": info.accountId
})
.then((res) => {
if (res.data.Status == 1) {
if (res.data.Data == 1) {
this[key] = true
}
resolve()
}
})
})
},
getSortBadge() {
return new Promise((resolve) => {
http.netPost('Data/SmartWord/GetTodoSmartWordCount', {
"AccountId": info.accountId
})
.then((res) => {
if (res.data.Status == 1) {
if (res.data.Data > 0) {
this.isWordsDot = true
} else {
this.isWordsDot = false
}
resolve(res)
}
})
})
},
changeIndexType() {
this.$refs.wordsTree.filter(this.searchInput)
// this.searchInputed = this.inputedIndex
},
getStatus(obj) {
if (!obj) {
return 1
}
console.log(obj)
var status = 0
obj.WdPublicSmartWordWorkflows.forEach(item => {
if (item.IsCurrent == 1) {
status = item.FlowStatus
}
})
return status
},
selectWord(data) {
console.log(data)
this.activeIndex = data
this.activeIndex.from = this.findPathByLeafId(data.myId, this.myTreeData)
if (data.isIndex) {
this.activeIndexStatus = this.getStatus(data)
this.detailType = 1
this.detailTitle = '指标详情-' + data.name
this.activeWordConditions = []
data.WdSmartWordCondition.forEach(item => {
this.activeWordConditions.push({
indexParams: {},
dateParams: {},
numParams: {},
symbolParams: {},
functionParams: {},
dom: '',
showDom: ''
})
})
this.getUsedCompany(data.WdSmartWordCondition).then(res => {
this.activeWordConditions.forEach((item, index) => {
this.initIndex++
mytools.getSaveCondition(
item,
data.WdSmartWordCondition[index].Condition,
this.initIndex,
this.initIndexObj,
this.companyNameObj,
this.keyboardObj
)
})
this.$nextTick(() => {
this.activeWordConditions.forEach((item, index) => {
var spans = document.getElementById('conditionBox' + index).getElementsByTagName('span')
var html = ''
Array.from(spans).forEach(span => {
html += span.outerHTML
})
document.getElementById('conditionBox' + index).innerHTML = html
var spans = document.getElementById('conditionBox' + index).getElementsByTagName('span')
mytools.formatShowDom(spans)
})
})
})
this.activeIndex.from = this.findPathByLeafId(data.myId, this.myTreeData)
} else {
this.detailType = 3
this.detailTitle = '文件夹操作-' + this.activeIndex.name
}
},
findPathByLeafId(leafId, nodes, path) {
if (path === undefined) {
path = []
}
for (var i = 0; i < nodes.length; i++) {
var tmpPath = path.concat()
tmpPath.push({
myId: nodes[i].myId,
name: nodes[i].name,
id: nodes[i].Id
})
if (leafId == nodes[i].myId) {
return tmpPath;
}
if (nodes[i].children) {
var findResult = this.findPathByLeafId(leafId, nodes[i].children, tmpPath);
if (findResult) {
return findResult
}
}
}
},
formatIndexFrom(arr) {
if (arr) {
var newArr = []
arr.forEach(item => {
newArr.push(item.name)
})
return newArr.join(' / ')
}
return ''
},
addConditionList() {
this.initIndex++
var id = new Date().getTime() + this.initIndex
this.editConditionList.push({
id: id,
riskLevel: 0,
signalLevel: 0,
complexCondition: {},
simpleCondition: {
operator: '&&',
content: []
},
conditionType: 0,
completed: false,
selectedType: null
})
},
removeConditionList(index) {
this.editConditionList.splice(index, 1)
},
completeSettedCondition(index) {
var activeObj = this.editConditionList[index]
if (activeObj.conditionType == 1) {
this.$set(activeObj, 'complexCondition', this.$refs['complexcondition' + index][0].sendDataToHost(true))
activeObj.selectedType = 1
} else {
this.$refs['simplecondition' + index][0].completedEdit()
activeObj.selectedType = 2
}
activeObj.completed = true
activeObj.conditionType = 0
},
resetCondition(index) {
var id = this.editConditionList[index].id
this.$set(this.editConditionList, index, {
id: id,
riskLevel: 0,
signalLevel: 0,
complexCondition: {},
simpleCondition: {
operator: '&&',
content: []
},
conditionType: 0,
completed: false,
selectedType: null
})
},
setCondition(item, type, index) {
if (type == 1) {
item.conditionType = 1
} else {
item.conditionType = 2
this.$refs['simplecondition' + index][0].resetEdit()
}
},
editNowCondition(index) {
var activeObj = this.editConditionList[index]
if (activeObj.selectedType == 1) {
activeObj.conditionType = 1
} else {
this.$refs['simplecondition' + index][0].resetEdit()
activeObj.conditionType = 2
}
activeObj.completed = false
},
editWord() {
this.detailType = 2
this.detailTitle = "编辑智能词"
this.detailTitle = "编辑智能词"
this.editWiki = this.activeIndex.Wiki
this.choosedPassCategory = this.getEditIndexCategory()
this.editWordName = this.activeIndex.name
this.editPosition = this.activeIndex.Direction
this.editConditionList = []
this.activeIndex.WdSmartWordCondition.forEach((item, index) => {
this.initIndex++
var id = new Date().getTime() + this.initIndex
if (item.ShowType == 1) {
this.editConditionList.push({
id: id,
riskLevel: item.RiskLevel,
signalLevel: item.SignalStrength,
complexCondition: item.ShowType == 1 ? this.activeWordConditions[index] : {},
simpleCondition: {
operator: '&&',
content: []
},
conditionType: 0,
completed: true,
selectedType: item.ShowType
})
} else if (item.ShowType == 2) {
this.editConditionList.push({
id: id,
riskLevel: item.RiskLevel,
signalLevel: item.SignalStrength,
complexCondition: {},
simpleCondition: {
operator: '&&',
content: this.setSimpleCondition(item.Condition)
},
conditionType: 0,
completed: true,
selectedType: item.ShowType
})
// this.setSimpleCondition(item.Condition.Object)
}
})
var that = this
this.$nextTick(() => {
this.activeIndex.WdSmartWordCondition.forEach((item, index) => {
if (item.ShowType == 1) {
that.$refs['complexcondition' + index][0].indexParams = that.activeWordConditions[index].indexParams
that.$refs['complexcondition' + index][0].numParams = that.activeWordConditions[index].numParams
that.$refs['complexcondition' + index][0].dateParams = that.activeWordConditions[index].dateParams
that.$refs['complexcondition' + index][0].symbolParams = that.activeWordConditions[index].symbolParams
that.$refs['complexcondition' + index][0].functionParams = that.activeWordConditions[index].functionParams
for (var key in that.activeWordConditions[index].functionParams) {
that.activeWordConditions[index].functionParams[key].paramsValue.forEach(item => {
var arr = ['indexParams', 'numParams', 'dateParams', 'symbolParams']
arr.forEach(child => {
for (var key in item[child]) {
that.$refs['complexcondition' + index][0].indexParams[key] = item[child]
}
})
})
}
that.$refs['complexcondition' + index][0].setHtml(that.activeWordConditions[index].dom)
}
})
})
},
setSimpleCondition(arr) {
var content = []
var firsrArr = []
var finalArr = []
//第一步找出最外层
arr.forEach((item, index) => {
if (item.Value && arr[index - 1] && arr[index - 2] && (item.Value == '&&' || item.Value == '||') && arr[index - 1].Value == ')' && arr[index - 2].Value == ')') {
firsrArr.push(index)
}
})
if (firsrArr.length > 0) {
var resultArr = []
var spliceArr = JSON.parse(JSON.stringify(firsrArr))
spliceArr.unshift(0)
spliceArr.push(arr.length)
for (var i = 0; i < spliceArr.length - 1; i++) {
resultArr.push(arr.slice(i == 0 ? 0 : spliceArr[i] + 1, spliceArr[i + 1]))
}
var newresult = []
resultArr.forEach((item, index) => {
var newarr = []
item.forEach(sub => {
if ((sub.Value && sub.Value !== '(' && sub.Value !== ')') || !sub.Value) {
newarr.push(sub)
}
})
newresult.push(newarr)
})
newresult.forEach(item => {
var newArr = []
var indexArr = [0]
item.forEach((sub, index) => {
if (sub.Value == '&&' || sub.Value == '||') {
indexArr.push(index)
}
})
indexArr.push(item.length)
var smallArr = []
for (var i = 0; i < indexArr.length - 1; i++) {
smallArr.push(item.slice(i == 0 ? 0 : indexArr[i], indexArr[i + 1]))
}
newArr.push(smallArr)
finalArr.push(newArr)
})
} else {
var newarr = []
arr.forEach((sub, index) => {
if ((sub.Value && sub.Value !== '(' && sub.Value !== ')') || !sub.Value) {
newarr.push(sub)
}
})
var centerArr = []
var indexArr = [0]
newarr.forEach((sub, index) => {
if (sub.Value == '&&' || sub.Value == '||') {
indexArr.push(index)
}
})
indexArr.push(newarr.length)
var smallArr = []
for (var i = 0; i < indexArr.length - 1; i++) {
smallArr.push(newarr.slice(i == 0 ? 0 : indexArr[i], indexArr[i + 1]))
}
centerArr.push(smallArr)
finalArr.push(centerArr)
finalArr.push(smallArr)
}
for (var i = 0; i < firsrArr.length + 1; i++) {
content.push({
content: this.getSimpleContent(finalArr[i]),
operator: i == 0 ? '&&' : arr[firsrArr[i - 1]].Value
})
}
return content
},
getItemType(item) {
var type = ''
switch (item.OperandType) {
case 0:
type = 'index'
break;
case 2:
type = 'number'
break;
case 3:
type = 'time'
break;
default:
break;
}
return type
},
setSingleCondition(content, item) {
var evalObj1 = {}, evalObj2 = {}, evalObj3 = {}
var index1 = null, index2 = null, index3 = null
var num = item.length
switch (num) {
case 3:
index1 = 0
index2 = 2
break;
case 4:
index1 = 1
index2 = 3
break;
case 5:
index1 = 0
index2 = 2
index3 = 4
break;
case 6:
index1 = 1
index2 = 3
index3 = 5
break;
default:
break;
}
if (item[index1].OperandType == 0) {
evalObj1 = this.getEval(item[index1].Where[0])
}
if (item[index2].OperandType == 0) {
evalObj2 = this.getEval(item[index2].Where[0])
}
if (index3 && item[index3].OperandType == 0) {
evalObj3 = this.getEval(item[index3].Where[0])
}
content.push({
index1: item[index1].OperandType == 0 ? {
indexCode: item[index1].List[0],
indexName: this.initIndexObj[item[index1].List[0]].Name,
mark: this.initIndexObj[item[index1].List[0]].Mark,
mergeType: item[index1].Where[1].Value,
typeContent: this.initIndexObj[item[index1].List[0]].TypeContent,
origin: "",
qQuarter: evalObj1.qQuarter,
reportQuarterType: evalObj1.reportQuarterType,
reportYearType: evalObj1.reportYearType,
selectYear: evalObj1.selectYear,
selsetQuarter: evalObj1.selsetQuarter,
tYear: evalObj1.tYear,
} : {},
input1: item[index1].OperandType == 2 ? item[index1].Value : '',
time1: item[index1].OperandType == 3 ? item[index1].Value : '',
type1: this.getItemType(item[index1]),
showType1: true,
symbol1: item[index1 + 1].Value,
index2: item[index2].OperandType == 0 ? {
indexCode: item[index2].List[0],
indexName: this.initIndexObj[item[index2].List[0]].Name,
mark: this.initIndexObj[item[index2].List[0]].Mark,
mergeType: item[index2].Where[1].Value,
typeContent: this.initIndexObj[item[index2].List[0]].TypeContent,
origin: "",
qQuarter: evalObj2.qQuarter,
reportQuarterType: evalObj2.reportQuarterType,
reportYearType: evalObj2.reportYearType,
selectYear: evalObj2.selectYear,
selsetQuarter: evalObj2.selsetQuarter,
tYear: evalObj2.tYear,
} : {},
input2: item[index2].OperandType == 2 ? item[index2].Value : '',
time2: item[index2].OperandType == 3 ? item[index2].Value : '',
type2: this.getItemType(item[index2]),
showType2: false,
symbol2: index3 ? item[index3 - 1].Value : '',
index3: index3 ? (item[index3].OperandType == 0 ? {
indexCode: item[index3].List[0],
indexName: this.initIndexObj[item[index3].List[0]].Name,
mark: this.initIndexObj[item[index3].List[0]].Mark,
mergeType: item[index3].Where[1].Value,
typeContent: this.initIndexObj[item[index3].List[0]].TypeContent,
origin: "",
qQuarter: evalObj3.qQuarter,
reportQuarterType: evalObj3.reportQuarterType,
reportYearType: evalObj3.reportYearType,
selectYear: evalObj3.selectYear,
selsetQuarter: evalObj3.selsetQuarter,
tYear: evalObj3.tYear,
} : {}) : {},
input3: index3 ? (item[index3].OperandType == 2 ? item[index3].Value : '') : '',
time3: index3 ? (tem[index3].OperandType == 3 ? item[index3].Value : '') : '',
type3: index3 ? (this.getItemType(item[index3])) : '',
linkCondition: (item.length == 4 || item.length == 6) ? (item[0].Value == '&&' ? 'and' : 'or') : 'and',
showHandle: true
})
},
getSimpleContent(arr) {
var content = []
arr.forEach(item => {
item.forEach(sub => {
this.setSingleCondition(content, sub)
})
})
return content
},
getEval(item) {
var newObj = {
reportYearType: 1,
tYear: 0,
selectYear: '',
reportQuarterType: 1,
qQuarter: 0,
selsetQuarter: ''
}
switch (item.Eval.length) {
case 0:
newObj.reportYearType = 2
newObj.selectYear = item.Value.slice(0, 4)
newObj.reportQuarterType = 2
newObj.qQuarter = 0
newObj.tYear = 0
newObj.selsetQuarter = item.Value.slice(5, 10)
break;
case 1:
if (item.Eval[0].EvalOption == 1) { //年度为t
newObj.reportYearType = 1
newObj.tYear = item.Eval[0].Value
newObj.selectYear = item.Value.slice(0, 4)
newObj.reportQuarterType = 2
newObj.qQuarter = 0
newObj.selsetQuarter = item.Value.slice(5, 10)
} else if (item.Eval[0].EvalOption == 2) {
newObj.reportYearType = 2
newObj.tYear = 0
newObj.selectYear = item.Value.slice(0, 4)
newObj.reportQuarterType = 1
newObj.qQuarter = item.Eval[0].Value
newObj.selsetQuarter = item.Value.slice(5, 10)
}
break;
case 2:
newObj.reportYearType = 1
newObj.selectYear = ''
newObj.reportQuarterType = 1
newObj.selsetQuarter = ''
newObj.qQuarter = item.Eval[1].Value
newObj.tYear = item.Eval[0].Value
break;
default:
break;
}
return newObj
},
getEditIndexCategory() {
var arr = []
this.activeIndex.from.forEach((item, index) => {
if (index < this.activeIndex.from.length - 1) {
arr.push(item.id)
}
})
return arr
},
backToDetail() {
this.detailType = 1
},
testRunSingle() {
this.testSingleVisible = true
this.testRunType = 'single'
this.testTitle = '单智能词测试'
this.testRunWords = [this.activeIndex]
},
testRunMultiple() {
this.testSingleVisible = true
this.testRunType = 'multiple'
this.testTitle = '批量智能词测试'
this.testRunWords = []
},
getIndexs() {
return new Promise((resolve, reject) => {
http.netPost('Data/Encode/GetEncodeList', {
"Current": 0,
"Psize": 100,
"Code": "B",
'Name': '',
"AccountId": info.accountId
})
.then((res) => {
if (res.data.Status == 1) {
this.treeData = res.data.Data.Records
this.creatIndexObj(res.data.Data.Records)
resolve()
}
})
})
},
returnSimpleCondition(sub, num) {
var obj = {}
switch (sub['type' + num]) {
case 'index':
var param = sub["index" + num]
var dateYear = '1900'
var dateQuater = '06-30'
var evalArray = []
if (param.reportYearType == 1) {
evalArray.push({
"EvalOption": 1,
"Value": param.tYear
})
} else if (param.reportYearType == 2) {
dateYear = param.selectYear
}
if (param.reportQuarterType == 1) {
evalArray.push({
"EvalOption": 2,
"Value": param.qQuarter
})
} else if (param.reportQuarterType == 2) {
dateQuater = param.selsetQuarter
}
var where = [
{
"State": 1,
"Encode": "F91996D",
"Value": dateYear + '-' + dateQuater,
"Eval": evalArray
},
{
"State": 1,
"Value": param.mergeType,
"Encode": "F91997V",
"Eval": []
}
]
obj = {
"List": [param.indexCode],
"Where": where,
"OperandType": 0
}
break;
case 'number':
obj = {
"Value": parseFloat(sub["input" + num]),
"OperandType": 2
}
break;
case 'time':
obj = {
"Value": sub["time" + num],
"OperandType": 3
}
break;
default:
break;
}
return obj
},
getSingleCondition(condition) {
var content = []
condition.content.forEach((item, index) => {
if (index) {
content.push({
"Value": item.operator,
"OperandType": 1
})
}
content.push({
"Value": '(',
"OperandType": 1
})
item.content.forEach((sub, index) => {
if (index) {
content.push({
"Value": sub.linkCondition == 'and' ? '&&' : '||',
"OperandType": 1
})
}
content.push({
"Value": '(',
"OperandType": 1
})
content.push(this.returnSimpleCondition(sub, 1))
content.push({
"Value": sub.symbol1,
"OperandType": 1
})
content.push(this.returnSimpleCondition(sub, 2))
if (sub.type3) {
content.push({
"Value": sub.symbol2,
"OperandType": 1
})
content.push(this.returnSimpleCondition(sub, 3))
}
content.push({
"Value": ')',
"OperandType": 1
})
})
content.push({
"Value": ')',
"OperandType": 1
})
})
return content
},
//新增关键词
addSmartWord() {
this.addWordLoading = true
var conditions = []
this.editConditionList.forEach(item => {
var obj = {
"content": item.selectedType == 1 ? conditionFuns.setSaveCondition({ params: item.complexCondition }) : this.getSingleCondition(item.simpleCondition),
"riskLevel": item.riskLevel,
"signalStrength": item.signalLevel,
"showType": item.selectedType
}
conditions.push(obj)
})
return new Promise((resolve, reject) => {
http.netPost('Data/SmartWord/AddMySmartWord', {
"id": this.activeIndex.isIndex ? this.activeIndex.Id : 0,
"name": this.editWordName,
"archiveId": this.choosedPassCategory[this.choosedPassCategory.length - 1],
"direction": this.editPosition, //-1 负 0 中性 1正面
"conditions": conditions,
"Wiki": this.editWiki,
"AccountId": info.accountId
})
.then((res) => {
if (res.data.Status == 1) {
this.detailType = 1
this.detailTitle = "详情"
this.$message({
message: (this.activeIndex.isIndex && this.activeIndex.Id) ? "智能词编辑成功!" : "智能词新增成功!",
type: "success"
})
this.getWordsList()
}
this.addWordLoading = false
})
})
},
//获取关键词
getWordsList() {
this.treeLoading = true
return new Promise((resolve, reject) => {
http.netPost('Data/SmartWord/GetMySmartWord', {
"AccountId": info.accountId
})
.then((res) => {
res.data.Data.forEach(item => {
this.initIndex++
item.myId = new Date().getTime() + this.initIndex
item.name = item.ArchiveName
this.categoryDic[item.Id] = item.myId
if (item.Required) {
this.defaultCategoryId = item.Id
}
})
res.data.Data.forEach(item => {
item.parentId = this.categoryDic[item.ParentId]
})
var categroyData = JSON.parse(JSON.stringify(res.data.Data))
var cascaderData = JSON.parse(JSON.stringify(res.data.Data))
this.myTreeData = this.setTreeData(this.indexIntoCategroy(categroyData), 'myId', 'parentId')
this.cascaderOptions = this.setTreeData(cascaderData, 'Id', 'ParentId')
this.activeIndex = {}
this.detailType = 1
this.treeLoading = false
})
})
},
setTreeData(jsonData, id, pid) {
let result = [],
temp = {}
for (let i = 0; i < jsonData.length; i++) {
temp[jsonData[i][id]] = jsonData[i]
}
for (let j = 0; j < jsonData.length; j++) {
let currentElement = jsonData[j]
let tempCurrentElementParent = temp[currentElement[pid]]
if (tempCurrentElementParent) {
if (!tempCurrentElementParent["children"]) {
tempCurrentElementParent["children"] = []
}
tempCurrentElementParent["children"].push(currentElement)
} else {
result.push(currentElement)
}
}
return result
},
indexIntoCategroy(data) {
var newData = JSON.parse(JSON.stringify(data))
newData.forEach(item => {
item.name = item.ArchiveName
})
data.forEach(item => {
item.WdSmartWord.forEach(sub => {
var newSub = JSON.parse(JSON.stringify(sub))
this.initIndex++
newSub.myId = new Date().getTime() + this.initIndex
newSub.CurrentFlowStatus = this.getStatus(newSub)
newSub.parentId = item.myId
newSub.isIndex = true
newSub.name = newSub.Name
newData.push(newSub)
})
})
return newData
},
openAddCategory() {
this.inputedCategoryName = ''
this.addOrEditCategoryTitle = '新增分类'
this.addCategoryType = 'add'
this.addOrEditCategoryVisible = true
},
openChangeCategory() {
this.inputedCategoryName = this.activeIndex.ArchiveName
this.addOrEditCategoryTitle = '修改分类'
this.addCategoryType = 'edit'
this.addOrEditCategoryVisible = true
},
createOrChangeCategory() {
this.createOrChangeCategoryLoading = true
return new Promise((resolve, reject) => {
http.netPost('Data/SmartWord/AddMySmartWordArchive', {
"id": this.addCategoryType == 'add' ? 0 : this.activeIndex.Id,
"name": this.inputedCategoryName,
"parentId": this.addCategoryType == 'add' ? this.activeIndex.Id : this.activeIndex.ParentId,
"accountId": info.accountId
})
.then((res) => {
this.createOrChangeCategoryLoading = false
if (res.data.Status == 1) {
this.addOrEditCategoryVisible = false
this.getWordsList()
resolve()
}
})
})
},
filterTreeNode(value, data) {
// if (!value) return true;
// return data.name.indexOf(value) !== -1;
if (!value) {
if (this.wordsFilterType == 0) {
return true
} else {
if (this.wordsFilterType == 1 && data.CurrentFlowStatus == 1) {
return true
}
if (this.wordsFilterType == 3 && (data.CurrentFlowStatus == 2 || data.CurrentFlowStatus == 4)) {
return true
}
if (this.wordsFilterType == 16 && data.CurrentFlowStatus == 16) {
return true
}
if (this.wordsFilterType == 32 && data.CurrentFlowStatus == 32) {
return true
}
}
} else {
if (this.wordsFilterType == 0 && data.name.indexOf(value) !== -1) {
return true
} else {
if (this.wordsFilterType == 1 && data.CurrentFlowStatus == 1 && data.name.indexOf(value) !== -1) {
return true
}
if (this.wordsFilterType == 3 && (data.CurrentFlowStatus == 2 || data.CurrentFlowStatus == 4) && data.name.indexOf(value) !== -1) {
return true
}
if (this.wordsFilterType == 16 && data.CurrentFlowStatus == 16 && data.name.indexOf(value) !== -1) {
return true
}
if (this.wordsFilterType == 32 && data.CurrentFlowStatus == 32 && data.name.indexOf(value) !== -1) {
return true
}
}
}
},
searchIndex() {
this.$refs.wordsTree.filter(this.searchInput)
},
removeIndex() {
return new Promise((resolve, reject) => {
http.netPost('Data/SmartWord/RmoveMySmartWord', {
"id": this.activeIndex.Id,
"AccountId": info.accountId
})
.then((res) => {
if (res.data.Status == 1) {
this.$message({
message: "智能词删除成功!",
type: "success"
})
this.getWordsList()
resolve()
}
})
})
},
openAddNewWord() {
this.detailType = 2
this.detailTitle = "新增智能词"
this.editWordName = ''
this.editWiki = ''
var arr = []
this.activeIndex.from.forEach(item => {
arr.push(item.id)
})
this.choosedPassCategory = arr
this.editPosition = 3
},
handleCheckChange() {
this.testRunWords = []
var choosed = this.$refs.testWordsTree.getCheckedNodes(true, false)
this.testRunWords = choosed.filter(item => item.isIndex)
},
deleteCategory() {
return new Promise((resolve, reject) => {
http.netPost('Data/SmartWord/RmoveMySmartWordArchive', {
"id": this.activeIndex.Id,
"AccountId": info.accountId
})
.then((res) => {
if (res.data.Status == 1) {
this.$message({
message: "文件夹删除成功!",
type: "success"
})
this.getWordsList()
resolve()
}
})
})
},
searchTestWords() {
this.$refs.testWordsTree.filter(this.testSearchName)
},
confirmRunWords() {
var arr = []
this.testRunWords.forEach(item => {
arr.push(item.Id)
})
var args = []
var ref = this.$refs.conditionChoose
var selectedRangeCompany = this.$refs.companySelector.selectedRangeCompany
if (!ref.testMergeType || !ref.testYear || !ref.testQuarter || selectedRangeCompany.length == 0) {
this.$message({
message: '参数不完整或标的为空',
type: 'error'
})
return false
}
selectedRangeCompany.forEach(item => {
args.push({
stockCode: item.code,
argType: 1
})
})
args.push({
mergeType: ref.testMergeType,
argType: 2
}, {
reportingPeriod: ref.testYear + '-' + ref.testQuarter,
argType: 4
})
this.runLoading = true
this.runSingleTableLoading = true
return new Promise((resolve, reject) => {
http.netPost('Data/SmartWord/TestRunMySmartWord', {
"id": arr,
"args": args,
"direction": this.testDirection,
"riskLevel": [this.testMinRiskLevel, this.testMaxRiskLevel],
"signalStrength": [this.testMinRiskStrong, this.testMaxRiskStrong],
"AccountId": info.accountId
})
.then((res) => {
if (res.data.Status == 1) {
var arr = JSON.parse(JSON.stringify(this.$refs.companySelector.selectedRangeCompany))
arr.forEach(item => {
item.value = res.data.Data[item.code]
})
this.runSingleTableData = arr
resolve()
} else {
this.runSingleTableData = JSON.parse(JSON.stringify(this.$refs.companySelector.selectedRangeCompany))
}
this.runLoading = false
this.runSingleTableLoading = false
})
})
},
getRunningResult(arr) {
if (arr) {
var newArr = []
arr.forEach(item => {
newArr.push(item.SmartWord.Name)
})
return newArr.join('')
} else {
return '-'
}
},
creatIndexObj(initData) {
initData.forEach(element => {
if (element.Sub.length > 0) {
this.creatIndexObj(element.Sub)
} else {
this.initIndexObj[element.Code] = element
}
})
},
getUsedCompany(arr) {
var codes = []
arr.forEach(item => {
var params = item.Condition
params.forEach(item => {
if (item.OperandType == 0 && item.Where[2]) {
codes.push(item.Where[2].Value)
} else if (item.OperandType == 4) {
item.Args.forEach(sub => {
sub.forEach(child => {
if (child.OperandType == 0 && child.Where[2]) {
codes.push(child.Where[2].Value)
}
})
})
}
})
})
var where = [{
"Encode": "F90001V",
"State": 7,
"Value": codes.join(','),
}]
return new Promise((resolve, reject) => {
http.netPost('Data/Query/Query', {
"List": ['F90001V', 'F90002V'],
"Where": where,
"Current": 0,
"Psize": 100
})
.then((res) => {
if (res.data.Status == 1) {
res.data.Data.Records.forEach(item => {
this.companyNameObj[item.F90001V] = item.F90002V
})
resolve()
} else if (res.data.Status == 0) {
resolve()
} else {
reject()
}
})
})
},
exportExcel() {
var that = this
var excelName = new Date().getTime()
var xlsx = officegen('xlsx')
var filePath = dialog.showSaveDialog({
defaultPath: excelName + '.xlsx',
title: '保存',
buttonLabel: '保存'
})
xlsx.on('finalize', function (written) {
that.$message({
message: '表格导出成功!',
type: 'success'
})
})
xlsx.on('error', function (err) {
console.log(err)
})
var sheet = xlsx.makeNewSheet()
sheet.name = 'sheet'
sheet.orientation = 'landscape'
sheet.data[0] = []
sheet.data[0][0] = '序号'
sheet.data[0][1] = '证券简称'
sheet.data[0][2] = '证券代码'
sheet.data[0][3] = '运行结果'
var newArr = JSON.parse(JSON.stringify(this.runSingleTableData))
newArr.forEach((item, index) => {
sheet.data[index + 1] = []
sheet.data[index + 1][0] = index + 1
sheet.data[index + 1][1] = item['name']
sheet.data[index + 1][2] = item['code']
sheet.data[index + 1][3] = this.getRunningResult(item['value'])
})
var out = fs.createWriteStream(filePath)
out.on('error', function (err) {
console.log(err)
})
xlsx.generate(out)
},
submitWords() {
this.submitCategoryVisible = true
},
getPublicCategory() {
return new Promise((resolve, reject) => {
http.netPost('Data/SmartWord/GetPublicSmartWordArchive', {})
.then((res) => {
if (res.data.Status == 1) {
this.publicCategoryOptions = res.data.Data
resolve()
}
})
})
},
confirmSubmit() {
if (!this.submitCategory) {
this.$message({
message: '请选择分类',
type: 'error'
})
return false
}
this.submitLoading = true
var arr = []
this.submitCategory.forEach(item => {
arr.push(item[item.length - 1])
})
return new Promise((resolve, reject) => {
http.netPost('Data/SmartWord/SubmitToPublicView', {
"id": this.activeIndex.Id,
"remark": "",
"archiveIds": arr,
"AccountId": info.accountId
})
.then((res) => {
if (res.data.Status == 1) {
this.activeIndex = {}
this.getWordsList()
this.$message({
message: '审核提交成功',
type: 'success'
})
resolve()
}
this.submitLoading = false
this.submitCategoryVisible = false
})
})
},
cancelSubmit() {
return new Promise((resolve, reject) => {
http.netPost('Data/SmartWord/UndoSubmitToPublicView', {
"id": this.activeIndex.Id,
"AccountId": info.accountId
})
.then((res) => {
if (res.data.Status == 1) {
this.$message({
message: "撤销提交成功",
type: "success"
})
this.activeIndex = {}
this.getWordsList()
resolve()
}
})
})
}
}
}
}
\ No newline at end of file
<template>
<div class="container">
<div class="header shadow">
<div class="header-router">
<div class="parent-name">智能词管理</div>
<div class="router-list" style="display: flex">
<router-link tag="span" active-class="active-link" exact to="/">我的智能词</router-link>
<router-link tag="span" active-class="active-link" exact to="/publicWords">公共智能词</router-link>
<el-badge :is-dot="isWordsDot && wordsPermission" class="item">
<router-link tag="span" active-class="active-link" exact to="/wordsAudit">智能词审核</router-link>
</el-badge >
<router-link tag="span" style="flex: auto; text-align: right;border-left: 0" active-class="active-link" exact to="/wordsRecord">
<span class="el-icon-date"> 指标修改日志</span>
</router-link>
</div>
</div>
<div class="header-search">
<div>
<el-button type="primary" icon="el-icon-odometer" size="mini" @click="testRunMultiple">批量测试</el-button>
</div>
</div>
</div>
<div class="main-body">
<div class="words-list">
<div class="body-title no-margin" style="display: flex">
<span class="active" style="flex: auto">我的智能词</span>
<el-radio-group
class="my-radio"
@change="changeIndexType"
v-model="wordsFilterType"
size="mini"
>
<el-radio-button :label="0">全部</el-radio-button>
<el-radio-button :label="1">未提交</el-radio-button>
<el-radio-button :label="3">待审核</el-radio-button>
<el-radio-button :label="16">通过</el-radio-button>
<el-radio-button :label="32">未通过</el-radio-button>
</el-radio-group>
</div>
<div class="words-list-search">
<el-input
v-model="searchInput"
size="mini"
suffix-icon="el-icon-edit"
clearable
ref="wordsTree"
@keyup.enter.native="searchIndex"
placeholder="输入智能词进行搜索"
></el-input>
</div>
<div class="words-list-inner">
<el-tree
:data="myTreeData"
v-loading="treeLoading"
ref="wordsTree"
:props="defaultProps"
:filter-node-method="filterTreeNode"
@node-click="selectWord">
<span class="custom-tree-node" slot-scope="{ node, data }">
<span class="el-icon-folder" v-show="!data.isIndex"></span>
<span style="font-size: 12px">{{ node.label }}</span>
</span>
</el-tree>
</div>
</div>
<div class="words-detail">
<div class="body-title border">
<span>{{detailTitle}}</span>
<el-popconfirm @onConfirm="backToDetail" title="指标正在编辑中,确认返回?">
<el-button v-show="detailType == 2" slot="reference" class="back-btn" size="mini" icon="el-icon-back">返回</el-button>
</el-popconfirm>
</div>
<!-- 智能词详情显示 -->
<div class="action-list" v-show="detailType == 1 && activeIndex.isIndex">
<span class="el-icon-odometer" @click="testRunSingle">测试</span>
<span class="el-icon-edit" v-show="activeIndexStatus !== 2" @click="editWord">编辑</span>
<span class="el-icon-s-check"
v-show="activeIndexStatus == 1 || activeIndexStatus == 32 || activeIndexStatus == 0"
@click="submitWords">提交审核</span>
<el-popconfirm title="是否确认撤销提交该智能词?"
v-show="activeIndexStatus == 2"
@onConfirm="cancelSubmit">
<span
slot="reference"
class="el-icon-refresh-left"
>撤销提交</span>
</el-popconfirm>
<el-popconfirm
title="是否确认删除该智能词?"
@onConfirm="removeIndex">
<span slot="reference" v-show="activeIndexStatus !== 2" class="el-icon-delete">删除</span>
</el-popconfirm>
</div>
<div class="words-detail-inner" v-show="detailType == 1 && activeIndex.isIndex">
<div class="form-item">
<div class="title">智能词名称:</div>
<div class="detail">{{activeIndex.name}}</div>
</div>
<div class="form-item">
<div class="title">分类:</div>
<div class="detail">{{formatIndexFrom(activeIndex.from)}}</div>
</div>
<div class="form-item">
<div class="title">智能词风控方向:</div>
<div class="detail" v-if="activeIndex.Direction || activeIndex.Direction == 0">{{deirectionObj[activeIndex.Direction.toString()]}}</div>
</div>
<div class="form-item">
<div class="title">智能词百科:</div>
<div class="detail" v-if="activeIndex.Wiki">{{activeIndex.Wiki}}</div>
</div>
<div class="form-item">
<div class="title">条件:</div>
<div class="detail" v-if="activeIndex.WdSmartWordCondition">
<div class="condition-list" v-for="(item,index) in activeIndex.WdSmartWordCondition">
<div class="condition-box" :id="'conditionBox' + index" v-html="activeWordConditions[index].showDom"></div>
<div class="condition-detail">
<div class="condition-detail-list">
<div class="inline-block">
<span class="gray">风控等级:</span>
<span>{{item.RiskLevel}}</span>
</div>
<div class="inline-block">
<span class="gray">信号强度:</span>
<span>{{item.SignalStrength}}</span>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="words-detail-inner" v-show="detailType == 1 && !activeIndex.isIndex">
<div class="empty-status">
<img src="../../static/image/empty.png" />
<div class="empty-tip">请从左侧点击指标或者分类</div>
</div>
</div>
<!-- 智能词编辑显示 -->
<div class="words-detail-inner" v-show="detailType == 2">
<div class="form-item center">
<div class="title">智能词名称:</div>
<div class="detail">
<el-input size="mini" style="width: 300px" v-model="editWordName" placeholder="请输入智能词名称"></el-input>
</div>
</div>
<div class="form-item">
<div class="title">分类:</div>
<div class="detail">
<el-cascader
size="mini"
style="width: 300px"
:props="cascaderProps"
placeholder="请选择所属分类"
v-model="choosedPassCategory"
:options="cascaderOptions">
</el-cascader>
</div>
</div>
<div class="form-item">
<div class="title">智能词风控方向:</div>
<div class="detail">
<el-radio-group class="small-radio" v-model="editPosition">
<el-radio :label="1">正面</el-radio>
<el-radio :label="0">中性</el-radio>
<el-radio :label="-1">负面</el-radio>
<el-radio :label="2">不确定</el-radio>
<el-radio :label="3">未定义</el-radio>
</el-radio-group>
</div>
</div>
<div class="form-item">
<div class="title">智能词百科:</div>
<div class="detail">
<el-input
type="textarea"
:rows="10"
size="mini"
style="width: 600px"
placeholder="请输入智能词百科"
v-model="editWiki">
</el-input>
</div>
</div>
<div class="form-item">
<div class="title">条件:</div>
<div class="detail">
<div class="condition-list-box">
<transition-group name="slide-fade">
<div class="condition-list" :key="item.id" v-for="(item, index) in editConditionList">
<div class="condition-box">
<div v-show="item.conditionType == 0 && !item.selectedType">
<span class="hover-icon red" @click="setCondition(item, 1, index)">设置复杂条件</span>
<span class="hover-icon red" @click="setCondition(item, 2, index)" style="margin-left: 12px">设置简易条件</span>
</div>
<div>
<div class="complex-condition-showDom"
v-show="item.selectedType == 1 && item.completed">
<div v-html="item.complexCondition.showDom"></div>
</div>
<complexCondition
:ref="'complexcondition' + index"
v-show="item.conditionType == 1 && !item.completed"
class="complex-condition"
:treeData="treeData"
:type="'condition'" />
<div class="simple-condition-box"
v-show="(item.conditionType == 2 && !item.completed) || (item.conditionType == 0 && item.selectedType == 2 && item.completed)">
<condition
:treeData="treeData"
:indexNameList="[]"
:type="1"
:ref="'simplecondition' + index"
:selectedCondition="item.simpleCondition" />
</div>
</div>
<div style="margin-top: 12px"
v-show="item.conditionType !== 0 && !item.completed"
class="hover-icon red condition-action">
<span @click="completeSettedCondition(index)">完成条件设置</span>
<span style="margin-left:12px" @click="resetCondition(index)">取消设置</span>
</div>
<div style="margin-top: 12px"
v-show="item.conditionType == 0 && item.completed"
class="hover-icon red condition-action">
<span @click="resetCondition(index)">重新设置条件</span>
<span style="margin-left:12px" @click="editNowCondition(index)">编辑</span>
</div>
</div>
<div class="condition-detail">
<div class="condition-detail-list" style="margin-bottom: 12px">
<span>风控等级:</span>
<el-input-number size="mini" :min="1" :max="10" v-model="item.riskLevel"></el-input-number>
<span style="margin-left: 12px">信号强度:</span>
<el-input-number size="mini" :min="1" :max="10" v-model="item.signalLevel"></el-input-number>
</div>
</div>
<span class="el-icon-error close-btn hover-icon"
@click="removeConditionList(index)">
</span>
</div>
</transition-group>
</div>
<span :style="{marginTop: editConditionList.length == 0?'0px':'12px'}" class="el-icon-circle-plus-outline hover-icon red"@click="addConditionList"> 添加条件</span>
</div>
</div>
<div class="form-item">
<div class="title">操作:</div>
<div class="detail">
<el-popconfirm @onConfirm="backToDetail" title="指标正在编辑中,确认取消?">
<el-button slot="reference" size="mini">取消</el-button>
</el-popconfirm>
<el-button size="mini"
style="margin-left: 8px"
@click="addSmartWord"
:loading="addWordLoading"
type="primary">确认
</el-button>
</div>
</div>
</div>
<!-- 智能词文件夹显示 -->
<div class="words-detail-inner" v-show="detailType == 3">
<div class="form-item">
<div class="title">分类名称:</div>
<div class="detail">{{activeIndex.name}}</div>
</div>
<div class="form-item">
<div class="title">分类路径:</div>
<div class="detail">{{formatIndexFrom(activeIndex.from)}}</div>
</div>
<div class="form-item">
<div class="title">操作:</div>
<div class="detail">
<el-button size="mini"
:disabled="activeIndex.Required == 1?true:false"
@click="openChangeCategory()">修改名称</el-button>
<el-button size="mini" @click="openAddCategory()">新增分类</el-button>
<el-button size="mini" @click="openAddNewWord()">新增智能词</el-button>
<el-popconfirm
title="是否确认删除该分类?"
@onConfirm="deleteCategory">
<el-button style="margin-left: 10px" size="mini" slot="reference" :disabled="activeIndex.Required == 1?true:false" type="primary">删除分类</el-button>
</el-popconfirm>
<span style="color: #999; margin-left: 12px" v-show="activeIndex.Required">系统根目录禁止删除和修改</span>
</div>
</div>
</div>
</div>
</div>
<el-dialog :title="testTitle"
:visible.sync="testSingleVisible"
width="1000px">
<div class="run-dialog">
<div class="flex-dialog-left" v-show="testRunType == 'multiple'">
<el-input size="mini"
v-model="testSearchName"
:loading="treeLoading"
style="margin-bottom: 12px"
@keyup.enter.native="searchTestWords"
clearable
placeholder="请输入名称进行搜索">
</el-input>
<el-tree
:data="myTreeData"
show-checkbox
ref="testWordsTree"
:props="defaultProps"
@check-change="handleCheckChange"
:filter-node-method="filterTreeNode">
<span class="custom-tree-node" slot-scope="{ node, data }">
<span class="el-icon-folder" v-show="!data.isIndex"></span>
<span style="font-size: 12px">{{ node.label }}</span>
</span>
</el-tree>
</div>
<div class="flex-dialog-right">
<div class="form-item" v-show="testRunType == 'multiple'">
<div class="title">已选智能词:</div>
<div class="detail">
<span class="selected-words" style="color: #999" v-show="testRunWords.length == 0">未选择智能词</span>
<span class="selected-words" v-for="(item,index) in testRunWords">{{(index == 0?'':'') + item.Name}}</span>
</div>
</div>
<div class="form-item" v-show="testRunType == 'single'">
<div class="title">当前智能词:</div>
<div class="detail">
<span class="selected-words">{{activeIndex.Name}}</span>
</div>
</div>
<indexCondition style="padding: 20px 0" ref="conditionChoose" :params="7" :allParams="[]" />
<div class="form-item">
<div class="title">选择标的:</div>
<div class="detail">
<companySelector ref="companySelector" />
</div>
</div>
<div class="form-item">
<div class="title">运行结果:</div>
<div class="detail">
<div class="detail-condition">
<span class="title">风控方向:</span>
<el-radio-group v-model="testDirection">
<el-radio :label="null">全部</el-radio>
<el-radio :label="-1">负面</el-radio>
<el-radio :label="0">中性</el-radio>
<el-radio :label="1">正面</el-radio>
</el-radio-group>
</div>
<div class="detail-condition">
<span class="title">风控等级:</span>
<el-input size="mini" style="width: 120px" placeholder="最小等级" v-model="testMinRiskLevel"></el-input>
<span> - </span>
<el-input size="mini" style="width: 120px" placeholder="最大等级" v-model="testMaxRiskLevel"></el-input>
</div>
<div class="detail-condition">
<span class="title">风控强度:</span>
<el-input size="mini" style="width: 120px" placeholder="最小等级" v-model="testMinRiskStrong"></el-input>
<span> - </span>
<el-input size="mini" style="width: 120px" placeholder="最大等级" v-model="testMaxRiskStrong"></el-input>
</div>
<el-table
size="mini"
style="width:600px; margin-top: 12px"
max-height="300"
v-loading="runSingleTableLoading"
:data="runSingleTableData"
:header-cell-style="{background:'#f5f7fa',color:'#666'}"
border>
<el-table-column width="50" type="index" label="序号"></el-table-column>
<el-table-column width="100">
<template slot="header" slot-scope="scope">
<span>证券名称</span>
</template>
<template slot-scope="scope">{{scope.row.name}}</template>
</el-table-column>
<el-table-column width="100">
<template slot="header" slot-scope="scope">
<span>证券代码</span>
</template>
<template slot-scope="scope">{{scope.row.code}}</template>
</el-table-column>
<el-table-column>
<template slot="header" slot-scope="scope">
<span>结果</span>
</template>
<template slot-scope="scope">{{getRunningResult(scope.row.value)}}</template>
</el-table-column>
</el-table>
<div style="font-size: 12px; margin-top: 8px; color: #d0021b">
<span
class="el-icon-upload2"
style="cursor: pointer;"
@click="exportExcel"
>导出excel</span>
</div>
</div>
</div>
<div class="form-item">
<div class="title">操作:</div>
<div class="detail">
<el-button size="mini" type="primary" :loading="runLoading" @click="confirmRunWords">点击运行</el-button>
</div>
</div>
</div>
</div>
</el-dialog>
<el-dialog :title="addOrEditCategoryTitle"
:visible.sync="addOrEditCategoryVisible"
width="360px" >
<div>
<el-input placeholder="请输入分类名称" size="small" v-model="inputedCategoryName"></el-input>
</div>
<span slot="footer" class="dialog-footer">
<el-button size="mini" @click="addOrEditCategoryVisible = false">取消</el-button>
<el-button
size="mini"
type="primary"
@click="createOrChangeCategory"
:loading="createOrChangeCategoryLoading"
>确认</el-button>
</span>
</el-dialog>
<el-dialog title="选择指标分类" :visible.sync="submitCategoryVisible" width="500px">
<div class="detail-index">
<!-- <div class="title" style="text-align: left; color: #999; min-width: 80px">相似公共指标:</div>
<div class="detail">
</div>-->
</div>
<div class="detail-index">
<div class="title" style="text-align: left; color: #999; min-width: 80px">建议分类:</div>
<div class="detail">
<el-cascader
:props="publicProps"
v-model="submitCategory"
size="mini"
style="width: 300px"
:options="publicCategoryOptions"
></el-cascader>
</div>
</div>
<span slot="footer" class="dialog-footer">
<el-button size="mini" @click="submitCategoryVisible = false">取消</el-button>
<el-button size="mini" type="primary" @click="confirmSubmit()" :loading="submitLoading">确认</el-button>
</span>
</el-dialog>
</div>
</template>
\ No newline at end of file
#app{
width: 100%;
height: 100%;
display: block;
}
.header-router{
background: #fff;
width: 100%;
box-sizing: border-box;
padding: 16px 20px;
display: flex;
align-items: center;
border-bottom: 1px solid #eaeaea;
}
.parent-name{
font-size: 16px;
font-weight: bold;
margin-right: 32px;
}
.router-list{
flex: auto;
}
.router-list span{
padding: 0 12px;
font-size: 14px;
cursor: pointer;
}
.router-list span:hover{
color: #d0021b;
}
.router-list span+span{
border-left: 1px solid #eaeaea;
}
span.active-link{
color: #d0021b;
}
.header-search{
background: #fff;
padding: 12px 0;
box-sizing: border-box;
padding: 0 20px;
height: 62px;
box-sizing: border-box;
display: flex;
flex-direction: column;
justify-content: center;
align-items: start;
}
.header-search-inner{
display: inline-block;
width: 560px;
}
.container{
height: 100%;
display: flex;
flex-direction: column;
}
.container .header{
min-height: 117px;
background: #fff;
}
.header-container{
height: 117px;
overflow: hidden;
}
.main-body{
height: calc(100% - 139px);
margin-top: 12px;
background: #fff;
padding: 16px;
box-sizing: border-box;
display: flex;
flex: auto;
}
.header-search-box{
width: 50%;
margin: 0 auto;
background: #f1f1f1;
line-height: 36px;
padding: 0 12px;
box-sizing: border-box;
}
.header-search-box .icon{
font-size: 14px;
}
.header-search-box input{
border: 0;
outline: 0;
background: #f1f1f1;
line-height: 36px;
font-size: 14px;
width: calc(100% - 20px);
box-sizing: border-box;
}
.header-search-box input:focus{
outline: 0;
}
.words-list{
min-width: 320px;
border-right: 1px solid #eaeaea;
padding-right: 12px;
box-sizing: border-box;
}
.words-detail{
padding-left: 20px;
flex: auto;
}
.body-title{
font-size: 14px;
font-weight: bold;
min-height: 20px;
padding-bottom: 12px;
position: relative;
}
.words-list, .words-detail{
display: flex;
flex-direction: column;
}
.words-list-inner{
flex: auto;
overflow: scroll;
}
.words-detail-inner{
flex: auto;
overflow: scroll;
/* padding: 12px 0; */
margin-top: 24px;
padding-bottom: 20px;
}
.body-title.border{
border-bottom: 1px solid #eaeaea;
}
.body-title.no-margin{
margin-bottom: 0;
}
.form-item{
display: flex;
}
.form-item.center{
align-items: center;
}
.form-item+.form-item{
margin-top: 20px;
}
.form-item .title{
min-width: 104px;
color: #999;
text-align: left;
margin-right: 12px;
font-size: 13px;
}
.form-item .detail{
flex: auto;
}
.action-list span{
padding: 0 10px;
cursor: pointer;
}
.action-list span:hover{
color: #d0021b;
}
.action-list span+span{
border-left: 1px solid #eaeaea;
}
.condition-list{
border: 1px solid #eaeaea;
border-radius: 4px;
padding: 8px 12px;
width: 636px;
position: relative;
}
.condition-list+.condition-list{
margin-top: 20px;
}
.action-list{
/* border-bottom: 1px solid #eaeaea; */
padding: 12px 0;
background: #f9f9f9;
margin-top: 12px;
border-radius: 4px;
}
.my-slider{
display: inline-block;
flex: auto;
margin-left: 12px;
}
.condition-detail-list{
display: flex;
align-items: center;
}
.my-slider .el-slider__runway{
margin: 12px 0;
}
.my-slider .el-slider__button{
width: 12px;
height: 12px;
}
.condition-detail{
margin-top: 12px;
border-top: 1px solid #eaeaea;
padding-top: 12px;
}
.form-item .detail img{
width: 636px;
height: auto;
border-radius: 4px;
}
.chart-condition{
padding: 8px 0;
}
.words-list-search{
margin-bottom: 12px;
}
.hover-icon{
cursor: pointer;
}
.hover-icon:hover{
color: #d0021b;
}
.hover-icon.red{
color: #d0021b;
}
.slide-fade-enter-active {
transition: all .3s ease;
}
.slide-fade-leave-active {
transition: all .1s cubic-bezier(1.0, 0.5, 0.8, 1.0);
}
.slide-fade-enter, .slide-fade-leave-to
/* .slide-fade-leave-active for below version 2.1.8 */ {
transform: translateX(50px);
opacity: 0;
}
.close-btn{
position: absolute;
background: #fff;
right: -10px;
top: -10px;
font-size: 20px;
}
.complex-condition .cal-index-detail{
min-width: 220px;
max-width: 220px;
height: 442px;
}
.condition-action{
/* background: rgb(245, 247, 250); */
padding: 6px 12px;
border-radius: 4px;
}
.simple-condition-box{
border: 1px solid #eaeaea;
padding: 0 12px;
}
.complex-condition-showDom{
padding: 12px;
border: 1px solid #eaeaea;
box-sizing: border-box;
background: rgb(245, 247, 250);
}
.back-btn{
position: absolute;
top: -6px;
right: 0;
}
.inline-block{
display: inline-block;
}
.condition-detail-list .inline-block+.inline-block{
margin-left: 20px;
}
.gray{
color: #999;
}
.run-dialog .title{
text-align: right;
}
.run-dialog{
display: flex;
}
.flex-dialog-left{
min-width: 200px;
padding-right:12px;
border-right: 1px solid #eaeaea;
overflow: scroll;
}
.flex-dialog-right{
flex: auto;
padding-left:12px;
}
.selected-words{
font-size: 13px;
color: #333;
font-weight: bold;
}
.calculater-keybord{
width: 400px;
}
.empty-status{
min-height: 400px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.empty-status img{
width: 130px;
height: auto;
margin-bottom: 10px;
}
.empty-status .empty-tip{
font-size: 14px;
color: #999;
}
.detail-condition{
font-size: 12px;
}
.detail-condition+.detail-condition{
margin-top: 12px;
}
.detail-condition .title{
color: #999;
}
.side-modal{
position: fixed;
width: 400px;
background: #fff;
height: 100%;
right: 0px;
top: 0;
z-index: 100;
box-shadow: -8px 0 8px rgba(0, 0, 0, 0.1);
padding: 20px 12px;
box-sizing: border-box;
}
.slide-fade-enter-active {
transition: all .3s ease;
}
.slide-fade-leave-active {
transition: all .1s cubic-bezier(1.0, 0.5, 0.8, 1.0);
}
.slide-fade-enter, .slide-fade-leave-to
/* .slide-fade-leave-active for below version 2.1.8 */ {
transform: translateX(50px);
opacity: 0;
}
.side-close{
font-size: 20px;
color: #999;
position: absolute;
right: 10px;
top: 10px;
cursor: pointer;
}
.side-close:hover{
color: #D0021B;
}
.side-modal-column{
display: flex;
align-items: baseline;
}
.side-modal-column .title{
min-width: 80px;
text-align: right;
color: #999;
margin-right: 10px;
}
.side-modal-column .detail{
flex: auto;
}
.side-modal h3{
margin-bottom: 20px;
}
.side-modal-column+.side-modal-column{
margin-top: 20px;
}
.detail-line-list+.detail-line-list{
margin-top: 8px;
}
.side-modal-operation{
position: absolute;
width: 100%;
bottom: 0px;
left: 0;
padding: 8px 12px;
box-sizing: border-box;
border-top: 1px solid #eaeaea;
}
.side-modal-inner{
overflow: scroll;
overflow-x: hidden;
height: calc(100% - 66px);
padding-bottom: 12px;
box-sizing: border-box;
}
.side-tree-box{
border: 1px solid #eaeaea;
padding: 12px;
height: 500px;
max-height: 500px;
overflow: scroll;
overflow-x: hidden;
}
\ No newline at end of file
var init = require('../../lib/init.js')
var value = init(__filename, __dirname)
const condition = require('../../../../components/simpleCondition/index')
const complexCondition = require('../../../../components/complexCondition/index')
const conditionFuns = require('../../../../components/complexCondition/conditionFun')
const companySelector = require('../../../../components/companySelector/index.js')
const indexCondition = require('../../../../components/condition/index.js')
var tools = require('../../lib/tools.js')
var keyBord = require('../../lib/keyBord')
//以上代码引入vue、css等,初始化
const officegen = require('officegen')
const { dialog } = require('electron').remote
const fs = require('fs')
const { ipcRenderer } = require('electron')
module.exports[value.name] = {
data: function () {
return {
searchInput: '',
defaultProps: {
children: 'children',
label: 'name'
},
detailType: 1, //1详情2编辑3文件夹0空
editWordName: '',
choosedPassCategory: [],
publicCategoryOptions: [],
editPosition: 1,
editConditionList: [],
initIndex: 1,
testSingleVisible: false,
runSingleTableLoading: false,
runSingleTableData: [],
testSearchName: '',
copyConditionHtml: null,
addWordLoading: false,
myTreeData: [],
treeData: [],
cascaderOptions: [],
cascaderProps: {
value: 'Id',
label: 'ArchiveName',
checkStrictly: true,
multiple: true
},
detailTitle: '详情',
activeIndex: {},
inputedCategoryName: '',
addOrEditCategoryTitle: '',
addCategoryType: '',
addOrEditCategoryVisible: false,
createOrChangeCategoryLoading: false,
deirectionObj: {
"-1": "负面",
"0": "中性",
"1": "正面",
"2": '不确定',
"3": '未定义'
},
testRunType: 'single',
categoryDic: {},
treeLoading: true,
testTitle: '',
testRunWords: [],
testDirection: null,
testMinRiskLevel: 0,
testMaxRiskLevel: 10,
testMinRiskStrong: 0,
testMaxRiskStrong: 10,
runLoading: false,
initIndexObj: {},
companyNameObj: {},
activeWordConditions: [],
keyboardObj: {},
changePositionVisible: false,
activeIndexStatus: 0,
editTip: '编辑完成后需要提交审核,是否继续编辑?',
editWikiVisible: false,
editWiki: '',
editDialogWiki: '',
changeWikiLoading: false,
editWikiText: '',
hasPermission: false,
isWordsDot: false,
IntervalId: 0
}
},
components: { condition, complexCondition, companySelector, indexCondition},
template: value.template,
mounted() {
var that = this
ipcRenderer.on('copy-multiple-condition-reply', function (event, arg) {
that.copyConditionHtml = arg
})
this.getSortBadge()
this.IntervalId = setInterval(() => {
this.getSortBadge()
}, 30000)
this.getIndexs().then(res => {
this.getWordsList()
this.getPublicCategory()
this.checkPermission(53)
tools.getKeyboardObj(keyBord, this.keyboardObj)
})
},
beforeDestroy(){
clearInterval(this.IntervalId)
},
methods: {
getSortBadge () {
return new Promise((resolve) => {
http.netPost('Data/SmartWord/GetTodoSmartWordCount', {
"AccountId": store.get('accountId')
})
.then((res) => {
if (res.data.Status == 1) {
if(res.data.Data > 0){
this.isWordsDot = true
}else{
this.isWordsDot = false
}
resolve(res)
}
})
})
},
checkPermission (id) {
return new Promise((resolve, reject) => {
http.netPost('Account/Account/CheckPermission', {
"id": id,
"AccountId": store.get('accountId')
})
.then((res) => {
if (res.data.Status == 1) {
if(res.data.Data == 1){
this.hasPermission = true
this.editTip = "编辑完成后需要提交审核,是否继续编辑?"
this.editConfirmText = "提交审核"
this.editWikiText = "确认修改"
}
resolve()
}
})
})
},
copyIndexToCatrgory () {
this.copyIndexVisible = true
},
copyIndex () {
return new Promise((resolve, reject) => {
http.netPost('Data/SmartWord/CopyPublicToMySmartWord', {
"id": this.activeIndex.Id,
"accountId": store.get('accountId')
})
.then((res) => {
if (res.data.Status == 1) {
this.$message({
message: "复制成功,智能词已存入个人指标库根目录",
type: "success"
})
resolve()
}
})
})
},
changePosition () {
this.copyTreeData = JSON.parse(JSON.stringify(this.myTreeData))
this.changePositionVisible = true
},
closeSideModal () {
this.changePositionVisible = false
},
getStatus (obj) {
if(!obj){
return 1
}
var status = 0
obj.WdPublicSmartWordWorkflow.forEach( item => {
if(item.IsCurrent == 1){
status = item.FlowStatus
}
})
return status
},
selectWord(data) {
console.log(data)
this.activeIndex = data
this.activeIndex.from = this.findPathByLeafId(data.myId, this.myTreeData)
if(data.isIndex){
this.activeIndexStatus = this.getStatus(data)
this.detailType = 1
this.detailTitle = '指标详情-' + data.name
this.activeWordConditions = []
data.Conditions.forEach(item => {
this.activeWordConditions.push({
indexParams: {},
dateParams: {},
numParams: {},
symbolParams: {},
functionParams: {},
dom: '',
showDom: ''
})
})
this.getUsedCompany(data.Conditions).then(res => {
this.activeWordConditions.forEach((item,index) => {
this.initIndex++
tools.getSaveCondition(
item,
data.Conditions[index].Condition.Object,
this.initIndex,
this.initIndexObj,
this.companyNameObj,
this.keyboardObj
)
})
this.$nextTick(() => {
this.activeWordConditions.forEach((item, index)=>{
var spans = document.getElementById('conditionBox' + index).getElementsByTagName('span')
var html = ''
Array.from(spans).forEach(span => {
html += span.outerHTML
})
document.getElementById('conditionBox' + index).innerHTML = html
var spans = document.getElementById('conditionBox' + index).getElementsByTagName('span')
tools.formatShowDom(spans)
})
})
})
this.activeIndex.from = this.findPathByLeafId(data.myId, this.myTreeData)
}else{
this.detailType = 3
this.detailTitle = '文件夹操作-' + this.activeIndex.name
if(!data.children || data.children.length == 0){
this.activeIndex.allowedDelete = true
}
}
},
findPathByLeafId(leafId, nodes, path) {
if (path === undefined) {
path = []
}
for (var i = 0; i < nodes.length; i++) {
var tmpPath = path.concat()
tmpPath.push({
myId: nodes[i].myId,
name: nodes[i].name,
id: nodes[i].Id
})
if (leafId == nodes[i].myId) {
return tmpPath;
}
if (nodes[i].children) {
var findResult = this.findPathByLeafId(leafId, nodes[i].children, tmpPath);
if (findResult) {
return findResult
}
}
}
},
formatIndexFrom(arr) {
if(arr){
var newArr = []
arr.forEach(item => {
newArr.push(item.name)
})
return newArr.join(' / ')
}
return ''
},
addConditionList () {
this.initIndex++
var id = new Date().getTime() + this.initIndex
this.editConditionList.push({
id: id,
riskLevel: 0,
signalLevel: 0,
complexCondition: {},
simpleCondition: {
operator: '&&',
content: []
},
conditionType: 0,
completed: false,
selectedType: null
})
},
removeConditionList (index) {
this.editConditionList.splice(index, 1)
},
completeSettedCondition (index) {
var activeObj = this.editConditionList[index]
if(activeObj.conditionType == 1){
this.$set(activeObj, 'complexCondition', this.$refs['complexcondition' + index][0].sendDataToHost(true))
activeObj.selectedType = 1
}else{
this.$refs['simplecondition' + index][0].completedEdit()
activeObj.selectedType = 2
}
activeObj.completed = true
activeObj.conditionType = 0
},
resetCondition (index) {
var id = this.editConditionList[index].id
this.$set(this.editConditionList, index, {
id: id,
riskLevel: 0,
signalLevel: 0,
complexCondition: {},
simpleCondition: {
operator: '&&',
content: []
},
conditionType: 0,
completed: false,
selectedType: null
})
},
setCondition(item, type, index){
if(type == 1){
item.conditionType = 1
}else{
item.conditionType = 2
this.$refs['simplecondition' + index][0].resetEdit()
}
},
editNowCondition (index) {
var activeObj = this.editConditionList[index]
if(activeObj.selectedType == 1){
activeObj.conditionType = 1
}else{
this.$refs['simplecondition' + index][0].resetEdit()
activeObj.conditionType = 2
}
activeObj.completed = false
},
editWord () {
this.detailType = 2
this.detailTitle = "编辑智能词"
this.editWiki = this.activeIndex.Wiki
this.choosedPassCategory = this.getEditIndexCategory()
this.editWordName = this.activeIndex.name
this.editPosition = this.activeIndex.Direction
this.editConditionList = []
this.activeIndex.Conditions.forEach((item,index) => {
this.initIndex++
var id = new Date().getTime() + this.initIndex
if(item.ShowType == 1){
this.editConditionList.push({
id: id,
riskLevel: item.RiskLevel,
signalLevel: item.SignalStrength,
complexCondition: item.ShowType == 1 ? this.activeWordConditions[index] : {},
simpleCondition: {
operator: '&&',
content: []
},
conditionType: 0,
completed: true,
selectedType: item.ShowType
})
}else if(item.ShowType == 2){
this.editConditionList.push({
id: id,
riskLevel: item.RiskLevel,
signalLevel: item.SignalStrength,
complexCondition: {},
simpleCondition: {
operator: '&&',
content: this.setSimpleCondition(item.Condition.Object)
},
conditionType: 0,
completed: true,
selectedType: item.ShowType
})
// this.setSimpleCondition(item.Condition.Object)
}
})
var that = this
this.$nextTick(() => {
this.activeIndex.Conditions.forEach((item,index) => {
if(item.ShowType == 1){
that.$refs['complexcondition'+index][0].indexParams = that.activeWordConditions[index].indexParams
that.$refs['complexcondition'+index][0].numParams = that.activeWordConditions[index].numParams
that.$refs['complexcondition'+index][0].dateParams = that.activeWordConditions[index].dateParams
that.$refs['complexcondition'+index][0].symbolParams = that.activeWordConditions[index].symbolParams
that.$refs['complexcondition'+index][0].functionParams = that.activeWordConditions[index].functionParams
for (var key in that.activeWordConditions[index].functionParams) {
that.activeWordConditions[index].functionParams[key].paramsValue.forEach(item => {
var arr = ['indexParams', 'numParams', 'dateParams', 'symbolParams']
arr.forEach(child => {
for (var key in item[child]) {
that.$refs['complexcondition' + index][0].indexParams[key] = item[child]
}
})
})
}
that.$refs['complexcondition' + index][0].setHtml(that.activeWordConditions[index].dom)
}
})
})
},
setSimpleCondition (arr) {
var content = []
var firsrArr = []
var finalArr = []
//第一步找出最外层
arr.forEach((item,index) => {
if(item.Value && arr[index - 1] && arr[index - 2] && (item.Value == '&&' || item.Value == '||') && arr[index - 1].Value == ')' && arr[index - 2].Value == ')'){
firsrArr.push(index)
}
})
if(firsrArr.length > 0){
var resultArr = []
var spliceArr = JSON.parse(JSON.stringify(firsrArr))
spliceArr.unshift(0)
spliceArr.push(arr.length)
for(var i = 0; i < spliceArr.length - 1; i++){
resultArr.push(arr.slice(i == 0?0:spliceArr[i] + 1, spliceArr[i+1]))
}
var newresult = []
resultArr.forEach((item, index)=>{
var newarr = []
item.forEach(sub => {
if((sub.Value && sub.Value !== '(' && sub.Value !== ')') || !sub.Value){
newarr.push(sub)
}
})
newresult.push(newarr)
})
newresult.forEach(item => {
var newArr = []
var indexArr = [0]
item.forEach((sub,index) => {
if(sub.Value == '&&' || sub.Value == '||'){
indexArr.push(index)
}
})
indexArr.push(item.length)
var smallArr = []
for(var i = 0; i < indexArr.length - 1; i++){
smallArr.push(item.slice(i == 0?0:indexArr[i], indexArr[i+1]))
}
newArr.push(smallArr)
finalArr.push(newArr)
})
}else{
var newarr = []
arr.forEach((sub,index) => {
if((sub.Value && sub.Value !== '(' && sub.Value !== ')') || !sub.Value){
newarr.push(sub)
}
})
var centerArr = []
var indexArr = [0]
newarr.forEach((sub,index) => {
if(sub.Value == '&&' || sub.Value == '||'){
indexArr.push(index)
}
})
indexArr.push(newarr.length)
var smallArr = []
for(var i = 0; i < indexArr.length - 1; i++){
smallArr.push(newarr.slice(i == 0?0:indexArr[i], indexArr[i+1]))
}
centerArr.push(smallArr)
finalArr.push(centerArr)
finalArr.push(smallArr)
}
for(var i = 0; i < firsrArr.length + 1; i++){
content.push({
content: this.getSimpleContent(finalArr[i]),
operator: i == 0?'&&':arr[firsrArr[i - 1]].Value
})
}
return content
},
getItemType (item) {
var type = ''
switch (item.OperandType) {
case 0:
type = 'index'
break;
case 2:
type = 'number'
break;
case 3:
type = 'time'
break;
default:
break;
}
return type
},
setSingleCondition (content, item) {
var evalObj1 = {}, evalObj2 = {}, evalObj3 = {}
var index1 = null, index2 = null, index3 = null
var num = item.length
switch (num) {
case 3:
index1 = 0
index2 = 2
break;
case 4:
index1 = 1
index2 = 3
break;
case 5:
index1 = 0
index2 = 2
index3 = 4
break;
case 6:
index1 = 1
index2 = 3
index3 = 5
break;
default:
break;
}
if(item[index1].OperandType == 0){
evalObj1 = this.getEval(item[index1].Where[0])
}
if(item[index2].OperandType == 0){
evalObj2 = this.getEval(item[index2].Where[0])
}
if(index3 && item[index3].OperandType == 0){
evalObj3 = this.getEval(item[index3].Where[0])
}
content.push({
index1: item[index1].OperandType == 0?{
indexCode: item[index1].List[0],
indexName: this.initIndexObj[item[index1].List[0]].Name,
mark: this.initIndexObj[item[index1].List[0]].Mark,
mergeType: item[index1].Where[1].Value,
typeContent: this.initIndexObj[item[index1].List[0]].TypeContent,
origin: "",
qQuarter: evalObj1.qQuarter,
reportQuarterType: evalObj1.reportQuarterType,
reportYearType: evalObj1.reportYearType,
selectYear: evalObj1.selectYear,
selsetQuarter: evalObj1.selsetQuarter,
tYear: evalObj1.tYear,
}:{},
input1: item[index1].OperandType == 2?item[index1].Value:'',
time1: item[index1].OperandType == 3?item[index1].Value:'',
type1: this.getItemType(item[index1]),
showType1: true,
symbol1: item[index1 + 1].Value,
index2: item[index2].OperandType == 0?{
indexCode: item[index2].List[0],
indexName: this.initIndexObj[item[index2].List[0]].Name,
mark: this.initIndexObj[item[index2].List[0]].Mark,
mergeType: item[index2].Where[1].Value,
typeContent: this.initIndexObj[item[index2].List[0]].TypeContent,
origin: "",
qQuarter: evalObj2.qQuarter,
reportQuarterType: evalObj2.reportQuarterType,
reportYearType: evalObj2.reportYearType,
selectYear: evalObj2.selectYear,
selsetQuarter: evalObj2.selsetQuarter,
tYear: evalObj2.tYear,
}:{},
input2: item[index2].OperandType == 2?item[index2].Value:'',
time2: item[index2].OperandType == 3?item[index2].Value:'',
type2: this.getItemType(item[index2]),
showType2: false,
symbol2: index3?item[index3 - 1].Value:'',
index3: index3?(item[index3].OperandType == 0?{
indexCode: item[index3].List[0],
indexName: this.initIndexObj[item[index3].List[0]].Name,
mark: this.initIndexObj[item[index3].List[0]].Mark,
mergeType: item[index3].Where[1].Value,
typeContent: this.initIndexObj[item[index3].List[0]].TypeContent,
origin: "",
qQuarter: evalObj3.qQuarter,
reportQuarterType: evalObj3.reportQuarterType,
reportYearType: evalObj3.reportYearType,
selectYear: evalObj3.selectYear,
selsetQuarter: evalObj3.selsetQuarter,
tYear: evalObj3.tYear,
}:{}):{},
input3: index3?(item[index3].OperandType == 2?item[index3].Value:''):'',
time3: index3?(tem[index3].OperandType == 3?item[index3].Value:''):'',
type3: index3?(this.getItemType(item[index3])):'',
linkCondition: (item.length == 4 || item.length == 6 )?(item[0].Value == '&&'?'and':'or'):'and',
showHandle: true
})
},
getSimpleContent (arr) {
var content = []
arr.forEach(item => {
item.forEach(sub => {
this.setSingleCondition(content, sub)
})
})
return content
},
getEval (item) {
var newObj = {
reportYearType: 1,
tYear: 0,
selectYear: '',
reportQuarterType: 1,
qQuarter: 0,
selsetQuarter: ''
}
switch (item.Eval.length) {
case 0:
newObj.reportYearType = 2
newObj.selectYear = item.Value.slice(0,4)
newObj.reportQuarterType = 2
newObj.qQuarter = 0
newObj.tYear = 0
newObj.selsetQuarter = item.Value.slice(5,10)
break;
case 1:
if(item.Eval[0].EvalOption == 1) { //年度为t
newObj.reportYearType = 1
newObj.tYear = item.Eval[0].Value
newObj.selectYear = item.Value.slice(0,4)
newObj.reportQuarterType = 2
newObj.qQuarter = 0
newObj.selsetQuarter = item.Value.slice(5,10)
}else if(item.Eval[0].EvalOption == 2){
newObj.reportYearType = 2
newObj.tYear = 0
newObj.selectYear = item.Value.slice(0,4)
newObj.reportQuarterType = 1
newObj.qQuarter = item.Eval[0].Value
newObj.selsetQuarter = item.Value.slice(5,10)
}
break;
case 2:
newObj.reportYearType = 1
newObj.selectYear = ''
newObj.reportQuarterType = 1
newObj.selsetQuarter = ''
newObj.qQuarter = item.Eval[1].Value
newObj.tYear = item.Eval[0].Value
break;
default:
break;
}
return newObj
},
getPublicCategory () {
return new Promise((resolve, reject) => {
http.netPost('Data/SmartWord/GetPublicSmartWordArchive', {})
.then((res) => {
if (res.data.Status == 1) {
this.publicCategoryOptions = res.data.Data
resolve()
}
})
})
},
getEditIndexCategory() {
var result = []
this.activeIndex.PendingData.ArchiveIds.forEach(item => {
var categoryArr = []
var arr = this.findAllPathByLeafId(item, this.publicCategoryOptions)
if(!arr){
return []
}
arr.forEach((item, index) => {
categoryArr.push(item.code)
})
result.push(categoryArr)
})
return result
},
findAllPathByLeafId(leafId, nodes, path) {
if (path === undefined) {
path = []
}
for (var i = 0; i < nodes.length; i++) {
var tmpPath = path.concat()
tmpPath.push({
code: nodes[i].Id,
name: nodes[i].ArchiveName
})
if (leafId == nodes[i].Id) {
return tmpPath;
}
if (nodes[i].Children) {
var findResult = this.findAllPathByLeafId(leafId, nodes[i].Children, tmpPath);
if (findResult) {
return findResult
}
}
}
},
backToDetail () {
this.detailType = 1
},
testRunSingle () {
this.testSingleVisible = true
this.testRunType = 'single'
this.testTitle = '单智能词测试'
this.testRunWords = [this.activeIndex]
},
testRunMultiple () {
this.testSingleVisible = true
this.testRunType = 'multiple'
this.testTitle = '批量智能词测试'
this.testRunWords = []
},
getIndexs() {
return new Promise((resolve, reject) => {
http.netPost('Data/Encode/GetEncodeList', {
"Current": 0,
"Psize": 100,
"Code": "B",
'Name': '',
"AccountId": store.get('accountId')
})
.then((res) => {
if (res.data.Status == 1) {
this.treeData = res.data.Data.Records
this.creatIndexObj(res.data.Data.Records)
resolve()
}
})
})
},
returnSimpleCondition (sub, num) {
var obj = {}
switch (sub['type' + num]) {
case 'index':
var param = sub["index" + num]
var dateYear = '1900'
var dateQuater = '06-30'
var evalArray = []
if (param.reportYearType == 1) {
evalArray.push({
"EvalOption": 1,
"Value": param.tYear
})
} else if (param.reportYearType == 2) {
dateYear = param.selectYear
}
if (param.reportQuarterType == 1) {
evalArray.push({
"EvalOption": 2,
"Value": param.qQuarter
})
} else if (param.reportQuarterType == 2) {
dateQuater = param.selsetQuarter
}
var where = [
{
"State": 1,
"Encode": "F91996D",
"Value": dateYear + '-' + dateQuater,
"Eval": evalArray
},
{
"State": 1,
"Value": param.mergeType,
"Encode": "F91997V",
"Eval": []
}
]
obj = {
"List": [param.indexCode],
"Where": where,
"OperandType": 0
}
break;
case 'number':
obj = {
"Value": parseFloat(sub["input" + num]),
"OperandType": 2
}
break;
case 'time':
obj = {
"Value": sub["time" + num],
"OperandType": 3
}
break;
default:
break;
}
return obj
},
getSingleCondition (condition) {
var content = []
condition.content.forEach((item, index) => {
if(index){
content.push({
"Value": item.operator,
"OperandType": 1
})
}
content.push({
"Value": '(',
"OperandType": 1
})
item.content.forEach((sub, index) => {
if(index){
content.push({
"Value": sub.linkCondition == 'and'?'&&':'||',
"OperandType": 1
})
}
content.push({
"Value": '(',
"OperandType": 1
})
content.push(this.returnSimpleCondition(sub, 1))
content.push({
"Value": sub.symbol1,
"OperandType": 1
})
content.push(this.returnSimpleCondition(sub, 2))
if(sub.type3){
content.push({
"Value": sub.symbol2,
"OperandType": 1
})
content.push(this.returnSimpleCondition(sub, 3))
}
content.push({
"Value": ')',
"OperandType": 1
})
})
content.push({
"Value": ')',
"OperandType": 1
})
})
return content
},
//新增关键词
addSmartWord () {
this.addWordLoading = true
var conditions = []
this.editConditionList.forEach(item => {
var obj = {
"content": item.selectedType == 1?conditionFuns.setSaveCondition({params: item.complexCondition}):this.getSingleCondition(item.simpleCondition),
"riskLevel": item.riskLevel,
"signalStrength": item.signalLevel,
"showType": item.selectedType
}
conditions.push(obj)
})
var arr = []
this.choosedPassCategory.forEach(item => {
arr.push(item[item.length - 1])
})
return new Promise((resolve, reject) => {
http.netPost('Data/SmartWord/EditPublicSmartWord', {
"id": this.activeIndex.isIndex?this.activeIndex.Id:0,
"name": this.editWordName,
"archiveIds": arr,
"direction": this.editPosition, //-1 负 0 中性 1正面
"conditions": conditions,
"Wiki": this.editWiki,
"AccountId": store.get('accountId')
})
.then((res) => {
if(res.data.Status == 1){
this.detailType = 1
this.detailTitle = "详情"
this.$message({
message: '提交审核成功',
type: "success"
})
this.getWordsList()
}
this.addWordLoading = false
})
})
},
//获取关键词
getWordsList () {
this.treeLoading = true
return new Promise((resolve, reject) => {
http.netPost('Data/SmartWord/GetPublicSmartWord', {
"AccountId": store.get('accountId')
})
.then((res) => {
res.data.Data.forEach(item => {
this.initIndex++
item.myId = new Date().getTime() + this.initIndex
item.name = item.ArchiveName
this.categoryDic[item.Id] = item.myId
if (item.Required) {
this.defaultCategoryId = item.Id
}
})
res.data.Data.forEach(item => {
item.parentId = this.categoryDic[item.ParentId]
})
var categroyData = JSON.parse(JSON.stringify(res.data.Data))
var cascaderData = JSON.parse(JSON.stringify(res.data.Data))
this.myTreeData = this.setTreeData(this.indexIntoCategroy(categroyData), 'myId', 'parentId')
this.cascaderOptions = this.setTreeData(cascaderData, 'Id', 'ParentId')
this.activeIndex = {}
this.detailType = 1
this.treeLoading = false
})
})
},
setTreeData(jsonData, id, pid) {
let result = [],
temp = {}
for (let i = 0; i < jsonData.length; i++) {
temp[jsonData[i][id]] = jsonData[i]
}
for (let j = 0; j < jsonData.length; j++) {
let currentElement = jsonData[j]
let tempCurrentElementParent = temp[currentElement[pid]]
if (tempCurrentElementParent) {
if (!tempCurrentElementParent["children"]) {
tempCurrentElementParent["children"] = []
}
tempCurrentElementParent["children"].push(currentElement)
} else {
result.push(currentElement)
}
}
return result
},
indexIntoCategroy(data) {
var newData = JSON.parse(JSON.stringify(data))
newData.forEach(item => {
item.name = item.ArchiveName
})
data.forEach(item => {
item.WdPublicSmartWord.forEach(sub => {
var newSub = JSON.parse(JSON.stringify(sub))
this.initIndex++
newSub.myId = new Date().getTime() + this.initIndex
newSub.parentId = item.myId
newSub.isIndex = true
newSub.name = newSub.Name
newData.push(newSub)
})
})
return newData
},
openAddCategory() {
this.inputedCategoryName = ''
this.addOrEditCategoryTitle = '新增分类'
this.addCategoryType = 'add'
this.addOrEditCategoryVisible = true
},
openChangeCategory() {
this.inputedCategoryName = this.activeIndex.ArchiveName
this.addOrEditCategoryTitle = '修改分类'
this.addCategoryType = 'edit'
this.addOrEditCategoryVisible = true
},
createOrChangeCategory () {
this.createOrChangeCategoryLoading = true
return new Promise((resolve, reject) => {
http.netPost('Data/SmartWord/AddPublicSmartWordArchive', {
"id": this.addCategoryType == 'add' ? 0 : this.activeIndex.Id,
"name": this.inputedCategoryName,
"parentId": this.addCategoryType == 'add' ? this.activeIndex.Id : this.activeIndex.ParentId,
"accountId":store.get('accountId')
})
.then((res) => {
this.createOrChangeCategoryLoading = false
if (res.data.Status == 1) {
this.addOrEditCategoryVisible = false
this.$message({
message: '操作成功',
type: 'success'
})
this.getWordsList()
resolve()
}
})
})
},
filterTreeNode (value, data) {
if (!value) return true;
return data.name.indexOf(value) !== -1;
},
searchIndex() {
this.$refs.wordsTree.filter(this.searchInput)
},
removeIndex () {
return new Promise((resolve, reject) => {
http.netPost('Data/SmartWord/RmoveMySmartWord', {
"id": this.activeIndex.Id,
"AccountId": store.get('accountId')
})
.then((res) => {
if (res.data.Status == 1) {
this.$message({
message: "智能词删除成功!",
type: "success"
})
this.getWordsList()
resolve()
}
})
})
},
openAddNewWord () {
this.detailType = 2
this.detailTitle = "新增智能词"
this.editWordName = ''
this.editWiki = ''
var arr = []
this.activeIndex.from.forEach(item => {
arr.push(item.id)
})
this.choosedPassCategory = arr
this.editPosition = 0
},
handleCheckChange () {
this.testRunWords = []
var choosed = this.$refs.testWordsTree.getCheckedNodes(true, false)
this.testRunWords = choosed.filter(item => item.isIndex)
},
deleteCategory () {
return new Promise((resolve, reject) => {
http.netPost('Data/SmartWord/RemoveEmptyPublicSmartWordArchive', {
"id": this.activeIndex.Id,
"AccountId": store.get('accountId')
})
.then((res) => {
if (res.data.Status == 1) {
this.$message({
message: "文件夹删除成功!",
type: "success"
})
this.getWordsList()
resolve()
}
})
})
},
searchTestWords () {
this.$refs.testWordsTree.filter(this.testSearchName)
},
confirmRunWords () {
var arr = []
this.testRunWords.forEach(item => {
if(item.Id){
arr.push(item.Id)
}
})
var args = []
var ref = this.$refs.conditionChoose
var selectedRangeCompany = this.$refs.companySelector.selectedRangeCompany
if(!ref.testMergeType || !ref.testYear || !ref.testQuarter || selectedRangeCompany.length == 0){
this.$message({
message: '参数不完整或标的为空',
type: 'error'
})
return false
}
selectedRangeCompany.forEach(item => {
args.push({
stockCode: item.code,
argType: 1
})
})
args.push({
mergeType: ref.testMergeType,
argType: 2
},{
reportingPeriod: ref.testYear + '-' +ref.testQuarter,
argType: 4
})
this.runLoading = true
this.runSingleTableLoading = true
return new Promise((resolve, reject) => {
http.netPost('Data/SmartWord/TestRunPublicSmartWord', {
"id": arr,
"args": args,
"direction": this.testDirection,
"riskLevel": [this.testMinRiskLevel, this.testMaxRiskLevel],
"signalStrength": [this.testMinRiskStrong, this.testMaxRiskStrong],
"AccountId": store.get('accountId')
})
.then((res) => {
if (res.data.Status == 1) {
var arr = JSON.parse(JSON.stringify(this.$refs.companySelector.selectedRangeCompany))
arr.forEach(item => {
item.value = res.data.Data[item.code]
})
this.runSingleTableData = arr
resolve()
}else{
this.runSingleTableData = JSON.parse(JSON.stringify(this.$refs.companySelector.selectedRangeCompany))
}
this.runLoading = false
this.runSingleTableLoading = false
})
})
},
getRunningResult (arr) {
if(arr){
var newArr = []
arr.forEach(item => {
newArr.push(item.SmartWord.Name)
})
return newArr.join('')
}else{
return '-'
}
},
creatIndexObj(initData) {
initData.forEach(element => {
if (element.Sub.length > 0) {
this.creatIndexObj(element.Sub)
} else {
this.initIndexObj[element.Code] = element
}
})
},
getUsedCompany(arr){
var codes = []
arr.forEach(item => {
var params = item.Condition.Object
params.forEach(item => {
if (item.OperandType == 0 && item.Where[2]) {
codes.push(item.Where[2].Value)
} else if (item.OperandType == 4) {
item.Args.forEach(sub => {
sub.forEach(child => {
if (child.OperandType == 0 && child.Where[2]) {
codes.push(child.Where[2].Value)
}
})
})
}
})
})
var where = [{
"Encode": "F90001V",
"State": 7,
"Value": codes.join(','),
}]
return new Promise((resolve, reject) => {
http.netPost('Data/Query/Query', {
"List": ['F90001V', 'F90002V'],
"Where": where,
"Current": 0,
"Psize": 100
})
.then((res) => {
if (res.data.Status == 1) {
res.data.Data.Records.forEach(item => {
this.companyNameObj[item.F90001V] = item.F90002V
})
resolve()
} else if (res.data.Status == 0) {
resolve()
} else {
reject()
}
})
})
},
exportExcel () {
var that = this
var excelName = new Date().getTime()
var xlsx = officegen('xlsx')
var filePath = dialog.showSaveDialog({
defaultPath: excelName + '.xlsx',
title: '保存',
buttonLabel: '保存'
})
xlsx.on('finalize', function(written) {
that.$message({
message: '表格导出成功!',
type: 'success'
})
})
xlsx.on('error', function(err) {
console.log(err)
})
var sheet = xlsx.makeNewSheet()
sheet.name = 'sheet'
sheet.orientation = 'landscape'
sheet.data[0] = []
sheet.data[0][0] = '序号'
sheet.data[0][1] = '证券简称'
sheet.data[0][2] = '证券代码'
sheet.data[0][3] = '运行结果'
var newArr = JSON.parse(JSON.stringify(this.runSingleTableData))
newArr.forEach((item, index)=>{
sheet.data[index + 1] = []
sheet.data[index + 1][0] = index+1
sheet.data[index + 1][1] = item['name']
sheet.data[index + 1][2] = item['code']
sheet.data[index + 1][3] = this.getRunningResult(item['value'])
})
var out = fs.createWriteStream(filePath)
out.on('error', function(err) {
console.log(err)
})
xlsx.generate(out)
},
getIndexArgsIds(args) {
var arr = []
this.defaultTypeList.forEach(item => {
if (args & item.Id) {
arr.push(item.Id)
}
})
return arr
},
openWikiDialog ( ) {
this.editDialogWiki = this.activeIndex.Wiki
this.editWikiVisible = true
},
confirmChangeWiki () {
this.changeWikiLoading = true
return new Promise((resolve, reject) => {
http.netPost('Data/SmartWord/EditPublicSmartWordWiki', {
"id": this.activeIndex.Id,
"wiki": this.editDialogWiki,
"AccountId": store.get('accountId')
})
.then((res) => {
if (res.data.Status == 1) {
this.$message({
message: "操作成功",
type: "success"
})
this.activeIndex = {}
this.getWordsList()
this.editWikiVisible = false
resolve()
}
this.changeWikiLoading = false
})
})
},
}
}
\ No newline at end of file
<template>
<div class="container">
<div class="header shadow">
<div class="header-router">
<div class="parent-name">智能词管理</div>
<div class="router-list" style="display: flex">
<router-link tag="span" active-class="active-link" exact to="/">我的智能词</router-link>
<router-link tag="span" active-class="active-link" exact to="/publicWords">公共智能词</router-link>
<el-badge :is-dot="isWordsDot && hasPermission" class="item">
<router-link tag="span" active-class="active-link" exact to="/wordsAudit">智能词审核</router-link>
</el-badge >
<!-- <router-link tag="span" active-class="active-link" exact to="/wordsAudit">公共分类修改审核</router-link> -->
<router-link tag="span" style="flex: auto; text-align: right;border-left: 0" active-class="active-link" exact to="/wordsRecord">
<span class="el-icon-date"> 指标修改日志</span>
</router-link>
</div>
</div>
<div class="header-search">
<div>
<el-button type="primary" icon="el-icon-odometer" size="mini" @click="testRunMultiple">批量测试</el-button>
</div>
</div>
</div>
<div class="main-body">
<div class="words-list">
<div class="body-title no-margin" style="display: flex; align-items: center">
<span style="flex: auto">公共智能词</span>
<!-- <span class="el-icon-edit hover-icon" style="font-size: 13px" @click="changePosition()"> 位置调整</span> -->
</div>
<div class="words-list-search">
<el-input
v-model="searchInput"
size="mini"
suffix-icon="el-icon-edit"
clearable
@keyup.enter.native="searchIndex"
placeholder="输入智能词进行搜索"
></el-input>
</div>
<div class="words-list-inner">
<el-tree
:data="myTreeData"
v-loading="treeLoading"
ref="wordsTree"
:props="defaultProps"
:filter-node-method="filterTreeNode"
@node-click="selectWord">
<span class="custom-tree-node" slot-scope="{ node, data }">
<span class="el-icon-folder" v-show="!data.isIndex"></span>
<span style="font-size: 12px">{{ node.label }}</span>
</span>
</el-tree>
</div>
</div>
<div class="words-detail">
<div class="body-title border">
<span>{{detailTitle}}</span>
<el-popconfirm @onConfirm="backToDetail" title="指标正在编辑中,确认返回?">
<el-button v-show="detailType == 2" slot="reference" class="back-btn" size="mini" icon="el-icon-back">返回</el-button>
</el-popconfirm>
</div>
<!-- 智能词详情显示 -->
<div class="action-list" v-show="detailType == 1 && activeIndex.isIndex">
<span class="el-icon-odometer" @click="testRunSingle">测试</span>
<el-popconfirm
:title="editTip"
v-show="activeIndexStatus == 16 || activeIndexStatus == 32"
@onConfirm="editWord">
<span class="el-icon-edit" slot="reference" v-show="activeIndexStatus !== 2">编辑</span>
</el-popconfirm>
<span v-show="activeIndexStatus == 16 || activeIndexStatus == 32" class="el-icon-edit icon" @click="openWikiDialog"> 编辑百科</span>
<span v-show="activeIndexStatus == 16 || activeIndexStatus == 32" class="el-icon-document-copy icon" @click="copyIndex"> 复制到我的智能词</span>
<!-- <span v-show="activeIndexStatus == 16 || activeIndexStatus == 32" class="el-icon-document-copy icon" @click="copyIndexToCatrgory"> 复制至其它文件夹</span> -->
<span v-show="activeIndexStatus !== 16 && activeIndexStatus !== 32" style="padding-left: 12px; color: #999; border-left:0">当前指标编辑中,暂时无法编辑和修改百科以及复制</span>
</div>
<div class="words-detail-inner" v-show="detailType == 1 && activeIndex.isIndex">
<div class="form-item">
<div class="title">智能词名称:</div>
<div class="detail">{{activeIndex.name}}</div>
</div>
<div class="form-item">
<div class="title">分类:</div>
<div class="detail">{{formatIndexFrom(activeIndex.from)}}</div>
</div>
<div class="form-item">
<div class="title">智能词风控方向:</div>
<div class="detail" v-if="activeIndex.Direction">{{deirectionObj[activeIndex.Direction.toString()]}}</div>
</div>
<div class="form-item">
<div class="title">智能词百科:</div>
<div class="detail" v-if="activeIndex.Wiki">{{activeIndex.Wiki}}</div>
</div>
<div class="form-item">
<div class="title">条件:</div>
<div class="detail" v-if="activeIndex.Conditions">
<div class="condition-list" v-for="(item,index) in activeIndex.Conditions">
<div class="condition-box" :id="'conditionBox' + index" v-html="activeWordConditions[index].showDom"></div>
<div class="condition-detail">
<div class="condition-detail-list">
<div class="inline-block">
<span class="gray">风控等级:</span>
<span>{{item.RiskLevel}}</span>
</div>
<div class="inline-block">
<span class="gray">信号强度:</span>
<span>{{item.SignalStrength}}</span>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="words-detail-inner" v-show="detailType == 1 && !activeIndex.isIndex">
<div class="empty-status">
<img src="../../static/image/empty.png" />
<div class="empty-tip">请从左侧点击指标或者分类</div>
</div>
</div>
<!-- 智能词编辑显示 -->
<div class="words-detail-inner" v-show="detailType == 2">
<div class="form-item center">
<div class="title">智能词名称:</div>
<div class="detail">
<el-input size="mini" style="width: 300px" v-model="editWordName" placeholder="请输入智能词名称"></el-input>
</div>
</div>
<div class="form-item">
<div class="title">分类:</div>
<div class="detail">
<el-cascader
size="mini"
style="width: 300px"
:props="cascaderProps"
placeholder="请选择所属分类"
v-model="choosedPassCategory"
:options="cascaderOptions">
</el-cascader>
</div>
</div>
<div class="form-item">
<div class="title">智能词风控方向:</div>
<div class="detail">
<el-radio-group class="small-radio" v-model="editPosition">
<el-radio :label="1">正面</el-radio>
<el-radio :label="0">中性</el-radio>
<el-radio :label="-1">负面</el-radio>
<el-radio :label="2">不确定</el-radio>
<el-radio :label="3">未定义</el-radio>
</el-radio-group>
</div>
</div>
<div class="form-item">
<div class="title">智能词百科:</div>
<div class="detail">
<el-input
type="textarea"
:rows="10"
size="mini"
style="width: 600px"
placeholder="请输入智能词百科"
v-model="editWiki">
</el-input>
</div>
</div>
<div class="form-item">
<div class="title">条件:</div>
<div class="detail">
<div class="condition-list-box">
<transition-group name="slide-fade">
<div class="condition-list" :key="item.id" v-for="(item, index) in editConditionList">
<div class="condition-box">
<div v-show="item.conditionType == 0 && !item.selectedType">
<span class="hover-icon red" @click="setCondition(item, 1, index)">设置复杂条件</span>
<span class="hover-icon red" @click="setCondition(item, 2, index)" style="margin-left: 12px">设置简易条件</span>
</div>
<div>
<div class="complex-condition-showDom"
v-show="item.selectedType == 1 && item.completed">
<div v-html="item.complexCondition.showDom"></div>
</div>
<complexCondition
:ref="'complexcondition' + index"
v-show="item.conditionType == 1 && !item.completed"
class="complex-condition"
:treeData="treeData"
:type="'condition'" />
<div class="simple-condition-box"
v-show="(item.conditionType == 2 && !item.completed) || (item.conditionType == 0 && item.selectedType == 2 && item.completed)">
<condition
:treeData="treeData"
:indexNameList="[]"
:type="1"
:ref="'simplecondition' + index"
:selectedCondition="item.simpleCondition" />
</div>
</div>
<div style="margin-top: 12px"
v-show="item.conditionType !== 0 && !item.completed"
class="hover-icon red condition-action">
<span @click="completeSettedCondition(index)">完成条件设置</span>
<span style="margin-left:12px" @click="resetCondition(index)">取消设置</span>
</div>
<div style="margin-top: 12px"
v-show="item.conditionType == 0 && item.completed"
class="hover-icon red condition-action">
<span @click="resetCondition(index)">重新设置条件</span>
<span style="margin-left:12px" @click="editNowCondition(index)">编辑</span>
</div>
</div>
<div class="condition-detail">
<div class="condition-detail-list" style="margin-bottom: 12px">
<span>风控等级:</span>
<el-input-number size="mini" :min="1" :max="10" v-model="item.riskLevel"></el-input-number>
<span style="margin-left: 12px">信号强度:</span>
<el-input-number size="mini" :min="1" :max="10" v-model="item.signalLevel"></el-input-number>
</div>
</div>
<span class="el-icon-error close-btn hover-icon"
@click="removeConditionList(index)">
</span>
</div>
</transition-group>
</div>
<span :style="{marginTop: editConditionList.length == 0?'0px':'12px'}" class="el-icon-circle-plus-outline hover-icon red"@click="addConditionList"> 添加条件</span>
</div>
</div>
<div class="form-item">
<div class="title">操作:</div>
<div class="detail">
<el-popconfirm @onConfirm="backToDetail" title="指标正在编辑中,确认取消?">
<el-button slot="reference" size="mini">取消</el-button>
</el-popconfirm>
<el-button size="mini"
style="margin-left: 8px"
@click="addSmartWord"
:loading="addWordLoading"
type="primary">确认
</el-button>
</div>
</div>
</div>
<!-- 智能词文件夹显示 -->
<div class="words-detail-inner" v-show="detailType == 3">
<div class="form-item">
<div class="title">分类名称:</div>
<div class="detail">{{activeIndex.name}}</div>
</div>
<div class="form-item">
<div class="title">分类路径:</div>
<div class="detail">{{formatIndexFrom(activeIndex.from)}}</div>
</div>
<div class="form-item">
<div class="title">操作:</div>
<div class="detail">
<el-button size="mini"
:disabled="activeIndex.Required == 1?true:false"
@click="openChangeCategory()">修改名称</el-button>
<el-button size="mini" :disabled="!hasPermission" @click="openAddCategory()">新增分类</el-button>
<el-popconfirm
title="是否确认删除该分类?"
@onConfirm="deleteCategory">
<el-button style="margin-left: 10px" size="mini" slot="reference" :disabled="!(activeIndex.allowedDelete && activeIndex.Required !== 1 && hasPermission)" type="primary">删除分类</el-button>
</el-popconfirm>
<span style="color: #999; margin-left: 12px" v-show="activeIndex.Required">系统根目录禁止删除和修改</span>
</div>
</div>
</div>
</div>
</div>
<el-dialog :title="testTitle"
:visible.sync="testSingleVisible"
width="1000px">
<div class="run-dialog">
<div class="flex-dialog-left" v-show="testRunType == 'multiple'">
<el-input size="mini"
v-model="testSearchName"
:loading="treeLoading"
style="margin-bottom: 12px"
@keyup.enter.native="searchTestWords"
clearable
placeholder="请输入名称进行搜索">
</el-input>
<el-tree
:data="myTreeData"
show-checkbox
ref="testWordsTree"
:props="defaultProps"
@check-change="handleCheckChange"
:filter-node-method="filterTreeNode">
<span class="custom-tree-node" slot-scope="{ node, data }">
<span class="el-icon-folder" v-show="!data.isIndex"></span>
<span style="font-size: 12px">{{ node.label }}</span>
</span>
</el-tree>
</div>
<div class="flex-dialog-right">
<div class="form-item" v-show="testRunType == 'multiple'">
<div class="title">已选智能词:</div>
<div class="detail">
<span class="selected-words" style="color: #999" v-show="testRunWords.length == 0">未选择智能词</span>
<span class="selected-words" v-for="(item,index) in testRunWords">{{(index == 0?'':'') + item.Name}}</span>
</div>
</div>
<div class="form-item" v-show="testRunType == 'single'">
<div class="title">当前智能词:</div>
<div class="detail">
<span class="selected-words">{{activeIndex.Name}}</span>
</div>
</div>
<indexCondition style="padding: 20px 0" ref="conditionChoose" :params="7" :allParams="[]" />
<div class="form-item">
<div class="title">选择标的:</div>
<div class="detail">
<companySelector ref="companySelector" />
</div>
</div>
<div class="form-item">
<div class="title">运行结果:</div>
<div class="detail">
<div class="detail-condition">
<span class="title">风控方向:</span>
<el-radio-group v-model="testDirection">
<el-radio :label="null">全部</el-radio>
<el-radio :label="-1">负面</el-radio>
<el-radio :label="0">中性</el-radio>
<el-radio :label="1">正面</el-radio>
</el-radio-group>
</div>
<div class="detail-condition">
<span class="title">风控等级:</span>
<el-input size="mini" style="width: 120px" placeholder="最小等级" v-model="testMinRiskLevel"></el-input>
<span> - </span>
<el-input size="mini" style="width: 120px" placeholder="最大等级" v-model="testMaxRiskLevel"></el-input>
</div>
<div class="detail-condition">
<span class="title">风控强度:</span>
<el-input size="mini" style="width: 120px" placeholder="最小等级" v-model="testMinRiskStrong"></el-input>
<span> - </span>
<el-input size="mini" style="width: 120px" placeholder="最大等级" v-model="testMaxRiskStrong"></el-input>
</div>
<el-table
size="mini"
style="width:600px; margin-top: 12px"
max-height="300"
v-loading="runSingleTableLoading"
:data="runSingleTableData"
:header-cell-style="{background:'#f5f7fa',color:'#666'}"
border>
<el-table-column width="50" type="index" label="序号"></el-table-column>
<el-table-column width="100">
<template slot="header" slot-scope="scope">
<span>证券名称</span>
</template>
<template slot-scope="scope">{{scope.row.name}}</template>
</el-table-column>
<el-table-column width="100">
<template slot="header" slot-scope="scope">
<span>证券代码</span>
</template>
<template slot-scope="scope">{{scope.row.code}}</template>
</el-table-column>
<el-table-column>
<template slot="header" slot-scope="scope">
<span>结果</span>
</template>
<template slot-scope="scope">{{getRunningResult(scope.row.value)}}</template>
</el-table-column>
</el-table>
<div style="font-size: 12px; margin-top: 8px; color: #d0021b">
<span
class="el-icon-upload2"
style="cursor: pointer;"
@click="exportExcel"
>导出excel</span>
</div>
</div>
</div>
<div class="form-item">
<div class="title">操作:</div>
<div class="detail">
<el-button size="mini" type="primary" :loading="runLoading" @click="confirmRunWords">点击运行</el-button>
</div>
</div>
</div>
</div>
</el-dialog>
<el-dialog :title="addOrEditCategoryTitle"
:visible.sync="addOrEditCategoryVisible"
width="360px" >
<div>
<el-input placeholder="请输入分类名称" size="small" v-model="inputedCategoryName"></el-input>
</div>
<span slot="footer" class="dialog-footer">
<el-button size="mini" @click="addOrEditCategoryVisible = false">取消</el-button>
<el-button
size="mini"
type="primary"
@click="createOrChangeCategory"
:loading="createOrChangeCategoryLoading"
>确认</el-button>
</span>
</el-dialog>
<el-dialog title="编辑百科"
:visible.sync="editWikiVisible"
width="800px">
<div class="detail-index" style="align-items: flex-start">
<div class="title" style="text-align: left; color: #999; min-width: 80px">编辑百科:</div>
<div class="detail">
<el-input
type="textarea"
style="width: 660px"
:rows="8"
placeholder="请输入内容"
v-model="editDialogWiki">
</el-input>
</div>
</div>
<span slot="footer" class="dialog-footer">
<el-button size="mini" @click="editWikiVisible = false">取消</el-button>
<el-button
size="mini"
type="primary"
@click="confirmChangeWiki()"
:loading="changeWikiLoading"
>{{editWikiText}}</el-button>
</span>
</el-dialog>
<!-- <transition name="slide-fade">
<div class="side-modal" v-show="changePositionVisible">
<span class="el-icon-error side-close" @click="closeSideModal"></span>
<h3>修改指标分类</h3>
<div class="side-modal-inner">
<div class="side-tree-box">
<el-tree
draggable
:default-expanded-keys="defaultExpandedKeys"
ref="publicIndexTree"
node-key="myId"
class="small-tree"
highlight-current
:expand-on-click-node="false"
:data="copyTreeData"
:allow-drop="allowDrop"
:props="treeProps">
<span class="custom-tree-node" slot-scope="{ node, data }">
<span class="el-icon-folder" v-show="!data.isIndex"></span>
<span style="font-size: 12px">{{ node.label }}</span>
</span>
</el-tree>
</div>
<div style="margin-top:20px">
<el-input
type="textarea"
:rows="8"
placeholder="请输入修改备注,对操作作具体说明"
v-model="changePositionMemo">
</el-input>
</div>
</div>
<div class="side-modal-operation">
<el-button size="mini" @click="closeSideModal">取消编辑</el-button>
<el-button size="mini" :loading="sortLoading" type="primary" @click="submitSortChange">提交审核</el-button>
</div>
</div>
</transition> -->
</div>
</template>
\ No newline at end of file
#app{
width: 100%;
height: 100%;
display: block;
}
.header-router{
background: #fff;
width: 100%;
box-sizing: border-box;
padding: 16px 20px;
display: flex;
align-items: center;
border-bottom: 1px solid #eaeaea;
}
.parent-name{
font-size: 16px;
font-weight: bold;
margin-right: 32px;
}
.router-list{
flex: auto;
}
.router-list span{
padding: 0 12px;
font-size: 14px;
cursor: pointer;
}
.router-list span:hover{
color: #d0021b;
}
.router-list span+span{
border-left: 1px solid #eaeaea;
}
span.active-link{
color: #d0021b;
}
.header-search{
background: #fff;
padding: 12px 0;
box-sizing: border-box;
padding: 0 20px;
height: 62px;
box-sizing: border-box;
display: flex;
flex-direction: column;
justify-content: center;
align-items: start;
}
.header-search-inner{
display: inline-block;
width: 560px;
}
.container{
height: 100%;
display: flex;
flex-direction: column;
}
.container .header{
min-height: 117px;
background: #fff;
}
.header-container{
height: 117px;
overflow: hidden;
}
.main-body{
height: calc(100% - 139px);
margin-top: 12px;
background: #fff;
padding: 16px;
box-sizing: border-box;
display: flex;
flex: auto;
}
.header-search-box{
width: 50%;
margin: 0 auto;
background: #f1f1f1;
line-height: 36px;
padding: 0 12px;
box-sizing: border-box;
}
.header-search-box .icon{
font-size: 14px;
}
.header-search-box input{
border: 0;
outline: 0;
background: #f1f1f1;
line-height: 36px;
font-size: 14px;
width: calc(100% - 20px);
box-sizing: border-box;
}
.header-search-box input:focus{
outline: 0;
}
.words-list{
min-width: 320px;
border-right: 1px solid #eaeaea;
padding-right: 12px;
box-sizing: border-box;
}
.words-detail{
padding-left: 20px;
flex: auto;
}
.body-title{
font-size: 14px;
font-weight: bold;
min-height: 20px;
padding-bottom: 12px;
position: relative;
}
.words-list, .words-detail{
display: flex;
flex-direction: column;
}
.words-list-inner{
flex: auto;
overflow: scroll;
}
.words-detail-inner{
flex: auto;
overflow: scroll;
/* padding: 12px 0; */
margin-top: 24px;
padding-bottom: 20px;
}
.body-title.border{
border-bottom: 1px solid #eaeaea;
}
.body-title.no-margin{
margin-bottom: 0;
}
.form-item{
display: flex;
}
.form-item.center{
align-items: center;
}
.form-item+.form-item{
margin-top: 20px;
}
.form-item .title{
min-width: 104px;
color: #999;
text-align: left;
margin-right: 12px;
font-size: 13px;
}
.form-item .detail{
flex: auto;
}
.action-list span{
padding: 0 10px;
cursor: pointer;
}
.action-list span:hover{
color: #d0021b;
}
.action-list span+span{
border-left: 1px solid #eaeaea;
}
.condition-list{
border: 1px solid #eaeaea;
border-radius: 4px;
padding: 8px 12px;
width: 636px;
position: relative;
}
.condition-list+.condition-list{
margin-top: 20px;
}
.action-list{
/* border-bottom: 1px solid #eaeaea; */
padding: 12px 0;
background: #f9f9f9;
margin-top: 12px;
border-radius: 4px;
}
.my-slider{
display: inline-block;
flex: auto;
margin-left: 12px;
}
.condition-detail-list{
display: flex;
align-items: center;
}
.my-slider .el-slider__runway{
margin: 12px 0;
}
.my-slider .el-slider__button{
width: 12px;
height: 12px;
}
.condition-detail{
margin-top: 12px;
border-top: 1px solid #eaeaea;
padding-top: 12px;
}
.form-item .detail img{
width: 636px;
height: auto;
border-radius: 4px;
}
.chart-condition{
padding: 8px 0;
}
.words-list-search{
margin-bottom: 12px;
}
.hover-icon{
cursor: pointer;
}
.hover-icon:hover{
color: #d0021b;
}
.hover-icon.red{
color: #d0021b;
}
.slide-fade-enter-active {
transition: all .3s ease;
}
.slide-fade-leave-active {
transition: all .1s cubic-bezier(1.0, 0.5, 0.8, 1.0);
}
.slide-fade-enter, .slide-fade-leave-to
/* .slide-fade-leave-active for below version 2.1.8 */ {
transform: translateX(50px);
opacity: 0;
}
.close-btn{
position: absolute;
background: #fff;
right: -10px;
top: -10px;
font-size: 20px;
}
.complex-condition .cal-index-detail{
min-width: 220px;
max-width: 220px;
height: 442px;
}
.condition-action{
/* background: rgb(245, 247, 250); */
padding: 6px 12px;
border-radius: 4px;
}
.simple-condition-box{
border: 1px solid #eaeaea;
padding: 0 12px;
}
.complex-condition-showDom{
padding: 12px;
border: 1px solid #eaeaea;
box-sizing: border-box;
background: rgb(245, 247, 250);
}
.back-btn{
position: absolute;
top: -6px;
right: 0;
}
.inline-block{
display: inline-block;
}
.condition-detail-list .inline-block+.inline-block{
margin-left: 20px;
}
.gray{
color: #999;
}
.run-dialog .title{
text-align: right;
}
.run-dialog{
display: flex;
}
.flex-dialog-left{
min-width: 200px;
padding-right:12px;
border-right: 1px solid #eaeaea;
overflow: scroll;
}
.flex-dialog-right{
flex: auto;
padding-left:12px;
}
.selected-words{
font-size: 13px;
color: #333;
font-weight: bold;
}
.calculater-keybord{
width: 400px;
}
.empty-status{
min-height: 400px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.empty-status img{
width: 130px;
height: auto;
margin-bottom: 10px;
}
.empty-status .empty-tip{
font-size: 14px;
color: #999;
}
.detail-condition{
font-size: 12px;
}
.detail-condition+.detail-condition{
margin-top: 12px;
}
.detail-condition .title{
color: #999;
}
.table-condition{
margin-bottom: 20px;
}
.el-link{
font-size: 12px;
}
.el-link.el-link--default{
color: #d0021b;
}
.calculater-words-box{
border: 1px solid #eaeaea;
padding: 12px;
}
.detail.active{
background: #ffe7ea;
padding: 6px 12px;
}
\ No newline at end of file
var init = require('../../lib/init.js')
var value = init(__filename, __dirname)
const { dialog } = require('electron').remote
const officegen = require('officegen')
const fs = require('fs')
const indexCondition = require('../../../../components/condition/index.js')
const companySelector = require('../../../../components/companySelector/index.js')
var keyBord = require('../../lib/keyBord')
var tools = require('../../lib/tools.js')
// const condition = require('../components/condition/index.js')
module.exports[value.name] = {
data: function () {
return {
tableData: [],
tableType: 2,
searchedName: '',
pageTotal: 0,
pageCurrent: 1,
psize: 15,
tableLoading: true,
activeIndex: {},
activeIndexCondition: {},
subActiveIndex: {},
subActiveIndexCondition: {},
showIndexDetail: false,
defaultTypeList: [],
companyNameObj: {},
initIndexObj: {},
keyboardObj: {},
passCategoryVisible: false,
choosedPassCategory: [],
publicCategoryOptions: [],
publicProps: {
value: 'Id',
label: 'ArchiveName',
children: 'Children',
checkStrictly: true,
multiple: true
},
passLoading: false,
testRunVisible: false,
rangeCompany: '',
searchCompanyLoading: false,
runningCompanyList: [],
selectedRangeCompany: [],
zjhIndustryData: [],
swIndustryData: [],
marketData:[],
positionData: [],
industryObj: {},
testYear: '',
testQuarter: '',
testMergeType: '合并本期',
activeRangeTab: '3',
showEditIndexDetail: false,
showEditWikiDetail: false,
initIndex: 1,
currentAccount: 0,
sortType: null,
companyStatusData: [],
companyStatusCheck: {
isIndeterminate: false,
checkAll: false,
checkedItems: ['013001'],
options: []
},
activeWordConditions: [],
mainActiveWordConditions: [],
subActiveWordConditions: [],
deirectionObj: {
"-1": "负面",
"0": "中性",
"1": "正面",
"2": '不确定',
"3": '未定义'
},
testSingleVisible: false,
testDirection: null,
testMinRiskLevel: 1,
testMaxRiskLevel: 10,
testMinRiskStrong: 1,
testMaxRiskStrong: 10,
runSingleTableLoading: false,
runSingleTableData: [],
runLoading: false,
isWordsDot: false,
IntervalId: 0,
wordsPermission: false
}
},
components: {indexCondition, companySelector},
template: value.template,
mounted () {
this.checkPermission(53, 'wordsPermission')
this.getSortBadge()
this.IntervalId = setInterval(() => {
this.getSortBadge()
}, 30000)
this.currentAccount = store.get('accountId')
this.getDefaultType()
this.getPublicCategory()
tools.getKeyboardObj(keyBord, this.keyboardObj)
tools.getIndexs(this.initIndexObj).then(res => {
this.getWordsData()
})
this.getZjhIndustryCategoryList()
this.getSwIndustryCategoryList()
this.getPositionData()
this.getMarketData()
this.getCompanyStatusData()
},
beforeDestroy(){
clearInterval(this.IntervalId)
},
methods: {
checkPermission (id, key) {
return new Promise((resolve, reject) => {
http.netPost('Account/Account/CheckPermission', {
"id": id,
"AccountId": store.get('accountId')
})
.then((res) => {
if (res.data.Status == 1) {
if(res.data.Data == 1){
this[key] = true
}
resolve()
}
})
})
},
getSortBadge () {
return new Promise((resolve) => {
http.netPost('Data/SmartWord/GetTodoSmartWordCount', {
"AccountId": store.get('accountId')
})
.then((res) => {
if (res.data.Status == 1) {
if(res.data.Data > 0){
this.isWordsDot = true
}else{
this.isWordsDot = false
}
resolve(res)
}
})
})
},
getCompanyStatusData () {
return new Promise((resolve, reject) => {
http.netPost('Data/Query/Query', {
"List": [
"F90063V",
"F90064V"
],
"Where": [],
"WhereOr": [],
"WhereOrArrayAnd": [],
"Sort": [{
"Encode":"F90063V",
"State":1
}],
"GPBField": ["F90063V"],
"Current": 0,
"Psize": 100,
"JoinTableWay": 0
})
.then((res) => {
if (res.data.Status == 1) {
this.companyStatusData = []
res.data.Data.Records.forEach(item => {
if(item["F90063V"]){
this.companyStatusData.push(item)
this.companyStatusCheck.options.push(item["F90063V"])
}
})
}
})
})
},
changeSort (res) {
this.sortType = res.order
},
compare (prop, type) {
return function (obj1, obj2) {
var val1 = parseFloat(obj1[prop])
var val2 = parseFloat(obj2[prop])
if (val1 < val2) {
return type == 'ascending'?-1:1;
} else if (val1 > val2) {
return type == 'ascending'?1:-1;
} else {
return 0;
}
}
},
exportExcel () {
var that = this
var excelName = new Date().getTime()
var xlsx = officegen('xlsx')
var filePath = dialog.showSaveDialog({
defaultPath: excelName + '.xlsx',
title: '保存',
buttonLabel: '保存'
})
xlsx.on('finalize', function(written) {
that.$message({
message: '表格导出成功!',
type: 'success'
})
})
xlsx.on('error', function(err) {
console.log(err)
})
var sheet = xlsx.makeNewSheet()
sheet.name = 'sheet'
sheet.orientation = 'landscape'
sheet.data[0] = []
sheet.data[0][0] = '序号'
sheet.data[0][1] = '证券简称'
sheet.data[0][2] = '证券代码'
sheet.data[0][3] = this.activeIndex.IndexName
var newArr = JSON.parse(JSON.stringify(this.selectedRangeCompany))
if(this.sortType == 'descending'){
newArr.sort(that.compare('result', 'descending'))
}else if(this.sortType == 'ascending'){
newArr.sort(that.compare('result', 'ascending'))
}
newArr.forEach((item, index)=>{
sheet.data[index + 1] = []
sheet.data[index + 1][0] = index+1
sheet.data[index + 1][1] = item['name']
sheet.data[index + 1][2] = item['code']
sheet.data[index + 1][3] = item['result']
})
var out = fs.createWriteStream(filePath)
out.on('error', function(err) {
console.log(err)
})
xlsx.generate(out)
},
testRunIndex () {
//判断条件
var args = []
var ref = this.$refs.conditionChoose
if(!ref.testMergeType || !ref.testYear || !ref.testQuarter || this.selectedRangeCompany.length == 0){
this.$message({
message: '参数不完整或标的为空',
type: 'error'
})
return false
}
this.selectedRangeCompany.forEach(item => {
args.push({
stockCode: item.code,
argType: 1
})
})
args.push({
mergeType: ref.testMergeType,
argType: 2
},{
reportingPeriod: ref.testYear + '-' +ref.testQuarter,
argType: 4
})
this.searchCompanyLoading = true
return new Promise((resolve, reject) => {
http.netPost('Data/CustomIndex/TestRunPublicCustomIndex', {
args: args,
"id": this.activeIndex.Id,
"runVersion": 1
})
.then((res) => {
if (res.data.Status == 1) {
this.selectedRangeCompany.forEach(item => {
if(res.data.Data[item.code] !== "NaN"){
item.result = res.data.Data[item.code]
}else{
item.result = '分母为0'
}
})
resolve()
}
this.searchCompanyLoading = false
})
})
},
addRangeCompany(item) {
var code = item.split(',')[1]
var obj = {
name: item.split(',')[0],
code: code,
}
// this.selectedRangeCompany.push([])
this.addAndRemoveCompany([obj])
this.rangeCompany = ''
},
//对数据进行去重
addAndRemoveCompany (arr) {
var oldCompany = {}
this.selectedRangeCompany.forEach(item => {
oldCompany[item.code] = item.name
})
arr.forEach(item => {
if(!oldCompany[item.code]){
this.selectedRangeCompany.push({
code: item.code,
name: item.name,
result: null
})
}
})
},
searchRunningCompany(value) {
this.searchCompanyLoading = true
var checkeds = this.companyStatusCheck.checkedItems
var Where = []
if(checkeds.length > 0){
Where.push({
"Encode": "F90063V",
"State": checkeds.length == 1?1:8,
"Value": checkeds.length == 1?checkeds[0]:checkeds
})
}
return new Promise((resolve, reject) => {
http.netPost('Data/Query/Query', {
"List": ["F90004V", 'F90001V', 'F90002V'],
"WhereOr": [
{
"Encode": "F90004V",
"State": 2,
"Value": value,
},
{
"Encode": "F90001V",
"State": 2,
"Value": value,
},
{
"Encode": "F90002V",
"State": 2,
"Value": value,
},
],
"Where": Where,
"Current": 0,
"Psize": 20
})
.then((res) => {
if (res.data.Status == 1) {
this.runningCompanyList = res.data.Data.Records
}
this.searchCompanyLoading = false
})
})
},
selectedExcel(e) {
var file = e.target.files[0]
var type = file.name.split('.')
if (type[type.length - 1] !== 'xlsx' && type[type.length - 1] !== 'xls') {
this.$message({
message: '所选文件格式不正确!',
type: 'error'
})
e.target.value = ''
return false;
} else {
const reader = new FileReader();
reader.readAsBinaryString(file);
reader.onload = (e) => {
const data = e.target.result;
const zzexcel = window.XLS.read(data, {
type: 'binary'
})
const result = [];
for (let i = 0; i < zzexcel.SheetNames.length; i++) {
const newData = window.XLS.utils.sheet_to_json(zzexcel.Sheets[zzexcel.SheetNames[i]]);
result.push(...newData)
}
var arr = []
result.forEach(item => {
var obj = {
name: item.name,
code: item.code.split('.')[0]
// label: item.name,
// type: 5,
// from: '批量添加'
}
arr.push(obj)
})
this.addAndRemoveCompany(arr)
}
this.$message({
message: '导入成功!',
type: 'success'
})
e.target.value = ''
}
},
handleCheckAllChange(val, obj) {
obj.checkedItems = val ? obj.options : []
obj.isIndeterminate = false
},
handleCheckedResults(value, obj) {
let checkedCount = value.length
obj.checkAll = checkedCount === obj.options.length
obj.isIndeterminate = checkedCount > 0 && checkedCount < obj.options.length
},
getZjhIndustryCategoryList() {
return new Promise((resolve, reject) => {
http.netPost('Data/Query/Query', {
"List": [
"F90013V",
"F90012V",
"F90014V",
"F90015V"
],
"Where": [],
"GPBField": ["F90015V"],
"Current": 0,
"Psize": 10000
})
.then((res) => {
if (res.data.Status == 1) {
this.handleZjhData(res.data.Data.Records)
}
})
})
},
getMarketData() {
http.netPost('Data/Query/Query', {
"List": [
"F90005V",
"F90006V"
],
"Where": [],
"WhereOr": [],
"GPBField": [
"F90005V"
],
"Current": 0,
"Psize": 999
}).then((res) => {
this.marketData = res.data.Data.Records
this.marketData.forEach(item => {
item.label = item.F90006V,
item.searchCode = 'F90006V'
})
})
},
getPositionData() {
return new Promise((resolve, reject) => {
http.netPost('Data/Query/Query', {
"List": [
"F90010V",
"F90011V"
],
"Where": [],
"WhereOr": [],
"GPBField": [
"F90010V",
"F90011V"
],
"Current": 0,
"Psize": 999
}).then((res) => {
if (res.data.Status == 1) {
var parentObj = {}
var newArray = res.data.Data.Records
newArray.forEach(item => {
if (!parentObj[item.F90010V]) {
parentObj[item.F90010V] = {
id: item.F90010V,
label: item.F90010V,
code: 'F90010V',
children: [],
searchCode: 'F90010V',
}
parentObj[item.F90010V].children.push({
id: item.F90011V,
label: item.F90011V,
code: 'F90011V',
searchCode: 'F90011V'
})
} else {
parentObj[item.F90010V].children.push({
id: item.F90011V,
label: item.F90011V,
code: 'F90011V',
searchCode: 'F90011V'
})
}
})
this.positionData = []
for (var key in parentObj) {
if (key !== 'null') {
this.positionData.push(parentObj[key])
}
}
}
})
})
},
handleSwData(data) {
var parentObj = {}
var parentArray = []
var childObj = {}
var childArray = []
data.map((item) => {
if (!parentObj[item.F90016V]) {
parentObj[item.F90016V] = item
parentArray.push({
label: item.F90017V,
id: item.F90016V,
code: 'F90017V',
from: '申万' + '-' + item.F90017V,
searchCode: 'F90017V'
})
this.industryObj[item.F90016V] = '申万' + '-' + item.F90017V
}
if (!childObj[item.F90018V]) {
childObj[item.F90018V] = item
childArray.push({
label: item.F90019V,
id: item.F90018V,
parentId: item.F90016V,
code: 'F90019V',
from: '申万' + '-' + item.F90017V + '-' + item.F90019V,
searchCode: 'F90019V'
})
this.industryObj[item.F90018V] = '申万' + '-' + item.F90017V + '-' + item.F90019V
}
})
childArray.map((chid) => {
chid.children = []
data.map((item) => {
if (chid.id == item.F90018V) {
chid.children.push({
label: item.F90021V,
id: item.F90020V,
code: 'F90021V',
from: chid.from + '-' + item.F90021V,
searchCode: 'F90021V'
})
this.industryObj[item.F90020V] = chid.from + '-' + item.F90021V
}
})
})
parentArray.map((sub) => {
sub.children = []
childArray.map((item) => {
if (sub.id == item.parentId) {
sub.children.push(item)
}
})
})
this.swIndustryData = [
{
label: '申万行业',
id: 0,
code: '0',
from: '',
searchCode: '0',
children: parentArray
}
]
},
//处理证监会行业数据
handleZjhData(data) {
var newObj = {}
var newArray = []
data.map((item) => {
if (!newObj[item.F90014V]) {
newObj[item.F90014V] = item
newArray.push({
label: item.F90012V,
id: item.F90014V,
code: 'F90014V',
from: '证监会' + '-' + item.F90012V,
labelCode: 'F90012V',
searchCode: 'F90012V'
})
this.industryObj[item.F90014V] = '证监会' + '-' + item.F90012V
}
})
newArray.map((chid) => {
chid.children = []
data.map((item, index) => {
if (chid.id == item.F90014V) {
chid.children.push({
label: item.F90013V,
id: item.F90015V,
code: 'F90015V',
labelCode: 'F90013V',
from: chid.from + '-' + item.F90013V,
searchCode: 'F90013V'
})
this.industryObj[item.F90015V] = chid.from + '-' + item.F90013V
}
})
})
this.zjhIndustryData = [
{
label: '证监会行业',
id: 0,
code: '0',
labelCode: '0',
from: '',
searchCode: '0',
children: newArray
}
]
},
getSwIndustryCategoryList() {
return new Promise((resolve, reject) => {
http.netPost('Data/Query/Query', {
"List": [
"F90016V",
"F90017V",
"F90018V",
"F90019V",
"F90020V",
"F90021V"
],
"Where": [],
"GPBField": ["F90020V"],
"Current": 0,
"Psize": 10000
})
.then((res) => {
if (res.data.Status == 1) {
this.handleSwData(res.data.Data.Records)
}
})
})
},
searchCompanyByIndustry(item, type) {
this.searchCompanyLoading = true
var Where = []
var checkeds = this.companyStatusCheck.checkedItems
if(type == 1 || type == 2 || type == 4 || type == 3){
Where.push({
"Encode": item.searchCode,
"State": 1,
"Value": item.label,
})
if(checkeds.length > 0){
Where.push({
"Encode": "F90063V",
"State": checkeds.length == 1?1:8,
"Value": checkeds.length == 1?checkeds[0]:checkeds
})
}
}
this.initIndex++
var params = {
content: {
"List": ['F90001V', 'F90002V'],
"Where": Where,
"Current": 0,
"Psize": 10000
}
}
return new Promise((resolve, reject) => {
var companyObj = {}
this.selectedRangeCompany.forEach(item => {
if(!companyObj[item.F90001V]){
companyObj[item.F90001V] = item.F90001V
}
})
http.netPost('Data/Query/Query', params.content)
.then((res) => {
if (res.data.Status == 1) {
var arr = []
res.data.Data.Records.map((child) => {
if(!companyObj[child.F90001V]){
arr.push({
name: child.F90002V,
code: child.F90001V
})
}
})
this.addAndRemoveCompany(arr)
}
this.searchCompanyLoading = false
})
})
},
openTestRunDialog (row) {
this.activeIndex = row
this.testRunVisible = true
},
confirmPassReview (type) {
this.passLoading = true
var arr = []
this.choosedPassCategory.forEach(item => {
arr.push(item[item.length - 1])
})
return new Promise((resolve, reject) => {
http.netPost('Data/SmartWord/ViewSmartWord', {
"status": type == 'pass'?16:32,
"id": this.activeIndex.Id,
"archiveIds": arr,
"AccountId": store.get('accountId')
})
.then((res) => {
if (res.data.Status == 1) {
this.pagClick(1)
this.getSortBadge()
this.passCategoryVisible = false
this.$message({
message: '操作成功',
type: 'success'
})
resolve()
}
this.passLoading = false
})
})
},
getIndexCategory (code, options) {
var textArr = []
var arr = this.findPathByLeafId(code, options)
if(!arr){
arr = []
}
arr.forEach(item => {
textArr.push(item.name)
})
return textArr.join(' / ')
},
getIndexCategorys (codes, options) {
var arr = []
if(codes){
codes.forEach(item => {
arr.push(this.getIndexCategory(item, options))
})
}
return arr
},
getIsSameCategory (activeIndex, subActiveIndex) {
var activeText = '', subText = ''
if(activeIndex.ArchiveIds.length == 0){
activeText = '0'
}else{
activeText = JSON.stringify(activeIndex.ArchiveIds)
}
if(subActiveIndex.ArchiveIds.length == 0){
subText = ''
}else{
subText = JSON.stringify(subActiveIndex.ArchiveIds)
}
return subText == activeText
},
findPathByLeafId(leafId, nodes, path) {
if (path === undefined) {
path = []
}
for (var i = 0; i < nodes.length; i++) {
var tmpPath = path.concat()
tmpPath.push({
code: nodes[i].Id,
name: nodes[i].ArchiveName
})
if (leafId == nodes[i].Id) {
return tmpPath;
}
if (nodes[i].Children) {
var findResult = this.findPathByLeafId(leafId, nodes[i].Children, tmpPath);
if (findResult) {
return findResult
}
}
}
},
getPublicCategory () {
return new Promise((resolve, reject) => {
http.netPost('Data/SmartWord/GetPublicSmartWordArchive', {})
.then((res) => {
if (res.data.Status == 1) {
this.publicCategoryOptions = res.data.Data
resolve()
}
})
})
},
confirmPass (row, type) {
this.activeIndex = row
if(type == 'add'){
this.choosedPassCategory = this.getEditIndexCategory(row)
this.passCategoryVisible = true
}else if(type == 'edit'){
this.choosedPassCategory = this.getEditIndexCategory(row)
this.passCategoryVisible = false
this.confirmPassReview('pass')
}
},
getEditIndexCategory(row) {
var result = []
if(row.PendingData.ArchiveIds){
row.PendingData.ArchiveIds.forEach(item => {
var categoryArr = []
var arr = this.findPathByLeafId(item, this.publicCategoryOptions)
if(!arr){
return []
}
arr.forEach((item, index) => {
categoryArr.push(item.code)
})
result.push(categoryArr)
})
}
return result
},
getDefaultType () {
return new Promise((resolve, reject) => {
http.netPost('Data/CustomIndex/GetAllIndexArgs', {
"AccountId": store.get('accountId')
})
.then((res) => {
if (res.data.Status == 1) {
this.defaultTypeList = res.data.Data
resolve()
}
})
})
},
getDataType(activeIndex) {
var obj = {
0: '字符',
1: '日期',
2: '数字'
}
return obj[activeIndex.ReturnType]
},
getIndexArgsType (args) {
var arr = []
this.defaultTypeList.forEach(item => {
if(args&item.Id){
arr.push(item.Name)
}
})
return arr.join('')
},
getWordsData () {
this.tableLoading = true
return new Promise((resolve, reject) => {
http.netPost('Data/SmartWord/GetPendingViewSmartWord', {
"status": this.tableType,
"current": (this.pageCurrent - 1) * this.psize,
"psize": this.psize,
"name": this.searchedName,
"accountId": store.get('accountId')
})
.then((res) => {
if (res.data.Status == 1) {
res.data.Data.Result.forEach(item => {
item.status = this.getCurrentStatus(item.WdPublicSmartWordWorkflows)
})
this.tableData = res.data.Data.Result
this.pageTotal = res.data.Data.Total
}
this.tableLoading = false
})
})
},
getCurrentStatus (arr) {
var status = {}
arr.forEach(item => {
if(item.IsCurrent == 1){
status = item
}
})
return status
},
pagClick (page) {
this.pageCurrent = page
this.getWordsData()
},
openDetailDialog (data) {
if(this.tableType == 2){ //审核升级
this.openDetail(data)
}else if(this.tableType == 4){ //审核修改
this.openChangeDetail(data)
}else if(this.tableType == 8){ //审核百科
this.openWikiDetail(data)
}
},
openWikiDetail (data) {
this.showEditWikiDetail = true
this.activeIndex = data
},
openChangeDetail (data) {
this.showEditIndexDetail = true
data.Conditions.forEach(item => {
item.Content = item.Condition.Object
})
this.activeIndex = data
this.subActiveIndex = data.PendingData
this.setDetailCondition(data, 'mainActiveWordConditions', 'mainConditionBox')
this.setDetailCondition(data.PendingData, 'subActiveWordConditions', 'subConditionBox')
},
setDetailCondition (data, keyName, id) {
this[keyName] = []
data.Conditions.forEach(item => {
this[keyName].push({
indexParams: {},
dateParams: {},
numParams: {},
symbolParams: {},
functionParams: {},
dom: '',
showDom: ''
})
})
this.getUsedCompany(data.Conditions).then(res => {
this[keyName].forEach((item,index) => {
this.initIndex++
tools.getSaveCondition(
item,
data.Conditions[index].Content,
this.initIndex,
this.initIndexObj,
this.companyNameObj,
this.keyboardObj
)
})
this.$nextTick(()=>{
this[keyName].forEach((item, index)=>{
var spans = document.getElementById(id + index).getElementsByTagName('span')
var html = ''
Array.from(spans).forEach(span => {
html += span.outerHTML
})
document.getElementById(id + index).innerHTML = html
var spans = document.getElementById(id + index).getElementsByTagName('span')
tools.formatShowDom(spans)
})
})
})
},
getUsedCompany(arr){
var codes = []
arr.forEach(item => {
var params = item.Content
params.forEach(item => {
if (item.OperandType == 0 && item.Where[2]) {
codes.push(item.Where[2].Value)
} else if (item.OperandType == 4) {
item.Args.forEach(sub => {
sub.forEach(child => {
if (child.OperandType == 0 && child.Where[2]) {
codes.push(child.Where[2].Value)
}
})
})
}
})
})
var where = [{
"Encode": "F90001V",
"State": 7,
"Value": codes.join(','),
}]
return new Promise((resolve, reject) => {
http.netPost('Data/Query/Query', {
"List": ['F90001V', 'F90002V'],
"Where": where,
"Current": 0,
"Psize": 100
})
.then((res) => {
if (res.data.Status == 1) {
res.data.Data.Records.forEach(item => {
this.companyNameObj[item.F90001V] = item.F90002V
})
resolve()
} else if (res.data.Status == 0) {
resolve()
} else {
reject()
}
})
})
},
openDetail (data) {
this.activeIndex = data
this.showIndexDetail = true
this.activeWordConditions = []
data.PendingData.Conditions.forEach(item => {
this.activeWordConditions.push({
indexParams: {},
dateParams: {},
numParams: {},
symbolParams: {},
functionParams: {},
dom: '',
showDom: ''
})
})
this.getUsedCompany(this.activeIndex.PendingData.Conditions).then(res => {
this.activeWordConditions.forEach((item,index) => {
this.initIndex++
tools.getSaveCondition(
item,
data.PendingData.Conditions[index].Content,
this.initIndex,
this.initIndexObj,
this.companyNameObj,
this.keyboardObj
)
})
this.$nextTick(()=>{
this.activeWordConditions.forEach((item, index)=>{
var spans = document.getElementById('conditionBox' + index).getElementsByTagName('span')
var html = ''
Array.from(spans).forEach(span => {
html += span.outerHTML
})
document.getElementById('conditionBox' + index).innerHTML = html
var spans = document.getElementById('conditionBox' + index).getElementsByTagName('span')
tools.formatShowDom(spans)
})
})
})
},
testRunMultiple (data) {
this.activeIndex = data
this.testSingleVisible = true
this.testRunWords = [data]
},
confirmRunWords () {
var arr = []
this.testRunWords.forEach(item => {
arr.push(item.Id)
})
var args = []
var ref = this.$refs.conditionChoose
var selectedRangeCompany = this.$refs.companySelector.selectedRangeCompany
if(!ref.testMergeType || !ref.testYear || !ref.testQuarter || selectedRangeCompany.length == 0){
this.$message({
message: '参数不完整或标的为空',
type: 'error'
})
return false
}
selectedRangeCompany.forEach(item => {
args.push({
stockCode: item.code,
argType: 1
})
})
args.push({
mergeType: ref.testMergeType,
argType: 2
},{
reportingPeriod: ref.testYear + '-' +ref.testQuarter,
argType: 4
})
this.runLoading = true
this.runSingleTableLoading = true
return new Promise((resolve, reject) => {
http.netPost('Data/SmartWord/TestRunPublicSmartWord', {
"id": arr,
"args": args,
"direction": this.testDirection,
"riskLevel": [this.testMinRiskLevel, this.testMaxRiskLevel],
"signalStrength": [this.testMinRiskStrong, this.testMaxRiskStrong],
"AccountId": store.get('accountId')
})
.then((res) => {
if (res.data.Status == 1) {
var arr = JSON.parse(JSON.stringify(this.$refs.companySelector.selectedRangeCompany))
arr.forEach(item => {
item.value = res.data.Data[item.code]
})
this.runSingleTableData = arr
resolve()
}else{
this.runSingleTableData = JSON.parse(JSON.stringify(this.$refs.companySelector.selectedRangeCompany))
}
this.runLoading = false
this.runSingleTableLoading = false
})
})
},
getRunningResult (arr) {
if(arr){
var newArr = []
arr.forEach(item => {
newArr.push(item.SmartWord.Name)
})
return newArr.join('')
}else{
return '-'
}
},
downloadExample () {
var that = this
var excelName = '示例表格'
var xlsx = officegen('xlsx')
var filePath = dialog.showSaveDialog({
defaultPath: excelName + '.xlsx',
title: '保存',
buttonLabel: '保存'
})
xlsx.on('finalize', function(written) {
that.$message({
message: '下载完成',
type: 'success'
})
})
xlsx.on('error', function(err) {
console.log(err)
})
var sheet = xlsx.makeNewSheet()
sheet.name = 'sheet1'
sheet.orientation = 'landscape'
sheet.data[0] = []
sheet.data[0][0] = 'name'
sheet.data[0][1] = 'code'
sheet.data[1] = []
sheet.data[1][0] = '华夏银行'
sheet.data[1][1] = '600015.sh'
sheet.data[2] = []
sheet.data[2][0] = '贵州茅台'
sheet.data[2][1] = '600519'
sheet.data[3] = []
sheet.data[3][0] = '工商银行'
sheet.data[3][1] = '601398'
var out = fs.createWriteStream(filePath)
out.on('error', function(err) {
console.log(err)
})
xlsx.generate(out)
}
}
}
<template>
<div class="container">
<div class="header shadow">
<div class="header-router">
<div class="parent-name">智能词管理</div>
<div class="router-list" style="display: flex">
<router-link tag="span" active-class="active-link" exact to="/">我的智能词</router-link>
<router-link tag="span" active-class="active-link" exact to="/publicWords">公共智能词</router-link>
<el-badge :is-dot="isWordsDot && wordsPermission" class="item">
<router-link tag="span" active-class="active-link" exact to="/wordsAudit">智能词审核</router-link>
</el-badge >
<router-link tag="span" style="flex: auto; text-align: right;border-left: 0" active-class="active-link" exact to="/wordsRecord">
<span class="el-icon-date"> 指标修改日志</span>
</router-link>
</div>
</div>
<div class="header-search">
<div>
<el-radio-group v-model="tableType" @change="pagClick(1)" size="small">
<el-radio-button :label="2">审核升级</el-radio-button>
<el-radio-button :label="4">审核修改</el-radio-button>
<el-radio-button :label="8">审核百科</el-radio-button>
</el-radio-group>
</div>
</div>
</div>
<div class="main-body" style="display: block">
<div class="table-condition">
<span class="gray">关键词搜索:</span>
<el-input clearable style="width: 200px" v-model="searchedName" size="mini" placeholder="请输入关键词名称"></el-input>
<el-button type="primary" size="mini" style="margin-left:12px" @click="pagClick(1)">搜索</el-button>
</div>
<div class="table-box">
<div class="table-wrap">
<el-table
size="mini"
v-loading="tableLoading"
:data="tableData"
:header-cell-style="{background:'#f5f7fa',color:'#666'}"
border>
<el-table-column prop="index" label="序号" width="60" type="index"></el-table-column>
<el-table-column prop="Name" width="400" label="关键词名称"></el-table-column>
<el-table-column prop="resarcher" label="提交人">
<template slot-scope="scope">
<span v-if="(tableType == 4 || tableType == 8) && scope.row.status.Creator">{{scope.row.status.Creator.NickName}}</span>
<span v-if="tableType == 2">{{scope.row.status.Creator.NickName}}</span>
</template>
</el-table-column>
<el-table-column prop="LastUpdate" label="提交时间">
<template slot-scope="scope">
<span>{{scope.row.status.CreateDate}}</span>
</template>
</el-table-column>
<el-table-column prop="formula" width="120" label="详情">
<template slot-scope="scope">
<el-link size="mini" @click="openDetailDialog(scope.row)">查看详情</el-link>
</template>
</el-table-column>
<el-table-column width="280" label="操作">
<template slot-scope="scope">
<!-- <el-link size="mini">查看日志</el-link> -->
<el-link size="mini" type="success" @click="testRunMultiple(scope.row)">测试运行</el-link>
<el-link size="mini" type="success" @click="confirmPass(scope.row, 'add')" v-show="tableType == 2 && scope.row.PendingData.CreatorId !== currentAccount">审核通过</el-link>
<el-link size="mini" type="success" @click="confirmPass(scope.row, 'edit')" v-show="tableType == 4 && scope.row.PendingData.CreatorId !== currentAccount">审核通过</el-link>
<el-link size="mini" type="success" @click="confirmPass(scope.row, 'edit')" v-show="tableType == 8 && scope.row.PendingData.CreatorId !== currentAccount">审核通过</el-link>
<el-popconfirm
confirmButtonText='确认'
@onConfirm="activeIndex = scope.row; choosedPassCategory = getEditIndexCategory(scope.row); confirmPassReview('delete')"
cancelButtonText='取消'
icon="el-icon-info"
iconColor="red"
title="确认驳回该指标?">
<el-link size="mini" type="danger" v-show="(scope.row.PendingData.CreatorId !== currentAccount && tableType == 2) || (scope.row.PendingData.CreatorId !== currentAccount && tableType == 4) || (scope.row.PendingData.CreatorId !== currentAccount && tableType == 8)" slot="reference">审核驳回</el-link>
</el-popconfirm>
</template>
</el-table-column>
</el-table>
</div>
</div>
<div class="pagination-container">
<el-pagination
layout="prev, pager, next"
:current-page="pageCurrent"
@current-change="pagClick"
:page-size="psize"
:total="pageTotal"
></el-pagination>
</div>
</div>
<el-dialog title="指标文件夹选择" :visible.sync="passCategoryVisible" width="600px">
<div class="detail-container" style="padding-top:0; font-size: 13px">
<div class="detail-index">
<div class="title" style="color: #999">所属文件夹:</div>
<div class="detail">
<el-cascader
size="mini"
style="width: 300px"
:props="publicProps"
v-model="choosedPassCategory"
:options="publicCategoryOptions">
</el-cascader>
</div>
</div>
</div>
<div slot="footer">
<el-button size="mini" @click="passCategoryVisible = false">取消</el-button>
<el-button size="mini" type="primary" :loading="passLoading" @click="confirmPassReview('pass')">确认</el-button>
</div>
</el-dialog>
<el-dialog title="智能词详情" :visible.sync="showIndexDetail" width="800px">
<div class="detail-container" style="padding-top:0; font-size: 13px">
<div class="detail-index">
<div class="title" style="color: #999">智能词名称:</div>
<div class="detail">{{activeIndex.Name}}</div>
</div>
<div class="detail-index">
<div class="title" style="color: #999">智能词创建人:</div>
<div class="detail" v-if="activeIndex.status">{{activeIndex.status.Creator.NickName}}</div>
</div>
<div class="detail-index">
<div class="title" style="color: #999">建议分类:</div>
<div class="detail" v-if="activeIndex.PendingData">
<div v-for="item in getIndexCategorys(activeIndex.PendingData.ArchiveIds, publicCategoryOptions)">
{{item}}
</div>
</div>
</div>
<div class="detail-index">
<div class="title" style="color: #999">智能词方向:</div>
<div class="detail">
<div class="sub-detail">
<span v-if="activeIndex.Direction">{{deirectionObj[activeIndex.Direction.toString()]}}</span>
</div>
</div>
</div>
<div class="detail-index">
<div class="title" style="color: #999">智能词百科:</div>
<div class="detail">
<div class="sub-detail">
<span>{{activeIndex.Wiki}}</span>
</div>
</div>
</div>
<div class="detail-index">
<div class="title" style="color: #999">智能词算法:</div>
<div class="detail">
<div v-for="(item,index) in activeWordConditions"
class="calculater-words-box" :id="'conditionBox' + index"
v-html="item.showDom">
</div>
</div>
</div>
<div class="detail-index" v-if="activeIndex.WdCustomIndexWorkflow">
<div class="title" style="color: #999">备注:</div>
<div class="detail">
<span>{{activeIndex.WdCustomIndexWorkflow[activeIndex.WdCustomIndexWorkflow.length - 1].Remark}}</span>
</div>
</div>
</div>
</el-dialog>
<el-dialog title="智能词详情" :visible.sync="showEditIndexDetail" width="1100px">
<div class="double-detail-box" style="display:flex">
<div class="detail-container" style="padding-top:0; font-size: 13px; margin-right: 12px">
<div class="detail-index">
<h3>原数据</h3>
</div>
<div class="detail-index">
<div class="title" style="color: #999">智能词名称:</div>
<div class="detail"
:class="{active: activeIndex.IndexName !== subActiveIndex.IndexName}">
{{activeIndex.Name}}
</div>
</div>
<div class="detail-index">
<div class="title" style="color: #999">智能词创建人:</div>
<div class="detail" v-if="activeIndex.status">{{activeIndex.status.Creator.NickName}}</div>
</div>
<div class="detail-index">
<div class="title" style="color: #999">分类:</div>
<div class="detail"
v-if="activeIndex.ArchiveIds && subActiveIndex.ArchiveIds"
:class="{active: !getIsSameCategory(activeIndex, subActiveIndex)}">
<div v-for="item in getIndexCategorys(activeIndex.ArchiveIds, publicCategoryOptions)">
{{item}}
</div>
</div>
</div>
<div class="detail-index">
<div class="title" style="color: #999">智能词方向:</div>
<div class="detail">
<div class="sub-detail"
v-if="activeIndex.Direction"
:class="{active: activeIndex.Direction !== subActiveIndex.Direction}">
<span>{{deirectionObj[activeIndex.Direction.toString()]}}</span>
</div>
</div>
</div>
<div class="detail-index">
<div class="title" style="color: #999">智能词百科:</div>
<div class="detail">
<div class="sub-detail"
:class="{active: activeIndex.Wiki !== subActiveIndex.Wiki}">
<span>{{activeIndex.Wiki?activeIndex.Wiki:'-'}}</span>
</div>
</div>
</div>
<div class="detail-index">
<div class="title" style="color: #999">智能词算法:</div>
<div class="detail">
<div v-for="(item,index) in mainActiveWordConditions"
class="calculater-words-box" :id="'mainConditionBox' + index"
v-html="item.showDom">
</div>
</div>
</div>
</div>
<div class="detail-container" style="padding-top:0; font-size: 13px;">
<div class="detail-index">
<h3>修改数据</h3>
</div>
<div class="detail-index">
<div class="title" style="color: #999">智能词名称:</div>
<div class="detail"
:class="{active: activeIndex.IndexName !== subActiveIndex.IndexName}">
{{subActiveIndex.Name}}
</div>
</div>
<div class="detail-index">
<div class="title" style="color: #999">智能词创建人:</div>
<div class="detail" v-if="activeIndex.status">{{activeIndex.status.Creator.NickName}}</div>
</div>
<div class="detail-index">
<div class="title" style="color: #999">分类:</div>
<div class="detail">
<div v-for="item in getIndexCategorys(subActiveIndex.ArchiveIds, publicCategoryOptions)">
{{item}}
</div>
</div>
</div>
<div class="detail-index">
<div class="title" style="color: #999">智能词方向:</div>
<div class="detail">
<div class="sub-detail">
<span v-if="subActiveIndex.Direction">{{deirectionObj[subActiveIndex.Direction.toString()]}}</span>
</div>
</div>
</div>
<div class="detail-index">
<div class="title" style="color: #999">智能词百科:</div>
<div class="detail">
<div class="sub-detail">
<span>{{subActiveIndex.Wiki?subActiveIndex.Wiki:'-'}}</span>
</div>
</div>
</div>
<div class="detail-index">
<div class="title" style="color: #999">智能词算法:</div>
<div class="detail">
<div v-for="(item,index) in subActiveWordConditions"
class="calculater-words-box" :id="'subConditionBox' + index"
v-html="item.showDom">
</div>
</div>
</div>
<div class="detail-index" v-if="activeIndex.WdPublicSmartWordWorkflows">
<div class="title" style="color: #999">备注:</div>
<div class="detail">
<span>{{activeIndex.WdPublicSmartWordWorkflows[activeIndex.WdPublicSmartWordWorkflows.length - 1].Remark}}</span>
</div>
</div>
</div>
</div>
</el-dialog>
<el-dialog title="智能词详情" :visible.sync="showEditWikiDetail" width="800px">
<div class="detail-container" style="padding-top:0; font-size: 13px">
<div class="detail-index" v-if="activeIndex.status && activeIndex.status.PreData">
<div class="title" style="color: #999">原百科:</div>
<div class="detail">{{activeIndex.status.PreData.Object.Wiki}}</div>
</div>
<div class="detail-index">
<div class="title" style="color: #999">修改百科:</div>
<div class="detail">{{activeIndex.Wiki}}</div>
</div>
</div>
</el-dialog>
<el-dialog title="测试运行指标"
:close-on-press-escape="false"
:close-on-click-modal="false"
:visible.sync="testRunVisible"
width="800px">
<div class="test-run-box">
<div class="detail-index">
<div class="title">当前指标:</div>
<div class="detail">
<span>{{activeIndex.IndexName}}</span>
</div>
</div>
<!-- <condition style="padding: 20px 0" ref="conditionChoose" :params="activeIndex.Args" :allParams="defaultTypeList" /> -->
<div class="detail-index" style="align-items: flex-start">
<div class="title">标的选择:</div>
<div class="detail" style="color: #333">
<div class="flex-form-cintent">
<div style="margin-bottom: 20px">
<el-checkbox
:indeterminate="companyStatusCheck.isIndeterminate"
v-model="companyStatusCheck.checkAll"
@change="handleCheckAllChange($event, companyStatusCheck)"
>全选</el-checkbox>
<el-checkbox-group
v-model="companyStatusCheck.checkedItems"
@change="handleCheckedResults($event, companyStatusCheck)"
>
<el-checkbox
v-for="item in companyStatusData"
:value="item['F90063V']"
:label="item['F90063V']"
:key="item['F90063V']"
>{{item['F90064V']}}</el-checkbox>
</el-checkbox-group>
</div>
<div class="flex-form-detail no-bg">
<el-tabs
v-model="activeRangeTab"
class="mini-size"
style="margin-bottom: 12px"
type="card"
>
<el-tab-pane label="单个添加" :name="'3'">
<div>
<el-select
v-model="rangeCompany"
filterable
remote
@change="addRangeCompany"
placeholder="请输入名称或代码"
:remote-method="searchRunningCompany"
:loading="searchCompanyLoading"
size="mini"
>
<el-option
v-for="item in runningCompanyList"
:key="item.F90001V"
:label="item.F90002V + ' ' + item.F90001V"
:value="item.F90002V + ',' + item.F90001V"
></el-option>
</el-select>
</div>
</el-tab-pane>
<el-tab-pane label="excel导入" :name="'6'">
<div
style="padding-bottom: 8px; color: #999; font-size: 12px"
>excel格式:表为两列, 表头必须为字符"name"、"code", 表身对应为证券简称、证券代码</div>
<div>
<input type="file" @change="selectedExcel" />
</div>
<div style="padding-top: 12px">
<span style="color: #d0021b; font-size: 12px; cursor: pointer" @click="downloadExample">下载示例表格</span>
</div>
</el-tab-pane>
<!-- <el-tab-pane label="证监会行业" :name="'1'">
<div class="mini-size industry-tree-box">
<el-tree
:indent="8"
accordion
:expand-on-click-node="false"
@node-click="searchCompanyByIndustry($event, 1)"
:data="zjhIndustryData"
node-key="id"
ref="zjhCategory"
highlight-current
></el-tree>
</div>
</el-tab-pane> -->
<el-tab-pane label="行业分类" :name="'2'">
<div class="mini-size industry-tree-box">
<el-tree
:indent="8"
accordion
:expand-on-click-node="false"
@node-click="searchCompanyByIndustry($event, 1)"
:data="zjhIndustryData"
node-key="id"
ref="zjhCategory"
></el-tree>
<el-tree
:indent="8"
accordion
:expand-on-click-node="false"
@node-click="searchCompanyByIndustry($event, 2)"
:data="swIndustryData"
node-key="id"
ref="swCategory"
></el-tree>
</div>
</el-tab-pane>
<el-tab-pane label="市场分类" :name="'5'">
<div class="mini-size industry-tree-box">
<el-tree
:indent="8"
accordion
:data="marketData"
highlight-current
ref="marketCategory"
:expand-on-click-node="false"
@node-click="searchCompanyByIndustry($event, 3)"
></el-tree>
</div>
</el-tab-pane>
<el-tab-pane label="地域分类" :name="'4'">
<div class="mini-size industry-tree-box">
<el-tree
:indent="8"
accordion
:data="positionData"
highlight-current
ref="posCategory"
:expand-on-click-node="false"
@node-click="searchCompanyByIndustry($event, 4)"
></el-tree>
</div>
</el-tab-pane>
</el-tabs>
<el-table
@sort-change="changeSort"
size="mini"
max-height="300"
v-loading="searchCompanyLoading"
:data="selectedRangeCompany"
:header-cell-style="{background:'#f5f7fa',color:'#666'}"
border
>
<el-table-column width="50" type="index" label="序号"></el-table-column>
<el-table-column width="80" label="证券名称">
<template slot-scope="scope">{{scope.row.name}}</template>
</el-table-column>
<el-table-column width="80" label="证券代码">
<template slot-scope="scope">{{scope.row.code}}</template>
</el-table-column>
<el-table-column prop="result" sortable label="运行结果">
<template slot-scope="scope">{{scope.row.result}}</template>
</el-table-column>
<el-table-column width="80" label="操作">
<template slot-scope="scope">
<span
class="hover-icon el-icon-delete"
@click="selectedRangeCompany.splice(scope.$index, 1)"
>
删除
</span>
</template>
</el-table-column>
</el-table>
<div style="font-size: 12px; margin-top: 8px; color: #d0021b">
<span
class="el-icon-refresh-right"
style="cursor: pointer"
@click="selectedRangeCompany = []"
>清空表格</span>
<span
class="el-icon-upload2"
style="cursor: pointer; margin-left: 12px"
@click="exportExcel"
>导出excel</span>
</div>
</div>
</div>
</div>
</div>
<div class="detail-index">
<div class="title">操作:</div>
<div class="detail">
<el-button type="primary" size="mini" @click="testRunIndex">点击运行</el-button>
</div>
</div>
</div>
</el-dialog>
<el-dialog title="智能词测试"
:visible.sync="testSingleVisible"
width="1000px">
<div class="run-dialog">
<div class="flex-dialog-right">
<div class="form-item">
<div class="title">当前智能词:</div>
<div class="detail">
<span class="selected-words">{{activeIndex.Name}}</span>
</div>
</div>
<indexCondition style="padding: 20px 0" ref="conditionChoose" :params="7" :allParams="[]" />
<div class="form-item">
<div class="title">选择标的:</div>
<div class="detail">
<companySelector ref="companySelector" />
</div>
</div>
<div class="form-item">
<div class="title">运行结果:</div>
<div class="detail">
<div class="detail-condition">
<span class="title">风控方向:</span>
<el-radio-group v-model="testDirection">
<el-radio :label="null">全部</el-radio>
<el-radio :label="-1">负面</el-radio>
<el-radio :label="0">中性</el-radio>
<el-radio :label="1">正面</el-radio>
</el-radio-group>
</div>
<div class="detail-condition">
<span class="title">风控等级:</span>
<el-input size="mini" style="width: 120px" placeholder="最小等级" v-model="testMinRiskLevel"></el-input>
<span> - </span>
<el-input size="mini" style="width: 120px" placeholder="最大等级" v-model="testMaxRiskLevel"></el-input>
</div>
<div class="detail-condition">
<span class="title">风控强度:</span>
<el-input size="mini" style="width: 120px" placeholder="最小等级" v-model="testMinRiskStrong"></el-input>
<span> - </span>
<el-input size="mini" style="width: 120px" placeholder="最大等级" v-model="testMaxRiskStrong"></el-input>
</div>
<el-table
size="mini"
style="width:600px; margin-top: 12px"
max-height="300"
v-loading="runSingleTableLoading"
:data="runSingleTableData"
:header-cell-style="{background:'#f5f7fa',color:'#666'}"
border>
<el-table-column width="50" type="index" label="序号"></el-table-column>
<el-table-column width="100">
<template slot="header" slot-scope="scope">
<span>证券名称</span>
</template>
<template slot-scope="scope">{{scope.row.name}}</template>
</el-table-column>
<el-table-column width="100">
<template slot="header" slot-scope="scope">
<span>证券代码</span>
</template>
<template slot-scope="scope">{{scope.row.code}}</template>
</el-table-column>
<el-table-column>
<template slot="header" slot-scope="scope">
<span>结果</span>
</template>
<template slot-scope="scope">{{getRunningResult(scope.row.value)}}</template>
</el-table-column>
</el-table>
<div style="font-size: 12px; margin-top: 8px; color: #d0021b">
<span
class="el-icon-upload2"
style="cursor: pointer;"
@click="exportExcel"
>导出excel</span>
</div>
</div>
</div>
<div class="form-item">
<div class="title">操作:</div>
<div class="detail">
<el-button size="mini" type="primary" :loading="runLoading" @click="confirmRunWords">点击运行</el-button>
</div>
</div>
</div>
</div>
</el-dialog>
</div>
</template>
\ No newline at end of file
#app{
width: 100%;
height: 100%;
display: block;
}
.header-router{
background: #fff;
width: 100%;
box-sizing: border-box;
padding: 16px 20px;
display: flex;
align-items: center;
border-bottom: 1px solid #eaeaea;
}
.parent-name{
font-size: 16px;
font-weight: bold;
margin-right: 32px;
}
.router-list{
flex: auto;
}
.router-list span{
padding: 0 12px;
font-size: 14px;
cursor: pointer;
}
.router-list span:hover{
color: #d0021b;
}
.router-list span+span{
border-left: 1px solid #eaeaea;
}
span.active-link{
color: #d0021b;
}
.header-search{
background: #fff;
padding: 12px 0;
box-sizing: border-box;
padding: 0 20px;
height: 62px;
box-sizing: border-box;
display: flex;
flex-direction: column;
justify-content: center;
align-items: start;
}
.header-search-inner{
display: inline-block;
width: 560px;
}
.container{
height: 100%;
display: flex;
flex-direction: column;
}
.container .header{
min-height: 117px;
background: #fff;
}
.header-container{
height: 117px;
overflow: hidden;
}
.main-body{
height: calc(100% - 139px);
margin-top: 12px;
background: #fff;
padding: 16px;
box-sizing: border-box;
display: flex;
flex: auto;
}
.header-search-box{
width: 50%;
margin: 0 auto;
background: #f1f1f1;
line-height: 36px;
padding: 0 12px;
box-sizing: border-box;
}
.header-search-box .icon{
font-size: 14px;
}
.header-search-box input{
border: 0;
outline: 0;
background: #f1f1f1;
line-height: 36px;
font-size: 14px;
width: calc(100% - 20px);
box-sizing: border-box;
}
.header-search-box input:focus{
outline: 0;
}
.words-list{
min-width: 320px;
border-right: 1px solid #eaeaea;
padding-right: 12px;
box-sizing: border-box;
}
.words-detail{
padding-left: 20px;
flex: auto;
}
.body-title{
font-size: 14px;
font-weight: bold;
min-height: 20px;
padding-bottom: 12px;
position: relative;
}
.words-list, .words-detail{
display: flex;
flex-direction: column;
}
.words-list-inner{
flex: auto;
overflow: scroll;
}
.words-detail-inner{
flex: auto;
overflow: scroll;
/* padding: 12px 0; */
margin-top: 24px;
padding-bottom: 20px;
}
.body-title.border{
border-bottom: 1px solid #eaeaea;
}
.body-title.no-margin{
margin-bottom: 0;
}
.form-item{
display: flex;
}
.form-item.center{
align-items: center;
}
.form-item+.form-item{
margin-top: 20px;
}
.form-item .title{
min-width: 104px;
color: #999;
text-align: left;
margin-right: 12px;
font-size: 13px;
}
.form-item .detail{
flex: auto;
}
.action-list span{
padding: 0 10px;
cursor: pointer;
}
.action-list span:hover{
color: #d0021b;
}
.action-list span+span{
border-left: 1px solid #eaeaea;
}
.condition-list{
border: 1px solid #eaeaea;
border-radius: 4px;
padding: 8px 12px;
width: 636px;
position: relative;
}
.condition-list+.condition-list{
margin-top: 20px;
}
.action-list{
/* border-bottom: 1px solid #eaeaea; */
padding: 12px 0;
background: #f9f9f9;
margin-top: 12px;
border-radius: 4px;
}
.my-slider{
display: inline-block;
flex: auto;
margin-left: 12px;
}
.condition-detail-list{
display: flex;
align-items: center;
}
.my-slider .el-slider__runway{
margin: 12px 0;
}
.my-slider .el-slider__button{
width: 12px;
height: 12px;
}
.condition-detail{
margin-top: 12px;
border-top: 1px solid #eaeaea;
padding-top: 12px;
}
.form-item .detail img{
width: 636px;
height: auto;
border-radius: 4px;
}
.chart-condition{
padding: 8px 0;
}
.words-list-search{
margin-bottom: 12px;
}
.hover-icon{
cursor: pointer;
}
.hover-icon:hover{
color: #d0021b;
}
.hover-icon.red{
color: #d0021b;
}
.slide-fade-enter-active {
transition: all .3s ease;
}
.slide-fade-leave-active {
transition: all .1s cubic-bezier(1.0, 0.5, 0.8, 1.0);
}
.slide-fade-enter, .slide-fade-leave-to
/* .slide-fade-leave-active for below version 2.1.8 */ {
transform: translateX(50px);
opacity: 0;
}
.close-btn{
position: absolute;
background: #fff;
right: -10px;
top: -10px;
font-size: 20px;
}
.complex-condition .cal-index-detail{
min-width: 220px;
max-width: 220px;
height: 442px;
}
.condition-action{
/* background: rgb(245, 247, 250); */
padding: 6px 12px;
border-radius: 4px;
}
.simple-condition-box{
border: 1px solid #eaeaea;
padding: 0 12px;
}
.complex-condition-showDom{
padding: 12px;
border: 1px solid #eaeaea;
box-sizing: border-box;
background: rgb(245, 247, 250);
}
.back-btn{
position: absolute;
top: -6px;
right: 0;
}
.inline-block{
display: inline-block;
}
.condition-detail-list .inline-block+.inline-block{
margin-left: 20px;
}
.gray{
color: #999;
}
.run-dialog .title{
text-align: right;
}
.run-dialog{
display: flex;
}
.flex-dialog-left{
min-width: 200px;
padding-right:12px;
border-right: 1px solid #eaeaea;
overflow: scroll;
}
.flex-dialog-right{
flex: auto;
padding-left:12px;
}
.selected-words{
font-size: 13px;
color: #333;
font-weight: bold;
}
.calculater-keybord{
width: 400px;
}
.empty-status{
min-height: 400px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.empty-status img{
width: 130px;
height: auto;
margin-bottom: 10px;
}
.empty-status .empty-tip{
font-size: 14px;
color: #999;
}
.detail-condition{
font-size: 12px;
}
.detail-condition+.detail-condition{
margin-top: 12px;
}
.detail-condition .title{
color: #999;
}
.table-condition{
margin-bottom: 20px;
}
.el-link{
font-size: 12px;
}
.el-link.el-link--default{
color: #d0021b;
}
.calculater-words-box{
border: 1px solid #eaeaea;
padding: 12px;
}
.detail.active{
background: #ffe7ea;
padding: 6px 12px;
}
\ No newline at end of file
var init = require('../../lib/init.js')
var value = init(__filename, __dirname)
module.exports[value.name] = {
data: function () {
return {
tableData: [],
pageTotal: 0,
pageCurrent: 1,
psize: 15,
tableLoading: true,
searchName: '',
recordType: 1,
isWordsDot: false,
IntervalId: 0,
wordsPermission: false
}
},
components: {},
template: value.template,
mounted () {
this.checkPermission(53, 'wordsPermission')
this.getSortBadge()
this.IntervalId = setInterval(() => {
this.getSortBadge()
}, 30000)
this.currentAccount = store.get('accountId')
this.getIndexData()
},
beforeDestroy(){
clearInterval(this.IntervalId)
},
methods: {
checkPermission (id, key) {
return new Promise((resolve, reject) => {
http.netPost('Account/Account/CheckPermission', {
"id": id,
"AccountId": store.get('accountId')
})
.then((res) => {
if (res.data.Status == 1) {
if(res.data.Data == 1){
this[key] = true
}
resolve()
}
})
})
},
getSortBadge () {
return new Promise((resolve) => {
http.netPost('Data/SmartWord/GetTodoSmartWordCount', {
"AccountId": store.get('accountId')
})
.then((res) => {
if (res.data.Status == 1) {
if(res.data.Data > 0){
this.isWordsDot = true
}else{
this.isWordsDot = false
}
resolve(res)
}
})
})
},
getIndexData () {
this.tableLoading = true
return new Promise((resolve, reject) => {
http.netPost('Data/SmartWord/GetSmartWordStatusChanges', {
"logOptions": this.recordType,
"Current": (this.pageCurrent - 1) * this.psize,
"Psize": this.psize,
"name": this.searchName,
"AccountId": store.get('accountId')
})
.then((res) => {
if (res.data.Status == 1) {
this.tableData = res.data.Data.Records
this.pageTotal = res.data.Data.Total
}
this.tableLoading = false
})
})
},
pagClick (page) {
this.pageCurrent = page
this.getIndexData()
},
changeType () {
this.searchName = ''
this.pagClick(1)
}
}
}
<template>
<div class="container">
<div class="header shadow">
<div class="header-router">
<div class="parent-name">智能词管理</div>
<div class="router-list" style="display: flex">
<router-link tag="span" active-class="active-link" exact to="/">我的智能词</router-link>
<router-link tag="span" active-class="active-link" exact to="/publicWords">公共智能词</router-link>
<el-badge :is-dot="isWordsDot && wordsPermission" class="item">
<router-link tag="span" active-class="active-link" exact to="/wordsAudit">智能词审核</router-link>
</el-badge >
<router-link tag="span" style="flex: auto; text-align: right;border-left: 0" active-class="active-link" exact to="/wordsRecord">
<span class="el-icon-date"> 指标修改日志</span>
</router-link>
</div>
</div>
<div class="header-search">
<div style="margin-top: 12px; padding-bottom: 12px">
<span style="color: #999">日志类型:</span>
<el-radio-group v-model="recordType" @change="changeType">
<el-radio :label="1">智能词修改</el-radio>
<!-- <el-radio :label="2">排序调整</el-radio> -->
</el-radio-group>
<span style="color: #999; margin-left: 20px">名称搜索:</span>
<el-input style="width: 240px" @keyup.enter.native="pagClick(1)" clearable v-model="searchName" size="mini" placeholder="请输入姓名查询相关日志"></el-input>
<el-button size="mini" style="margin-left: 12px" @click="pagClick(1)" type="primary">搜索</el-button>
</div>
</div>
</div>
<div class="main-body" style="display: block; margin-top:0; padding-top: 0">
<div class="table-box">
<div>
<el-table
size="mini"
v-loading="tableLoading"
:data="tableData"
:header-cell-style="{background:'#f5f7fa',color:'#666'}"
border>
<el-table-column label="序号" width="60" type="index"></el-table-column>
<el-table-column prop="CreateDate" width="160" label="创建时间"></el-table-column>
<el-table-column prop="StatusChangeMsg" label="详情"></el-table-column>
<el-table-column prop="Remark" label="操作备注"></el-table-column>
</el-table>
<div class="pagination-container">
<el-pagination
layout="prev, pager, next"
:current-page="pageCurrent"
@current-change="pagClick"
:page-size="psize"
:total="pageTotal"
></el-pagination>
</div>
</div>
</div>
</div>
</div>
</template>
\ No newline at end of file
#app{
width: 100%;
height: 100%;
display: block;
}
.header-router{
background: #fff;
width: 100%;
box-sizing: border-box;
padding: 16px 20px;
display: flex;
align-items: center;
border-bottom: 1px solid #eaeaea;
}
.parent-name{
font-size: 16px;
font-weight: bold;
margin-right: 32px;
}
.router-list{
flex: auto;
}
.router-list span{
padding: 0 12px;
font-size: 14px;
cursor: pointer;
}
.router-list span:hover{
color: #d0021b;
}
.router-list span+span{
border-left: 1px solid #eaeaea;
}
span.active-link{
color: #d0021b;
}
.header-search{
background: #fff;
padding: 12px 0;
box-sizing: border-box;
padding: 0 20px;
height: 62px;
box-sizing: border-box;
display: flex;
flex-direction: column;
justify-content: center;
align-items: start;
}
.header-search-inner{
display: inline-block;
width: 560px;
}
.container{
height: 100%;
display: flex;
flex-direction: column;
}
.container .header{
min-height: 117px;
background: #fff;
}
.header-container{
height: 117px;
overflow: hidden;
}
.main-body{
height: calc(100% - 139px);
margin-top: 12px;
background: #fff;
padding: 16px;
box-sizing: border-box;
display: flex;
flex: auto;
}
.header-search-box{
width: 50%;
margin: 0 auto;
background: #f1f1f1;
line-height: 36px;
padding: 0 12px;
box-sizing: border-box;
}
.header-search-box .icon{
font-size: 14px;
}
.header-search-box input{
border: 0;
outline: 0;
background: #f1f1f1;
line-height: 36px;
font-size: 14px;
width: calc(100% - 20px);
box-sizing: border-box;
}
.header-search-box input:focus{
outline: 0;
}
.words-list{
min-width: 320px;
border-right: 1px solid #eaeaea;
padding-right: 12px;
box-sizing: border-box;
}
.words-detail{
padding-left: 20px;
flex: auto;
}
.body-title{
font-size: 14px;
font-weight: bold;
min-height: 20px;
padding-bottom: 12px;
position: relative;
}
.words-list, .words-detail{
display: flex;
flex-direction: column;
}
.words-list-inner{
flex: auto;
overflow: scroll;
}
.words-detail-inner{
flex: auto;
overflow: scroll;
/* padding: 12px 0; */
margin-top: 24px;
padding-bottom: 20px;
}
.body-title.border{
border-bottom: 1px solid #eaeaea;
}
.body-title.no-margin{
margin-bottom: 0;
}
.form-item{
display: flex;
}
.form-item.center{
align-items: center;
}
.form-item+.form-item{
margin-top: 20px;
}
.form-item .title{
min-width: 104px;
color: #999;
text-align: left;
margin-right: 12px;
font-size: 13px;
}
.form-item .detail{
flex: auto;
}
.action-list span{
padding: 0 10px;
cursor: pointer;
}
.action-list span:hover{
color: #d0021b;
}
.action-list span+span{
border-left: 1px solid #eaeaea;
}
.condition-list{
border: 1px solid #eaeaea;
border-radius: 4px;
padding: 8px 12px;
width: 636px;
position: relative;
}
.condition-list+.condition-list{
margin-top: 20px;
}
.action-list{
/* border-bottom: 1px solid #eaeaea; */
padding: 12px 0;
background: #f9f9f9;
margin-top: 12px;
border-radius: 4px;
}
.my-slider{
display: inline-block;
flex: auto;
margin-left: 12px;
}
.condition-detail-list{
display: flex;
align-items: center;
}
.my-slider .el-slider__runway{
margin: 12px 0;
}
.my-slider .el-slider__button{
width: 12px;
height: 12px;
}
.condition-detail{
margin-top: 12px;
border-top: 1px solid #eaeaea;
padding-top: 12px;
}
.form-item .detail img{
width: 636px;
height: auto;
border-radius: 4px;
}
.chart-condition{
padding: 8px 0;
}
.words-list-search{
margin-bottom: 12px;
}
.hover-icon{
cursor: pointer;
}
.hover-icon:hover{
color: #d0021b;
}
.hover-icon.red{
color: #d0021b;
}
.slide-fade-enter-active {
transition: all .3s ease;
}
.slide-fade-leave-active {
transition: all .1s cubic-bezier(1.0, 0.5, 0.8, 1.0);
}
.slide-fade-enter, .slide-fade-leave-to
/* .slide-fade-leave-active for below version 2.1.8 */ {
transform: translateX(50px);
opacity: 0;
}
.close-btn{
position: absolute;
background: #fff;
right: -10px;
top: -10px;
font-size: 20px;
}
.complex-condition .cal-index-detail{
min-width: 220px;
max-width: 220px;
height: 442px;
}
.condition-action{
/* background: rgb(245, 247, 250); */
padding: 6px 12px;
border-radius: 4px;
}
.simple-condition-box{
border: 1px solid #eaeaea;
padding: 0 12px;
}
.complex-condition-showDom{
padding: 12px;
border: 1px solid #eaeaea;
box-sizing: border-box;
background: rgb(245, 247, 250);
}
.back-btn{
position: absolute;
top: -6px;
right: 0;
}
.inline-block{
display: inline-block;
}
.condition-detail-list .inline-block+.inline-block{
margin-left: 20px;
}
.gray{
color: #999;
}
.run-dialog .title{
text-align: right;
}
.run-dialog{
display: flex;
}
.flex-dialog-left{
min-width: 200px;
padding-right:12px;
border-right: 1px solid #eaeaea;
overflow: scroll;
}
.flex-dialog-right{
flex: auto;
padding-left:12px;
}
.selected-words{
font-size: 13px;
color: #333;
font-weight: bold;
}
.calculater-keybord{
width: 400px;
}
.empty-status{
min-height: 400px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.empty-status img{
width: 130px;
height: auto;
margin-bottom: 10px;
}
.empty-status .empty-tip{
font-size: 14px;
color: #999;
}
.detail-condition{
font-size: 12px;
}
.detail-condition+.detail-condition{
margin-top: 12px;
}
.detail-condition .title{
color: #999;
}
.my-radio .el-radio-button--mini .el-radio-button__inner{
font-size: 12px;
padding: 4px;
}
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="../../../static/plTable/index.css">
<link rel="stylesheet" href="../../../static/element/theme/index.css">
<link rel="stylesheet" href="../../../static/global/global.css">
<body>
<div id="app" v-cloak>
<router-view></router-view>
</div>
</body>
<script>
const { app } = require('electron').remote
const { ipcRenderer } = require('electron')
window.global.urls = require(app.getAppPath() + '/build_config/url')
</script>
<script src="../../../static/vue/vue.min.js"></script>
<script src="../../../static/element/index.js"></script>
<script src="../../../static/vue-router/vue-router.js"></script>
<script src='../../../static/xlsx/xlsx.full.min.js'></script>
<script src="../../../static/plTable/index.js"></script>
<script src="../../../assist/loadVue.js"></script>
<script src="./routers/customWords/index.js"></script>
<script src="../../../assist/axios.js"></script>
<script src="./smartWords.js"></script>
<script>
var http = newHttp()
const mytools = new tools()
var info = JSON.parse(localStorage.getItem('userInfo'))
const { splitPane } = require('vue-splitpane')
Vue.component('split-pane', splitPane)
async function init() {
var customWords = await getCustomWords()
// var indexAudit = await getIndexAudit()
// var publicIndex = await getPublicIndex()
// var categoryAudit = await getCategoryAudit()
// var indexRecord = await getIndexRecord()
var routes = [
{ path: '/', component: customWords },
// { path: '/indexAudit', component: indexAudit },
// { path: '/publicIndex', component: publicIndex },
// { path: '/categoryAudit', component: categoryAudit },
// { path: '/indexRecord', component: indexRecord }
]
var router = new VueRouter({ routes })
new Vue({
router,
el: '#app',
data: function () {
return {
}
},
mounted() {
},
methods: {
}
})
}
init()
</script>
</html>
\ No newline at end of file
class tools {
constructor() { }
getKeyboardObj(keyBord, keyboardObj) {
var arr = keyBord.keybordData
arr.forEach(item => {
item.forEach(sub => {
if (sub.type == 5) {
keyboardObj[sub.funcId] = sub
}
})
})
}
getIndexs(initIndexObj) {
return new Promise((resolve, reject) => {
http.netPost('Data/Encode/GetEncodeList', {
"Current": 0,
"Psize": 100,
"Code": "B",
'Name': '',
"AccountId": store.get('accountId')
})
.then((res) => {
if (res.data.Status == 1) {
this.creatIndexObj(res.data.Data.Records, initIndexObj)
resolve()
}
})
})
}
creatIndexObj(initData, initIndexObj) {
initData.forEach(element => {
if (element.Sub.length > 0) {
this.creatIndexObj(element.Sub, initIndexObj)
} else {
initIndexObj[element.Code] = element
var tableName = element.Origin ? element.Origin.TableComment : null
var dbName = element.Origin ? element.Origin.DbComment : null
initIndexObj[element.Code].originText = tableName + '-' + dbName
}
})
}
getUsedCompany(params, companyNameObj) {
var codes = []
params.forEach(item => {
if (item.OperandType == 0 && item.Where[2]) {
codes.push(item.Where[2].Value)
} else if (item.OperandType == 4) {
item.Args.forEach(sub => {
sub.forEach(child => {
if (child.OperandType == 0 && child.Where[2]) {
codes.push(child.Where[2].Value)
}
})
})
}
})
var where = [{
"Encode": "F90001V",
"State": 7,
"Value": codes.join(','),
}]
return new Promise((resolve, reject) => {
http.netPost('Data/Query/Query', {
"List": ['F90001V', 'F90002V'],
"Where": where,
"Current": 0,
"Psize": 100
})
.then((res) => {
if (res.data.Status == 1) {
res.data.Data.Records.forEach(item => {
companyNameObj[item.F90001V] = item.F90002V
})
resolve()
} else if (res.data.Status == 0) {
resolve()
} else {
reject()
}
})
})
}
getSaveCondition(activeIndexCondition, condition, initIndex, initIndexObj, companyNameObj, keyboardObj) {
condition.forEach(item => {
initIndex++
var id = new Date().getTime() + initIndex
var obj = {}
var inputDom = ''
var showDom = ''
var paramsType = ''
switch (item.OperandType) {
case 0: //指标
var index = initIndexObj[item.List[0]]
var condition = this.getIndexType(index)
var evalObj = this.getEval(item.Where[0])
obj = {
code: item.List[0],
id: id,
inputQuarter: evalObj.selsetQuarter,
inputYear: evalObj.selectYear,
q: evalObj.qQuarter,
t: evalObj.tYear,
quarterType: evalObj.reportQuarterType,
yearType: evalObj.reportYearType,
mergeType: item.Where[1].Value,
type: 1,
isAppointCompany: item.Where[2] ? true : false,
selectedCompany: item.Where[2] ? (companyNameObj[item.Where[2].Value] + '-' + item.Where[2].Value) : '',
mark: index.Mark,
name: index.Name,
needMergeType: condition.needMergeType,
needReportData: condition.needReportData,
needCompany: condition.needCompany,
typeContent: index.TypeContent || []
}
var text = this.getFullIndexName(obj)
var width = this.getInputLength(text) + 'px'
inputDom = '<input readonly class="cal-index" type="1" id="' + id + '" style="width:' + width + '" value="' + text + '" />'
showDom = '<span type="1">' + text + '</span>'
paramsType = 'indexParams'
break;
case 1: //符号
obj = {
id: id,
key: item.Value,
type: 4,
value: item.Value
}
var width = this.getInputLength(item.Value) + 'px'
var moreClass = ''
switch (item.Value) {
case '(': case ')':
moreClass = 'brackets'
break;
default:
break;
}
inputDom = '<input readonly class="cal-index ' + moreClass + '" type="4" id="' + id + '" style="width:' + width + '" value="' + item.Value + '" />'
showDom = '<span type="4">' + item.Value + '</span>'
paramsType = 'symbolParams'
break;
case 2: //数字
obj = {
id: id,
type: 3,
value: item.Value
}
var text = item.Value + "[" + this.getFormatValue(item.Value) + "]"
var width = this.getInputLength(text) + 'px'
inputDom = '<input readonly class="cal-index" type="3" id="' + id + '" style="width:' + width + '" value="' + text + '" />'
showDom = '<span type="3">' + text + '</span>'
paramsType = 'numParams'
break;
case 3: //时间
obj = {
id: id,
type: 2,
value: item.Value
}
var text = item.Value
var width = this.getInputLength(text) + 'px'
inputDom = '<input readonly class="cal-index" type="2" id="' + id + '" style="width:' + width + '" value="' + text + '" />'
showDom = '<span type="2">' + text + '</span>'
paramsType = 'dateParams'
break;
case 4:
var origin = keyboardObj[item.Action]
obj = {
value: origin.key,
key: origin.key,
type: 5,
id: id,
originParams: JSON.parse(JSON.stringify(origin)),
paramsValue: []
}
item.Args.forEach((sub, index) => {
if (index > origin.length) {
obj.originParams.params.push(JSON.parse(JSON.stringify(obj.originParams.params[0])))
}
obj.paramsValue[index] = {
indexParams: {},
dateParams: {},
numParams: {},
symbolParams: {},
functionParams: {},
dom: '',
showDom: ''
}
initIndex++
this.getSaveCondition(obj.paramsValue[index], item.Args[index], initIndex, initIndexObj, companyNameObj, keyboardObj)
})
// origin.params.forEach((item,index) => {
// this.getFuncCondition(obj.paramsValue[index], item.Args[index])
// })
var arr = []
obj.paramsValue.forEach(item => {
var text = this.getShowDomText(item.showDom)
arr.push(text)
})
var name = obj.key.replace('( )', '')
var value = name + '(' + arr.join(', ') + ')'
var text = value
var width = this.getInputLength(text) + 'px'
inputDom = '<input readonly class="cal-index" type="5" id="' + id + '" style="width:' + width + '" value="' + text + '" />'
showDom = '<span type="5">' + text + '</span>'
paramsType = 'functionParams'
break;
default:
break;
}
activeIndexCondition[paramsType][id] = obj
activeIndexCondition.dom += inputDom
activeIndexCondition.showDom += showDom
})
if (!activeIndexCondition.showDom) {
activeIndexCondition.showDom = '<span>暂未设置计算公式</span>'
}
}
getIndexType(obj) {
var newObj = {
needMergeType: false,
needReportData: false,
needCompany: false
}
if (obj.TypeContent) {
obj.TypeContent.Parameters.forEach(item => {
if (item.Encode == 'F91997V') {
newObj.needMergeType = true
}
if (item.Encode == 'F91996D') {
newObj.needReportData = true
}
if (item.Encode == 'F90001V') {
newObj.needCompany = true
}
})
}
return newObj
}
getEval(item) {
var newObj = {
reportYearType: 1,
tYear: 0,
selectYear: '',
reportQuarterType: 1,
qQuarter: 0,
selsetQuarter: ''
}
switch (item.Eval.length) {
case 0:
newObj.reportYearType = 2
newObj.selectYear = item.Value.slice(0, 4)
newObj.reportQuarterType = 2
newObj.qQuarter = 0
newObj.tYear = 0
newObj.selsetQuarter = item.Value.slice(5, 10)
break;
case 1:
if (item.Eval[0].EvalOption == 1) { //年度为t
newObj.reportYearType = 1
newObj.tYear = item.Eval[0].Value
newObj.selectYear = item.Value.slice(0, 4)
newObj.reportQuarterType = 2
newObj.qQuarter = 0
newObj.selsetQuarter = item.Value.slice(5, 10)
} else if (item.Eval[0].EvalOption == 2) {
newObj.reportYearType = 2
newObj.tYear = 0
newObj.selectYear = item.Value.slice(0, 4)
newObj.reportQuarterType = 1
newObj.qQuarter = item.Eval[0].Value
newObj.selsetQuarter = item.Value.slice(5, 10)
}
break;
case 2:
newObj.reportYearType = 1
newObj.selectYear = ''
newObj.reportQuarterType = 1
newObj.selsetQuarter = ''
newObj.qQuarter = item.Eval[1].Value
newObj.tYear = item.Eval[0].Value
break;
default:
break;
}
return newObj
}
getFullIndexName(index) {
var indexName = index.name, merge = '', company = '', year = '', quarter = ''
if (index.needMergeType) {
merge = '[' + index.mergeType + ']'
}
if (index.needReportData) {
if (index.yearType == 1) {
year = '[T:' + index.t + ']'
} else {
year = '[T:' + index.inputYear + ']'
}
if (index.quarterType == 1) {
quarter = '[Q:' + index.q + ']'
} else {
quarter = '[Q:' + index.inputQuarter + ']'
}
}
if (index.needCompany && index.isAppointCompany) {
company = '[' + index.selectedCompany + ']'
}
return indexName + year + quarter + merge + company
}
getInputLength(text) {
var width = 0, span
if (!document.getElementById('invented')) {
span = document.createElement('span')
span.id = 'invented'
span.innerHTML = text
document.body.appendChild(span)
} else {
span = document.getElementById('invented')
span.innerHTML = text
}
width = span.offsetWidth
return width + 4
}
getFormatValue(value) {
var unit = '', num = 1
if (value < 10000) {
unit = '', num = 1
} else if (10000 <= value && value < 100000000) {
unit = '', num = 10000
} else if (100000000 <= value && value < 1000000000000) {
unit = '亿', num = 100000000
} else if (value >= 1000000000000) {
unit = '万亿', num = 1000000000000
}
return (value / num).toFixed(0) + unit
}
getShowDomText(html) {
var div = document.createElement('div')
if (html) {
div.innerHTML = html
return div.innerText
} else {
return '未设置'
}
}
insertAfter(newElement, targetElement) {
var parent = targetElement.parentNode
if (parent.lastChild == targetElement) {
parent.appendChild(targetElement)
} else {
parent.insertBefore(newElement, targetElement.nextSibling);
}
}
createAppointedText(num) {
var str = '', text
for (var i = 0; i < num; i++) {
str += '\u00A0'
}
text = document.createTextNode(str)
return text
}
formatShowDom(spans) {
var brackets = []
var numArea = []
Array.from(spans).forEach(item => {
var value = item.innerText
var br = document.createElement('br')
if ('()&&||+-*/'.indexOf(value) >= 0 || (item.nextSibling && '()&&||+-*/'.indexOf(item.nextSibling.innerText) >= 0)) {
this.insertAfter(br, item)
}
})
Array.from(spans).forEach((item, index) => {
var value = item.innerText
if (value == '(' || value == ')') {
brackets.push({
indet: 0,
from: item,
value: value,
originIndex: index
})
}
})
brackets.forEach((item, index) => {
if (index == 0) {
item.indent = 0
var text = this.createAppointedText(item.indent)
item.from.parentNode.insertBefore(text, item.from)
} else {
var newIndent = brackets[index - 1].indent
if (brackets[index - 1].value !== item.value) {
item.indent = newIndent
var text = this.createAppointedText(newIndent)
item.from.parentNode.insertBefore(text, item.from)
} else {
if (item.value == '(') {
item.indent = newIndent + 4
} else {
item.indent = newIndent - 4
}
var text = this.createAppointedText(item.indent)
item.from.parentNode.insertBefore(text, item.from)
}
numArea.push({
start: brackets[index - 1].originIndex,
end: item.originIndex,
indent: brackets[index - 1].indent,
value: brackets[index - 1].value
})
}
})
Array.from(spans).forEach((item, index) => {
var value = item.innerText
if (value !== '(' && value !== ')' && item.previousSibling && item.previousSibling.nodeName == 'BR') {
numArea.forEach(area => {
if (index > area.start && index < area.end) {
var newIndent
if (area.value == '(') {
newIndent = area.indent + 4
} else {
newIndent = area.indent
}
var text = this.createAppointedText(newIndent)
item.parentNode.insertBefore(text, item)
}
})
}
})
}
getKeyboard() {
//条件上的键盘
var keybordData = [
[
{
key: '插入指标',
isActive: false,
isText: true,
isLong: true,
isFunction: false,
tip: '插入指标',
type: 1,
},
{
key: '插入日期',
isActive: false,
isText: true,
isLong: true,
isFunction: false,
tip: '插入日期',
type: 2
},
{
key: '插入数字',
isActive: false,
isText: true,
isLong: true,
isFunction: false,
tip: '插入数字',
type: 3
},
{
key: 'Kdp( )',
isActive: false,
isText: true,
isLong: false,
isFunction: true,
tip: '保留小数位函数',
type: 5,
funcId: 0,
describe: '保留小数位',
case: 'Kdp(归属于母公司所有者的净利润[T:0][Q:0][合并本期], 2)',
params: [[0, 4], [1]], //0指标 1数字 2字符 3时间 4公式
isLimited: true
},
{
key: 'Abs( )',
isActive: false,
isText: true,
isLong: false,
isFunction: true,
tip: '绝对值函数',
type: 5,
funcId: 1,
describe: '求指标或计算片段的绝对值',
case: 'Abs(归属于母公司所有者的净利润[T:0][Q:0][合并本期])',
params: [[0, 4]], //0指标 1数字 2字符 3时间 4公式
isLimited: true
},
// {
// key: 'Tf( )',
// isActive: false,
// isText: true,
// isLong: false,
// isFunction: true,
// tip: '时间格式化函数',
// type: 5,
// funcId: 2,
// describe: '对时间进行格式化操作',
// case: 'Abs(上市日期, yyyy-MM-dd)',
// params: [[3],[2]], //0指标 1数字 2字符 3时间 4公式
// isLimited: true
// },
{
key: 'Ave( )',
isActive: false,
isText: true,
isLong: false,
isFunction: true,
tip: '平均值函数',
type: 5,
funcId: 3,
describe: '计算一组数据的平均值',
case: 'Ave(营业总收入[T:-1][Q:0][合并本期], 营业总收入[T:-2][Q:0][合并本期])',
params: [[0, 1, 4]], //0指标 1数字 2字符 3时间 4公式
isLimited: false
},
{
key: 'Mer( )',
isActive: false,
isText: true,
isLong: false,
isFunction: true,
tip: '当该指标为年报时,用下一年合并上期数据',
type: 5,
funcId: 8,
describe: '计算下一年年报合并上期',
case: 'Mer(营业总收入[T:-1][Q:0][合并本期])',
params: [[0]], //0指标 1数字 2字符 3时间 4公式
isLimited: true
}
], [
{
key: '+',
isActive: false,
isText: true,
isLong: false,
isFunction: false,
tip: '计算符号:加号',
type: 4
},
{
key: '-',
isActive: false,
isText: true,
isLong: false,
isFunction: false,
tip: '计算符号:减号',
type: 4
},
{
key: '*',
isActive: false,
isText: true,
isLong: false,
isFunction: false,
tip: '计算符号:乘号',
type: 4
},
{
key: '/',
isActive: false,
isText: true,
isLong: false,
isFunction: false,
tip: '计算符号:除号',
type: 4
},
{
key: '(',
isActive: false,
isText: true,
isLong: false,
isFunction: false,
tip: '计算符号:左括号',
type: 4
},
{
key: ')',
isActive: false,
isText: true,
isLong: false,
isFunction: false,
tip: '计算符号:右括号',
type: 4
},
{
key: 'Sum( )',
isActive: false,
isText: true,
isLong: false,
isFunction: true,
tip: '求和函数',
type: 5,
funcId: 4,
describe: '计算一组数据的总和',
case: 'Sum(营业总收入[T:-1][Q:0][合并本期], 营业总收入[T:-2][Q:0][合并本期])',
params: [[0, 1, 4]], //0指标 1数字 2字符 3时间 4公式
isLimited: false
},
{
key: 'Max( )',
isActive: false,
isText: true,
isLong: false,
isFunction: true,
tip: '最大值函数',
type: 5,
funcId: 5,
describe: '计算一组数据的最大值',
case: 'Max(营业总收入[T:-1][Q:0][合并本期], 营业总收入[T:-2][Q:0][合并本期])',
params: [[0, 1, 4]], //0指标 1数字 2字符 3时间 4公式
isLimited: false
},
{
key: 'Min( )',
isActive: false,
isText: true,
isLong: false,
isFunction: true,
tip: '最小值函数',
type: 5,
funcId: 6,
describe: '计算一组数据的最小值',
case: 'Min(营业总收入[T:-1][Q:0][合并本期], 营业总收入[T:-2][Q:0][合并本期])',
params: [[0, 1, 4]], //0指标 1数字 2字符 3时间 4公式
isLimited: false
},
{
key: 'Fac( )',
isActive: false,
isText: true,
isLong: false,
isFunction: true,
tip: '阶乘函数',
type: 5,
funcId: 7,
describe: '计算一组数据的阶乘',
case: 'Fac(营业总收入[T:-1][Q:0][合并本期])',
params: [[0, 1, 4]], //0指标 1数字 2字符 3时间 4公式
isLimited: true
}
]
]
//条件上的键盘
var functionKeybord = [
[
{
key: '插入指标',
isActive: false,
isText: true,
isLong: true,
isFunction: false,
tip: '插入指标',
type: 1,
},
{
key: '插入日期',
isActive: false,
isText: true,
isLong: true,
isFunction: false,
tip: '插入日期',
type: 2
},
{
key: '插入数字',
isActive: false,
isText: true,
isLong: true,
isFunction: false,
tip: '插入数字',
type: 3
}
], [
{
key: '+',
isActive: false,
isText: true,
isLong: false,
isFunction: false,
tip: '计算符号:加号',
type: 4
},
{
key: '-',
isActive: false,
isText: true,
isLong: false,
isFunction: false,
tip: '计算符号:减号',
type: 4
},
{
key: '*',
isActive: false,
isText: true,
isLong: false,
isFunction: false,
tip: '计算符号:乘号',
type: 4
},
{
key: '/',
isActive: false,
isText: true,
isLong: false,
isFunction: false,
tip: '计算符号:除号',
type: 4
},
{
key: '(',
isActive: false,
isText: true,
isLong: false,
isFunction: false,
tip: '计算符号:左括号',
type: 4
},
{
key: ')',
isActive: false,
isText: true,
isLong: false,
isFunction: false,
tip: '计算符号:右括号',
type: 4
}
]
]
return {
keybordData: keybordData,
functionKeybord: functionKeybord
}
}//有关于条件的一些方法
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment