This commit is contained in:
2026-05-18 09:38:55 +08:00
parent 634e0b9456
commit 7d1e1012d4
10 changed files with 153 additions and 46 deletions
+11 -2
View File
@@ -35,15 +35,24 @@ export const endoscopeinware = (param) => {
return request.get('/cabinetapi/endoscopeinware', param) return request.get('/cabinetapi/endoscopeinware', param)
} }
// 内镜取出 // 内镜取出
export const endoscopeoutware = (param) => { export const endoscopeoutware = (param) => {
return request.get('/cabinetapi/endoscopeoutware', param) return request.get('/cabinetapi/endoscopeoutware', param)
} }
// 提交日志 // 提交日志
export const logsync = (param) => { export const logsync = (param) => {
return request.get('/cabinetapi/logsync', param) return request.get('/cabinetapi/logsync', param)
} }
// 内镜入库(endoscopeInwareLog
export const endoscopeInwareLog = (param) => {
return request.get('/app/controller/cabinet-api/endoscopeInwareLog', param)
}
// 内镜出库(endoscopeOutwareLog
export const endoscopeOutwareLog = (param) => {
return request.get('/app/controller/cabinet-api/endoscopeOutwareLog', param)
}
+1
View File
@@ -378,6 +378,7 @@ export const selectDataList = (tabName,setData,byName,byType) => {
setStr += ( setStr += (
`${item}=${JSON.stringify(setData[item])}${dataKeys.length - 1 !== index ? " and " : ""}`) `${item}=${JSON.stringify(setData[item])}${dataKeys.length - 1 !== index ? " and " : ""}`)
}) })
// console.log(setStr)
sql = `select * from ${tabName} where ${setStr}` sql = `select * from ${tabName} where ${setStr}`
} else { } else {
sql = `select * from ${tabName}` sql = `select * from ${tabName}`
+2 -2
View File
@@ -2,8 +2,8 @@
"name" : "endoscope", "name" : "endoscope",
"appid" : "__UNI__5A0A7D6", "appid" : "__UNI__5A0A7D6",
"description" : "", "description" : "",
"versionName" : "1.2.3", "versionName" : "1.2.4",
"versionCode" : 109, "versionCode" : 111,
"transformPx" : false, "transformPx" : false,
/* 5+App */ /* 5+App */
"app-plus" : { "app-plus" : {
+70 -14
View File
@@ -86,7 +86,7 @@
'over': item.isWarning == 'over', 'near': item.isWarning == 'near' 'over': item.isWarning == 'over', 'near': item.isWarning == 'near'
}"> }">
<view> <view>
{{ item.ic }} {{ item.rfid }}
</view> </view>
</uni-row> </uni-row>
<uni-row v-else class="info"> <uni-row v-else class="info">
@@ -197,6 +197,7 @@ import { getDataList } from '@/db/sqlite.js'
import * as db from '@/db/sqlite.js' import * as db from '@/db/sqlite.js'
import cmd from '@/utils/cmd.js' import cmd from '@/utils/cmd.js'
import storage from '@/utils/storage.js' import storage from '@/utils/storage.js'
import * as Api from '@/api/index.js'
export default { export default {
components: { components: {
PageFooter, PageHeader, Notice, SlotNotice PageFooter, PageHeader, Notice, SlotNotice
@@ -225,6 +226,8 @@ export default {
timer: null, // 定时器 timer: null, // 定时器
timeouter: null, // 延时器 timeouter: null, // 延时器
currentCardNumber: '', // 当前卡号 currentCardNumber: '', // 当前卡号
currentName: '' // 当前用户名
} }
}, },
computed: { computed: {
@@ -281,7 +284,7 @@ export default {
uni.redirectTo({ url: '/pages/start', animationType: 'fade-out' }) uni.redirectTo({ url: '/pages/start', animationType: 'fade-out' })
return true; return true;
}, },
onLoad() { async onLoad() {
}, },
onShow() { onShow() {
@@ -290,6 +293,7 @@ export default {
uni.$on('showActionSelect', (cardNumber) => { this.showActionSelect(cardNumber) }) uni.$on('showActionSelect', (cardNumber) => { this.showActionSelect(cardNumber) })
this.getData() // 注释掉以使用测试数据 this.getData() // 注释掉以使用测试数据
this.startTimer() this.startTimer()
}, },
onHide() { onHide() {
uni.$off('notice') uni.$off('notice')
@@ -327,7 +331,7 @@ export default {
// console.log('handleData', list) // console.log('handleData', list)
let data = [] let data = []
for (let i = 0; i < 16; i++) { for (let i = 0; i < 16; i++) {
data.push({ ic: '', text: '', isWarning: false }) data.push({ ic: '', text: '', isWarning: false, rfid: '' })
} }
this.list = data this.list = data
let curDate = formatDateTime() let curDate = formatDateTime()
@@ -340,6 +344,7 @@ export default {
let item = this.list[key] let item = this.list[key]
item.ic = i.ic item.ic = i.ic
item.text = '' item.text = ''
item.rfid = i.rfid
item.isWarning = false item.isWarning = false
if (i.ic != '') { if (i.ic != '') {
item.text = diffText item.text = diffText
@@ -360,7 +365,9 @@ export default {
// 调试手动关门 // 调试手动关门
// let door = this.$store.state.relay.door // let door = this.$store.state.relay.door
// cmd.Door(true) // cmd.Door(true)
this.$refs.doorNotice.open() // this.$refs.doorNotice.open()
uni.showToast({ title: '手动关门', icon: 'none' })
uni.$emit('closeDoor');
}, },
disinfectClick() { disinfectClick() {
// 消毒手动开启 // 消毒手动开启
@@ -416,6 +423,19 @@ export default {
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.doorNotice.open() this.$refs.doorNotice.open()
}) })
db.selectDataList('user', {'ic': cardNumber}).then(res => {
if (res.length > 0) {
this.currentName = res[0].name
} else {
db.selectDataList('user', {'ic2': cardNumber}).then(res => {
if (res.length > 0) {
this.currentName = res[0].name
}
})
}
})
}, },
showActionSelect(cardNumber) { showActionSelect(cardNumber) {
// 显示操作选择弹窗(存入/取出) // 显示操作选择弹窗(存入/取出)
@@ -444,24 +464,32 @@ export default {
let emptyKey = -1 let emptyKey = -1
for (let i = 0; i < scopeList.length; i++) { for (let i = 0; i < scopeList.length; i++) {
if (!scopeList[i].ic || scopeList[i].ic === '') { if (!scopeList[i].rfid || scopeList[i].rfid === '') {
emptyKey = scopeList[i].key emptyKey = scopeList[i].key
break break
} }
} }
if (emptyKey === -1) { if (emptyKey === -1) {
uni.showToast({ uni.showToast({ title: '没有空闲位置', icon: 'none' })
title: '没有空闲位置',
icon: 'none'
})
return return
} }
let rfid = ""
let endList = await db.selectDataList('endo', {ic: this.currentCardNumber})
if (endList.length > 0) {
rfid = endList[0].rfid
} else {
let endList = await db.selectDataList('endo', {ic2: this.currentCardNumber})
if (endList.length > 0) {
rfid = endList[0].rfid
}
}
// 更新scope表,记录存入信息 // 更新scope表,记录存入信息
await db.updateSQL('scope', { await db.updateSQL('scope', {
name: 'enter', name: 'enter',
ic: this.currentCardNumber, ic: this.currentCardNumber,
rfid: rfid,
time: formatDateTime() time: formatDateTime()
}, 'key', emptyKey) }, 'key', emptyKey)
@@ -472,8 +500,17 @@ export default {
title: '内镜已存入', title: '内镜已存入',
icon: 'none' icon: 'none'
}) })
// 关闭操作选择框
this.$refs.actionNotice.close()
// 刷新数据
this.getData() this.getData()
// 添加入库记录到服务器
Api.endoscopeInwareLog({
'endoscope_steel_no': rfid,
'rfid_reader': '123456',
'user_name': this.currentName
})
} catch (error) { } catch (error) {
console.log('存入内镜失败:', error) console.log('存入内镜失败:', error)
uni.showToast({ uni.showToast({
@@ -482,6 +519,7 @@ export default {
}) })
} }
}, },
async takeEndoscope() { async takeEndoscope() {
// 取出内镜 - 门关闭状态时才能取出 // 取出内镜 - 门关闭状态时才能取出
// if (this.$store.state.relay.door) { // if (this.$store.state.relay.door) {
@@ -497,15 +535,25 @@ export default {
// 根据卡号查找scope表中的位置 // 根据卡号查找scope表中的位置
try { try {
let rfid = ""
let endList = await db.selectDataList('endo', {ic: this.currentCardNumber})
if (endList.length > 0) {
rfid = endList[0].rfid
} else {
let endList = await db.selectDataList('endo', {ic2: this.currentCardNumber})
if (endList.length > 0) {
rfid = endList[0].rfid
}
}
let scopeList = await db.selectDataList('scope', {}) let scopeList = await db.selectDataList('scope', {})
let foundKey = -1 let foundKey = -1
for (let i = 0; i < scopeList.length; i++) { for (let i = 0; i < scopeList.length; i++) {
if (scopeList[i].ic == this.currentCardNumber) { if (scopeList[i].rfid == rfid) {
foundKey = scopeList[i].key foundKey = scopeList[i].key
break break
} }
} }
if (foundKey === -1) { if (foundKey === -1) {
uni.showToast({ uni.showToast({
title: '未找到该内镜', title: '未找到该内镜',
@@ -518,6 +566,7 @@ export default {
await db.updateSQL('scope', { await db.updateSQL('scope', {
name: 'leave', name: 'leave',
ic: '', ic: '',
rfid: '',
time: formatDateTime() time: formatDateTime()
}, 'key', foundKey) }, 'key', foundKey)
@@ -528,8 +577,15 @@ export default {
title: '内镜已取出', title: '内镜已取出',
icon: 'none' icon: 'none'
}) })
this.$refs.actionNotice.close()
this.getData() this.getData()
// 添加出库记录到服务器
Api.endoscopeOutwareLog({
'endoscope_steel_no': rfid,
'rfid_reader': '123456',
'user_name': this.currentName
})
} catch (error) { } catch (error) {
console.log('取出内镜失败:', error) console.log('取出内镜失败:', error)
uni.showToast({ uni.showToast({
+2 -2
View File
@@ -66,12 +66,12 @@ export default {
focus: 'ip' focus: 'ip'
} }
}, },
mounted() { onLoad() {
this.getData(); this.getData();
}, },
methods: { methods: {
getData() { getData() {
let server = storage.get('server', '') let server = storage.get('config', '')
if (server) { if (server) {
this.ip = server.ip; this.ip = server.ip;
this.port = server.port; this.port = server.port;
+1
View File
@@ -187,6 +187,7 @@ export default {
}) })
this.getList() this.getList()
} catch (error) { } catch (error) {
console.log(error)
uni.showToast({ uni.showToast({
title: '保存失败', title: '保存失败',
icon: 'none' icon: 'none'
+27 -9
View File
@@ -112,6 +112,19 @@ export default {
this.addLog(data.ic, '内镜取出') this.addLog(data.ic, '内镜取出')
}) })
uni.$on('closeDoor', async (data) => {
try {
cmd.LeftDoor(false)
await delay(100)
cmd.RightDoor(false)
this.addLog('门', '触摸屏关门')
// 触发关门事件
this.closeDoorEvent()
} catch (error) {
this.addLog('手动关门错误', error)
}
})
}, },
onShow() { onShow() {
// 监听日志记录事件 // 监听日志记录事件
@@ -144,7 +157,7 @@ export default {
this.startRS485() this.startRS485()
this.startRS232() this.startRS232()
} catch (e) { } catch (e) {
console.log(e) // console.log(e)
uni.showToast({ uni.showToast({
title: '初始化串口失败', title: '初始化串口失败',
icon: 'error' icon: 'error'
@@ -268,7 +281,7 @@ export default {
} }
let config = storage.get('config') let config = storage.get('config')
if (config) { if (config) {
this.$store.state.apiUrl = config.ip + ':' + config.port this.$store.state.apiUrl = 'http://' + config.ip + ':' + config.port
} }
}, },
async initDB() { async initDB() {
@@ -319,7 +332,7 @@ export default {
icon: 'none' icon: 'none'
}) })
this.RS485.startAutoReadData((res) =>{ this.RS485.startAutoReadData((res) =>{
console.log('485 data', res) // console.log('485 data', res)
// 转换成十六进制字符串 // 转换成十六进制字符串
let hex = this.RS485.byte2HexString(res) let hex = this.RS485.byte2HexString(res)
this.handle485HexData(hex) this.handle485HexData(hex)
@@ -402,6 +415,7 @@ export default {
title: '左门已关闭', title: '左门已关闭',
icon: 'none' icon: 'none'
}) })
this.addLog('左门触点触发', '左门已关闭')
} }
if (data.action == 'RightDoor' && data.status == 'closed') { if (data.action == 'RightDoor' && data.status == 'closed') {
// 右门触点触发(关门) // 右门触点触发(关门)
@@ -413,18 +427,22 @@ export default {
title: '右门已关闭', title: '右门已关闭',
icon: 'none' icon: 'none'
}) })
this.addLog('右门触点触发', '右门已关闭')
} }
if (data.action == 'door' && data.status == 'closed') { if (data.action == 'door' && data.status == 'closed') {
try {
cmd.LeftDoor(false) await cmd.LeftDoor(false)
await delay(100) await delay(100)
cmd.RightDoor(false) await cmd.RightDoor(false)
// 触发关门事件 // 触发关门事件
this.closeDoorEvent() await this.closeDoorEvent()
uni.showToast({ uni.showToast({
title: '两门已关闭', title: '两门已关闭',
icon: 'none' icon: 'none'
}) })
} catch (error) {
this.addLog('门关闭错误', error.message || error)
}
} }
}, },
handle232HexData(hex) { handle232HexData(hex) {
@@ -582,7 +600,7 @@ export default {
this.stopRS485() this.stopRS485()
this.stopRS232() this.stopRS232()
} catch (error) { } catch (error) {
console.log(error) // console.log(error)
} }
this.closePop() this.closePop()
uni.navigateTo({ uni.navigateTo({
@@ -693,7 +711,7 @@ export default {
// 网络同步 // 网络同步
// Api.logsync() // Api.logsync()
} catch (error) { } catch (error) {
console.log(error) // console.log(error)
} }
}, },
+20
View File
@@ -0,0 +1,20 @@
<template>
</template>
<script>
export default {
data() {
return {
}
},
onLoad() {
},
methods: {
}
}
</script>
+8 -2
View File
@@ -1,3 +1,5 @@
import store from '@/store'
// 获取合并的数据 // 获取合并的数据
export const mergeConfig = (_this, options) => { export const mergeConfig = (_this, options) => {
//判断url是不是链接 //判断url是不是链接
@@ -5,10 +7,14 @@ export const mergeConfig = (_this, options) => {
let config = Object.assign({ let config = Object.assign({
timeout: _this.timeout timeout: _this.timeout
}, _this.config, options); }, _this.config, options);
// 动态从 store 中获取最新的 apiUrl
const dynamicApiUrl = store.getters.apiUrl || _this.baseUrl;
if (options.method == "FILE") { if (options.method == "FILE") {
config.url = urlType ? options.url : _this.fileUrl + options.url; config.url = urlType ? options.url : (dynamicApiUrl || _this.fileUrl) + options.url;
} else { } else {
config.url = urlType ? options.url : _this.baseUrl + options.url; config.url = urlType ? options.url : dynamicApiUrl + options.url;
} }
//请求头 //请求头
if (options.header) { if (options.header) {
+5 -9
View File
@@ -4,16 +4,12 @@
import store from '@/store' import store from '@/store'
import request from './request' import request from './request'
// 后端api地址
// const apiUrl = 'http://' + store.getters.apiUrl
const apiUrl = 'http://ectms.dev.opmonitor.com'
// 可以new多个request来支持多个域名请求 // 可以new多个request来支持多个域名请求
const $http = new request({ const $http = new request({
// 接口请求地址 // 接口请求地址(初始值,实际使用时会从 store 动态读取)
baseUrl: apiUrl, baseUrl: '',
// 服务器本地上传文件地址 // 服务器本地上传文件地址(初始值,实际使用时会从 store 动态读取)
fileUrl: apiUrl, fileUrl: '',
// 服务器上传图片默认url // 服务器上传图片默认url
defaultUploadUrl: 'upload/image', defaultUploadUrl: 'upload/image',
// 设置请求头(如果使用报错跨域问题,可能是content-type请求类型和后台那边设置的不一致) // 设置请求头(如果使用报错跨域问题,可能是content-type请求类型和后台那边设置的不一致)
@@ -27,7 +23,7 @@ const $http = new request({
// 是否自动提示错误 // 是否自动提示错误
isPrompt: true, isPrompt: true,
// 是否显示加载动画 // 是否显示加载动画
load: true, load: false,
// 是否使用数据工厂 // 是否使用数据工厂
isFactory: true isFactory: true
} }