Pdf.vue 7.0 KB

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