revokeDialog.vue
4.82 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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
<template>
<el-dialog
class="entryDialog classCUploadDialog"
title="撤销单申报"
:visible.sync="cancelVisible"
:show-close="false"
width="60%"
:close-on-click-modal="false"
>
<div>
<el-form
class="fedexFormStyle"
ref="cancelForm"
:model="cancelFormData"
:rules="cancelFormRules"
label-position="left"
size="small"
>
<Formitem label="撤销原因" prop="cancellationReason">
<el-select
type="text"
v-model="cancelFormData.cancellationReason"
@change="changeCancellationReason"
clearable
placeholder=""
>
<el-option
v-for="item in cancellationReasons"
:key="item.itemValue"
:label="item.itemValue"
:value="item.itemValue"
></el-option>
</el-select>
</Formitem>
<Formitem v-if="showOtherReason" label="其他原因" prop="otherReason">
<el-input
type="textarea"
class="inputShadow"
resize="none"
v-model="cancelFormData.otherReason"
clearable
placeholder="请输入其它撤销原因"
></el-input>
</Formitem>
</el-form>
</div>
<div class="dialogOption entrySave revokeOperation">
<el-button
class="entrySaveButton entrySaveButton-background revokeSubmitBtn"
type="primary"
@click="submitRevoke"
>提交</el-button
>
<el-button class="entrySaveButton" @click="cancelRevoke">取消</el-button>
</div>
</el-dialog>
</template>
<script>
import { declareDataUpload } from "@/api/declareData-api.js";
import { getDictData } from "@/api/system/dict-api.js";
export default {
props: {
showDialog: {
type: Boolean,
default: false,
},
selectedDatas: {
type: Array,
default: () => [],
},
dropdownCode: {
type: String,
default: "full",
},
},
data() {
return {
cancelVisible: false,
showOtherReason: false,
cancellationReasons: [],
cancelFormData: {
cancellationReason: "",
otherReason: "",
},
cancelFormRules: {
cancellationReason: [
{ required: true, message: "请选择撤销原因", trigger: "change" },
],
otherReason: [
{ required: true, message: "请输入撤销原因", trigger: "blur" },
],
},
};
},
watch: {
showDialog(val) {
if (val) {
this.cancelVisible = val;
}
},
},
created() {
this.getCancellationReasons();
},
methods: {
getCancellationReasons() {
getDictData({ doctCode: "CANCELLATION_REASON" })
.then((res) => {
if (res.code == "200") {
this.cancellationReasons = res.data;
}
})
.catch((err) => {
console.error(err);
});
},
changeCancellationReason(ev) {
if (ev == "手工输入") {
this.showOtherReason = true;
} else {
this.showOtherReason = false;
}
},
submitRevoke() {
if (!this.showOtherReason) {
this.cancelFormData.otherReason = "";
}
this.$refs.cancelForm.validate((valid) => {
if (valid) {
let obj = {
cancellationReason:
this.cancelFormData.otherReason ||
this.cancelFormData.cancellationReason,
declareIds: [],
type: this.dropdownCode,
};
this.selectedDatas.forEach((item) => {
obj.declareIds.push(item.declareId);
});
console.log("datas==", obj);
declareDataUpload(obj)
.then((res) => {
if (res.code === "200") {
// this.alertSuccessMsg(res.message);
this.alertSuccessMsg("数据已成功提交申报,请等待海关回执。");
} else {
this.alertWarningMsg(res.message);
}
this.cancelRevoke();
})
.catch((err) => {
console.log(err);
this.cancelRevoke();
});
} else {
return false;
}
});
},
cancelRevoke() {
this.cancelVisible = false;
this.showOtherReason = false;
this.cancelFormData.cancellationReason = "";
this.cancelFormData.otherReason = "";
this.$emit("cancelRevoke");
},
},
};
</script>
<style lang="scss" scoped>
@import "@/assets/styles/variables.scss";
.modelItem {
width: 100%;
.modelItem-title {
display: flex;
justify-content: space-between;
margin-bottom: 5px;
font-size: 14px;
font-weight: 600;
color: #333;
}
}
.revokeOperation {
margin-bottom: 25px;
.revokeSubmitBtn {
margin-right: 30px;
}
}
</style>