<template>
  <div style="width: 100%;padding-top: 1%;" :style="{'height':heightAll+'px'}">
    <div style="display: flex;width: 100%;margin-left: 1%;justify-content: space-between;">
      <div style="display: flex;width: 35%;">
        <div style="display: flex;width: 100%;align-items: center;">
            <div>
                模型名称:
            </div>
            <el-input v-model="name" style="width:50%;margin-left: 1%;" placeholder="" />
        </div>
        <div style="display: flex;width: 100%;align-items: center;margin-left:-15%;">
            <div>
                模型归属单位:
            </div>
            <el-input v-model="mdUnit" style="width: 50%;margin-left: 1%;" placeholder="" />
        </div>
        <el-button type="primary" style="margin-left: -10%;" @click="getModelListTable" :icon="Search">查询</el-button>
      </div>
        <div style="display: flex;align-items: center;margin-right: 3%;">
            
            <el-button type="primary" style="margin-left:5%;" @click="reg" icon="Plus">注册</el-button>
        </div>
    </div>
    <div style="margin-top: 0%;margin-left: 0%;width: 100%;">
        <el-table 
        :data="tableData" 
        style="width: 98%;margin-left: 1%;margin-top: 0.5%;"
        :cell-style="{ padding:'5px' }"
        :header-cell-style="{height: heightAll*0.01+'px',}"
        :row-style="{ fontSize: '16px',textAlign:'center'}"
        border >
        <el-table-column type="index" label="序号" width="80">
          <template #default="{ $index }">
            <div style="text-align: center;">
              {{ $index + 1 }}
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="name" label="模型名称">
        </el-table-column>
        <el-table-column prop="enname" label="英文名称">
        </el-table-column>
        <el-table-column prop="className" label="模型类型" width="160"/>
        <el-table-column prop="mdUnit" label="模型单位" width="160"/>
        <el-table-column prop="mdContact" label="联系方式" width="100"/>
        <el-table-column prop="status" label="模型状态" width="140">
        </el-table-column>
        <el-table-column prop="modifyBy" label="发布时间" width="170"/>
        <el-table-column prop="version" label="版本" width="120"/>
        <el-table-column prop="address" label="操作" width="250">
            <template #default="scope">
                <div style="display: flex;justify-content: space-between;width: 100%;">
                    <el-button type="primary" @click="showEdit(scope.row)" size="mini" text style="margin-left: 0%;">编辑</el-button>
                    <!-- <el-button type="danger" text size="mini" style="margin-left: -5%;" @click="handleDelete(scope.row)">注销</el-button> -->
                    <el-button @click="showDe(scope.row)" type="primary" text size="mini" style="margin-left: 0%;">查看</el-button>
                    <el-button @click="showPei(scope.row)" type="warning" text size="mini" style="margin-left: 0%;">配置</el-button>
                    <el-button type="danger" @click="delModel(scope.row)" text size="mini" style="margin-left: 0%;">删除</el-button>
                </div>
            </template>
        </el-table-column>
      </el-table>
        <el-dialog v-model="dialogVisible" title="" width="60%" @close="clearForm" destroy-on-close>
                <div class="card-header">
                  <span style="font-size: 20px;margin-left: 1%;">基本信息</span>
                  <el-divider style="margin-top: 1%;"/>
                </div>
              <div>
                <el-form  size="mini"  style="margin-top: 0%;width: 98%;"  :model="formJi" label-position="right" ref="formRefJi" label-width="120px" :rules="rulesJi">
                  <el-row :gutter="40">
                        <el-col :span="8">
                          <el-form-item label="模型名称:" prop="name" style="">
                              <div style="display: flex;width: 120%;justify-content: space-between;">
                                <el-input  v-model="formJi.name" style="width: 100%;"/>
                              </div>
                          </el-form-item>
                        </el-col>
                        <el-col :span="8">
                          <el-form-item label="英文名:" prop="enname" style="">
                            <div style="display: flex;width: 100%;justify-content: space-between;">
                              <el-input  v-model="formJi.enname" style="width: 100%;"/>
                            </div>
                          </el-form-item>
                        </el-col>
                        <el-col :span="6">
                          <el-form-item label="版本号:" prop="" style="">
                            <div style="display: flex;width: 100%;justify-content: space-between;">
                              <el-input  v-model="formJi.version" style="width: 100%;"/>
                            </div>
                          </el-form-item>
                        </el-col>
                  </el-row>
                  <el-row :gutter="48">
                    <el-col :span="8">
                      <el-form-item label="模型类型:" prop="" style="">
                        <div style="display: flex;width: 100%;justify-content: space-between;">
                          <el-input placeholder="如水利模型、排水模型、供水模型、海洋模型" v-model="formJi.type" style="width: 100%;" resize="none"/>
                        </div>
                      </el-form-item>
                    </el-col>
                  </el-row>
                  <el-row :gutter="48">
                    <el-col :span="24">
                      <el-form-item label="开发语言:">
                          <el-radio-group v-model="formJi.devlang" class="custom-radio-group" style="width: 100%;">
                            <el-radio label="java" size="large">java</el-radio>
                            <el-radio label="nodeJs" size="large">nodeJs</el-radio>
                            <el-radio label="python" size="large">python</el-radio>
                            <el-radio label="c/c++" size="large">c/c++</el-radio>
                            <el-radio label="1" size="large">
                              <div class="custom-input-wrapper">
                                <span>其它</span>
                                <el-input 
                                  v-model="elseLan"
                                  class="underline-input"
                                  v-show="isElse"
                                />
                              </div>
                            </el-radio>
                            </el-radio-group>
                      </el-form-item>
                    </el-col>
                  </el-row>
                  <el-row :gutter="48">
                        <el-col :span="16">
                          <el-form-item label="简介:">
                              <el-input  v-model="formJi.intro" style="width: 100%;" :rows="3" resize="none" type="textarea"/>
                          </el-form-item>
                        </el-col>
                  </el-row>
                </el-form>
              </div>
            
              <div class="card-header">
                <span style="font-size: 20px;margin-left: 1%;">单位</span>
                <el-divider style="margin-top: 1%;"/>
              </div>
            <div style="margin-top: 0%;">
              <el-form size="mini" :key="tableKey" style="margin-top: 0%;width: 98%;"  :model="formJi" label-position="right"  label-width="120px" :rules="rulesJi">
                <el-row :gutter="48">
                      <el-col :span="11">
                        <el-form-item label="模型归属单位:" prop="" style="">
                            <div style="display: flex;width: 100%;justify-content: space-between;">
                              <el-input  v-model="formJi.mdUnit" style="width: 100%;"/>
                            </div>
                        </el-form-item>
                      </el-col>
                      <el-col :span="11">
                        <el-form-item label="联系方式:" prop="" style="">
                          <div style="display: flex;width: 100%;justify-content: space-between;">
                            <el-input  v-model="formJi.mdContact" style="width: 100%;"/>
                          </div>
                        </el-form-item>
                      </el-col>
                </el-row>
                <el-row :gutter="48">
                      <el-col :span="11">
                        <el-form-item label="技术支持单位:" prop="" style="">
                            <div style="display: flex;width: 100%;justify-content: space-between;">
                              <el-input  v-model="formJi.devUnit" style="width: 100%;"/>
                            </div>
                        </el-form-item>
                      </el-col>
                      <el-col :span="11">
                        <el-form-item label="联系方式:" prop="" style="">
                          <div style="display: flex;width: 100%;justify-content: space-between;">
                            <el-input  v-model="formJi.devContact" style="width: 100%;"/>
                          </div>
                        </el-form-item>
                      </el-col>
                </el-row>
              </el-form>
            </div>
            <el-tabs
            v-model="activeName"
            type="card"
            style="margin-top: 1%;"
          >
            <el-tab-pane label="部署情况" name="first">
              <el-form size="mini" :key="tableKey" style="margin-top: 0%;width: 98%;"  :model="formJi" label-position="right" label-width="120px"   :rules="rulesJi">
                <el-row :gutter="48">
                      <el-col :span="11">
                        <el-form-item label="服务器IP:" prop="" style="">
                            <div style="display: flex;width: 100%;justify-content: space-between;">
                              <el-input   v-model="formJi.deployIp" style="width: 100%;"/>
                            </div>
                        </el-form-item>
                      </el-col>
                      <el-col :span="11">
                        <el-form-item label="端口:" prop="" style="">
                          <div style="display: flex;width: 100%;justify-content: space-between;">
                            <el-input placeholder="可填写多个端口，以“,”分隔"  v-model="formJi.deployPort" style="width: 100%;"/>
                          </div>
                        </el-form-item>
                      </el-col>
                </el-row>
                <el-row :gutter="48">
                      <el-col :span="15">
                        <el-form-item label="部署位置:" prop="" style="">
                            <div style="display: flex;width: 100%;justify-content: space-between;">
                              <el-input  v-model="formJi.deployDir" style="width: 100%;"/>
                            </div>
                        </el-form-item>
                      </el-col>
                      <el-col :span="10">
                      </el-col>
                </el-row>
                <el-row :gutter="48">
                      <el-col :span="15">
                        <el-form-item label="服务访问地址:" prop="" style="">
                          <div style="display: flex;width: 100%;justify-content: space-between;">
                            <el-input  v-model="formJi.mirrorImageUrl" style="width: 100%;"/>
                          </div>
                        </el-form-item>
                      </el-col>
                </el-row>
                <el-row :gutter="48">
                      <el-col :span="15">
                        <el-form-item label="服务器运行命令:" prop="" style="">
                          <div style="display: flex;width: 100%;justify-content: space-between;">
                            <el-input  v-model="formJi.mdRunCmd" style="width: 100%;"/>
                          </div>
                        </el-form-item>
                      </el-col>
                </el-row>
              </el-form>
              <div style="display: flex;margin-top: -5%;">
                <div class="card-header" style="margin-top: 5%;display: flex;justify-content: inherit;margin-left: 2%">
                  <span style="font-size: 20px;margin-top: 5%; writing-mode: vertical-rl;position: relative;top: 15%;">运行环境</span>
                </div>
                <el-form size="mini" :key="tableKey" style="margin-top: 5%;width: 85%;"  :model="formJi" label-position="right" label-width="120px"   :rules="rulesJi">
                  <el-row :gutter="48">
                        <el-col :span="12">
                          <el-form-item label="操作系统:" prop="" style="">
                              <div style="display: flex;width: 100%;justify-content: space-between;">
                                <el-select
                                v-model="formJi.envOs"
                                
                                    style="width: 75%;margin-left: 0%;"
                                >
                                    <el-option
                                    v-for="item in optionsEnv"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value"
                                    />
                                </el-select>
                              </div>
                          </el-form-item>
                        </el-col>
                        <el-col :span="12">
                          <el-form-item label="运行架构:" prop="" style="">
                            <div style="display: flex;width: 100%;justify-content: space-between;">
                               <el-radio-group v-model="formJi.evnArmX86" class="ml-4" size="small" style="" >
                                    <el-radio label="X86" size="large">X86</el-radio>
                                    <el-radio label="ARM" size="large">ARM</el-radio>
                                </el-radio-group>
                            </div>
                          </el-form-item>
                        </el-col>
                  </el-row>
                  <el-row :gutter="24">
                        <el-col :span="8">
                          <el-form-item label="硬盘:" prop="" style="">
                              <div style="display: flex;width: 100%;" >
                                <el-input-number
                                  v-model="formJi.envDisk"
                                  :min="100"
                                  :max="2048"
                                  size="mini"
                                  controls-position="right"
                                  @change="handleChange"
                                />
                                <div style="margin-left: 4%;font-size: 15px;">
                                  G
                                </div>
                              </div>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                          <el-form-item label="CPU核数:" prop="" style="">
                            <div style="display: flex;width: 100%;" >
                                <el-input-number
                                  v-model="formJi.envCpuNum"
                                  :max="64"
                                  :min="2"
                                  size="mini"
                                  controls-position="right"
                                  @change="handleChange"
                                />
                                <div style="margin-left: 4%;font-size: 15px;">
                                  个
                                </div>
                              </div>
                          </el-form-item>
                        </el-col>
                        <el-col :span="8">
                          <el-form-item label="内存:" prop="" style="">
                            <div style="display: flex;width: 100%;" >
                                <el-input-number
                                  v-model="formJi.envMem"
                                  :max="512"
                                  :min="1"
                                  size="mini"
                                  controls-position="right"
                                  @change="handleChange"
                                />
                                <div style="margin-left: 4%;font-size: 15px;">
                                  G
                                </div>
                              </div>
                          </el-form-item>
                        </el-col>
                  </el-row>
                  <el-row :gutter="24">
                        <el-col :span="8">
                          <el-form-item label="GPU型号:" prop="" style="">
                              <div style="display: flex;width: 100%;">
                                <el-input   v-model="formJi.envGpuType" style="width: 100%;"/>
                              </div>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                          <el-form-item label="GPU数量:" prop="" style="">
                            <div style="display: flex;width: 100%;" >
                               <el-input-number
                                  v-model="formJi.envGpuNum"
                                  :min="1"
                                  :max="64"
                                  size="mini"
                                  controls-position="right"
                                  @change="handleChange"
                                />
                                <div style="margin-left: 4%;font-size: 15px;">
                                  个
                                </div>
                              </div>
                          </el-form-item>
                        </el-col>
                        <el-col :span="8">
                          <el-form-item label="GUP显存:" prop="" style="">
                            <div style="display: flex;width: 100%;" >
                                <el-input-number
                                  v-model="formJi.envGpuMem"
                                  :min="1"
                                  size="mini"
                                  :max="512"
                                  controls-position="right"
                                  @change="handleChange"
                                />
                                <div style="margin-left: 4%;font-size: 15px;">
                                  G
                                </div>
                              </div>
                          </el-form-item>
                        </el-col>
                  </el-row>
                </el-form>
              </div>
            </el-tab-pane>
            <el-tab-pane label="输入" name="second">
              <el-form style="margin-left: 5%;margin-top: 2%;" label-position="right" label-width="120px" :model="formZu" class="demo-form-inline" ref="formRefZu" :rules="rulesZu">
                <el-form-item label="输入文档:" prop="">
                    <div style="width: 75%;">
                      <el-upload
                          ref="uploadRef"
                          :limit="1"
                          accept=".xlsx, .xls"
                          :headers="upload.headers"
                          :on-change="handleChange"
                          :file-list="fileList"
                          :action="upload.url + '?file=' + upload.updateSupport"
                          :on-progress="handleFileUploadProgress"
                          :on-success="handleFileSuccess"
                          :auto-upload="false"
                          drag
                      >
                          <el-icon class="el-icon--upload"><upload-filled /></el-icon>
                          <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
                      </el-upload>
                    </div>
                    <div style="color: #b1b3b8;width: 100%;">
                      注:请上传后缀名为.docx .pdf .txt的文件
                    </div>
                    <el-link type="primary" @click="downIn">{{formJi.mdInName}}</el-link>
                  </el-form-item>
                  <el-form-item label="说明:" prop="" style="margin-left: -1%;">
                    <el-input v-model="formJi.mdInNote" style="width: 75%;" placeholder="请输入组件执行路径" :rows="2" type="textarea" resize="none"/>
                  </el-form-item>
                </el-form>
            </el-tab-pane>
            <el-tab-pane label="输出" name="third">
              <el-form  style="margin-left: 5%;margin-top: 2%;" label-position="right" label-width="120px" :model="formZu" class="demo-form-inline" ref="formRefZu" :rules="rulesZu">
                <el-form-item label="输出文档:" prop="">
                    <div style="width: 75%;">
                      <el-upload
                          ref="uploadRef1"
                          :limit="1"
                          accept=".xlsx, .xls"
                          :headers="upload.headers"
                          :on-change="handleChange1"
                          :file-list="fileList1"
                          :action="upload.url + '?file=' + upload.updateSupport"
                          :on-progress="handleFileUploadProgress"
                          :on-success="handleFileSuccess1"
                          :auto-upload="false"
                          drag
                      >
                          <el-icon class="el-icon--upload"><upload-filled /></el-icon>
                          <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
                      </el-upload>
                    </div>
                    <div style="color: #b1b3b8;width: 100%;">
                      注:请上传后缀名为.docx .pdf .txt的文件
                    </div>
                    <el-link type="primary" @click="downOut">{{formJi.mdOutName}}</el-link>
                  </el-form-item>
                  <el-form-item label="说明:" prop="" style="margin-left: -1%;">
                    <el-input v-model="formJi.mdOutNote" style="width: 75%;" placeholder="请输入组件执行路径" :rows="2" type="textarea" resize="none"/>
                  </el-form-item>
                </el-form>
            </el-tab-pane>
          </el-tabs>
            <template #footer>
            <span class="dialog-footer">
                <el-button @click="dialogVisible = false">取消</el-button>
                <el-button type="primary" @click="submit" v-if="!isEdit">
                  提交
                </el-button>
                <el-button type="primary" @click="subEdit" v-if="isEdit">
                  提交
                </el-button>
            </span>
            </template>
        </el-dialog>
        <el-dialog  v-model="dialogVisibleDe" title="" width="50%" @close="" destroy-on-close class="custom-dialog-bg">
          <el-descriptions title="基本信息" :column="3" style="margin-top: 0%;margin-left: 1%;background: transparent;">
            <el-descriptions-item label="模型名称:">{{formJi.name}}</el-descriptions-item>
            <el-descriptions-item label="英文名:">{{formJi.enname}}</el-descriptions-item>
            <el-descriptions-item label="版本号:">{{formJi.version}}</el-descriptions-item>
            <el-descriptions-item label="接口分类:">{{formJi.type}}</el-descriptions-item>
            <el-descriptions-item label="开发语言:"  span="2">{{formJi.devlang}}</el-descriptions-item>
            <el-descriptions-item label="简介:" span="3">{{formJi.intro}}</el-descriptions-item>
          </el-descriptions>
          <el-divider style="margin-top: 0%;"/>
          <el-descriptions title="单位" :column="2" style="margin-top: 1%;margin-left: 1%;background-color: transparent;">
            <el-descriptions-item label="模型归属单位:">{{formJi.mdUnit}}</el-descriptions-item>
            <el-descriptions-item label="联系方式:">{{formJi.mdContact}}</el-descriptions-item>
            <el-descriptions-item label="技术支持单位:">{{formJi.devUnit}}</el-descriptions-item>
            <el-descriptions-item label="联系方式:">{{formJi.devContact}}</el-descriptions-item>
          </el-descriptions>
          <el-tabs
            v-model="activeName"
            type="card"
            style="margin-top: 1%;background-color: transparent;"
          >
            <el-tab-pane label="部署情况" name="first" style="background-color: transparent;">
              <el-descriptions title="" :column="3" style="margin-top: 0%;margin-left: 1%;background-color: transparent;">
                <el-descriptions-item label="服务器IP:" span="2">{{formJi.deployIp}}</el-descriptions-item>
                <el-descriptions-item label="端口:">{{formJi.deployPort}}</el-descriptions-item>
                <el-descriptions-item label="部署位置:" span="2">{{formJi.deployDir}}</el-descriptions-item>
                <el-descriptions-item label="服务访问地址:">{{formJi.mirrorImageUrl}}</el-descriptions-item>
                <el-descriptions-item label="服务器运行命令:" span="3">{{formJi.mdRunCmd}}</el-descriptions-item>
                <el-descriptions-item label="操作系统:" span="2">{{formJi.envOs}}</el-descriptions-item>
                <el-descriptions-item label="运行架构:" span="3">{{formJi.evnArmX86}}</el-descriptions-item>
                <el-descriptions-item label="硬盘:" span="">
                  {{formJi.envDisk + 'G'}}
                </el-descriptions-item>
                <el-descriptions-item label="CPU核心数:">
                  {{formJi.envCpuNum + '个'}}
                </el-descriptions-item>
                <el-descriptions-item label="内存:">
                  {{formJi.envMem + 'G'}}
                </el-descriptions-item>
                <el-descriptions-item label="GPU型号:">{{formJi.envGpuType}}</el-descriptions-item>
                <el-descriptions-item label="GPU数量:">
                  {{formJi.envGpuNum + '个'}}
                </el-descriptions-item>
                <el-descriptions-item label="GUP显存:">
                  {{formJi.envGpuMem + 'G'}}
                </el-descriptions-item>
              </el-descriptions>
            </el-tab-pane>
            <el-tab-pane label="输入" name="second">
              <el-descriptions title="" :column="2" style="margin-top: 0%;margin-left: 1%;">
                <el-descriptions-item label="输入文档:" span="2">
                  <el-link type="primary"  @click="downIn">{{formJi.mdInName}}</el-link>
                </el-descriptions-item>
                <el-descriptions-item label="说明:">{{formJi.mdInNote}}</el-descriptions-item>
              </el-descriptions>
            </el-tab-pane>
            <el-tab-pane label="输出" name="third">
              <el-descriptions title="" :column="2" style="margin-top: 0%;margin-left: 1%;">
                <el-descriptions-item label="输出文档:" span="2">
                  <el-link type="primary" @click="downOut">{{formJi.mdOutName}}</el-link>
                </el-descriptions-item>
                <el-descriptions-item label="说明:">{{formJi.mdOutNote}}</el-descriptions-item>
              </el-descriptions>
            </el-tab-pane>
          </el-tabs>
        </el-dialog>
        <el-dialog  @close="clearForm" v-model="dialogVisiblePei" width="70%" title="参数配置">
          <el-tabs v-model="activeName" type="border-card">
            <el-tab-pane label="基本信息" name="first">
              <el-descriptions title="" :column="3" style="margin-top: 0%;margin-left: 1%;background: transparent;">
                <el-descriptions-item label="模型名称:">{{formJi.name}}</el-descriptions-item>
                <el-descriptions-item label="英文名:">{{formJi.enname}}</el-descriptions-item>
                <el-descriptions-item label="版本号:">{{formJi.version}}</el-descriptions-item>
                <el-descriptions-item label="接口分类:">{{formJi.type}}</el-descriptions-item>
                <el-descriptions-item label="开发语言:"  span="2">{{formJi.devlang}}</el-descriptions-item>
                <el-descriptions-item label="简介:" span="3">{{formJi.intro}}</el-descriptions-item>
              </el-descriptions>
              <el-divider style="margin-top: 0%;"/>
              <el-descriptions title="" :column="2" style="margin-top: 1%;margin-left: 1%;background-color: transparent;">
                <el-descriptions-item label="模型归属单位:">{{formJi.mdUnit}}</el-descriptions-item>
                <el-descriptions-item label="联系方式:">{{formJi.mdContact}}</el-descriptions-item>
                <el-descriptions-item label="技术支持单位:">{{formJi.devUnit}}</el-descriptions-item>
                <el-descriptions-item label="联系方式:">{{formJi.devContact}}</el-descriptions-item>
              </el-descriptions>
            </el-tab-pane>
            <el-tab-pane label="模型参数" style="height: 50vh;">
              <div style="display: flex;justify-content: space-between;margin-right: 2%;align-items: center;">
                <div style="display: flex;align-items: center;">
                  <el-checkbox v-model="checked1" label="参数是否分组" size="large"  />
                  <el-button  @click="addCan" style="margin-left: 10%;" type="success" size="mini" plain v-if="checked1">新增分组</el-button>
                </div>
                <div style="display: flex;justify-content: flex-end;margin-right: 1%;">
                  <el-button  @click="addCan" style="margin-left: 5%;" type="success" size="mini" plain>新增参数</el-button>
                  <el-button  @click="delAllCan" style="margin-top: 0%;" type="danger" size="mini" plain>删除</el-button>
                </div>
              </div>
              <div style="display: flex;">
              <div v-show="checked1" style="flex:1;margin-top:1%;width: 10%;background-color: #F2F6FC;height:45vh;">
               <el-tree   :expand-on-click-node="false" ref="treeRef" :filter-node-method="filterNode" :current-node-key="currentNodeKey" class="treeLeft" :data="groupTreeData" @node-click="handleNodeClick" node-key="id" style="margin-top: 10%;background-color: transparent;" default-expand-all :key="valueKet">
                  
              </el-tree>
              </div>
              <div style="width: 90%;flex: 1;">
                <el-table 
              style="margin-top: 1%;width: 100%;margin-left: 1%;"
              :data="tableDataCan" 
              :cell-style="{ textAlign: 'center',padding:'3px 0px' }"
              :header-cell-style="{ textAlign: 'center', }"
              :row-style="{ height: heightAll*0.01+'px',fontSize: '16px',textAlign:'center'  }"
              border >
                  <el-table-column prop="parName" label="*参数英文名">
                    <template #default="scope" style="width: 120%;">
                        <el-input  v-model="scope.row.parEnname" style="width: 120%;margin-left: -10%;"/>
                    </template>
                  </el-table-column>
                  <el-table-column prop="parName" label="*参数名称">
                    <template #default="scope">
                        <el-input  v-model="scope.row.parName" style="width: 120%;margin-left: -10%;"/>
                    </template>
                  </el-table-column>
                  <el-table-column prop="parType" label="*参数类型" >
                    <template #default="scope">
                        <el-input  v-model="scope.row.parType" style="width: 120%;margin-left: -10%;"/>
                    </template>
                  </el-table-column>
                  <el-table-column prop="parLine" label="行号">
                    <template #default="scope">
                        <el-input  v-model="scope.row.parLine" style="width: 120%;margin-left: -10%;"/>
                    </template>
                  </el-table-column>
                  <el-table-column prop="parNote" label="维度">
                    <template #default="scope">
                        <el-input  v-model="scope.row.parDimen" style="width: 120%;margin-left: -10%;"/>
                    </template>
                  </el-table-column>
                  <el-table-column prop="parNote" label="表达式">
                    <template #default="scope">
                        <el-input  v-model="scope.row.parExpr" style="width: 120%;margin-left: -10%;"/>
                    </template>
                  </el-table-column>
                  <el-table-column prop="parNote" label="*默认值">
                    <template #default="scope">
                        <el-input  v-model="scope.row.parDefVal" style="width: 120%;margin-left: -10%;"/>
                    </template>
                  </el-table-column>
                  <el-table-column prop="parNote" label="参数范围">
                    <template #default="scope">
                        <el-input  v-model="scope.row.parRange" style="width: 120%;margin-left: -10%;"/>
                    </template>
                  </el-table-column>
                  <el-table-column prop="parNote" label="版本号">
                    <template #default="scope">
                        <el-input  v-model="scope.row.parVersion" style="width: 120%;margin-left: -10%;"/>
                    </template> 
                  </el-table-column>
                  <el-table-column prop="parNote" label="操作" width="85">
                    <template #default="scope">
                        <el-button type="danger" @click="delCan(scope.$index)" text size="mini" style="margin-left: 0%;">删除</el-button>
                    </template> 
                  </el-table-column>
              </el-table>
              </div>
              </div>
            </el-tab-pane>
            <el-tab-pane label="模型状态">Role</el-tab-pane>
            <el-tab-pane label="Task">Task</el-tab-pane>
          </el-tabs>
          <template #footer>
          <span class="dialog-footer">
              <el-button @click="dialogVisiblePei = false">取消</el-button>
              <el-button type="primary" @click="saveChangePar">
                提交
              </el-button>
          </span>
          </template>
        </el-dialog >
    </div>
  </div>
</template>
<script   setup>
import { getModelList,addModel,delMdid,getModelDetail,updateModel,modelFile,getParamsList,changePar,delAllPar,getModelParList } from "@/api/register/regCom";
import { ref, onMounted, onUnmounted, nextTick } from 'vue';
import { Search } from '@element-plus/icons-vue'
import {
  ArrowLeft,
  Plus
} from '@element-plus/icons-vue'
import { reactive } from 'vue'
import { forwardRefProps } from 'element-plus/es/components/tooltip-v2/src/forward-ref.mjs';
import { getToken } from "@/utils/auth";
import { fa } from "element-plus/es/locales.mjs";
import { column } from "element-plus/es/components/table-v2/src/common.mjs";
import { TRUE } from "sass";
const { proxy } = getCurrentInstance();
const dragTableRef = ref()
const dialogVisible = ref(false)
const dialogVisibleDe = ref(false)
const dialogVisiblePei = ref(false)
const active = ref(0)
const isEdit = ref(true)
const name = ref('')
const isAdd = ref(true)
const mdUnit = ref('')
const isElse = ref(false)
const elseLan = ref('')
const tableDataCan = ref([])
const groupTreeData = ref([])
const formJi = ref({
  name:'',
  version:'',
  enname:'',
  devlang:'',
  intro:'',
  type:'',
  mdContact:'',
  mdUnit:'',
  devUnit:'',
  devContact:'',
  deployDir:'',
  deployIp:'',
  deployPort:'',
  mirrorImageUrl:'',
  mdRunCmd:'',
  envOs:'',
  envDisk:'',
  envGpuMem:'11',
  evnArmX86:'',
  envCpuNum:'',
  envGpuType:'',
  envGpuNum:'2',
  envMem:'',
  mdInNote:'',
  mdOutNote:''
});
const rulesJi = reactive({
  name: [{ required: true, message: '必填', trigger: 'blur' }],
  enname: [{ required: true, message: '必填', trigger: 'blur' }],
});
const formRefJi = ref();

const formZu = ref({
  mirrorImageEurl:'',
  mdCPU:'',
  mdGPU:''
});
const rulesZu = reactive({
  mirrorImageEurl: [{ required: true, message: '必填', trigger: 'blur' }],
  mdCPU: [{ required: true, message: '必填', trigger: 'blur' }],
});
const formRefZu = ref();
const activeName = ref('first')

const upload = reactive({
  // 是否显示弹出层（用户导入）
  open: false,
  // 弹出层标题（用户导入）
  title: "",
  // 是否禁用上传
  isUploading: false,
  // 是否更新已经存在的用户数据
  updateSupport: '',
  // 设置上传的请求头部
  headers: { Authorization: "Bearer " + getToken() },
  // 上传的地址
  url: import.meta.env.VITE_APP_BASE_API + "/common/upload"
});
const downUrl = ref(import.meta.env.VITE_APP_BASE_API)
const tableKey = ref(0);
const totalComReg = ref()
const currentPage = ref(1)
const tableData2 = ref([ 
  { date1:'流域拓扑', date2:'', date3:'single', date4:'基于水文响应' },
  { date1:'雨量站', date2:'', date3:'single', date4:'基于水文响应' },
  { date1:'水库', date2:'', date3:'single', date4:'基于水文响应' }
]);
const tableData3 = ref([
  { date1:'流域拓扑', date2:'', date3:'single', date4:'基于水文响应' },
  { date1:'水库', date2:'', date3:'single', date4:'基于水文响应' },
  { date1:'雨量站', date2:'', date3:'single', date4:'基于水文响应' }
]);
const checked1 = ref(false)
const tableData1= [{date1:'初始状态',
  date2:'sts',
  date3:'数据项',
  date4:'初始状态',
  date5:'是',
  date6:'否',
  date7:'2023-09-08'
}]
const checkGroup = [
    {label:'水文预报'},
    {label:'维水动力'},
    {label:'二维水动力'},
    {label:'机器学习'},
]
let tableData = ref([{name:'1'}])
const heightAll = window.innerHeight
const valueHelpSel = '';
const tableheight = window.innerHeight*0.8
const optionsType = [
  {
    value: '1',
    label: '水利专业模型',
  },
  {
    value: '2',
    label: '排水专业模型',
  },
  {
    value: '3',
    label: '供水专业模型',
  },
  {
    value: '4',
    label: '海洋专业模型',
  },
]
const optionsEnv = ref([
  {
    value: 'windwos',
    label: 'windwos',
  },
  {
    value: 'Linux',
    label: 'Linux',
  },
  {
    value: 'Ubuntu',
    label: 'Ubuntu',
  },
  {
    value: 'CentOS',
    label: 'CentOS',
  },
  {
    value: 'Debian',
    label: 'Debian',
  },
  {
    value: 'RedHat',
    label: 'RedHat',
  },
  {
    value: '统信',
    label: '统信',
  },
  {
    value: '麒麟',
    label: '麒麟',
  },
  {
    value: '欧拉',
    label: '欧拉',
  },
])
const uploadRef = ref(null);
const fileList = ref([]);
const fileList1 = ref([]);
const parForm = ref('')
onMounted(() => {
  getModelListTable()
  // addNewModel()
});
const handleChange = (file, files) => {
  fileList.value = files;
};
const handleChange1 = (file, files) => {
  fileList1.value = files;
};
function delAllCan(){
  
  proxy.$modal.confirm('是否确认删除所有参数？').then(function () {
    return delAllPar(parForm.value.mdid);
  }).then(() => {
    tableDataCan.value = []
    proxy.$modal.msgSuccess("删除成功");
  }).catch(() => {});
}
function saveChangePar(){
  tableDataCan.value.forEach((item, index, array) => { 
      item.mdid = parForm.value.mdid
      item.parGroup = 'def'
      item.parCate = 'int'
  })
  changePar(tableDataCan.value).then(res=>{
    if(res.code===200){
      proxy.$modal.msgSuccess("修改成功");
      dialogVisiblePei.value = false
      getModelListTable()
    }
  })
}
async function showPei(row){
  dialogVisiblePei.value = true
  var par = {
    mdid:row.mdid
  }
  await getModelParList(par).then(res=>{
    groupTreeData.value = res.data
    groupTreeData.value.forEach((item, index, array) => { 
      item.label = item.parGroupName
      item.value = item.parGroupCode
    })
  })
  await getModelDetail(row.mdid).then(res=>{
    parForm.value = res.data
    formJi.value = res.data
  })
  
  await getParamsList(par).then(res=>{
    tableDataCan.value = res.data
  }) 
  
}
function delCan(index){
  tableDataCan.value.splice(index, 1)
}
function showDe(row){
  dialogVisibleDe.value = true
  getModelDetail(row.mdid).then(res=>{
    parForm.value = res.data
    formJi.value = res.data
    if(formJi.value.devlang!=='java'&&formJi.value.devlang!=='nodeJs'&&formJi.value.devlang!=='python'&&formJi.value.devlang!=='c/c++'){
      isElse.value = true
      formJi.value.devlang = 1
    }
  })
}
function addCan(){
  tableDataCan.value.push({
    mdid:parForm.value.mdid
  })
}
function downOut(){
  var url = window.location.host + formJi.value.mdOutFile
  console.log(url)
  const link = document.createElement('a');
  link.href = 'http://' + url.toString();
  link.download = formJi.value.mdOutName; // 自定义文件名（可选）
  document.body.appendChild(link);
  link.click();
  document.body.removeChild(link);
}
function downIn(){
  var url = window.location.host + formJi.value.mdInFile
  console.log(url)
  const link = document.createElement('a');
  link.href = 'http://' + url.toString();
  link.download = formJi.value.mdInName; // 自定义文件名（可选）
  document.body.appendChild(link);
  link.click();
  document.body.removeChild(link);
}
function delModel(row){
  proxy.$modal.confirm('是否确认删除？').then(function () {
    return delMdid(row.mdid);
  }).then(() => {
    getModelListTable();
    proxy.$modal.msgSuccess("删除成功");
  }).catch(() => {});
}
async function showEdit(row){
  dialogVisible.value = true
  isEdit.value = true
  await nextTick()
  getModelDetail(row.mdid).then(res=>{
    formJi.value = res.data
    if(formJi.value.devlang!=='java'&&formJi.value.devlang!=='nodeJs'&&formJi.value.devlang!=='python'&&formJi.value.devlang!=='c/c++'){
      console.log(formJi.value.devlang)
      isElse.value = true
      formJi.value.devlang = '1'
    }
  })
}
async function subEdit(){
  if(fileList.value.length>0&&fileList1.value.length===0){
    await proxy.$refs["uploadRef"].submit();
  }
  else if(fileList.value.length>0&&fileList.value.length===0){
    await proxy.$refs["uploadRef1"].submit();
  }
  else if(fileList.value.length>0&&fileList.value.length>0){
    await proxy.$refs["uploadRef1"].submit();
    await proxy.$refs["uploadRef"].submit();
  }
  else{
    await formRefJi.value.validate((valid) => {
      if(valid){
        if(formJi.value.devlang==='1'){
          formJi.value.devlang = elseLan.value
        }
          updateModel(formJi.value).then(res=>{
          if(res.code===200){
            proxy.$modal.msgSuccess("修改成功");
            dialogVisible.value = false
            getModelListTable()
          }
        })
      }
    });
  }
}
async function submit(){
  formRefJi.value.validate((valid) => {
    console.log(formJi.value,valid)
    if(valid){
        if(formJi.value.devlang==='1'){
          formJi.value.devlang = elseLan.value
        }
        addModel(formJi.value).then(res=>{
        if(res.code===200){
          proxy.$modal.msgSuccess("新增成功");
          dialogVisible.value = false
          getModelListTable()
        }
      })
    }
  })
}
async function handleFileSuccess1(response, file, fileList){
  formJi.value.mdOutFile = response.originalFilename
  formJi.value.mdOutName = response.fileName
  await formRefJi.value.validate((valid) => {
    if(valid){
        if(formJi.value.devlang==='1'){
          formJi.value.devlang = elseLan.value
        }
        updateModel(formJi.value).then(res=>{
        if(res.code===200){
          proxy.$modal.msgSuccess("修改成功");
          dialogVisible.value = false
          getModelListTable()
        }
      })
    }
  });
};
async function handleFileSuccess(response, file, fileList){
  formJi.value.mdInFile = response.originalFilename
  formJi.value.mdInName = response.fileName
  await formRefJi.value.validate((valid) => {
    if(valid){
        if(formJi.value.devlang==='1'){
          formJi.value.devlang = elseLan.value
        }
        updateModel(formJi.value).then(res=>{
        if(res.code===200){
          proxy.$modal.msgSuccess("修改成功");
          dialogVisible.value = false
          getModelListTable()
        }
      })
    }
  });
};
function clearForm(){
  tableDataCan.value = []
  activeName.value = 'first'
  fileList.value = []
  fileList1.value = []
  formJi.value = {
    name:'',
    version:'',
    enname:'',
    devlang:'',
    intro:'',
    type:'',
    mdContact:'',
    mdUnit:'',
    devUnit:'',
    devContact:'',
    deployDir:'',
    deployIp:'',
    deployPort:'',
    mirrorImageUrl:'',
    mdRunCmd:'',
    envOs:'',
    envDisk:'',
    envGpuMem:'',
    evnArmX86:'',
    envCpuNum:'',
    envGpuType:'',
    envGpuNum:'',
    envMem:'',
    mdInNote:'',
    mdOutNote:''
  }
}
function reg(){
  isEdit.value = false
  dialogVisible.value = true
}
function getModelListTable(){
  tableData.value = []
  var par = {
    pageNum:1,
    pageSize:20,
    name:name.value,
    mdUnit:mdUnit.value
  }
  getModelList(par).then(res=>{
    tableData.value = res.rows
    totalComReg.value = res.total
    console.log(tableData)
  })
}
const seledMo = ['primary','plain','plain','plain','plain','plain','plain']

</script>
<style scoped>
:deep(.treeLeft) .el-tree-node__content {
  display: flex !important;
  height: 28px;                  /* 按设计稿调整高度 */
  align-items: center;
  padding-top: 0 !important;
}
:deep(.treeLeft) .el-tree-node__content:hover {
  background-color: #e9e9eb;
}
:deep(.treeLeft) .el-tree-node__content:active {
    background-color: rgka(69,157,255,0.1) !important;
  }

  /* 选中态（Active） */
:deep(.treeLeft) .el-tree-node.is-current > .el-tree-node__content {
    background-color: #c6e2ff !important;
  }

.tabs-wrapper {
  position: relative; /* 确保内容层在伪元素上方 */
  z-index: 1; /* 关键：高于背景图 */
}

.tabs-wrapper :deep(.el-tabs),
.tabs-wrapper :deep(.el-tabs__content) {
  background-color: red !important; 
}
:deep(.el-tabs){
  background-color: transparent !important;
}
:deep(.el-tabs__content){
  background-color: transparent !important; 
}
:deep(.custom-dialog-bg) {
  z-index: 1000;
  background-image: url('@/assets/images/backDia.jpg') !important; 
  background-position-x: left;
  background-position-y: bottom;
  background-size: initial;
  background-repeat: repeat-x;
  background-attachment: initial;
  background-origin: initial;
  background-clip: initial;
  background-color: rgb(255, 255, 255);
}
:deep(.custom-dialog-bg .el-dialog__header) {
  
}
:deep(.custom-dialog-bg .el-dialog__body) {
  
  color: #ecf0f1 !important; ; /* 内容文字颜色 */
}
/* 横向排列单选框标签和输入框 */
.custom-input-wrapper {
  display: flex;
  align-items: center;
  gap: 10px; /* 调整间距 */
}

/* 输入框仅显示底部横线 */
.underline-input :deep(.el-input__wrapper) {
  padding: 0;
  box-shadow: none !important;
  border-bottom: 1px solid #dcdfe6; /* 横线颜色 */
  border-radius: 0;
  background: transparent;
}
.underline-input :deep(.el-input__inner) {
  height: 24px;
  padding: 0 5px;
}
:deep(.el-table__body tr:hover > td) {
  background-color: #eaf7ff !important;
}
.drag-handle {
  cursor: move;
}

.ghost {
  opacity: 0.5;
  background: #c8ebfb;
}

/* 防止文字选中 */
:deep(.el-table__row) {
  user-select: none;
  -webkit-user-select: none;
}
</style>
<style scoped lang="scss">


.el-table .el-table__row td {
  height: 60px !important; /* 行高 */
}
.custom-tree-node {
  display: flex;       /* 启用 Flex 布局 */
  align-items: center; /* 垂直居中 */
  gap: 8px;            /* 图标与文字间距 */
}
</style>