add-or-edit-invoice.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451
  1. <template>
  2. <div class="addr-pop-con">
  3. <!-- 弹窗 -->
  4. <div class="popup-mask" />
  5. <div class="fix-transform-blur">
  6. <div class="popup-box" style="width: 610px">
  7. <!-- 新增地址 -->
  8. <div class="tit">
  9. <div class="text">{{ $t('invoice.invoiceInfo') }}</div>
  10. <div class="close" @click="hidePop" />
  11. </div>
  12. <div class="con invoice-con">
  13. <div class="edit">
  14. <div class="item error">
  15. <div
  16. class="label"
  17. :class="{ 'invoice-en': $t('language') === 'en' }"
  18. >
  19. {{ $t('invoice.invoiceType') }}:
  20. </div>
  21. <div class="button-box">
  22. <div
  23. class="button-box-item"
  24. :class="{ active: dataFrom.invoiceType === 1 }"
  25. @click="selectInvoiceType(1)"
  26. >
  27. <div class="text">
  28. {{ $t('invoice.generalInvoice') }}
  29. </div>
  30. </div>
  31. <div
  32. v-if="!orderInvoiceId"
  33. class="button-box-item"
  34. :class="{ active: dataFrom.invoiceType === 2 }"
  35. @click="selectInvoiceType(2)"
  36. >
  37. <div class="text">
  38. {{ $t('invoice.noInvoice') }}
  39. </div>
  40. </div>
  41. </div>
  42. </div>
  43. <div v-if="dataFrom.invoiceType === 1" class="item">
  44. <div
  45. class="label"
  46. :class="{ 'invoice-en': $t('language') === 'en' }"
  47. >
  48. {{ $t('invoice.invoiceTitle') }}:
  49. </div>
  50. <div class="button-box">
  51. <div
  52. class="button-box-item"
  53. :class="{ active: dataFrom.headerType === 2 }"
  54. @click="selectheaderType(2)"
  55. >
  56. <div class="text">
  57. {{ $t('invoice.personal') }}
  58. </div>
  59. </div>
  60. <div
  61. class="button-box-item"
  62. :class="{ active: dataFrom.headerType === 1 }"
  63. @click="selectheaderType(1)"
  64. >
  65. <div class="text">
  66. {{ $t('invoice.unit') }}
  67. </div>
  68. </div>
  69. </div>
  70. </div>
  71. <div
  72. v-if="dataFrom.headerType === 2 && dataFrom.invoiceType === 1"
  73. class="item"
  74. >
  75. <div
  76. class="label"
  77. :class="{ 'invoice-en': $t('language') === 'en' }"
  78. >
  79. {{ $t('invoice.personalName') }}:
  80. </div>
  81. <div class="button-box text-box">
  82. <input
  83. v-model="dataFrom.headerName"
  84. maxlength="11"
  85. :placeholder="$t('invoice.inputTips1')"
  86. type="text"
  87. class="input"
  88. />
  89. <!-- <div v-if="errTip===1" class="error-text">请输入个人名称</div> -->
  90. </div>
  91. </div>
  92. <div
  93. v-if="dataFrom.headerType === 1 && dataFrom.invoiceType === 1"
  94. class="item"
  95. >
  96. <div
  97. class="label"
  98. :class="{ 'invoice-en': $t('language') === 'en' }"
  99. >
  100. <span style="color: red">*</span>
  101. {{ $t('invoice.unitName') }}:
  102. </div>
  103. <div class="button-box text-box">
  104. <input
  105. v-model="dataFrom.headerName"
  106. maxlength="50"
  107. :placeholder="$t('invoice.inputTips2')"
  108. type="text"
  109. class="input"
  110. />
  111. <div v-if="errTip === 1" class="error-text">
  112. {{ $t('invoice.inputTips2') }}
  113. </div>
  114. </div>
  115. </div>
  116. <div
  117. v-if="dataFrom.headerType === 1 && dataFrom.invoiceType === 1"
  118. class="item"
  119. >
  120. <div
  121. class="label"
  122. :class="{ 'invoice-en': $t('language') === 'en' }"
  123. >
  124. <span style="color: red">*</span>
  125. {{ $t('invoice.TaxpayerIDNumber') }}:
  126. </div>
  127. <div class="button-box text-box">
  128. <input
  129. v-model="dataFrom.invoiceTaxNumber"
  130. maxlength="20"
  131. :placeholder="$t('invoice.inputTips3')"
  132. type="text"
  133. class="input"
  134. />
  135. <div v-if="errTip === 2" class="error-text">
  136. {{ $t('invoice.inputTips3') }}
  137. </div>
  138. <div v-if="errTip === 5" class="error-text">
  139. {{ $t('invoice.inputTips4') }}
  140. </div>
  141. </div>
  142. </div>
  143. <div v-if="dataFrom.invoiceType === 1" class="item">
  144. <div
  145. class="label"
  146. :class="{ 'invoice-en': $t('language') === 'en' }"
  147. >
  148. {{ $t('invoice.invoiceContent') }}:
  149. </div>
  150. <div class="button-box">
  151. <div
  152. class="button-box-item"
  153. :class="{ active: dataFrom.invoiceContext === 1 }"
  154. >
  155. <div class="text">
  156. {{ $t('invoice.productDetails') }}
  157. </div>
  158. </div>
  159. </div>
  160. </div>
  161. <div class="item">
  162. <div
  163. class="label"
  164. :class="{ 'invoice-en': $t('language') === 'en' }"
  165. >
  166. {{ $t('invoice.invoiceInstructions') }}:
  167. </div>
  168. <div class="description-box">
  169. <div>1、{{ $t('invoice.invoiceTips1') }}</div>
  170. <div>2、{{ $t('invoice.invoiceTips2') }}</div>
  171. <div>3、{{ $t('invoice.invoiceTips3') }}</div>
  172. <div>4、{{ $t('invoice.invoiceTips4') }}</div>
  173. </div>
  174. </div>
  175. <div class="item item-btn">
  176. <div class="label-btn">&nbsp;</div>
  177. <a
  178. href="javascript:void(0)"
  179. class="btn-r"
  180. @click="submitDataForm"
  181. >{{ $t('invoice.saveInvoiceInformation') }}</a
  182. >
  183. <a href="javascript:void(0)" class="btn-close" @click="hidePop">{{
  184. $t('cancel')
  185. }}</a>
  186. </div>
  187. </div>
  188. </div>
  189. <!-- /新增地址 -->
  190. </div>
  191. </div>
  192. <!-- /弹窗 -->
  193. </div>
  194. </template>
  195. <script>
  196. // import util from '../plugins/util'
  197. export default {
  198. data() {
  199. return {
  200. dataFrom: {
  201. invoiceType: 2, // 发票类型 1、普通电子发票 2、不开具发票
  202. headerType: 2, // 抬头类型 2、个人 1、企业
  203. invoiceContext: 1,
  204. headerName: ''
  205. },
  206. errTip: 0, // 错误提示: 1收件人 2手机号 3地区数据 4详细地址 5纳税人识别号
  207. type: 0,
  208. shopId: '',
  209. orderNumber: '',
  210. orderInvoiceId: null,
  211. TaxNumberReg: /^(([0-9A-Za-z]{15})|([0-9A-Za-z]{17})|([0-9A-Za-z]{18})|([0-9A-Za-z]{20}))$/
  212. }
  213. },
  214. mounted() {},
  215. methods: {
  216. init(type, data, orderNumber, shopId, orderInvoiceId) {
  217. this.type = type
  218. this.shopId = shopId || ''
  219. this.orderNumber = orderNumber || ''
  220. this.orderInvoiceId = orderInvoiceId || null
  221. if (this.orderInvoiceId) {
  222. this.dataFrom.invoiceType = 1
  223. }
  224. if (data) {
  225. this.dataFrom = JSON.parse(JSON.stringify(data))
  226. }
  227. },
  228. /**
  229. * 隐藏新增地址弹窗
  230. */
  231. hidePop() {
  232. this.$emit('hidePop', false)
  233. },
  234. selectInvoiceType(type) {
  235. this.dataFrom.invoiceType = type
  236. this.dataFrom.headerType = 2
  237. },
  238. selectheaderType(headerType) {
  239. // this.dataFrom.headerName = ''
  240. this.errTip = -1
  241. this.dataFrom.headerType = headerType
  242. },
  243. submitDataForm() {
  244. // if (!this.dataFrom.headerName || !this.dataFrom.headerName.trim()) {
  245. // this.errTip = 1
  246. // return
  247. // }
  248. if (this.dataFrom.headerType === 1) {
  249. if (!this.dataFrom.headerName || !this.dataFrom.headerName.trim()) {
  250. this.errTip = 1
  251. return
  252. }
  253. if (
  254. !this.dataFrom.invoiceTaxNumber ||
  255. !this.dataFrom.invoiceTaxNumber.trim()
  256. ) {
  257. this.errTip = 2
  258. return
  259. }
  260. if (!this.TaxNumberReg.test(this.dataFrom.invoiceTaxNumber)) {
  261. this.errTip = 5
  262. return
  263. }
  264. }
  265. if (!this.type) {
  266. if (this.shopId) {
  267. this.dataFrom.shopId = this.shopId
  268. }
  269. this.$emit('getInvoiceData', this.dataFrom)
  270. } else {
  271. const orderInvoiceDTO = {
  272. headerName: this.dataFrom.headerName,
  273. headerType: this.dataFrom.headerType,
  274. invoiceContext: this.dataFrom.invoiceContext,
  275. invoiceTaxNumber: this.dataFrom.invoiceTaxNumber,
  276. invoiceType: this.dataFrom.invoiceType,
  277. shopId: this.shopId,
  278. orderNumber: this.orderNumber,
  279. orderInvoiceId: this.orderInvoiceId
  280. }
  281. if (this.dataFrom.headerType === 2) {
  282. delete orderInvoiceDTO.invoiceTaxNumber
  283. }
  284. if (this.dataFrom.invoiceType === 2) {
  285. this.hidePop()
  286. } else if (this.orderInvoiceId) {
  287. this.$axios
  288. .put('/p/orderInvoice', orderInvoiceDTO)
  289. .then(({ data }) => {
  290. this.$message({
  291. message: this.$t('applyReturn.modifiedSuccessfully'),
  292. type: 'success',
  293. duration: 1000,
  294. onClose: () => {
  295. // this.$emit('updateData')
  296. this.$emit('updateData', false)
  297. }
  298. })
  299. })
  300. } else {
  301. this.$axios
  302. .post('/p/orderInvoice', orderInvoiceDTO)
  303. .then(({ data }) => {
  304. this.$message({
  305. message: this.$t('invoice.successTip'),
  306. type: 'success',
  307. duration: 1000,
  308. onClose: () => {
  309. this.$emit('updateData', false)
  310. // this.hidePop()
  311. }
  312. })
  313. })
  314. }
  315. }
  316. }
  317. }
  318. }
  319. </script>
  320. <style scoped>
  321. .area .el-input__inner {
  322. margin: 0;
  323. padding: 0;
  324. height: 20px;
  325. line-height: 20px;
  326. }
  327. .area .el-scrollbar {
  328. width: 97px;
  329. }
  330. .area .el-input__suffix-inner {
  331. position: absolute;
  332. top: -10px;
  333. left: -18px;
  334. }
  335. .el-select-dropdown {
  336. z-index: 20005 !important;
  337. }
  338. .el-select-dropdown__item.selected {
  339. color: unset;
  340. font-weight: unset;
  341. }
  342. .el-select .area .el-select > .el-input {
  343. overflow: hidden;
  344. }
  345. /* 修复transform导致弹窗内容模糊问题 */
  346. .fix-transform-blur {
  347. z-index: 10000;
  348. position: fixed;
  349. top: 50%;
  350. left: 50%;
  351. transform: translate(-50%, -50%);
  352. }
  353. .empty {
  354. color: #acacac;
  355. padding: 10px 0 10px;
  356. }
  357. .addr-pop-con .con .button-box {
  358. display: flex;
  359. justify-content: flex-start;
  360. }
  361. .addr-pop-con .con .button-box .button-box-item {
  362. margin-right: 20px;
  363. height: 32px;
  364. background: #ffffff;
  365. border: 1px solid #dcdcdc;
  366. opacity: 1;
  367. border-radius: 2px;
  368. display: flex;
  369. justify-content: center;
  370. align-items: center;
  371. cursor: pointer;
  372. position: relative;
  373. padding: 0 20px;
  374. }
  375. .addr-pop-con .con .button-box .button-box-item.active {
  376. border: 1px solid #e1251b;
  377. }
  378. .addr-pop-con .con .button-box .active ::after {
  379. position: absolute;
  380. bottom: 2px;
  381. right: 1px;
  382. display: block;
  383. width: 10px;
  384. height: 8px;
  385. content: ' ';
  386. background: url(../assets/images/icons.png) no-repeat 0 -19px;
  387. background-position: -21px -750px;
  388. }
  389. .addr-pop-con .con .button-box .active ::before {
  390. position: absolute;
  391. bottom: 0;
  392. right: 0;
  393. display: block;
  394. width: 0;
  395. height: 0;
  396. content: ' ';
  397. border: 10px solid transparent;
  398. border-right: 10px solid #e1251b;
  399. border-bottom: 10px solid #e1251b;
  400. }
  401. .addr-pop-con .con .button-box .button-box-item .text {
  402. min-width: 56px;
  403. height: 16px;
  404. font-size: 12px;
  405. font-family: Microsoft YaHei;
  406. font-weight: 400;
  407. line-height: 16px;
  408. color: #333333;
  409. opacity: 1;
  410. text-align: center;
  411. }
  412. .addr-pop-con .con .description-box {
  413. width: 396px;
  414. min-height: 80px;
  415. padding: 10px;
  416. background: #f9f9f9;
  417. opacity: 1;
  418. border-radius: 2px;
  419. line-height: 20px;
  420. color: #999999;
  421. }
  422. .addr-pop-con .invoice-con .edit .item .label {
  423. width: 95px;
  424. text-align: right;
  425. margin-right: 10px;
  426. }
  427. .addr-pop-con .invoice-con .edit .item .label.invoice-en {
  428. width: 155px;
  429. }
  430. .popup-box .invoice-con .edit .item .btn-r {
  431. padding: 6px 15px 5px 15px;
  432. background: #e1251b;
  433. color: #fff;
  434. border-radius: 2px;
  435. }
  436. .popup-box .invoice-con .edit .item .btn-close {
  437. margin-left: 12px;
  438. padding: 6px 15px 5px 15px;
  439. background: #ffffff;
  440. color: #333333;
  441. border-radius: 2px;
  442. border: 1px solid #dcdcdc;
  443. }
  444. .popup-box .invoice-con .edit .item .label-btn {
  445. width: 95px;
  446. margin-right: 10px;
  447. }
  448. </style>