|
|
@@ -21,6 +21,7 @@
|
|
|
<div class="col time">时间</div>
|
|
|
<div class="col operator">操作人</div>
|
|
|
<div class="col content">操作内容</div>
|
|
|
+ <div class="col status">操作状态</div>
|
|
|
</div>
|
|
|
|
|
|
<!-- 表格主体 -->
|
|
|
@@ -39,57 +40,65 @@
|
|
|
<div class="col time">{{ item.operationTime }}</div>
|
|
|
<div class="col operator">{{ item.operatorName }}</div>
|
|
|
<div class="col content">{{ item.deliveryNo }}</div>
|
|
|
+ <div class="col status" :style="{ color: item.isPush ? '#333' : '#FF0202FF'}" @click="_rePush(item)">
|
|
|
+ {{ item.isPush ? '已上传' : '上传失败' }}
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</van-list>
|
|
|
</div>
|
|
|
</van-col>
|
|
|
</van-row>
|
|
|
<van-button class="add" icon="setting-o" type="primary" @click="_openSetting" />
|
|
|
- <van-dialog
|
|
|
- v-model:show="setting.show"
|
|
|
- title="设置"
|
|
|
- class="setting-dialog"
|
|
|
- show-cancel-button
|
|
|
- :before-close="_verifyMac"
|
|
|
- @confirm="_saveMac"
|
|
|
- @closed="_closeSetting"
|
|
|
- width="380px">
|
|
|
-
|
|
|
- <van-notice-bar
|
|
|
- wrapable
|
|
|
- left-icon="volume-o"
|
|
|
- :scrollable="false"
|
|
|
- :text="hintMessage"
|
|
|
- />
|
|
|
-
|
|
|
- <van-cell-group inset>
|
|
|
- <van-field
|
|
|
- v-model="setting.mac"
|
|
|
- label="MAC地址"
|
|
|
- placeholder="请输入MAC地址"
|
|
|
+ <van-sticky>
|
|
|
+ <van-dialog
|
|
|
+ v-model:show="setting.show"
|
|
|
+ title="设置"
|
|
|
+ class="setting-dialog"
|
|
|
+ show-cancel-button
|
|
|
+ :before-close="_verifyMac"
|
|
|
+ @confirm="_saveMac"
|
|
|
+ @closed="_closeSetting"
|
|
|
+ width="380px">
|
|
|
+
|
|
|
+ <van-notice-bar
|
|
|
+ wrapable
|
|
|
+ left-icon="volume-o"
|
|
|
+ :scrollable="false"
|
|
|
+ :text="hintMessage"
|
|
|
/>
|
|
|
- <van-field
|
|
|
- v-model="setting.password"
|
|
|
- type="password"
|
|
|
- label="密码"
|
|
|
- placeholder="设置密码"
|
|
|
- />
|
|
|
- </van-cell-group>
|
|
|
|
|
|
- <van-notice-bar color="#1989fa" background="#ecf9ff" style="font-size: 16px; padding-left: 10px" left-icon="info-o">
|
|
|
- {{ versionName }}
|
|
|
- </van-notice-bar>
|
|
|
- </van-dialog>
|
|
|
+ <van-cell-group inset>
|
|
|
+ <van-field
|
|
|
+ v-model="setting.mac"
|
|
|
+ label="MAC地址"
|
|
|
+ placeholder="请输入MAC地址"
|
|
|
+ />
|
|
|
+ <van-field
|
|
|
+ v-model="setting.password"
|
|
|
+ type="password"
|
|
|
+ label="密码"
|
|
|
+ placeholder="设置密码"
|
|
|
+ />
|
|
|
+ </van-cell-group>
|
|
|
+
|
|
|
+ <van-notice-bar color="#1989fa" background="#ecf9ff" @click="checkUpdate"
|
|
|
+ style="font-size: 16px; padding-left: 10px" left-icon="info-o">
|
|
|
+ {{ versionName }} (点击检查更新)
|
|
|
+ </van-notice-bar>
|
|
|
+ </van-dialog>
|
|
|
+ </van-sticky>
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
import { onMounted, onUnmounted, ref } from 'vue'
|
|
|
import { closeListener, openListener, scanInit } from '@/utils/keydownListener'
|
|
|
-import { getVersionName, saveUserId, getUserId, scanSuccess, scanError, scanRepeat, saveMacAddress, readMacAddress, pageDelivery, addDelivery } from '@/utils/android'
|
|
|
+import { scanSuccess, scanError } from '@/utils/android'
|
|
|
+import { getVersionName, checkUpdate, saveUserId, getUserId, scanRepeat, saveMacAddress,
|
|
|
+ readMacAddress, pageDelivery, addDelivery, updateDeliveryPushFail, markAsPushed } from '@/utils/androidPiece'
|
|
|
import { showNotify } from 'vant'
|
|
|
-import { getUserIdByCert, getUserNameById } from '@/api/login/index.ts'
|
|
|
-import { receive } from '@/api/scan/index.ts'
|
|
|
-import { formatDateTime } from '@/utils/date.ts'
|
|
|
+import { getUserIdByCert, getUserNameById } from '@/api/login/index'
|
|
|
+import { receive } from '@/api/scan/index'
|
|
|
+import { formatDateTime } from '@/utils/date'
|
|
|
|
|
|
// 在输入对话框或界面中添加提示文本
|
|
|
const hintMessage = ref(`请前往:设置 → 关于平板电脑 → 设备WLAN MAC 地址 长按复制并粘贴到此处。`);
|
|
|
@@ -116,12 +125,13 @@ onMounted(() => {
|
|
|
mac.value = readMacAddress()
|
|
|
const userId = getUserId()
|
|
|
if (userId) {
|
|
|
- _handlerScan(userId)
|
|
|
+ userInfo.value.userId = userId
|
|
|
+ getUserName(userId)
|
|
|
}
|
|
|
if (mac.value) {
|
|
|
_openScan()
|
|
|
} else {
|
|
|
- setting.value.show = true
|
|
|
+ _openSetting()
|
|
|
}
|
|
|
// ip
|
|
|
fetchIP()
|
|
|
@@ -136,6 +146,7 @@ const _openScan = () => {
|
|
|
}
|
|
|
const _handlerScan = (code) => {
|
|
|
console.log(code)
|
|
|
+ code = fixDuplicateText(code)
|
|
|
// 校验扫描的是否为登录二维码
|
|
|
const regex = /\{"sign":"([^"]*)",\s*"identity":(\d+)\}/;
|
|
|
if (code !== null && regex.test(code)) {
|
|
|
@@ -146,13 +157,7 @@ const _handlerScan = (code) => {
|
|
|
getUserIdByCert({sign: sign, identity: identity}).then(res => {
|
|
|
if (res && res.data) {
|
|
|
userInfo.value.userId = res.data
|
|
|
- getUserNameById(res.data).then(res => {
|
|
|
- if (res && res.data) {
|
|
|
- saveUserId(userInfo.value.userId)
|
|
|
- userInfo.value.name = res.data
|
|
|
- showNotify({ type: 'success', style: 'font-size: 30px !important;height:50px', message: '登录成功!' });
|
|
|
- }
|
|
|
- })
|
|
|
+ getUserName(res.data)
|
|
|
} else {
|
|
|
showNotify({ type: 'danger', style: 'font-size: 30px !important;height:50px', message: '登录失败!' });
|
|
|
}
|
|
|
@@ -194,7 +199,7 @@ const _handlerScan = (code) => {
|
|
|
return
|
|
|
}
|
|
|
message.value = ''
|
|
|
- const dto = { deliveryNo: code, machine: mac.value, operator: userInfo.value.userId, operationTime: currentTime, operatorName: userInfo.value.name }
|
|
|
+ const dto = { deliveryNo: code, machine: mac.value, operator: userInfo.value.userId, operationTime: currentTime, operatorName: userInfo.value.name, isPush: true }
|
|
|
receive(dto).then(res => {
|
|
|
console.log(res)
|
|
|
scanSuccess()
|
|
|
@@ -203,11 +208,53 @@ const _handlerScan = (code) => {
|
|
|
}).catch(err => {
|
|
|
console.log(err)
|
|
|
scanError()
|
|
|
+ updateDeliveryPushFail(code)
|
|
|
+ dto.isPush = false
|
|
|
+ list.value.unshift(dto)
|
|
|
showNotify({ type: 'danger', style: 'font-size: 30px !important;height:50px', message: `扫描失败!${err.message}` });
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+function fixDuplicateText(input) {
|
|
|
+ // 改进版正则表达式(支持任意字符且精确匹配完全重复)
|
|
|
+ const regex = /^(.+?)\1$/; // 非贪婪模式防止误匹配
|
|
|
+ const match = input.match(regex);
|
|
|
+ // 返回处理逻辑
|
|
|
+ return match ? match[1] : input;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+const _rePush = (item) => {
|
|
|
+ if (!item || item.isPush) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ const dto = { deliveryNo: item.deliveryNo, machine: item.machine, operator: item.operator, operationTime: item.operationTime }
|
|
|
+ receive(dto).then(res => {
|
|
|
+ const result = markAsPushed(item.deliveryNo)
|
|
|
+ console.log(result)
|
|
|
+ if (result === 1) {
|
|
|
+ item.isPush = true
|
|
|
+ showNotify({ type: 'success', style: 'font-size: 30px !important;height:50px', message: '推送成功!' });
|
|
|
+ } else {
|
|
|
+ showNotify({ type: 'danger', style: 'font-size: 30px !important;height:50px', message: '推送失败!' });
|
|
|
+ }
|
|
|
+ }).catch(err => {
|
|
|
+ scanError()
|
|
|
+ showNotify({ type: 'danger', style: 'font-size: 30px !important;height:50px', message: `扫描失败!${err.message}` });
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+const getUserName = (userId) => {
|
|
|
+ getUserNameById(userId).then(res => {
|
|
|
+ if (res && res.data) {
|
|
|
+ saveUserId(userInfo.value.userId)
|
|
|
+ userInfo.value.name = res.data
|
|
|
+ showNotify({ type: 'success', style: 'font-size: 30px !important;height:50px', message: '登录成功!' });
|
|
|
+ }
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
const versionName = ref('')
|
|
|
const _openSetting = () => {
|
|
|
closeListener()
|
|
|
@@ -281,6 +328,8 @@ const onLoad = () => {
|
|
|
const result = pageDelivery(page.value, size.value)
|
|
|
if (result.size < size.value) {
|
|
|
finished.value = true;
|
|
|
+ } else {
|
|
|
+ page.value += 1
|
|
|
}
|
|
|
list.value.push(...result)
|
|
|
loading.value = false;
|
|
|
@@ -371,6 +420,10 @@ span
|
|
|
min-width: 0 /* 允许内容换行 */
|
|
|
white-space: normal /* 允许换行 */
|
|
|
|
|
|
+.status
|
|
|
+ flex: 0 0 50px
|
|
|
+ width: 50px
|
|
|
+
|
|
|
/* 确保表体中的单元格与表头对齐 */
|
|
|
:deep(.van-list)
|
|
|
.van-cell
|