Pdf.vue 6.7 KB

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