Pdf.vue 7.1 KB

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