addinvoice.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444
  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') : ''" :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') : ''" :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="number" 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' && (!/^0\d{2,3}-\d{7,8}$/.test(this.chooseItem.companyPhone))) {
  197. this.setRemindText('单位电话不正确')
  198. } else if (this.invoiceType !== 'normal' && (this.chooseItem.companyTaxNumber === '' || !this.chooseItem.companyTaxNumber)) {
  199. this.setRemindText('税务登记号不能为空')
  200. } else if (this.invoiceType !== 'normal' && (!/^[0-9a-zA-Z]*$/g.test(this.chooseItem.companyTaxNumber))) {
  201. this.setRemindText('税务登记号为只能输入字母和数字')
  202. } else if (this.invoiceType !== 'normal' && (this.chooseItem.bankName === '' || !this.chooseItem.bankName)) {
  203. this.setRemindText('开户银行不能为空')
  204. } else if (this.invoiceType !== 'normal' && (this.chooseItem.bankAccount === '' || !this.chooseItem.bankAccount)) {
  205. this.setRemindText('开户银行账号不能为空')
  206. } else if (this.chooseItem.name === '' || !this.chooseItem.name) {
  207. this.setRemindText('收票人不能为空')
  208. } else if (this.chooseItem.telephone === '' || !this.chooseItem.telephone) {
  209. this.setRemindText('联系电话不能为空')
  210. } else if (!/^1\d{10}$/.test(this.chooseItem.telephone)) {
  211. this.setRemindText('联系电话不正确')
  212. } else if (this.chooseItem.detailAddress === '' || !this.chooseItem.detailAddress) {
  213. this.setRemindText('详细地址不能为空')
  214. } else if (!this.agreeInfo) {
  215. this.setRemindText('请阅读并勾选发票须知')
  216. } else {
  217. this.chooseItem.kind = this.invoiceType === 'normal' ? 1206 : 1205
  218. this.chooseItem.is_agree = true
  219. let params = new FormData()
  220. params.append('bill', JSON.stringify(this.chooseItem))
  221. let config = {
  222. headers: {'Content-Type': 'multipart/form-data'}
  223. }
  224. this.$http.post('/trade/bill/save', params).then(res => {
  225. this.setRemindText('保存成功')
  226. this.$emit('addinvoiceBtn', str)
  227. }, config)
  228. }
  229. } else {
  230. this.$emit('addinvoiceBtn')
  231. }
  232. },
  233. addressData(item) {
  234. this.addressShow = false
  235. if (item) {
  236. this.chooseItem.address = item
  237. this.chooseItem.area = item.province + ',' + item.city + ',' + item.area
  238. }
  239. },
  240. setRemindText(str) {
  241. this.collectResult = str
  242. this.timeoutCount++
  243. }
  244. },
  245. components: {
  246. RemindBox,
  247. SelectAddress,
  248. RemindStr
  249. }
  250. }
  251. </script>
  252. <style scoped lang="scss">
  253. @mixin overFlowHidden {
  254. overflow: hidden;
  255. text-overflow: ellipsis;
  256. white-space: nowrap;
  257. }
  258. @mixin lineHeight($value) {
  259. height: $value;
  260. line-height: $value;
  261. }
  262. .addinvoice-wrapper {
  263. position: fixed;
  264. z-index: 99;
  265. background: #f1f3f6;
  266. top: 0;
  267. left: 0;
  268. bottom: 0;
  269. right: 0;
  270. .mobile-header{
  271. position: fixed;
  272. top: 0;
  273. z-index: 10;
  274. width:100%;
  275. height: 1.26rem;
  276. line-height: 1.26rem;
  277. /*border-bottom:.01rem solid #ccc;*/
  278. background: #3e82f5;
  279. padding:0 .2rem 0 .1rem;
  280. color:#fff;
  281. }
  282. .mobile-header p{
  283. overflow: hidden;
  284. text-overflow: ellipsis;
  285. white-space: nowrap;
  286. font-size:.36rem;
  287. text-align: center;
  288. width: 6rem;
  289. padding-left: 1rem;
  290. }
  291. .mobile-center-header p.en-name {
  292. font-size: .3rem;
  293. }
  294. .mobile-header a{
  295. font-size:.28rem;
  296. color:#fff;
  297. position: absolute;
  298. }
  299. .mobile-header a i{
  300. font-size: .48rem;
  301. margin-right: -.1rem;
  302. }
  303. .addinvoice-content-wrapper {
  304. margin: 1.26rem 0 0 0;
  305. height: calc(100vh - 1.26rem);
  306. /*overflow-y: scroll;*/
  307. overflow: hidden;
  308. .addinvoice-title {
  309. font-size: 0.28rem;
  310. color: #333;
  311. @include lineHeight(0.8rem);
  312. margin: 0 0.2rem;
  313. }
  314. .addinvoice-ul {
  315. background: #fff;
  316. margin: 0 0.2rem;
  317. border: 1px solid #e0e0e0;
  318. border-radius: 0.07rem;
  319. }
  320. .addinvoice-focus {
  321. font-size: 0.28rem;
  322. color: #226ce7;
  323. line-height: 1.16rem;
  324. border-bottom: 1px solid #dcdcdc;
  325. margin: 0 0.2rem;
  326. .addinvoice-focus-name {
  327. width: 2.2rem;
  328. }
  329. .red {
  330. color: #ff0000;
  331. }
  332. .noclick {
  333. color: #999;
  334. }
  335. .normal {
  336. .icon {
  337. font-size: 0.28rem;
  338. color: #333;
  339. width: 0.5rem;
  340. height: 0.5rem;
  341. border-radius: 50%;
  342. border: 1px solid #dcdcdc;
  343. position: relative;
  344. display: inline-block;
  345. vertical-align: top;
  346. margin-top: 0.32rem;
  347. &.active {
  348. border: 1px solid #226ce7;
  349. }
  350. &.noclick2 {
  351. border: 1px solid #999;
  352. color: #999;
  353. }
  354. &.active .icon-next {
  355. background: #226ce7;
  356. width: 0.3rem;
  357. height: 0.3rem;
  358. border-radius: 50%;
  359. position: absolute;
  360. left: 50%;
  361. top: 50%;
  362. transform: translate3d(-50%, -50%, 0);
  363. }
  364. }
  365. }
  366. input {
  367. width: 4.4rem;
  368. font-size: 0.28rem;
  369. height: 0.5rem;
  370. line-height: 0.5rem;
  371. color: #666;
  372. }
  373. .input {
  374. width: 4.4rem;
  375. font-size: 0.28rem;
  376. color: #666;
  377. position: relative;
  378. i {
  379. position: absolute;
  380. right: 0;
  381. }
  382. }
  383. }
  384. .addinvoice-agree {
  385. margin: 0.25rem 0.2rem 0;
  386. font-size: 0.24rem;
  387. color: #666;
  388. input[type="checkbox"] + label::before {
  389. content: "\a0"; /*不换行空格*/
  390. display: inline-block;
  391. width: 0.36rem;
  392. height: 0.36rem;
  393. vertical-align: top;
  394. margin-right: .05rem;
  395. border-radius: 0.07rem;
  396. background-color: #fff;
  397. text-indent: .15em;
  398. border: 1px solid #226ce7;
  399. line-height: 0.36rem; /*行高不加单位,子元素将继承数字乘以自身字体尺寸而非父元素行高*/
  400. }
  401. input[type="checkbox"]:checked + label::before {
  402. content: "\2713";
  403. color: #226ce7;
  404. }
  405. input {
  406. position: absolute;
  407. clip: rect(0, 0, 0, 0);
  408. }
  409. a {
  410. color: #226ce7
  411. }
  412. }
  413. .addinvoice-controll {
  414. font-size: 0.32rem;
  415. color: #fff;
  416. margin: 0.5rem 0.2rem 0;
  417. div {
  418. width: 3.16rem;
  419. @include lineHeight(0.77rem);
  420. border-radius: 0.07rem;
  421. text-align: center;
  422. &:first-child {
  423. background: #bfbfbf;
  424. }
  425. &:last-child {
  426. background: #3f84f6
  427. }
  428. }
  429. }
  430. }
  431. }
  432. </style>