黄伟杰 2 weeks ago
commit 860aa3c32d

@ -1,8 +1,9 @@
<!DOCTYPE html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" href="/favicon.ico" />
<link rel="stylesheet" type="text/css" media="print" href="/print-lock.css" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta
@ -146,6 +147,34 @@
</div>
</div>
</div>
<!-- Edge 兼容hiprint socket.io 连接添加 polling 降级策略,防止 WebSocket-only 连接在 Edge 下失败 -->
<script>
(function() {
try {
if (window.__hiprintEdgeFixApplied) return;
var _io = window.io;
Object.defineProperty(window, 'io', {
configurable: true,
enumerable: true,
get: function() { return _io; },
set: function(fn) {
if (typeof fn === 'function' && fn !== _io && !fn.__hiprintPatched) {
var _orig = fn;
_io = function(url, opts) {
opts = Object.assign({}, opts || {});
opts.transports = ['websocket', 'polling'];
return _orig(url, opts);
};
_io.__hiprintPatched = true;
} else {
_io = fn;
}
}
});
window.__hiprintEdgeFixApplied = true;
} catch(e) { console.warn('[hiprint-fix]', e); }
})();
</script>
<script type="module" src="/src/main.ts"></script>
</body>
</html>

@ -7,6 +7,7 @@
"scripts": {
"i": "pnpm install",
"dev": "vite --mode env.local",
"dev:local": "cross-env VITE_BASE_URL=http://localhost:48081 vite --mode env.local",
"pro": "vite --mode env.prod",
"dev-server": "vite --mode dev",
"ts:check": "vue-tsc --noEmit",
@ -102,6 +103,7 @@
"bpmn-js": "^17.9.2",
"bpmn-js-properties-panel": "5.23.0",
"consola": "^3.2.3",
"cross-env": "^10.1.0",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-define-config": "^2.1.0",

@ -0,0 +1,46 @@
import request from '@/config/axios'
// 打印机配置 VO
export interface ConfigVO {
id: number // 主键ID
hostName: string // 主机名如PACKING-PC-01不可修改
systemPrinterName: string // 系统打印机名称,关联下拉选项
isDefault: boolean // 是否默认0-否1-是
isEnabled: boolean // 是否启用0-禁用1-启用
remark: string // 备注,记录打印机用途说明,用户不可修改
createdAt: Date // 创建时间
updatedAt: Date // 更新时间
}
// 打印机配置 API
export const ConfigApi = {
// 查询打印机配置分页
getConfigPage: async (params: any) => {
return await request.get({ url: `/printer/config/page`, params })
},
// 查询打印机配置详情
getConfig: async (id: number) => {
return await request.get({ url: `/printer/config/get?id=` + id })
},
// 新增打印机配置
createConfig: async (data: ConfigVO) => {
return await request.post({ url: `/printer/config/create`, data })
},
// 修改打印机配置
updateConfig: async (data: ConfigVO) => {
return await request.put({ url: `/printer/config/update`, data })
},
// 删除打印机配置
deleteConfig: async (id: number) => {
return await request.delete({ url: `/printer/config/delete?id=` + id })
},
// 导出打印机配置 Excel
exportConfig: async (params) => {
return await request.download({ url: `/printer/config/export-excel`, params })
},
}

@ -3309,6 +3309,24 @@ export default {
validatorTypeRequired: 'Template type can not be empty',
design: 'Design',
designTitle: 'Template Design'
},
PrintConfig: {
moduleName: 'Printer Config',
currentHostName: 'Current Host Name',
unknownHostName: 'Not detected',
currentHostTip: 'This page only displays and manages printer configurations for the current host.',
hostName: 'Host Name',
systemPrinterName: 'Printer Name',
defaultStatus: 'Is Default',
isEnable: 'Is Enabled',
remark: 'remark',
createTime: 'Create Time',
updateTime: 'Update Time',
operate: 'Operate',
placeholderHostName: 'Please input host name',
placeholderSystemPrinterName: 'Please input printer name',
placeholderRemark: 'Please input printer remark',
testPrint:'Test Print'
}
},
QualityManagement: {

@ -2795,6 +2795,31 @@ export default {
validatorTypeRequired: '模板类型不能为空',
design: '配置',
designTitle: '模板配置'
},
PrintConfig: {
moduleName: '打印机配置',
currentHostName: '当前主机名',
unknownHostName: '未获取到',
currentHostTip: '当前页面仅展示和管理当前主机的打印机配置。',
hostName: '主机名',
systemPrinterName: '打印机名称',
defaultStatus: '是否默认',
isEnable: '是否启用',
remark: '备注',
createTime: '创建时间',
updateTime: '更新时间',
operate: '操作',
placeholderHostName: '请输入主机名',
placeholderSystemPrinterName: '请输入系统打印机名称',
placeholderTemplateType: '请选择模板类型',
placeholderTemplateJson: '请输入模板JSON内容',
placeholderRemark: '请输入备注',
validatorCodeRequired: '模板编码不能为空',
validatorNameRequired: '模板名称不能为空',
validatorTypeRequired: '模板类型不能为空',
design: '配置',
designTitle: '模板配置',
testPrint:'测试打印'
}
},
QualityManagement: {

@ -0,0 +1,265 @@
<template>
<Dialog :title="dialogTitle" v-model="dialogVisible">
<el-form
ref="formRef"
:model="formData"
:rules="formRules"
label-width="120px"
v-loading="formLoading"
>
<el-form-item :label="t('TemplateManagement.PrintConfig.hostName')" prop="hostName">
<el-input v-model="formData.hostName" :disabled="true" :placeholder="t('TemplateManagement.PrintConfig.placeholderHostName')" />
</el-form-item>
<el-form-item :label="t('TemplateManagement.PrintConfig.systemPrinterName')" prop="systemPrinterName">
<!-- <el-input v-model="formData.systemPrinterName" :placeholder="t('TemplateManagement.PrintConfig.placeholderSystemPrinterName')" />-->
<el-select
v-model="formData.systemPrinterName"
clearable
filterable
:placeholder="t('TemplateManagement.PrintConfig.placeholderSystemPrinterName')"
class="hiprint-printer-select"
>
<el-option
v-for="printer in printerList"
:key="printer.name"
:label="printer.name"
:value="printer.name"
/>
</el-select>
</el-form-item>
<el-form-item :label="t('TemplateManagement.PrintConfig.defaultStatus')" prop="isDefault">
<el-switch v-model="formData.isDefault" />
</el-form-item>
<el-form-item :label="t('TemplateManagement.PrintConfig.isEnable')" prop="isEnabled">
<el-switch v-model="formData.isEnable" />
</el-form-item>
<el-form-item :label="t('TemplateManagement.PrintConfig.remark')" prop="remark">
<el-input v-model="formData.remark" :placeholder="t('TemplateManagement.PrintConfig.placeholderRemark')" />
</el-form-item>
</el-form>
<template #footer>
<el-button @click="handleClientPrint" type="primary" plain :disabled="formLoading">{{ t('TemplateManagement.PrintConfig.testPrint') }}</el-button>
<el-button @click="submitForm" type="primary" :disabled="formLoading">{{ t('common.ok') }}</el-button>
<el-button @click="dialogVisible = false">{{ t('common.cancel') }}</el-button>
</template>
</Dialog>
</template>
<script setup lang="ts">
import { ConfigApi, ConfigVO } from '@/api/mes/printconfig/index'
import {
autoConnect,
defaultElementTypeProvider,
hiwebSocket,
hiprint
} from 'vue-plugin-hiprint'
/** 打印机配置 表单 */
defineOptions({ name: 'ConfigForm' })
const { t } = useI18n() //
const message = useMessage() //
const printerList = ref<Array<{ name: string; [key: string]: any }>>([])
const dialogVisible = ref(false) //
const dialogTitle = ref('') //
const formLoading = ref(false) // 12
const formType = ref('') // create - update -
const formData = ref({
id: undefined,
hostName: undefined,
systemPrinterName: undefined,
isDefault: undefined,
isEnabled: undefined,
remark: undefined,
createdAt: undefined,
updatedAt: undefined,
})
const formRules = reactive({
hostName: [{ required: false, message: '主机名如PACKING-PC-01不可修改不能为空', trigger: 'blur' }],
systemPrinterName: [{ required: true, message: '系统打印机名称,关联下拉选项不能为空', trigger: 'blur' }],
isDefault: [{ required: false, message: '是否默认0-否1-是不能为空', trigger: 'blur' }],
isEnabled: [{ required: false, message: '是否启用0-禁用1-启用不能为空', trigger: 'blur' }],
createdAt: [{ required: false, message: '创建时间不能为空', trigger: 'blur' }],
updatedAt: [{ required: false, message: '更新时间不能为空', trigger: 'blur' }],
})
const formRef = ref() // Ref
let hiprintTemplate: any
const selectedPrinter = ref('')
const clientConnected = ref(false)
const clientPrinting = ref(false)
let hiprintInited = false
let printEventBound = false
let autoConnectTried = false
const clientConnecting = ref(false)
const clientHostStorageKey = 'hiprint-client-host'
const defaultClientHost = 'http://192.168.2.58:17521'
let item = localStorage.getItem(clientHostStorageKey);
const clientHost = ref(localStorage.getItem(clientHostStorageKey) || defaultClientHost)
const getHiwebSocket = () => {
return ((hiwebSocket as any) || (window as any).hiwebSocket) as any
}
const syncClientState = (printersFromCallback?: Array<{ name: string; [key: string]: any }>) => {
const socket = getHiwebSocket()
clientConnected.value = !!socket?.opened
const printers = printersFromCallback || hiprintTemplate?.getPrinterList?.() || socket?.printerList || []
printerList.value = Array.isArray(printers) ? printers : []
if (selectedPrinter.value && !printerList.value.some((printer) => printer.name === selectedPrinter.value)) {
selectedPrinter.value = ''
}
}
/** 打开弹窗 */
const open = async (type: string, host: string, id?: number) => {
dialogVisible.value = true
dialogTitle.value = t('action.' + type)
formType.value = type
resetForm()
formData.value.hostName = host
syncClientState()
//
if (id) {
formLoading.value = true
try {
formData.value = await ConfigApi.getConfig(id)
} finally {
formLoading.value = false
}
}
}
defineExpose({ open }) // open
/** 提交表单 */
const emit = defineEmits(['success']) // success
const submitForm = async () => {
//
await formRef.value.validate()
//
formLoading.value = true
try {
const data = formData.value as unknown as ConfigVO
if (formType.value === 'create') {
await ConfigApi.createConfig(data)
message.success(t('common.createSuccess'))
} else {
await ConfigApi.updateConfig(data)
message.success(t('common.updateSuccess'))
}
dialogVisible.value = false
//
emit('success')
} finally {
formLoading.value = false
}
}
const printData = ref({
orderNo: 'TEST-20231125-001',
customerName: '测试客户',
amount: 199.99,
address: '北京市朝阳区测试街道123号'
});
const handleClientPrint = () => {
if (!hiprintTemplate) {
return
}
syncClientState()
if (!clientConnected.value) {
connectClient()
message.warning('正在连接本地打印客户端,请连接成功后重试')
return
}
clientPrinting.value = true
try {
hiprintTemplate.print2(printData.value, {
printer: selectedPrinter.value,
title: dialogTitle.value
})
} catch (error: any) {
clientPrinting.value = false
message.error(error?.message || '本地客户端打印失败')
}
}
const applyClientHost = () => {
const socket = getHiwebSocket()
let host = normalizeClientHost()
clientHost.value = host
localStorage.setItem(clientHostStorageKey, host)
if (!socket) {
return false
}
if (socket?.host !== host) {
socket?.stop?.()
socket.host = host
}
return true
}
const normalizeClientHost = () => {
const host = clientHost.value.trim()
if (!host) {
return defaultClientHost
}
if (/^https?:\/\//i.test(host)) {
return host
}
return `http://${host}`
}
const refreshPrinterList = () => {
let item = localStorage.getItem(clientHostStorageKey);
message.success('本地打印客户端已连接'+item)
if (!clientConnected.value) {
applyClientHost()
message.warning('请先连接本地打印客户端')
return
}
const socket = getHiwebSocket()
if (typeof socket?.refreshPrinterList === 'function') {
socket.refreshPrinterList()
window.setTimeout(syncClientState, 500)
return
}
syncClientState()
}
const connectClient = () => {
ensureInit()
if (!applyClientHost()) {
message.warning('打印客户端连接对象未初始化,请刷新页面后重试')
return
}
clientConnecting.value = true
autoConnect((status: boolean, msg?: string) => {
clientConnecting.value = false
clientConnected.value = !!status
syncClientState()
if (status) {
message.success('本地打印客户端已连接')
refreshPrinterList()
return
}
message.warning(msg || '未连接到本地打印客户端,请确认 electron-hiprint 已启动')
})
}
const ensureInit = () => {
if (hiprintInited) {
return
}
hiprint.init({
host: normalizeClientHost(),
providers: [defaultElementTypeProvider()]
})
hiprintInited = true
}
/** 重置表单 */
const resetForm = () => {
formData.value = {
id: undefined,
hostName: undefined,
systemPrinterName: undefined,
isDefault: undefined,
isEnabled: undefined,
remark: undefined,
createdAt: undefined,
updatedAt: undefined,
}
formRef.value?.resetFields()
}
</script>

@ -0,0 +1,501 @@
<template>
<ContentWrap>
<div class="print-config-header">
<div class="print-config-title-row">
<div class="print-config-title">{{ t('TemplateManagement.PrintConfig.moduleName') }}</div>
<el-tag
class="print-config-host-tag"
:type="currentHostName ? 'primary' : 'info'"
effect="plain"
>
<span class="print-config-host-label">
{{ t('TemplateManagement.PrintConfig.currentHostName') }}
</span>
<span>{{ currentHostName || t('TemplateManagement.PrintConfig.unknownHostName') }}</span>
</el-tag>
</div>
<div class="print-config-tip">{{ t('TemplateManagement.PrintConfig.currentHostTip') }}</div>
</div>
<!-- 搜索工作栏 -->
<el-form
class="-mb-15px"
:model="queryParams"
ref="queryFormRef"
:inline="true"
label-width="120px"
>
<el-form-item :label="t('TemplateManagement.PrintConfig.hostName')" prop="hostName">
<el-input
v-model="queryParams.hostName"
:placeholder="t('TemplateManagement.PrintConfig.placeholderHostName')"
:clearable="!currentHostName"
:disabled="!!currentHostName"
@keyup.enter="handleQuery"
class="!w-240px"
/>
</el-form-item>
<el-form-item :label="t('TemplateManagement.PrintConfig.systemPrinterName')" prop="systemPrinterName">
<el-input
v-model="queryParams.systemPrinterName"
:placeholder="t('TemplateManagement.PrintConfig.placeholderSystemPrinterName')"
clearable
@keyup.enter="handleQuery"
class="!w-240px"
/>
</el-form-item>
<el-form-item>
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> {{ t('common.query') }}</el-button>
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> {{ t('common.reset') }}</el-button>
<el-button
type="primary"
plain
@click="openForm('create')"
v-hasPermi="['printer:config:create']"
>
<Icon icon="ep:plus" class="mr-5px" /> {{ t('action.add') }}
</el-button>
<el-button
type="success"
plain
@click="handleExport"
:loading="exportLoading"
v-hasPermi="['printer:config:export']"
>
<Icon icon="ep:download" class="mr-5px" /> {{ t('action.export') }}
</el-button>
</el-form-item>
</el-form>
</ContentWrap>
<!-- 列表 -->
<ContentWrap>
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
<!-- <el-table-column label="主键ID" align="center" prop="id" />-->
<!-- <el-table-column type="selection" width="55" fixed="left" reserve-selection />-->
<el-table-column :label="t('TemplateManagement.PrintConfig.hostName')" align="center" prop="hostName" />
<el-table-column :label="t('TemplateManagement.PrintConfig.systemPrinterName')" align="center" prop="systemPrinterName" />
<el-table-column :label="t('TemplateManagement.PrintConfig.defaultStatus')" align="center" prop="isDefault" />
<el-table-column :label="t('TemplateManagement.PrintConfig.isEnable')" align="center" prop="isEnabled" />
<el-table-column :label="t('TemplateManagement.PrintConfig.remark')" align="center" prop="remark" />
<el-table-column
:label="t('TemplateManagement.PrintConfig.createTime')"
align="center"
prop="createdAt"
:formatter="dateFormatter"
width="180px"
/>
<el-table-column
:label="t('TemplateManagement.PrintConfig.updateTime')"
align="center"
prop="updatedAt"
:formatter="dateFormatter"
width="180px"
/>
<el-table-column :label="t('TemplateManagement.PrintConfig.operate')" align="center" min-width="120px">
<template #default="scope">
<el-button
link
type="primary"
@click="openForm('update', scope.row.id)"
v-hasPermi="['printer:config:update']"
>
{{ t('action.edit') }}
</el-button>
<el-button
link
type="danger"
@click="handleDelete(scope.row.id)"
v-hasPermi="['printer:config:delete']"
>
{{ t('action.del') }}
</el-button>
</template>
</el-table-column>
</el-table>
<!-- 分页 -->
<Pagination
:total="total"
v-model:page="queryParams.pageNo"
v-model:limit="queryParams.pageSize"
@pagination="getList"
/>
</ContentWrap>
<!-- 表单弹窗添加/修改 -->
<ConfigForm ref="formRef" @success="getList" />
</template>
<script setup lang="ts">
import { autoConnect, defaultElementTypeProvider, hiprint, hiwebSocket } from 'vue-plugin-hiprint'
import { dateFormatter } from '@/utils/formatTime'
import download from '@/utils/download'
import { ConfigApi, ConfigVO } from '@/api/mes/printconfig'
import ConfigForm from './ConfigForm.vue'
/** 打印机配置 列表 */
defineOptions({ name: 'PrinterConfig' })
const message = useMessage() //
const { t } = useI18n() //
const loading = ref(true) //
const list = ref<ConfigVO[]>([]) //
const total = ref(0) //
interface QueryParams {
pageNo: number
pageSize: number
hostName?: string
systemPrinterName?: string
isDefault?: boolean
isEnabled?: boolean
remark?: string
}
const currentHostName = ref('')
const queryParams = reactive<QueryParams>({
pageNo: 1,
pageSize: 10,
hostName: undefined,
systemPrinterName: undefined,
isDefault: undefined,
isEnabled: undefined,
remark: undefined,
})
const queryFormRef = ref() //
const exportLoading = ref(false) //
const clientHostStorageKey = 'hiprint-client-host'
const defaultClientHost = 'http://127.0.0.1:17521'
let hiprintInited = false
const normalizeClientHost = () => {
const host = (localStorage.getItem(clientHostStorageKey) || defaultClientHost).trim()
if (!host) {
return defaultClientHost
}
if (/^https?:\/\//i.test(host)) {
return host
}
return `http://${host}`
}
const getHiwebSocket = () => {
return ((hiwebSocket as any) || (window as any).hiwebSocket) as any
}
const ensureHiprintInit = () => {
if (hiprintInited) {
return
}
// Edge <EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD>Ϊ hiwebSocket <EFBFBD><EFBFBD><EFBFBD>?polling <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>? // ԭ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>?transports:["websocket"]<EFBFBD><EFBFBD>Edge <EFBFBD><EFBFBD>ȫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> WebSocket <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD>
const socket = getHiwebSocket()
if (socket?.start && !socket.__transportPatched) {
const originalStart = socket.start.bind(socket)
socket.start = function (callback?: any) {
const originalIo = window.io
window.io = function (url: string, opts?: any) {
opts = opts || {}
opts.transports = ['websocket', 'polling']
return originalIo(url, opts)
}
originalStart(callback)
window.io = originalIo
}
socket.__transportPatched = true
}
hiprint.init({
host: normalizeClientHost(),
providers: [defaultElementTypeProvider()]
})
hiprintInited = true
}
const applyClientHost = () => {
const socket = getHiwebSocket()
if (!socket) {
return
}
const host = normalizeClientHost()
if (socket.host !== host) {
socket.stop?.()
socket.host = host
}
}
const sanitizeHostName = (hostName?: unknown) => {
if (typeof hostName !== 'string') {
return ''
}
const value = hostName.trim()
if (!value || /^https?:\/\//i.test(value) || /[/:\\]/.test(value)) {
return ''
}
return value
}
const extractHostName = (source?: any) => {
if (!source || typeof source !== 'object') {
return ''
}
const fields = [
'hostName',
'hostname',
'computerName',
'machineName',
'pcName',
'clientName',
'name'
]
for (const field of fields) {
const hostName = sanitizeHostName(source[field])
if (hostName) {
return hostName
}
}
return ''
}
const getActiveXComputerName = () => {
try {
const ActiveXObjectCtor = (window as any).ActiveXObject
if (!ActiveXObjectCtor) {
return ''
}
const network = new ActiveXObjectCtor('WScript.Network')
return sanitizeHostName(network?.ComputerName)
} catch {
return ''
}
}
const getSocketHostName = () => {
const socket = getHiwebSocket()
// <EFBFBD><EFBFBD><EFBFBD>ȼ<EFBFBD><EFBFBD> socket.clientInfo<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD>ӿͻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD>
const hostNameFromInfo = extractHostName(socket?.clientInfo)
if (hostNameFromInfo) {
return hostNameFromInfo
}
const clients = socket?.clients
const clientList = Array.isArray(clients) ? clients : Object.values(clients || {})
for (const client of clientList) {
const hostName =
extractHostName(client) ||
extractHostName(client?.client) ||
extractHostName(client?.clientInfo) ||
extractHostName(client?.info)
if (hostName) {
return hostName
}
}
const printerList = Array.isArray(socket?.printerList) ? socket.printerList : []
for (const printer of printerList) {
const hostName =
extractHostName(printer?.server) ||
extractHostName(printer?.client) ||
extractHostName(printer?.clientInfo) ||
extractHostName(clients?.[printer?.clientId]) ||
extractHostName(clients?.[printer?.server?.clientId])
if (hostName) {
return hostName
}
}
return ''
}
const resolveCurrentHostName = async () => {
const activeXHostName = getActiveXComputerName()
if (activeXHostName) {
return activeXHostName
}
try {
ensureHiprintInit()
applyClientHost()
const socketHostName = getSocketHostName()
if (socketHostName) {
return socketHostName
}
return await new Promise<string>((resolve) => {
let settled = false
const finish = (hostName?: string) => {
if (settled) {
return
}
settled = true
window.clearTimeout(timer)
resolve(hostName || getSocketHostName())
}
const timer = window.setTimeout(() => finish(), 3000)
const socket = getHiwebSocket()
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> socket.io ʵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD>Ӽ<EFBFBD><EFBFBD><EFBFBD> clients/clientInfo <EFBFBD>¼<EFBFBD>
if (socket?.socket?.on) {
const onClients = () => {
const hn = getSocketHostName()
if (hn) finish(hn)
}
const onClientInfo = () => {
const hn = extractHostName(socket.clientInfo) || getSocketHostName()
if (hn) finish(hn)
}
socket.socket.on('clients', onClients)
socket.socket.on('clientInfo', onClientInfo)
}
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if (socket) {
if (typeof socket.getClients === 'function') socket.getClients()
if (typeof socket.getClientInfo === 'function') socket.getClientInfo()
if (typeof socket.refreshPrinterList === 'function') socket.refreshPrinterList()
}
if (typeof hiprint.getClientInfo === 'function') {
hiprint.getClientInfo((clientInfo: any) => {
const hn = extractHostName(clientInfo)
if (hn) finish(hn)
})
}
// autoConnect <EFBFBD><EFBFBD><EFBFBD><EFBFBD> socket<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD><EFBFBD><EFBFBD> false<EFBFBD><EFBFBD><EFBFBD>ȴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӳɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> true<EFBFBD><EFBFBD>
autoConnect((status: boolean) => {
if (!status) {
return
}
getHiwebSocket()?.refreshPrinterList?.()
window.setTimeout(() => finish(getSocketHostName()), 300)
})
})
} catch {
return ''
}
}
const initCurrentHostName = async () => {
const hostName = await resolveCurrentHostName()
if (hostName) {
currentHostName.value = hostName
queryParams.hostName = hostName
}
}
/** 查询列表 */
const getList = async () => {
loading.value = true
try {
const data = await ConfigApi.getConfigPage(queryParams)
list.value = data.list
total.value = data.total
} finally {
loading.value = false
}
}
/** 搜索按钮操作 */
const handleQuery = () => {
if (currentHostName.value) {
queryParams.hostName = currentHostName.value
}
queryParams.pageNo = 1
getList()
}
/** 重置按钮操作 */
const resetQuery = () => {
queryFormRef.value.resetFields()
queryParams.hostName = currentHostName.value || undefined
handleQuery()
}
/** 添加/修改操作 */
const formRef = ref()
const openForm = (type: string, id?: number) => {
let host = normalizeClientHost();
formRef.value.open(type,host, id)
}
/** 删除按钮操作 */
const handleDelete = async (id: number) => {
try {
//
await message.delConfirm()
//
await ConfigApi.deleteConfig(id)
message.success(t('common.delSuccess'))
//
await getList()
} catch {}
}
/** 导出按钮操作 */
const handleExport = async () => {
try {
//
await message.exportConfirm()
//
exportLoading.value = true
const data = await ConfigApi.exportConfig(queryParams)
download.excel(data, '打印机配置.xls')
} catch {
} finally {
exportLoading.value = false
}
}
/** 初始化 **/
onMounted(async () => {
await initCurrentHostName()
getList()
})
</script>
<style scoped lang="scss">
.print-config-header {
margin-bottom: 22px;
}
.print-config-title-row {
display: flex;
align-items: center;
gap: 12px;
flex-wrap: wrap;
}
.print-config-title {
color: var(--el-text-color-primary);
font-size: 28px;
font-weight: 700;
line-height: 1.25;
}
.print-config-host-tag {
height: 30px;
padding: 0 10px;
border-radius: 4px;
font-size: 14px;
font-weight: 600;
}
.print-config-host-label {
font-weight: 700;
}
.print-config-tip {
margin-top: 8px;
color: var(--el-text-color-secondary);
font-size: 14px;
line-height: 1.5;
}
</style>

@ -1373,6 +1373,11 @@
resolved "https://registry.npmjs.org/@element-plus/icons-vue/-/icons-vue-2.3.2.tgz"
integrity sha512-OzIuTaIfC8QXEPmJvB4Y4kw34rSXdCJzxcD1kFStBvr8bK6X1zQAYDo0CNMjojnfTqRQCJ0I7prlErcoRiET2A==
"@epic-web/invariant@^1.0.0":
version "1.0.0"
resolved "https://registry.npmjs.org/@epic-web/invariant/-/invariant-1.0.0.tgz"
integrity sha512-lrTPqgvfFQtR/eY/qkIzp98OGdNJu0m5ji3q/nJI8v3SXkRKEnWiOxMmbvcSoAIzv/cGiuvRy57k4suKQSAdwA==
"@esbuild/win32-x64@0.19.12":
version "0.19.12"
resolved "https://registry.npmmirror.com/@esbuild/win32-x64/-/win32-x64-0.19.12.tgz"
@ -4002,6 +4007,14 @@ cropperjs@^1.6.1:
resolved "https://registry.npmmirror.com/cropperjs/-/cropperjs-1.6.2.tgz"
integrity sha512-nhymn9GdnV3CqiEHJVai54TULFAE3VshJTXSqSJKa8yXAKyBKDWdhHarnlIPrshJ0WMFTGuFvG02YjLXfPiuOA==
cross-env@^10.1.0:
version "10.1.0"
resolved "https://registry.npmjs.org/cross-env/-/cross-env-10.1.0.tgz"
integrity sha512-GsYosgnACZTADcmEyJctkJIoqAhHjttw7RsFrVoJNXbsWWqaq6Ym+7kZjq6mS45O0jij6vtiReppKQEtqWy6Dw==
dependencies:
"@epic-web/invariant" "^1.0.0"
cross-spawn "^7.0.6"
cross-fetch@^3.1.5:
version "3.1.8"
resolved "https://registry.npmmirror.com/cross-fetch/-/cross-fetch-3.1.8.tgz"
@ -4009,10 +4022,10 @@ cross-fetch@^3.1.5:
dependencies:
node-fetch "^2.6.12"
cross-spawn@^7.0.0, cross-spawn@^7.0.2, cross-spawn@^7.0.3:
version "7.0.3"
resolved "https://registry.npmmirror.com/cross-spawn/-/cross-spawn-7.0.3.tgz"
integrity sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==
cross-spawn@^7.0.0, cross-spawn@^7.0.2, cross-spawn@^7.0.3, cross-spawn@^7.0.6:
version "7.0.6"
resolved "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz"
integrity sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==
dependencies:
path-key "^3.1.0"
shebang-command "^2.0.0"

Loading…
Cancel
Save