addinvoice.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481
  1. <template>
  2. <div class="addinvoice-wrapper">
  3. <div class="mobile-nav">
  4. <div class="mobile-header mobile-center-header">
  5. <a @click="goBack()"><i class="iconfont icon-fanhui"></i></a>
  6. <p v-if="!isAddInvoice">{{joinType === 'update' ? '修改': '新增'}}开票信息</p>
  7. <p v-else>开票信息</p>
  8. <p class="en-name">
  9. <img :src="`/images/mobile/center/${user.data.enterprise && user.data.enterprise.uu ? 'en' : 'self'}.png`" alt="">{{currentEnName}}
  10. </p>
  11. </div>
  12. </div>
  13. <div class="addinvoice-content-wrapper" ref="ScrollContent">
  14. <!--<div class="order-nav">-->
  15. <!--<div :class="{'active': invoiceType === 'speci', 'noclick2': isSaveinvoiceType === 1205}" @click="isSaveinvoiceType === 0 ? changeType('speci') : (isSaveinvoiceType === 1205 ? setRemindText('已有增值税专票信息') : '')">-->
  16. <!--<span>增值税专票</span>-->
  17. <!--</div>-->
  18. <!--<div :class="{'active' : invoiceType === 'normal', 'noclick2': isSaveinvoiceType === 1206}" @click="isSaveinvoiceType === 0 ? changeType('normal') : (isSaveinvoiceType === 1206 ? setRemindText('已有增值税普票信息') : '')">-->
  19. <!--<span>增值税普票</span>-->
  20. <!--</div>-->
  21. <!--</div>-->
  22. <div>
  23. <div class="addinvoice-title" v-if="joinType !== 'add'">{{chooseItem.kind === 1206 ? '增值税普票' : '增值税专票'}}</div>
  24. <div class="addinvoice-ul" :style="joinType === 'add' ? 'margin-top: 0.2rem' : ''">
  25. <div class="addinvoice-focus clearfix" v-if="joinType === 'add'">
  26. <div class="pull-left addinvoice-focus-name"><a class="red">*</a>发票类型:</div>
  27. <div class="pull-left clearfix">
  28. <div class="normal pull-left" style="margin-right: 0.2rem;" @click="isSaveinvoiceType === 0 ? changeType('speci') : (isSaveinvoiceType === 1205 ? setRemindText('已有增值税专票信息') : '')" :class="{'noclick': isSaveinvoiceType === 1205}">
  29. <div class="icon" :class="{'active': invoiceType === 'speci', 'noclick2': isSaveinvoiceType === 1205}">
  30. <div class="icon-next"></div>
  31. </div>
  32. 增值税专票
  33. </div>
  34. <div class="normal pull-left" @click="isSaveinvoiceType === 0 ? changeType('normal') : (isSaveinvoiceType === 1206 ? setRemindText('已有增值税普票信息') : '')" :class="{'noclick': isSaveinvoiceType === 1206}">
  35. <div class="icon" v-bind:class="{'active' : invoiceType === 'normal', 'noclick2': isSaveinvoiceType === 1206}">
  36. <div class="icon-next"></div>
  37. </div>
  38. 增值税普票
  39. </div>
  40. </div>
  41. </div>
  42. <div class="addinvoice-focus clearfix">
  43. <div class="pull-left addinvoice-focus-name"><a class="red">*</a>发票抬头:</div>
  44. <div class="pull-left input">
  45. <input placeholder="请输入发票抬头" type="text" v-model="chooseItem.head" maxlength="50"/>
  46. </div>
  47. </div>
  48. <div class="addinvoice-focus clearfix" v-if="invoiceType === 'speci'">
  49. <div class="pull-left addinvoice-focus-name"><a class="red">*</a>单位地址:</div>
  50. <div class="pull-left input">
  51. <input placeholder="请输入单位地址" type="text" v-model="chooseItem.companyAddress" maxlength="50" />
  52. </div>
  53. </div>
  54. <div class="addinvoice-focus clearfix" v-if="invoiceType === 'speci'">
  55. <div class="pull-left addinvoice-focus-name"><a class="red">*</a>单位电话:</div>
  56. <div class="pull-left input">
  57. <input placeholder="区号和号码用“-”隔开" type="text" v-model="chooseItem.companyPhone" maxlength="20"/>
  58. </div>
  59. </div>
  60. <div class="addinvoice-focus clearfix" v-if="invoiceType === 'speci'">
  61. <div class="pull-left addinvoice-focus-name"><a class="red">*</a>税务登记号:</div>
  62. <div class="pull-left input">
  63. <input placeholder="请输入税务登记号" type="text" v-model="chooseItem.companyTaxNumber" maxlength="20"/>
  64. </div>
  65. </div>
  66. <div class="addinvoice-focus clearfix" v-if="invoiceType === 'speci'">
  67. <div class="pull-left addinvoice-focus-name"><a class="red">*</a>开户银行:</div>
  68. <div class="pull-left input">
  69. <input placeholder="请输入开户银行" type="text" v-model="chooseItem.bankName" maxlength="30"/>
  70. </div>
  71. </div>
  72. <div class="addinvoice-focus clearfix" v-if="invoiceType === 'speci'">
  73. <div class="pull-left addinvoice-focus-name"><a class="red">*</a>开户银行账号:</div>
  74. <div class="pull-left input">
  75. <input placeholder="请输入开户银行账号" type="number" v-model="chooseItem.bankAccount" oninput="if(value.length>30)value=value.slice(0,30)" />
  76. </div>
  77. </div>
  78. <div class="addinvoice-focus clearfix">
  79. <div class="pull-left addinvoice-focus-name"><a class="red">*</a>收票人:</div>
  80. <div class="pull-left input">
  81. <input placeholder="请输入收票人" type="text" maxlength="10" v-model="chooseItem.name" />
  82. </div>
  83. </div>
  84. <div class="addinvoice-focus clearfix">
  85. <div class="pull-left addinvoice-focus-name"><a class="red">*</a>联系电话:</div>
  86. <div class="pull-left input">
  87. <input placeholder="请输入联系电话" type="text" oninput="if(value.length>13)value=value.slice(0,13)" v-model="chooseItem.telephone" />
  88. </div>
  89. </div>
  90. <div class="addinvoice-focus clearfix">
  91. <div class="pull-left addinvoice-focus-name"><a class="red">*</a>所在地区:</div>
  92. <div class="pull-left input" @click="addressShow = true">
  93. <span v-text="chooseItem.area || '选择地区'">选择地区</span>
  94. <i class="iconfont icon-xiangyou"></i>
  95. <!--<input placeholder="省/市/区" type="text" />-->
  96. </div>
  97. </div>
  98. <div class="addinvoice-focus clearfix">
  99. <div class="pull-left addinvoice-focus-name"><a class="red">*</a>详细地址:</div>
  100. <div class="pull-left input">
  101. <input placeholder="建议您填写详细发件地址,如街道名,门牌号楼层和房间号等信息" type="text" v-model="chooseItem.detailAddress" maxlength="30"/>
  102. </div>
  103. </div>
  104. <div class="line addinvoice-agree" v-if="joinType === 'add'" style="line-height: 0.36rem">
  105. <span class="inline-block title">
  106. <label class="bottom-modal-check mobile-cart-check" :class="{active: agreeInfo}" @click="agreeInfo = !agreeInfo">
  107. <!--<input type="checkbox">-->
  108. </label>
  109. 我已阅读并同意<a @click="showRemindStr = true">《发票须知》</a>
  110. </span>
  111. <!--<input type="checkbox" id="awesome" :checked="agreeInfo" @click="agreeInfo = !agreeInfo"/>-->
  112. <!--<label for="awesome"></label>-->
  113. </div>
  114. <div class="addinvoice-controll clearfix" v-if="!isAddInvoice">
  115. <div class="pull-left" @click="goBack()">取消</div>
  116. <div class="pull-right" @click="goBack(true)">确认</div>
  117. </div>
  118. <div class="addinvoice-controll clearfix" v-else >
  119. <div class="pull-right" @click="goBack(true)" style="width: 100%">确认</div>
  120. </div>
  121. <div style="width:100%;height:1.2rem;position: relative"></div>
  122. </div>
  123. </div>
  124. </div>
  125. <remind-box :title="collectResult" :timeoutCount="timeoutCount"></remind-box>
  126. <select-address :className="''" :isShow="addressShow" @closeAction="addressData"></select-address>
  127. <remind-str :showRemind="showRemindStr"
  128. :text="remindText"
  129. @closeAction="showRemindStr = false"
  130. ></remind-str>
  131. </div>
  132. </template>
  133. <script>
  134. import { RemindBox } from '~components/mobile/common'
  135. import { RemindStr } from '~components/mobile/base'
  136. import SelectAddress from '~components/mobile/base/SelectAddress.vue'
  137. import Bscroll from 'better-scroll'
  138. export default {
  139. name: 'addinvoice',
  140. props: {
  141. chooseItem: {
  142. type: Object,
  143. default: {}
  144. },
  145. isSaveinvoiceType: { // 已保存的发票信息
  146. type: Number,
  147. default: 0
  148. },
  149. joinType: {
  150. type: String,
  151. default: 'add'
  152. },
  153. isAddInvoice: {// 第一次新增
  154. type: Boolean,
  155. default: false
  156. }
  157. },
  158. computed: {
  159. isEmpty() {
  160. return this.chooseItem.kind
  161. }
  162. // invoiceType() {
  163. // return this.isSaveinvoiceType > 0 ? (this.isSaveinvoiceType === 1205 ? 'speci' : 'normal') : 'speci'
  164. // }
  165. },
  166. mounted() {
  167. if (this.isSaveinvoiceType === 1205) {
  168. this.invoiceType = 'normal'
  169. } else if (this.isSaveinvoiceType === 1206) {
  170. this.invoiceType = 'speci'
  171. } else {
  172. if (this.chooseItem.kind) {
  173. this.invoiceType = this.chooseItem.kind === 1205 ? 'speci' : 'normal'
  174. }
  175. if (this.chooseItem.kind) {
  176. this.agreeInfo = true
  177. }
  178. }
  179. this.$nextTick(res => {
  180. if (!this.scroll) {
  181. this.scroll = new Bscroll(this.$refs.ScrollContent, {click: true})
  182. } else {
  183. this.scroll.refresh()
  184. }
  185. })
  186. },
  187. data() {
  188. return {
  189. invoiceType: 'speci',
  190. agreeInfo: false,
  191. collectResult: '',
  192. timeoutCount: 0,
  193. addressShow: false,
  194. showRemindStr: false,
  195. remindText : '<div style="font-size: 0.3rem">为确保发票的开具顺利,在【订单信息】页面填写开票信息后请认真核对,因为您填写的错误信息导致的损失由您自行承担。</div>' +
  196. '<p style="font-size: 0.3rem;margin: 0.1rem 0">1. 如您收到的发票与您的开票信息、订单信息不符,请及时向卖家提出更换发票申请。</p>' +
  197. '<p style="font-size: 0.3rem;margin: 0.1rem 0">2. 发票与您的开票信息、订单信息一致的情况下,发票一经开出,恕不退换。</p>' +
  198. '<p style="font-size: 0.3rem">3. 补开发票的同时要补交税费。</p>'
  199. }
  200. },
  201. methods: {
  202. changeType(str) {
  203. this.scroll.refresh()
  204. this.invoiceType = str
  205. },
  206. goBack(str) {
  207. if (str) {
  208. if (this.chooseItem.head === '' || !this.chooseItem.head) {
  209. this.setRemindText('发票抬头不能为空')
  210. } else if (this.invoiceType !== 'normal' && (this.chooseItem.companyAddress === '' || !this.chooseItem.companyAddress)) {
  211. this.setRemindText('单位地址不能为空')
  212. } else if (this.invoiceType !== 'normal' && (this.chooseItem.companyPhone === '' || !this.chooseItem.companyPhone)) {
  213. this.setRemindText('单位电话不能为空')
  214. } else if (this.invoiceType !== 'normal' && (!/^0\d{2,3}-\d{7,8}$/.test(this.chooseItem.companyPhone))) {
  215. this.setRemindText('单位电话不正确')
  216. } else if (this.invoiceType !== 'normal' && (this.chooseItem.companyTaxNumber === '' || !this.chooseItem.companyTaxNumber)) {
  217. this.setRemindText('税务登记号不能为空')
  218. } else if (this.invoiceType !== 'normal' && (!/^[0-9a-zA-Z]*$/g.test(this.chooseItem.companyTaxNumber))) {
  219. this.setRemindText('税务登记号为只能输入字母和数字')
  220. } else if (this.invoiceType !== 'normal' && (this.chooseItem.bankName === '' || !this.chooseItem.bankName)) {
  221. this.setRemindText('开户银行不能为空')
  222. } else if (this.invoiceType !== 'normal' && (this.chooseItem.bankAccount === '' || !this.chooseItem.bankAccount)) {
  223. this.setRemindText('开户银行账号不能为空')
  224. } else if (this.chooseItem.name === '' || !this.chooseItem.name) {
  225. this.setRemindText('收票人不能为空')
  226. } else if (this.chooseItem.telephone === '' || !this.chooseItem.telephone) {
  227. this.setRemindText('联系电话不能为空')
  228. } else if (!/^1\d{10,13}$/.test(this.chooseItem.telephone)) {
  229. this.setRemindText('联系电话不正确')
  230. } else if (this.chooseItem.area === '' || !this.chooseItem.area) {
  231. this.setRemindText('地址区域未选择')
  232. } else if (this.chooseItem.detailAddress === '' || !this.chooseItem.detailAddress) {
  233. this.setRemindText('详细地址不能为空')
  234. } else if (!this.agreeInfo) {
  235. this.setRemindText('请阅读并勾选发票须知')
  236. } else {
  237. this.chooseItem.kind = this.invoiceType === 'normal' ? 1206 : 1205
  238. this.chooseItem.is_agree = true
  239. let params = new FormData()
  240. params.append('bill', JSON.stringify(this.chooseItem))
  241. let config = {
  242. headers: {'Content-Type': 'multipart/form-data'}
  243. }
  244. this.$http.post('/trade/bill/save', params).then(res => {
  245. this.setRemindText('保存成功')
  246. this.$emit('addinvoiceBtn', str)
  247. }, config)
  248. }
  249. } else {
  250. this.$emit('addinvoiceBtn')
  251. }
  252. },
  253. addressData(item) {
  254. this.addressShow = false
  255. if (item) {
  256. this.chooseItem.address = item
  257. this.chooseItem.area = item.province + ',' + item.city + ',' + item.area
  258. }
  259. },
  260. setRemindText(str) {
  261. this.collectResult = str
  262. this.timeoutCount++
  263. }
  264. },
  265. components: {
  266. RemindBox,
  267. SelectAddress,
  268. RemindStr
  269. }
  270. }
  271. </script>
  272. <style scoped lang="scss">
  273. @mixin overFlowHidden {
  274. overflow: hidden;
  275. text-overflow: ellipsis;
  276. white-space: nowrap;
  277. }
  278. @mixin lineHeight($value) {
  279. height: $value;
  280. line-height: $value;
  281. }
  282. .addinvoice-wrapper {
  283. position: fixed;
  284. z-index: 99;
  285. background: #f1f3f6;
  286. top: 0;
  287. left: 0;
  288. bottom: 0;
  289. right: 0;
  290. .order-nav {
  291. background: #fff;
  292. div {
  293. height: 0.82rem;
  294. line-height: 0.82rem;
  295. display: inline-block;
  296. width: 25%;
  297. text-align: center;
  298. font-size: .28rem;
  299. color: #666;
  300. &.active span{
  301. color: #3f84f6;
  302. border-bottom: 0.04rem solid #3f84f6;
  303. padding-bottom: 0.2rem;
  304. }
  305. }
  306. }
  307. .mobile-header{
  308. position: fixed;
  309. top: 0;
  310. z-index: 10;
  311. width:100%;
  312. height: 1.26rem;
  313. line-height: 1.26rem;
  314. /*border-bottom:.01rem solid #ccc;*/
  315. background: #3e82f5;
  316. padding:0 .2rem 0 .1rem;
  317. color:#fff;
  318. }
  319. .mobile-header p{
  320. overflow: hidden;
  321. text-overflow: ellipsis;
  322. white-space: nowrap;
  323. font-size:.36rem;
  324. text-align: center;
  325. width: 6rem;
  326. padding-left: 1rem;
  327. }
  328. .mobile-center-header p.en-name {
  329. font-size: .3rem;
  330. }
  331. .mobile-header a{
  332. font-size:.28rem;
  333. color:#fff;
  334. position: absolute;
  335. }
  336. .mobile-header a i{
  337. font-size: .48rem;
  338. margin-right: -.1rem;
  339. }
  340. .addinvoice-content-wrapper {
  341. margin: 1.26rem 0 0 0;
  342. height: calc(100vh - 1.26rem);
  343. /*overflow-y: scroll;*/
  344. overflow: hidden;
  345. .addinvoice-title {
  346. font-size: 0.28rem;
  347. color: #333;
  348. @include lineHeight(0.8rem);
  349. margin: 0 0.2rem;
  350. }
  351. .addinvoice-ul {
  352. background: #fff;
  353. margin: 0 0.2rem;
  354. border: 1px solid #e0e0e0;
  355. border-radius: 0.07rem;
  356. }
  357. .addinvoice-focus {
  358. font-size: 0.28rem;
  359. color: #226ce7;
  360. line-height: 1.16rem;
  361. border-bottom: 1px solid #dcdcdc;
  362. margin: 0 0.2rem;
  363. .addinvoice-focus-name {
  364. width: 2.2rem;
  365. }
  366. .red {
  367. color: #ff0000;
  368. }
  369. .noclick {
  370. color: #999;
  371. }
  372. .normal {
  373. .icon {
  374. font-size: 0.28rem;
  375. color: #333;
  376. width: 0.5rem;
  377. height: 0.5rem;
  378. border-radius: 50%;
  379. border: 1px solid #dcdcdc;
  380. position: relative;
  381. display: inline-block;
  382. vertical-align: top;
  383. margin-top: 0.32rem;
  384. &.active {
  385. border: 1px solid #226ce7;
  386. }
  387. &.noclick2 {
  388. border: 1px solid #999;
  389. color: #999;
  390. }
  391. &.active .icon-next {
  392. background: #226ce7;
  393. width: 0.3rem;
  394. height: 0.3rem;
  395. border-radius: 50%;
  396. position: absolute;
  397. left: 50%;
  398. top: 50%;
  399. transform: translate3d(-50%, -50%, 0);
  400. }
  401. }
  402. }
  403. input {
  404. width: 4.4rem;
  405. font-size: 0.28rem;
  406. height: 0.5rem;
  407. line-height: 0.5rem;
  408. color: #333;
  409. }
  410. .input {
  411. width: 4.4rem;
  412. font-size: 0.28rem;
  413. color: #666;
  414. position: relative;
  415. i {
  416. position: absolute;
  417. right: 0;
  418. }
  419. }
  420. }
  421. .addinvoice-agree {
  422. margin: 0.25rem 0.2rem 0;
  423. font-size: 0.24rem;
  424. color: #666;
  425. input[type="checkbox"] + label::before {
  426. content: "\a0"; /*不换行空格*/
  427. display: inline-block;
  428. width: 0.36rem;
  429. height: 0.36rem;
  430. vertical-align: top;
  431. margin-right: .05rem;
  432. border-radius: 0.07rem;
  433. background-color: #fff;
  434. text-indent: .15em;
  435. border: 1px solid #226ce7;
  436. line-height: 0.36rem; /*行高不加单位,子元素将继承数字乘以自身字体尺寸而非父元素行高*/
  437. }
  438. input[type="checkbox"]:checked + label::before {
  439. content: "\2713";
  440. color: #226ce7;
  441. }
  442. input {
  443. position: absolute;
  444. clip: rect(0, 0, 0, 0);
  445. }
  446. a {
  447. color: #226ce7
  448. }
  449. }
  450. .addinvoice-controll {
  451. font-size: 0.32rem;
  452. color: #fff;
  453. margin: 0.5rem 0.2rem 0;
  454. div {
  455. width: 3.16rem;
  456. @include lineHeight(0.77rem);
  457. border-radius: 0.07rem;
  458. text-align: center;
  459. &:first-child {
  460. background: #bfbfbf;
  461. }
  462. &:last-child {
  463. background: #3f84f6
  464. }
  465. }
  466. }
  467. }
  468. }
  469. </style>