|
@@ -72,7 +72,7 @@
|
72
|
72
|
backgroundColor: 'rgb(245, 247, 250)',
|
73
|
73
|
color: '#606266',
|
74
|
74
|
}"
|
75
|
|
- :data="recordInfo.tableList"
|
|
75
|
+ :data="recordInfo.contacts"
|
76
|
76
|
:class="signAndWeighBoxPatients"
|
77
|
77
|
border
|
78
|
78
|
style="width: 100%"
|
|
@@ -85,8 +85,8 @@
|
85
|
85
|
</template>
|
86
|
86
|
<template slot-scope="scope">
|
87
|
87
|
<el-form-item
|
88
|
|
- :prop="'tableList.' + scope.$index + '.supply_count'"
|
89
|
|
- :rules="tableRules.contacts"
|
|
88
|
+ :prop="'contacts.' + scope.$index + '.name'"
|
|
89
|
+ :rules="tableRules.name"
|
90
|
90
|
>
|
91
|
91
|
<el-input
|
92
|
92
|
v-model="scope.row.name"
|
|
@@ -121,10 +121,10 @@
|
121
|
121
|
<span>首要联系人<span style="color: red">*</span></span>
|
122
|
122
|
</template>
|
123
|
123
|
<template slot-scope="scope">
|
124
|
|
- <el-form-item :prop="'tableList.' + scope.$index + '.name'">
|
125
|
|
- <!-- :prop="'tableList.' + scope.$index + '.name'" 如需添加可在上方标签加入 -->
|
|
124
|
+ <el-form-item :prop="'contacts.' + scope.$index + '.name'">
|
|
125
|
+ <!-- :prop="'contacts.' + scope.$index + '.name'" 如需添加可在上方标签加入 -->
|
126
|
126
|
<el-select
|
127
|
|
- v-model="scope.row.is_first"
|
|
127
|
+ v-model="scope.row.isfirst"
|
128
|
128
|
style="width: 90px"
|
129
|
129
|
placeholder="请选择"
|
130
|
130
|
@change="changeName($event, scope)"
|
|
@@ -133,7 +133,7 @@
|
133
|
133
|
v-for="(item, index) in tabList"
|
134
|
134
|
:key="index"
|
135
|
135
|
:label="item.label"
|
136
|
|
- :value="item"
|
|
136
|
+ :value="item.value"
|
137
|
137
|
>
|
138
|
138
|
</el-option>
|
139
|
139
|
</el-select>
|
|
@@ -186,7 +186,7 @@
|
186
|
186
|
|
187
|
187
|
<span slot="footer" class="dialog-footer">
|
188
|
188
|
<el-button @click="closePop">取 消</el-button>
|
189
|
|
- <el-button type="primary" @click="submitForm('supplier')"
|
|
189
|
+ <el-button type="primary" @click="submitForm('supplier', 'recordInfo')"
|
190
|
190
|
>确 定</el-button
|
191
|
191
|
>
|
192
|
192
|
</span>
|
|
@@ -198,25 +198,30 @@ import {
|
198
|
198
|
getSupplierId,
|
199
|
199
|
getsupplytype,
|
200
|
200
|
getsupplyandcontactone,
|
|
201
|
+ delcontactone,
|
|
202
|
+ savesupply,
|
|
203
|
+ updatesupply,
|
201
|
204
|
} from "@/api/supply";
|
202
|
205
|
import Template from "../../data/template.vue";
|
203
|
206
|
export default {
|
204
|
207
|
data() {
|
205
|
208
|
return {
|
|
209
|
+ show_type: 1,
|
|
210
|
+ supplier_ids: "",
|
206
|
211
|
title: "",
|
207
|
212
|
Template,
|
208
|
213
|
signAndWeighBoxPatients: "sign-and-weigh-box-patients",
|
209
|
214
|
list: ["001", "002"],
|
210
|
215
|
// 表单验证规则
|
211
|
216
|
rules: {
|
212
|
|
- id: [
|
|
217
|
+ supplierCode: [
|
213
|
218
|
{
|
214
|
219
|
required: true,
|
215
|
220
|
message: "请填写供应商编号",
|
216
|
221
|
trigger: "blur",
|
217
|
222
|
},
|
218
|
223
|
],
|
219
|
|
- name: [
|
|
224
|
+ supplierName: [
|
220
|
225
|
{
|
221
|
226
|
required: true,
|
222
|
227
|
message: "请填写供应商名称",
|
|
@@ -226,21 +231,19 @@ export default {
|
226
|
231
|
},
|
227
|
232
|
tabList: [
|
228
|
233
|
{
|
229
|
|
- value: 0,
|
|
234
|
+ value: 1,
|
230
|
235
|
label: "是",
|
231
|
236
|
},
|
232
|
237
|
{
|
233
|
|
- value: 1,
|
|
238
|
+ value: 0,
|
234
|
239
|
label: "否",
|
235
|
240
|
},
|
236
|
241
|
],
|
237
|
242
|
tableRules: {
|
238
|
|
- contacts: [
|
239
|
|
- { required: true, message: "联系人不能为空", trigger: "blur" },
|
240
|
|
- ],
|
|
243
|
+ name: [{ required: true, message: "联系人不能为空", trigger: "blur" }],
|
241
|
244
|
},
|
242
|
245
|
recordInfo: {
|
243
|
|
- tableList: [{}],
|
|
246
|
+ contacts: [{}],
|
244
|
247
|
},
|
245
|
248
|
tableData: [
|
246
|
249
|
{
|
|
@@ -251,23 +254,12 @@ export default {
|
251
|
254
|
operate: "",
|
252
|
255
|
},
|
253
|
256
|
],
|
254
|
|
- options: [
|
255
|
|
- {
|
256
|
|
- value: "1",
|
257
|
|
- label: "是",
|
258
|
|
- },
|
259
|
|
- {
|
260
|
|
- value: "2",
|
261
|
|
- label: "否",
|
262
|
|
- },
|
263
|
|
- ],
|
264
|
|
- value: "",
|
265
|
257
|
dialogVisible: false,
|
266
|
258
|
supplier: {
|
267
|
|
- supplierName: "a",
|
|
259
|
+ supplierName: "",
|
268
|
260
|
supplierCode: "gsy001",
|
269
|
261
|
supplierType: "",
|
270
|
|
- vatRate: 10,
|
|
262
|
+ vatRate: "",
|
271
|
263
|
number: "",
|
272
|
264
|
bank: "",
|
273
|
265
|
bankAccount: "",
|
|
@@ -285,9 +277,12 @@ export default {
|
285
|
277
|
show(data, type) {
|
286
|
278
|
if (type == 1) {
|
287
|
279
|
this.initSupplierData();
|
|
280
|
+ this.show_type = 1;
|
288
|
281
|
this.title = "新增供应商";
|
289
|
282
|
this.dialogVisible = true;
|
290
|
283
|
} else if (type == 2) {
|
|
284
|
+ this.show_type = 2;
|
|
285
|
+ this.supplier_ids = data.ID;
|
291
|
286
|
this.title = "编辑供应商";
|
292
|
287
|
this.supplier.supplierCode = data.SupplierCode;
|
293
|
288
|
this.supplier.supplierName = data.SupplierName;
|
|
@@ -310,36 +305,15 @@ export default {
|
310
|
305
|
this.supplier.number = "";
|
311
|
306
|
this.supplier.bank = "";
|
312
|
307
|
this.supplier.bankAccount = "";
|
313
|
|
- this.recordInfo.tableList = [{}];
|
|
308
|
+ this.recordInfo.contacts = [{}];
|
314
|
309
|
},
|
315
|
310
|
|
316
|
311
|
// 获取供应商编码接口
|
317
|
312
|
initSupplierData() {
|
318
|
|
- let Arr = [];
|
319
|
313
|
getSupplierId().then((res) => {
|
320
|
|
- Arr = res.data.data;
|
321
|
|
- Arr.supplycode.forEach((o) => {
|
322
|
|
- this.supply_code.push(o.supplier_code);
|
323
|
|
- });
|
324
|
|
- });
|
325
|
|
- this.orderIdAdd();
|
326
|
|
- },
|
327
|
|
-
|
328
|
|
- // 供应商编码动态递增
|
329
|
|
- orderIdAdd() {
|
330
|
|
- let data = this.supply_code;
|
331
|
|
- let len = 3;
|
332
|
|
- data.forEach((o, index) => {
|
333
|
|
- o = o.split("gsy");
|
334
|
|
- index = index + 1;
|
335
|
|
- let index1 = index;
|
336
|
|
- index1 = parseInt(index1, 10);
|
337
|
|
- index1 = index1.toString();
|
338
|
|
- while (index1.length < len) index1 = "0" + index1;
|
339
|
|
- if (o[1] != index1) {
|
340
|
|
- data.splice(index - 1, 0, `gsy${index1}`);
|
341
|
|
- // console.log(`gsy${index1}`);
|
342
|
|
- this.supplier.id = `gsy${index1}`;
|
|
314
|
+ if (res.data.state == 1) {
|
|
315
|
+ this.supplier.supplierCode =
|
|
316
|
+ res.data.data.supplycode[0].supplier_code;
|
343
|
317
|
}
|
344
|
318
|
});
|
345
|
319
|
},
|
|
@@ -376,21 +350,57 @@ export default {
|
376
|
350
|
},
|
377
|
351
|
|
378
|
352
|
handleSelect(item) {
|
379
|
|
- console.log(item, "l");
|
380
|
353
|
this.supplier.name = item.value;
|
381
|
354
|
this.supplier.value = item.name;
|
382
|
355
|
},
|
383
|
356
|
|
384
|
357
|
// 验证表单内容
|
385
|
|
- submitForm(formName) {
|
386
|
|
- this.$refs[formName].validate((valid) => {
|
387
|
|
- if (valid) {
|
388
|
|
- alert("submit!");
|
389
|
|
- this.dialogVisible = false;
|
390
|
|
- } else {
|
391
|
|
- return false;
|
392
|
|
- }
|
393
|
|
- });
|
|
358
|
+ submitForm(supplier, formName) {
|
|
359
|
+ if (this.show_type == 1) {
|
|
360
|
+ this.$refs[supplier].validate((valid) => {
|
|
361
|
+ if (valid) {
|
|
362
|
+ this.$refs[formName].validate((valid) => {
|
|
363
|
+ if (valid) {
|
|
364
|
+ let params = {
|
|
365
|
+ ...this.supplier,
|
|
366
|
+ ...this.recordInfo,
|
|
367
|
+ };
|
|
368
|
+ console.log(params, "dhas");
|
|
369
|
+ savesupply(params).then((res) => {});
|
|
370
|
+ } else {
|
|
371
|
+ return false;
|
|
372
|
+ }
|
|
373
|
+ });
|
|
374
|
+
|
|
375
|
+ this.dialogVisible = false;
|
|
376
|
+ } else {
|
|
377
|
+ return false;
|
|
378
|
+ }
|
|
379
|
+ });
|
|
380
|
+ } else if (this.show_type == 2) {
|
|
381
|
+ this.$refs[supplier].validate((valid) => {
|
|
382
|
+ if (valid) {
|
|
383
|
+ this.$refs[formName].validate((valid) => {
|
|
384
|
+ if (valid) {
|
|
385
|
+ let params = {
|
|
386
|
+ ...this.supplier,
|
|
387
|
+ ...this.recordInfo,
|
|
388
|
+ };
|
|
389
|
+ console.log(params, "dhas");
|
|
390
|
+ updatesupply(params).then((res) => {
|
|
391
|
+ console.log(res, "oo");
|
|
392
|
+ });
|
|
393
|
+ } else {
|
|
394
|
+ return false;
|
|
395
|
+ }
|
|
396
|
+ });
|
|
397
|
+
|
|
398
|
+ this.dialogVisible = false;
|
|
399
|
+ } else {
|
|
400
|
+ return false;
|
|
401
|
+ }
|
|
402
|
+ });
|
|
403
|
+ }
|
394
|
404
|
|
395
|
405
|
this.contactsinfo();
|
396
|
406
|
},
|
|
@@ -402,74 +412,92 @@ export default {
|
402
|
412
|
label: "是",
|
403
|
413
|
};
|
404
|
414
|
getsupplyandcontactone({ id: val }).then((res) => {
|
405
|
|
- console.log(res, "oo");
|
406
|
415
|
if (res.data.code == 0) {
|
407
|
|
- this.recordInfo.tableList = res.data.data.contact;
|
408
|
|
- if (this.recordInfo.tableList.length == 0) {
|
409
|
|
- this.recordInfo.tableList = [{}];
|
410
|
|
- this.recordInfo.tableList[0].is_first = data;
|
411
|
|
- this.$forceUpdate();
|
|
416
|
+ this.recordInfo.contacts = res.data.data.contact;
|
|
417
|
+ if (this.recordInfo.contacts.length == 0) {
|
|
418
|
+ this.recordInfo.contacts = [{}];
|
|
419
|
+ this.recordInfo.contacts[0].isfirst = data;
|
|
420
|
+ } else if (this.recordInfo.contacts.length == 1) {
|
|
421
|
+ let val = res.data.data.contact[0];
|
|
422
|
+ this.recordInfo.contacts[0].isfirst = data;
|
|
423
|
+ this.recordInfo.contacts[0] = {
|
|
424
|
+ name: val.name,
|
|
425
|
+ address: val.address,
|
|
426
|
+ phone: val.phone,
|
|
427
|
+ isfirst: val.is_first,
|
|
428
|
+ };
|
412
|
429
|
} else {
|
413
|
|
- this.recordInfo.tableList.forEach((o) => {
|
414
|
|
- if (o.is_first == 0) {
|
415
|
|
- o.is_first = "否";
|
416
|
|
- } else if (o.is_first == 1) {
|
417
|
|
- o.is_first = "是";
|
|
430
|
+ this.recordInfo.contacts.forEach((o) => {
|
|
431
|
+ if (o.isfirst == 0) {
|
|
432
|
+ this.tabList.label = "否";
|
|
433
|
+ } else if (o.isfirst == 1) {
|
|
434
|
+ this.tabList.label = "是";
|
418
|
435
|
}
|
419
|
436
|
});
|
420
|
437
|
}
|
421
|
|
-
|
422
|
|
- console.log(this.recordInfo.tableList, "this.recordInfo.tableList");
|
423
|
438
|
}
|
424
|
439
|
});
|
425
|
|
-
|
426
|
|
- if (this.recordInfo.tableList.length == 1) {
|
427
|
|
- this.recordInfo.tableList[0].is_first = data;
|
428
|
|
- this.$forceUpdate();
|
429
|
|
- }
|
430
|
440
|
},
|
431
|
441
|
|
432
|
442
|
// 首要联系人选择变更动态展示
|
433
|
443
|
changeName(data, scope) {
|
434
|
444
|
let data1 = {
|
435
|
|
- value: 1,
|
|
445
|
+ value: 0,
|
436
|
446
|
label: "否",
|
437
|
447
|
};
|
438
|
|
-
|
439
|
448
|
let data2 = {
|
440
|
|
- value: 0,
|
|
449
|
+ value: 1,
|
441
|
450
|
label: "是",
|
442
|
451
|
};
|
443
|
452
|
let arr = [];
|
444
|
|
- if (this.recordInfo.tableList.length == 1) {
|
445
|
|
- this.recordInfo.tableList[0] = data2;
|
446
|
|
- this.$forceUpdate();
|
447
|
|
- }
|
448
|
|
- this.recordInfo.tableList.forEach((el, index) => {
|
449
|
|
- if (scope.$index == index) {
|
450
|
|
- el.is_first = data;
|
451
|
|
- // console.log(scope);
|
452
|
|
- this.$forceUpdate();
|
|
453
|
+ if (this.recordInfo.contacts.length <= 1) {
|
|
454
|
+ this.recordInfo.contacts[0].isfirst = data2.value;
|
|
455
|
+ } else {
|
|
456
|
+ this.recordInfo.contacts.forEach((el, index) => {
|
|
457
|
+ console.log(scope.$index, index, "oo");
|
|
458
|
+ if (scope.$index == index) {
|
|
459
|
+ el.isfirst = data;
|
|
460
|
+ } else {
|
|
461
|
+ el.isfirst = data1.value;
|
|
462
|
+ }
|
|
463
|
+ arr.push(el.isfirst);
|
|
464
|
+ });
|
|
465
|
+ if (arr.includes(1)) {
|
|
466
|
+ return;
|
453
|
467
|
} else {
|
454
|
|
- el.is_first = data1;
|
455
|
|
- this.$forceUpdate();
|
|
468
|
+ this.recordInfo.contacts[0].isfirst = data2.value;
|
456
|
469
|
}
|
457
|
|
- arr.push(el.is_first.value);
|
458
|
|
- });
|
459
|
|
- if (arr.includes(0)) {
|
460
|
|
- return;
|
461
|
|
- } else {
|
462
|
|
- this.recordInfo.tableList[0].is_first = data2;
|
463
|
470
|
}
|
464
|
471
|
},
|
465
|
472
|
|
466
|
473
|
// 添加表单行
|
467
|
474
|
handleAdd() {
|
468
|
475
|
let data = {};
|
469
|
|
- this.recordInfo.tableList.push(data);
|
|
476
|
+ this.recordInfo.contacts.push(data);
|
470
|
477
|
},
|
471
|
478
|
// 删除表单行
|
472
|
|
- handleDelete() {},
|
|
479
|
+ handleDelete(index, data) {
|
|
480
|
+ let params = {
|
|
481
|
+ id: data.id,
|
|
482
|
+ };
|
|
483
|
+
|
|
484
|
+ if (this.show_type == 1) {
|
|
485
|
+ if (this.recordInfo.contacts.length <= 1) {
|
|
486
|
+ return;
|
|
487
|
+ } else {
|
|
488
|
+ this.recordInfo.contacts.splice(index, 1);
|
|
489
|
+ }
|
|
490
|
+ } else if (this.show_type == 2) {
|
|
491
|
+ delcontactone(params).then((res) => {
|
|
492
|
+ if (res.data.data.list == "删除成功") {
|
|
493
|
+ this.$message.success(res.data.data.list);
|
|
494
|
+ this.getcontacts(this.supplier_ids);
|
|
495
|
+ } else {
|
|
496
|
+ this.$message.error(res.data.data.list);
|
|
497
|
+ }
|
|
498
|
+ });
|
|
499
|
+ }
|
|
500
|
+ },
|
473
|
501
|
|
474
|
502
|
//表格判断是否填入信息
|
475
|
503
|
contactsinfo() {
|