LaveyD 7 ヶ月 前
コミット
1da010e43f

+ 128 - 0
src/api/HuashiReaderWsApi.js

@@ -0,0 +1,128 @@
+const Store = require('electron-store')
+const localStore = new Store()
+
+export default class HuashiReaderWsApi {
+  constructor () {
+    this.statusArr = [
+      { state: 0, value: '正在连接' },
+      { state: 1, value: '已建立连接' },
+      { state: 2, value: '正在关闭连接' },
+      { state: 3, value: '已关闭连接' }
+    ]
+    this.websockets = null
+    this.isConnected = false
+    this.messageListeners = [] // Listeners for incoming messages
+    this.connectCallback = null
+  }
+
+  // 建立连接
+  connect (cb) {
+    this.connectCallback = cb
+    let url = localStore.get('idDeviceUrl') || ''
+
+    if (!url.startsWith('ws://')) {
+      url = url.replace('http://', 'ws://').replace('https://', 'ws://')
+
+      if (!url) {
+        url = 'ws:127.0.0.1:8800'
+      }
+    }
+    if (!this.isConnected) {
+      this.websockets = new WebSocket(url)
+
+      this.websockets.onopen = () => this.socketChange()
+      this.websockets.onmessage = (res) => this.handleMessage(res)
+      this.websockets.onclose = () => this.socketChange()
+    } else {
+      this.closeConnect()
+    }
+  }
+
+  // 处理接收到的消息
+  handleMessage (res) {
+    // Notify all listeners about the new message
+    this.messageListeners.forEach(listener => listener(res))
+
+    if (res.data === 'failed to obtain ID card information') {
+      return false
+    }
+  }
+
+  // 添加消息监听器
+  addMessageListener (listener) {
+    if (typeof listener === 'function') {
+      this.messageListeners.push(listener)
+    }
+  }
+
+  // 移除消息监听器
+  removeMessageListener (listener) {
+    this.messageListeners = this.messageListeners.filter(l => l !== listener)
+  }
+
+  // 发送消息
+  sendMessage (message) {
+    if (this.isConnected && this.websockets) {
+      this.websockets.send(message)
+    }
+  }
+
+  // 读取身份证(带超时)
+  timeOutReadIDCard (timeout) {
+    this.sendCommand('02', `timeout=${timeout}`)
+  }
+
+  // 读取身份证
+  readIDCard (timeout) {
+    this.sendCommand('03', `timeout=${timeout}`)
+  }
+
+  // 读取身份证(无判断)
+  readIDCardNoJudge (timeout) {
+    this.sendCommand('04', `timeout=${timeout}`)
+  }
+
+  // 读取 SAM ID
+  readSAMID (timeout) {
+    this.sendCommand('05', `timeout=${timeout}`)
+  }
+
+  // 发送命令
+  sendCommand (command, parameters) {
+    const val = `${command}?${parameters}`
+    this.sendMessage(val)
+  }
+
+  // 处理 socket 状态变化
+  socketChange () {
+    const state = this.websockets.readyState
+
+    if (state === 1) {
+      this.isConnected = true
+    } else if (state === 3) {
+      this.isConnected = false
+    }
+
+    if (this.connectCallback && typeof this.connectCallback === 'function') {
+      this.connectCallback(this.isConnected)
+    }
+  }
+
+  // 获取连接状态
+  getConnectionStatus () {
+    return this.isConnected
+  }
+
+  // 关闭连接
+  closeConnect () {
+    if (this.websockets) {
+      this.websockets.close()
+    }
+    this.clear()
+  }
+
+  // 清理数据
+  clear () {
+    this.messageListeners = []
+  }
+}

+ 23 - 1
src/pages/config/index.vue

@@ -241,6 +241,10 @@
                   label="华视身份证读卡器"
                   value="hs">
                 </el-option>
+                <el-option
+                  label="华视身份证读卡器(CVR-100N)"
+                  value="hs-ws">
+                </el-option>
                 <el-option
                   label="精伦身份证读卡器"
                   value="jl">
@@ -273,7 +277,7 @@
             <el-form-item label="身份证阅读器web接口地址">
               <el-input
                 v-model="form.idDeviceUrl"
-                placeholder="一般不用设置; 华视:http://127.0.0.1:19196;新中新:http://localhost:8989"></el-input>
+                :placeholder="idDevicePlaceholder"></el-input>
             </el-form-item>
           </el-form>
         </el-tab-pane>
@@ -392,6 +396,24 @@ export default {
   computed: {
     scenicName () {
       return this.$localStore.get('scenicName') || this.$store.state.user.scenicName
+    },
+    idDevicePlaceholder () {
+      let pc = ''
+      switch (this.form.idDevice) {
+        case 'hs':
+          pc = '一般不用设置; 华视:http://127.0.0.1:19196'
+          break
+        case 'hs-ws':
+          pc = '一般不用设置; 华视:ws://127.0.0.1:8800'
+          break
+        case 'xzx':
+          pc = '一般不用设置; 新中新:http://localhost:8989'
+          break
+        default:
+          pc = '一般不用设置'
+      }
+
+      return pc
     }
   },
   data () {

+ 1 - 1
src/pages/member/memberTradeLog.vue

@@ -318,7 +318,7 @@
         :page-sizes="[10, 20, 50, 100]"
         :page-size="form.pageSize"
         @size-change="handleSizeChange"
-        @current-change="getList"
+        @current-change="getList()"
         layout="total, sizes, prev, pager, next, jumper"
         :total="total"
       >

+ 2 - 2
src/pages/queryReport/OrderStatistic.vue

@@ -330,11 +330,11 @@ import Tip from '@/components/Tip'
 import moment from 'moment'
 
 const groupKeys = [
+  { value: 'adminName', label: '售票员', prop: 'adminName' },
   { value: 'ticketTypeName', label: '票种', prop: 'ticketTypeName' },
+  { value: 'payChannel', label: '支付方式' },
   { value: 'unitPrice', label: '单价', prop: 'unitPrice' },
-  { value: 'adminName', label: '售票员', prop: 'adminName' },
   { value: 'otaSourceName', label: '销售渠道' },
-  { value: 'payChannel', label: '支付方式' },
   { value: 'team', label: '团体' },
   { value: 'guide', label: '导游' },
   { value: 'orderDateDay', label: '统计日期' },

+ 5 - 2
src/pages/queryReport/salesQuery.vue

@@ -477,7 +477,7 @@
         :page-sizes="[10, 20, 50, 100]"
         :page-size="form.pageSize"
         @size-change="handleSizeChange"
-        @current-change="getOrderList"
+        @current-change="getOrderList()"
         layout="total, sizes, prev, pager, next, jumper"
         :total="total"
       >
@@ -1618,10 +1618,13 @@ export default {
     // 如果存在查询条件,则设置到组件的数据中
       this.form = searchParams // 记住上次搜索条件
     }
+    // this.getSaleChannelList()
+    // this.getOrderList()
+  },
+  mounted () {
     this.getSaleChannelList()
     this.getOrderList()
   },
-  mounted () {},
   methods: {
     getPayStatus,
     hasPermission (key) {

+ 43 - 3
src/pages/sellManage/common/TouristList.vue

@@ -280,6 +280,7 @@ import { setTourist } from '@/pages/common'
 import { verifyId, verifyPhone, verifyId_HUZHAO, verifyId_GANGAO, verifyId_TAIBAO } from '@/utils/validate'
 import { getIdInfo } from '@/api/ZTKReaderApi'
 import { getReadCert } from '@/api/JinlunReaderApi'
+import HuashiReaderWsApi from '@/api/HuashiReaderWsApi'
 import donsee from '@/api/donsee'
 import { IDENTIFY_TYPES } from '@/const'
 import GetFace from '@/components/GetFace'
@@ -389,7 +390,8 @@ export default {
       },
       papersOption: IDENTIFY_TYPES,
       uploadUrl: '',
-      showUpload: true
+      showUpload: true,
+      hsWsApi: null
     }
   },
   methods: {
@@ -404,6 +406,8 @@ export default {
         this.startReadCard()
         this.getAge()
       })
+
+      this.hsWsApi = new HuashiReaderWsApi()
     },
 
     // 获取社保卡信息
@@ -448,7 +452,7 @@ export default {
           case 'tecsun':
             data = await getTecsun(this)
             if (data) {
-              setTourist(this.touristData, 1, { Name: data.name, IDNumber: data.idNum })
+              setTourist(this.touristData, 1, { guestName: data.name, IDNumber: data.idNum })
             }
             break
           case 'zk':
@@ -465,7 +469,7 @@ export default {
               if (res.data.resultFlag === 0) {
                 readcard().then(res => {
                   if (res.data.resultFlag === 0) {
-                    setTourist(this.touristData, 1, { Name: res.data.partyName, IDNumber: res.data.certNumber })
+                    setTourist(this.touristData, 1, { guestName: res.data.partyName, IDNumber: res.data.certNumber })
 
                     closeDevice()
                   }
@@ -476,6 +480,40 @@ export default {
             }).catch(e => {
               this.message = '身份证读卡器暂时无法使用,请检查;关闭弹窗后重试'
             })
+            break
+          case 'hs-ws':
+            if (!this.hsWsApi) return
+            if (this.hsWsApi.isConnected) {
+              this.hsWsApi.addMessageListener((res) => {
+                console.log(res, '11212')
+                if (res.data === 'failed to obtain ID card information') {
+                  this.message = '读取失败,请重试'
+                  this.getIdInfo()
+                  return
+                }
+
+                const alldata = res.data.split('|')
+                console.log(alldata)
+
+                if (alldata.length >= 17) {
+                  setTourist(this.touristData, 1, { Name: alldata[3], IDNumber: alldata[8] })
+                  this.hsWsApi.closeConnect()
+                }
+              })
+
+              this.hsWsApi.readIDCard(1500)
+            } else {
+              this.hsWsApi.closeConnect()
+              this.hsWsApi.connect((isConnected) => {
+                if (isConnected) {
+                  this.message = '身份证读卡器已连接'
+                  // this.timer && clearTimeout(this.timer)
+                } else {
+                  this.message = '身份证读卡器暂时无法使用,请检查;关闭弹窗后重试'
+                }
+              })
+            }
+
             break
           case 'xzx':
             readcard_xzx().then(res => {
@@ -541,6 +579,8 @@ export default {
       if (this.deviceName === 'donsee-100R') {
         this.$store.dispatch('stopAutoReadIDCard')
       }
+
+      this.hsWsApi && this.hsWsApi.closeConnect()
     },
     validateTourist () {
       // 验证游客信息

+ 2 - 0
src/pages/sellManage/common/confirmMixin.js

@@ -339,6 +339,7 @@ export default {
     handleCreateSuccess (params, order) {
       this.$message.success('出票成功')
       this.submitDisable = false
+      this.payCode = ''
       // 获取订单详情
       // 自动打印
       getSingleOrder(order?.id).then(async order => {
@@ -409,6 +410,7 @@ export default {
       if (val) {
         this.$nextTick(() => {
           if (this.$refs.payCodeInputRef) {
+            this.payCode = ''
             this.$refs.payCodeInputRef.focus()
           }
         })

+ 41 - 1
src/pages/sellManage/preOrder/TouristList.vue

@@ -236,6 +236,7 @@ import { setTourist } from '@/pages/common'
 import { verifyId, verifyPhone, verifyId_HUZHAO, verifyId_GANGAO, verifyId_TAIBAO } from '@/utils/validate'
 import { getIdInfo } from '@/api/ZTKReaderApi'
 import { getReadCert } from '@/api/JinlunReaderApi'
+import HuashiReaderWsApi from '@/api/HuashiReaderWsApi'
 import donsee from '@/api/donsee'
 import { papersType } from '@/assets/staticData'
 import GetFace from '@/components/GetFace'
@@ -320,7 +321,8 @@ export default {
         }
       }),
       uploadUrl: '',
-      showUpload: true
+      showUpload: true,
+      hsWsApi: null
     }
   },
   methods: {
@@ -339,6 +341,8 @@ export default {
         //   travellerType: extraInfo.travellers.find(traveller => tourist.guestIdentify && tourist.guestIdentify.length && traveller.idNum === tourist.guestIdentify)?.travellerType || 0
         // }))
       })
+
+      this.hsWsApi = new HuashiReaderWsApi()
     },
 
     // 获取社保卡信息
@@ -411,6 +415,40 @@ export default {
             }).catch(e => {
               this.message = '身份证读卡器暂时无法使用,请检查;关闭弹窗后重试'
             })
+            break
+          case 'hs-ws':
+            if (!this.hsWsApi) return
+            if (this.hsWsApi.isConnected) {
+              this.hsWsApi.addMessageListener((res) => {
+                console.log(res, '11212')
+                if (res.data === 'failed to obtain ID card information') {
+                  this.message = '读取失败,请重试'
+                  this.getIdInfo()
+                  return
+                }
+
+                const alldata = res.data.split('|')
+                console.log(alldata)
+
+                if (alldata.length >= 17) {
+                  setTourist(this.touristData, 1, { Name: alldata[3], IDNumber: alldata[8] })
+                  this.hsWsApi.closeConnect()
+                }
+              })
+
+              this.hsWsApi.readIDCard(1500)
+            } else {
+              this.hsWsApi.closeConnect()
+              this.hsWsApi.connect((isConnected) => {
+                if (isConnected) {
+                  this.message = '身份证读卡器已连接'
+                  // this.timer && clearTimeout(this.timer)
+                } else {
+                  this.message = '身份证读卡器暂时无法使用,请检查;关闭弹窗后重试'
+                }
+              })
+            }
+
             break
           case 'xzx':
             readcard_xzx().then(res => {
@@ -474,6 +512,8 @@ export default {
       if (this.deviceName === 'donsee-100R') {
         this.$store.dispatch('stopAutoReadIDCard')
       }
+
+      this.hsWsApi && this.hsWsApi.closeConnect()
     },
     handleSave: debounce(1000, true, function () {
       if (this.checkId) {