contractPDFOne.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395
  1. <template>
  2. <div>
  3. <div id="pdfDom" ref="pdfDom" style="padding: 0px 20px; text-align: center;font-size:12px;color:#333333" v-loading="loading">
  4. <div class="title">
  5. 福建三梵体育用品实业有限公司
  6. </div>
  7. <div class="title-info">
  8. <div class="vertical-bar"></div>
  9. <div class="content">销售订单</div>
  10. </div>
  11. <div style="display:flex;margin-bottom:20px; font-weight: 600;">
  12. <div style="width:50%;padding-right:20px">
  13. <div class="row">
  14. <div class="left">
  15. 需方:
  16. </div>
  17. <div class="right">
  18. {{pdfData.buyCorporationName}}
  19. </div>
  20. </div>
  21. <div class="row">
  22. <div class="left">
  23. 需方名称:
  24. </div>
  25. <div class="right">
  26. {{pdfData.buyCorporationName}}
  27. </div>
  28. </div>
  29. <div class="row">
  30. <div class="left">
  31. 联系人:
  32. </div>
  33. <div class="right">
  34. {{pdfData.buyContactName}}
  35. </div>
  36. </div>
  37. <div class="row">
  38. <div class="left">
  39. 联系电话:
  40. </div>
  41. <div class="right">
  42. {{pdfData.buyContactNumber}}
  43. </div>
  44. </div>
  45. <div class="row">
  46. <div class="left">
  47. 传真:
  48. </div>
  49. <div class="right">
  50. {{pdfData.buyCorporationFax}}
  51. </div>
  52. </div>
  53. </div>
  54. <div style="width:50%">
  55. <div class="row">
  56. <div class="left">
  57. 订单编号:
  58. </div>
  59. <div class="right">
  60. {{pdfData.contractCode}}
  61. </div>
  62. </div>
  63. <div class="row">
  64. <div class="left">
  65. 下单日期:
  66. </div>
  67. <div v-if="pdfData.createTime" class="right">
  68. {{pdfData.createTime.substr(0,10)}} &nbsp;&nbsp;{{calculationWeek(pdfData.createTime)}}
  69. </div>
  70. </div>
  71. <div class="row">
  72. <div class="left">
  73. 结算方式:
  74. </div>
  75. <div class="right">
  76. {{dictKeyValue(pdfData.paymentMethod,fundsPaymentMethod)}}
  77. </div>
  78. </div>
  79. <div class="row">
  80. <div class="left">
  81. 业务员/联系电话:
  82. </div>
  83. <div class="right">
  84. {{pdfData.createUserName}} / {{pdfData.createUserPhone}}
  85. </div>
  86. </div>
  87. <div class="row">
  88. <div class="left">
  89. 送货地址:
  90. </div>
  91. <div class="right">
  92. <span v-if="pdfData.buyCountryName">{{pdfData.buyCountryName}},</span>
  93. <span v-if="pdfData.buyProvinceName">{{pdfData.buyProvinceName}},</span>
  94. <span v-if="pdfData.buyCityName">{{pdfData.buyCityName}},</span>
  95. <span v-if="pdfData.buyDetailedAddress">{{pdfData.buyDetailedAddress}}</span>
  96. </div>
  97. </div>
  98. </div>
  99. </div>
  100. <table border="1" style="width: 100%" class="table">
  101. <tr>
  102. <td>序号</td>
  103. <td>产品名称</td>
  104. <td>规格型号</td>
  105. <td>产品纹路</td>
  106. <td> 颜色</td>
  107. <td>单位</td>
  108. <td>数量</td>
  109. <td>单价</td>
  110. <td>金额</td>
  111. <!-- <td>备注</td> -->
  112. </tr>
  113. <tr v-if="pdfData.productInfoList && pdfData.productInfoList.length > 0" v-for="(item, index) in pdfData.productInfoList" :key="item.id">
  114. <td>{{index+1}}</td>
  115. <td>{{item.productName}}</td>
  116. <td>{{item.productLength }}*{{item.productWidth}}*{{item.productHeight}}</td>
  117. <td>{{dictKeyValue(item.frontalTexture,frontLinesData)}}</td>
  118. <td>{{item.productColor}}</td>
  119. <td>{{dictKeyValue(item.productUnit,materialUnitData)}}</td>
  120. <td>{{moneyFormat(item.productQuantity)}}</td>
  121. <td>{{moneyFormat(item.productPrice)}}</td>
  122. <td>{{moneyFormat(item.amount)}}</td>
  123. <!-- <td>{{item.productRemark}}</td> -->
  124. </tr>
  125. <template v-if="
  126. pdfData.contractProjectList &&
  127. pdfData.contractProjectList.length > 0
  128. ">
  129. <tr v-for="(item, index) in pdfData.contractProjectList" :key="item.id">
  130. <td colspan="8" style="text-align: right">
  131. {{ item.payName }}:
  132. </td>
  133. <td colspan="2">
  134. {{ moneyFormat(item.amount, 2) }}
  135. </td>
  136. </tr>
  137. </template>
  138. <tr>
  139. <td colspan="8" style="text-align: right">
  140. 合同总金额:
  141. </td>
  142. <td colspan="2">
  143. {{ moneyFormat(pdfData.totalAmount, 2) }}
  144. </td>
  145. </tr>
  146. </table>
  147. <div style="margin-top:20px;text-align:left">
  148. <!-- <div v-html="getHtmlVal(pdfData.templateContent)">
  149. </div> -->
  150. <div v-html="pdfData.templateContent"></div>
  151. </div>
  152. <div style="display:flex;margin-top:40px">
  153. <div style="width:50%">
  154. <div class="rowOne">
  155. <div class="left">
  156. 需方签字并盖章:
  157. </div>
  158. <div class="right">
  159. </div>
  160. </div>
  161. <div class="rowOne">
  162. <div class="left">
  163. 经办人:
  164. </div>
  165. <div class="right">
  166. </div>
  167. </div>
  168. <div class="rowOne">
  169. <div class="left">
  170. 主管:
  171. </div>
  172. <div class="right">
  173. </div>
  174. </div>
  175. <div class="rowOne">
  176. <div class="left">
  177. 日期:
  178. </div>
  179. <div class="right">
  180. </div>
  181. </div>
  182. </div>
  183. <div style="width:50%">
  184. <div class="rowOne">
  185. <div class="left">
  186. 供方签字并盖章:
  187. </div>
  188. <div class="right">
  189. </div>
  190. </div>
  191. <div class="rowOne">
  192. <div class="left">
  193. 经办人:
  194. </div>
  195. <div class="right">
  196. </div>
  197. </div>
  198. <div class="rowOne">
  199. <div class="left">
  200. 主管:
  201. </div>
  202. <div class="right">
  203. </div>
  204. </div>
  205. <div class="rowOne">
  206. <div class="left">
  207. 日期:
  208. </div>
  209. <div class="right">
  210. </div>
  211. </div>
  212. </div>
  213. </div>
  214. </div>
  215. <div style="text-align: center;margin-top:20px">
  216. <el-button type="primary" v-print="printObj" size="default" v-debounce>打印</el-button>
  217. <el-button type="primary" @click="clickDownload()" size="default" v-debounce>下载PDF</el-button>
  218. <!-- <el-button type="primary" @click="exportExcel()" size="default" v-debounce>导出Excel</el-button> -->
  219. </div>
  220. </div>
  221. </template>
  222. <script setup>
  223. import { NumberToChinese } from "@/utils/util.js";
  224. import { calculationWeek } from "@/utils/util.js";
  225. import $ from "jquery";
  226. const { proxy } = getCurrentInstance();
  227. const pdfData = ref({});
  228. const props = defineProps({
  229. rowData: Object,
  230. });
  231. const materialUnitData = computed(
  232. () => proxy.useUserStore().allDict["material_unit"]
  233. );
  234. const frontLinesData = computed(
  235. () => proxy.useUserStore().allDict["front_lines"]
  236. );
  237. const fundsPaymentMethod = computed(
  238. () => proxy.useUserStore().allDict["funds_payment_method"]
  239. );
  240. const loading = ref(false);
  241. const getPdfData = (query) => {
  242. loading.value = true;
  243. proxy.post("/contract/getContractPdfInfo", query).then((res) => {
  244. pdfData.value = res;
  245. loading.value = false;
  246. });
  247. };
  248. const productUnit = ref([]);
  249. const tradeMethods = ref([]);
  250. const getBalance = (val) => {
  251. if (val) {
  252. return proxy.moneyFormat(
  253. parseFloat(pdfData.value.totalAmount * (val / 100)).toFixed(2),
  254. 2
  255. );
  256. }
  257. };
  258. const getHtmlVal = (val) => {
  259. if (val) {
  260. return val.replace(/<p>/g, "<div>").replace(/<\/p>/g, "</div>");
  261. }
  262. return "";
  263. };
  264. watch(
  265. () => props.rowData,
  266. (val) => {
  267. if (props.rowData.id) {
  268. getPdfData({ id: props.rowData.id });
  269. }
  270. },
  271. {
  272. immediate: true,
  273. deep: true,
  274. }
  275. );
  276. const printObj = ref({
  277. id: "pdfDom",
  278. popTitle: "",
  279. extraCss:
  280. "https://cdn.bootcdn.net/ajax/libs/animate.css/4.1.1/animate.compat.css, https://cdn.bootcdn.net/ajax/libs/hover.css/2.3.1/css/hover-min.css",
  281. extraHead: '<meta http-equiv="Content-Language"content="zh-cn"/>',
  282. });
  283. const clickDownload = () => {
  284. proxy.getPdf("销售订单PDF文件");
  285. };
  286. const pdfDom = ref(null);
  287. const exportExcel = () => {
  288. // pdfDom.value.exportExcel();
  289. // isShowImg.value = false;
  290. loading.value = true;
  291. setTimeout(() => {
  292. $("#pdfDom").table2excel({
  293. exclude: ".noExl",
  294. sheetName: `销售订单${pdfData.value.code}`,
  295. filename: `销售订单${pdfData.value.code}`,
  296. exclude_img: false,
  297. exclude_links: false,
  298. exclude_inputs: true,
  299. });
  300. // isShowImg.value = true;
  301. loading.value = false;
  302. }, 500);
  303. };
  304. </script>
  305. <style lang="scss" scoped>
  306. .title {
  307. font-size: 28px;
  308. // font-weight: 700;
  309. text-align: center;
  310. }
  311. .title-info {
  312. text-align: center;
  313. width: 100%;
  314. margin: 20px 0 50px 0;
  315. .vertical-bar {
  316. width: 6px;
  317. height: 18px;
  318. background-color: #0084ff;
  319. // background-color: #000;
  320. margin-right: 9px;
  321. display: inline-block;
  322. }
  323. .content {
  324. // font-weight: 600;
  325. font-size: 32px;
  326. color: #333333;
  327. display: inline-block;
  328. }
  329. }
  330. .row {
  331. display: flex;
  332. // line-height: 28px;
  333. .left {
  334. width: 120px;
  335. text-align: justify;
  336. display: inline-block;
  337. &::after {
  338. content: "";
  339. display: inline-block;
  340. width: 100%;
  341. }
  342. }
  343. .right {
  344. width: calc(100% - 120px);
  345. text-align: left;
  346. line-height: 18px;
  347. }
  348. }
  349. .rowOne {
  350. display: flex;
  351. line-height: 32px;
  352. .left {
  353. width: 120px;
  354. text-align: left;
  355. // text-align: justify;
  356. // display: inline-block;
  357. // &::after {
  358. // content: "";
  359. // display: inline-block;
  360. // width: 100%;
  361. // }
  362. }
  363. .right {
  364. width: calc(100% - 120px);
  365. text-align: left;
  366. }
  367. }
  368. .table {
  369. border-collapse: collapse;
  370. border-spacing: 0;
  371. td {
  372. text-align: center;
  373. padding: 2px 4px;
  374. // padding: 5px 10px;
  375. }
  376. }
  377. </style>