|
@@ -6,7 +6,7 @@
|
|
|
</el-form-item>
|
|
|
<el-form-item label="发票类型" :prop="mapFields.invoiceType">
|
|
|
<el-select v-model="ruleForm[mapFields.invoiceType]" style="width:100%" placeholder="发票类型">
|
|
|
- <el-option v-for="type in invoiceTypeList" :key="type.value" :value="type.value" :label="type.label"/>
|
|
|
+ <el-option v-for="type in invTypes" :key="type.value" :value="type.value" :label="type.label"/>
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
<el-form-item label="发票代码" :prop="mapFields.invoiceCode" v-if="!isAllelectric">
|
|
@@ -24,6 +24,7 @@
|
|
|
<el-form-item label="校验码" :prop="mapFields.checkNumber" v-if="!isAllelectric">
|
|
|
<el-input v-model="ruleForm[mapFields.checkNumber]" placeholder="校验码" />
|
|
|
</el-form-item>
|
|
|
+
|
|
|
<el-form-item label="开票日期" :prop="mapFields.openTime">
|
|
|
<el-date-picker
|
|
|
v-model="ruleForm[mapFields.openTime]"
|
|
@@ -34,7 +35,7 @@
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item style="display:flex;justify-content:flex-end">
|
|
|
- <el-button type="primary" @click="onSubmit">保存</el-button>
|
|
|
+ <el-button type="primary" @click="onSubmit" :loading="loading">保存</el-button>
|
|
|
</el-form-item>
|
|
|
</el-form>
|
|
|
</el-dialog>
|
|
@@ -59,33 +60,52 @@ import { invoiceTypeList } from '@/assets/js/statusList'
|
|
|
* 校验码 checkNumber
|
|
|
*/
|
|
|
|
|
|
+ const {
|
|
|
+ invoiceCode: IC,
|
|
|
+ invoiceType: IT,
|
|
|
+ beforeTax: BT,
|
|
|
+ openTime: OT,
|
|
|
+ invoiceNumber:IN,
|
|
|
+ checkNumber:CC
|
|
|
+ } = mapFields
|
|
|
+
|
|
|
export default {
|
|
|
- props:['visible','updateItem','updateIndex'],
|
|
|
+ props:[
|
|
|
+ 'visible',
|
|
|
+ 'updateItem',
|
|
|
+ 'updateIndex',
|
|
|
+ 'isNormalType',
|
|
|
+ 'loading'
|
|
|
+ ],
|
|
|
computed:{
|
|
|
+ invTypes(){
|
|
|
+ const INT = this.isNormalType
|
|
|
+ const ITS = invoiceTypeList.filter(({isNormal}) => (INT && isNormal) || (!INT && !isNormal))
|
|
|
+ return ITS
|
|
|
+ },
|
|
|
isAllelectric(){
|
|
|
const invoiceType = this.ruleForm[mapFields.invoiceType]
|
|
|
const allelectries = ['5','6']
|
|
|
- return allelectries.includes(invoiceType)
|
|
|
+ return allelectries.includes(String(invoiceType))
|
|
|
},
|
|
|
isNormalTicket(){
|
|
|
const invoiceType = this.ruleForm[mapFields.invoiceType]
|
|
|
const specialTickets = ['1','3']
|
|
|
- return specialTickets.includes(invoiceType)
|
|
|
+ return specialTickets.includes(String(invoiceType))
|
|
|
},
|
|
|
title(){
|
|
|
- const base = '发票'
|
|
|
- console.log(this.updateItem)
|
|
|
+ const baseTitle = '发票'
|
|
|
const prefix = this.updateItem ? '编辑' : '上传'
|
|
|
- return `${prefix}${base}`
|
|
|
+ return `${prefix}${baseTitle}`
|
|
|
},
|
|
|
rules(){
|
|
|
const isNormalTicket = this.isNormalTicket
|
|
|
return {
|
|
|
...manuallyUploadRules,
|
|
|
- [mapFields.checkNumber]:[{
|
|
|
- ...manuallyUploadRules[mapFields.checkNumber][0],
|
|
|
- //普票必填校验码
|
|
|
- required:isNormalTicket
|
|
|
+ [CC]:[{
|
|
|
+ ...manuallyUploadRules[CC][0],
|
|
|
+ // 普票必填校验码
|
|
|
+ required: isNormalTicket
|
|
|
}]
|
|
|
}
|
|
|
},
|
|
@@ -104,21 +124,22 @@ export default {
|
|
|
if(!visible) return
|
|
|
this.$nextTick(() => this.initData())
|
|
|
},
|
|
|
- immediate:true
|
|
|
+ immediate: true
|
|
|
}
|
|
|
},
|
|
|
data(){
|
|
|
+
|
|
|
return {
|
|
|
- scanValue:"",
|
|
|
- invoiceTypeList,
|
|
|
mapFields,
|
|
|
+ scanValue: "",
|
|
|
+ invoiceTypeList,
|
|
|
ruleForm:{
|
|
|
- [mapFields.invoiceType]:"",
|
|
|
- [mapFields.invoiceCode]:"",
|
|
|
- [mapFields.beforeTax]:"",
|
|
|
- [mapFields.openTime]: "",
|
|
|
- [mapFields.invoiceNumber]:"",
|
|
|
- [mapFields.checkNumber]:""
|
|
|
+ [IT]: "",
|
|
|
+ [IC]: "",
|
|
|
+ [BT]: "",
|
|
|
+ [OT]: "",
|
|
|
+ [IN]: "",
|
|
|
+ [CC]: ""
|
|
|
}
|
|
|
}
|
|
|
},
|
|
@@ -126,81 +147,82 @@ export default {
|
|
|
handleClose(){
|
|
|
this.innerVisible = false
|
|
|
this.ruleForm = {
|
|
|
- [mapFields.invoiceType]:"",
|
|
|
- [mapFields.invoiceCode]:"",
|
|
|
- [mapFields.beforeTax]:"",
|
|
|
- [mapFields.openTime]: "",
|
|
|
- [mapFields.invoiceNumber]:"",
|
|
|
- [mapFields.checkNumber]:""
|
|
|
+ [IT]: "", [IC]: "", [BT]: "",
|
|
|
+ [OT]: "", [IN]: "", [CC]: ""
|
|
|
}
|
|
|
},
|
|
|
- handleEnterParse(evt){
|
|
|
+
|
|
|
+ handleEnterParse(){
|
|
|
+ const _sV = this.scanValue
|
|
|
+
|
|
|
/* 校验是否有中文逗号 **/
|
|
|
- if(this.scanValue.indexOf(',') >= 0){
|
|
|
+ if(_sV.indexOf(',') >= 0){
|
|
|
this.scanValue = ""
|
|
|
this.$message.error("不能包含中文逗号")
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- const result = this.scanValue.split(",")
|
|
|
- if(result.length !== 8 && result.length !== 9){
|
|
|
+ const chunks = _sV.split(",")
|
|
|
+ const correctLength = [8,9]
|
|
|
+
|
|
|
+ if(!correctLength.includes(chunks.length)){
|
|
|
this.scanValue = ""
|
|
|
this.$message.error("扫码枪识别数据格式不正确,请重新扫描")
|
|
|
+ return
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * @param iT 发票类型
|
|
|
- * @param iC 发票代码
|
|
|
- * @param iN 发票号码
|
|
|
- * @param bT 税前金额
|
|
|
- * @param oT 发票日期
|
|
|
- * @param cC 校验码
|
|
|
- * */
|
|
|
- const [ _, iT, iC, iN, bT, oT, cC ] = result
|
|
|
+ const [
|
|
|
+ _,
|
|
|
+ iT, // 发票类型
|
|
|
+ iC, // 发票代码
|
|
|
+ iN, // 发票号码
|
|
|
+ bT, // 税前金额
|
|
|
+ oT, // 开票日期
|
|
|
+ cC // 校验码
|
|
|
+ ] = chunks
|
|
|
let _oT = ""
|
|
|
|
|
|
if(oT){
|
|
|
- const year = oT.slice(0, 4);
|
|
|
- const month = oT.slice(4, 6);
|
|
|
- const day = oT.slice(6);
|
|
|
- _oT = dayjs(`${year}-${month}-${day}`).format("YYYY-MM-DD HH:mm:ss");
|
|
|
+ const yyyy = oT.slice(0, 4);
|
|
|
+ const mm = oT.slice(4, 6);
|
|
|
+ const dd = oT.slice(6);
|
|
|
+ _oT = dayjs(`${yyyy}-${mm}-${dd}`).format("YYYY-MM-DD HH:mm:ss");
|
|
|
}
|
|
|
|
|
|
- // 1,01,3,4,5,6,7,8,9
|
|
|
-
|
|
|
- const _iT = invoiceTypeList.find(({scanValue}) => scanValue === String(iT))
|
|
|
+ const _iT = invoiceTypeList.find(({sV}) => sV === String(iT))
|
|
|
|
|
|
this.scanValue = ""
|
|
|
this.ruleForm = {
|
|
|
- [mapFields.beforeTax]: bT,
|
|
|
- [mapFields.openTime]: _oT,
|
|
|
- [mapFields.invoiceCode]: iC,
|
|
|
- [mapFields.checkNumber]: cC,
|
|
|
- [mapFields.invoiceNumber]: iN,
|
|
|
- [mapFields.invoiceType]: _iT ? _iT.value : "",
|
|
|
+ [BT]: bT,
|
|
|
+ [IC]: iC,
|
|
|
+ [CC]: cC,
|
|
|
+ [IN]: iN,
|
|
|
+ [OT]: _oT,
|
|
|
+ [IT]: _iT ? _iT.value : "",
|
|
|
}
|
|
|
},
|
|
|
initData(){
|
|
|
- const data = this.updateItem ? JSON.parse(JSON.stringify(this.updateItem)) :{
|
|
|
- [mapFields.invoiceType]:"",
|
|
|
- [mapFields.invoiceCode]:"",
|
|
|
- [mapFields.beforeTax]:"",
|
|
|
- [mapFields.openTime]: "",
|
|
|
- [mapFields.invoiceNumber]:"",
|
|
|
- [mapFields.checkNumber]:""
|
|
|
- }
|
|
|
+ const data = this.updateItem
|
|
|
+ ? JSON.parse(JSON.stringify(this.updateItem))
|
|
|
+ : { [IT]: "", [IC]: "", [BT]: "", [OT]: "", [IN]: "", [CC]: "" }
|
|
|
+
|
|
|
this.ruleForm = data
|
|
|
},
|
|
|
async onSubmit(){
|
|
|
try{
|
|
|
await this.$refs.ruleForm.validate()
|
|
|
- this.$emit("change",{
|
|
|
- data:this.ruleForm,
|
|
|
- index:this.updateIndex
|
|
|
- })
|
|
|
- this.handleClose()
|
|
|
- // thiis
|
|
|
- }catch(err){
|
|
|
+ const { invoiceType } = this.ruleForm
|
|
|
+
|
|
|
+ if(!this.invTypes.map(({value}) => value).includes(invoiceType)){
|
|
|
+ this.$message.warning('上传发票的发票类型与申请发票的发票类型不一致')
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ this.$emit("change", { data: this.ruleForm, index: this.updateIndex })
|
|
|
+ // this.handleClose()
|
|
|
+ }
|
|
|
+ catch(err)
|
|
|
+ {
|
|
|
console.log(err)
|
|
|
}
|
|
|
}
|