Pdf.vue 6.5 KB

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