RedDialog.vue
4.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
<template>
<d2-dialog :title="title" :is-visible="redVisible" class="redDialog" width="680px" @closeDialog="handleRedClose" @confirmDialog="handleRedConfirm">
<div class="red-box">
<glsx-combi-form class="edit-form-container" ref="editFormRef" label-width="180px" default-width="400px" :isBlock="isBlock" :form-ref="editChildRef" :form-obj="editForm" :form-data="editFormData" :form-rules="formRules"></glsx-combi-form>
</div>
</d2-dialog>
</template>
<script>
import { deepClone } from '@/common/util'
import { redReasonOpt } from "@/common/constants.js"
import { invoiceRed } from "@api/invoiceManage"
export default {
name: 'RedDialog',
props: {
redVisible: {
type: Boolean,
default: false
},
redInfo: {
type: Object,
default: () => { }
}
},
data() {
//这里存放数据
return {
title: '冲红',
isBlock: true,
editChildRef: 'editChildRef',
editForm: {
reason: ''
},
formRules: {
reason: [{ required: true, message: '请选择冲红原因', trigger: 'change' }]
},
editFormData: [{
label: "数电票号码",
name: "electronicInvoiceNo",
type: 'showTxt'
}, {
label: "原发票价税合计金额",
name: "amountWithTax",
type: 'showTxt'
}, {
label: "原发票金额(不含税)",
name: "noTaxAmount",
type: 'showTxt'
}, {
label: "原发票税额",
name: "taxAmount",
type: 'showTxt'
}, {
label: "剩余可冲红金额",
name: "noTaxAmount",
type: 'showTxt'
}, {
label: "剩余可冲红税额",
name: "taxAmount",
type: 'showTxt'
}, {
label: "冲红原因",
name: "reason",
type: "select",
isClear: true,
optionList: [],
optionId: "confId",
optionLabel: "confValue",
optionsName: "redReasonOpt"
}],
baseData: {
redReasonOpt: deepClone(redReasonOpt)
}
}
},
methods: {
getOptionsList(formName, hasAll = true, refreshSigle) {
if (refreshSigle) {
var item = this[formName].find((k) => k.name == refreshSigle)
var index = this[formName].findIndex((k) => k.name == refreshSigle)
this.$set(
this[formName][index],
"optionList",
deepClone(this.baseData[item.optionsName])
)
if (
hasAll &&
this.baseData[item.optionsName].length &&
this.baseData[item.optionsName][0][
this[formName][index].optionLabel
] !== "全部"
) {
const temp = {}
temp[this[formName][index].optionId] = ""
temp[this[formName][index].optionLabel] = "全部"
this[formName][index].optionList.unshift(temp)
}
} else {
this[formName].forEach((item, index) => {
if (
item.type === "select" &&
this.baseData[item.optionsName].length
) {
this.$set(
this[formName][index],
"optionList",
deepClone(this.baseData[item.optionsName])
)
if (
hasAll &&
this.baseData[item.optionsName].length &&
this.baseData[item.optionsName][0][
this[formName][index].optionLabel
] !== "全部"
) {
const temp = {}
temp[this[formName][index].optionId] = ""
temp[this[formName][index].optionLabel] = "全部"
this[formName][index].optionList.unshift(temp)
}
}
})
}
},
handleRedClose() {
this.$emit('handleRedClose')
},
handleRedConfirm() {
this.$refs.editFormRef.$refs[this.editChildRef].validate((valid) => {
if (valid) {
this.$confirm('请确认是否要执行当前操作', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.loading = true
const params = {
electronicInvoiceNo: this.redInfo.electronicInvoiceNo,
reason: this.editForm.reason
}
invoiceRed(params).then(res => {
this.notice.okTips('冲红成功')
this.$emit('handleRedClose', true)
})
}).catch(err => {
console.log(err)
}).finally(() => {
this.loading = false
})
}
})
}
},
mounted() {
this.editForm = deepClone(this.redInfo)
this.getOptionsList('editFormData', false)
}
};
</script>
<style lang='scss' scoped>
</style>