<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>
              <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" border 
			  :show-overflow-tooltip="true"
			  @selection-change="handleSelectionChange" @row-dblclick="doubleClick">
              <el-table-column type="selection" width="55" />
              <el-table-column align="left" label="工单编号" prop="sczl_gdbh" width="120"/>
              <el-table-column align="left" label="产品名称" prop="Gd_cpmc"  width="340"/>
              <el-table-column align="left" label="印件及工序" prop="jyno_gxmc"  width="120"/>
              <el-table-column align="left" label="生产日期" prop="sczl_rq"  width="120"/>
              <el-table-column align="left" label="机台" prop="sczl_jtbh"  width="120"/>
              <el-table-column align="left" label="班组" prop="sczl_bzdh"  width="120"/>
              <el-table-column align="left" label="流程单" prop="sczl_num"  width="120"/>
              <el-table-column align="left" label="车头产量" prop="sczl_cl"  width="120"/>
              <el-table-column align="left" label="色度数" prop="sczl_ms" width="120" />
			  <el-table-column align="left" label="制程废" prop="sczl_zcfp" width="120" />
			  <el-table-column align="left" label="次品" prop="sczl_zccp"  width="120"/>
			  <el-table-column align="left" label="来料异常" prop="incomingerror"  width="120"/>
			  <el-table-column align="left" label="装版工时" prop="sczl_装版工时"  width="120"/>
			  <el-table-column align="left" label="保养工时" prop="sczl_保养工时"  width="120"/>
			  <el-table-column align="left" label="打样工时" prop="sczl_打样工时"  width="120"/>
			  <el-table-column align="left" label="异常停机工时" prop="sczl_异常停机工时"  width="120"/>
			  <el-table-column align="left" label="设备运行工时" prop="sczl_设备运行工时"  width="120"/>
			  <el-table-column align="left" label="组员编号1" prop="sczl_bh1" width="120"/>
			  <el-table-column align="left" label="组员姓名1" prop="name1"  width="120"/>
			  <el-table-column align="left" label="组员编号2" prop="sczl_bh2"  width="120"/>
			  <el-table-column align="left" label="组员姓名2" prop="name1" width="120" />
			  <el-table-column align="left" label="组员编号3" prop="sczl_bh3"  width="120"/>
			  <el-table-column align="left" label="组员姓名3" prop="name3" width="120"/>
			  <el-table-column align="left" label="组员编号4" prop="sczl_bh4" width="120"/>
			  <el-table-column align="left" label="组员姓名4" prop="name4"width="120" />
			  <el-table-column align="left" label="组员编号5" prop="sczl_bh5" width="120"/>
			  <el-table-column align="left" label="组员姓名5" prop="name5" width="120"/>
			  <el-table-column align="left" label="组员编号6" prop="sczl_bh6"width="120" />
			  <el-table-column align="left" label="组员姓名6" prop="name6" width="120"/> 
			  <el-table-column align="left" label="拆片联拼系数" prop="拆片联拼系数" width="120"/>
			  <el-table-column align="left" label="拆片条小盒系数" prop="拆片条小盒系数" width="120"/>
			  <el-table-column align="left" label="工价系数" prop="sczl_工价系数" width="160"/>
			  <el-table-column align="left" label="日定额" prop="日定额" width="120"/>
			  <el-table-column align="left" label="千件工价" prop="piecesprice " width="120"/>
			  <el-table-column align="left" label="补产标准" prop="addstandards " width="120"/>
			  <el-table-column align="left" label="创建用户" prop="sys_id" 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="160"/>
			<tbody>
			  <tr v-for="row in filteredRows" :key="row.sczl_gdbh">
				<td>{{ row.sczl_gdbh }}</td>
				<td>{{ row.sczl_rq }}</td>
				<td>{{ row.sczl_bzdh }}</td>
				<td>{{ row.sczl_cl }}</td>
				<!-- 其他列 -->
			  </tr>
			</tbody>
            </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="formData" label-position="left" ref="elFormRef" :rules="rule">

              <el-row :gutter="20">
                <el-col :span="4">
                  <el-form-item label="工单编号" prop="id">
                    <el-input v-model="formData.address" :clearable="true" placeholder="2023.12.14" />
                  </el-form-item>
                </el-col>
                <el-col :span="6">
                  <el-form-item label="产品名称" prop="name">
                    <el-row :gutter="20">
                      <el-col :span="12">
                        <el-input v-model="formData.code" :clearable="true" placeholder="ZT01733" />
                      </el-col>                      
                    </el-row>
                  </el-form-item>
                </el-col>
              </el-row>

              <el-row :gutter="20">
                <el-col :span="8">
                  <el-row :gutter="20">
                    <el-col :span="14">
                      <el-form-item label="印件号" prop="id">
                        <el-input v-model="formData.address" :clearable="true" placeholder="0.00" />
                      </el-form-item>
                    </el-col>
                    <el-col :span="10">
                      <el-form-item label="印件名称" prop="id">
                        <el-input v-model="formData.address" :clearable="true" placeholder="是" />
                      </el-form-item>
                    </el-col>
                  </el-row>
                </el-col>
              </el-row>
			  
             <el-row :gutter="20">
                <el-col :span="4">
                  <el-form-item label="工序名称" prop="id">
                    <el-input v-model="formData.address" :clearable="true" placeholder="2023.12.14" />
                  </el-form-item>
                </el-col>
                <el-col :span="6">          
                    <el-row :gutter="20">
                      <el-col :span="12">
                        <el-input v-model="formData.code" :clearable="true" placeholder="ZT01733" />
                      </el-col>
                    </el-row>
                </el-col>
                <el-col :span="3">
                  <el-form-item label="工艺名称" prop="name">
                    <el-input v-model="formData.image" :clearable="true" placeholder="A班" />
                  </el-form-item>
                </el-col>
              </el-row>
			  
			  
			  <el-row :gutter="20">
			     <el-col :span="4">
			       <el-form-item label="日期" prop="id">
			         <el-input v-model="formData.address" :clearable="true" placeholder="2023.12.14" />
			       </el-form-item>
			     </el-col>
			     <el-col :span="6">          
			         <el-row :gutter="20">
			           <el-col :span="12">
						<el-form-item label="机器" prop="id">
			             <el-input v-model="formData.code" :clearable="true" placeholder="ZT01733" />
						</el-form-item>
			           </el-col>
			         </el-row>
			     </el-col>
			     <el-col :span="3">
			       <el-form-item label="组别" prop="name">
			         <el-input v-model="formData.image" :clearable="true" placeholder="A班" />
			       </el-form-item>
			     </el-col>
			   </el-row>
			  
			  <el-row :gutter="20">
			     <el-col :span="4">
			       <el-form-item label="墨色" prop="id">
			         <el-input v-model="formData.address" :clearable="true" placeholder="2023.12.14" />
			       </el-form-item>
			     </el-col>
			     <el-col :span="6">          
			         <el-row :gutter="20">
			           <el-col :span="12">
						 <el-form-item label="加工联数" prop="id">
			             <el-input v-model="formData.code" :clearable="true" placeholder="ZT01733" />
						 </el-form-item>
			           </el-col>
			         </el-row>
			     </el-col>
			     <el-col :span="3">
			       <el-form-item label="产量" prop="name">
			         <el-input v-model="formData.image" :clearable="true" placeholder="A班" />
			       </el-form-item>
			     </el-col>
				 <el-col :span="3">
				   <el-form-item label="制程废品" prop="name">
				     <el-input v-model="formData.image" :clearable="true" placeholder="A班" />
				   </el-form-item>
				 </el-col>
			   </el-row>
			   
			   
			   <el-row :gutter="20">
			      <el-col :span="4">
			        <el-form-item label="装版总工时" prop="id">
			          <el-input v-model="formData.address" :clearable="true" placeholder="2023.12.14" />
			        </el-form-item>
			      </el-col>
			      <el-col :span="6">          
			          <el-row :gutter="20">
			            <el-col :span="12">
			   						 <el-form-item label="装版补产工时" prop="id">
			              <el-input v-model="formData.code" :clearable="true" placeholder="ZT01733" />
			   						 </el-form-item>
			            </el-col>
			          </el-row>
			      </el-col>
			      <el-col :span="3">
			        <el-form-item label="保养工时" prop="name">
			          <el-input v-model="formData.image" :clearable="true" placeholder="A班" />
			        </el-form-item>
			      </el-col>
			   				 <el-col :span="3">
			   				   <el-form-item label="异常停机" prop="name">
			   				     <el-input v-model="formData.image" :clearable="true" placeholder="A班" />
			   				   </el-form-item>
			   				 </el-col>
			    </el-row>
			  
			  
			  <el-row :gutter="20">
			     <el-col :span="4">
			       <el-form-item label="打样总工时" prop="id">
			         <el-input v-model="formData.address" :clearable="true" placeholder="2023.12.14" />
			       </el-form-item>
			     </el-col>
			     <el-col :span="6">          
			         <el-row :gutter="20">
			           <el-col :span="12">
			  						 <el-form-item label="打样补产工时" prop="id">
			             <el-input v-model="formData.code" :clearable="true" placeholder="ZT01733" />
			  						 </el-form-item>
			           </el-col>
			         </el-row>
			     </el-col>
			     <el-col :span="3">
			       <el-form-item label="通电时间" prop="name">
			         <el-input v-model="formData.image" :clearable="true" placeholder="A班" />
			       </el-form-item>
			     </el-col>			  				
			   </el-row>
			  
			  
			  <el-row :gutter="20">
			     <el-col :span="4">			       
			     </el-col>
			     <el-col :span="6">          
			         <el-row :gutter="20">
			           <el-col :span="12">
			  						 <el-form-item label="拆片联拼系数" prop="id">
			             <el-input v-model="formData.code" :clearable="true" placeholder="ZT01733" />
			  						 </el-form-item>
			           </el-col>
			         </el-row>
			     </el-col>
			     <el-col :span="3">
			       <el-form-item label="拆片条小盒系数" prop="name">
			         <el-input v-model="formData.image" :clearable="true" placeholder="A班" />
			       </el-form-item>
			     </el-col>			  				 
			   </el-row>
			  
            
              <el-row :gutter="10">
				  <el-col :span="2">
				    
				  </el-col>
                <el-col :span="2">
                  <span>员工姓名1</span>
                </el-col>
                <el-col :span="2">
                  <span>员工姓名2</span>
                </el-col>
                <el-col :span="2">
                  <span>员工姓名3</span>
                </el-col>
                <el-col :span="2">
                  <span>员工姓名4</span>
                </el-col>
                <el-col :span="2">
                  <span>员工姓名5</span>
                </el-col>
				<el-col :span="2">
				  <span>员工姓名6</span>
				</el-col>
				<el-col :span="2">
				  <span>员工姓名7</span>
				</el-col>
				<el-col :span="2">
				  <span>员工姓名8</span>
				</el-col>
				<el-col :span="2">
				  <span>员工姓名9</span>
				</el-col>
				<el-col :span="2">
				  <span>特殊组员</span>
				</el-col>
              </el-row>

             <el-row :gutter="10" style="margin-top: 10px;">
				 <el-col :span="2">
				   <span>班组成员</span>
				 </el-col>
                <el-col :span="2">
                  <el-input v-model="formData.image" :clearable="true" placeholder="ZI00401" />
                </el-col>
                <el-col :span="2">
                  <el-input v-model="formData.image" :clearable="true" placeholder="瞿春生" />
                </el-col>
                <el-col :span="2">
                  <el-input v-model="formData.image" :clearable="true" placeholder="11.0" />
                </el-col>
                <el-col :span="2">
                  <el-input v-model="formData.image" :clearable="true" placeholder="打包废纸" />
                </el-col>
                <el-col :span="2">
                  <el-input v-model="formData.image" :clearable="true" placeholder="是" />
                </el-col>
				<el-col :span="2">
				  <el-input v-model="formData.image" :clearable="true" placeholder="ZI00401" />
				</el-col>
				<el-col :span="2">
				  <el-input v-model="formData.image" :clearable="true" placeholder="瞿春生" />
				</el-col>
				<el-col :span="2">
				  <el-input v-model="formData.image" :clearable="true" placeholder="11.0" />
				</el-col>
				<el-col :span="2">
				  <el-input v-model="formData.image" :clearable="true" placeholder="打包废纸" />
				</el-col>
				<el-col :span="2">
				  <el-input v-model="formData.image" :clearable="true" placeholder="是" />
				</el-col>
              </el-row>
            </el-form>
			
			<el-row :gutter="10" style="margin-top: 10px;">
				 <el-col :span="2">
				  
				 </el-col>
			   <el-col :span="2">
			     <el-input v-model="formData.image" :clearable="true" placeholder="ZI00401" />
			   </el-col>
			   <el-col :span="2">
			     <el-input v-model="formData.image" :clearable="true" placeholder="瞿春生" />
			   </el-col>
			   <el-col :span="2">
			     <el-input v-model="formData.image" :clearable="true" placeholder="11.0" />
			   </el-col>
			   <el-col :span="2">
			     <el-input v-model="formData.image" :clearable="true" placeholder="打包废纸" />
			   </el-col>
			   <el-col :span="2">
			     <el-input v-model="formData.image" :clearable="true" placeholder="是" />
			   </el-col>
				<el-col :span="2">
				  <el-input v-model="formData.image" :clearable="true" placeholder="ZI00401" />
				</el-col>
				<el-col :span="2">
				  <el-input v-model="formData.image" :clearable="true" placeholder="瞿春生" />
				</el-col>
				<el-col :span="2">
				  <el-input v-model="formData.image" :clearable="true" placeholder="11.0" />
				</el-col>
				<el-col :span="2">
				  <el-input v-model="formData.image" :clearable="true" placeholder="打包废纸" />
				</el-col>
				<el-col :span="2">
				  <el-input v-model="formData.image" :clearable="true" placeholder="是" />
				</el-col>
			 </el-row>
			 
			 <el-row :gutter="10" style="margin-top: 10px;">
				 <el-col :span="2">
				   
				 </el-col>
			    <el-col :span="2">
			      <el-input v-model="formData.image" :clearable="true" placeholder="ZI00401" />
			    </el-col>
			    <el-col :span="2">
			      <el-input v-model="formData.image" :clearable="true" placeholder="瞿春生" />
			    </el-col>
			    <el-col :span="2">
			      <el-input v-model="formData.image" :clearable="true" placeholder="11.0" />
			    </el-col>
			    <el-col :span="2">
			      <el-input v-model="formData.image" :clearable="true" placeholder="打包废纸" />
			    </el-col>
			    <el-col :span="2">
			      <el-input v-model="formData.image" :clearable="true" placeholder="是" />
			    </el-col>
				<el-col :span="2">
				  <el-input v-model="formData.image" :clearable="true" placeholder="ZI00401" />
				</el-col>
				<el-col :span="2">
				  <el-input v-model="formData.image" :clearable="true" placeholder="瞿春生" />
				</el-col>
				<el-col :span="2">
				  <el-input v-model="formData.image" :clearable="true" placeholder="11.0" />
				</el-col>
				<el-col :span="2">
				  <el-input v-model="formData.image" :clearable="true" placeholder="打包废纸" />
				</el-col>
				<el-col :span="2">
				  <el-input v-model="formData.image" :clearable="true" placeholder="是" />
				</el-col>
			  </el-row>
            
            <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-main>
      </el-container>
    </el-container>

  </div>
</template>

<script setup>
import {
  getproductionCount,
  getproductionList
} from '@/api/jixiaoguanli/jitairibaobiao'

// 全量引入格式化工具 请按需保留
import { getDictFunc, formatDate, formatBoolean, filterDict, ReturnArrImg, onDownloadFile } from '@/utils/format'
import { ElMessage, ElMessageBox } 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 getproductionCount();
	console.log(response.data)
	
	
 const transformedData = response.data.map(item => ({
     label: `${item.date.replace(/-/g, '.')}【单据数: ${item.counts}张】`,
     children: Object.keys(item.sys).map(sysItem => {
        const matchResult = sysItem.match(/\[(.*?)\]/);
        const sysLabel = matchResult ? matchResult[1] : "";
        return {
          label: `${sysLabel}【记录数: ${item.sys[sysItem]}张】`,
          params: {
        date: item.date.replace(/\./g, '-'),
        sys_id: sysItem,
        total: item.sys[sysItem],
         },
       };
     }),
   }));
   treeData.splice(0, treeData.length, ...transformedData);
   console.log(treeData);
}

getTabdata();

// 自动化生成的字典（可能为空）以及字段
const formData = ref({
  id: '',
  name: '',
  date: '',
  group: '',
  packingOutput: '',
  reworkOutput: '',
  pieceOutput: '',
  order: '',
  user: '',
  createTime: '',
  updateTime: '',
  uniqid: '',
})

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

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

// =========== 表格控制部分 ===========
const tableData = 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 page = ref(1)
const limit = ref(10)
const searchInfo = ref('')
const params = {
  date: '',
  sys_id: '',
  page: page.value.toString(),
  limit: limit.value.toString(),
}

// 分页设置
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 getproductionList(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();
 }

}

// 搜索
function onSearch() {
return this.rows.filter(row => row.sczl_gdbh.includes(this.searchInfo));
}
// ============== 表格控制部分结束 ===============

// 获取需要的字典 可能为空 按需保留
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 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 dialogFormVisible = ref(false)

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

// 关闭弹窗
const closeDialog = () => {
  dialogFormVisible.value = false
  formData.value = {
    address: '',
    image: '',
    name: '',
  }
}
// 弹窗确定
const enterDialog = async () => {
  elFormRef.value?.validate(async (valid) => {
    if (!valid) return
    let res
    switch (type.value) {
      case 'create':
        res = await createCompany(formData.value)
        break
      case 'update':
        res = await updateCompany(formData.value)
        break
      default:
        res = await createCompany(formData.value)
        break
    }
    if (res.code === 0) {
      ElMessage({
        type: 'success',
        message: '创建/更改成功'
      })
      closeDialog()
      getTableData()
    }
  })
}

// 双击表格操作
function doubleClick(row, column, event) {
  console.log(row, column, event);
  // updateCompanyFunc(row);
  type.value = 'update';
  dialogFormVisible.value = true
}

// 导出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>