﻿<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>
