<template>
  <div>
    <!-- 左侧树形结构 -->
    <el-container>
      <el-aside width="250px">
        <div class="JKWTree-tree">
          <h3>包装工序产量维护</h3>
          <el-tree :data="treeData" :props="defaultProps" highlight-current="true"
            @node-click="handleNodeClick"></el-tree>
        </div>
      </el-aside>

      <el-container>
        <el-main>
          <!-- 按钮区域 -->
          <div class="gva-table-box">
            <div class="gva-btn-list">
              <el-row :span="6">
                <el-input v-model="searchInfo" placeholder="输入工单编号或产品名称" />
              </el-row>
              <el-button type="primary" :icon="Search" @click="onSearch">搜索</el-button>
              <el-button type="primary" :icon="Refresh">重置</el-button>
			  <el-button type="primary" :icon="Search" @click="positioningVisible">定位</el-button>
			  <el-button type="primary" :icon="Search">查改</el-button>
              <div style="margin-left: auto;">
                <el-button type="primary" :icon="Download" @click="exportExcel">导出到Excel</el-button>
              </div>
            </div>
            <!-- 数据展示 -->
            <el-table ref="multipleTable" style="width: 100%" tooltip-effect="dark" :data="tableData" row-key="ID"
              highlight-current-row="true"  :cell-style="cellStyle" border @selection-change="handleSelectionChange" 
			  :show-overflow-tooltip="true" @row-dblclick="doubleClick">
              <el-table-column type="selection" width="55" />
			  <el-table-column align="left" label="创建用户" prop="sys_id" width="120" />
              <el-table-column align="left" label="日期" prop="sczl_rq" width="120"/>
              <el-table-column align="left" label="包装产量" prop="sczl_cl" width="120"/>
              <el-table-column align="left" label="包装数量" prop="sczl_PgCl" width="120"/>
              <el-table-column align="left" label="创建时间" prop="sys_rq" width="160"/>
              <el-table-column align="left" label="修改时间" prop="mod_rq" width="160"/>
              <el-table-column align="left" label="UNIQID" prop="UniqId" width="120"/>
            </el-table>
            <!-- 分页 -->
            <div class="gva-pagination">
              <el-pagination layout="total, sizes, prev, pager, next, jumper" :current-page="page" :page-size="limit"
                :page-sizes="[10, 30, 50, 100]" :total="total" @current-change="handleCurrentChange"
                @size-change="handleSizeChange" />
            </div>
          </div>
          <!-- 弹出框 -->
          <el-dialog v-model="dialogFormVisible" :before-close="closeDialog" :title="type === 'create' ? '添加' : '修改'"
            destroy-on-close width="1200px">
            <!-- <el-scrollbar height="500px"> -->
            <el-form :model="gdbhformData" label-position="left" ref="elFormRef" :rules="rule">

              <el-row :gutter="20">

                <el-col :span="6">
                  <el-form-item label="日期" prop="name">
                    <el-row :gutter="20">
                      <el-col :span="12">
                        <el-input v-model="formData.sczl_rq" :clearable="true" placeholder="ZT01733" />
                      </el-col>
                    </el-row>
                  </el-form-item>
                </el-col>
              </el-row>

                            <!-- 标题栏 -->
                            <el-row :gutter="10">
                              <el-col :span="3">
                                <span>工单编号</span>
                              </el-col>
                              <el-col :span="3">
                                <span>印件工序</span>
                              </el-col>
                              <el-col :span="3">
                                <span>工序名称</span>
                              </el-col>
                              <el-col :span="9">
                                <span>印件名称</span>
                              </el-col>
                              <el-col :span="2">
                                <span>包装产量</span>
                              </el-col>
							  <el-col :span="2">
							    <span>每箱数量</span>
							  </el-col>
							  <el-col :span="2">
							    <span>零头</span>
							  </el-col>
                            </el-row>
              
                            <!-- 员工1 -->
                            <el-row :gutter="5" style="margin-top: 10px;">
                              <el-col :span="3">
                                <el-input v-model="formData.sczl_gdbh1" :clearable="true" @keyup.enter.native="getGxMcsubmit($event, '1')" placeholder="ZI00401" />
                              </el-col>
                              <el-col :span="3">
                                <el-input v-model="formData.sczl_yjGx1" :clearable="true" placeholder="瞿春生" />
                              </el-col>
                              <el-col :span="3">
                                <el-input v-model="formData.sczl_gxmc1" :clearable="true" placeholder="11.0" />
                              </el-col>
                              <el-col :span="9">
                                <el-input v-model="formData.Gd_cpmc1" :clearable="true" placeholder="打包废纸" />
                              </el-col>
                              <el-col :span="2">
                                <el-input v-model="formData.sczl_cl1" :clearable="true" placeholder="是" />
                              </el-col>
							  <el-col :span="2">
							    <el-input v-model="formData.sczl_PgCl1" :clearable="true" placeholder="是" />
							  </el-col>
							  <el-col :span="2">
							    <el-input v-model="formData.sczl_clAdd1" :clearable="true" placeholder="是" />
							  </el-col>
                            </el-row>
              
                            <!-- 员工2 -->
                            <el-row :gutter="5" style="margin-top: 10px;">
                              <el-col :span="3">
                                <el-input v-model="formData.sczl_gdbh2" :clearable="true" @keyup.enter.native="getGxMcsubmit($event, '2')" placeholder="ZI00401" />
                              </el-col>
                              <el-col :span="3">
                                <el-input v-model="formData.sczl_yjGx2" :clearable="true" placeholder="瞿春生" data-="" />
                              </el-col>
                              <el-col :span="3">
                                <el-input v-model="formData.sczl_gxmc2" :clearable="true" placeholder="11.0" />
                              </el-col>
                              <el-col :span="9">
                                <el-input v-model="formData.Gd_cpmc2" :clearable="true" placeholder="打包废纸" />
                              </el-col>
                              <el-col :span="2">
                                <el-input v-model="formData.sczl_cl2" :clearable="true" placeholder="是" />
                              </el-col>
							  <el-col :span="2">
							    <el-input v-model="formData.sczl_PgCl2" :clearable="true" placeholder="是" />
							  </el-col>
							  <el-col :span="2">
							    <el-input v-model="formData.sczl_clAdd2" :clearable="true" placeholder="是" />
							  </el-col>
                            </el-row>
              
                            <!-- 员工3 -->
                            <el-row :gutter="5" style="margin-top: 10px;">
                              <el-col :span="3">
                                <el-input v-model="formData.sczl_gdbh3" :clearable="true" @keyup.enter.native="getGxMcsubmit($event, '3')" placeholder="ZI00401" />
                              </el-col>
                              <el-col :span="3">
                                <el-input v-model="formData.sczl_yjGx3" :clearable="true" placeholder="瞿春生" data-="" />
                              </el-col>
                              <el-col :span="3">
                                <el-input v-model="formData.sczl_gxmc3" :clearable="true" placeholder="11.0" />
                              </el-col>
                              <el-col :span="9">
                                <el-input v-model="formData.Gd_cpmc3" :clearable="true" placeholder="打包废纸" />
                              </el-col>
                              <el-col :span="2">
                                <el-input v-model="formData.sczl_cl3" :clearable="true" placeholder="是" />
                              </el-col>
                              <el-col :span="2">
                                <el-input v-model="formData.sczl_PgCl3" :clearable="true" placeholder="是" />
                              </el-col>
                              <el-col :span="2">
                                <el-input v-model="formData.sczl_clAdd3" :clearable="true" placeholder="是" />
                              </el-col>
                            </el-row>
              
                            <!-- 员工4 -->
                           <el-row :gutter="5" style="margin-top: 10px;">
                              <el-col :span="3">
                                <el-input v-model="formData.sczl_gdbh4" :clearable="true" @keyup.enter.native="getGxMcsubmit($event, '4')" placeholder="ZI00401" />
                              </el-col>
                              <el-col :span="3">
                                <el-input v-model="formData.sczl_yjGx4" :clearable="true" placeholder="瞿春生" data-="" />
                              </el-col>
                              <el-col :span="3">
                                <el-input v-model="formData.sczl_gxmc4" :clearable="true" placeholder="11.0" />
                              </el-col>
                              <el-col :span="9">
                                <el-input v-model="formData.Gd_cpmc4" :clearable="true" placeholder="打包废纸" />
                              </el-col>
                              <el-col :span="2">
                                <el-input v-model="formData.sczl_cl4" :clearable="true" placeholder="是" />
                              </el-col>
							  <el-col :span="2">
							    <el-input v-model="formData.sczl_PgCl4" :clearable="true" placeholder="是" />
							  </el-col>
							  <el-col :span="2">
							    <el-input v-model="formData.sczl_clAdd4" :clearable="true" placeholder="是" />
							  </el-col>
                            </el-row>
              
                            <!-- 员工5 -->
                            <el-row :gutter="5" style="margin-top: 10px;">
                              <el-col :span="3">
                                <el-input v-model="formData.sczl_gdbh5"  @keyup.enter.native="getGxMcsubmit($event, '5')" :clearable="true" placeholder="ZI00401" />
                              </el-col>
                              <el-col :span="3">
                                <el-input v-model="formData.sczl_yjGx5" :clearable="true" placeholder="瞿春生" data-="" />
                              </el-col>
                              <el-col :span="3">
                                <el-input v-model="formData.sczl_gxmc5" :clearable="true" placeholder="11.0" />
                              </el-col>
                              <el-col :span="9">
                                <el-input v-model="formData.Gd_cpmc5" :clearable="true" placeholder="打包废纸" />
                              </el-col>
                              <el-col :span="2">
                                <el-input v-model="formData.sczl_cl5" :clearable="true" placeholder="是" />
                              </el-col>
                              <el-col :span="2">
                                <el-input v-model="formData.sczl_PgCl5" :clearable="true" placeholder="是" />
                              </el-col>
                              <el-col :span="2">
                                <el-input v-model="formData.sczl_clAdd5" :clearable="true" placeholder="是" />
                              </el-col>
                            </el-row>
              
                            <!-- 员工6 -->
                            <el-row :gutter="5" style="margin-top: 10px;">
                              <el-col :span="3">
                                <el-input v-model="formData.sczl_gdbh6" :clearable="true"  @keyup.enter.native="getGxMcsubmit($event, '6')" placeholder="ZI00401" />
                              </el-col>
                              <el-col :span="3">
                                <el-input v-model="formData.sczl_yjGx6" :clearable="true" placeholder="瞿春生" data-="" />
                              </el-col>
                              <el-col :span="3">
                                <el-input v-model="formData.sczl_gxmc6" :clearable="true" placeholder="11.0" />
                              </el-col>
                              <el-col :span="9">
                                <el-input v-model="formData.Gd_cpmc6" :clearable="true" placeholder="打包废纸" />
                              </el-col>
                              <el-col :span="2">
                                <el-input v-model="formData.sczl_cl6" :clearable="true" placeholder="是" />
                              </el-col>
                              <el-col :span="2">
                                <el-input v-model="formData.sczl_PgCl6" :clearable="true" placeholder="是" />
                              </el-col>
                              <el-col :span="2">
                                <el-input v-model="formData.sczl_clAdd6" :clearable="true" placeholder="是" />
                              </el-col>
                            </el-row>
			  
            </el-form>
            <!-- </el-scrollbar> -->
            <template #footer>
              <div class="dialog-footer">
                <el-button @click="closeDialog">取 消</el-button>
                <el-button type="primary" @click="enterDialog">确 定</el-button>
              </div>
            </template>
          </el-dialog>



          <el-dialog v-model="positioningVisibleshow" :before-close="closepositioningVisible" :title="type==='create'?'添加':'修改'" destroy-on-close>
            <el-card>
				<el-form-item label="工单编号" prop="name">
				  <el-row :gutter="20">
				    <el-col :span="12">
				      <el-input v-model="positionvalue" :clearable="true" placeholder="ZT01733" />
				    </el-col>                      
				  </el-row>
				</el-form-item>
			</el-card>
			<el-button type="primary" @click="enterpositioning">确 定</el-button>
          </el-dialog>


          <el-dialog v-model="getGxMcshow" :before-close="closegetGxMcshow" :title="type==='create'?'添加':'修改'" destroy-on-close>
                
					<el-form :model="form" label-width="80px">
					  <div style="display: flex; justify-content: center;">
					    <el-form-item label="关键字">
					      <el-input v-model="name"></el-input>
					    </el-form-item>
					  </div>
					</el-form>

			<el-table ref="GxMctable" style="width: 100%" tooltip-effect="dark" :data="GxMctableData" row-key="ID"
			  highlight-current-row="true"  :cell-style="cellStyle" border @selection-change="handleSelectionChange"
			   :show-overflow-tooltip="true" @row-dblclick="GxMcdoubleClick">			   
			  <el-table-column align="left" label="印件工序" prop="jyGx" width="120" />
			  <el-table-column align="left" label="工序名称" prop="Gy0_gxmc" width="120"/>
			  <el-table-column align="left" label="印件名称" prop="Gd_cpmc" width="800"/>
			</el-table>
		
			<template #footer>
			  <div class="dialog-footer">
			    <el-button @click="closegetGxMcshow">取 消</el-button>
			  </div>
			</template>
          </el-dialog>

        </el-main>
      </el-container>
    </el-container>

  </div>
</template>

<script setup>
import {
  getList,
  getTab,
  locate,
  getInfo,
  getGxMc,
  edit
} from '@/api/jixiaoguanli/jitairibaobiao'

// 全量引入格式化工具 请按需保留
import { getDictFunc, formatDate, formatBoolean, filterDict, ReturnArrImg, onDownloadFile } from '@/utils/format'
import { ElMessage, ElMessageBox, LAST_KEYS } from 'element-plus'
import { Search, Refresh, Download } from '@element-plus/icons-vue'
import { ref, reactive, onMounted, onBeforeMount } from 'vue'
import { getPackingSideTable, getPackingTable } from '@/api/mes_api_gty/myapi'

defineOptions({
  name: '06-packingDocuments'
})

// 侧边栏数据请求
const treeData = reactive([]);

const getTabdata = async () => {
    //接口调用函数
    const response  = await getTab();
	console.log(response)
	
	
	const transformedData = response.data.map(item => ({
	      label: `${item.date.replace(/-/g, '.')}【单据数: ${item.counts}张】`,
	      children: item.sys.map(sysItem => ({
	        label: `${sysItem.sys_id} 【记录数: ${sysItem.count}张】`,
	        params: {
	          date: item.date.replace(/\./g, '-'),
	          sys_id: sysItem.sys_id,
	          total: sysItem.count,
	        },
	      })),
	    }));
	    treeData.splice(0, treeData.length, ...transformedData);

	
	}
	

getTabdata();

// 自动化生成的字典（可能为空）以及字段
const formData = ref({
		  sczl_rq: '',
          sczl_gdbh1: '',
          sczl_gdbh2: '',
          sczl_gdbh3: '',
          sczl_gdbh4: '',
          sczl_gdbh5: '',
          sczl_gdbh6: '',
          sczl_yjGx1: '',
          sczl_yjGx2: '',
          sczl_yjGx3: '',
          sczl_yjGx4: '',
          sczl_yjGx5: '',
          sczl_yjGx6: '',
          sczl_cl1: '',
          sczl_cl2: '',
          sczl_cl3: '',
          sczl_cl4: '',
          sczl_cl5: '',
          sczl_cl6: '',
          sczl_PgCl1:'',
          sczl_PgCl2: '',
          sczl_PgCl3: '',
          sczl_PgCl4: '',
          sczl_PgCl5: '',
          sczl_PgCl6: '',
          Gd_cpmc1: '',
          Gd_cpmc2: '',
          Gd_cpmc3: '',
          Gd_cpmc4: '',
          Gd_cpmc5: '',
          Gd_cpmc6: '',
		  sczl_clAdd1: '',
		  sczl_clAdd2: '',
		  sczl_clAdd3: '',
		  sczl_clAdd4: '',
		  sczl_clAdd5:'',
		  sczl_clAdd6: '',
		  UniqId:'000',
})


const formData2 = ref({
	      UniqId:'000',
		  sczl_rq: '',
          sczl_gdbh1: '',
          sczl_gdbh2: '',
          sczl_gdbh3: '',
          sczl_gdbh4: '',
          sczl_gdbh5: '',
          sczl_gdbh6: '',
          sczl_yjGx1: '',
          sczl_yjGx2: '',
          sczl_yjGx3: '',
          sczl_yjGx4: '',
          sczl_yjGx5: '',
          sczl_yjGx6: '',
		  sczl_gxmc1: '',
		  sczl_gxmc2: '',
		  sczl_gxmc3: '',
		  sczl_gxmc4: '',
		  sczl_gxmc5: '',
		  sczl_gxmc6: '',
          sczl_cl1: '',
          sczl_cl2: '',
          sczl_cl3: '',
          sczl_cl4: '',
          sczl_cl5: '',
          sczl_cl6: '',
          sczl_PgCl1:'',
          sczl_PgCl2: '',
          sczl_PgCl3: '',
          sczl_PgCl4: '',
          sczl_PgCl5: '',
          sczl_PgCl6: '',
		  sczl_clAdd1: '',
		  sczl_clAdd2: '',
		  sczl_clAdd3: '',
		  sczl_clAdd4: '',
		  sczl_clAdd5:'',
		  sczl_clAdd6: '',  
})

// 验证规则
const rule = reactive({
})

const elFormRef = ref()
const elSearchFormRef = ref()

// =========== 表格控制部分 ===========
const tableData = reactive([])
const GxMctableData = reactive([])

const detailData = reactive([
  {
    gdbh: '2311736',
    yjgx: '01-15',
    gxmc: '包装(圆切)',
    yjmc: '利群(新)小《降焦改版)',
    bzcl: '13.00',
    fgcl: '0.00',
    mxsl: '2500',
    jcxs: '1.000',
    ly: '',
    dedh: '030002002',
  },
  {
    gdbh: '2311736',
    yjgx: '01-15',
    gxmc: '包装(圆切)',
    yjmc: '利群(新)小《降焦改版)',
    bzcl: '13.00',
    fgcl: '0.00',
    mxsl: '2500',
    jcxs: '1.000',
    ly: '',
    dedh: '030002002',
  },
  {
    gdbh: '2311736',
    yjgx: '01-15',
    gxmc: '包装(圆切)',
    yjmc: '利群(新)小《降焦改版)',
    bzcl: '13.00',
    fgcl: '0.00',
    mxsl: '2500',
    jcxs: '1.000',
    ly: '',
    dedh: '030002002',
  },
  {
    gdbh: '2311736',
    yjgx: '01-15',
    gxmc: '包装(圆切)',
    yjmc: '利群(新)小《降焦改版)',
    bzcl: '13.00',
    fgcl: '0.00',
    mxsl: '2500',
    jcxs: '1.000',
    ly: '',
    dedh: '030002002',
  },
  {
    gdbh: '2311736',
    yjgx: '01-15',
    gxmc: '包装(圆切)',
    yjmc: '利群(新)小《降焦改版)',
    bzcl: '13.00',
    fgcl: '0.00',
    mxsl: '2500',
    jcxs: '1.000',
    ly: '',
    dedh: '030002002',
  },
  {
    gdbh: '2311736',
    yjgx: '01-15',
    gxmc: '包装(圆切)',
    yjmc: '利群(新)小《降焦改版)',
    bzcl: '13.00',
    fgcl: '0.00',
    mxsl: '2500',
    jcxs: '1.000',
    ly: '',
    dedh: '030002002',
  },
  {
    gdbh: '2311736',
    yjgx: '01-15',
    gxmc: '包装(圆切)',
    yjmc: '利群(新)小《降焦改版)',
    bzcl: '13.00',
    fgcl: '0.00',
    mxsl: '2500',
    jcxs: '1.000',
    ly: '',
    dedh: '030002002',
  },
  {
    gdbh: '2311736',
    yjgx: '01-15',
    gxmc: '包装(圆切)',
    yjmc: '利群(新)小《降焦改版)',
    bzcl: '13.00',
    fgcl: '0.00',
    mxsl: '2500',
    jcxs: '1.000',
    ly: '',
    dedh: '030002002',
  },
  {
    gdbh: '2311736',
    yjgx: '01-15',
    gxmc: '包装(圆切)',
    yjmc: '利群(新)小《降焦改版)',
    bzcl: '13.00',
    fgcl: '0.00',
    mxsl: '2500',
    jcxs: '1.000',
    ly: '',
    dedh: '030002002',
  },
  {
    gdbh: '2311736',
    yjgx: '01-15',
    gxmc: '包装(圆切)',
    yjmc: '利群(新)小《降焦改版)',
    bzcl: '13.00',
    fgcl: '0.00',
    mxsl: '2500',
    jcxs: '1.000',
    ly: '',
    dedh: '030002002',
  },
])
const total=ref(0)
const inputname=ref(0)
const page = ref(1)
const limit = ref(10)
const searchInfo = ref('')
const params = {
  date: '',
  sys_id: '',
  page: page.value.toString(),
  limit: limit.value.toString(),  
}
const locatevalue={
	gdbh:'',
	cpmc:'',
	page:page.value.toString(),
	limit:limit.value.toString(),  
}
let table=ref(5);
let positionvalue=ref()
let GxMcvalue=ref()

// 分页设置
const handleSizeChange = (val) => {
  limit.value = val;
  params.limit = val.toString();
  getTableData();
}



// 页面跳转
const handleCurrentChange = (val) => {
  page.value = val
  params.page = val.toString();
  getTableData()
}

// 查询
const getTableData = async () => {
		
  const response = await getList(params);
  console.log(response)
  if (response.code === 0) {
    tableData.splice(0, tableData.length, ...response.data.rows);
  }
}

const handleNodeClick = (node, check) => {
  //存放当前节点的nodeId
  if (node.params) {
    params.date = node.params.date;
    params.sys_id = node.params.sys_id;
    total.value = node.params.total;
    getTableData();
  }
}
const Getlocate = async () => {
  
  const response = await locate(locatevalue);
  console.log(locatevalue)
  console.log(response)
  if (response.code === 0) {
    tableData.splice(0, tableData.length, ...response.data.rows);
  }
}

const enterpositioning = async () => {
 locatevalue.gdbh=positionvalue.value;

 console.log(locatevalue.gdbh)
 Getlocate()
 closepositioningVisible()
}



const getpickInfo = async (value) => {
  const response = await getInfo({UniqId:value});
  console.log(response) 
  if (response.code === 0) {
	formData.value=response.data;
	formData2.value=response.data;
	console.log(formData2)
  }
}


const GxMcedit = async () => {
  
  console.log(formData2)
  const response = await edit(formData2);
  if (response.code === 0) {
	console.log(333)
  }
}


const GetGxMc = async (value, num) => {
  const response = await getGxMc({gdbh: value});
  console.log(response);
  if (response.code === 0) {
    if (response.data.length > 1) {
		
		
	GxMctableData.splice(0, GxMctableData.length, ...response.data);
    getGxMcshow.value = true; 
    }
    
    // 取出 data 中的第一个元素
    const item = response.data[0];
    
    // 将数据拆分成变量名和内容
    const variableName = Object.keys(item)[0]; // 变量名
    const variableContent = item[variableName]; // 变量内容
    
    const variableName1 = Object.keys(item)[1]; // 变量名
    const variableContent1 = item[variableName1]; // 变量内容
    
    const variableName2 = Object.keys(item)[2]; // 变量名
    const variableContent2 = item[variableName2]; // 变量内容
    
    console.log(variableContent2); // 输出生成的 Vue 代码
    
    // 根据 response.data.length 的值动态给 formData 中的变量赋值
    let Bname = 'Gd_cpmc' + num;
    let Bname2= 'sczl_gxmc' + num;
    let Bname3 = 'sczl_yjGx' + num;
    formData.value[Bname] = variableContent; // 假设要赋的值是 123
    formData.value[Bname2] = variableContent1;
    formData.value[Bname3] = variableContent2;
    console.log(formData.value[Bname]);
  }
}




// const inputOnclick = (event, inputName) => {
//  if(formData.value.sczl_gdbh6.length!=7||formData.value.sczl_gdbh5.length!=7||formData.value.sczl_gdbh3.length!=7||formData.value.sczl_gdbh4.length!=7||formData.value.sczl_gdbh2.length!=7||formData.value.sczl_gdbh1.length!=7){
// 	  	return false
// 	  }
// 	  // console.log(inputName);
// 	  let combinedString = 'formData.value.sczl_gdbh' + inputName;
// 	  // console.log(combinedString)
// 	  let variableName = 'sczl_gdbh'+inputName;
// 	  let variableValue = eval('formData.value.' + variableName);
// 	 console.log(variableValue)
// 	  // GetGxMc(combinedString)

// }

const getGxMcsubmit = (event, inputName) => {
 if(formData.value.sczl_gdbh6.length!=7||formData.value.sczl_gdbh5.length!=7||formData.value.sczl_gdbh3.length!=7||formData.value.sczl_gdbh4.length!=7||formData.value.sczl_gdbh2.length!=7||formData.value.sczl_gdbh1.length!=7){
	  	return false
	  }
	   // console.log(inputName);
	   inputname.value=inputName
	   console.log(inputname.value)
	  let combinedString = 'formData.value.sczl_gdbh' + inputName;
	  // console.log(combinedString)
	  let variableName = 'sczl_gdbh'+inputName;
	  let variableValue = eval('formData.value.' + variableName);
	 console.log(variableValue)
	  GetGxMc(variableValue,inputName)

}

// 搜索
function onSearch() {

}
// ============== 表格控制部分结束 ===============

// 获取需要的字典 可能为空 按需保留
const setOptions = async () => {
}

// 获取需要的字典 可能为空 按需保留
setOptions()

// 多选数据
const multipleSelection = ref([])
// 多选
const handleSelectionChange = (val) => {
  multipleSelection.value = val
}

// 批量删除控制标记
const deleteVisible = ref(false)

// 多选删除
const onDelete = async () => {
  const ids = []
  if (multipleSelection.value.length === 0) {
    ElMessage({
      type: 'warning',
      message: '请选择要删除的数据'
    })
    return
  }
  multipleSelection.value &&
    multipleSelection.value.map(item => {
      ids.push(item.ID)
    })
  const res = await deleteCompanyByIds({ ids })
  if (res.code === 0) {
    ElMessage({
      type: 'success',
      message: '删除成功'
    })
    if (tableData.value.length === ids.length && page.value > 1) {
      page.value--
    }
    deleteVisible.value = false
    getTableData()
  }
}

// 弹窗控制标记
const dialogFormVisible = ref(false)

// 行为控制标记（弹窗内部需要增还是改）
const type = ref('')

// 更新行
const updateCompanyFunc = async (row) => {
  const res = await findCompany({ ID: row.ID })
  type.value = 'update'
  if (res.code === 0) {
    formData.value = res.data.recompany
    dialogFormVisible.value = true
  }
}

// 弹窗控制标记
const positioningVisibleshow = ref(false)
const getGxMcshow = ref(false)

const positioningVisible = () => {
    type.value = 'create'
    positioningVisibleshow.value = true
}


const closepositioningVisible = () => {
  positioningVisibleshow.value = false
  formData.value = {
    address: '',
    image: '',
    name: '',
  }
}

const closegetGxMcshow = () => {
  getGxMcshow.value = false
}

// 打开弹窗
const openDialog = () => {
  type.value = 'create'
  dialogFormVisible.value = true
}

// 关闭弹窗
const closeDialog = () => {
  dialogFormVisible.value = false
  formData.value = {
    address: '',
    image: '',
    name: '',
  }
}
// 弹窗确定
const enterDialog = async () => {
      
	  formData.value.UniqId=lastCellValue
      GxMcedit()
   //    GxMcedit(lastCellValue)
	 // closeDialog()
	 // getTableData()
}

let lastCellValue=ref()
// 双击表格操作
function doubleClick(row) {
  
     // console.log(row, column, event);
       // updateCompanyFunc(row);
       type.value = 'update';
       dialogFormVisible.value = true
	   lastCellValue= row['UniqId'];
		 console.log(lastCellValue)
		 table.value=lastCellValue
       getpickInfo(table.value)
}


function GxMcdoubleClick(row) {

   GxMcvalue=row
   closegetGxMcshow()
   console.log(GxMcvalue.Gd_cpmc)
   
   
   
   // 根据 response.data.length 的值动态给 formData 中的变量赋值
   let Bname = 'Gd_cpmc' + inputname.value;
   let Bname2= 'sczl_gxmc' + inputname.value;
   let Bname3 = 'sczl_yjGx' + inputname.value;
   formData.value[Bname] =GxMcvalue.Gd_cpmc; // 假设要赋的值是 123
   formData.value[Bname2] = GxMcvalue.Gy0_gxmc;
   formData.value[Bname3] = GxMcvalue.jyGx;
   
}

// 导出excel
function exportExcel() {
  console.log('导出到excel');
}

// 生命周期钩子
onMounted(async () => {
});
</script>

<style>
.JKWTree-container {
  display: flex;
}

.JKWTree-tree {
  width: 300px;
  background-color: #fff;
  padding: 10px;
  margin-right: 20px;
}

.JKWTree-tree h3 {
  font-size: 15px;
  font-weight: 700;
  margin: 10px 0;
}

.JKWTree-content {
  flex: 1;
}

/* 选中某行时的背景色*/
.el-table__body tr.current-row>td {
  background: #ff80ff !important;
  /* 背景颜色 */
}
</style>