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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
| <template>
| <vol-box
| :lazy="true"
| v-model="model"
| :show-fullscreen="false"
| title="检验"
| :width="550"
| :padding="5"
| :onModelClose="onModelClose"
| >
| <div style="width: 520px; margin-left: 0px" :style="height + 'px'">
| <div style="text-align: center; margin-top: 10px"></div>
| <vol-form
| ref="form"
| :loadKey="true"
| :formFields="formFields"
| :formRules="formRules"
| >
| </vol-form>
| </div>
| <template #footer>
| <div>
| <el-button type="primary" size="small" @click="IsCheck">确认</el-button>
| <el-button type="default" size="small" @click="closeModel"
| >关闭</el-button
| >
| </div>
| </template>
| </vol-box>
| </template>
| <script>
| import VolBox from "@/components/basic/VolBox.vue";
| import VolForm from "@/components/basic/VolForm.vue";
| //这里使用的vue2语法,也可以写成vue3语法
| export default {
| components: { "vol-box": VolBox, "vol-form": VolForm },
| methods: {},
| data() {
| return {
| model: false,
| height: 200,
| rowData: null, //当前行的数据
| //表单数据
| formFields: {
| accpetVal: null, //设置单选框默认值
| isReturn: null,
| decimalVal: null,
| Remark: null,
| defectCode: null,
| checkCount: null,
| sampleCount: null
| },
| formRules: [
| [
| {
| data: [
| { key: 1, value: "接受" },
| { key: 2, value: "不接受" },
| ], //loadKey设置为true,会根据dataKey从后台的下拉框数据源中自动加载数据
| title: "是否接受",
| filter: true,
| // required: true, //设置为必选项
| field: "accpetVal",
| type: "select",
| labelWidth: 80,
| validator: (rule, val) => {
| if (!val) {
| return "请选择是否接受";
| }
| },
| onChange: (val, option) => {
| var select = option.find((x) => x.key == val)?.value;
| if (select == "接受") {
| this.$Message.success(select);
| } else if (select == "不接受") {
| this.formFields.isReturn =1;
| this.formRules[2][0].hidden = false;
| this.formRules[2][0].required = true;
| this.formRules[2][1].hidden = false;
| this.formRules[2][1].required = true;
| this.formRules[3][0].hidden = false;
| this.$Message.error(select);
| } else {
| this.$Message.warning("请选择是否接受");
| }
| },
| },
| ],
| [
| {
| title: "是否退料",
| field: "isReturn",
| data: [],
| required: false,
| type: "switch",
| onChange: (val) => {
| if (val == 1) {
| this.formRules[2][0].hidden = false;
| this.formRules[2][0].required = true;
| this.formRules[2][1].hidden = false;
| this.formRules[2][1].required = true;
| this.formRules[3][0].hidden = false;
| } else {
| this.formRules[2][0].hidden = true;
| this.formRules[2][0].required = false;
| this.formRules[2][1].hidden = true;
| this.formRules[2][1].required = false;
| this.formRules[3][0].hidden = true;
| }
| },
| },
| ],
| [
| {
| type: "select",
| title: "缺陷代码",
| required: false,
| hidden: true,
| placeholder: "缺陷代码",
| field: "defectCode",
| data: [{key:'WMSReturn',value:'WMS品质退货'}]
| },
| {
| type: "decimal",
| title: "退料数量",
| required: false,
| hidden: true,
| placeholder: "退料数量",
| field: "decimalVal",
| },
| ],
| [
| {
| title: "备注",
| required: false,
| hidden: true,
| field: "Remark",
| placeholder: "备注",
| min: 1,
| max: 3,
| type: "textarea",
| colSize: 12, //设置宽度100%
| },
| ],
| [
| {
| title: "检验数量",
| field: "checkCount",
| type: "label",
| inputStyle: { color: "#000000" }, //自定义样式,其他的input也生效
| },
| {
| title: "抽样数量",
| field: "sampleCount",
| type: "label",
| inputStyle: { color: "#e6a23c" }, //自定义样式,其他的input也生效
| },
| ],
| ],
| };
| },
| methods: {
| open(res) {
| this.model = true;
| this.rowData = res[0];
| this.formFields.checkCount = this.rowData.receivedQuantity;
| //sampleCount保留两位小数
| this.formFields.sampleCount = (this.rowData.receivedQuantity/10).toFixed(2);
| },
| onModelClose() {
| this.$refs.form.reset();
| this.model = false;
| this.formRules[2][0].hidden = true;
| this.formRules[2][0].required = false;
| this.formRules[2][1].hidden = true;
| this.formRules[2][1].required = false;
| this.formRules[3][0].hidden = true;
| },
| closeModel() {
| this.$refs.form.reset();
| this.model = false;
| this.formRules[2][0].hidden = true;
| this.formRules[2][0].required = false;
| this.formRules[2][1].hidden = true;
| this.formRules[2][1].required = false;
| this.formRules[3][0].hidden = true;
| },
| IsCheck() {
| //获取accpetVal的值
| this.$refs.form.validate(() => {
| var requestData = null;
| if (this.formFields.isReturn == 1) {
| requestData = {
| checkOrderId: this.rowData.checkOrderId,
| defectCode: this.formFields.defectCode,
| quantity: this.formFields.decimalVal,
| note: this.formFields.Remark,
| result: "Return",
| sampleCount: this.formFields.sampleCount,
| };
| }
| this.http
| .post(
| "/api/CheckOrderResult/CommitCheckResult?checkOrderId=" +
| this.rowData.checkOrderId +
| "&isAccept=" +
| this.formFields.accpetVal,
| requestData ? requestData : {},
| "请求中"
| )
| .then((x) => {
| if (x.status) {
| this.$refs.form.reset();
| this.model = false;
| this.formRules[2][0].hidden = true;
| this.formRules[2][0].required = false;
| this.formRules[3][0].hidden = true;
| this.$Message.success("提交成功");
| this.$parent.refresh();
| } else {
| this.$Message.error(x.message);
| }
| });
| });
| },
| },
| };
| </script>
| <style>
| /* 隐藏全屏放大按钮 */
| .el-icon-full-screen {
| display: none;
| }
| </style>
|
|