Browse Source

打印机维护 2022-05-10 sxm

master
[li_she] 4 years ago
parent
commit
8cb05c2a90
  1. 7
      src/api/print/print.js
  2. 2
      src/utils/httpRequest.js
  3. 30
      src/views/main-navbar.vue
  4. 118
      src/views/modules/common/print-list.vue
  5. 200
      src/views/modules/common/user-print-list.vue

7
src/api/print/print.js

@ -0,0 +1,7 @@
import { createAPI } from "@/utils/httpRequest.js";
// 获取用户打印机
export const getUserLabelPrintList = data => createAPI(`/sysUserPrinter/getUserPrint/${data.userName}`,'get')
// 保存用户打印机
export const saveUserLabelPrint = data => createAPI('/sysUserPrinter/saveUserLabelPrint','post',data)

2
src/utils/httpRequest.js

@ -26,7 +26,7 @@ http.interceptors.request.use(config => {
})
/**
* 响应拦截
* 响应拦截 可自定义统一返回结果
*/
http.interceptors.response.use(response => {
if (response.data && response.data.code === 401) { // 401, token失效

30
src/views/main-navbar.vue

@ -37,6 +37,7 @@
</el-submenu>
<el-menu-item index="2-3" @click="$router.push({ name: 'theme' })">{{ pageLanguage.cssSetting }}</el-menu-item>
<el-menu-item index="2-4" @click="printList()">{{ pageLanguage.printSetting }}</el-menu-item>
</el-submenu>
<el-menu-item class="site-navbar__avatar" index="3">
<el-dropdown :show-timeout="0" placement="bottom">
@ -55,8 +56,10 @@
<update-password v-if="updatePassowrdVisible" ref="updatePassowrd"></update-password>
<!-- 弹窗, 修改默认语言 -->
<update-language v-if="updateLanguageVisible" ref="updateLanguage"></update-language>
<!-- 文件列表 -->
<FileListView ref="fileListView" v-if="helpFileVisible"></FileListView>
<!-- 打印机列表 -->
<UserPrintList ref="userPrintList" v-if="printListVisible"></UserPrintList>
</nav>
</template>
@ -65,6 +68,7 @@
import UpdateLanguage from './main-navbar-update-language'
import {clearLoginInfo} from '@/utils'
import FileListView from './modules/common/file-list-view'
import UserPrintList from './modules/common/user-print-list'
import {
searchFunctionButtonList,
saveButtonList,
@ -76,6 +80,7 @@
updatePassowrdVisible: false,
updateLanguageVisible: false,
helpFileVisible:false,
printListVisible:false,
message: this.$t('language.name'),
languageList: [],
pageLanguage: {
@ -86,7 +91,8 @@
userSetting: '用户设置',
updatePassword: '修改密码',
updateDefaultLanguage: '修改默认语言',
cssSetting: '主提设置'
cssSetting: '主提设置',
printSetting: '打印设置',
},
// end
pageLanguageList: [
@ -152,6 +158,13 @@
objectId: 'cssSetting',
objectType: "label",
tableId: "systemInformation"
},
{
functionId: "systemInformation",
languageValue: '打印设置',
objectId: 'printSetting',
objectType: "label",
tableId: "systemInformation"
}
],
@ -160,7 +173,8 @@
components: {
UpdatePassword,
UpdateLanguage,
FileListView
FileListView,
UserPrintList
},
computed: {
navbarLayoutType: {
@ -194,6 +208,13 @@
},
methods: {
//
printList(){
this.printListVisible = true;
this.$nextTick(() => {
this.$refs.userPrintList.init()
})
},
//
helpFileList(){
let fileMappingDto = {
@ -223,9 +244,8 @@
objectType: 'label'
}
searchFunctionButtonList(queryButton).then(({data}) => {
if (JSON.stringify(data.data) != '{}') {
if (data.code === 0) {
this.pageLanguage = data.data
} else {
saveButtonList(this.pageLanguageList).then(({data}) => {
this.getFunctionButtonList()

118
src/views/modules/common/print-list.vue

@ -0,0 +1,118 @@
<template>
<div class="mod-oss">
<el-dialog
v-drag
:title="title"
:close-on-click-modal="false"
:visible.sync="visible"
width="400px"
:append-to-body="true">
<el-form>
<el-form label-position="top">
<el-form-item :label="'标签名称'">
<el-input v-model="userPrint.labelName" readonly></el-input>
</el-form-item>
<el-form-item :label="'打印机地址'">
<el-input v-model="userPrint.ipAddress" ></el-input>
</el-form-item>
<el-form-item label="打印机名称">
<el-select style="width:100%" v-model="userPrint.printerName">
<el-option v-for="(item,index) in printList"
:key="index"
:label="item.label" :value="item.label"></el-option>
</el-select>
</el-form-item>
</el-form>
<select v-show="false" ref="printElement">
</select>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="savePrint()" type="primary">{{ buttons.save }}</el-button>
<el-button @click="visible = false" type="primary">{{ buttons.close }}</el-button>
</span>
</el-dialog>
</div>
</template>
<script>
import {saveUserLabelPrint} from '@/api/print/print.js';
export default {
data() {
return {
tableHeight: 365,
title: '用户打印机管理',
visible: false,
userPrint: {
printerName: '',
userId: this.$store.state.user.name,
ipAddress: '',
labelName: '',
},
printList: [],
buttons: {
save: "保存",
close: "关闭"
},
buttonList: []
}
},
components: {},
mounted() {
this.$nextTick(() => {
this.height = (window.innerHeight * 0.82);
})
},
methods: {
//
init(val) {
this.visible = true
this.userPrint = val
this.userPrint.ipAddress = val.ipAddress?val.ipAddress: '127.0.0.1'
this.getPrintName()
},
//
getPrintName(){
this.$nextTick(() => {
let lodop = this.getLodop()
var elementById = this.$refs.printElement;
lodop.Create_Printer_List(elementById)
setTimeout(()=>{},1000)
console.log(elementById)
var children = elementById.children
let list = []
for (let child of children) {
let option = {
value: child.index,
label: child.innerText
}
list.push(option)
}
this.printList = list
})
},
//
savePrint(){
this.userPrint.userId = this.$store.state.user.name
saveUserLabelPrint(this.userPrint).then(({data}) =>{
if (data.code === 0){
this.$message.success(data.msg)
this.visible = false
this.$emit('refreshDataList')
}else {
this.$message.warning(data.msg)
}
})
}
},
created() {
}
}
</script>

200
src/views/modules/common/user-print-list.vue

@ -0,0 +1,200 @@
<template>
<div class="mod-oss">
<el-dialog
v-drag
:title="title"
:close-on-click-modal="false"
:visible.sync="visible"
width="955px"
:append-to-body="true">
<el-table
:height="tableHeight"
:data="dataList"
border
v-loading="dataListLoading"
style="width: 100%;">
<el-table-column
v-for="(item,index) in columnList" :key="index"
:sortable="item.columnSortable"
:prop="item.columnProp"
:header-align="item.headerAlign"
:show-overflow-tooltip="item.showOverflowTooltip"
:align="item.align"
:fixed="item.fixed"
:min-width="item.columnWidth"
:label="item.columnLabel">
<template slot-scope="scope">
<span v-if="!item.columnHidden"> {{ scope.row[item.columnProp] }}</span>
<span v-if="item.columnImage"><img :src="scope.row[item.columnProp]"
style="width: 100px; height: 80px"/></span>
</template>
</el-table-column>
<el-table-column
fixed="right"
header-align="center"
align="center"
width="150"
:label="buttons.operate">
<template slot-scope="scope">
<a type="text" size="small" @click="printSetting(scope.row)">{{ buttons.settingPrint }}</a>
</template>
</el-table-column>
</el-table>
<span slot="footer" class="dialog-footer">
<el-button @click="visible = false" type="primary">关闭</el-button>
</span>
</el-dialog>
<PrintList ref="printListRef" v-if="printListVisible" @refreshDataList="getDataList"></PrintList>
</div>
</template>
<script>
import {getUserLabelPrintList} from '@/api/print/print.js'
import PrintList from './print-list.vue'
export default {
data() {
return {
tableHeight: 365,
title: '打印机管理',
visible: false,
printListVisible: false,
dataListLoading: true,
dataForm: {
fileName: ''
},
dataList: [],
printList: [],
columnList: [
{
"tableId": "common1001",
"tableName": "common",
"columnProp": "labelName",
"columnLabel": "标签名称",
"columnHidden": false,
"columnImage": false,
"columnSortable": false,
"columnWidth": '15%',
"format": null,
"functionId": this.$route.meta.menuId,
"sortLv": 0,
"status": true,
"fixed": false,
"serialNumber": null,
"columnType": null,
"align": null
},
{
"tableId": "common1001",
"tableName": "common",
"columnProp": "userId",
"columnLabel": "用户名",
"columnHidden": false,
"columnImage": false,
"columnSortable": false,
"columnWidth": '15%',
"format": null,
"functionId": this.$route.meta.menuId,
"sortLv": 0,
"status": true,
"fixed": false,
"serialNumber": null,
"columnType": null,
"align": null
},
{
"tableId": "common1001",
"tableName": "common",
"columnProp": "ipAddress",
"columnLabel": "打印机地址",
"columnHidden": false,
"columnImage": false,
"columnSortable": false,
"columnWidth": '20%',
"format": null,
"functionId": this.$route.meta.menuId,
"sortLv": 0,
"status": true,
"fixed": false,
"serialNumber": null,
"columnType": null,
"align": null
},
{
"tableId": "common1001",
"tableName": "common",
"columnProp": "printerName",
"columnLabel": "打印机名称",
"columnHidden": false,
"columnImage": false,
"columnSortable": false,
"columnWidth": '50%',
"format": null,
"functionId": this.$route.meta.menuId,
"sortLv": 0,
"status": true,
"fixed": false,
"serialNumber": null,
"columnType": null,
"align": null
},
],
buttons: {
settingPrint: "设置打印机",
operate: "操作"
},
buttonList: []
}
},
components: {PrintList,},
mounted() {
this.$nextTick(() => {
this.height = (window.innerHeight * 0.82);
})
},
activated() {
this.getDataList()
},
methods: {
//
init() {
this.visible = true
this.getDataList()
},
//
getDataList() {
let query = {
userName: this.$store.state.user.name
}
getUserLabelPrintList(query).then(({data}) => {
if (data.code === 0) {
this.dataList = data.dataList
}
this.dataListLoading = false
})
},
//
printSetting(row) {
// ,
let rowData = JSON.parse(JSON.stringify(row))
this.printListVisible = true
this.$nextTick(() => {
this.$refs.printListRef.init(rowData)
})
},
//
savePrint() {
}
},
created() {
}
}
</script>
Loading…
Cancel
Save