addinvoice.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  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="">
  9. {{currentEnName}}
  10. </p>
  11. </div>
  12. </div>
  13. <div class="addinvoice-content-wrapper">
  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 ? invoiceType = 'speci' : ''">
  20. <div class="icon" :class="invoiceType === 'speci' ? 'active' : ''">
  21. <div class="icon-next"></div>
  22. </div>
  23. 增值税专票
  24. </div>
  25. <div class="normal pull-left" @click="isSaveinvoiceType === 0 ? invoiceType = 'normal' : ''">
  26. <div class="icon" :class="invoiceType === 'normal' ? 'active' : ''">
  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" />
  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"/>
  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" maxlength="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" maxlength="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" />
  93. </div>
  94. </div>
  95. <div class="addinvoice-agree" v-if="joinType === 'add'">
  96. <input type="checkbox" id="awesome" :checked="agreeInfo" @click="agreeInfo = !agreeInfo"/>
  97. <label for="awesome">我已阅读并同意<a>《发票须知》</a></label>
  98. </div>
  99. <div class="addinvoice-controll clearfix">
  100. <div class="pull-left" @click="goBack()">取消</div>
  101. <div class="pull-right" @click="goBack(true)">确认</div>
  102. </div>
  103. </div>
  104. </div>
  105. <remind-box :title="collectResult" :timeoutCount="timeoutCount"></remind-box>
  106. <select-address :className="''" :isShow="addressShow" @closeAction="addressData"></select-address>
  107. </div>
  108. </template>
  109. <script>
  110. import { RemindBox } from '~components/mobile/common'
  111. import SelectAddress from '~components/mobile/base/SelectAddress.vue'
  112. export default {
  113. name: 'addinvoice',
  114. props: {
  115. chooseItem: {
  116. type: Object,
  117. default: {}
  118. },
  119. isSaveinvoiceType: { // 已保存的发票信息
  120. type: Number,
  121. default: 0
  122. },
  123. joinType: {
  124. type: String,
  125. default: 'add'
  126. }
  127. },
  128. computed: {
  129. isEmpty() {
  130. return this.chooseItem.kind
  131. }
  132. // invoiceType() {
  133. // return this.isSaveinvoiceType > 0 ? (this.isSaveinvoiceType === 1205 ? 'speci' : 'normal') : 'speci'
  134. // }
  135. },
  136. mounted() {
  137. if (this.isSaveinvoiceType === 1205) {
  138. this.invoiceType = 'normal'
  139. } else if (this.isSaveinvoiceType === 1206) {
  140. this.invoiceType = 'speci'
  141. } else {
  142. if (this.chooseItem.kind) {
  143. this.invoiceType = this.chooseItem.kind === 1205 ? 'speci' : 'normal'
  144. }
  145. if (this.chooseItem.kind) {
  146. this.agreeInfo = true
  147. }
  148. }
  149. },
  150. data() {
  151. return {
  152. invoiceType: 'speci',
  153. agreeInfo: false,
  154. collectResult: '',
  155. timeoutCount: 0,
  156. addressShow: false
  157. }
  158. },
  159. methods: {
  160. goBack(str) {
  161. if (str) {
  162. if (this.chooseItem.head === '' || !this.chooseItem.head) {
  163. this.setRemindText('发票抬头不能为空')
  164. } else if (this.invoiceType !== 'normal' && (this.chooseItem.companyAddress === '' || !this.chooseItem.companyAddress)) {
  165. this.setRemindText('单位地址不能为空')
  166. } else if (this.invoiceType !== 'normal' && (!/^0\d{2,3}-\d{7,8}$/.test(this.chooseItem.companyPhone))) {
  167. this.setRemindText('单位电话不正确')
  168. } else if (this.invoiceType !== 'normal' && (this.chooseItem.companyTaxNumber === '' || !this.chooseItem.companyTaxNumber)) {
  169. this.setRemindText('税务登记号不能为空')
  170. } else if (this.invoiceType !== 'normal' && (!/^[0-9a-zA-Z]*$/g.test(this.chooseItem.companyTaxNumber))) {
  171. this.setRemindText('税务登记号为只能输入字母和数字')
  172. } else if (this.invoiceType !== 'normal' && (this.chooseItem.bankName === '' || !this.chooseItem.bankName)) {
  173. this.setRemindText('开户银行不能为空')
  174. } else if (this.invoiceType !== 'normal' && (this.chooseItem.bankAccount === '' || !this.chooseItem.bankAccount)) {
  175. this.setRemindText('开户银行账号不能为空')
  176. } else if (this.chooseItem.name === '' || !this.chooseItem.name) {
  177. this.setRemindText('收票人不能为空')
  178. } else if (!/^1\d{10}$/.test(this.chooseItem.telephone)) {
  179. this.setRemindText('联系电话不正确')
  180. } else if (this.chooseItem.detailAddress === '' || !this.chooseItem.detailAddress) {
  181. this.setRemindText('详细地址不能为空')
  182. } else if (!this.agreeInfo) {
  183. this.setRemindText('请阅读并勾选发票须知')
  184. } else {
  185. this.chooseItem.kind = this.invoiceType === 'normal' ? 1206 : 1205
  186. this.chooseItem.is_agree = true
  187. let params = new FormData()
  188. params.append('bill', JSON.stringify(this.chooseItem))
  189. let config = {
  190. headers: {'Content-Type': 'multipart/form-data'}
  191. }
  192. this.$http.post('/trade/bill/save', params).then(res => {
  193. this.setRemindText('保存成功')
  194. this.$emit('addinvoiceBtn', str)
  195. }, config)
  196. }
  197. } else {
  198. this.$emit('addinvoiceBtn')
  199. }
  200. },
  201. addressData(item) {
  202. this.addressShow = false
  203. if (item) {
  204. this.chooseItem.address = item
  205. this.chooseItem.area = item.province + ',' + item.city + ',' + item.area
  206. }
  207. },
  208. setRemindText(str) {
  209. this.collectResult = str
  210. this.timeoutCount++
  211. }
  212. },
  213. components: {
  214. RemindBox,
  215. SelectAddress
  216. }
  217. }
  218. </script>
  219. <style scoped lang="scss">
  220. @mixin overFlowHidden {
  221. overflow: hidden;
  222. text-overflow: ellipsis;
  223. white-space: nowrap;
  224. }
  225. @mixin lineHeight($value) {
  226. height: $value;
  227. line-height: $value;
  228. }
  229. .addinvoice-wrapper {
  230. position: fixed;
  231. z-index: 99;
  232. background: #f1f3f6;
  233. top: 0;
  234. left: 0;
  235. bottom: 0;
  236. right: 0;
  237. .mobile-header{
  238. position: fixed;
  239. top: 0;
  240. z-index: 10;
  241. width:100%;
  242. height: 1.26rem;
  243. line-height: 1.26rem;
  244. /*border-bottom:.01rem solid #ccc;*/
  245. background: #3e82f5;
  246. padding:0 .2rem 0 .1rem;
  247. color:#fff;
  248. }
  249. .mobile-header p{
  250. overflow: hidden;
  251. text-overflow: ellipsis;
  252. white-space: nowrap;
  253. font-size:.36rem;
  254. text-align: center;
  255. width: 6rem;
  256. padding-left: 1rem;
  257. }
  258. .mobile-header a{
  259. font-size:.28rem;
  260. color:#fff;
  261. position: absolute;
  262. }
  263. .mobile-header a i{
  264. font-size: .48rem;
  265. margin-right: -.1rem;
  266. }
  267. .addinvoice-content-wrapper {
  268. margin: 1.26rem 0 0 0;
  269. height: calc(100vh - 1.26rem);
  270. overflow-y: scroll;
  271. .addinvoice-title {
  272. font-size: 0.28rem;
  273. color: #333;
  274. @include lineHeight(0.8rem);
  275. margin: 0 0.2rem;
  276. }
  277. .addinvoice-ul {
  278. background: #fff;
  279. margin: 0 0.2rem;
  280. padding-bottom: 0.5rem;
  281. border: 1px solid #e0e0e0;
  282. border-radius: 0.07rem;
  283. }
  284. .addinvoice-focus {
  285. font-size: 0.28rem;
  286. color: #226ce7;
  287. line-height: 1.16rem;
  288. border-bottom: 1px solid #dcdcdc;
  289. margin: 0 0.2rem;
  290. .addinvoice-focus-name {
  291. width: 2.1rem;
  292. }
  293. .red {
  294. color: #ff0000;
  295. }
  296. .normal {
  297. .icon {
  298. font-size: 0.28rem;
  299. color: #333;
  300. width: 0.5rem;
  301. height: 0.5rem;
  302. border-radius: 50%;
  303. border: 1px solid #dcdcdc;
  304. position: relative;
  305. display: inline-block;
  306. vertical-align: top;
  307. margin-top: 0.32rem;
  308. &.active .icon-next {
  309. background: #226ce7;
  310. width: 0.3rem;
  311. height: 0.3rem;
  312. border-radius: 50%;
  313. position: absolute;
  314. left: 50%;
  315. top: 50%;
  316. transform: translate3d(-50%, -50%, 0);
  317. }
  318. }
  319. }
  320. input {
  321. width: 4.55rem;
  322. font-size: 0.28rem;
  323. height: 0.5rem;
  324. line-height: 0.5rem;
  325. color: #666;
  326. }
  327. .input {
  328. width: 4.55rem;
  329. font-size: 0.28rem;
  330. color: #666;
  331. position: relative;
  332. i {
  333. position: absolute;
  334. right: 0;
  335. }
  336. }
  337. }
  338. .addinvoice-agree {
  339. margin: 0.25rem 0.2rem 0;
  340. font-size: 0.24rem;
  341. color: #666;
  342. input[type="checkbox"] + label::before {
  343. content: "\a0"; /*不换行空格*/
  344. display: inline-block;
  345. width: 0.36rem;
  346. height: 0.36rem;
  347. vertical-align: top;
  348. margin-right: .05rem;
  349. border-radius: 0.07rem;
  350. background-color: #fff;
  351. text-indent: .15em;
  352. border: 1px solid #226ce7;
  353. line-height: 0.36rem; /*行高不加单位,子元素将继承数字乘以自身字体尺寸而非父元素行高*/
  354. }
  355. input[type="checkbox"]:checked + label::before {
  356. content: "\2713";
  357. color: #226ce7;
  358. }
  359. input {
  360. position: absolute;
  361. clip: rect(0, 0, 0, 0);
  362. }
  363. a {
  364. color: #226ce7
  365. }
  366. }
  367. .addinvoice-controll {
  368. font-size: 0.32rem;
  369. color: #fff;
  370. margin: 0.5rem 0.2rem 0;
  371. div {
  372. width: 3.16rem;
  373. @include lineHeight(0.77rem);
  374. border-radius: 0.07rem;
  375. text-align: center;
  376. &:first-child {
  377. background: #bfbfbf;
  378. }
  379. &:last-child {
  380. background: #3f84f6
  381. }
  382. }
  383. }
  384. }
  385. }
  386. </style>