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