index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439
  1. <template>
  2. <div class="my-invoice">
  3. <div class="my-invoice__header">
  4. <el-button type="primary" @click="apply">申请发票</el-button>
  5. </div>
  6. <div class="my-invoice__body">
  7. <el-table :data="tableData" style="width: 100%">
  8. <el-table-column
  9. align="center"
  10. header-align="center"
  11. type="index"
  12. label="序号"
  13. />
  14. <el-table-column
  15. align="center"
  16. header-align="center"
  17. prop="invoiceTitle"
  18. label="发票抬头"
  19. >
  20. </el-table-column>
  21. <el-table-column
  22. align="center"
  23. header-align="center"
  24. prop="amount"
  25. label="开票金额"
  26. >
  27. <template slot-scope="scope">
  28. ¥{{ scope.row.amount | toFixed }}
  29. </template>
  30. </el-table-column>
  31. <el-table-column align="center" header-align="center" label="发票类型">
  32. <template slot-scope="scope">
  33. {{
  34. scope.row.type == 1
  35. ? "普通发票"
  36. : scope.row.type == 2
  37. ? "增值税专用发票"
  38. : ""
  39. }}
  40. </template>
  41. </el-table-column>
  42. <!-- <el-table-column align="center" header-align="center" label="开票状态"
  43. ><template slot-scope="scope">
  44. {{
  45. scope.row.invoiceStatus == 1
  46. ? "未开票"
  47. : scope.row.invoiceStatus == 2
  48. ? "已开票"
  49. : scope.row.invoiceStatus == -1
  50. ? "已退票"
  51. : ""
  52. }}
  53. </template>
  54. </el-table-column> -->
  55. <el-table-column align="center" header-align="center" label="申请时间">
  56. <template slot-scope="scope">
  57. {{ $tools.timestampToTime(scope.row.applyTime, false, false) }}
  58. </template>
  59. </el-table-column>
  60. <el-table-column align="center" header-align="center" label="开票订单">
  61. <template slot-scope="scope">
  62. <div v-for="(item, index) in scope.row.orderList" :key="index">
  63. {{ item.orderSn }}
  64. </div>
  65. </template>
  66. </el-table-column>
  67. <el-table-column align="center" header-align="center" label="审核状态">
  68. <template slot-scope="scope">
  69. {{
  70. scope.row.periodStatus == 1
  71. ? "待审核"
  72. : scope.row.periodStatus == 3
  73. ? "通过"
  74. : scope.row.periodStatus == 2
  75. ? "驳回"
  76. : ""
  77. }}
  78. </template>
  79. </el-table-column>
  80. <el-table-column align="center" header-align="center" label="发票状态">
  81. <template slot-scope="scope">
  82. {{
  83. scope.row.invoiceStatus == 1
  84. ? "未开票"
  85. : scope.row.invoiceStatus == 2
  86. ? "已开票"
  87. : scope.row.invoiceStatus == -1
  88. ? "已退票"
  89. : ""
  90. }}
  91. </template>
  92. </el-table-column>
  93. <el-table-column align="center" header-align="center" label="操作">
  94. <template slot-scope="scope">
  95. <el-button
  96. @click.native.prevent="showDetail(scope.row)"
  97. type="text"
  98. size="small"
  99. >
  100. 查看
  101. </el-button>
  102. <el-button
  103. v-if="
  104. scope.row.periodStatus == 3 &&
  105. (scope.row.invoiceStatus == 2 ||
  106. scope.row.invoiceStatus == -1) &&
  107. scope.row.invoiceImg
  108. "
  109. @click.native.prevent="download(scope.row)"
  110. type="text"
  111. size="small"
  112. >
  113. 下载
  114. </el-button>
  115. </template>
  116. </el-table-column>
  117. </el-table>
  118. <div class="pagination">
  119. <el-pagination
  120. @current-change="currentChange"
  121. background
  122. layout="prev, pager, next"
  123. :total="total"
  124. :pager-count="5"
  125. :page-size="params.pageSize"
  126. >
  127. </el-pagination>
  128. </div>
  129. </div>
  130. <el-dialog
  131. :title="$tools.timestampToTime(invoiceDetail.applyTime, false, false)"
  132. :visible.sync="invoiceDetailModal"
  133. custom-class="invoice-modal"
  134. >
  135. <el-descriptions title="发票申请信息" :column="2">
  136. <el-descriptions-item label="发票类型"
  137. ><span v-if="invoiceDetail.type == 1">普通发票</span>
  138. <span v-if="invoiceDetail.type == 2"
  139. >增值税专用发票</span
  140. ></el-descriptions-item
  141. >
  142. <el-descriptions-item label="申请主体"
  143. ><span v-if="invoiceDetail.subject == 1">个人</span>
  144. <span v-if="invoiceDetail.subject == 2"
  145. >企业</span
  146. ></el-descriptions-item
  147. >
  148. <el-descriptions-item label="发票抬头">{{
  149. invoiceDetail.invoiceTitle
  150. }}</el-descriptions-item>
  151. <el-descriptions-item label="开票订单"> </el-descriptions-item>
  152. <el-descriptions-item label="开票金额">
  153. ¥ {{ invoiceDetail.amount }}
  154. </el-descriptions-item>
  155. <template v-if="invoiceDetail.type == 2">
  156. <el-descriptions-item label="纳税登记号">
  157. {{ invoiceDetail.taxRegistryNumber || "" }}
  158. </el-descriptions-item>
  159. <el-descriptions-item label="单位地址">{{
  160. invoiceDetail.companyAddress || ""
  161. }}</el-descriptions-item
  162. ><el-descriptions-item label="电话号码">{{
  163. invoiceDetail.phone || ""
  164. }}</el-descriptions-item
  165. ><el-descriptions-item label="开户银行">{{
  166. invoiceDetail.bankName || ""
  167. }}</el-descriptions-item
  168. ><el-descriptions-item label="银行账号">{{
  169. invoiceDetail.bankAccount || ""
  170. }}</el-descriptions-item
  171. ><el-descriptions-item label="收件地址">{{
  172. invoiceDetail.receivingAddress || ""
  173. }}</el-descriptions-item
  174. ><el-descriptions-item label="收件人">{{
  175. invoiceDetail.receivingName || ""
  176. }}</el-descriptions-item
  177. ><el-descriptions-item label="收件手机">{{
  178. invoiceDetail.receivingTel || ""
  179. }}</el-descriptions-item>
  180. </template>
  181. </el-descriptions>
  182. <el-descriptions title="发票申请结果" :column="1">
  183. <el-descriptions-item label="审核结果">
  184. <span class="text wait" v-if="invoiceDetail.periodStatus == 1"
  185. >待审核</span
  186. >
  187. <span class="text agree" v-if="invoiceDetail.periodStatus == 3"
  188. >通过</span
  189. >
  190. <span class="text refuse" v-if="invoiceDetail.periodStatus == 2"
  191. >驳回</span
  192. >
  193. </el-descriptions-item>
  194. <el-descriptions-item label="审核反馈">{{
  195. invoiceDetail.periodReason || ""
  196. }}</el-descriptions-item>
  197. <el-descriptions-item label="发票状态">
  198. <span class="text refuse" v-if="invoiceDetail.invoiceStatus == 1"
  199. >未开票</span
  200. >
  201. <span class="text agree" v-if="invoiceDetail.invoiceStatus == 2"
  202. >已开票</span
  203. >
  204. <span class="text refuse" v-if="invoiceDetail.invoiceStatus == -1"
  205. >已退票</span
  206. >
  207. </el-descriptions-item>
  208. <el-descriptions-item
  209. label="发票预览"
  210. v-if="
  211. invoiceDetail.periodStatus == 3 &&
  212. (invoiceDetail.invoiceStatus == 2 ||
  213. invoiceDetail.invoiceStatus == -1) &&
  214. invoiceDetail.invoiceImg
  215. "
  216. >
  217. <div class="preview-wrap">
  218. <img
  219. class="preview"
  220. :src="$tools.splitImgHost(invoiceDetail.invoiceImg)"
  221. />
  222. </div>
  223. <el-button type="primary" @click="download(invoiceDetail)"
  224. >下载电子发票</el-button
  225. >
  226. </el-descriptions-item>
  227. <el-descriptions-item
  228. label="机构发票邮寄状态"
  229. v-if="
  230. invoiceDetail.periodStatus == 3 &&
  231. (invoiceDetail.invoiceStatus == 2 ||
  232. invoiceDetail.invoiceStatus == -1) &&
  233. invoiceDetail.type == 2 &&
  234. invoiceDetail.subject == 2
  235. "
  236. >
  237. <span class="text" v-if="invoiceDetail.sendInvoice == 1">是</span>
  238. <span class="text" v-else>否</span>
  239. </el-descriptions-item>
  240. <el-descriptions-item
  241. label="发票邮寄快递单号:(点击可复制)"
  242. v-if="
  243. invoiceDetail.periodStatus == 3 &&
  244. (invoiceDetail.invoiceStatus == 2 ||
  245. invoiceDetail.invoiceStatus == -1) &&
  246. invoiceDetail.sendInvoice == 1 &&
  247. invoiceDetail.type == 2 &&
  248. invoiceDetail.subject == 2
  249. "
  250. >
  251. {{ invoiceDetail.trackingNum }}
  252. </el-descriptions-item>
  253. </el-descriptions>
  254. <span slot="footer" class="dialog-footer">
  255. <el-button
  256. @click="cancelApply(invoiceDetail)"
  257. v-if="invoiceDetail.periodStatus == 1"
  258. >撤销申请</el-button
  259. >
  260. <el-button type="primary" @click="invoiceDetailModal = false"
  261. >知道了</el-button
  262. >
  263. </span>
  264. </el-dialog>
  265. </div>
  266. </template>
  267. <script>
  268. import axios from "@/axios";
  269. export default {
  270. name: "MyInvoice",
  271. data() {
  272. return {
  273. invoiceDetail: {},
  274. invoiceDetailModal: false,
  275. tableData: [],
  276. params: {
  277. pageNum: 1,
  278. pageSize: 10,
  279. },
  280. total: 0,
  281. };
  282. },
  283. mounted() {
  284. this.orderInvoiceList();
  285. },
  286. methods: {
  287. cancelApply(row) {
  288. const confirmText = [
  289. "撤销申请后,",
  290. "本次的发票申请内容将不存在。",
  291. "请慎重考虑。",
  292. "您确定要取消本次发票申请吗?",
  293. ];
  294. const newDatas = [];
  295. const h = this.$createElement;
  296. for (const i in confirmText) {
  297. newDatas.push(h("p", null, confirmText[i]));
  298. }
  299. this.$confirm(h("div", null, newDatas), "温馨提示", {
  300. confirmButtonText: "确定",
  301. cancelButtonText: "取消",
  302. closeOnClickModal: false,
  303. closeOnPressEscape: false,
  304. distinguishCancelAndClose: false,
  305. showClose: false,
  306. })
  307. .then((_) => {
  308. let invoiceDetail = JSON.parse(JSON.stringify(this.invoiceDetail));
  309. invoiceDetail.status = -1;
  310. this.$request.orderInvoiceCancel(invoiceDetail).then((res) => {
  311. this.orderInvoiceList();
  312. this.invoiceDetailModal = false;
  313. this.$message({
  314. type: "success",
  315. message: "撤销成功",
  316. });
  317. });
  318. })
  319. .catch((_) => {
  320. console.log(_);
  321. });
  322. },
  323. apply() {
  324. this.$router.push({
  325. path: "/person-center/my-invoice/add",
  326. });
  327. },
  328. currentChange(e) {
  329. this.params.pageNum = e;
  330. this.orderInvoiceList();
  331. },
  332. orderInvoiceList() {
  333. this.$request
  334. .orderInvoiceList(this.params)
  335. .then((res) => {
  336. this.tableData = res.rows;
  337. this.total = res.total;
  338. })
  339. .catch((err) => {
  340. this.$message({
  341. type: "error",
  342. message: err.msg,
  343. });
  344. });
  345. },
  346. showDetail(row) {
  347. this.invoiceDetail = row;
  348. this.invoiceDetailModal = true;
  349. },
  350. /**
  351. ** 下载图片到本地
  352. ** @param blobUrl: blob 格式的图片文件
  353. ** @param name: 图片名称
  354. */
  355. download(row) {
  356. // 创建虚拟a标签
  357. let url = this.$tools.splitImgHost(row.invoiceImg);
  358. let name = row.invoiceImg.substring(row.invoiceImg.lastIndexOf("/") + 1);
  359. var image = new Image();
  360. // 解决跨域 Canvas 污染问题,
  361. image.setAttribute("crossorigin", "anonymous");
  362. image.onload = function () {
  363. var canvas = document.createElement("canvas");
  364. canvas.width = image.width;
  365. canvas.height = image.height;
  366. var context = canvas.getContext("2d");
  367. context.drawImage(image, 0, 0, image.width, image.height);
  368. var url = canvas.toDataURL("image/png"); //将图片格式转为base64
  369. var a = document.createElement("a"); // 生成一个a元素
  370. var event = new MouseEvent("click"); // 创建一个单击事件
  371. a.download = name; // 设置图片名称
  372. a.href = url; // 将生成的URL设置为a.href属性
  373. a.dispatchEvent(event); // 触发a的单击事件
  374. };
  375. image.src = url + "?time=" + Date.now(); //注意,这里是灵魂,否则依旧会产生跨域问题
  376. },
  377. },
  378. };
  379. </script>
  380. <!-- Add "scoped" attribute to limit CSS to this component only -->
  381. <style scoped lang="scss">
  382. .my-invoice {
  383. overflow: hidden;
  384. &__header {
  385. margin-top: 24px;
  386. }
  387. &__body {
  388. margin-top: 20px;
  389. /deep/ .el-table {
  390. border: 1px solid #eeeeee;
  391. box-shadow: 0px 0px 7px 1px rgba(0, 0, 0, 0.04);
  392. border-radius: 8px;
  393. }
  394. .pagination {
  395. padding: 30px 0;
  396. text-align: center;
  397. }
  398. }
  399. .invoice-modal {
  400. .preview-wrap {
  401. img {
  402. max-width: 200px;
  403. }
  404. }
  405. .text {
  406. &.wait {
  407. color: #007aff;
  408. }
  409. &.refuse {
  410. color: #ff3b30;
  411. }
  412. &.agree {
  413. color: #34c759;
  414. }
  415. }
  416. }
  417. }
  418. </style>