|
@@ -8,8 +8,11 @@
|
|
|
<div class="address-input-item">
|
|
|
<div class="address-sub">
|
|
|
<div class="top-title">设备选择</div>
|
|
|
- <div class="ant-input prov" @click="handleSelect('device')">
|
|
|
+ <div class="ant-input prov sajiao" @click="handleSelect('device')">
|
|
|
{{activeDevice.childName||'设备选择'}}
|
|
|
+ <div class="xia">
|
|
|
+ <i class="iconfont icon-xia" ></i>
|
|
|
+ </div>
|
|
|
<ul v-if="device">
|
|
|
<li
|
|
|
v-for="(item,i) in invoicedevice"
|
|
@@ -29,9 +32,9 @@
|
|
|
<div class="address-input-con">
|
|
|
<div class="address-input-item">
|
|
|
<div class="address-sub">
|
|
|
- <div class="top-title">开票金额</div>
|
|
|
+ <div class="top-title">开票金额 (可开票额度:{{max}}元)</div>
|
|
|
<div class="ant-input">
|
|
|
- <input v-model="amount" oninput="value=Math.max(Number(value.replace(/[^\d]/g,'')),1)" type="text" placeholder="请输入开票金额" />
|
|
|
+ <input v-model="amount" @input="limitMoney" type="text" placeholder="请输入开票金额" />
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -46,45 +49,45 @@
|
|
|
<span class="check-box">
|
|
|
<span class="checkbox-inner" :class="{'checkbox-inner-checked':type==='geren'}"></span>
|
|
|
</span>
|
|
|
- <span>个人</span>
|
|
|
+ <span>增值税普票(电子发票)</span>
|
|
|
</label>
|
|
|
<label class="check-con" @click="type='qiye'">
|
|
|
<span class="check-box">
|
|
|
<span class="checkbox-inner" :class="{'checkbox-inner-checked':type==='qiye'}"></span>
|
|
|
</span>
|
|
|
- <span>企业</span>
|
|
|
+ <span>增值税专用发票</span>
|
|
|
</label>
|
|
|
</div>
|
|
|
<div class="address-input-con" v-if="type==='qiye'">
|
|
|
<div class="address-input-item">
|
|
|
<div class="address-sub">
|
|
|
- <div class="top-title">抬头名称</div>
|
|
|
+ <div class="top-title">发票抬头</div>
|
|
|
<div class="ant-input">
|
|
|
- <input v-model="tempInvoice3.title" type="text" placeholder="请输入发票抬头" />
|
|
|
+ <input v-model="tempInvoice3.title" maxlength='20' type="text" placeholder="请输入发票抬头" />
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="address-input-item">
|
|
|
<div class="address-sub">
|
|
|
- <div class="top-title">税号</div>
|
|
|
+ <div class="top-title">税务登记号</div>
|
|
|
<div class="ant-input">
|
|
|
- <input v-model="tempInvoice3.code" type="text" placeholder="请输入税务登记号" />
|
|
|
+ <input v-model="tempInvoice3.code" oninput="value=value.replace(/[^\w\.\/]/ig,'')" maxlength='18' type="text" placeholder="请输入18位税务登记号" />
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="address-input-item">
|
|
|
<div class="address-sub">
|
|
|
- <div class="top-title">地址</div>
|
|
|
+ <div class="top-title">注册地址</div>
|
|
|
<div class="ant-input">
|
|
|
- <input v-model="tempInvoice3.organizedAddress" type="text" placeholder="公司地址" />
|
|
|
+ <input v-model="tempInvoice3.organizedAddress" maxlength='30' type="text" placeholder="注册地址" />
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="address-input-item">
|
|
|
<div class="address-sub">
|
|
|
- <div class="top-title">电话号码</div>
|
|
|
+ <div class="top-title">注册电话</div>
|
|
|
<div class="ant-input">
|
|
|
- <input v-model="tempInvoice3.registerPhone" type="text" placeholder="公司电话号码" />
|
|
|
+ <input v-model="tempInvoice3.registerPhone" oninput="value=value.replace(/[^\d\-]/g,'')" maxlength='30' type="text" placeholder="注册电话" />
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -92,7 +95,7 @@
|
|
|
<div class="address-sub">
|
|
|
<div class="top-title">开户银行</div>
|
|
|
<div class="ant-input">
|
|
|
- <input v-model="tempInvoice3.bankName" type="text" placeholder="开户银行" />
|
|
|
+ <input v-model="tempInvoice3.bankName" maxlength='30' type="text" placeholder="开户银行" />
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -100,7 +103,7 @@
|
|
|
<div class="address-sub">
|
|
|
<div class="top-title">银行账户</div>
|
|
|
<div class="ant-input">
|
|
|
- <input v-model="tempInvoice3.bankAccount" type="text" placeholder="银行账户" />
|
|
|
+ <input v-model="tempInvoice3.bankAccount" maxlength='30' type="text" placeholder="银行账户" />
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -108,24 +111,32 @@
|
|
|
<div class="address-input-con" v-else>
|
|
|
<div class="address-input-item">
|
|
|
<div class="address-sub">
|
|
|
- <div class="top-title">抬头名称</div>
|
|
|
+ <div class="top-title">发票抬头</div>
|
|
|
<div class="ant-input">
|
|
|
- <input v-model="tempInvoice2.title" type="text" placeholder="发票抬头" />
|
|
|
+ <input v-model="tempInvoice2.title" maxlength='30' type="text" placeholder="请输入发票抬头" />
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="address-input-item">
|
|
|
<div class="address-sub">
|
|
|
- <div class="top-title">税号</div>
|
|
|
+ <div class="top-title no-require" >税务登记号</div>
|
|
|
<div class="ant-input">
|
|
|
- <input v-model="tempInvoice2.code" type="text" placeholder="税务登记号" />
|
|
|
+ <input v-model="tempInvoice2.code" type="text" oninput="value=value.replace(/[^\w\.\/]/ig,'')" maxlength='18' placeholder="请输入18位税务登记号" />
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="address-input-item">
|
|
|
+ <div class="address-sub">
|
|
|
+ <div class="top-title">电子邮箱</div>
|
|
|
+ <div class="ant-input">
|
|
|
+ <input v-model="tempInvoice2.emailAddress" maxlength='30' type="text" placeholder="请输入电子邮箱" />
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
|
- <div class="select-layout">
|
|
|
+ <div class="select-layout" v-if="type==='qiye'">
|
|
|
<p class="sub-title">
|
|
|
<span>收货地址</span>
|
|
|
</p>
|
|
@@ -134,13 +145,13 @@
|
|
|
<div class="address-sub address-name">
|
|
|
<div class="top-title">姓名</div>
|
|
|
<div class="ant-input">
|
|
|
- <input v-model="tempAddress.shipName" type="text" placeholder="姓名" />
|
|
|
+ <input v-model="tempAddress.shipName" maxlength='20' type="text" placeholder="姓名" />
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="address-sub address-phone">
|
|
|
<div class="top-title">联系电话</div>
|
|
|
<div class="ant-input">
|
|
|
- <input v-model="tempAddress.shipMobile" type="text" placeholder="联系电话" />
|
|
|
+ <input v-model="tempAddress.shipMobile" maxlength='30' type="text" placeholder="联系电话" />
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -186,7 +197,7 @@
|
|
|
</ul>
|
|
|
</div>
|
|
|
<div class="ant-input">
|
|
|
- <input v-model="tempAddress.shipAddress" type="text" placeholder="详细地址" />
|
|
|
+ <input v-model="tempAddress.shipAddress" maxlength='50' type="text" placeholder="详细地址" />
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -207,6 +218,8 @@
|
|
|
<script>
|
|
|
import { mapState } from 'vuex'
|
|
|
import { citylist } from './city'
|
|
|
+import { reg } from '@/util'
|
|
|
+
|
|
|
let sle = ['prov', 'city', 'dist', 'device']
|
|
|
|
|
|
export default {
|
|
@@ -215,6 +228,7 @@ export default {
|
|
|
|
|
|
return {
|
|
|
type: 'geren',
|
|
|
+ max: 0,
|
|
|
amount: '',
|
|
|
tempInvoice2: {},
|
|
|
tempInvoice3: {},
|
|
@@ -233,6 +247,8 @@ export default {
|
|
|
},
|
|
|
computed: {
|
|
|
...mapState({
|
|
|
+ langToast: state => state.language.home.toast,
|
|
|
+ language: state => state.language.current,
|
|
|
token: state => state.user.token,
|
|
|
invoicedevice: state => {
|
|
|
let type = Object.prototype.toString.call(state.user.invoicedevice)
|
|
@@ -257,14 +273,43 @@ export default {
|
|
|
currentProv () {
|
|
|
this.currentCID = 0
|
|
|
this.currentSID = 0
|
|
|
+ },
|
|
|
+ activeDevice () {
|
|
|
+ this.getMax()
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
+ limitMoney (e) {
|
|
|
+ let value = e.target.value
|
|
|
+ // this.edu = Math.max(Math.min(Number(value.replace(/[^\d]/g, '')), this.edititem.max), 1)
|
|
|
+ this.amount = Math.max(Math.min(Number(value.replace(/[^\d]/g, '')), this.max), 0) || ''
|
|
|
+ },
|
|
|
+ async getMax () {
|
|
|
+ let res = await this.$http({
|
|
|
+ method: 'post',
|
|
|
+ data: {
|
|
|
+ cameraId: this.activeDevice.id
|
|
|
+ },
|
|
|
+ headers: {
|
|
|
+ token: this.token
|
|
|
+ },
|
|
|
+ url: '/user/invoice/max'
|
|
|
+ })
|
|
|
+
|
|
|
+ let data = res.data
|
|
|
+ if (data.code !== 0) return
|
|
|
+ this.max = data.data.maxInvoice
|
|
|
+ },
|
|
|
async getAllDevice (searchKey = '') {
|
|
|
let params = {
|
|
|
cameraType: ''
|
|
|
}
|
|
|
await this.$store.dispatch('getInvoiceDevice', params)
|
|
|
+ if (this.invoicedevice.length <= 0) {
|
|
|
+ this.$toast.show('warn', '暂无可开票设备', () => {
|
|
|
+ this.$router.back()
|
|
|
+ })
|
|
|
+ }
|
|
|
this.activeDevice = this.invoicedevice[0]
|
|
|
},
|
|
|
handledeviceClick (item) {
|
|
@@ -291,26 +336,66 @@ export default {
|
|
|
console.log(this.areaPath)
|
|
|
},
|
|
|
async saveInvoice () {
|
|
|
+ if (!this.amount) {
|
|
|
+ return this.$toast.show('warn', '请输入开票金额')
|
|
|
+ }
|
|
|
+ let isObject = function (obj) {
|
|
|
+ return JSON.stringify(obj) === '{}' ? '' : obj
|
|
|
+ }
|
|
|
let params = {}
|
|
|
let invoiceType = ''
|
|
|
+ let check = value => {
|
|
|
+ for (let i = 0, len = value.length; i < len; i++) {
|
|
|
+ if (!value[i].val) {
|
|
|
+ return this.$toast.show('warn', (this.language === 'en' ? value[i].En : value[i].name) + this.langToast['7'])
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return true
|
|
|
+ }
|
|
|
+
|
|
|
if (this.type === 'geren') {
|
|
|
invoiceType = 2
|
|
|
- let { title = '', code = '' } = this.tempInvoice2
|
|
|
+ let title = isObject(this.tempInvoice2.title)
|
|
|
+ let code = isObject(this.tempInvoice2.code)
|
|
|
+ let emailAddress = isObject(this.tempInvoice2.emailAddress)
|
|
|
+
|
|
|
params = {
|
|
|
invoiceType,
|
|
|
title,
|
|
|
- code
|
|
|
+ code,
|
|
|
+ emailAddress
|
|
|
+ }
|
|
|
+ let checkStr = [
|
|
|
+ {
|
|
|
+ name: '发票抬头',
|
|
|
+ En: 'Title',
|
|
|
+ val: title
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: '电子邮箱',
|
|
|
+ En: 'Email',
|
|
|
+ val: emailAddress
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ if (!check(checkStr)) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (code && code.length !== 18) {
|
|
|
+ return this.$toast.show('warn', this.langToast['21'])
|
|
|
+ }
|
|
|
+ if (!reg.email.test(emailAddress)) {
|
|
|
+ return this.$toast.show('warn', this.langToast['8'])
|
|
|
}
|
|
|
} else {
|
|
|
- let {
|
|
|
- title = '',
|
|
|
- code = '',
|
|
|
- organizedAddress = '',
|
|
|
- registerPhone = '',
|
|
|
- bankName = '',
|
|
|
- bankAccount = ''
|
|
|
- } = this.tempInvoice3
|
|
|
+ let {title: title1, code: code1, organizedAddress: organizedAddress1, registerPhone: registerPhone1, bankName: bankName1, bankAccount: bankAccount1} = this.tempInvoice3
|
|
|
invoiceType = 3
|
|
|
+ let title = isObject(title1)
|
|
|
+ let code = isObject(code1)
|
|
|
+ let organizedAddress = isObject(organizedAddress1)
|
|
|
+ let registerPhone = isObject(registerPhone1)
|
|
|
+ let bankName = isObject(bankName1)
|
|
|
+ let bankAccount = isObject(bankAccount1)
|
|
|
+
|
|
|
params = {
|
|
|
invoiceType,
|
|
|
title,
|
|
@@ -320,32 +405,78 @@ export default {
|
|
|
bankName,
|
|
|
bankAccount
|
|
|
}
|
|
|
- }
|
|
|
- let {
|
|
|
- shipName = '',
|
|
|
- shipMobile = '',
|
|
|
- shipAddress = ''
|
|
|
- } = this.tempAddress
|
|
|
+ let checkStr = [
|
|
|
+ {
|
|
|
+ name: '发票抬头',
|
|
|
+ En: 'Title',
|
|
|
+ val: title
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: '税务登记号',
|
|
|
+ En: 'Code',
|
|
|
+ val: code
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: '注册地址',
|
|
|
+ En: 'Organized Address',
|
|
|
+ val: organizedAddress
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: '注册电话',
|
|
|
+ En: 'Register Phone',
|
|
|
+ val: registerPhone
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: '开户银行',
|
|
|
+ En: 'Bank Name',
|
|
|
+ val: bankName
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: '银行账号',
|
|
|
+ En: 'Bank Account',
|
|
|
+ val: bankAccount
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ if (!check(checkStr)) {
|
|
|
+ return
|
|
|
+ }
|
|
|
|
|
|
- this.tempAddress.shipAreaPath = this.areaPath.join(',')
|
|
|
- this.tempAddress.amount = Number(this.amount)
|
|
|
- this.tempAddress.shipName = shipName || ''
|
|
|
- this.tempAddress.shipMobile = shipMobile || ''
|
|
|
- this.tempAddress.shipAddress = shipAddress || ''
|
|
|
+ if (!code || code.length !== 18) {
|
|
|
+ return this.$toast.show('warn', this.langToast['21'])
|
|
|
+ }
|
|
|
|
|
|
- let temp = Object.keys(this.tempAddress)
|
|
|
- temp.forEach(item => {
|
|
|
- params[item] = this.tempAddress[item] || ''
|
|
|
- })
|
|
|
- console.log(params)
|
|
|
- let arr = Object.keys(params)
|
|
|
- for (let i = 0; i < arr.length; i++) {
|
|
|
- if (!params[arr[i]]) {
|
|
|
- return this.$toast.show('warn', '信息填写不能为空')
|
|
|
+ if (!reg.guhua.test(registerPhone)) {
|
|
|
+ return this.$toast.show('warn', this.langToast['22'])
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ let {shipName = '', shipMobile = '', shipAddress = ''} = this.tempAddress
|
|
|
+
|
|
|
+ if (this.type !== 'geren') {
|
|
|
+ this.tempAddress.shipAreaPath = this.areaPath.join(',')
|
|
|
+ this.tempAddress.shipName = shipName || ''
|
|
|
+ this.tempAddress.shipMobile = shipMobile || ''
|
|
|
+ this.tempAddress.shipAddress = shipAddress || ''
|
|
|
+
|
|
|
+ // this.tempAddress.shipAreaPath = this.areaPath.join(',')
|
|
|
+ // this.tempAddress.amount = Number(this.amount)
|
|
|
+ // this.tempAddress.shipName = shipName || ''
|
|
|
+ // this.tempAddress.shipMobile = shipMobile || ''
|
|
|
+ // this.tempAddress.shipAddress = shipAddress || ''
|
|
|
+
|
|
|
+ let temp = Object.keys(this.tempAddress)
|
|
|
+ temp.forEach(item => {
|
|
|
+ params[item] = this.tempAddress[item] || ''
|
|
|
+ })
|
|
|
+ let arr = Object.keys(params)
|
|
|
+ for (let i = 0; i < arr.length; i++) {
|
|
|
+ if (!params[arr[i]]) {
|
|
|
+ return this.$toast.show('warn', '请完善收货信息')
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
params['cameraId'] = this.activeDevice.id
|
|
|
+ params['amount'] = Number(this.amount)
|
|
|
|
|
|
let res = await this.$http.post('/user/invoice/add', params, {
|
|
|
headers: {
|
|
@@ -364,8 +495,8 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
mounted () {
|
|
|
- this.handleChange()
|
|
|
this.getAllDevice()
|
|
|
+ this.handleChange()
|
|
|
}
|
|
|
}
|
|
|
</script>
|