addinvoice.vue 17 KB

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