already.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428
  1. <template>
  2. <div class="already">
  3. <!-- 头部细节部分 -->
  4. <div class="title">
  5. <el-row>
  6. <el-col :span="24">
  7. <div class="top">
  8. <el-select style="width:170px" v-model="formList.companyName" filterable placeholder="请选择公司名称">
  9. <el-option
  10. v-for="item in companyList"
  11. :key="item.companyName"
  12. :label="item.companyName"
  13. :value="item.companyName">
  14. </el-option>
  15. </el-select>
  16. <el-input placeholder="请输入车牌号码" style="width:170px" class="input-demo" v-model="formList.carNum"></el-input>
  17. <el-date-picker v-model="formList.invoiceMakeTime" type="daterange" value-format="yyyy-MM-dd HH:mm:SS" range-separator="至" start-placeholder="开票时间始" end-placeholder="开票时间止"></el-date-picker>
  18. <el-button type="success" style="margin-left: 1%;" @click="firstLoadData" v-loading.fullscreen.lock="fullscreenLoading">查询</el-button>
  19. <el-button type="success" style="margin-left: 1%;" @click="queryLook" v-loading.fullscreen.lock="fullscreenLoading">更新(取票)</el-button>
  20. <el-button type="primary" @click="exportExcel">导出报表</el-button>
  21. </div>
  22. </el-col>
  23. </el-row>
  24. </div>
  25. <!-- 头部细节部分结束 -->
  26. <template>
  27. <el-table
  28. class="table"
  29. ref="multipleTable"
  30. :data="usertabletwo"
  31. :height="heightt"
  32. border
  33. tooltip-effect="dark">
  34. <el-table-column
  35. label="企业编号"
  36. prop="companyNum"
  37. show-overflow-tooltip>
  38. </el-table-column>
  39. <el-table-column
  40. prop="companyName"
  41. label="公司名称"
  42. show-overflow-tooltip>
  43. </el-table-column>
  44. <el-table-column
  45. prop="buyerTaxpayerCode"
  46. label="购方税号"
  47. show-overflow-tooltip>
  48. </el-table-column>
  49. <el-table-column
  50. prop="plateNum"
  51. label="车牌号"
  52. show-overflow-tooltip>
  53. </el-table-column>
  54. <el-table-column
  55. prop="cardId"
  56. label="ETC卡号"
  57. show-overflow-tooltip>
  58. </el-table-column>
  59. <el-table-column
  60. prop="tradeId"
  61. label="交易ID"
  62. show-overflow-tooltip>
  63. </el-table-column>
  64. <el-table-column
  65. prop="sellerTaxpayerCode"
  66. label="销方税号"
  67. show-overflow-tooltip>
  68. </el-table-column>
  69. <el-table-column
  70. prop="sellerName"
  71. label="销方名称"
  72. show-overflow-tooltip>
  73. </el-table-column>
  74. <el-table-column
  75. prop="enStation"
  76. label="入口收费站"
  77. width="120"
  78. show-overflow-tooltip>
  79. </el-table-column>
  80. <el-table-column
  81. prop="exStation"
  82. label="出口收费站"
  83. width="120"
  84. show-overflow-tooltip>
  85. </el-table-column>
  86. <el-table-column
  87. prop="invoiceNum"
  88. label="发票号码"
  89. show-overflow-tooltip>
  90. </el-table-column>
  91. <el-table-column
  92. prop="invoiceCode"
  93. label="发票代码"
  94. show-overflow-tooltip>
  95. </el-table-column>
  96. <el-table-column
  97. prop="invoiceMakeTime"
  98. label="开票时间"
  99. show-overflow-tooltip>
  100. </el-table-column>
  101. <el-table-column
  102. label="交易金额(元)"
  103. width="120"
  104. show-overflow-tooltip>
  105. <template slot-scope="scope" show-overflow-tooltip>
  106. <span>{{scope.row.fee / 100}}</span>
  107. </template>
  108. </el-table-column>
  109. <el-table-column
  110. label="价税合计(元)"
  111. width="120"
  112. show-overflow-tooltip>
  113. <template slot-scope="scope" show-overflow-tooltip>
  114. <span>{{scope.row.totalAmount / 100}}</span>
  115. </template>
  116. </el-table-column>
  117. <el-table-column
  118. label="税额(元)"
  119. show-overflow-tooltip>
  120. <template slot-scope="scope" show-overflow-tooltip>
  121. <span>{{scope.row.totalTaxAmount / 100}}</span>
  122. </template>
  123. </el-table-column>
  124. <el-table-column
  125. prop="amount"
  126. label="金额"
  127. show-overflow-tooltip>
  128. <template slot-scope="scope">
  129. <span>{{scope.row.fee/100| rounding}}</span>
  130. </template>
  131. </el-table-column>
  132. <el-table-column
  133. prop="taxRate"
  134. label="税率"
  135. show-overflow-tooltip>
  136. <template slot-scope="scope">
  137. <span>{{scope.row.taxRate| rounding}}</span>
  138. </template>
  139. </el-table-column>
  140. <el-table-column
  141. prop="invoiceHtmlUrl"
  142. label="预览地址"
  143. show-overflow-tooltip>
  144. </el-table-column>
  145. <el-table-column
  146. prop="invoiceUrl"
  147. label="下载地址"
  148. show-overflow-tooltip>
  149. </el-table-column>
  150. <el-table-column
  151. prop="tradeStatus"
  152. label="状态"
  153. show-overflow-tooltip>
  154. <template slot-scope="scope">
  155. <span v-if="scope.row.tradeStatus == 1" style="color: green">待开票</span>
  156. <span v-else-if="scope.row.tradeStatus == 2" style="color: red">开票中</span>
  157. <span v-else-if="scope.row.tradeStatus == 3" style="color: red">已开票</span>
  158. </template>
  159. </el-table-column>
  160. <el-table-column
  161. prop="calculateTime"
  162. label="计费时间"
  163. show-overflow-tooltip>
  164. </el-table-column>
  165. <el-table-column
  166. label="操作"
  167. width="80">
  168. <template slot-scope="scope" show-overflow-tooltip>
  169. <span style="cursor:pointer;" @click="checkLook(scope.row.invoiceUrl)">下载</span>
  170. </template>
  171. </el-table-column>
  172. </el-table>
  173. </template>
  174. <!-- 分页 -->
  175. <div class="block">
  176. <el-pagination
  177. @size-change="handleSizeChange"
  178. @current-change="handleCurrentChange"
  179. :current-page="current"
  180. :page-sizes="[6, 8, 10, 20, 50, 100]"
  181. :page-size="pagesize"
  182. layout="total, sizes, prev, pager, next, jumper"
  183. :total="total">
  184. </el-pagination>
  185. </div>
  186. </div>
  187. </template>
  188. <script>
  189. import FileSaver from "file-saver";
  190. import XLSX from "xlsx";
  191. export default{
  192. data() {
  193. return {
  194. fullscreenLoading: false,
  195. usertabletwo: [],
  196. roleId: '',
  197. hightt:'0px',
  198. // codeNumber: '',
  199. formList: {
  200. "companyName": "",
  201. "customerName": "",
  202. "carNum": "",
  203. "startTime": "",
  204. "endTime": "",
  205. "invoiceMakeTime":""
  206. },
  207. current: 1,
  208. pagesize: 8,
  209. total:'',
  210. companyList:[]
  211. }
  212. },
  213. created() {
  214. this.heightt = tableHeight+20;
  215. this.formList.customerName = sessionStorage.getItem('userName');
  216. this.initCompanyList();
  217. },
  218. methods: {
  219. firstLoadData(){
  220. this.current = 1;
  221. this.pagesize = 8;
  222. this.loadData();
  223. },
  224. // 列表展示
  225. async loadData() {
  226. const formData = new FormData();
  227. formData.append('current', this.current);
  228. formData.append('size', this.pagesize);
  229. formData.append('customerName', this.formList.customerName);
  230. formData.append('companyName', this.formList.companyName);
  231. formData.append('plateNum', this.formList.carNum);
  232. formData.append('invoiceMakeTime', this.formList.invoiceMakeTime);
  233. const response = await this.$http.post('selfCar/findSelfCarInvoices', formData);
  234. if (response.data.code === 0) {
  235. this.usertabletwo = response.data.data.records;
  236. this.total = response.data.data.total;
  237. }
  238. },
  239. // 查询已开发票数据
  240. async queryLook() {
  241. if(this.formList.invoiceMakeTime !=null && this.formList.invoiceMakeTime !=''){
  242. this.formList.startTime = this.formList.invoiceMakeTime[0];
  243. this.formList.endTime = this.formList.invoiceMakeTime[1];
  244. }
  245. const response = await this.$http.post(`/selfCar/findSelfcarInvoiceByTime`, this.formList);
  246. var {data: { code, msg, data }} = response;
  247. if(code === 0) {
  248. this.$message({
  249. type: 'success',
  250. message: '更新成功'
  251. });
  252. }else{
  253. this.$message.error(msg);
  254. }
  255. },
  256. async initCompanyList(){
  257. const response = await this.$http.post(`lowerService/customeRecQueryList`, {"customerName":sessionStorage.getItem('userName')});
  258. if (response.data.code === 0) {
  259. this.companyList = response.data.data;
  260. }
  261. if(this.companyList == null || typeof this.companyList == 'undefined' || this.companyList =='' || this.companyList.length==0){
  262. this.companyList = [{'companyName':'.'}];
  263. }
  264. this.formList.companyName = this.companyList[0]['companyName'];
  265. this.loadData();
  266. },
  267. // 展示发票全部信息
  268. checkLook(user) {
  269. window.location.href= user;
  270. },
  271. // 分页方法
  272. handleSizeChange(val) {
  273. this.pagesize = val;
  274. this.loadData();
  275. console.log(`每页 ${val} 条`);
  276. },
  277. handleCurrentChange(val) {
  278. this.current = val;
  279. this.loadData();
  280. // console.log(`当前页: ${val}`);
  281. },
  282. formartNum(wb){
  283. var sheet = wb['Sheets']['Sheet1'];
  284. var replaceTemp = [];
  285. for(var i in sheet){
  286. if(sheet[i]['v'] == '税额(元)'||sheet[i]['v'] == '价税合计(元)'||sheet[i]['v'] == '交易金额(元)'){
  287. replaceTemp.push(i.replace(/[0-9]/g,''));
  288. continue;
  289. }
  290. if(replaceTemp.includes(i.replace(/[0-9]/g,''))){
  291. sheet[i]['t']='n';
  292. }
  293. }
  294. },
  295. async exportExcel() {
  296. const loading = this.$loading({
  297. lock: true,
  298. text: '系统正在努力接收中,过程大概需要几分钟的时间,请您耐心等待...',
  299. spinner: 'el-icon-loading',
  300. background: 'rgba(0, 0, 0, 0.7)'
  301. });
  302. let curr = this.current;
  303. let pagesize1 = this.pagesize;
  304. this.current = 1;
  305. this.pagesize = this.total;
  306. await this.loadData();
  307. // 设置当前日期
  308. let time = new Date();
  309. //console.log(time);
  310. let year = time.getFullYear();
  311. let month = time.getMonth() + 1;
  312. let day = time.getDate();
  313. let name = "自有车发票查询列表_"+year + "" + month + "" + day;
  314. // console.log(name)
  315. /* generate workbook object from table */
  316. // .table要导出的是哪一个表格
  317. var wb = XLSX.utils.table_to_book(document.querySelector(".table"),{ raw: true });
  318. this.formartNum(wb);
  319. /* get binary string as output */
  320. var wbout = XLSX.write(wb, {
  321. bookType: "xlsx",
  322. bookSST: true,
  323. type: "array"
  324. });
  325. try {
  326. // name+'.xlsx'表示导出的excel表格名字
  327. FileSaver.saveAs(
  328. new Blob([wbout], { type: "application/octet-stream" }),
  329. name + ".xlsx"
  330. );
  331. } catch (e) {
  332. if (typeof console !== "undefined") console.log(e, wbout);
  333. }
  334. this.current = curr;
  335. this.pagesize = pagesize1;
  336. this.loadData();
  337. loading.close();
  338. return wbout;
  339. },
  340. }
  341. };
  342. </script>
  343. <style>
  344. .already {
  345. border: 1px solid #d9d9d9;
  346. border-radius: 10px;
  347. }
  348. .already .title {
  349. font-size: 5px;
  350. margin-bottom: 20px;
  351. margin-top: 20px;
  352. }
  353. .already .top {
  354. padding-top: 20px;
  355. padding-left: 20px;
  356. }
  357. .already .input-demo {
  358. display: inline-block;
  359. width: 20%;
  360. margin-left: 1%;
  361. }
  362. .already {
  363. border: 1px solid #d9d9d9;
  364. border-radius: 10px;
  365. }
  366. .already .title {
  367. font-size: 5px;
  368. margin-bottom: 20px;
  369. }
  370. .already .top {
  371. padding-top: 20px;
  372. padding-left: 20px;
  373. }
  374. .already .text {
  375. display: inline-block;
  376. color: #000;
  377. font-size: 16px ;
  378. margin-left: 1%;
  379. }
  380. .already .input-demo {
  381. display: inline-block;
  382. width: 20%;
  383. margin-left: 1%;
  384. }
  385. .already .block {
  386. font-size: 5px;
  387. text-align: center;
  388. margin-top: 25px;
  389. margin-bottom: 25px;
  390. }
  391. .already .el-dialog {
  392. width: 60%;
  393. }
  394. .already .el-dialog__header, .el-dialog__body {
  395. padding: 0 20px;
  396. }
  397. .already .tou {
  398. font-size: 20px;
  399. height: 30px;
  400. line-height: 30px;
  401. padding-top: 15px;
  402. }
  403. .already .line {
  404. margin-top: 15px;
  405. margin-bottom: 15px;
  406. width: 100%;
  407. height: 2px;
  408. background-color: #d9d9d9;
  409. }
  410. .already .xinxi {
  411. text-align: center;
  412. margin: 15px auto;
  413. font-size: 18px;
  414. }
  415. </style>