Pdf.vue 6.5 KB

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