7 changed files with 13 additions and 504 deletions
@ -1,307 +0,0 @@ |
|||
// 纳排管理共享数据
|
|||
export default { |
|||
data() { |
|||
return { |
|||
formContent: [], |
|||
conditionObj: { |
|||
// 或并
|
|||
joinContent: [{ |
|||
join: [ |
|||
{ label: '必须', value: 'must' }, |
|||
{ label: '可以', value: 'should' }, |
|||
{ label: '排除', value: 'must_not' } |
|||
] |
|||
// selectValueArr: []
|
|||
}], |
|||
// 患者信息
|
|||
patientInfoContent: [{ |
|||
patientInfo: [], |
|||
// selectValueArr: [],
|
|||
// 显示类型:string,number,date
|
|||
showMode: [] |
|||
}], |
|||
// 匹配
|
|||
matchingContent: [{ |
|||
matching: [ |
|||
{ label: '匹配', value: 'matchQuery', disabled: false }, |
|||
{ label: '精准匹配', value: 'termQuery', disabled: false }, |
|||
{ label: '范围查询', value: 'rangeQuery', disabled: true } |
|||
] |
|||
// selectValueArr: []
|
|||
}], |
|||
// 大于等于符号
|
|||
symbolContent: [{ |
|||
symbol: [ |
|||
{ label: '等于', value: 'eq' }, |
|||
{ label: '小于', value: 'lt' }, |
|||
{ label: '小于等于', value: 'lte' }, |
|||
{ label: '大于', value: 'gt' }, |
|||
{ label: '大于等于', value: 'gte' } |
|||
] |
|||
// selectValueArr: []
|
|||
}], |
|||
InputData: [{ |
|||
// 输入框string
|
|||
inputString: [], |
|||
// 日期范围
|
|||
dataRange: [], |
|||
// 数值范围
|
|||
NumberRangeOne: [], |
|||
NumberRangeTwo: [] |
|||
}], |
|||
iconState: [{ |
|||
state: false |
|||
}] |
|||
}, |
|||
filterItemList: [{ |
|||
sort: '', // 排序
|
|||
fieldDescription: '', // 字段描述
|
|||
fieldType: '', // 字段类型
|
|||
tableDescription: '', // 表描述
|
|||
orgCode: '', // 用户
|
|||
value: '', // 输入框值
|
|||
projectId: '', |
|||
connection: '', // 或并 --连接词
|
|||
fieldName: '', // 患者信息名称
|
|||
queryType: '', // 匹配 --运算符号
|
|||
// 大于小于等于
|
|||
queryValue: { |
|||
eq: '', // =
|
|||
gt: '', // >
|
|||
gte: '', // >=
|
|||
lt: '', // <
|
|||
lte: '' // <=
|
|||
}, |
|||
id: '', |
|||
recId: '', |
|||
tableName: '', // 表名
|
|||
type: '' // 数据类型,前端查询对应的 1 or 2,1 患者信息 , 2 基本数据查询
|
|||
}], |
|||
pageName: '' |
|||
} |
|||
}, |
|||
created() { |
|||
this.formContent.push(this.conditionObj) |
|||
}, |
|||
|
|||
methods: { |
|||
// 设置图标 “对号” 显示状态为true
|
|||
setIconStateTrue(index, e) { |
|||
this.formContent.forEach(item => { |
|||
item.iconState[index].state = true |
|||
}) |
|||
this.conditionObj.iconState[index].state = true |
|||
}, |
|||
// 设置图标 “对号” 显示状态为false
|
|||
setIconStateFalse(index) { |
|||
this.formContent.forEach(item => { |
|||
item.iconState[index].state = false |
|||
}) |
|||
this.conditionObj.iconState[index].state = false |
|||
}, |
|||
// 患者信息选择
|
|||
patientInfoChange(index, e) { |
|||
// 患者数据只要发生改变就可以从新查询
|
|||
this.setIconStateFalse(index) |
|||
this.filterItemList[index].queryValue = { |
|||
eq: '', // =
|
|||
gt: '', // >
|
|||
gte: '', // >=
|
|||
lt: '', // <
|
|||
lte: '' // <=
|
|||
} |
|||
if (e === '') { |
|||
// 判断选中选项的tableName赋值给filterItemList
|
|||
this.filterItemList[index].connection = '' |
|||
this.filterItemList[index].fieldDescription = '' |
|||
this.filterItemList[index].fieldName = '' |
|||
this.filterItemList[index].fieldType = '' |
|||
this.filterItemList[index].orgCode = '' |
|||
this.filterItemList[index].tableName = '' |
|||
this.filterItemList[index].tableDescription = '' |
|||
this.filterItemList[index].type = '' |
|||
this.filterItemList[index].queryType = '' |
|||
this.filterItemList[index].projectId = '' |
|||
this.formContent.forEach(item => { |
|||
item.patientInfoContent[0].showMode[index] = 'string' |
|||
item.matchingContent[0].matching.forEach(matchItem => { |
|||
if (matchItem.value === 'rangeQuery') { |
|||
matchItem.disabled = true |
|||
} else { |
|||
matchItem.disabled = false |
|||
} |
|||
}) |
|||
}) |
|||
this.saveStorage ? this.saveStorage() : '' |
|||
} else { |
|||
this.filterItemList[index].sort = index |
|||
this.formContent.forEach(formContentItem => { |
|||
formContentItem.patientInfoContent[0].patientInfo.forEach(patientInfoItem => { |
|||
patientInfoItem.list.forEach(ListItem => { |
|||
if (ListItem.id === e) { |
|||
// 判断选中选项的tableName赋值给filterItemList
|
|||
this.filterItemList[index].fieldName = ListItem.fieldName |
|||
this.filterItemList[index].projectId = window.SITE_CONFIG['projectId'] |
|||
this.filterItemList[index].fieldDescription = ListItem.fieldDescription |
|||
this.filterItemList[index].fieldType = ListItem.fieldType |
|||
this.filterItemList[index].orgCode = ListItem.orgCode |
|||
this.filterItemList[index].tableName = patientInfoItem.tableName |
|||
this.filterItemList[index].tableDescription = patientInfoItem.tableDescription |
|||
this.filterItemList[index].type = patientInfoItem.type |
|||
// 判断选中的类型设置匹配禁用和启用状态
|
|||
if (ListItem.fieldType === 'string') { |
|||
// 如果是string类型,默认的匹配模式为:'匹配-matchQuery'
|
|||
this.filterItemList[index].queryType = 'matchQuery' |
|||
formContentItem.patientInfoContent[0].showMode[index] = 'string' |
|||
formContentItem.matchingContent[0].matching.forEach(matchItem => { |
|||
if (matchItem.value === 'rangeQuery') { |
|||
matchItem.disabled = true |
|||
} else { |
|||
matchItem.disabled = false |
|||
} |
|||
}) |
|||
} else if (ListItem.fieldType === 'number') { |
|||
// 如果是number类型,默认的匹配模式为:'范围查询-rangeQuery'
|
|||
this.filterItemList[index].queryType = 'rangeQuery' |
|||
formContentItem.patientInfoContent[0].showMode[index] = 'number' |
|||
formContentItem.matchingContent[0].matching.forEach(matchItem => { |
|||
if (matchItem.value !== 'rangeQuery') { |
|||
matchItem.disabled = true |
|||
} else { |
|||
matchItem.disabled = false |
|||
} |
|||
}) |
|||
} else if (ListItem.fieldType === 'date') { |
|||
// 如果是date类型,默认的匹配模式为:'范围查询-rangeQuery'
|
|||
this.filterItemList[index].queryType = 'rangeQuery' |
|||
formContentItem.patientInfoContent[0].showMode[index] = 'date' |
|||
formContentItem.matchingContent[0].matching.forEach(matchItem => { |
|||
if (matchItem.value !== 'rangeQuery') { |
|||
matchItem.disabled = true |
|||
} else { |
|||
matchItem.disabled = false |
|||
} |
|||
}) |
|||
} |
|||
} |
|||
}) |
|||
}) |
|||
}) |
|||
} |
|||
}, |
|||
// 数据还原
|
|||
dataReduction() { |
|||
this.filterItemList = [{ |
|||
sort: '', // 排序
|
|||
fieldDescription: '', // 字段描述
|
|||
fieldType: '', // 字段类型
|
|||
tableDescription: '', // 表描述
|
|||
orgCode: '', // 用户
|
|||
value: '', // 输入框值
|
|||
|
|||
connection: '', // 或并 --连接词
|
|||
fieldName: '', // 患者信息名称
|
|||
queryType: '', // 匹配 --运算符号
|
|||
projectId: this.projectId, |
|||
// 大于小于等于
|
|||
queryValue: { |
|||
eq: '', // =
|
|||
gt: '', // >
|
|||
gte: '', // >=
|
|||
lt: '', // <
|
|||
lte: '' // <=
|
|||
}, |
|||
id: '', // getTableDictTree下拉菜单里的id
|
|||
recId: '', // 获取的已添加过的纳排列表id
|
|||
tableName: '', // 表名
|
|||
type: '' // 数据类型,前端查询对应的 1 or 2,1 患者信息 , 2 基本数据查询
|
|||
}] |
|||
}, |
|||
// 删除条件
|
|||
deleteClick(index) { |
|||
if (this.formContent.length <= 1 && this.pageName !== 'napai') { |
|||
this.dataReduction() |
|||
this.getSearchData ? this.getSearchData() : '' |
|||
this.saveStorage ? this.saveStorage() : '' |
|||
return |
|||
} |
|||
this.filterItemList.splice(index, 1) |
|||
this.formContent.forEach(item => { |
|||
item.patientInfoContent[0].showMode.splice(index, 1) |
|||
}) |
|||
this.conditionObj.iconState.splice(index, 1) |
|||
this.conditionObj.patientInfoContent[0].showMode.splice(index, 1) |
|||
this.formContent.splice(index, 1) |
|||
// if (this.formContent.length <= 1) {
|
|||
// this.filterItemList[0].connection = 'must'
|
|||
// } else {
|
|||
// this.filterItemList[0].connection = ''
|
|||
// }
|
|||
this.getSearchData ? this.getSearchData() : '' |
|||
this.saveConditionData ? this.saveConditionData(index) : '' |
|||
this.saveStorage ? this.saveStorage() : '' |
|||
}, |
|||
// 查询条件
|
|||
findClick(index) { |
|||
if (this.filterItemList[index].fieldType === 'string') { |
|||
this.filterItemList[index].value = this.filterItemList[index].queryValue.eq ? String(this.filterItemList[index].queryValue.eq) : '' |
|||
} else { |
|||
this.filterItemList[index].value = this.filterItemList[index].queryValue.gte && this.filterItemList[index].queryValue.lte ? String([this.filterItemList[index].queryValue.gte, this.filterItemList[index].queryValue.lte]) : '' |
|||
} |
|||
if (!this.filterItemList[index].value || |
|||
!this.filterItemList[index].connection || |
|||
!this.filterItemList[index].fieldDescription || |
|||
!this.filterItemList[index].queryType || |
|||
!this.filterItemList[index].fieldName || |
|||
!this.filterItemList[index].fieldType || |
|||
!this.filterItemList[index].id || |
|||
!this.filterItemList[index].tableDescription || |
|||
!this.filterItemList[index].tableName |
|||
) { |
|||
this.$message({ |
|||
message: '请将条件补全完整后再次提交', |
|||
type: 'warning' |
|||
}) |
|||
} else { |
|||
this.setIconStateTrue(index) |
|||
this.getSearchData ? this.getSearchData() : '' |
|||
this.saveConditionData ? this.saveConditionData(index) : '' |
|||
this.saveStorage ? this.saveStorage() : '' |
|||
} |
|||
}, |
|||
// 添加条件
|
|||
addClick(scope) { |
|||
this.conditionObj.iconState.push({ state: false }) |
|||
this.formContent.forEach(item => { |
|||
item.iconState = this.conditionObj.iconState |
|||
}) |
|||
this.formContent.push(this.conditionObj) |
|||
this.filterItemList.push({ |
|||
sort: '', // 排序
|
|||
fieldDescription: '', // 字段描述
|
|||
fieldType: '', // 字段类型
|
|||
tableDescription: '', // 表描述
|
|||
orgCode: '', // 用户
|
|||
value: '', // 输入框值
|
|||
projectId: '', |
|||
connection: '', // 或并 --连接词
|
|||
fieldName: '', // 患者信息名称
|
|||
queryType: '', // 匹配 --运算符号
|
|||
// 大于小于等于
|
|||
queryValue: { |
|||
eq: '', // =
|
|||
gt: '', // >
|
|||
gte: '', // >=
|
|||
lt: '', // <
|
|||
lte: '' // <=
|
|||
}, |
|||
id: '', |
|||
recId: '', |
|||
tableName: '', // 表名
|
|||
type: '' // 数据类型,前端查询对应的 1 or 2,1 患者信息 , 2 基本数据查询
|
|||
}) |
|||
} |
|||
|
|||
} |
|||
} |
|||
|
@ -1,12 +0,0 @@ |
|||
export default { |
|||
data() { |
|||
return { |
|||
dialogFormVisible: false |
|||
} |
|||
}, |
|||
methods: { |
|||
closeDialog() { |
|||
this.dialogFormVisible = false |
|||
} |
|||
} |
|||
} |
@ -1,155 +0,0 @@ |
|||
export default { |
|||
data() { |
|||
return { |
|||
surgicalStatus: [], |
|||
|
|||
// websocket相关
|
|||
socketObj: '', // websocket实例对象
|
|||
// 心跳检测
|
|||
heartCheck: { |
|||
vueThis: this, // vue实例
|
|||
timeout: 10000, // 超时时间
|
|||
timeoutObj: null, // 计时器对象——向后端发送心跳检测
|
|||
serverTimeoutObj: null, // 计时器对象——等待后端心跳检测的回复
|
|||
// 心跳检测重置
|
|||
reset: function() { |
|||
clearTimeout(this.timeoutObj) |
|||
clearTimeout(this.serverTimeoutObj) |
|||
return this |
|||
}, |
|||
// 心跳检测启动
|
|||
start: function() { |
|||
this.timeoutObj && clearTimeout(this.timeoutObj) |
|||
this.serverTimeoutObj && clearTimeout(this.serverTimeoutObj) |
|||
this.timeoutObj = setTimeout(() => { |
|||
// 这里向后端发送一个心跳检测,后端收到后,会返回一个心跳回复
|
|||
this.vueThis.socketObj.send('HeartBeat') |
|||
console.log('发送心跳检测') |
|||
this.serverTimeoutObj = setTimeout(() => { |
|||
// 如果超过一定时间还没重置计时器,说明websocket与后端断开了
|
|||
console.log('未收到心跳检测回复') |
|||
// 关闭WebSocket
|
|||
this.vueThis.socketObj.close() |
|||
}, this.timeout) |
|||
}, this.timeout) |
|||
} |
|||
}, |
|||
socketReconnectTimer: null, // 计时器对象——重连
|
|||
socketReconnectLock: false, // WebSocket重连的锁
|
|||
socketLeaveFlag: false // 离开标记(解决 退出登录再登录 时出现的 多次相同推送 问题,出现的本质是多次建立了WebSocket连接)
|
|||
} |
|||
}, |
|||
destroyed() { |
|||
// 离开标记
|
|||
this.socketLeaveFlag = true |
|||
// 关闭WebSocket
|
|||
this.socketObj.close() |
|||
}, |
|||
created() { |
|||
}, |
|||
mounted() { |
|||
// websocket启动
|
|||
this.createWebSocket() |
|||
}, |
|||
methods: { |
|||
// websocket启动
|
|||
createWebSocket() { |
|||
// console.log(window.SITE_CONFIG['apiURL'].replace('http', 'ws'))
|
|||
const URL = window.SITE_CONFIG['apiURL'].replace('http', 'ws') |
|||
const webSocketLink = `${URL}/websocket/WZYSG_QG` // webSocket地址
|
|||
// console.log(webSocketLink);
|
|||
try { |
|||
if ('WebSocket' in window) { |
|||
this.socketObj = new WebSocket(webSocketLink) |
|||
} else { |
|||
console.log('Current browser Not support websocket') |
|||
} |
|||
// websocket事件绑定
|
|||
this.socketEventBind() |
|||
} catch (e) { |
|||
console.log('catch' + e) |
|||
// websocket重连
|
|||
this.socketReconnect() |
|||
} |
|||
}, |
|||
// websocket事件绑定
|
|||
socketEventBind() { |
|||
// 连接成功建立的回调
|
|||
this.socketObj.onopen = this.onopenCallback |
|||
// 连接发生错误的回调
|
|||
this.socketObj.onerror = this.onerrorCallback |
|||
// 连接关闭的回调
|
|||
this.socketObj.onclose = this.oncloseCallback |
|||
// 向后端发送数据的回调
|
|||
this.socketObj.onsend = this.onsendCallback |
|||
// 接收到消息的回调
|
|||
this.socketObj.onmessage = this.getMessageCallback |
|||
|
|||
// 监听窗口关闭事件,当窗口关闭时,主动去关闭websocket连接,防止连接还没断开就关闭窗口,server端会抛异常。
|
|||
window.onbeforeunload = () => { |
|||
this.socketObj.close() |
|||
} |
|||
}, |
|||
// websocket重连
|
|||
socketReconnect() { |
|||
if (this.socketReconnectLock) { |
|||
return |
|||
} |
|||
this.socketReconnectLock = true |
|||
this.socketReconnectTimer && clearTimeout(this.socketReconnectTimer) |
|||
this.socketReconnectTimer = setTimeout(() => { |
|||
console.log('WebSocket:重连中...') |
|||
this.socketReconnectLock = false |
|||
// websocket启动
|
|||
this.createWebSocket() |
|||
}, 4000) |
|||
}, |
|||
// 连接成功建立的回调
|
|||
onopenCallback: function(event) { |
|||
console.log('WebSocket:已连接') |
|||
// 心跳检测重置
|
|||
this.heartCheck.reset().start() |
|||
}, |
|||
// 连接发生错误的回调
|
|||
onerrorCallback: function(event) { |
|||
console.log('WebSocket:发生错误') |
|||
// websocket重连
|
|||
this.socketReconnect() |
|||
}, |
|||
// 连接关闭的回调
|
|||
oncloseCallback: function(event) { |
|||
console.log('WebSocket:已关闭') |
|||
// 心跳检测重置
|
|||
this.heartCheck.reset() |
|||
if (!this.socketLeaveFlag) { |
|||
// 没有离开——重连
|
|||
// websocket重连
|
|||
this.socketReconnect() |
|||
} |
|||
}, |
|||
// 向后端发送数据的回调
|
|||
onsendCallback: function() { |
|||
console.log('WebSocket:发送信息给后端') |
|||
}, |
|||
// 接收到消息的回调
|
|||
getMessageCallback: function(msg) { |
|||
// console.log(msg);
|
|||
console.log(msg.data) |
|||
if (msg.data.indexOf('HeartBeat') > -1) { |
|||
// 心跳回复——心跳检测重置
|
|||
// 收到心跳检测回复就说明连接正常
|
|||
console.log('收到心跳检测回复') |
|||
// 心跳检测重置
|
|||
this.heartCheck.reset().start() |
|||
} else { |
|||
// 普通推送——正常处理
|
|||
console.log('收到推送消息') |
|||
const data = JSON.parse(msg.data) |
|||
console.log(data) |
|||
this.getDataListInitial() |
|||
// 相关处理
|
|||
console.log(data) |
|||
} |
|||
} |
|||
} |
|||
} |
Loading…
Reference in new issue