Pdf.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. <template>
  2. <el-dialog
  3. class="my-dialog"
  4. fullscreen
  5. append-to-body
  6. :model-value="showDialog"
  7. @close="closeDialog()"
  8. >
  9. <div class="pdf-main">
  10. <div class="title" >
  11. <div class="name" ></div>
  12. <div class="pdf-close cursor-pointer" @click="closeDialog"></div>
  13. </div>
  14. <div id="printTest" class="pdf-dialog-box">
  15. <div class="pdf-my-body" >
  16. <div class="pdfBox" >
  17. <div class="a4" >
  18. <div class="a4_title">确权单</div>
  19. <table class="a4_table" border=1 style="border-collapse: collapse;">
  20. <tr>
  21. <td class="name">农场地址</td>
  22. <td class="text">{{rowData.address}}</td>
  23. <td class="name">农场名称</td>
  24. <td class="text">{{rowData.farmName}}</td>
  25. </tr>
  26. <tr>
  27. <td class="name">创建时间</td>
  28. <td class="text">{{rowData.createDate}}</td>
  29. <td class="name">农场面积</td>
  30. <td class="text">{{rowData.area}}亩</td>
  31. </tr>
  32. <tr>
  33. <td class="name">作物物种</td>
  34. <td class="text">{{rowData.speciesTypeName}}</td>
  35. <td class="name">客户姓名</td>
  36. <td class="text">{{rowData.masterName}}</td>
  37. </tr>
  38. <tr>
  39. <td class="name">联系电话</td>
  40. <td class="text">{{rowData.masterTel}}</td>
  41. </tr>
  42. <tr>
  43. <td class="name">经纬度</td>
  44. <td colspan="3" class="text2">{{rowData.points}}</td>
  45. </tr>
  46. </table>
  47. <div class="a4_sub_title">地块四至图</div>
  48. <div class="img_box" >
  49. <img class="img-content img" style="z-index: 999" width="595" height="500" v-if="imgUrl" :src="imgUrl" />
  50. <div class="img-content" v-if="!imgUrl" ref="mapRef" id="mapRefId"></div>
  51. </div>
  52. <div class="signature">签名:______________</div>
  53. </div>
  54. </div>
  55. </div>
  56. </div>
  57. <div style="text-align: left">
  58. <el-button size="large" color="#626aef" v-print="printObj">打印</el-button>
  59. <!-- <el-button size="large" color="#626aef" @click="closeDialog">关闭</el-button>-->
  60. </div>
  61. </div>
  62. </el-dialog>
  63. </template>
  64. <script setup>
  65. import {reactive, ref, toRefs, computed, nextTick, onMounted} from "vue";
  66. import {useStore} from "vuex";
  67. import {WKT} from "ol/format";
  68. import PdfMap from "./pdfMap";
  69. import { dateFormat } from "@/utils/date_util";
  70. import {getAreaByWkt} from "../../utils/map";
  71. const emit = defineEmits(["closeDialog","success"])
  72. const state = useStore().state;
  73. const sendConfirmShow = ref(false)
  74. const mapRef = ref(null)
  75. let pdfMap = new PdfMap()
  76. let rowData = ref({})
  77. async function send(){
  78. closeDialog();
  79. }
  80. const props = defineProps({
  81. title:{
  82. type:String,
  83. required:true
  84. },
  85. showDialog: {
  86. type: Boolean,
  87. default: true,
  88. },
  89. rowId:{
  90. type: Number,
  91. required:true,
  92. }
  93. });
  94. let printObj = {
  95. id:"printTest",
  96. popTitle: 'good print',
  97. beforeOpenCallback (vue) {
  98. toImg(pdfMap.kmap.map)
  99. console.log('打开之前')
  100. },
  101. openCallback (vue) {
  102. let {masterName, farmName, masterTel} = rowData.value
  103. document.title =`${farmName}-${masterTel}-${masterName}`
  104. console.log('执行了打印')
  105. },
  106. closeCallback (vue) {
  107. document.title =`飞鸟确权平台`
  108. console.log('关闭了打印工具')
  109. }
  110. }
  111. let imgUrl = ref(null)
  112. const executor = ref([])
  113. const executorList = ref([])
  114. const formRef = ref(null);
  115. const {title, rowId} = toRefs(props);
  116. const closeDialog = (key) => {
  117. switch (key){
  118. case "sendConfirm":
  119. sendConfirmShow.value = false;
  120. return
  121. }
  122. emit("closeDialog", "pdf");
  123. };
  124. function toImg(map) {
  125. let canvas = map.getViewport().querySelector('canvas');
  126. let dataURL = canvas.toDataURL('image/png');
  127. imgUrl.value = dataURL;
  128. }
  129. onMounted(()=>{
  130. VE_API.authentic.getDetails({id:rowId.value}).then(({data})=>{
  131. data.createDate = dateFormat(new Date(), "YYYY-mm-dd HH:MM:SS");
  132. data.area = getAreaByWkt(data.geom)
  133. rowData.value = data
  134. pdfMap.initMap(data,mapRef.value)
  135. // setTimeout(()=>{
  136. // toImg(pdfMap.kmap.map)
  137. // },500)
  138. })
  139. })
  140. </script>
  141. <style lang="scss" scoped>
  142. $title-height:0px;
  143. $body-height:calc(100% - $title-height);
  144. .pdf-main{
  145. left: 25%;
  146. right: 25%;
  147. top:10%;
  148. bottom:10%;
  149. background: rgba(1,17,22,0.8);
  150. box-shadow: 0px 0px 20px 0px #00FFF0;
  151. border-radius: 4px;
  152. border: 2px solid rgba(81,233,240,0.6);
  153. position: absolute;
  154. .title{
  155. width: 100%;
  156. height: $title-height;
  157. box-sizing: border-box;
  158. background: rgba(0,77,101,0.8);
  159. border-radius: 4px 4px 0px 0px;
  160. border-bottom: 2px solid rgba(81,233,240,0.3);
  161. display: flex;
  162. align-items: center;
  163. justify-content: space-between;
  164. .name{
  165. margin-left: 20px;
  166. font-size: 16px;
  167. font-weight: 600;
  168. color: #00FFF0;
  169. height: 22px;
  170. }
  171. .pdf-close{
  172. width: 16px;
  173. height: 16px;
  174. background-image: url("@/assets/img/close.png");
  175. background-size: 100% 100%;
  176. }
  177. }
  178. }
  179. .pdf-dialog-box{
  180. font-family: PingFangSC-Regular, PingFang SC;
  181. width: 100%;
  182. height: 100%;
  183. .pdf-my-body{
  184. width: 100%;
  185. height: $body-height;
  186. box-sizing: border-box;
  187. padding: 20px;
  188. ::-webkit-scrollbar-thumb {
  189. /* 滚动条里面小方块 */
  190. background: rgb(70, 71, 71);;
  191. border-radius: 6px;
  192. }
  193. ::-webkit-scrollbar-track {
  194. /* 滚动条里面轨道 */
  195. background: #ededed;
  196. }
  197. }
  198. .pdfBox{
  199. height: calc(100%);
  200. width: 100%;
  201. overflow-y: scroll;
  202. background-color: rgba(141, 142, 142);
  203. padding: 10px;
  204. box-sizing: border-box;
  205. display: flex;
  206. justify-content: center;
  207. }
  208. .a4{
  209. font-family: PingFangSC-Medium, PingFang SC;
  210. background-color: #FFFFFF;
  211. width:595px;
  212. height:1000px;
  213. margin: 5px 0px 5px 0px;
  214. padding: 19px 63px 19px 63px;
  215. font-weight: 600;
  216. color: #000000;
  217. .a4_title{
  218. width:595px;
  219. height: 33px;
  220. font-size: 24px;
  221. text-align: center;
  222. margin: 10px 0px 10px 0px;
  223. }
  224. .a4_sub_title{
  225. font-size: 16px;
  226. margin: 10px 0px 10px 0px;
  227. }
  228. .a4_table{
  229. height: calc(842px - 33px - 26px - 600px);
  230. max-height: calc(842px - 33px - 26px - 600px);
  231. width:595px;
  232. font-size: 12px;
  233. .name{
  234. width: 50px;
  235. height: 20px;
  236. line-height: 20px;
  237. padding-right: 9px;
  238. box-sizing: border-box;
  239. text-align: right;
  240. }
  241. .text{
  242. width: 122px;
  243. height: 20px;
  244. line-height: 20px;
  245. text-align: left;
  246. padding-left: 9px;
  247. box-sizing: border-box;
  248. }
  249. .text2{
  250. text-align: left;
  251. font-size: 10px;
  252. font-weight: normal;
  253. }
  254. }
  255. .img_box{
  256. position: relative;
  257. width:595px;
  258. height: 500px;
  259. z-index: 1000;
  260. .img-content{
  261. position: absolute;
  262. width:595px;
  263. height: 500px;
  264. z-index: 1000;
  265. }
  266. .img{
  267. z-index: 999;
  268. }
  269. }
  270. .signature{
  271. width:595px;
  272. height: 20px;
  273. z-index: 1000;
  274. margin-top: 40px;
  275. text-align: right;
  276. }
  277. }
  278. }
  279. </style>