addinvoice.vue 18 KB

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