bfb7c0b9
“wangming”
更新Form.vue和用户相关表单...
|
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
|
import request from '@/utils/request'
import { getDictionaryDataSelector } from '@/api/systemData/dictionary'
import { previewDataInterface } from '@/api/systemData/dataInterface'
import { getInfo } from '@/api/user'
export default {
components: {},
props: [],
data() {
return {
loading: false,
visible: false,
isDetail: false,
dataForm: {
id: '',
id: undefined,
kdhy: undefined,
kdhyc: undefined,
kdhysjh: undefined,
djmd: undefined,
jsj: undefined,
kdrq: undefined,
gjlx: undefined,
hgjg: undefined,
zdyj: undefined,
sfyj: undefined,
qk: undefined,
ckfs: undefined,
ckmx: undefined,
fkfs: undefined,
fkyy: undefined,
fkpd: undefined,
khly: undefined,
tjr: undefined,
sfskdd: undefined,
sfck: undefined,
jj: undefined,
scwj: [],
hyqz: [],
bz: undefined,
lqKdJksyjList: [],
lqKdKjbsyjList: [],
lqKdPxmxList: [],
jksyj: undefined,
kjblsyj: undefined,
pxxx: undefined,
},
rules: {
kdhy: [
{ required: true, message: '请选择开单会员', trigger: 'change' }
],
djmd: [
{ required: true, message: '请选择单据门店', trigger: 'change' }
],
jsj: [
{ required: true, message: '请选择金三角', trigger: 'change' }
],
gjlx: [
{ required: true, message: '请选择顾客类型', trigger: 'change' }
],
zdyj: [
{ required: true, message: '请输入整单业绩', trigger: 'blur' },
{ pattern: /^\d+(\.\d{1,2})?$/, message: '请输入正确的金额格式', trigger: 'blur' }
],
sfyj: [
{ required: true, message: '请输入实付业绩', trigger: 'blur' },
{ pattern: /^\d+(\.\d{1,2})?$/, message: '请输入正确的金额格式', trigger: 'blur' }
],
fkfs: [
{ required: true, message: '请选择付款方式', trigger: 'change' }
]
},
kdhyOptions: [],
djmdOptions: [],
jsjOptions: [],
gjlxOptions: [{ "fullName": "会员", "id": "会员" }, { "fullName": "非会员", "id": "非会员" }],
hgjgOptions: [],
ckfsOptions: [{ "fullName": "储值卡", "id": "储值卡" }, { "fullName": "扣项", "id": "扣项" }, { "fullName": "套餐", "id": "套餐" }],
fkfsOptions: [{ "fullName": "现金", "id": "现金" }, { "fullName": "微信", "id": "微信" }, { "fullName": "支付宝", "id": "支付宝" }, { "fullName": "银行卡", "id": "银行卡" }, { "fullName": "医院", "id": "医院" }],
fkyyOptions: [],
khlyOptions: [{ "fullName": "自然到店", "id": "自然到店" }, { "fullName": "会员推广", "id": "会员推广" }, { "fullName": "网络推广", "id": "网络推广" }],
sfskddOptions: [{ "fullName": "是", "id": "是" }, { "fullName": "否", "id": "否" }],
sfckOptions: [{ "fullName": "是", "id": "是" }, { "fullName": "否", "id": "否" }],
pxOptions: [],
}
},
computed: {},
watch: {
'dataForm.zdyj': {
handler(newVal) {
this.calculateQk();
|
bfb7c0b9
“wangming”
更新Form.vue和用户相关表单...
|
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
|
getdjmdOptions() {
previewDataInterface('730960205902251269').then(res => {
this.djmdOptions = res.data
});
},
getjsjOptions() {
previewDataInterface('733894897408410885').then(res => {
this.jsjOptions = res.data
});
},
gethgjgOptions() {
previewDataInterface('733896629660157189').then(res => {
this.hgjgOptions = res.data
});
},
getfkyyOptions() {
previewDataInterface('733898797075137797').then(res => {
this.fkyyOptions = res.data
});
},
getpxOptions() {
previewDataInterface('730971133356016901').then(res => {
this.pxOptions = res.data
});
},
goBack() {
this.$emit('refresh')
},
init(id, isDetail) {
this.dataForm.id = id || 0;
this.visible = true;
this.isDetail = isDetail || false;
this.$nextTick(() => {
this.$refs['elForm'].resetFields();
if (this.dataForm.id) {
request({
url: '/api/Extend/LqKdKdjlb/' + this.dataForm.id,
method: 'get'
}).then(res => {
this.dataForm = res.data;
if (!this.dataForm.scwj) this.dataForm.scwj = [];
if (!this.dataForm.hyqz) this.dataForm.hyqz = [];
})
} else {
// 新增时先加载门店数据,再获取用户门店
this.loadStoreDataAndSetDefault();
}
})
},
loadStoreDataAndSetDefault() {
console.log('开始加载门店数据和用户信息...');
// 先加载门店数据
this.loadStoreDataPromise().then(() => {
// 门店数据加载完成后,获取用户信息
return this.getCurrentUserStorePromise();
}).then((userData) => {
if (userData && userData.mdid) {
const userStoreId = userData.mdid;
console.log('用户门店ID:', userStoreId);
console.log('门店选项列表:', this.djmdOptions);
// 检查用户门店ID是否在门店列表中
const matchingStore = this.djmdOptions.find(store => store.id === userStoreId);
if (matchingStore) {
this.dataForm.djmd = userStoreId;
console.log('找到匹配的门店,设置默认门店ID:', userStoreId);
console.log('匹配的门店信息:', matchingStore);
} else {
console.warn('用户门店ID在门店列表中未找到匹配项');
console.log('用户门店ID:', userStoreId);
console.log('可用门店ID列表:', this.djmdOptions.map(s => s.id));
}
} else {
console.warn('用户数据中没有门店ID,无法设置默认值');
}
}).catch(err => {
console.error('加载数据失败:', err);
});
},
loadStoreDataPromise() {
// 使用原来的数据接口方式
return previewDataInterface('730960205902251269').then(res => {
console.log('门店API原始响应:', res);
if (res.data && res.data.length > 0) {
this.djmdOptions = res.data;
console.log('门店数据加载成功:', this.djmdOptions);
return res.data;
} else {
console.warn('门店数据为空');
return [];
}
}).catch(err => {
console.error('门店数据加载失败:', err);
return [];
});
},
getCurrentUserStorePromise() {
return new Promise((resolve, reject) => {
getInfo().then(res => {
resolve(res.data.userInfo);
}).catch(err => {
console.error('获取当前用户信息失败:', err);
reject(err);
|
bfb7c0b9
“wangming”
更新Form.vue和用户相关表单...
|
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
|
});
},
getCurrentUserStore() {
getInfo().then(res => {
if (res.data && res.data.mdid) {
// 使用mdid字段作为门店ID
this.dataForm.djmd = res.data.mdid;
console.log('当前用户门店ID:', res.data.mdid);
} else {
console.warn('当前用户没有门店ID信息');
}
}).catch(err => {
console.error('获取当前用户信息失败:', err);
});
},
calculateQk() {
const zdyj = parseFloat(this.dataForm.zdyj) || 0;
const sfyj = parseFloat(this.dataForm.sfyj) || 0;
this.dataForm.qk = (zdyj - sfyj).toFixed(2);
},
formatNumber(field) {
// 移除千分位分隔符,只保留数字和小数点
let value = this.dataForm[field].toString().replace(/,/g, '');
// 确保是有效的数字格式
if (!/^\d*\.?\d*$/.test(value)) {
value = value.replace(/[^\d.]/g, '');
}
// 更新原始值
this.dataForm[field] = value;
// 重新计算欠款
this.calculateQk();
},
formatTableNumber(index, field, listName) {
// 表格中数字格式化
let value = this.dataForm[listName][index][field].toString().replace(/,/g, '');
if (!/^\d*\.?\d*$/.test(value)) {
value = value.replace(/[^\d.]/g, '');
}
this.dataForm[listName][index][field] = value;
},
handleJksChange(index, row) {
// 当选择健康师时,自动填充姓名和账号
if (row.jks) {
// 这里可以根据用户ID获取用户信息
// 暂时手动输入
this.$message.info('请手动输入健康师姓名和账号');
}
},
handleKjblsChange(index, row) {
// 当选择科技部老师时,自动填充姓名和账号
if (row.kjbls) {
// 这里可以根据用户ID获取用户信息
// 暂时手动输入
this.$message.info('请手动输入科技部老师姓名和账号');
}
},
resetForm() {
this.$confirm('确定要重置表单吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.$refs['elForm'].resetFields();
// 重置表格数据
this.dataForm.lqKdJksyjList = [];
this.dataForm.lqKdKjbsyjList = [];
this.dataForm.lqKdPxmxList = [];
// 重新获取当前用户门店
if (!this.dataForm.id) {
this.getCurrentUserStore();
}
this.$message.success('表单已重置');
}).catch(() => {
// 用户取消
});
},
dataFormSubmit() {
this.$refs['elForm'].validate((valid) => {
if (valid) {
if (!this.dataForm.id) {
request({
url: `/api/Extend/LqKdKdjlb`,
method: 'post',
data: this.dataForm,
}).then((res) => {
this.$message({
message: res.msg,
type: 'success',
duration: 1000,
onClose: () => {
this.visible = false,
this.$emit('refresh', true)
}
})
})
} else {
|
bfb7c0b9
“wangming”
更新Form.vue和用户相关表单...
|
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
|
})
},
addHandleLqKdJksyjEntityList() {
let item = {
id: undefined,
glkdbh: undefined,
jks: undefined,
jksxm: undefined,
jkszh: undefined,
jksyj: undefined,
yjsj: undefined,
}
this.dataForm.lqKdJksyjList.push(item)
},
handleDelLqKdJksyjEntityList(index) {
this.dataForm.lqKdJksyjList.splice(index, 1);
},
addHandleLqKdKjbsyjEntityList() {
let item = {
id: undefined,
glkdbh: undefined,
kjbls: undefined,
kjblsxm: undefined,
kjblszh: undefined,
kjblsyj: undefined,
yjsj: undefined,
}
this.dataForm.lqKdKjbsyjList.push(item)
},
handleDelLqKdKjbsyjEntityList(index) {
this.dataForm.lqKdKjbsyjList.splice(index, 1);
},
addHandleLqKdPxmxEntityList() {
let item = {
id: undefined,
glkdbh: undefined,
px: undefined,
pxmc: undefined,
pxjg: undefined,
}
this.dataForm.lqKdPxmxList.push(item)
},
handleDelLqKdPxmxEntityList(index) {
this.dataForm.lqKdPxmxList.splice(index, 1);
},
|