safecheck-client 3.0.30-47 → 3.0.30-48
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/components/pc/LodopFuncs.js +159 -0
- package/src/components/pc/PrintData.vue +243 -0
- package/src/components/pc/PrintTable.vue +241 -0
- package/src/filiale/yongzhou/pc/NoCheckplanSafecheck.vue +2 -2
- package/src/filiale/yongzhou/pc/PrintData.vue +243 -243
- package/src/filiale/yongzhou/pc/communityDetail.vue +2 -2
- package/src/filiale/yongzhou/pc/communityTypeDetailG.vue +2 -2
- package/src/filiale/yongzhou/pc/communityTypeDetailM.vue +2 -2
- package/src/filiale/yongzhou/pc/safeDetail.vue +2 -2
- package/src/filiale/yongzhou/pc/safeStatisticsDay.vue +2 -2
- package/src/filiale/yongzhou/pc/safeStatisticsMonth.vue +2 -2
- package/src/filiale/yongzhou/pc.js +15 -15
- package/src/safecheck.js +892 -886
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "safecheck-client",
|
3
3
|
"//": "主分支版本别乱升,测试包的版本直接发包(建议使用1.XX.XX-XXX格式作为测试包,不要频繁升级第三位版本号),别提交版本号。切了分支切记把主分支版本升了,保证主分支始终是最高版本!!!!!",
|
4
|
-
"version": "3.0.30-
|
4
|
+
"version": "3.0.30-48",
|
5
5
|
"description": "安检模块 前端组件",
|
6
6
|
"author": "丁新 <417755458@qq.com>",
|
7
7
|
"license": "ISC",
|
@@ -0,0 +1,159 @@
|
|
1
|
+
var CreatedOKLodop7766 = null
|
2
|
+
|
3
|
+
// ====判断是否需要安装CLodop云打印服务器:====
|
4
|
+
function needCLodop () {
|
5
|
+
// return false;
|
6
|
+
try {
|
7
|
+
// 看是什么浏览器
|
8
|
+
var ua = navigator.userAgent
|
9
|
+
// windows,安装
|
10
|
+
if (ua.match(/Windows\sPhone/i) != null) return true
|
11
|
+
// iPhone, 安装
|
12
|
+
if (ua.match(/iPhone|iPod/i) != null) return true
|
13
|
+
// Android, 安装
|
14
|
+
if (ua.match(/Android/i) != null) return true
|
15
|
+
// Edge,安装
|
16
|
+
if (ua.match(/Edge\D?\d+/i) != null) return true
|
17
|
+
// QQ,不安装
|
18
|
+
if (ua.match(/QQBrowser/i) != null) return false
|
19
|
+
|
20
|
+
var verTrident = ua.match(/Trident\D?\d+/i)
|
21
|
+
var verIE = ua.match(/MSIE\D?\d+/i)
|
22
|
+
var verOPR = ua.match(/OPR\D?\d+/i)
|
23
|
+
var verFF = ua.match(/Firefox\D?\d+/i)
|
24
|
+
var x64 = ua.match(/x64/i)
|
25
|
+
if ((verTrident == null) && (verIE == null) && (x64 !== null)) {
|
26
|
+
return true
|
27
|
+
} else if (verFF !== null) {
|
28
|
+
verFF = verFF[0].match(/\d+/)
|
29
|
+
if (verFF[0] >= 42) return true
|
30
|
+
} else if (verOPR !== null) {
|
31
|
+
verOPR = verOPR[0].match(/\d+/)
|
32
|
+
if (verOPR[0] >= 32) return true
|
33
|
+
} else if ((verTrident == null) && (verIE == null)) {
|
34
|
+
var verChrome = ua.match(/Chrome\D?\d+/i)
|
35
|
+
if (verChrome !== null) {
|
36
|
+
verChrome = verChrome[0].match(/\d+/)
|
37
|
+
if (verChrome[0] >= 42) return true
|
38
|
+
}
|
39
|
+
}
|
40
|
+
return false
|
41
|
+
} catch (err) {
|
42
|
+
return true
|
43
|
+
}
|
44
|
+
}
|
45
|
+
|
46
|
+
// ====页面引用CLodop云打印必须的JS文件:====
|
47
|
+
if (needCLodop()) {
|
48
|
+
var head = document.head || document.getElementsByTagName('head')[0] || document.documentElement
|
49
|
+
var oscript = document.createElement('script')
|
50
|
+
// 让本机浏览器打印(更优先):
|
51
|
+
oscript.src = 'http://localhost:18000/CLodopfuncs.js?priority=1'
|
52
|
+
head.insertBefore(oscript, head.firstChild)
|
53
|
+
}
|
54
|
+
|
55
|
+
// ====获取LODOP对象的主过程:====
|
56
|
+
function getLodop (oOBJECT, oEMBED) {
|
57
|
+
// 显示提示用的内容
|
58
|
+
var strHtmInstall = "<br><font color='#FF00FF'>打印控件未安装!点击这里<a href='http://113.10.155.131/install_lodop32.zip' target='_self'>执行安装</a>,安装后请刷新页面或重新进入。</font>"
|
59
|
+
var strHtmUpdate = "<br><font color='#FF00FF'>打印控件需要升级!点击这里<a href='http://113.10.155.131/install_lodop32.zip' target='_self'>执行升级</a>,升级后请重新进入。</font>"
|
60
|
+
var strHtm64_Install = "<br><font color='#FF00FF'>打印控件未安装!点击这里<a href='http://113.10.155.131/install_lodop64.zip' target='_self'>执行安装</a>,安装后请刷新页面或重新进入。</font>"
|
61
|
+
var strHtm64_Update = "<br><font color='#FF00FF'>打印控件需要升级!点击这里<a href='http://113.10.155.131/install_lodop64.zip' target='_self'>执行升级</a>,升级后请重新进入。</font>"
|
62
|
+
var strHtmFireFox = "<br><br><font color='#FF00FF'>(注意:如曾安装过Lodop旧版附件npActiveXPLugin,请在【工具】->【附加组件】->【扩展】中先卸它)</font>"
|
63
|
+
var strHtmChrome = "<br><br><font color='#FF00FF'>(如果此前正常,仅因浏览器升级或重安装而出问题,需重新执行以上安装)</font>"
|
64
|
+
var strCLodopInstall = "<br><font color='#FF00FF'>CLodop云打印服务(localhost本地)未安装启动!点击这里<a href='CLodopPrint_Setup_for_Win32NT.zip' target='_self'>执行安装</a>,安装后请刷新页面。</font>"
|
65
|
+
var strCLodopUpdate = "<br><font color='#FF00FF'>CLodop云打印服务需升级!点击这里<a href='CLodopPrint_Setup_for_Win32NT.zip' target='_self'>执行升级</a>,升级后请刷新页面。</font>"
|
66
|
+
|
67
|
+
var LODOP
|
68
|
+
try {
|
69
|
+
var isIE = (navigator.userAgent.indexOf('MSIE') >= 0) || (navigator.userAgent.indexOf('Trident') >= 0)
|
70
|
+
if (needCLodop()) {
|
71
|
+
try {
|
72
|
+
// 调用脚本中的获取打印对象
|
73
|
+
LODOP = getCLodop()
|
74
|
+
} catch (err) {
|
75
|
+
}
|
76
|
+
// 如果没找到打印控件
|
77
|
+
if (!LODOP && document.readyState !== 'complete') {
|
78
|
+
alert('C-Lodop没准备好,请稍后再试!')
|
79
|
+
return
|
80
|
+
}
|
81
|
+
if (!LODOP) {
|
82
|
+
if (isIE) {
|
83
|
+
// document.write(strCLodopInstall)
|
84
|
+
if(confirm('CLodop云打印服务(localhost本地)未安装启动!你确定要安装吗?\n(点击确定进行安装,安装后请刷新页面)')){
|
85
|
+
window.open('download/CLodop_Setup_for_Win32NT.exe')
|
86
|
+
}
|
87
|
+
}
|
88
|
+
else {
|
89
|
+
// document.documentElement.innerHTML = strCLodopInstall + document.documentElement.innerHTML
|
90
|
+
if(confirm('CLodop云打印服务(localhost本地)未安装启动!你确定要安装吗?\n(点击确定进行安装,安装后请刷新页面)')){
|
91
|
+
window.open('download/CLodop_Setup_for_Win32NT.exe')
|
92
|
+
}
|
93
|
+
}
|
94
|
+
return
|
95
|
+
} else { // 找到后的处理
|
96
|
+
if (CLODOP.CVERSION < '2.0.6.2') {
|
97
|
+
if (isIE) document.write(strCLodopUpdate)
|
98
|
+
else {
|
99
|
+
document.documentElement.innerHTML = strCLodopUpdate + document.documentElement.innerHTML
|
100
|
+
}
|
101
|
+
}
|
102
|
+
if (oEMBED && oEMBED.parentNode) oEMBED.parentNode.removeChild(oEMBED)
|
103
|
+
if (oOBJECT && oOBJECT.parentNode) oOBJECT.parentNode.removeChild(oOBJECT)
|
104
|
+
}
|
105
|
+
} else { // 非云服务
|
106
|
+
var is64IE = isIE && (navigator.userAgent.indexOf('x64') >= 0)
|
107
|
+
// =====如果页面有Lodop就直接使用,没有则新建:==========
|
108
|
+
if (oOBJECT !== undefined || oEMBED !== undefined) {
|
109
|
+
if (isIE) LODOP = oOBJECT
|
110
|
+
else LODOP = oEMBED
|
111
|
+
} else if (CreatedOKLodop7766 == null) {
|
112
|
+
LODOP = document.createElement('object')
|
113
|
+
LODOP.setAttribute('width', 0)
|
114
|
+
LODOP.setAttribute('height', 0)
|
115
|
+
LODOP.setAttribute('style', 'position:absolute;left:0px;top:-100px;width:0px;height:0px;')
|
116
|
+
if (isIE) LODOP.setAttribute('classid', 'clsid:2105C259-1E0C-4534-8141-A753534CB4CA')
|
117
|
+
else LODOP.setAttribute('type', 'application/x-print-lodop')
|
118
|
+
document.documentElement.appendChild(LODOP)
|
119
|
+
CreatedOKLodop7766 = LODOP
|
120
|
+
} else LODOP = CreatedOKLodop7766
|
121
|
+
// =====Lodop插件未安装时提示下载地址:==========
|
122
|
+
if ((LODOP == null) || (typeof (LODOP.VERSION) === 'undefined')) {
|
123
|
+
if (navigator.userAgent.indexOf('Chrome') >= 0) {
|
124
|
+
document.documentElement.innerHTML = strHtmChrome + document.documentElement.innerHTML
|
125
|
+
}
|
126
|
+
if (navigator.userAgent.indexOf('Firefox') >= 0) {
|
127
|
+
document.documentElement.innerHTML = strHtmFireFox + document.documentElement.innerHTML
|
128
|
+
}
|
129
|
+
if (is64IE) document.write(strHtm64_Install)
|
130
|
+
else if (isIE) document.write(strHtmInstall)
|
131
|
+
else {
|
132
|
+
document.documentElement.innerHTML = strHtmInstall + document.documentElement.innerHTML
|
133
|
+
}
|
134
|
+
return LODOP
|
135
|
+
}
|
136
|
+
}
|
137
|
+
|
138
|
+
// 检查版本
|
139
|
+
if (LODOP.VERSION < '6.2.0.3') {
|
140
|
+
if (needCLodop()) {
|
141
|
+
document.documentElement.innerHTML = strCLodopUpdate + document.documentElement.innerHTML
|
142
|
+
} else if (is64IE) {
|
143
|
+
document.write(strHtm64_Update)
|
144
|
+
} else if (isIE) {
|
145
|
+
document.write(strHtmUpdate)
|
146
|
+
} else {
|
147
|
+
document.documentElement.innerHTML = strHtmUpdate + document.documentElement.innerHTML
|
148
|
+
}
|
149
|
+
return LODOP
|
150
|
+
}
|
151
|
+
// ===如下空白位置适合调用统一功能(如注册语句、语言选择等):===
|
152
|
+
LODOP.SET_LICENSES('西安奥枫软件有限公司', '552C41D5AB0D146FCF77D05CD8AA15A1', '', '')
|
153
|
+
return LODOP
|
154
|
+
} catch (err) {
|
155
|
+
alert('getLodop出错:' + err)
|
156
|
+
}
|
157
|
+
}
|
158
|
+
|
159
|
+
export default getLodop
|
@@ -0,0 +1,243 @@
|
|
1
|
+
<template>
|
2
|
+
<button class="button_export button_spacing" @click='printData()'>打印</button>
|
3
|
+
<modal :show.sync="printshow" v-ref:modal backdrop="false">
|
4
|
+
<header slot="modal-header" class="modal-header text-center">
|
5
|
+
<h4 class="modal-title">打印列选择</h4>
|
6
|
+
<input type="checkbox" class="" id="f_generations" v-model="all">
|
7
|
+
<label for="f_generations" class="font-size">全选</label>
|
8
|
+
</header>
|
9
|
+
<article slot="modal-body">
|
10
|
+
<div class="auto col-sm-11 col-md-offset-1" style="margin-top: 10px;">
|
11
|
+
<div class="col-sm-3" v-for="f in fields">
|
12
|
+
<input type="checkbox" class="" :id="'water-owe-details-'+$index" v-model="modelval" :value="$key">
|
13
|
+
<label :for="'water-owe-details-'+$index" class="font-size">{{f}}</label>
|
14
|
+
</div>
|
15
|
+
</div>
|
16
|
+
</article>
|
17
|
+
<footer slot="modal-footer" class="modal-footer">
|
18
|
+
<center>
|
19
|
+
<button v-show="printshow" type="button" class="btn btn-default" @click='close()'>取消</button>
|
20
|
+
<button v-show="printshow" type="button" class="btn btn-success" @click='print()'>打印</button>
|
21
|
+
<print-table-safe :model='model' v-show="false" v-ref:print
|
22
|
+
:printview="printview"
|
23
|
+
:xyprint="xyprint"
|
24
|
+
:top='40' :left='40' :right='40' :bottom='40' :print-name="printName"
|
25
|
+
:thead="thead" :tfoot='tfoot' :attach="attach" :sumhtml="sumhtml"
|
26
|
+
:fields="modelval" :is-selected="isSelected" :printpage="printpage">
|
27
|
+
</print-table-safe>
|
28
|
+
</center>
|
29
|
+
</footer>
|
30
|
+
</modal>
|
31
|
+
</template>
|
32
|
+
|
33
|
+
<script>
|
34
|
+
import co from 'co'
|
35
|
+
|
36
|
+
export default {
|
37
|
+
// data:sql需要的替换字段
|
38
|
+
// sqlurl:导出Excel查询的sql语句
|
39
|
+
// field:需要导出Excel的字段名和对应中文名或hbm配置文件名(全名)
|
40
|
+
// total:统计字段(统计行)
|
41
|
+
// props: ['data', 'sqlurl', 'field', 'total', 'bean', 'chooseCol'],
|
42
|
+
data () {
|
43
|
+
return {
|
44
|
+
printshow: false,
|
45
|
+
all: false,
|
46
|
+
fields: {},
|
47
|
+
modelval: [],
|
48
|
+
thead: '',
|
49
|
+
tfoot: '',
|
50
|
+
//合计数据
|
51
|
+
sumsmodel: {},
|
52
|
+
// 合计超文本
|
53
|
+
sumhtml: ''
|
54
|
+
}
|
55
|
+
},
|
56
|
+
props: {
|
57
|
+
model: {},
|
58
|
+
field: {},
|
59
|
+
printview:{},
|
60
|
+
xyprint:{},
|
61
|
+
starthead: {
|
62
|
+
type:String,
|
63
|
+
default:''
|
64
|
+
},
|
65
|
+
titletable: {
|
66
|
+
type:String,
|
67
|
+
default:''
|
68
|
+
},
|
69
|
+
printName: {},
|
70
|
+
// 默认列
|
71
|
+
defaultfield: {},
|
72
|
+
// 合计数据
|
73
|
+
sumsmodel: {},
|
74
|
+
// 合计数据的列名称配置(当没有找到对应合计的名称时,会从field中找)
|
75
|
+
sumField: {},
|
76
|
+
// 单页合计
|
77
|
+
pageSum: null,
|
78
|
+
isSelected: {
|
79
|
+
type:Boolean,
|
80
|
+
default:false
|
81
|
+
},
|
82
|
+
//设置打印底部信息 如制表人:审核人:。。。
|
83
|
+
footinfo: [],
|
84
|
+
// 设置打印底部信息 其他信息 格式为二维数组 如:[['1','','','4'],['5','','','8']]
|
85
|
+
footmsg: [],
|
86
|
+
printpage: {
|
87
|
+
type:Boolean,
|
88
|
+
default:false
|
89
|
+
},
|
90
|
+
// 全表汇总信息只在最后一页显示
|
91
|
+
sumone: {
|
92
|
+
type:Boolean,
|
93
|
+
default:true
|
94
|
+
},
|
95
|
+
attach: {
|
96
|
+
type: String,
|
97
|
+
default: 'name'
|
98
|
+
},
|
99
|
+
chooserow: {
|
100
|
+
type: Boolean,
|
101
|
+
default: false
|
102
|
+
}
|
103
|
+
},
|
104
|
+
methods: {
|
105
|
+
|
106
|
+
async printData () {
|
107
|
+
console.log('打印。。。', this.model, this.field, this.printName, this.sumsmodel)
|
108
|
+
|
109
|
+
if (this.model.rows.length === 0) {
|
110
|
+
this.$showAlert('请查询需要打印的数据!!', 'warning', 2000)
|
111
|
+
return
|
112
|
+
}
|
113
|
+
this.all = false
|
114
|
+
//默认选择要打印的列
|
115
|
+
this.modelval = this.defaultfield
|
116
|
+
this.fields = this.field
|
117
|
+
console.log('所有打印字段',this.fields)
|
118
|
+
this.printshow = true
|
119
|
+
await this.put()
|
120
|
+
if(this.chooserow){
|
121
|
+
this.print()
|
122
|
+
}
|
123
|
+
},
|
124
|
+
|
125
|
+
put () {
|
126
|
+
// 对Modelval进行排序
|
127
|
+
this.sortModelval()
|
128
|
+
this.getfield()
|
129
|
+
// 组织头数据
|
130
|
+
if(this.titletable!=''){
|
131
|
+
this.thead = `<tr><th colspan=${this.modelval.length}><h1>${this.titletable}</h1></th></tr><tr>`
|
132
|
+
}else{
|
133
|
+
this.thead = `<tr><th colspan=${this.modelval.length}><h1>${this.printName}统计报表</h1></th></tr><tr>`
|
134
|
+
}
|
135
|
+
if(this.starthead!=''){
|
136
|
+
this.thead += `<tr><th colspan=${this.modelval.length}>${this.starthead}</th></tr><tr>`
|
137
|
+
}
|
138
|
+
for (let key of this.modelval) {
|
139
|
+
this.thead += '<th>' + this.fields[key] + '</th>'
|
140
|
+
}
|
141
|
+
this.thead += '</tr>'
|
142
|
+
},
|
143
|
+
// 对选择的列进行排序
|
144
|
+
sortModelval () {
|
145
|
+
console.log('选择列进行排序。。。', this.fields, this.modelval)
|
146
|
+
let sortModel = []
|
147
|
+
Object.keys(this.fields).forEach((key) => {
|
148
|
+
if (this.modelval.includes(key)) {
|
149
|
+
sortModel.push(key)
|
150
|
+
}
|
151
|
+
})
|
152
|
+
this.modelval = sortModel
|
153
|
+
console.log('选择的打印的字段', this.modelval)
|
154
|
+
},
|
155
|
+
|
156
|
+
close () {
|
157
|
+
this.all = false
|
158
|
+
this.modelval = []
|
159
|
+
this.printshow = false
|
160
|
+
this.$dispatch('print-close')
|
161
|
+
},
|
162
|
+
|
163
|
+
print () {
|
164
|
+
if (this.$login.r.includes('限制打印')) {
|
165
|
+
this.$showMessage('你被限制打印, 请联系管理员')
|
166
|
+
return
|
167
|
+
}
|
168
|
+
this.$refs.print.PrintAsFile()
|
169
|
+
this.printshow = false
|
170
|
+
this.$dispatch('print-data')
|
171
|
+
},
|
172
|
+
getfield(){
|
173
|
+
//合计字段打印
|
174
|
+
this.tfoot = ''
|
175
|
+
if(this.sumsmodel){
|
176
|
+
if (this.sumone) {
|
177
|
+
this.sumhtml = `<tr><th colspan=${this.modelval.length} style="border-width: 0;">全表汇总信息: `
|
178
|
+
Object.keys(this.sumsmodel).forEach((key) => {
|
179
|
+
let keyName = this.sumField[key] ? this.sumField[key] : this.fields[key]
|
180
|
+
this.sumhtml += keyName + '合计: ' + `<font color="blue">${this.sumsmodel[key]} </font>`
|
181
|
+
})
|
182
|
+
this.sumhtml += '</th></tr>'
|
183
|
+
} else {
|
184
|
+
this.tfoot = `<tr><th colspan=${this.modelval.length} style="border-width: 0;">全表汇总信息: `
|
185
|
+
Object.keys(this.sumsmodel).forEach((key) => {
|
186
|
+
let keyName = this.sumField[key] ? this.sumField[key] : this.fields[key]
|
187
|
+
this.tfoot += keyName + '合计: ' + `<font color="blue">${this.sumsmodel[key]} </font>`
|
188
|
+
})
|
189
|
+
this.tfoot += '</th></tr>'
|
190
|
+
}
|
191
|
+
}
|
192
|
+
if (this.pageSum) {
|
193
|
+
this.tfoot += `<tr>`
|
194
|
+
for (let row of this.modelval) {
|
195
|
+
let format = this.pageSum[row]
|
196
|
+
if (format) {
|
197
|
+
this.tfoot += `<td tdata="SubSum" format="${format}" style="border-width: 0;">######</td>`
|
198
|
+
} else {
|
199
|
+
this.tfoot += `<td style="border-width: 0;"></td>`
|
200
|
+
}
|
201
|
+
}
|
202
|
+
this.tfoot += `</tr>`
|
203
|
+
}
|
204
|
+
this.tfoot += `<tr><th colspan=${this.modelval.length} style="border-width: 0;">打印时间: ${this.$login.toStandardTimeString()}</th></tr>`
|
205
|
+
//设置打印底部信息 如制表人:审核人:。。。
|
206
|
+
if(this.footinfo!=null && this.footinfo.length!=0){
|
207
|
+
this.tfoot += `<tr><td colspan=${this.modelval.length} style="border-width: 0;"></td></tr><tr>`
|
208
|
+
for(let i=0;i<this.footinfo.length;i++){
|
209
|
+
this.tfoot += `<th colspan=${this.modelval.length/this.footinfo.length} style="border-width: 0;text-align: left;">${this.footinfo[i]}:</th>`
|
210
|
+
}
|
211
|
+
this.tfoot += `</tr>`
|
212
|
+
}
|
213
|
+
// 设置打印底部信息 其他信息 格式为二维数组 如:[['1','','','4'],['5','','','8']]
|
214
|
+
if (this.footmsg != null && this.footmsg.length != 0) {
|
215
|
+
for (let i = 0; i < this.footmsg.length; i++) {
|
216
|
+
this.tfoot += `<tr style="padding: 0 2px 0 2px"><th style="border: 0" colspan=${this.modelval.length} ><table style="width: 100%;border-width: 0;text-align: left;"><tr>`
|
217
|
+
for (let j = 0; j < this.footmsg[i].length; j++) {
|
218
|
+
// 如果this.footsmg[i]有三个元素 则每个占比 33.33%
|
219
|
+
// 如果this.footsmg[i]有四个元素 则每个占比 25%
|
220
|
+
this.tfoot += `<td style="border-width: 0;text-align: left;width: ${(Number(1) / Number(this.footmsg[i].length) * 100).toFixed(2)}%">${this.footmsg[i][j]}</td>`
|
221
|
+
}
|
222
|
+
this.tfoot += `</tr></table></th></tr>`
|
223
|
+
}
|
224
|
+
}
|
225
|
+
},
|
226
|
+
},
|
227
|
+
watch: {
|
228
|
+
'all' (val) {
|
229
|
+
if (val) {
|
230
|
+
this.modelval = Object.keys(this.fields)
|
231
|
+
} else {
|
232
|
+
this.modelval = []
|
233
|
+
}
|
234
|
+
},
|
235
|
+
'modelval.length' () {
|
236
|
+
this.put()
|
237
|
+
}
|
238
|
+
},
|
239
|
+
computed: {
|
240
|
+
|
241
|
+
}
|
242
|
+
}
|
243
|
+
</script>
|
@@ -0,0 +1,241 @@
|
|
1
|
+
<template>
|
2
|
+
<button class="btn btn-default" @click='PrintAsFile()' :id="'vc-printtable-'+attach">打印表格</button>
|
3
|
+
</template>
|
4
|
+
|
5
|
+
<script>
|
6
|
+
import co from 'co'
|
7
|
+
import getLodop from './LodopFuncs'
|
8
|
+
|
9
|
+
let printGen = function * (self, pageNo) {
|
10
|
+
|
11
|
+
console.log('开始打印', self.isSelected, self.model, self.tfoot)
|
12
|
+
//是否分页打印
|
13
|
+
if(pageNo){
|
14
|
+
self.PrintSinglePage()
|
15
|
+
return
|
16
|
+
}
|
17
|
+
if (self.isSelected) {
|
18
|
+
// 判断是否选择行数据进行打印
|
19
|
+
self.PrintSelectedPage()
|
20
|
+
return
|
21
|
+
}
|
22
|
+
|
23
|
+
let lodop = getLodop()
|
24
|
+
lodop.PRINT_INIT(self.printName+'打印')
|
25
|
+
var style
|
26
|
+
if (!self.style) {
|
27
|
+
style = '<style>table{font-size:15px;border-width: 2px;border-collapse: collapse;border:solid 2px ; border-color:black;}' +
|
28
|
+
'table th {border-width: 1px;padding: 2px;border-style: solid;}table td {border-width: 1px;padding: 2px;border-style: solid;}</style>'
|
29
|
+
} else {
|
30
|
+
style = self.style
|
31
|
+
}
|
32
|
+
let tHtml = style + '<table class="table table-hover"><thead>' + self.thead + '</thead><tbody>'
|
33
|
+
|
34
|
+
for (var i = 1; i <= self.model.totalPage; i++) {
|
35
|
+
console.log('pageIndex = ' + i)
|
36
|
+
yield self.model.loadPage(i)
|
37
|
+
for (let row of self.model.rows) {
|
38
|
+
tHtml += '<tr>'
|
39
|
+
for (let field of self.fields) {
|
40
|
+
if (field && (row[field] || row[field] === 0) ) {
|
41
|
+
tHtml += '<td>' + row[field] + '</td>'
|
42
|
+
} else {
|
43
|
+
tHtml += '<td></td>'
|
44
|
+
}
|
45
|
+
// console.log(row[field])
|
46
|
+
}
|
47
|
+
tHtml += '</tr>'
|
48
|
+
}
|
49
|
+
}
|
50
|
+
// 加入合计数据 (最后一页显示)
|
51
|
+
if (self.sumhtml) {
|
52
|
+
tHtml += self.sumhtml
|
53
|
+
}
|
54
|
+
// 如果有表尾,则添加表尾,如果内容翻页的话,表尾每一页都要打印
|
55
|
+
if (self.tfoot) {
|
56
|
+
self.tfoot += `<tr><td width="100%" colspan=${self.fields.length} style="text-align: center;border-width: 0;">第<font tdata="PageNO" format="#" color="blue">#</font>页</span>/共<font tdata="PageCount" format="#" color="blue">##</font></span>页</td></tr>`
|
57
|
+
tHtml += `</tbody><tfoot>${self.tfoot}</tfoot></table>`
|
58
|
+
} else {
|
59
|
+
tHtml += '</tbody></table>'
|
60
|
+
}
|
61
|
+
|
62
|
+
lodop.ADD_PRINT_TABLE(self.top, self.left, 'RightMargin:' + self.right, 'BottomMargin:' + self.bottom, tHtml)
|
63
|
+
lodop.SET_PRINT_STYLEA(0, 'HOrient', 3)
|
64
|
+
lodop.SET_PRINT_STYLEA(0, 'VOrient', 3)
|
65
|
+
// 指定打印方向 0--可通过打印机选择纵向或横向,1--锁定为纵向打印,2---锁定为横向打印
|
66
|
+
LODOP.SET_PRINT_PAGESIZE(self.xyprint, 0, 0, "A4");
|
67
|
+
|
68
|
+
if(self.printview==null){
|
69
|
+
// 打印维护
|
70
|
+
lodop.PRINT_SETUP()
|
71
|
+
}else if(self.printview){
|
72
|
+
// 使用打印预览是为了方便调整打印格式。例如:横向打印
|
73
|
+
lodop.PREVIEW()
|
74
|
+
}else if(!self.printview){
|
75
|
+
// 直接打印
|
76
|
+
lodop.PRINT()
|
77
|
+
}
|
78
|
+
|
79
|
+
}
|
80
|
+
|
81
|
+
export default {
|
82
|
+
// props: ['model', 'thead', 'fields', 'top', 'left', 'right', 'bottom', 'tfoot'],
|
83
|
+
props: {
|
84
|
+
model: Object,
|
85
|
+
thead: String,
|
86
|
+
tfoot: String,
|
87
|
+
sumhtml: String,
|
88
|
+
fields: Array,
|
89
|
+
//null 打印维护, true 打印预览 false 直接打印
|
90
|
+
printview:{},
|
91
|
+
// 指定打印方向 0--可通过打印机选择纵向或横向,1--锁定为纵向打印,2---锁定为横向打印
|
92
|
+
xyprint:{
|
93
|
+
default : 0
|
94
|
+
},
|
95
|
+
top: {},
|
96
|
+
left: {},
|
97
|
+
right: {},
|
98
|
+
bottom: {},
|
99
|
+
attach: {
|
100
|
+
type: String,
|
101
|
+
default: 'name'
|
102
|
+
},
|
103
|
+
style: {
|
104
|
+
type: String
|
105
|
+
},
|
106
|
+
isSelected: {
|
107
|
+
type:Boolean,
|
108
|
+
default:false
|
109
|
+
},
|
110
|
+
//是否分页打印
|
111
|
+
printpage:{
|
112
|
+
type:Boolean,
|
113
|
+
default:false
|
114
|
+
},
|
115
|
+
// 打印名称,在同一个名称下的打印可以统一风格(打印维护界面点击应用即可)
|
116
|
+
printName: {
|
117
|
+
type: String
|
118
|
+
}
|
119
|
+
},
|
120
|
+
data(){
|
121
|
+
return{
|
122
|
+
//打印任务的JOB代码,用于获得打印状态信息及最终结果。
|
123
|
+
P_ID:"",
|
124
|
+
//第几次任务
|
125
|
+
loop:0,
|
126
|
+
}
|
127
|
+
},
|
128
|
+
methods: {
|
129
|
+
PrintAsFile () {
|
130
|
+
console.log(this.model)
|
131
|
+
let gen = printGen(this,this.printpage)
|
132
|
+
co(gen)
|
133
|
+
},
|
134
|
+
async PrintSinglePage(){
|
135
|
+
let lodop = getLodop()
|
136
|
+
lodop.PRINT_INIT('打印表格'+(this.loop+1))
|
137
|
+
var style
|
138
|
+
if (!this.style) {
|
139
|
+
style = '<style>table{font-size:15px;border-width: 2px;border-collapse: collapse;border:solid 2px ; border-color:black;}' +
|
140
|
+
'table th {border-width: 1px;padding: 2px;border-style: solid;}table td {border-width: 1px;padding: 2px;border-style: solid;}</style>'
|
141
|
+
} else {
|
142
|
+
style = this.style
|
143
|
+
}
|
144
|
+
let tHtml = style + '<table class="table table-hover"><thead>' + this.thead + '</thead><tbody>'
|
145
|
+
|
146
|
+
//所有数据全部打印,打印任务结束
|
147
|
+
if(this.loop+1>this.model.totalPage){
|
148
|
+
this.printinit()
|
149
|
+
console.log('打印结束')
|
150
|
+
return
|
151
|
+
}
|
152
|
+
console.log('获取数据pageIndex = ' + (this.loop+1))
|
153
|
+
await this.model.loadPage(this.loop+1)
|
154
|
+
for (let row of this.model.rows) {
|
155
|
+
tHtml += '<tr>'
|
156
|
+
for (let field of this.fields) {
|
157
|
+
if (field && (row[field] || row[field] === 0) ) {
|
158
|
+
tHtml += '<td>' + row[field] + '</td>'
|
159
|
+
} else {
|
160
|
+
tHtml += '<td></td>'
|
161
|
+
}
|
162
|
+
}
|
163
|
+
tHtml += '</tr>'
|
164
|
+
}
|
165
|
+
//插入页码
|
166
|
+
let page = `<tr><th width="100%" colspan=${this.fields.length} style="border-width: 0;">当前是第<font format="ChineseNum" color="blue">${this.loop+1}</font>页/共<font format="ChineseNum" color="blue">${this.model.totalPage}</font>页`
|
167
|
+
// 如果有表尾,则添加表尾,如果内容翻页的话,表尾每一页都要打印
|
168
|
+
if (this.tfoot) {
|
169
|
+
tHtml += `</tbody><tfoot>${this.tfoot}${page}</tfoot></table>`
|
170
|
+
} else {
|
171
|
+
tHtml += '</tbody></table>'
|
172
|
+
}
|
173
|
+
|
174
|
+
lodop.ADD_PRINT_TABLE(this.left, this.top, 'RightMargin:' + this.right, 'BottomMargin:' + this.bottom, tHtml)
|
175
|
+
lodop.SET_PRINT_STYLEA(0, 'HOrient', 3)
|
176
|
+
lodop.SET_PRINT_STYLEA(0, 'VOrient', 3)
|
177
|
+
//设置打印机为默认打印机
|
178
|
+
lodop.SET_PRINTER_INDEX(-1)
|
179
|
+
|
180
|
+
this.P_ID=lodop.PRINT()
|
181
|
+
if(this.P_ID){
|
182
|
+
this.loop+=1
|
183
|
+
console.log("正打印第"+this.loop+"个任务(JOB代码"+this.P_ID)
|
184
|
+
}
|
185
|
+
//延迟循环缓解压力
|
186
|
+
await this.timeout(1500)
|
187
|
+
this.PrintSinglePage()
|
188
|
+
},
|
189
|
+
|
190
|
+
async PrintSelectedPage () {
|
191
|
+
console.log('选择列打印开始', this.model)
|
192
|
+
|
193
|
+
if (this.model.rows.length > 100) {
|
194
|
+
this.$showAlert('您选择的数据过大,请选择少于100条数据进行打印', 'warning', 3000)
|
195
|
+
return
|
196
|
+
}
|
197
|
+
|
198
|
+
let lodop = getLodop()
|
199
|
+
lodop.PRINT_INIT('打印表格'+(this.loop+1))
|
200
|
+
var style
|
201
|
+
if (!this.style) {
|
202
|
+
style = '<style>table{font-size:15px;border-width: 2px;border-collapse: collapse;border:solid 2px ; border-color:black;}' +
|
203
|
+
'table th {border-width: 1px;padding: 2px;border-style: solid;}table td {border-width: 1px;padding: 2px;border-style: solid;}</style>'
|
204
|
+
} else {
|
205
|
+
style = this.style
|
206
|
+
}
|
207
|
+
let tHtml = style + '<table class="table table-hover"><thead>' + this.thead + '</thead><tbody>'
|
208
|
+
for (let row of this.model.rows) {
|
209
|
+
tHtml += '<tr>'
|
210
|
+
for (let field of this.fields) {
|
211
|
+
tHtml += '<td style="text-align: center;">' + row[field] + '</td>'
|
212
|
+
}
|
213
|
+
tHtml += '</tr>'
|
214
|
+
}
|
215
|
+
// // 如果有表尾,则添加表尾,如果内容翻页的话,表尾每一页都要打印
|
216
|
+
if (this.tfoot) {
|
217
|
+
tHtml += `</tbody><tfoot>${this.tfoot}</tfoot></table>`
|
218
|
+
} else {
|
219
|
+
tHtml += '</tbody></table>'
|
220
|
+
}
|
221
|
+
console.log('选择列打印的html', tHtml)
|
222
|
+
lodop.ADD_PRINT_TABLE(this.left, this.top, 'RightMargin:' + this.right, 'BottomMargin:' + this.bottom, tHtml)
|
223
|
+
lodop.SET_PRINT_STYLEA(0, 'HOrient', 3)
|
224
|
+
lodop.SET_PRINT_STYLEA(0, 'VOrient', 3)
|
225
|
+
//设置打印机为默认打印机
|
226
|
+
lodop.SET_PRINTER_INDEX(-1)
|
227
|
+
console.log('开始调用打印。。')
|
228
|
+
this.P_ID=lodop.PRINT()
|
229
|
+
},
|
230
|
+
printinit(){
|
231
|
+
this.P_ID="",
|
232
|
+
this.loop=0
|
233
|
+
},
|
234
|
+
async timeout(ms){
|
235
|
+
return new Promise((resolve, reject) => {
|
236
|
+
setTimeout(resolve, ms)
|
237
|
+
})
|
238
|
+
}
|
239
|
+
}
|
240
|
+
}
|
241
|
+
</script>
|
@@ -54,11 +54,11 @@
|
|
54
54
|
condition="f_check_type = '{}'"></v-select>
|
55
55
|
</div>
|
56
56
|
<div class="col-sm-3 form-group form-input-group" style="width: 20%;float: right;">
|
57
|
-
<print-data :sum-field="$parent.$parent.excelHeaders" :model="$parent.$parent.print_model"
|
57
|
+
<print-data-safe :sum-field="$parent.$parent.excelHeaders" :model="$parent.$parent.print_model"
|
58
58
|
:field="$parent.$parent.excelHeaders"
|
59
59
|
:defaultfield="$parent.$parent.defaultPrint"
|
60
60
|
titletable="无计划安检汇总" :starthead="$parent.$parent.getstart"
|
61
|
-
></print-data>
|
61
|
+
></print-data-safe>
|
62
62
|
<export-excel-safe :data="$parent.$parent.searchData"
|
63
63
|
:field="$parent.$parent.excelHeaders"
|
64
64
|
sqlurl="rs/logic/SafeExportExcel"
|