tb-orders-email.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>二级市场订单表-电子交易协议</title>
  5. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  6. <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
  7. <!-- 所有的 css js 资源 -->
  8. <link rel="stylesheet" href="https://unpkg.com/element-ui@2.13.0/lib/theme-chalk/index.css">
  9. <link rel="stylesheet" href="../../static/sa.css">
  10. <script src="../../static/kj/vue.min.js"></script>
  11. <script src="../../static/kj/element-ui/index.js"></script>
  12. <script src="../../static/kj/httpVueLoader.js"></script>
  13. <script src="../../static/kj/jquery.min.js"></script>
  14. <script src="../../static/kj/layer/layer.js"></script>
  15. <script src="../../static/sa.js"></script>
  16. <script src="../../static/kj/upload-util.js"></script>
  17. <!-- 引入 html2canvas 和 jsPDF -->
  18. <script src="../../static/kj/html2canvas.min.js"></script>
  19. <script src="../../static/kj/jspdf.umd.min.js"></script>
  20. <style type="text/css">
  21. .c-panel .c-label{width: 8em;}
  22. table {
  23. font-family: arial, sans-serif;
  24. border-collapse: collapse;
  25. width: 90%;
  26. margin-top: 20px ;
  27. margin-left: auto;
  28. margin-right: auto;
  29. }
  30. th {
  31. border: 1px solid darkgray;
  32. text-align: left;
  33. height: 24px;
  34. padding: 8px;
  35. background-color: #dddddd;
  36. }
  37. td {
  38. border: 1px solid darkgray;
  39. text-align: left;
  40. padding: 8px;
  41. }
  42. </style>
  43. </head>
  44. <body>
  45. <div class="vue-box sbot" style="display: none;" :style="'display: block;'">
  46. <!-- ------- 内容部分 ------- -->
  47. <div class="s-body">
  48. <div class="c-panel" id="content-to-convert" ref="contentToConvert">
  49. <el-form v-if="m">
  50. <table>
  51. <tr>
  52. <td colspan='6' style="text-align:center;font-weight: bold; border: 0 0 1px 0; " >电子交易协议</td>
  53. </tr>
  54. <tr>
  55. <td colspan='6' style="font-weight: bold;" >一、交易信息</td>
  56. </tr>
  57. <tr>
  58. <th>订单编号</th>
  59. <td colspan='2'>{{m.orderNo}}</td>
  60. <th>结算单号</th>
  61. <td colspan='2'>{{m.settleBillNo}}</td>
  62. </tr>
  63. <tr>
  64. <th>交易日期</th>
  65. <td colspan='2'>{{m.payTime}}</td>
  66. <th>交货日期</th>
  67. <td colspan='2'></td>
  68. </tr>
  69. <tr>
  70. <th>银行流水号</th>
  71. <td colspan='5'>{{m.result}}</td>
  72. </tr>
  73. <tr>
  74. <th>商品名称</th>
  75. <th>数量</th>
  76. <th>重量(KG)</th>
  77. <th>单价(元)</th>
  78. <th>合计(元)</th>
  79. <th>备注</th>
  80. </tr>
  81. <tr>
  82. <td>{{m.goodsName}}</td>
  83. <td>{{m.buyQty}}</td>
  84. <td>{{m.netWet}}</td>
  85. <td>{{m.singlePrice}}</td>
  86. <td>{{m.resalePrice}}</td>
  87. <td>含税价</td>
  88. </tr>
  89. <tr>
  90. <td>合计</td>
  91. <td>{{m.buyQty}}</td>
  92. <td>{{m.netWet}}</td>
  93. <td>{{m.singlePrice}}</td>
  94. <td>{{m.resalePrice}}</td>
  95. <td>含税价</td>
  96. </tr>
  97. <tr>
  98. <td colspan='6'>合计金额人民币(大写):{{convertToChineseNumeral(m.resalePrice)}}</td>
  99. </tr>
  100. <tr>
  101. <td colspan='6' style="font-weight: bold;" >二、卖方信息</td>
  102. </tr>
  103. <tr>
  104. <th>卖方</th>
  105. <td colspan='2'>{{m.businessName}}</td>
  106. <th>联系人</th>
  107. <td colspan='2'>{{m.contacts}}</td>
  108. </tr>
  109. <tr>
  110. <th>开户行</th>
  111. <td colspan='2'>{{m.peopleBankName}}</td>
  112. <th>联系方式</th>
  113. <td colspan='2'>{{m.phone}}</td>
  114. </tr>
  115. <tr>
  116. <th>银行账号</th>
  117. <td colspan='2'>{{m.peopleBankCode}}</td>
  118. <th>统一信用代码</th>
  119. <td colspan='2'>{{m.peopleDutyParagraph}}</td>
  120. </tr>
  121. <tr>
  122. <td colspan='6' style="font-weight: bold;" >三、买方信息</td>
  123. </tr>
  124. <tr>
  125. <th>买方</th>
  126. <td colspan='2' v-if="m.purchaserBusinessName">{{m.purchaserBusinessName}}</td>
  127. <td colspan='2' v-else>{{m.purchaserName}}</td>
  128. <th>联系人</th>
  129. <td colspan='2' v-if="m.legalPerson">{{m.legalPerson}}</td>
  130. <td colspan='2' v-else>{{m.purchaserName}}</td>
  131. </tr>
  132. <tr>
  133. <th>开户行</th>
  134. <td colspan='2'>{{m.purchaserBankName}}</td>
  135. <th>联系方式</th>
  136. <td colspan='2'>{{m.purchaserContact}}</td>
  137. </tr>
  138. <tr>
  139. <th>银行账号</th>
  140. <td colspan='2'>{{m.purchaserBankAccount}}</td>
  141. <th>统一信用代码</th>
  142. <td colspan='2'>{{m.purchaserDutyParagraph}}</td>
  143. </tr>
  144. <tr>
  145. <td colspan='6' style="font-weight: bold;" >四、其它信息</td>
  146. </tr>
  147. <tr>
  148. <th>交货地点</th>
  149. <td colspan='5'>{{m.unloadingAddress}}</td>
  150. </tr>
  151. <tr>
  152. <th>提货方式</th>
  153. <td colspan='5'></td>
  154. </tr>
  155. <tr>
  156. <th>付款方式</th>
  157. <td colspan='5'></td>
  158. </tr>
  159. <tr>
  160. <th>发票类型</th>
  161. <td colspan='5'></td>
  162. </tr>
  163. <tr>
  164. <th>其它约定</th>
  165. <td colspan='5'></td>
  166. </tr>
  167. <tr>
  168. <th>补充说明</th>
  169. <td colspan='5'></td>
  170. </tr>
  171. <tr>
  172. <td colspan='3'>
  173. 卖方:{{m.businessName}} <br>
  174. 法定代表人或授权委托人:{{m.contacts}}
  175. </td>
  176. <td colspan='3'>
  177. <span>
  178. <span v-if="m.purchaserBusinessName">买方:{{m.purchaserBusinessName}}<br></span>
  179. <span v-else>买方:{{m.purchaserName}}<br></span>
  180. </span>
  181. <span>
  182. <span v-if="m.legalPerson">法定代表人或授权委托人:{{m.legalPerson}}</span>
  183. <span v-else>法定代表人或授权委托人:{{m.purchaserName}}</span>
  184. </span>
  185. </td>
  186. </tr>
  187. </table>
  188. </el-form>
  189. </div>
  190. </div>
  191. <!-- ------- 底部按钮 ------- -->
  192. <div class="s-foot">
  193. <el-button type="success" icon="el-icon-printer" @click="htmlToPdf()">打印协议</el-button>
  194. <el-button type="primary" icon="el-icon-download" @click="downloadToPdf()">下载协议</el-button>
  195. <el-button @click="sa.closeCurrIframe()">关闭</el-button>
  196. </div>
  197. </div>
  198. <script>
  199. var app = new Vue({
  200. components: {
  201. "sa-info": httpVueLoader('../../sa-frame/com/sa-info.vue')
  202. },
  203. el: '.vue-box',
  204. data: {
  205. id: sa.p('id', 0), // 获取数据ID
  206. m: null
  207. },
  208. methods: {
  209. downloadToPdf() {
  210. const element = document.getElementById('content-to-convert');
  211. html2canvas(element).then(canvas => {
  212. // 使用 jsPDF 将 canvas 转换成 PDF
  213. const imgData = canvas.toDataURL('image/png');
  214. const pdf = new jspdf.jsPDF({
  215. orientation: 'portrait',
  216. unit: 'px',
  217. format: 'a4'
  218. });
  219. const imgProps = pdf.getImageProperties(imgData);
  220. const pdfWidth = pdf.internal.pageSize.getWidth();
  221. const pdfHeight = (imgProps.height * pdfWidth) / imgProps.width;
  222. // 添加图片,适应页面大小
  223. pdf.addImage(imgData, 'PNG', 0, 0, pdfWidth, pdfHeight);
  224. pdf.save(Date.now()+'.pdf');
  225. });
  226. },
  227. htmlToPdf() {
  228. const element = document.getElementById('content-to-convert');
  229. html2canvas(element).then(canvas => {
  230. // 使用 jsPDF 将 canvas 转换成 PDF
  231. const imgData = canvas.toDataURL('image/png');
  232. const pdf = new jspdf.jsPDF({
  233. orientation: 'portrait',
  234. unit: 'px',
  235. format: 'a4'
  236. });
  237. const imgProps = pdf.getImageProperties(imgData);
  238. const pdfWidth = pdf.internal.pageSize.getWidth();
  239. const pdfHeight = (imgProps.height * pdfWidth) / imgProps.width;
  240. // 添加图片,适应页面大小
  241. pdf.addImage(imgData, 'PNG', 0, 0, pdfWidth, pdfHeight);
  242. // 将 PDF 保存为 Blob 并处理它 这里需要处理跨域问题
  243. const pdfBlob = pdf.output('blob');
  244. var blobURL = window.URL.createObjectURL(pdfBlob);
  245. var newWindow = window.open(blobURL, '_blank');
  246. if (newWindow) {
  247. newWindow.focus();
  248. } else {
  249. alert('请允许弹出窗口或在新标签页中手动查看 PDF。');
  250. }
  251. });
  252. },
  253. convertToChineseNumeral(money) {
  254. // 汉字的数字
  255. const cnNums = ['零','壹','贰','叁','肆','伍','陆','柒','捌','玖']
  256. // 基本单位
  257. const cnIntRadice = ['', '拾', '佰', '仟']
  258. // 对应整数部分扩展单位
  259. const cnIntUnits = ['', '万', '亿', '兆']
  260. // 对应小数部分单位
  261. const cnDecUnits = ['角', '分', '毫', '厘']
  262. // 整数金额时后面跟的字符
  263. const cnInteger = '整'
  264. // 整型完以后的单位
  265. const cnIntLast = '圆'
  266. // 最大处理的数字
  267. const maxNum = 999999999999999.9999
  268. // 金额整数部分
  269. let integerNum
  270. // 金额小数部分
  271. let decimalNum
  272. // 输出的中文金额字符串
  273. let chineseStr = ''
  274. // 分离金额后用的数组,预定义
  275. let parts
  276. if (money == '') {
  277. return ''
  278. }
  279. money = parseFloat(money)
  280. if (money >= maxNum) {
  281. // 超出最大处理数字
  282. return ''
  283. }
  284. if (money == 0) {
  285. chineseStr = cnNums[0] + cnIntLast + cnInteger
  286. return chineseStr
  287. }
  288. // 转换为字符串
  289. money = money.toString()
  290. if (money.indexOf('.') == -1) {
  291. integerNum = money
  292. decimalNum = ''
  293. } else {
  294. parts = money.split('.')
  295. integerNum = parts[0]
  296. decimalNum = parts[1].substr(0, 4)
  297. }
  298. // 获取整型部分转换
  299. if (parseInt(integerNum, 10) > 0) {
  300. let zeroCount = 0
  301. const IntLen = integerNum.length
  302. for (let i = 0; i < IntLen; i++) {
  303. const n = integerNum.substr(i, 1)
  304. const p = IntLen - i - 1
  305. const q = p / 4
  306. const m = p % 4
  307. if (n == '0') {
  308. zeroCount++
  309. } else {
  310. if (zeroCount > 0) {
  311. chineseStr += cnNums[0]
  312. }
  313. // 归零
  314. zeroCount = 0
  315. chineseStr += cnNums[parseInt(n)] + cnIntRadice[m]
  316. }
  317. if (m == 0 && zeroCount < 4) {
  318. chineseStr += cnIntUnits[q]
  319. }
  320. }
  321. chineseStr += cnIntLast
  322. }
  323. // 小数部分
  324. if (decimalNum != '') {
  325. const decLen = decimalNum.length
  326. for (let i = 0; i < decLen; i++) {
  327. const n = decimalNum.substr(i, 1)
  328. if (n != '0') {
  329. chineseStr += cnNums[Number(n)] + cnDecUnits[i]
  330. }
  331. }
  332. }
  333. if (chineseStr == '') {
  334. chineseStr += cnNums[0] + cnIntLast + cnInteger
  335. } else if (decimalNum == '') {
  336. chineseStr += cnInteger
  337. }
  338. return chineseStr
  339. }
  340. },
  341. mounted: function() {
  342. sa.ajax('/level-two-server/TbOrders/getSubEmail?id=' + this.id, function(res) {
  343. this.m = res.data;
  344. if(res.data == null) {
  345. sa.alert('未能查找到 id=' + this.id + " 详细数据");
  346. }
  347. }.bind(this))
  348. }
  349. })
  350. </script>
  351. </body>
  352. </html>