Form.vue 27.5 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 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 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 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 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 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 552 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 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 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 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825
<template>
	<el-dialog :title="!dataForm.id ? '新建开单记录' : isDetail ? '开单记录详情' : '编辑开单记录'" :close-on-click-modal="false"
		:visible.sync="visible" class="NCC-dialog NCC-dialog_center" lock-scroll width="1200px">
		<el-row :gutter="10" class="compact-form">
			<el-form ref="elForm" :model="dataForm" size="mini" label-width="100px" label-position="right"
				:disabled="!!isDetail" :rules="rules">
				<!-- 基本信息 -->
				<el-col :span="24">
					<div class="form-section-title">
						<i class="el-icon-user"></i>
						<span>基本信息</span>
					</div>
				</el-col>
				<el-col :span="8" v-if="false">
					<el-form-item label="开单编号" prop="id">
						<el-input v-model="dataForm.id" placeholder="请输入" clearable readonly :style='{"width":"100%"}' >
						</el-input>
					</el-form-item>
				</el-col>
				<el-col :span="6">
					<el-form-item label="开单会员" prop="kdhy" required>
						<el-select v-model="dataForm.kdhy" placeholder="请选择" clearable :style='{"width":"100%"}' filterable >
							<el-option v-for="(item, index) in kdhyOptions" :key="index" :label="item.fullName" :value="item.id" ></el-option>
						</el-select>
					</el-form-item>
				</el-col>
				<el-col :span="6">
					<el-form-item label="单据门店" prop="djmd" required>
						<el-select v-model="dataForm.djmd" placeholder="请选择" clearable :style='{"width":"100%"}' filterable >
							<el-option v-for="(item, index) in djmdOptions" :key="index" :label="item.fullName" :value="item.id" ></el-option>
						</el-select>
					</el-form-item>
				</el-col>
				<el-col :span="6">
					<el-form-item label="金三角" prop="jsj" required>
						<el-select v-model="dataForm.jsj" placeholder="请选择" clearable :style='{"width":"100%"}' filterable >
							<el-option v-for="(item, index) in jsjOptions" :key="index" :label="item.fullName" :value="item.id" ></el-option>
						</el-select>
					</el-form-item>
				</el-col>
				<el-col :span="6">
					<el-form-item label="顾客类型" prop="gjlx" required>
						<el-select v-model="dataForm.gjlx" placeholder="请选择" clearable :style='{"width":"100%"}' >
							<el-option v-for="(item, index) in gjlxOptions" :key="index" :label="item.fullName" :value="item.id" ></el-option>
						</el-select>
					</el-form-item>
				</el-col>
				<el-col :span="8" v-if="false">
					<el-form-item label="开单日期" prop="kdrq">
						<el-date-picker v-model="dataForm.kdrq" placeholder="请选择" clearable :style='{"width":"100%"}' type='date' format="yyyy-MM-dd" value-format="timestamp" >
						</el-date-picker>
					</el-form-item>
				</el-col>
				<!-- 业绩信息 -->
				<el-col :span="24">
					<div class="form-section-title">
						<i class="el-icon-money"></i>
						<span>业绩信息</span>
					</div>
				</el-col>
				<el-col :span="6">
					<el-form-item label="整单业绩" prop="zdyj" required>
						<el-input v-model="dataForm.zdyj" placeholder="请输入" clearable :style='{"width":"100%"}' @input="formatNumber('zdyj')">
							<template slot="append">元</template>
						</el-input>
					</el-form-item>
				</el-col>
				<el-col :span="6">
					<el-form-item label="实付业绩" prop="sfyj" required>
						<el-input v-model="dataForm.sfyj" placeholder="请输入" clearable :style='{"width":"100%"}' @input="formatNumber('sfyj')">
							<template slot="append">元</template>
						</el-input>
					</el-form-item>
				</el-col>
				<el-col :span="6">
					<el-form-item label="欠款" prop="qk">
						<el-input v-model="dataForm.qk" placeholder="自动计算" clearable readonly :style='{"width":"100%"}' >
							<template slot="append">元</template>
						</el-input>
					</el-form-item>
				</el-col>
				<el-col :span="6">
					<el-form-item label="是否储扣" prop="sfck">
						<el-radio-group v-model="dataForm.sfck" :style='{}' >
							<el-radio v-for="(item, index) in sfckOptions" :key="index" :label="item.id"  >{{item.fullName}}</el-radio>
						</el-radio-group>
					</el-form-item>
				</el-col>
				<el-col :span="6" v-if="dataForm.sfck === '是'">
					<el-form-item label="储扣方式" prop="ckfs">
						<el-select v-model="dataForm.ckfs" placeholder="请选择" clearable :style='{"width":"100%"}' >
							<el-option v-for="(item, index) in ckfsOptions" :key="index" :label="item.fullName" :value="item.id" ></el-option>
						</el-select>
					</el-form-item>
				</el-col>
				<el-col :span="6" v-if="dataForm.sfck === '是'">
					<el-form-item label="储扣明细" prop="ckmx">
						<el-input v-model="dataForm.ckmx" placeholder="请输入" clearable :style='{"width":"100%"}' >
						</el-input>
					</el-form-item>
				</el-col>
				<!-- 付款信息 -->
				<el-col :span="24">
					<div class="form-section-title">
						<i class="el-icon-credit-card"></i>
						<span>付款信息</span>
					</div>
				</el-col>
				<el-col :span="6">
					<el-form-item label="付款方式" prop="fkfs" required>
						<el-select v-model="dataForm.fkfs" placeholder="请选择" clearable :style='{"width":"100%"}' >
							<el-option v-for="(item, index) in fkfsOptions" :key="index" :label="item.fullName" :value="item.id" ></el-option>
						</el-select>
					</el-form-item>
				</el-col>
				<el-col :span="6">
					<el-form-item label="付款医院" prop="fkyy">
						<el-select v-model="dataForm.fkyy" placeholder="请选择" clearable :style='{"width":"100%"}' filterable >
							<el-option v-for="(item, index) in fkyyOptions" :key="index" :label="item.fullName" :value="item.id" ></el-option>
						</el-select>
					</el-form-item>
				</el-col>
				<el-col :span="6">
					<el-form-item label="合作机构" prop="hgjg">
						<el-select v-model="dataForm.hgjg" placeholder="请选择" clearable :style='{"width":"100%"}' >
							<el-option v-for="(item, index) in hgjgOptions" :key="index" :label="item.fullName" :value="item.id" ></el-option>
						</el-select>
					</el-form-item>
				</el-col>
				<el-col :span="6">
					<el-form-item label="是否首开订单" prop="sfskdd">
						<el-radio-group v-model="dataForm.sfskdd" :style='{}' >
							<el-radio v-for="(item, index) in sfskddOptions" :key="index" :label="item.id"  >{{item.fullName}}</el-radio>
						</el-radio-group>
					</el-form-item>
				</el-col>
				<el-col :span="8" v-if="false">
					<el-form-item label="付款判断" prop="fkpd">
						<el-input v-model="dataForm.fkpd" placeholder="请输入" clearable :style='{"width":"100%"}' >
						</el-input>
					</el-form-item>
				</el-col>
				<el-col :span="8" v-if="false">
					<el-form-item label="客户来源" prop="khly">
						<el-select v-model="dataForm.khly" placeholder="请选择" clearable :style='{"width":"100%"}' >
							<el-option v-for="(item, index) in khlyOptions" :key="index" :label="item.fullName" :value="item.id" ></el-option>
						</el-select>
					</el-form-item>
				</el-col>
				<el-col :span="8" v-if="false">
					<el-form-item label="推荐人" prop="tjr">
						<el-input v-model="dataForm.tjr" placeholder="请输入" clearable :style='{"width":"100%"}' >
						</el-input>
					</el-form-item>
				</el-col>

				<!-- 业绩明细 -->
				<el-col :span="24">
					<div class="form-section-title">
						<i class="el-icon-s-data"></i>
						<span>业绩明细</span>
					</div>
				</el-col>
				<el-col :span="24">
					<el-form-item label-width="0">
						<div class="table-header">
							<span class="table-title">健康师业绩</span>
							<el-button type="primary" size="mini" icon="el-icon-plus" @click="addHandleLqKdJksyjEntityList()">新增健康师</el-button>
						</div>
						<el-table :data="dataForm.lqKdJksyjList" size='mini' border stripe style="width: 100%">
							<el-table-column type="index" width="60" label="序号" align="center" />
							<el-table-column prop="jks" label="健康师" min-width="150">
								<template slot-scope="scope">
									<user-select v-model="scope.row.jks" placeholder="请选择" clearable @change="handleJksChange(scope.$index, scope.row)"></user-select>
								</template>
							</el-table-column>
							<el-table-column prop="jksxm" label="健康师姓名" min-width="120">
								<template slot-scope="scope">
									<el-input v-model="scope.row.jksxm" placeholder="请输入" clearable ></el-input>
								</template>
							</el-table-column>
							<el-table-column prop="jkszh" label="健康师账号" min-width="120">
								<template slot-scope="scope">
									<el-input v-model="scope.row.jkszh" placeholder="请输入" clearable ></el-input>
								</template>
							</el-table-column>
							<el-table-column prop="jksyj" label="健康师业绩" min-width="150">
								<template slot-scope="scope">
									<el-input v-model="scope.row.jksyj" placeholder="请输入" clearable @input="formatTableNumber(scope.$index, 'jksyj', 'lqKdJksyjList')">
										<template slot="append">元</template>
									</el-input>
								</template>
							</el-table-column>
							<el-table-column label="操作" width="80" align="center" fixed="right">
								<template slot-scope="scope">
									<el-button size="mini" type="danger" icon="el-icon-delete" @click="handleDelLqKdJksyjEntityList(scope.$index)">删除</el-button>
								</template>
							</el-table-column>
						</el-table>
					</el-form-item>
				</el-col>
				<el-col :span="24">
					<el-form-item label-width="0">
						<div class="table-header">
							<span class="table-title">科技部老师业绩</span>
							<el-button type="success" size="mini" icon="el-icon-plus" @click="addHandleLqKdKjbsyjEntityList()">新增科技老师</el-button>
						</div>
						<el-table :data="dataForm.lqKdKjbsyjList" size='mini' border stripe style="width: 100%">
							<el-table-column type="index" width="60" label="序号" align="center" />
							<el-table-column prop="kjbls" label="科技部老师" min-width="150">
								<template slot-scope="scope">
									<user-select v-model="scope.row.kjbls" placeholder="请选择" clearable @change="handleKjblsChange(scope.$index, scope.row)"></user-select>
								</template>
							</el-table-column>
							<el-table-column prop="kjblsxm" label="科技部老师姓名" min-width="120">
								<template slot-scope="scope">
									<el-input v-model="scope.row.kjblsxm" placeholder="请输入" clearable ></el-input>
								</template>
							</el-table-column>
							<el-table-column prop="kjblszh" label="科技部老师账号" min-width="120">
								<template slot-scope="scope">
									<el-input v-model="scope.row.kjblszh" placeholder="请输入" clearable ></el-input>
								</template>
							</el-table-column>
							<el-table-column prop="kjblsyj" label="科技部老师业绩" min-width="150">
								<template slot-scope="scope">
									<el-input v-model="scope.row.kjblsyj" placeholder="请输入" clearable @input="formatTableNumber(scope.$index, 'kjblsyj', 'lqKdKjbsyjList')">
										<template slot="append">元</template>
									</el-input>
								</template>
							</el-table-column>
							<el-table-column label="操作" width="80" align="center" fixed="right">
								<template slot-scope="scope">
									<el-button size="mini" type="danger" icon="el-icon-delete" @click="handleDelLqKdKjbsyjEntityList(scope.$index)">删除</el-button>
								</template>
							</el-table-column>
						</el-table>
					</el-form-item>
				</el-col>
				<el-col :span="24">
					<el-form-item label-width="0">
						<div class="table-header">
							<span class="table-title">品项明细</span>
							<el-button type="warning" size="mini" icon="el-icon-plus" @click="addHandleLqKdPxmxEntityList()">新增品项</el-button>
						</div>
						<el-table :data="dataForm.lqKdPxmxList" size='mini' border stripe style="width: 100%">
							<el-table-column type="index" width="60" label="序号" align="center" />
							<el-table-column prop="px" label="品项" min-width="150">
								<template slot-scope="scope">
									<el-select v-model="scope.row.px" placeholder="请选择" clearable filterable >
										<el-option v-for="(item, index) in pxOptions" :key="index" :label="item.fullName" :value="item.id" :disabled="item.disabled"></el-option>
									</el-select>
								</template>
							</el-table-column>
							<el-table-column prop="pxmc" label="品项名称" min-width="200">
								<template slot-scope="scope">
									<el-input v-model="scope.row.pxmc" placeholder="请输入品项名称" clearable ></el-input>
								</template>
							</el-table-column>
							<el-table-column prop="pxjg" label="品项价格" min-width="150">
								<template slot-scope="scope">
									<el-input v-model="scope.row.pxjg" placeholder="请输入价格" clearable @input="formatTableNumber(scope.$index, 'pxjg', 'lqKdPxmxList')">
										<template slot="append">元</template>
									</el-input>
								</template>
							</el-table-column>
							<el-table-column label="操作" width="80" align="center" fixed="right">
								<template slot-scope="scope">
									<el-button size="mini" type="danger" icon="el-icon-delete" @click="handleDelLqKdPxmxEntityList(scope.$index)">删除</el-button>
								</template>
							</el-table-column>
						</el-table>
					</el-form-item>
				</el-col>

				<!-- 其他信息 -->
				<el-col :span="24">
					<div class="form-section-title">
						<i class="el-icon-document"></i>
						<span>其他信息</span>
					</div>
				</el-col>
				<el-col :span="24">
					<el-form-item label="简介" prop="jj">
						<el-input v-model="dataForm.jj" placeholder="请输入简介信息" show-word-limit :style='{"width":"100%"}' type='textarea' :autosize='{"minRows":3,"maxRows":6}' >
						</el-input>
					</el-form-item>
				</el-col>
				<el-col :span="12">
					<el-form-item label="上传文件" prop="scwj">
						<NCC-UploadImg v-model="dataForm.scwj" :fileSize="30" sizeUnit="MB" :limit="9" >
						</NCC-UploadImg>
					</el-form-item>
				</el-col>
				<el-col :span="12">
					<el-form-item label="会员签字" prop="hyqz">
						<NCC-UploadImg v-model="dataForm.hyqz" :fileSize="5" sizeUnit="MB" :limit="9" >
						</NCC-UploadImg>
					</el-form-item>
				</el-col>
				<el-col :span="24">
					<el-form-item label="备注" prop="bz">
						<el-input v-model="dataForm.bz" placeholder="请输入备注信息" show-word-limit :style='{"width":"100%"}' type='textarea' :autosize='{"minRows":3,"maxRows":6}' >
						</el-input>
					</el-form-item>
				</el-col>
				<el-col :span="24">
					<el-form-item label="健康师业绩" prop="jksyj" v-if="false">
						<el-input v-model="dataForm.jksyj" placeholder="请输入" clearable :style='{"width":"100%"}' >
						</el-input>
					</el-form-item>
				</el-col>
				<el-col :span="24">
					<el-form-item label="科技部老师业绩" prop="kjblsyj" v-if="false">
						<el-input v-model="dataForm.kjblsyj" placeholder="请输入" clearable :style='{"width":"100%"}' >
						</el-input>
					</el-form-item>
				</el-col>
				<el-col :span="24">
					<el-form-item label="品项信息" prop="pxxx" v-if="false">
						<el-input v-model="dataForm.pxxx" placeholder="请输入" clearable :style='{"width":"100%"}' >
						</el-input>
					</el-form-item>
				</el-col>
			</el-form>
		</el-row>
		<span slot="footer" class="dialog-footer">
			<el-button @click="visible = false">取 消</el-button>
			<el-button @click="resetForm" v-if="!isDetail">重 置</el-button>
			<el-button type="primary" @click="dataFormSubmit()" v-if="!isDetail">确 定</el-button>
		</span>
	</el-dialog>
</template>
<script>
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();
			}
		},
		'dataForm.sfyj': {
			handler(newVal) {
				this.calculateQk();
			}
		}
	},
	created() {
		this.getkdhyOptions();
		this.getdjmdOptions();
		this.getjsjOptions();
		this.gethgjgOptions();
		this.getfkyyOptions();
		this.getpxOptions();
	},
	mounted() {
	},
	methods: {
		getkdhyOptions() {
			previewDataInterface('730998109110273285').then(res => {
				this.kdhyOptions = res.data
			});
		},
		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);
				});
			});
		},
		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 {
						request({
							url: '/api/Extend/LqKdKdjlb/' + this.dataForm.id,
							method: 'PUT',
							data: this.dataForm
						}).then((res) => {
							this.$message({
								message: res.msg,
								type: 'success',
								duration: 1000,
								onClose: () => {
									this.visible = false
									this.$emit('refresh', true)
								}
							})
						})
					}
				}
			})
		},
		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);
		},
	}
}
</script>

<style scoped>
.form-section-title {
	display: flex;
	align-items: center;
	margin: 15px 0 10px 0;
	padding: 8px 12px;
	background: #409EFF;
	color: white;
	border-radius: 6px;
	font-size: 14px;
	font-weight: 600;
	box-shadow: 0 2px 4px rgba(64, 158, 255, 0.2);
}

.form-section-title i {
	margin-right: 8px;
	font-size: 18px;
}

.table-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 8px;
	padding: 8px 12px;
	background: #f5f7fa;
	border-radius: 4px;
	border-left: 3px solid #409EFF;
}

.table-title {
	font-size: 14px;
	font-weight: 600;
	color: #303133;
}

.table-actions {
	margin-top: 10px;
	text-align: right;
}

.el-table {
	border-radius: 6px;
	overflow: hidden;
}

.el-table th {
	background: #f5f7fa;
	color: #606266;
	font-weight: 600;
}

.el-form-item {
	margin-bottom: 12px;
}

.compact-form .el-form-item {
	margin-bottom: 8px;
}

.el-input-group__append {
	background: #f5f7fa;
	border-color: #dcdfe6;
	color: #606266;
}

.dialog-footer {
	text-align: right;
	padding: 20px 0;
}

.dialog-footer .el-button {
	margin-left: 10px;
}

/* 必填字段标识 */
.el-form-item.is-required .el-form-item__label::before {
	content: '*';
	color: #f56c6c;
	margin-right: 4px;
}

/* 数字输入框样式 */
.el-input-number {
	width: 100%;
}

/* 表格操作按钮样式 */
.el-button--mini {
	padding: 5px 10px;
	font-size: 12px;
}

/* 响应式布局 */
@media (max-width: 768px) {
	.el-col {
		margin-bottom: 10px;
	}

	.form-section-title {
		font-size: 14px;
		padding: 8px 12px;
	}

	.table-header {
		flex-direction: column;
		align-items: flex-start;
		gap: 10px;
	}
}
</style>