|
@@ -8,19 +8,37 @@
|
|
|
:title="modalTit"
|
|
|
:zIndex="1001"
|
|
|
destroyOnClose
|
|
|
- :bodyStyle="{padding: modalTit?'15px 15px 20px':'50px 32px 15px',background: '#f2f2f2'}"
|
|
|
@cancel="handleCommonCancel"
|
|
|
- width="1024px">
|
|
|
+ width="1000px">
|
|
|
<a-spin :spinning="spinning" tip="Loading...">
|
|
|
<div class="common-main">
|
|
|
- <vue-scroll :ops="ops" style="width: 100%;height: 70vh;">
|
|
|
- <!-- {{ page }} <span @click="page=page+1">下一页</span> -->
|
|
|
+ <div id="canvas"></div>
|
|
|
+ <div class="tools">
|
|
|
+ <div>
|
|
|
+ 调整比例:{{ Math.round(scalVal*100) }}%
|
|
|
+ <div>
|
|
|
+ <a-button size="small" @click="setScalVal(0)"><a-icon type="minus" /> 缩小</a-button>
|
|
|
+ <a-button size="small" @click="setScalVal(1)"><a-icon type="plus" /> 放大</a-button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div>
|
|
|
+ 选择打印机:
|
|
|
+ <div>
|
|
|
+ <a-select size="small" style="width:200px;" v-model="printIndex" @change="changePrint" placeholder="选择打印机">
|
|
|
+ <a-select-option v-for="item in printList" :key="'print-'+item.value" :value="item.name">
|
|
|
+ {{ item.name }}
|
|
|
+ </a-select-option>
|
|
|
+ </a-select>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <vue-scroll :ops="ops" :style="{width: Math.round(scalVal*100)+'%',height: '70vh',margin:'0 auto'}">
|
|
|
<div v-if="loadedRatio > 0 && loadedRatio < 1" style="background-color: green; color: white; text-align: center" :style="{ width: loadedRatio * 100 + '%' }">{{ Math.floor(loadedRatio * 100) }}%</div>
|
|
|
<pdf
|
|
|
ref="pdf"
|
|
|
v-for="(item,index) in pdfList"
|
|
|
:key="'pdf-'+index"
|
|
|
- style="width: 100%;"
|
|
|
+ :style="{width: '100%'}"
|
|
|
:src="getUrl('data:application/pdf;base64,' + item)"
|
|
|
:page="page"
|
|
|
:rotate="rotate"
|
|
@@ -77,6 +95,7 @@ export default {
|
|
|
},
|
|
|
data () {
|
|
|
return {
|
|
|
+ scalVal: 0.75,
|
|
|
isShow: this.openModal, // 是否打开弹框
|
|
|
show: true,
|
|
|
pdfList: [],
|
|
@@ -101,12 +120,31 @@ export default {
|
|
|
size: '10px',
|
|
|
'overflow-x': 'hidden'
|
|
|
}
|
|
|
- }
|
|
|
+ },
|
|
|
+ printIndex: undefined,
|
|
|
+ printList: []
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
+ // 选择打印机
|
|
|
+ changePrint (v) {
|
|
|
+ this.printIndex = v
|
|
|
+ this.$store.commit('SET_printDefNeedle', this.printIndex)
|
|
|
+ this.$store.state.app.printTaskID = undefined
|
|
|
+ },
|
|
|
+ // 缩放
|
|
|
+ setScalVal (t) {
|
|
|
+ this.scalVal = this.scalVal + (t ? 0.05 : -0.05)
|
|
|
+ if (this.scalVal > 1) {
|
|
|
+ this.scalVal = 1
|
|
|
+ }
|
|
|
+ if (this.scalVal < 0.5) {
|
|
|
+ this.scalVal = 0.5
|
|
|
+ }
|
|
|
+ },
|
|
|
getUrl (item) {
|
|
|
- return pdf.createLoadingTask({ url: item, CMapReaderFactory })
|
|
|
+ const src = pdf.createLoadingTask({ url: item, CMapReaderFactory })
|
|
|
+ return src
|
|
|
},
|
|
|
setData (data) {
|
|
|
// console.log(data)
|
|
@@ -114,6 +152,10 @@ export default {
|
|
|
this.src = data[0]
|
|
|
this.curpage = 1
|
|
|
this.total = data.length
|
|
|
+ // 获取打印机列表
|
|
|
+ this.printList = getPrintList()
|
|
|
+ const defPrint = this.$store.state.app.printDefNeedle
|
|
|
+ this.printIndex = defPrint ? (defPrint == 'undefined' ? undefined : defPrint) : undefined
|
|
|
},
|
|
|
error: function (err) {
|
|
|
console.log(err)
|
|
@@ -121,16 +163,14 @@ export default {
|
|
|
// 确定
|
|
|
handleCommonOk () {
|
|
|
const _this = this
|
|
|
- const printDefNeedle = _this.$store.state.app.printDefNeedle
|
|
|
- const hasPrint = getPrintList().find(item => item.name == printDefNeedle)
|
|
|
+ const hasPrint = this.printList.find(item => item.name == this.printIndex)
|
|
|
// 已选择打印机
|
|
|
if (hasPrint) {
|
|
|
hasExitTaskByName(function () {
|
|
|
pdfPrint(_this.$store.state.app.pdfPrintList, 0)
|
|
|
})
|
|
|
} else {
|
|
|
- // 选择打印机
|
|
|
- _this.$store.commit('SET_showSelectPrint', true)
|
|
|
+ this.$message.info('请选择打印机')
|
|
|
}
|
|
|
_this.$emit('ok')
|
|
|
},
|
|
@@ -141,10 +181,11 @@ export default {
|
|
|
this.$store.commit('SET_pdfPrintList', [])
|
|
|
this.$store.commit('SET_showPdfPrint', false)
|
|
|
this.$emit('cancel')
|
|
|
+ this.scalVal = 0.75
|
|
|
},
|
|
|
// 下载
|
|
|
handleDownload () {
|
|
|
-
|
|
|
+ console.log(this.$refs.pdf[0].pdf)
|
|
|
}
|
|
|
},
|
|
|
watch: {
|
|
@@ -164,7 +205,25 @@ export default {
|
|
|
|
|
|
<style lang="less">
|
|
|
.common-pdfView-modal{
|
|
|
+ .ant-modal-body{
|
|
|
+ padding: 0 0 30px 0;
|
|
|
+ }
|
|
|
.common-main{
|
|
|
+ background-color: #fff;
|
|
|
+ .tools{
|
|
|
+ padding: 10px;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ border-bottom: 1px solid #eee;
|
|
|
+ background-color: #f8f8f8;
|
|
|
+ > div{
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ >div{
|
|
|
+ padding: 0 10px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
.btn-box{
|
|
|
text-align: center;
|