zck 8 месяцев назад
Родитель
Сommit
512c810446

+ 603 - 922
src/view/performance/QualityAssessment/SemiFinishedRework.vue

@@ -1,939 +1,620 @@
 <template>
-    <div>
-      <!-- 左侧树形结构 -->
-      <el-container>
-        <layout-sider :resize-directions="['right']" :width="220" style="margin-right: 10px;" >
-           <div class="JKWTree-tree" style="height: 70vh;">
-             <h3>服装半成品返工维护</h3>
-             <el-tree :data="treeData" highlight-current @node-click="handleNodeClick"/>
-           </div>
-         </layout-sider>
-      <el-container>
-            
-          <el-main>
-            <!-- 按钮区域 -->
-            <div class="gva-table-box">
-              <el-form-item>
-                <el-input v-model="positionvalue" @keydown="keydown_onSearch($event)" placeholder="输入工单编号或产品名称" style="width: 180px;" />
-                <el-button type="primary" class="search" icon="search" @click="onSearch"></el-button>
-                <el-button type="primary" class="bt" icon="plus" @click="onAdd">新增</el-button>
-                <el-button type="primary" class="bt" icon="delete" @click="Del">删除</el-button>
-                <div style="margin-left: auto;">
-                  <el-button type="primary" :icon="Download" @click="exportExcel">导出到Excel</el-button>
-                </div>
-              </el-form-item>
-              <!-- 数据展示 -->
-              <el-table ref="multipleTable" style="width: 100%;height: 70vh;" tooltip-effect="dark" :data="tableData" row-key="ID"
-                highlight-current-row="true"   border @selection-change="handleSelectionChange" 
-                :row-style="{ height: '20px' }"  :header-cell-style="{ padding: '0px' }"
-                :cell-style="{ padding: '0px' }" :header-row-style="{ height: '20px' }"
-                :show-overflow-tooltip="true" @row-click="Click" @row-dblclick="doubleClick">
-                <el-table-column type="selection" width="55" />
-                <!-- 循环渲染列 -->
-                  <el-table-column
-                    v-for=" column in tableColumns "
-                    :key="column.prop"
-                    :prop="column.prop"
-                    :label="column.label"
-                    :width="column.width"
-                    sortable
-                    show-overflow-tooltip="true"/>
-              </el-table>
-              <!-- 分页 -->
-              <div class="gva-pagination">
-                <el-pagination layout="total, sizes, prev, pager, next, jumper" v-model:current-page="page"
-                  v-model:page-size="limit"
-                  :page-sizes="[10, 30, 50, 100]" :total="total" @current-change="handleCurrentChange"
-                  @size-change="handleSizeChange" />
+  <div>
+    <!-- 左侧树形结构 -->
+    <el-container>
+      <layout-sider :resize-directions="['right']" :width="220" style="margin-right: 10px;" >
+         <div class="JKWTree-tree" style="height: 70vh;">
+           <h3>服装半成品返工维护</h3>
+           <el-tree :data="treeData" highlight-current @node-click="handleNodeClick"/>
+         </div>
+       </layout-sider>
+    <el-container>
+          
+        <el-main>
+          <!-- 按钮区域 -->
+          <div class="gva-table-box">
+            <el-form-item>
+              <el-input v-model="searchinfo" @keydown="keydown_onSearch($event)" placeholder="输入工单编号或产品名称" style="width: 180px;" />
+              <el-button type="primary" class="search" icon="search" @click="onSearch"></el-button>
+              <el-button type="primary" class="bt" icon="plus" @click="onAdd">新增返工</el-button>
+              <el-button type="primary" class="bt" icon="delete" @click="Del">删除</el-button>
+              <div style="margin-left: auto;">
+                <el-button type="primary" :icon="Download" @click="exportExcel">导出到Excel</el-button>
               </div>
-            </div>
-            <!-- 弹出框 -->
-            <el-dialog v-model="dialogFormVisible" :before-close="closeDialog" :title="type === 'create' ? '服装半成品返工报工页面' : '服装半成品返工报工修改'"
-              destroy-on-close style="width: 90%; height: 90%; margin-top: 3%;">
-              
-              <el-form :model="formData" label-position="right" ref="elFormRef" :rules="rule" label-width="70px" >
-                <el-row :gutter="24">
-                  <el-col :span="6">
-                    <el-form-item label="日期" prop="name">
-                        <el-input type="date" max="9999-12-31" v-model="formData.sczl_rq" id="日期" @focus="rqHandleFocus()" @keydown="ent1($event)"  style="width: 120px; " />
-                    </el-form-item>
-                  </el-col>
-                </el-row>
-                <el-row :gutter="24">
-                    <div style="width: 100%; margin-left: 20px;">
-                        <div style="margin-bottom: 5px;">
-                            <span style="display: inline-block; text-align: center; width: 220px; margin-right: 5px;" >订单编号|款号</span>
-							<span style="display: inline-block; text-align: center; width: 110px; margin-left: 45px; margin-right: 5px;" >款式</span>
-							<span style="display: inline-block; text-align: center; width: 110px; margin-left: 45px; margin-right: 5px;" >颜色</span>
-							<span style="display: inline-block; text-align: center; width: 110px; margin-left: 45px; margin-right: 5px;" >尺码</span>
-                            <!-- <span style="display: inline-block; text-align: center; width: 110px; margin-left: 45px; margin-right: 5px;" >返工工序</span> -->
-                            <span style="display: inline-block; text-align: center; width: 95px;  margin-left: 10px; margin-right: 5px;" >返工数量</span>
-                            <span style="display: inline-block; text-align: center; width: 130px; margin-right: 5px;" >返工车缝小组</span>
-							<span style="display: inline-block; text-align: center; width: 130px; margin-right: 5px;" >返工问题</span>
-							<span style="display: inline-block; text-align: center; width: 130px; margin-right: 5px;" >备注</span>
-                        </div>
-                      <div v-for="index in 6" :key="index">
-                        <el-input style="width: 220px; margin-left: 75px; margin-right: 5px;margin-bottom: 5px;" placeholder="Enter回车" v-model="formData['sczl_gdbh' + index]" :id="'sczl_gdbh' + index" @keydown="ent1($event, index.toString())" @blur="getGxMcsubmit($event, index.toString())" />
-						<el-select v-model="formData['sczl_fggx' + index]" style="width: 100px;  margin-right: 5px;margin-bottom: 5px;" placeholder="请选择">
-                          <el-option label="手工" value="手工"/>
-                          <el-option label="大烫" value="大烫"/> 
-                          <el-option label="总检" value="总检"/>
-                          <el-option label="包装" value="包装"/>
-                        </el-select>
-                        <el-input style="width: 95px; margin-right: 5px;margin-bottom: 5px;" :readonly="true" v-model="formData['sczl_gxmc' + index]" :id="'sczl_gxmc' + index" @keydown="ent1($event)"/>
-                        <el-input style="width: 130px; margin-right: 5px;margin-bottom: 5px;" :readonly="true" v-model="formData['Gd_cpmc' + index]" :id="'Gd_cpmc' + index" @keydown="ent1($event)"/>
-                        <el-input style="width: 130px; margin-right: 5px;margin-bottom: 5px;" v-model="formData['sczl_cl' + index]" :id="'sczl_cl' + index" @keydown="ent1($event)"/>
-                      </div>
-                    </div>
-                </el-row>
-              </el-form>
-
-              <!-- </el-scrollbar> -->
-              <template #footer>
-                <div class="dialog-footer" style="display: flex; margin-left: 500px;">
-                    <p style="font-size: 18px;">报工人: 
-                        <el-input v-model="linguser" style="width: 200px;" />
-                    </p>
-                  <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-input v-model="positionvalue" :clearable="true" placeholder="ZT01733" />
-                  </el-form-item>
-              </el-card>
-              <el-button type="primary" @click="enterpositioning">确 定</el-button>
-            </el-dialog>
-  
-  
-              <el-dialog v-model="dialogSelectVisible" title="选择"
-                destroy-on-close width="800px" >
-                <el-table tooltip-effect="dark" :data="selectData" row-key="ID"
-                  highlight-current-row="true" border style="width:100%"
-                  @row-dblclick="handleSelectClick" >
-                  <el-table-column prop="Gd_cpmc" label="印件名称" width="450" />
-                  <el-table-column prop="jyGx" label="检验工序" width="85" />
-                  <el-table-column prop="Gy0_gxmc" label="工序名称" width="225" />			 
-                </el-table>
-              </el-dialog>
+            </el-form-item>
+            <!-- 数据展示 -->
+            <el-table ref="multipleTable" style="width: 100%;height: 70vh;" tooltip-effect="dark" :data="tableData" row-key="ID"
+              highlight-current-row="true"   border @selection-change="handleSelectionChange" 
+              :row-style="{ height: '20px' }"  :header-cell-style="{ padding: '0px' }" id="table"
+              :cell-style="{ padding: '0px' }" :header-row-style="{ height: '20px' }"
+              :show-overflow-tooltip="true" @row-click="Click" @row-dblclick="doubleClick">
+              <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="款式" 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="颜色" width="100" />
+              <el-table-column align="left"  label="尺码" prop="尺码" width="100" />
+              <el-table-column align="left"  label="数量" prop="数量" width="80" />
+              <el-table-column align="left"  label="计划用料" prop="计划用料" width="100" />
+              <el-table-column align="left"  label="实际用料" prop="实际用料" width="100" />
+              <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="组别" width="120" />
+              <el-table-column align="left"  label="操作人员" prop="Sys_id" width="120" />
+              <el-table-column align="left"  label="创建时间" prop="Sys_rq" width="120" />
+
               
-              <el-dialog v-model="getGxMcshow"  :before-close="closegetGxMcshow" title="工序选择"  destroy-on-close  width="630px" >
-                  <el-table tooltip-effect="dark" :data="selectData"
-                      row-key="ID" highlight-current-row="true"
-                      border style="width:100%"
-                      @row-dblclick="handleSelectClick">
-                      <el-table-column prop="jyGx" label="印件工序" width="100" />
-                      <el-table-column prop="Gd_cpmc" label="印件名称"/>
-                 </el-table>
-              <template #footer>
-                <div class="dialog-footer">
-                  <el-button @click="closegetGxMcshow">取 消</el-button>
-                </div>
-              </template>
-            </el-dialog>
-  
-          </el-main>
-        </el-container>
+            </el-table>
+            <!-- 分页 -->
+            <div class="gva-pagination">
+              <el-pagination layout="total, sizes, prev, pager, next, jumper" v-model:current-page="page"
+                v-model: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
+style="width: 90%; height: 90%; margin-top: 3%;"
+>
+<el-form :model="formData" label-position="right" ref="elFormRef" :rules="rule" label-width="120px">
+  <!-- 日期选择框 -->
+  <el-row :gutter="24" style="margin-bottom: 20px;">
+    <el-col :span="8">
+      <el-form-item label="日期">
+        <el-date-picker v-model="DefectiveformData['Sys_rq']" style="width: 100%;" type="date" />
+      </el-form-item>
+    </el-col>
+  </el-row>
+
+  <!-- 新增一行按钮 -->
+  <el-button type="primary" @click="addRow" style="margin-left: 20px; margin-bottom: 20px;">新增一行</el-button>
+
+  <!-- 表格区域 -->
+  <el-table
+    :data="SecondarytabeleData"
+    border
+    style="width: 100%; margin-bottom: 20px;"
+    :row-style="{ height: '40px' }"
+    :header-cell-style="{ padding: '0px' }"
+    :cell-style="{ padding: '0px' }"
+    :header-row-style="{ height: '40px' }"
+    :show-overflow-tooltip="true"
+  >
+    <!-- 订单编号|款号 -->
+    <el-table-column label="订单编号|款号" width="220">
+      <template #default="{ row, $index }">
+        <el-input v-model="row.ddbh" placeholder="Enter回车" @keyup.enter="getGxMcsubmit($event, $index)" />
+      </template>
+    </el-table-column>
+
+      <!-- 款式 -->
+        <el-table-column label="款式" width="120">
+      <template #default="{ row }">
+        <el-input v-model="row.ks" />
+      </template>
+    </el-table-column>
+
+
+
+    <!-- 颜色 -->
+    <el-table-column label="颜色" width="100">
+      <template #default="{ row }">
+        <el-select v-model="row.color" placeholder="请选择颜色" clearable>
+          <el-option
+            v-for="color in row.colorOptions"
+            :key="color.value"
+            :label="color.label"
+            :value="color.value"
+          />
+        </el-select>
+      </template>
+    </el-table-column>
+
+        <!-- 尺码 -->
+        <el-table-column label="尺码" width="100">
+      <template #default="{ row }">
+        <el-select v-model="row.size" placeholder="请选择尺码" clearable>
+          <el-option
+            v-for="size in row.sizeOptions"
+            :key="size.value"
+            :label="size.label"
+            :value="size.value"
+          />
+        </el-select>
+      </template>
+    </el-table-column>
+
+    <!-- 面料分类|面料名称 -->
+    <el-table-column label="面料分类|面料名称" width="220">
+      <template #default="{ row }">
+        <el-select v-model="row.material" placeholder="请选择面料分类|面料名称" clearable>
+          <el-option
+            v-for="material in row.materialOptions"
+            :key="material.value"
+            :label="material.label"
+            :value="material.value"
+          />
+        </el-select>
+      </template>
+    </el-table-column>
+
+    <!-- 返工数量 -->
+    <el-table-column label="返工数量" width="100">
+      <template #default="{ row }">
+        <el-input v-model="row.defectiveQuantity" />
+      </template>
+    </el-table-column>
+    
+        <!-- 返工车缝小组 -->
+        <el-table-column label="返工车缝小组" width="120">
+      <template #default="{ row }">
+        <el-select v-model="row.group" placeholder="请选择返工车缝小组" clearable>
+          <el-option
+            v-for="group in row.groupOptions"
+            :key="group.value"
+            :label="group.label"
+            :value="group.value"
+          />
+        </el-select>
+      </template>
+    </el-table-column>
+
+    <!-- 返工问题 -->
+    <el-table-column label="返工问题" width="140">
+      <template #default="{ row }">
+        <el-select v-model="row.issue" placeholder="请选择返工问题" clearable>
+          <el-option
+            v-for="issue in row.issueOptions"
+            :key="issue.value"
+            :label="issue.label"
+            :value="issue.value"
+          />
+        </el-select>
+      </template>
+    </el-table-column>
+
+    
+    <!-- 备注 -->
+    <el-table-column label="备注" width="220">
+      <template #default="{ row }">
+        <el-input v-model="row.remark" />
+      </template>
+    </el-table-column>
+
+
+
+    <!-- 操作列 -->
+    <el-table-column label="操作" width="220" fixed="right">
+      <template #default="{ row, $index }">
+        <el-button type="primary" @click="copyRow($index)" style="font-size: 18px;">复制本条</el-button>
+        <el-button type="danger" @click="removeRow($index)" style="font-size: 18px;">移除</el-button>
+      </template>
+    </el-table-column>
+  </el-table>
+</el-form>
+
+<!-- 弹窗底部按钮 -->
+<template #footer>
+  <div class="dialog-footer" style="width: 100%;">
+    <el-button @click="closeDialog" style="width: 100px; height: 40px;">关 闭</el-button>
+    <el-button type="primary" @click="enterDialog" style="width: 100px; height: 40px;">确 定</el-button>
+  </div>
+</template>
+</el-dialog>
+
+        </el-main>
       </el-container>
-    </div>
-  </template>
-  <script setup>
-  // 全量引入格式化工具 请按需保留
-  import { ElMessage, ElMessageBox, LAST_KEYS } from 'element-plus'
-//   import { Search, Refresh, Download } from '@element-plus/icons-vue'
-  import { ref, reactive, nextTick, onMounted, onBeforeMount } from 'vue'
-//   import { } from '@/api/mes_api_gty/myapi'
-  import { Layout, LayoutContent, LayoutHeader, LayoutSider } from '@arco-design/web-vue'
-  import { useUserStore } from '@/pinia/modules/user'
-  const userStore = useUserStore() 
-  const sys_id='['+userStore.userInfo.userName+'/'+userStore.userInfo.nickName+']'
-  defineOptions({name: '06-packingDocuments'})
-  
-  // 侧边栏数据请求
-  const treeData = reactive([]);
-  
-//   const getTabdata = async () => {
- 
-//   }
-//   getTabdata();
-  
-  // 自动化生成的字典(可能为空)以及字段
-  const formData = ref({
-    sczl_rq: '',
-    sczl_gdbh1: '',
-    sczl_gdbh2: '',
-    sczl_gdbh3: '',
-    sczl_gdbh4: '',
-    sczl_gdbh5: '',
-    sczl_gdbh6: '',
-    sczl_fggx1: '',
-    sczl_fggx2: '',
-    sczl_fggx3: '',
-    sczl_fggx4: '',
-    sczl_fggx5: '',
-    sczl_fggx6: '',
-    sczl_gxmc1: '',
-    sczl_gxmc2: '',
-    sczl_gxmc3: '',
-    sczl_gxmc4: '',
-    sczl_gxmc5: '',
-    sczl_gxmc6: '',
-    Gd_cpmc1: '',
-    Gd_cpmc2: '',
-    Gd_cpmc3: '',
-    Gd_cpmc4: '',
-    Gd_cpmc5: '',
-    Gd_cpmc6: '',
-    sczl_cl1: '0.00',
-    sczl_cl2: '0.00',
-    sczl_cl3: '0.00',
-    sczl_cl4: '0.00',
-    sczl_cl5: '0.00',
-    sczl_cl6: '0.00',
-    sczl_PgCl1:'0',
-    sczl_PgCl2: '0',
-    sczl_PgCl3: '0',
-    sczl_PgCl4: '0',
-    sczl_PgCl5: '0',
-    sczl_PgCl6: '0',
-    sczl_clAdd1: '0',
-    sczl_clAdd2: '0',
-    sczl_clAdd3: '0',
-    sczl_clAdd4: '0',
-    sczl_clAdd5: '0',
-    sczl_clAdd6: '0',
-    UniqId:'000',
-  })
-  const initFormData = () => {
-      formData.value = {
-          sczl_rq: '',
-          sczl_gdbh1: '',
-          sczl_gdbh2: '',
-          sczl_gdbh3: '',
-          sczl_gdbh4: '',
-          sczl_gdbh5: '',
-          sczl_gdbh6: '',
-          sczl_fggx1: '',
-          sczl_fggx2: '',
-          sczl_fggx3: '',
-          sczl_fggx4: '',
-          sczl_fggx5: '',
-          sczl_fggx6: '',
-          sczl_gxmc1: '',
-          sczl_gxmc2: '',
-          sczl_gxmc3: '',
-          sczl_gxmc4: '',
-          sczl_gxmc5: '',
-          sczl_gxmc6: '',
-          Gd_cpmc1: '',
-          Gd_cpmc2: '',
-          Gd_cpmc3: '',
-          Gd_cpmc4: '',
-          Gd_cpmc5: '',
-          Gd_cpmc6: '',
-          sczl_cl1: '0.00',
-          sczl_cl2: '0.00',
-          sczl_cl3: '0.00',
-          sczl_cl4: '0.00',
-          sczl_cl5: '0.00',
-          sczl_cl6: '0.00',
-          sczl_PgCl1:'0',
-          sczl_PgCl2: '0',
-          sczl_PgCl3: '0',
-          sczl_PgCl4: '0',
-          sczl_PgCl5: '0',
-          sczl_PgCl6: '0',
-          sczl_clAdd1: '0',
-          sczl_clAdd2: '0',
-          sczl_clAdd3: '0',
-          sczl_clAdd4: '0',
-          sczl_clAdd5: '0',
-          sczl_clAdd6: '0',
-          UniqId:'000',
-      }
-  }
-  
-  
-  const elFormRef = ref()
-  const elSearchFormRef = ref()
-  // =========== 表格控制部分 ===========
-  const tableData = reactive([])
-  const GxMctableData = reactive([])
-  const tableColumns = [
-    { label: '创建用户', prop: 'sys_id', width: '200' },
-    { label: '日期', prop: 'sczl_rq', width: '100' },
-    { label: '包装产量', prop: 'sczl_cl', width: '105' },
-    { label: '包装数量', prop: 'sczl_PgCl', width: '105' },
-    { label: '创建时间', prop: 'sys_rq', width: '160' },
-    { label: '修改时间', prop: 'mod_rq', width: '160' },
-    { label: 'UNIQID', prop: 'UniqId', width: '120' },
-  ]
-  
-  // 总条数
-  const total = ref(0);
-  // 当前页码
-  const page = ref(1);
-  // 每页条数
-  const limit = ref(50);
-  // 搜索关键字
-  const searchInfo = ref('');
-  // 查询参数
-  const params = ref({
-    // type: 'getTableData', // 默认查询类型
-    type: '',
-    date: '',
-    sys_id: '',
-    gdbh: '',
-    limit: limit.value, // 每页条数
-    page: page.value, // 当前页码
-  });
-  
-  const inputname=ref(0)
-  
-  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) => {
-      params.page = val;
-   switch (params.type) {
-     case 'getTableData':
-       getTableData()
-       break
-     case 'getLocateTable':
-       Getlocate()
-       break
-     default:
-       break
-   }
-  }
-  // 页面跳转
-  const handleCurrentChange = (val) => {
-      params.page = val;
-   switch (params.type) {
-     case 'getTableData':
-       getTableData()
-       break
-     case 'getLocateTable':
-       Getlocate()
-       break
-     default:
-       break
-   }
-  }
-  
-//   // 查询
-//   const getTableData = async () => {
-//       console.log(params)
-//     const response = await getList(params);
-//     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({
-//       gdbh: params.gdbh,
-//       page: page.value.toString(), limit: limit.value.toString(),
-//     })
-//     if (response.code === 0) {
-//       total.value = response.data.total
-//       tableData.splice(0, tableData.length, ...response.data.rows)
-//     }
-//   }
-//   //确定
-//   const enterpositioning = async () => {
-//    locatevalue.gdbh = positionvalue.value;
-//    Getlocate()
-//    closepositioningVisible()
-//   }
-  
-//   let sczl_rqValue=ref()
-//   const getpickInfo = async (value) => {
-//     const response = await getInfo({UniqId:value});
-//     if (response.code === 0) {
-//         formData.value=response.data;
-//     }
-//   }
-  
-//   //键盘 input框跳转
-//   const ent1 = (event) => {
-//     const inputs = document.getElementsByTagName('input');
-//     const currentIndex = Array.from(inputs).indexOf(event.target);
-//     if (event.keyCode === 13 || event.keyCode === 40) { // Enter 或向下箭头
-//         if(event.target.id=='sczl_clAdd6'){
-//             ElMessageBox.confirm('数据存盘?', '提示', {
-//                       confirmButtonText: '确定',
-//                       cancelButtonText: '取消',
-//                       type: 'warning'
-//                     }).then(() => {
-//                       enterDialog()
-//                   })
-//         }
-//       for (let i = currentIndex + 1; i < inputs.length; i++) {
-//         if (!inputs[i].readOnly) {
-//             nextTick(()=>{
-//                 inputs[i].focus();
-//                 inputs[i].select();
-//             })
-//           break;
-//         }
-//       }
-//       if(event.target.id.substring(0, 2)=='cl' || event.target.id.substring(0, 2)=='fp'){
-//           ent_sum()
-//       }
-//     } else if (event.keyCode === 38) { // 向上箭头
-//       for (let i = currentIndex - 1; i >= 0; i--) {
-//         if (!inputs[i].readOnly) {
-//           nextTick(()=>{
-//               inputs[i].focus();
-//               inputs[i].select();
-//           })
-//           break;
-//         }
-//       }
-//       if(event.target.id.substring(0, 2)=='cl' || event.target.id.substring(0, 2)=='fp'){
-//           ent_sum()
-//       }
-//     } else if (event.keyCode === 8) { // 删除箭头
-//       if (event.target.selectionStart === 0) {
-//         for (let i = currentIndex - 1; i >= 0; i--) {
-//           if (!inputs[i].readOnly) {
-//             nextTick(()=>{
-//                 inputs[i].focus();
-//               inputs[i].setSelectionRange(0, 0);
-//             })
-//             break;
-//           }
-//         }
-//         if(event.target.id.substring(0, 2)=='cl' || event.target.id.substring(0, 2)=='fp'){
-//             ent_sum()
-//         }
-//       }
-//     } else if (event.keyCode === 37) { // 向左箭头
-//       if (event.target.selectionStart === 0) {
-//         for (let i = currentIndex - 1; i >= 0; i--) {
-//           if (!inputs[i].readOnly) {
-//             nextTick(()=>{
-//                 inputs[i].focus();
-//               inputs[i].select();
-//             })
-//             break;
-//           }
-//         }
-//         if(event.target.id.substring(0, 2)=='cl' || event.target.id.substring(0, 2)=='fp'){
-//             ent_sum()
-//         }
-//       }
-//     } else if (event.keyCode === 39) { // 向右箭头
-//         if(event.target.id=='sczl_clAdd6'){
-//             ElMessageBox.confirm('数据存盘?', '提示', {
-//                       confirmButtonText: '确定',
-//                       cancelButtonText: '取消',
-//                       type: 'warning'
-//                     }).then(() => {
-//                       enterDialog()
-//                   })
-//         }
-//       if (event.target.selectionStart === event.target.value.length) {
-//         for (let i = currentIndex + 1; i < inputs.length; i++) {
-//           if (!inputs[i].readOnly) {
-//             nextTick(()=>{
-//                 inputs[i].focus();
-//               inputs[i].select();
-//             })
-//             break;
-//           }
-//         }
-//       }
-//       if(event.target.id.substring(0, 2)=='cl' || event.target.id.substring(0, 2)=='fp'){
-//           ent_sum()
-//       }
-//     }
-//   }
-  
-  //追加字体颜色和不可输入
-  const setColorReadonly = (id) => {
-      const newInput = document.getElementById(id)
-      newInput.style.color = 'red';
-      newInput.setAttribute('readonly', true);
-  }
-  
-  //追加字体颜色和可输入
-  const unsetColorReadonly = (id) => {
-      const newInput = document.getElementById(id)
-      newInput.style.color = 'black';
-      newInput.removeAttribute('readonly');
-  }
-  
-  //日期获得焦点事件
-  const rqHandleFocus = () =>{
-      if(formData.value.sczl_rq==''){
-          formData.value.sczl_rq = new Date().toISOString().split('T')[0]
-      }
-  }
-  
-  //工单编号失去焦点事件
-  const getGxMcshow = ref(false)
-  const selectData = reactive([])
-  let tableIndex = 0
-  
-  const getGxMcsubmit = async (event, index) => {
-      if(formData.value['sczl_gdbh'+index]!=''){
-          const response = await getGxMc({gdbh: formData.value['sczl_gdbh'+index] })
-          if (response.code === 0) {
-              if(response.data.length==0){
-                    ElMessage({
-                      type: 'error',
-                      message: '查无此编号的工单,请仔细检查后重新输入'
-                    })
-                    //设置输入框的值为空
-                    formData.value['sczl_gdbh'+index] = ''
-                    formData.value['Gd_cpmc'+index] = ''
-                    formData.value['sczl_fggx'+index] = ''
-                    formData.value['sczl_gxmc'+index] = ''
-              }else if(response.data.length==1){
-                    const { Gd_cpmc, Gy0_gxmc, jyGx } = response.data[0]
-                    formData.value['Gd_cpmc'+index] = Gd_cpmc
-                    formData.value['sczl_fggx'+index] = jyGx
-                    formData.value['sczl_gxmc'+index] = Gy0_gxmc
-                    setColorReadonly('Gd_cpmc'+index);
-                    setColorReadonly('sczl_fggx'+index);
-                    setColorReadonly('sczl_gxmc'+index);
-                    unsetColorReadonly('sczl_cl'+index);
-                    unsetColorReadonly('sczl_PgCl'+index);
-              }else{
-                  selectData.splice(0, selectData.length, ...response.data)
-                  tableIndex = index
-                  getGxMcshow.value = true
-              }
-          }
-      }else{
-          formData.value['Gd_cpmc'+index] = ''
-          formData.value['sczl_fggx'+index] = ''
-          formData.value['sczl_gxmc'+index] = ''
-          formData.value['sczl_cl'+index] = '0.00'
-          formData.value['sczl_PgCl'+index] = '0'
-          setColorReadonly('sczl_cl'+index);
-          setColorReadonly('sczl_PgCl'+index);
-      }
-        
-  }
-  // 处理选择框
-  const handleSelectClick = (row, column, event) => {
-    const { Gd_cpmc, Gy0_gxmc, jyGx } = row
-    formData.value['Gd_cpmc'+tableIndex] = Gd_cpmc
-    formData.value['sczl_fggx'+tableIndex] = jyGx
-    formData.value['sczl_gxmc'+tableIndex] = Gy0_gxmc
-    setColorReadonly('Gd_cpmc'+tableIndex);
-    setColorReadonly('sczl_fggx'+tableIndex);
-    setColorReadonly('sczl_gxmc'+tableIndex);
-    unsetColorReadonly('sczl_cl'+tableIndex);
-    unsetColorReadonly('sczl_PgCl'+tableIndex);
-    getGxMcshow.value = false
-  }
-  
-  
-  // 更新数据
-  const updateDetailData = async() => {
-      const restoredData = {
-           UniqId: lastCellValue,
-           sczl_rq: formData.value.sczl_rq,
-           sczl_gdbh1: formData.value.sczl_gdbh1,
-           sczl_gdbh2: formData.value.sczl_gdbh2,
-           sczl_gdbh3: formData.value.sczl_gdbh3,
-           sczl_gdbh4: formData.value.sczl_gdbh4,
-           sczl_gdbh5: formData.value.sczl_gdbh5,
-           sczl_gdbh6: formData.value.sczl_gdbh6,
-           sczl_fggx1: formData.value.sczl_fggx1,
-           sczl_fggx2: formData.value.sczl_fggx2,
-           sczl_fggx3: formData.value.sczl_fggx3,
-           sczl_fggx4: formData.value.sczl_fggx4,
-           sczl_fggx5: formData.value.sczl_fggx5,
-           sczl_fggx6: formData.value.sczl_fggx6,
-           sczl_gxmc1: formData.value.sczl_gxmc1,
-           sczl_gxmc2: formData.value.sczl_gxmc2,
-           sczl_gxmc3: formData.value.sczl_gxmc3,
-           sczl_gxmc4: formData.value.sczl_gxmc4,
-           sczl_gxmc5: formData.value.sczl_gxmc5,
-           sczl_gxmc6: formData.value.sczl_fggx6,
-           sczl_cl1: formData.value.sczl_cl1,
-           sczl_cl2: formData.value.sczl_cl2,
-           sczl_cl3: formData.value.sczl_cl3,
-           sczl_cl4: formData.value.sczl_cl4,
-           sczl_cl5: formData.value.sczl_cl5,
-           sczl_cl6: formData.value.sczl_cl6,
-           sczl_PgCl1:formData.value.sczl_PgCl1,
-           sczl_PgCl2: formData.value.sczl_PgCl2,
-           sczl_PgCl3: formData.value.sczl_PgCl3,
-           sczl_PgCl4: formData.value.sczl_PgCl4,
-           sczl_PgCl5: formData.value.sczl_PgCl5,
-           sczl_PgCl6: formData.value.sczl_PgCl6,
-           Gd_cpmc1: formData.value.Gd_cpmc1,
-           Gd_cpmc3: formData.value.Gd_cpmc2,
-           Gd_cpmc4: formData.value.Gd_cpmc3,
-           Gd_cpmc5: formData.value.Gd_cpmc4,
-           Gd_cpmc6: formData.value.Gd_cpmc5,
-           sczl_clAdd1: formData.value.sczl_clAdd1,
-           sczl_clAdd2: formData.value.sczl_clAdd2,
-           sczl_clAdd3: formData.value.sczl_clAdd3,
-           sczl_clAdd4: formData.value.sczl_clAdd4,
-           sczl_clAdd5:formData.value.sczl_clAdd5,
-           sczl_clAdd6: formData.value.sczl_clAdd6,
-           sys_id:sys_id,
-      }
+    </el-container>
+  </div>
+</template>
+<script setup>
+// 全量引入格式化工具 请按需保留
+import { ElMessage, ElMessageBox, LAST_KEYS } from 'element-plus';
+import * as XLSX from 'xlsx';
+import FileSaver from 'file-saver';
+import { Search, Refresh, Download } from '@element-plus/icons-vue'
+import { ref, reactive, nextTick, onMounted, onBeforeMount } from 'vue'
+import { Layout, LayoutContent, LayoutHeader, LayoutSider } from '@arco-design/web-vue'
+import {queryOrderSize,ApiAddDefective,ApiMouthlist,ApiSubPieceAndReworkList, search} from '@/api/mes/job'
+import { useUserStore } from '@/pinia/modules/user'
+// import { el } from 'element-plus/es/locale'
+//获取登录用户信息
+const userStore = useUserStore()
+const _username = ref('')
+_username.value = userStore.userInfo.userName + '/' + userStore.userInfo.nickName
+console.log('获取用户名称',_username.value)
+//全局获取当前日期
+const today = new Date();
+const year = today.getFullYear();
+const month = String(today.getMonth() + 1).padStart(2, '0'); // 月份从 0 开始,需要补零
+const day = String(today.getDate()).padStart(2, '0');
+const hours = String(today.getHours()).padStart(2, '0');
+const minutes = String(today.getMinutes()).padStart(2, '0');
+const seconds = String(today.getSeconds()).padStart(2, '0');
+const currentDate = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
+const currentDates = `${year}-${month}-${day}`;
+
+// 侧边栏数据请求
+const treeData = reactive([]);
+
+const getTabdata = async () => {
+try {
+  const response = await ApiMouthlist({ code: '返工' });
+  if (response.code === 0) {
+    // 清空数组
+    treeData.splice(0, treeData.length);
     
-    if(ADD.value=='新增'){
-         const response = await packagingAdd(restoredData);
-         ADD.value='0'
-       if(response.code==0){
-                ElMessage({
-                  type: 'success',
-                  message: '新增成功',
-                })
-               dialogFormVisible.value = false
-               //刷新侧边栏
-               getTabdata()
-               if(params.date != ''){
-                   //刷新页面
-                   getTableData()
-               }
-       }
-    }else{
-          const res = await edit(restoredData)
-       if(res.code==0){
-                ElMessage({
-                  type: 'success',
-                  message: '更新成功',
-                })
-       }
-       dialogFormVisible.value = false
-    }
-  }
-  
-  
-  const GxMcdel = () => {
-      if(typeof(lastCellValue)=='object'){
-          ElMessage({
-            type: 'warning',
-            message: '未选中记录',
-          })
-          return
-      }
-      
-      ElMessageBox.confirm(
-        `确认删除这条数据么?`,
-        '警告',
-        {
-          confirmButtonText: '确认',
-          cancelButtonText: '取消',
-          type: 'warning',
-        }
-      ).then(async() => {
-          const response = await del({UniqId:lastCellValue});
-          if (response.code === 0) {
-              ElMessage({type: 'success',message: '删除成功',})
-              //刷新侧边栏
-              getTabdata()
-              getTableData()
-          }
-      })
+    // 转换接口数据为树形结构
+    const formattedData = Object.entries(response.data).map(([year, months]) => ({
+      label: year,
+      children: Object.entries(months).map(([month, days]) => ({
+        label: month,
+        children: days.map(day => ({
+          label: day
+        }))
+      }))
+    }));
     
-  }
-  
-  //搜索按钮
-  const onSearch = async (event) => {
-    params.gdbh = positionvalue.value
-    params.type = 'getLocateTable'
-    page.value = 1
-    Getlocate()
-  }
-  //回车搜索
-  const keydown_onSearch = async (event) => {
-      const inputs = document.getElementsByTagName("input");
-      const currentIndex = Array.from(inputs).indexOf(event.target);
-      if(event.keyCode === 13){
-       params.gdbh = positionvalue.value
-       params.type = 'getLocateTable'
-       page.value = 1
-       Getlocate()
-      }
-  }
-  
-  // ============== 表格控制部分结束 ===============
-  
-  // 获取需要的字典 可能为空 按需保留
-  const setOptions = async () => {
-  }
-  
-  // 获取需要的字典 可能为空 按需保留
-  setOptions()
-  
-  // 多选数据
-  const multipleSelection = ref([])
-  // 多选
-  const handleSelectionChange = (val) => {
-      if(val.length>0){		
-          multipleSelection.value = val
-          const lenth=val.length
-          lastCellValue=val[lenth-1].UniqId
-          console.log(val)
-          val.splice(0, val.length);  // 清空 val 数组	
-          console.log(lastCellValue)
-      }
-  }
-  
-  // 批量删除控制标记
-  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()
+    treeData.push(...formattedData);
+    
+    console.log('转换后的树形数据:', treeData); // 调试用
+  } else {
+    ElMessage.error(response.msg || '获取数据失败');
+  }
+} catch (error) {
+  console.error('请求错误:', error);
+  ElMessage.error('请求失败,请稍后重试');
+}
+};
+
+getTabdata();
+
+
+const tableData = reactive([]);
+const loading = ref(false);
+
+const handleNodeClick = async (node) => {
+if (!node.children) {
+  loading.value = true;
+  try {
+    const response = await ApiSubPieceAndReworkList({
+      Sys_rq: node.label, 
+      page: 1,
+      limit: 50,
+      code: '返工'
+    });
+    
+    if (response.code === 0 && response.data?.data) {
+      // 清空并更新表格数据
+      tableData.splice(0, tableData.length, ...response.data.data);
+    } else {
+      ElMessage.warning(response.msg || '暂无数据');
+      tableData.splice(0, tableData.length);
     }
-  }
-  
-  // 弹窗控制标记
-  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
+  } catch (error) {
+    console.error('加载数据失败:', error);
+    ElMessage.error('数据加载失败');
+  } finally {
+    loading.value = false;
+  }
+}
+};
+
+const searchinfo = ref('');
+//回车搜索
+const keydown_onSearch = async (event) => {
+if(event.keyCode === 13){
+  const response = await ApiSubPieceAndReworkList({
+      search: searchinfo.value, 
+      page: 1,
+      limit: 50,
+      code: '返工'
+    });
+    if (response.code === 0 && response.data?.data) {
+      // 清空并更新表格数据
+      tableData.splice(0, tableData.length, ...response.data.data);
+    } else {
+      ElMessage.warning(response.msg || '暂无数据');
+      tableData.splice(0, tableData.length);
     }
-  }
-  
-  
+}
+}
+
+/**
+* 新增次品
+*/
+const dialogFormVisible = ref(false);
+const DefectiveformData = reactive({
+Sys_rq: '' ,
+});
+const rule = {}; // 表单验证规则(如果有)
+const GROUP_OPTIONS = [
+{ value: '车缝01组', label: '车缝01组' },
+{ value: '车缝02组', label: '车缝02组' },
+{ value: '车缝03组', label: '车缝03组' },
+{ value: '车缝04组', label: '车缝04组' },
+{ value: '车缝05组', label: '车缝05组' },
+{ value: '车缝06组', label: '车缝06组' },
+{ value: '车缝07组', label: '车缝07组' },
+{ value: '车缝08组', label: '车缝08组' },
+{ value: '车缝09组', label: '车缝09组' },
+{ value: '车缝10组', label: '车缝10组' },
+{ value: '车缝11组', label: '车缝11组' },
+{ value: '车缝12组', label: '车缝12组' },
+{ value: '大办组', label: '大办组' },
+{ value: '美英组', label: '美英组' },
+{ value: '小芬组', label: '小芬组' },
+];
+const SecondarytabeleData = reactive([
+{ 
+  ddbh: '',       // 订单编号
+  material: '',   // 面料分类
+  colorOptions: [],      // 颜色
+  sizeOptions: [],      // 尺码
+  ks: '',         // 款式
+  defectiveQuantity: '', // 返工数量
+  issueOptions: [], // 返工问题(下拉框选项)
+  remark: '',     // 备注
+  group: '车缝01组',      // 报工小组
+},
+]);
+// 定义初始行数据
+const initialRowData = () => ({ 
+ddbh: '',       // 订单编号
+material: '',   // 面料分类
+colorOptions: [],      // 颜色
+sizeOptions: [],      // 尺码
+ks: '',         // 款式
+defectiveQuantity: '', // 返工数量
+issueOptions: [], // 返工问题(下拉框选项)
+remark: '',     // 备注
+group: '车缝01组',      // 报工小组
+});
+// 方法:新增一行
+const addRow = () => {
+SecondarytabeleData.push({ 
+  ddbh: '',       // 订单编号
+  material: '',   // 面料分类
+  colorOptions: [],     // 颜色
+  sizeOptions: [],      // 尺码
+  ks: '',         // 款式
+  defectiveQuantity: '', // 返工数量
+  issueOptions: [], // 返工问题(下拉框选项)
+  remark: '',     // 备注
+  group: '车缝01组',      // 报工小组
+});
+};
+
+const type = ref('create'); // 弹窗类型,默认为 'create'
+//新增按钮
+const onAdd = async () => {
+type.value = 'create'
+dialogFormVisible.value = true
+DefectiveformData.Sys_rq = currentDates
+}
+
+// 键盘事件
+const ent1 = (event, index) => {
+// 处理键盘事件
+console.log(event, index);
+};
+
+// 工单编号|款号回车事件
+const getGxMcsubmit = async (event, index) => {
+const row = SecondarytabeleData[index]; // 获取当前行数据
+const ddbh = row.ddbh; // 获取输入的工单编号
+
+if (!ddbh) {
+  ElMessage.warning('请输入工单编号');
+  return;
+}
+
+try {
+  // 调用接口获取数据
+  const response = await queryOrderSize({ 订单编号: ddbh });
+
+  if (response.code === 0) {
+    const { list, fetchCategory, colorremark, FabricData, 面料统计,size } = response.data;
+
+    // 更新当前行的数据
+    row.ddbh = `${list.订单编号}|${list.生产款号}`;
+    row.ks = list.款式;
+    // 更新下拉框选项
+    row.colorOptions = colorremark.map(item => ({ value: item, label: item })); // 颜色选项
+    row.sizeOptions = size.map(item => ({ value: item, label: item })); // 尺码选项
+    row.issueOptions = fetchCategory.map(item => ({ value: item, label: item })); // 返工问题选项
+    row.materialOptions = FabricData.map(item => ({ value: item, label: item }));
+    row.groupOptions = GROUP_OPTIONS;// 报工小组选项
+    // 保存面料统计数据
+    row.fabricStats = 面料统计;
+    
+    ElMessage.success({
+        message: '数据加载成功',
+        duration: 2000,
+      });
+  } else {
+    ElMessage.error(response.msg || '接口返回错误');
+  }
+} catch (error) {
+  ElMessage.error('接口调用失败,请稍后重试');
+}
+};
+
+// 关闭弹窗
+const closeDialog = () => {
+SecondarytabeleData.splice(0, SecondarytabeleData.length, initialRowData());
+dialogFormVisible.value = false;
+};
+
+// 提交确认
+const enterDialog = async () => {
+console.log('确认提交', SecondarytabeleData);
+
+// 获取面料统计数据
+const fabricStats = SecondarytabeleData[0]?.fabricStats || [];
+console.log('fabricStats', fabricStats);
+
+const params = SecondarytabeleData.map(item => {
+  // 查找匹配的面料数据
+  console.log('物料名称', item['material'].split('-')[1]);
+  console.log('颜色', item.color);
+  const matchedFabric = fabricStats.find(f => 
+    f.颜色 === item.color && f.物料名称 === item['material'].split(' - ')[1]
+  );
+  console.log('匹配统计数据', matchedFabric);
+  return {
+    订单编号: item['ddbh'].split('|')[0],
+    生产款号: item['ddbh'].split('|')[1],
+    款式: item['ks'],
+    颜色: item['color'],
+    数量: item['defectiveQuantity'],
+    备注: item['remark'],
+    Sys_id: userStore.userInfo.nickName,
+    组别: item['group'],
+    Sys_rq: currentDates,
+    sczl_rq: currentDate,
+    状态: '返工',
+    问题分类: item['issue'],
+    尺码: item['size'],
+    实际用料: matchedFabric ? matchedFabric.实际用料 : '', 
+    计划用料: matchedFabric ? matchedFabric.计划用料 : '', 
+    物料名称: item['material'],
+  };
+});
+
+console.log('提交参数', params);
+try {
+  // 在这里执行提交逻辑
+  const ApiAddDefectiveRes = await ApiAddDefective(params);
+  if (ApiAddDefectiveRes.code === 0) {
+    ElMessage.success('提交成功');
+    closeDialog(); // 关闭弹窗	
+  } else {
+    ElMessage.error(ApiAddDefectiveRes.msg || '接口返回错误');	
+  }
+} catch (error) {
+  ElMessage.error('提交失败,请稍后重试');
+}
+};
+
+
+// 复制行
+const copyRow = (index) => {
+const copiedRow = { ...SecondarytabeleData[index] };
+SecondarytabeleData.splice(index + 1, 0, copiedRow);
+};
+// 移除行
+const removeRow = (index) => {
+SecondarytabeleData.splice(index, 1);	
+}
+
+
+//导出
+const exportExcel = () => {
+  const el = document.getElementById('table');
+  const filename = '导出半成品返工EXCEL.xlsx';
   
-  //新增
-  const ADD=ref('0')
-  const onAdd = async () => {
-      ADD.value='新增'
-      type.value = 'create'
-      initFormData()
-      dialogFormVisible.value = true
-      setTimeout(() => {
-      const inputElement = document.getElementById('日期');
-          if (inputElement) {
-              inputElement.focus();		
-          }
-      }, 100);
-  }
+  // 获取表格数据
+  const ws = XLSX.utils.table_to_sheet(el);
   
-  const Del = () => {
-     GxMcdel()
-  }
+  // 找出需要保留为数字的列(假设'sl'列是数字)
+  const numCols = ['数量']; // 添加其他需要保留数字的列名
   
-  /*
-      新增弹窗控制标记
-  */
-  const positioningVisibleshow = ref(false)
-  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: '',
+  // 遍历工作表数据,将指定列转换为数字
+  for (const cell in ws) {
+    if (cell[0] === '!') continue; // 跳过特殊属性
+    
+    const colName = cell.replace(/[0-9]/g, ''); // 获取列字母
+    const header = ws[colName + '1']; // 获取表头
+    
+    if (header && numCols.includes(header.v)) {
+      // 如果是数字列,尝试转换为数字
+      const value = ws[cell].v;
+      if (!isNaN(value) && value !== '') {
+        ws[cell].t = 'n'; // 设置为数字类型
+        ws[cell].v = Number(value); // 转换为数字
+      }
     }
   }
-  // 弹窗确定
-  const enterDialog = async () => {
-        ElMessageBox.confirm('数据存盘?', '提示', {
-          confirmButtonText: '确定',
-          cancelButtonText: '取消',
-          type: 'warning'
-        }).then(() => {
-          
-          if(formData.value.sczl_rq==''){
-              ElMessage({
-                  type: 'error',
-                  message: '请填写日期'
-              });
-              document.getElementById('日期').focus()
-              document.getElementById('日期').select()
-              return;
-          }
-          if(formData.value.sczl_gdbh1=='' && formData.value.sczl_gdbh2=='' && formData.value.sczl_gdbh3=='' &&
-              formData.value.sczl_gdbh4=='' && formData.value.sczl_gdbh5=='' && formData.value.sczl_gdbh6==''){
-              ElMessage({
-                  type: 'error',
-                  message: '请填写工单编号'
-              });
-              document.getElementById('sczl_gdbh1').focus()
-              document.getElementById('sczl_gdbh1').select()
-              return;
-          }
-          if(parseFloat(formData.value.sczl_cl1)==0 && parseFloat(formData.value.sczl_cl2)==0 && parseFloat(formData.value.sczl_cl3)==0 &&
-              parseFloat(formData.value.sczl_cl4)==0 && parseFloat(formData.value.sczl_cl5)==0 && parseFloat(formData.value.sczl_cl6)==0){
-              ElMessage({
-                  type: 'error',
-                  message: '请填写包装产量'
-              });
-              document.getElementById('sczl_cl1').focus()
-              document.getElementById('sczl_cl1').select()
-              return;
-          }
-          if(parseFloat(formData.value.sczl_PgCl1)==0 && parseFloat(formData.value.sczl_PgCl2)==0 && parseFloat(formData.value.sczl_PgCl3)==0 &&
-              parseFloat(formData.value.sczl_PgCl4)==0 && parseFloat(formData.value.sczl_PgCl5)==0 && parseFloat(formData.value.sczl_PgCl6)==0){
-              ElMessage({
-                  type: 'error',
-                  message: '请填写每箱数量'
-              });
-              document.getElementById('sczl_PgCl1').focus()
-              document.getElementById('sczl_PgCl1').select()
-              return;
-          }
-          
-          updateDetailData()
-        });
-  }
-  
-  let lastCellValue=ref()
-  // 双击表格操作
-  function doubleClick(row) {
-      type.value = 'update';
-      getpickInfo(row['UniqId'])
-      dialogFormVisible.value = true
-  }
-  // 单击表格操作
-  function Click(row, column, event) {
-      lastCellValue= row['UniqId'];  
-  }
-  
-  // 导出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;
-  }
+  // 创建工作簿并导出
+  const wb = XLSX.utils.book_new();
+  XLSX.utils.book_append_sheet(wb, ws, "Sheet1");
   
-  .JKWTree-content {
-    flex: 1;
+  try {
+    XLSX.writeFile(wb, filename);
+  } catch (e) {
+    console.log(e);
   }
-  
-  /* 选中某行时的背景色*/
-  .el-table__body tr.current-row>td {
+}
+
+</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>
+<style scoped>
+:deep(.el-table td .cell) {
+  line-height: 20px !important;
+}
+:deep(.el-tabs__header){
+  margin-bottom: 0;
+}
+.search{
+  margin-left: 0px !important;
+  margin-right: 10px !important;
+}
+.bt{
+  margin-left: 2px !important;
+  padding: 3px !important;
+  font-size: 12px;
+}
+.el-tabs__header{
+  margin: 0px !important;
+}
+.gva-table-box{
+  padding: 0px !important;
+}
+.mab{
+  margin-bottom: 5px;
+}
+/* tree组件背景高亮 */
+:deep(.el-tree-node:focus > .el-tree-node__content){
     background: #ff80ff !important;
-    /* 背景颜色 */
-  }
-  </style>
-  <style scoped>
-  :deep(.el-table td .cell) {
-    line-height: 20px !important;
-  }
-  :deep(.el-tabs__header){
-    margin-bottom: 0;
-  }
-  .search{
-    margin-left: 0px !important;
-    margin-right: 10px !important;
-  }
-  .bt{
-    margin-left: 2px !important;
-    padding: 3px !important;
-    font-size: 12px;
-  }
-  .el-tabs__header{
-    margin: 0px !important;
-  }
-  .gva-table-box{
-    padding: 0px !important;
-  }
-  .mab{
-    margin-bottom: 5px;
-  }
-  /* tree组件背景高亮 */
-  :deep(.el-tree-node:focus > .el-tree-node__content){
-      background: #ff80ff !important;
-  }
-  </style>
+}
+
+
+
+</style>

+ 405 - 96
src/view/performance/QualityAssessment/cropdefective.vue

@@ -14,7 +14,7 @@
             <!-- 按钮区域 -->
             <div class="gva-table-box">
               <el-form-item>
-                <el-input v-model="positionvalue" @keydown="keydown_onSearch($event)" placeholder="输入工单编号或产品名称" style="width: 180px;" />
+                <el-input v-model="searchinfo" @keydown="keydown_onSearch($event)" placeholder="输入工单编号或产品名称" style="width: 180px;" />
                 <el-button type="primary" class="search" icon="search" @click="onSearch"></el-button>
                 <el-button type="primary" class="bt" icon="plus" @click="onAdd">新增次品</el-button>
                 <el-button type="primary" class="bt" icon="delete" @click="Del">删除</el-button>
@@ -24,20 +24,26 @@
               </el-form-item>
               <!-- 数据展示 -->
               <el-table ref="multipleTable" style="width: 100%;height: 70vh;" tooltip-effect="dark" :data="tableData" row-key="ID"
-                highlight-current-row="true"   border @selection-change="handleSelectionChange" 
+                highlight-current-row="true"   border @selection-change="handleSelectionChange" id="table"
                 :row-style="{ height: '20px' }"  :header-cell-style="{ padding: '0px' }"
                 :cell-style="{ padding: '0px' }" :header-row-style="{ height: '20px' }"
                 :show-overflow-tooltip="true" @row-click="Click" @row-dblclick="doubleClick">
-                <el-table-column type="selection" width="55" />
-                <!-- 循环渲染列 -->
-                  <el-table-column
-                    v-for=" column in tableColumns "
-                    :key="column.prop"
-                    :prop="column.prop"
-                    :label="column.label"
-                    :width="column.width"
-                    sortable
-                    show-overflow-tooltip="true"/>
+                <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="款式" 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="颜色" width="100" />
+                <el-table-column align="left"  label="数量" prop="数量" width="80" />
+                <el-table-column align="left"  label="计划用料" prop="计划用料" width="100" />
+                <el-table-column align="left"  label="实际用料" prop="实际用料" width="100" />
+                <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="组别" width="120" />
+                <el-table-column align="left"  label="操作人员" prop="Sys_id" width="120" />
+                <el-table-column align="left"  label="创建时间" prop="Sys_rq" width="120" />
+
+                
               </el-table>
               <!-- 分页 -->
               <div class="gva-pagination">
@@ -49,64 +55,139 @@
             </div>
 			
 		<!-- 弹出框 -->
-		  <el-dialog v-model="dialogFormVisible" :before-close="closeDialog" :title="type === 'create' ? '裁剪次片汇总报工页面' : '裁剪次片汇总报工修改'"
-		    destroy-on-close style="width: 90%; height: 90%; margin-top: 3%;">
-		    
-		    <el-form :model="formData" label-position="right" ref="elFormRef":rules="rule" label-width="120px">
-		      
-		      <el-row :gutter="24" style="margin-bottom: 20px;" >
-		        <!-- 日期选择框 -->
-		        <el-col :span="8">
-		          <el-form-item label="日期">
-		            <el-date-picker v-model="DefectiveformData['Sys_rq']" id="日期" style="width: 100%;" type="date" />
-		          </el-form-item>
-		        </el-col>
-		      </el-row>
-		
-		      <!-- 新增一行按钮 -->
-		      <el-button type="primary" @click="addRow" style="margin-left: 20px; margin-bottom: 20px;">新增一行</el-button>
-		
-		      <el-row :gutter="24"> 
-		        <el-col :span="19" style="margin-bottom: 15px;">
-		          <!-- 表格头部 -->
-		        <div style="display: flex; justify-content: space-between; margin-bottom: 10px;">
-		          <span style="flex: 1;">订单编号|款号</span>
-		          <span style="flex: 1;">面料分类|面料名称</span>
-				  <span style="flex: 1;">颜色</span>
-		          <span style="flex: 1;">款号|款式</span>
-		          <span style="flex: 1;">次片数量</span>
-				  <span style="flex: 1;">次片问题</span>
-				  <span style="flex: 1;">备注</span>
-		          <span style="flex: 1;">报工小组</span>
-		        </div>
-		        </el-col>
-		        
-		        <!-- 使用v-for渲染行 -->
-		        <el-col v-for="(row, index) in rows" :key="index" :span="19" style="margin-bottom: 10px; overflow-x: auto;">
-		          <div style="display: flex; justify-content: space-between; align-items: center;">
-		            <el-input style="width: 220px;" placeholder="Enter回车" v-model="row.gdbh" @blur="getGxMcsubmit($event, index)" />
-		            <el-input style="width: 140px;" v-model="row.khks" />
-					<el-input style="width: 140px;"  v-model="row.color" />
-					<el-input style="width: 140px;"  v-model="row.cpsl" />
-					<el-input style="width: 140px;"  v-model="row.color" />
-					<el-input style="width: 140px;" v-model="row.color" />
-		            <el-input style="width: 140px;" v-model="row.bgxz" />
-					<el-button type="primary" @click="removeRow(index)" style="font-size: 18px;">复制本条</el-button>
-		            <el-button type="danger" @click="removeRow(index)" style="font-size: 18px;">移除</el-button>
-		          </div>
-		        </el-col>
-		      </el-row>
-		      
-		    </el-form>
-		
-		    <template #footer>
-		      <div class="dialog-footer" style="width: 100%;">
-		        <el-button @click="closeDialog" style="width: 100px;height: 40px;">关 闭</el-button>
-		        <el-button type="primary" @click="enterDialog"  style="width: 100px;height: 40px;">确 定</el-button>
-		      </div>
-		    </template>
-		  </el-dialog>
+    <el-dialog
+  v-model="dialogFormVisible"
+  :before-close="closeDialog"
+  :title="type === 'create' ? '裁剪次片汇总报工页面' : '裁剪次片汇总报工修改'"
+  destroy-on-close
+  style="width: 90%; height: 90%; margin-top: 3%;"
+>
+  <el-form :model="formData" label-position="right" ref="elFormRef" :rules="rule" label-width="120px">
+    <!-- 日期选择框 -->
+    <el-row :gutter="24" style="margin-bottom: 20px;">
+      <el-col :span="8">
+        <el-form-item label="日期">
+          <el-date-picker v-model="DefectiveformData['Sys_rq']" style="width: 100%;" type="date" />
+        </el-form-item>
+      </el-col>
+    </el-row>
+
+    <!-- 新增一行按钮 -->
+    <el-button type="primary" @click="addRow" style="margin-left: 20px; margin-bottom: 20px;">新增一行</el-button>
+
+    <!-- 表格区域 -->
+    <el-table
+      :data="SecondarytabeleData"
+      border
+      style="width: 100%; margin-bottom: 20px;"
+      :row-style="{ height: '40px' }"
+      :header-cell-style="{ padding: '0px' }"
+      :cell-style="{ padding: '0px' }"
+      :header-row-style="{ height: '40px' }"
+      :show-overflow-tooltip="true"
+    >
+      <!-- 订单编号|款号 -->
+      <el-table-column label="订单编号|款号" width="220">
+        <template #default="{ row, $index }">
+          <el-input v-model="row.ddbh" placeholder="Enter回车" @keyup.enter="getGxMcsubmit($event, $index)" />
+        </template>
+      </el-table-column>
+
+      <!-- 面料分类|面料名称 -->
+      <el-table-column label="面料分类|面料名称" width="220">
+        <template #default="{ row }">
+          <el-select v-model="row.material" placeholder="请选择面料" clearable>
+            <el-option
+              v-for="material in row.materialOptions"
+              :key="material.value"
+              :label="material.label"
+              :value="material.value"
+            />
+          </el-select>
+        </template>
+      </el-table-column>
+
+      <!-- 颜色 -->
+      <el-table-column label="颜色" width="100">
+        <template #default="{ row }">
+          <el-select v-model="row.color" placeholder="请选择颜色" clearable>
+            <el-option
+              v-for="color in row.colorOptions"
+              :key="color.value"
+              :label="color.label"
+              :value="color.value"
+            />
+          </el-select>
+        </template>
+      </el-table-column>
+
+      <!-- 款号|款式 -->
+      <el-table-column label="款式" width="120">
+        <template #default="{ row }">
+          <el-input v-model="row.ks" />
+        </template>
+      </el-table-column>
+
+      <!-- 次片数量 -->
+      <el-table-column label="次片数量" width="100">
+        <template #default="{ row }">
+          <el-input v-model="row.defectiveQuantity" />
+        </template>
+      </el-table-column>
+
+      <!-- 次片问题 -->
+      <el-table-column label="次片问题" width="140">
+        <template #default="{ row }">
+          <el-select v-model="row.issue" placeholder="请选择次片问题" clearable>
+            <el-option
+              v-for="issue in row.issueOptions"
+              :key="issue.value"
+              :label="issue.label"
+              :value="issue.value"
+            />
+          </el-select>
+        </template>
+      </el-table-column>
 
+      <!-- 备注 -->
+      <el-table-column label="备注" width="220">
+        <template #default="{ row }">
+          <el-input v-model="row.remark" />
+        </template>
+      </el-table-column>
+
+      <!-- 报工小组 -->
+      <el-table-column label="报工小组" width="120">
+        <template #default="{ row }">
+          <el-select v-model="row.group" placeholder="请选择报工小组" clearable>
+            <el-option
+              v-for="group in row.groupOptions"
+              :key="group.value"
+              :label="group.label"
+              :value="group.value"
+            />
+          </el-select>
+        </template>
+      </el-table-column>
+
+      <!-- 操作列 -->
+      <el-table-column label="操作" width="220" fixed="right">
+        <template #default="{ row, $index }">
+          <el-button type="primary" @click="copyRow($index)" style="font-size: 18px;">复制本条</el-button>
+          <el-button type="danger" @click="removeRow($index)" style="font-size: 18px;">移除</el-button>
+        </template>
+      </el-table-column>
+    </el-table>
+  </el-form>
+
+  <!-- 弹窗底部按钮 -->
+  <template #footer>
+    <div class="dialog-footer" style="width: 100%;">
+      <el-button @click="closeDialog" style="width: 100px; height: 40px;">关 闭</el-button>
+      <el-button type="primary" @click="enterDialog" style="width: 100px; height: 40px;">确 定</el-button>
+    </div>
+  </template>
+</el-dialog>
   
           </el-main>
         </el-container>
@@ -115,11 +196,15 @@
   </template>
 <script setup>
 // 全量引入格式化工具 请按需保留
-import { ElMessage, ElMessageBox, LAST_KEYS } from 'element-plus'
+import { ElMessage, ElMessageBox, LAST_KEYS } from 'element-plus';
+import * as XLSX from 'xlsx';
+import FileSaver from 'file-saver';
 import { Search, Refresh, Download } from '@element-plus/icons-vue'
 import { ref, reactive, nextTick, onMounted, onBeforeMount } from 'vue'
 import { Layout, LayoutContent, LayoutHeader, LayoutSider } from '@arco-design/web-vue'
+import {queryOrderSize,ApiAddDefective,ApiMouthlist,ApiSubPieceAndReworkList, search} from '@/api/mes/job'
 import { useUserStore } from '@/pinia/modules/user'
+// import { el } from 'element-plus/es/locale'
 //获取登录用户信息
 const userStore = useUserStore()
 const _username = ref('')
@@ -138,37 +223,146 @@ const currentDates = `${year}-${month}-${day}`;
 
 // 侧边栏数据请求
 const treeData = reactive([]);
+
 const getTabdata = async () => {
- 
-}
+  try {
+    const response = await ApiMouthlist({ code: '次片' });
+    if (response.code === 0) {
+      // 清空数组
+      treeData.splice(0, treeData.length);
+      
+      // 转换接口数据为树形结构
+      const formattedData = Object.entries(response.data).map(([year, months]) => ({
+        label: year,
+        children: Object.entries(months).map(([month, days]) => ({
+          label: month,
+          children: days.map(day => ({
+            label: day
+          }))
+        }))
+      }));
+      
+      treeData.push(...formattedData);
+      
+      console.log('转换后的树形数据:', treeData); // 调试用
+    } else {
+      ElMessage.error(response.msg || '获取数据失败');
+    }
+  } catch (error) {
+    console.error('请求错误:', error);
+    ElMessage.error('请求失败,请稍后重试');
+  }
+};
+
 getTabdata();
 
 
+const tableData = reactive([]);
+const loading = ref(false);
+
+const handleNodeClick = async (node) => {
+  if (!node.children) {
+    loading.value = true;
+    try {
+      const response = await ApiSubPieceAndReworkList({
+        Sys_rq: node.label, 
+        page: 1,
+        limit: 50,
+        code: '次片'
+      });
+      
+      if (response.code === 0 && response.data?.data) {
+        // 清空并更新表格数据
+        tableData.splice(0, tableData.length, ...response.data.data);
+      } else {
+        ElMessage.warning(response.msg || '暂无数据');
+        tableData.splice(0, tableData.length);
+      }
+    } catch (error) {
+      console.error('加载数据失败:', error);
+      ElMessage.error('数据加载失败');
+    } finally {
+      loading.value = false;
+    }
+  }
+};
+
+const searchinfo = ref('');
+//回车搜索
+const keydown_onSearch = async (event) => {
+	if(event.keyCode === 13){
+    const response = await ApiSubPieceAndReworkList({
+        search: searchinfo.value, 
+        page: 1,
+        limit: 50,
+        code: '次片'
+      });
+      if (response.code === 0 && response.data?.data) {
+        // 清空并更新表格数据
+        tableData.splice(0, tableData.length, ...response.data.data);
+      } else {
+        ElMessage.warning(response.msg || '暂无数据');
+        tableData.splice(0, tableData.length);
+      }
+	}
+}
 
 /**
  * 新增次品
 */
 const dialogFormVisible = ref(false);
-
-
-
-
 const DefectiveformData = reactive({
   Sys_rq: '' ,
   bgxz: '裁剪01z组'
 });
 const rule = {}; // 表单验证规则(如果有)
-const rows = reactive([
-  { gdbh: '', yjGx: '', gxmc: '', cpmc: '' }, // 初始一行
+const GROUP_OPTIONS = [
+  { value: '裁剪01组', label: '裁剪01组' },
+  { value: '裁剪02组', label: '裁剪02组' },
+  { value: '裁剪03组', label: '裁剪03组' },
+  { value: '裁剪04组', label: '裁剪04组' }
+];
+const SecondarytabeleData = reactive([
+  { 
+    ddbh: '',       // 订单编号
+    material: '',   // 面料分类
+    colorOptions: [],      // 颜色
+    ks: '',         // 款式
+    defectiveQuantity: '', // 次片数量
+    issueOptions: [], // 次片问题(下拉框选项)
+    remark: '',     // 备注
+    group: '裁剪01组',      // 报工小组
+  },
 ]);
-
+// 定义初始行数据
+const initialRowData = () => ({ 
+  ddbh: '',       // 订单编号
+  material: '',   // 面料分类
+  colorOptions: [],      // 颜色
+  ks: '',         // 款式
+  defectiveQuantity: '', // 次片数量
+  issueOptions: [], // 次片问题(下拉框选项)
+  remark: '',     // 备注
+  group: '裁剪01组',      // 报工小组
+});
 // 方法:新增一行
 const addRow = () => {
-  rows.push({ gdbh: '', yjGx: '', gxmc: '', cpmc: '' });
+  SecondarytabeleData.push({ 
+    ddbh: '',       // 订单编号
+    material: '',   // 面料分类
+    colorOptions: [],     // 颜色
+    ks: '',         // 款式
+    defectiveQuantity: '', // 次片数量
+    issueOptions: [], // 次片问题(下拉框选项)
+    remark: '',     // 备注
+    group: '裁剪01组',      // 报工小组
+  });
 };
 
+const type = ref('create'); // 弹窗类型,默认为 'create'
 //新增按钮
 const onAdd = async () => {
+  type.value = 'create'
 	dialogFormVisible.value = true
 	DefectiveformData.Sys_rq = currentDates
 }
@@ -179,28 +373,149 @@ const ent1 = (event, index) => {
   console.log(event, index);
 };
 
-// 失去焦点事件
-const getGxMcsubmit = async (row) => {
-  // 处理失去焦点事件
-  console.log('处理失去焦点', row);
+// 工单编号|款号回车事件
+const getGxMcsubmit = async (event, index) => {
+  const row = SecondarytabeleData[index]; // 获取当前行数据
+  const ddbh = row.ddbh; // 获取输入的工单编号
+
+  if (!ddbh) {
+    ElMessage.warning('请输入工单编号');
+    return;
+  }
+
+  try {
+    // 调用接口获取数据
+    const response = await queryOrderSize({ 订单编号: ddbh });
+
+    if (response.code === 0) {
+      const { list, fetchCategory, colorremark, FabricData, 面料统计 } = response.data;
+
+      // 更新当前行的数据
+      row.ddbh = `${list.订单编号}|${list.生产款号}`;
+      row.ks = list.款式;
+      // 更新下拉框选项
+      row.colorOptions = colorremark.map(item => ({ value: item, label: item })); // 颜色选项
+      row.issueOptions = fetchCategory.map(item => ({ value: item, label: item })); // 次片问题选项
+      row.materialOptions = FabricData.map(item => ({ value: item, label: item }));
+      row.groupOptions = GROUP_OPTIONS;// 报工小组选项
+      // 保存面料统计数据
+      row.fabricStats = 面料统计;
+      
+      ElMessage.success('数据加载成功');
+    } else {
+      ElMessage.error(response.msg || '接口返回错误');
+    }
+  } catch (error) {
+    ElMessage.error('接口调用失败,请稍后重试');
+  }
 };
 
 // 关闭弹窗
 const closeDialog = () => {
+  SecondarytabeleData.splice(0, SecondarytabeleData.length, initialRowData());
   dialogFormVisible.value = false;
 };
 
 // 提交确认
-const enterDialog = () => {
-  console.log('确认提交', formData, rows);
+const enterDialog = async () => {
+  console.log('确认提交', SecondarytabeleData);
+  
+  // 获取面料统计数据
+  const fabricStats = SecondarytabeleData[0]?.fabricStats || [];
+  console.log('fabricStats', fabricStats);
+
+  const params = SecondarytabeleData.map(item => {
+    // 查找匹配的面料数据
+    console.log('物料名称', item['material'].split('-')[1]);
+    console.log('颜色', item.color);
+    const matchedFabric = fabricStats.find(f => 
+      f.颜色 === item.color && f.物料名称 === item['material'].split(' - ')[1]
+    );
+    console.log('匹配统计数据', matchedFabric);
+    return {
+      订单编号: item['ddbh'].split('|')[0],
+      生产款号: item['ddbh'].split('|')[1],
+      款式: item['ks'],
+      颜色: item['color'],
+      数量: item['defectiveQuantity'],
+      备注: item['remark'],
+      Sys_id: userStore.userInfo.nickName,
+      组别: item['group'],
+      Sys_rq: currentDates,
+      sczl_rq: currentDate,
+      状态: '次片',
+      问题分类: item['issue'],
+      尺码: '',
+      实际用料: matchedFabric ? matchedFabric.实际用料 : '', 
+      计划用料: matchedFabric ? matchedFabric.计划用料 : '', 
+      物料名称: item['material'],
+    };
+  });
+
+  console.log('提交参数', params);
+  try {
+    // 在这里执行提交逻辑
+    const ApiAddDefectiveRes = await ApiAddDefective(params);
+    if (ApiAddDefectiveRes.code === 0) {
+      ElMessage.success('提交成功');
+      closeDialog(); // 关闭弹窗	
+    } else {
+      ElMessage.error(ApiAddDefectiveRes.msg || '接口返回错误');	
+    }
+  } catch (error) {
+    ElMessage.error('提交失败,请稍后重试');
+  }
 };
 
+
+// 复制行
+const copyRow = (index) => {
+  const copiedRow = { ...SecondarytabeleData[index] };
+  SecondarytabeleData.splice(index + 1, 0, copiedRow);
+};
 // 移除行
 const removeRow = (index) => {
-  rows.splice(index, 1);
-};
-
+  SecondarytabeleData.splice(index, 1);	
+}
 
+//导出
+const exportExcel = () => {
+  const el = document.getElementById('table');
+  const filename = '导出次片EXCEL.xlsx';
+  
+  // 获取表格数据
+  const ws = XLSX.utils.table_to_sheet(el);
+  
+  // 找出需要保留为数字的列(假设'sl'列是数字)
+  const numCols = ['数量']; // 添加其他需要保留数字的列名
+  
+  // 遍历工作表数据,将指定列转换为数字
+  for (const cell in ws) {
+    if (cell[0] === '!') continue; // 跳过特殊属性
+    
+    const colName = cell.replace(/[0-9]/g, ''); // 获取列字母
+    const header = ws[colName + '1']; // 获取表头
+    
+    if (header && numCols.includes(header.v)) {
+      // 如果是数字列,尝试转换为数字
+      const value = ws[cell].v;
+      if (!isNaN(value) && value !== '') {
+        ws[cell].t = 'n'; // 设置为数字类型
+        ws[cell].v = Number(value); // 转换为数字
+      }
+    }
+  }
+  
+  // 创建工作簿并导出
+  const wb = XLSX.utils.book_new();
+  XLSX.utils.book_append_sheet(wb, ws, "Sheet1");
+  
+  try {
+    XLSX.writeFile(wb, filename);
+  } catch (e) {
+    console.log(e);
+  }
+}
 </script>
   
   <style>
@@ -261,12 +576,6 @@ const removeRow = (index) => {
       background: #ff80ff !important;
   }
 
-  /* 屏幕宽度小于 768px 时调整样式 */
-  :deep(@media (max-width: 1280px)) {
-    .el-dialog {
-      width: 90vw;
-      height: 90vh;
-    }
-  }
+
 
   </style>