zck 7 месяцев назад
Родитель
Сommit
0bda60b21a

+ 29 - 1
src/api/jixiaoguanli/caiwubaobiao.js

@@ -136,4 +136,32 @@ export const SummaryCostAccountingList = (params) => {
       method: 'get',
       params
     })
-}
+}
+
+//v23财务--各月水电气列表
+export const UtilitiesList = (params) => {
+  return service({
+    url:'/mes_server/Cost_Accounting/UtilitiesList',
+    method: 'get',
+    params
+  })
+}
+
+//v23财务--创建各月水电气分摊
+export const UtilitiesAdd = (data) => {
+  return service({
+    url:'/mes_server/Cost_Accounting/UtilitiesAdd',
+    method: 'post',
+    data
+  })
+}
+
+//v23财务--水电气分摊费用下方明细列表
+export const shuidianqiMachineDetailList = (params) => {
+  return service({
+    url:'/mes_server/Cost_Accounting/shuidianqiMachineDetailList',
+    method: 'get',
+    params
+  })
+}
+

+ 1 - 1
src/view/v23financial/v23CostSummary.vue

@@ -188,7 +188,7 @@ const ToExcel = async () => {
           if (!isNaN(numValue)) {
             worksheet[cellAddress].t = 'n'; // 数字类型
             worksheet[cellAddress].v = numValue; // 更新值
-            worksheet[cellAddress].z = '0.000'; // 数字格式
+            // worksheet[cellAddress].z = '0.000'; // 数字格式
           }
         }
       }

+ 491 - 41
src/view/v23financial/v23Costmaintenance.vue

@@ -9,11 +9,12 @@
                 <!-- <el-input v-model="searchInfo" placeholder="搜索工单编号" clearable style="width: 200px;margin: 5px"></el-input>
                 <el-button type="primary" class="bt" icon="edit" @click="onout">月度费用结构建立</el-button>
                 <el-button type="primary" class="bt" icon="edit" @click="onout">月度费用处理</el-button>
-                <el-button type="primary" class="bt" icon="edit" @click="onout">创建</el-button>
-                <el-button type="primary" class="bt" icon="edit" @click="onout">月度人工维护</el-button>
+                <el-button type="primary" class="bt" icon="edit" @click="onout">创建</el-button> -->
+                <el-button type="primary" class="bt" icon="edit" :disabled="tableStates.showrgdownTable === false" @click="onartificial">月度人工维护</el-button>
+                <el-button type="primary" class="bt" icon="edit" :disabled="tableStates.showsdqftupTable === false" @click="onsdqft">水电气分摊批量维护</el-button>
                 <el-button type="primary" class="bt" icon="download" @click="hzToExcel" >导出到Excel(汇总)</el-button>
                 <el-button type="primary" class="bt" icon="download" @click="mxToExcel" >导出到Excel(明细)</el-button>
-                <el-button type="primary" class="bt" icon="edit" @click="onforms">能耗报表</el-button> -->
+                <!-- <el-button type="primary" class="bt" icon="edit" @click="onforms">能耗报表</el-button> -->
 
               </el-form-item>
             </el-form>
@@ -44,7 +45,7 @@
                         :row-style="{ height: '25px' }"  :header-cell-style="{ padding: '0px' }"
                         :cell-style="{ padding: '0px' }" :header-row-style="{ height: '20px' }"
                         :data="rguptableData"  border row-key="ID"
-                        size="small"
+                        size="small" id="up-rg"
                         :cell-class-name="gxbgCellClass"
                         highlight-current-row="true" @row-dblclick="updateCompanyFunc"
                         @row-click="rguptableRowClick" :show-overflow-tooltip="true"
@@ -66,7 +67,7 @@
                         :row-style="{ height: '25px' }"  :header-cell-style="{ padding: '0px' }"
                         :cell-style="{ padding: '0px' }" :header-row-style="{ height: '20px' }"
                         :data="rgdowntableData"  border row-key="ID"
-                        size="small"
+                        size="small" id="down-rg"
                         :cell-class-name="gxbgCellClass"
                         highlight-current-row="true" @row-dblclick="updateCompanyFunc"
                         @row-click="tableRowClick" :show-overflow-tooltip="true"
@@ -92,8 +93,7 @@
                         :row-style="{ height: '25px' }"  :header-cell-style="{ padding: '0px' }"
                         :cell-style="{ padding: '0px' }" :header-row-style="{ height: '20px' }"
                         :data="sdqzjuptableData"  border row-key="ID"
-
-                        size="small"
+                        size="small" id="up-sdqzj"
                         :cell-class-name="gxbgCellClass"
                         highlight-current-row="true" @row-dblclick="updateCompanyFunc"
                         @row-click="sdqzjuptableRowClick" :show-overflow-tooltip="true"
@@ -118,7 +118,7 @@
                         :row-style="{ height: '25px' }"  :header-cell-style="{ padding: '0px' }"
                         :cell-style="{ padding: '0px' }" :header-row-style="{ height: '20px' }"
                         :data="sdqzjdowntableData"  border row-key="ID"
-                        size="small"
+                        size="small" id="down-sdqzj"
                         :cell-class-name="gxbgCellClass"
                         highlight-current-row="true" @row-dblclick="updateCompanyFunc"
                         @row-click="tableRowClick" :show-overflow-tooltip="true"
@@ -141,7 +141,7 @@
                         :row-style="{ height: '25px' }"  :header-cell-style="{ padding: '0px' }"
                         :cell-style="{ padding: '0px' }" :header-row-style="{ height: '20px' }"
                         :data="sdqftuptableData"  border row-key="ID"
-                        size="small"
+                        size="small" id="up-sdqft"
                         :cell-class-name="gxbgCellClass"
                         highlight-current-row="true" @row-dblclick="updateCompanyFunc"
                         @row-click="sdqftuptableRowClick" :show-overflow-tooltip="true"
@@ -163,7 +163,7 @@
                         :row-style="{ height: '25px' }"  :header-cell-style="{ padding: '0px' }"
                         :cell-style="{ padding: '0px' }" :header-row-style="{ height: '20px' }"
                         :data="sdqftdowntableData"  border row-key="ID"
-                        size="small"
+                        size="small" id="down-sdqft"
                         :cell-class-name="gxbgCellClass"
                         highlight-current-row="true" @row-dblclick="updateCompanyFunc"
                         @row-click="tableRowClick" :show-overflow-tooltip="true"
@@ -171,7 +171,7 @@
                <el-table-column  sortable align="center" label="设备编号" prop="设备编号"  width="120" />
                <el-table-column  sortable align="center" label="设备名称" prop="设备名称"  width="120" />
                <el-table-column  sortable align="center" label="通电工时_全部" prop="通电工时_全部"  width="200" />
-               <el-table-column  sortable align="center" label="通电工时_成本" prop="通电工时_成本"  width="100" />
+               <el-table-column  sortable align="center" label="通电工时_成本" prop="通电工时_成本"  width="200" />
                <el-table-column  sortable align="center" label="年月" prop="年月"  width="100" />
                <el-table-column  sortable align="center" label="科目名称" prop="科目名称"  width="100" />
                <el-table-column  sortable align="center" label="使用部门" prop="使用部门"  width="100" />
@@ -207,7 +207,7 @@
                         :row-style="{ height: '25px' }"  :header-cell-style="{ padding: '0px' }"
                         :cell-style="{ padding: '0px' }" :header-row-style="{ height: '20px' }"
                         :data="sdsuptableData"  border row-key="ID"
-                        size="small"
+                        size="small" id="up-sds"
                         :cell-class-name="gxbgCellClass"
                         highlight-current-row="true" @row-dblclick="updateCompanyFunc"
                         @row-click="sdsuptableRowClick" :show-overflow-tooltip="true"
@@ -222,7 +222,7 @@
                         :row-style="{ height: '25px' }"  :header-cell-style="{ padding: '0px' }"
                         :cell-style="{ padding: '0px' }" :header-row-style="{ height: '20px' }"
                         :data="sdsdowntableData"  border row-key="ID"
-                        size="small"
+                        size="small" id="down-sds"
                         :cell-class-name="gxbgCellClass"
                         highlight-current-row="true" @row-dblclick="updateCompanyFunc"
                         @row-click="tableRowClick" :show-overflow-tooltip="true"
@@ -246,6 +246,81 @@
                <el-table-column  sortable align="center" label="创建时间" prop="Sys_Rq"  width="110" /> 
               </el-table>
 
+
+              <el-dialog v-model="rgsjlist" title="月度车间人工维护"  style="width: 100%;height: 100%;margin: 0px;padding: 0px">
+                <el-button type="primary" @click="rgsjConfirm":class="{ 'confirm-btn': true, 'is-new': isNewData }">{{ isNewData ? '新增' : '更新' }}</el-button>
+            <el-button type="" @click="rgsjCancel">退出</el-button>
+            <div style="width: 100%; height: 60px; padding: 0px; margin: 10px 0px 0px 0px; display: flex; align-items: center;">
+              <el-form-item label="年月份:" prop="currentProcess" style="margin-right: 20px; padding: 0px">
+                <el-input v-model="_noderq"
+                @keyup.enter="rgsjgetProductValue" style="width: 200px;"/>
+              </el-form-item>
+            </div>
+            <el-table ref="paichengRef"
+                      :show-overflow-tooltip="true"
+                      :row-style="{ height: '0px' }"
+                      :cell-style="{ padding: '0px' }" :header-row-style="{ height: '0px' }"
+                      :header-cell-style="{ padding: '0px' }"
+                      style="width: 100%;height: 74vh" border tooltip-effect="dark"
+                      :data="rgsjtableData" row-key="ID"
+                      :cell-class-name="rgsjCellClass">
+              <template v-for="(item, idx) in rgsj_tableColumns">
+                <el-table-column #default="{ row, column, $index }" align="left" :label="item.label" :width="item.width" >
+                  <div v-if="['一线工资总额',].includes(item.prop)">
+                    <el-input v-model="row[item.prop]" :clearable="false"
+                              :id="`input${idx}${$index}`" @keyup="zjfpxs_handleKeyDown($event, idx, $index, item.prop)"/>
+                  </div>
+                  <div v-else>{{ row[item.prop] }}</div>
+                </el-table-column>
+              </template>
+            </el-table>
+          </el-dialog>
+
+          <el-dialog v-model="sdqftlist" title="水电气分推批量维护"  style="width: 100%;height: 100%;margin: 0px;padding: 0px">
+                <el-button type="primary" @click="sdqftConfirm":class="{ 'confirm-btn': true, 'is-new': isNewData }">{{ isNewData ? '新增' : '更新' }}</el-button>
+            <el-button type="" @click="sdqftCancel">退出</el-button>
+            <el-button type="primary" icon="plus" @click="add_sdqftenterDialog">新增一行</el-button>
+            <div style="width: 100%; height: 60px; padding: 0px; margin: 10px 0px 0px 0px; display: flex; align-items: center;">
+              <el-form-item label="年月份:" prop="currentProcess" style="margin-right: 20px; padding: 0px">
+                <el-input v-model="_noderq"
+                @keyup.enter="sdqftgetProductValue" style="width: 200px;"/>
+              </el-form-item>
+            </div>
+            <el-table ref="paichengRef"
+                      :show-overflow-tooltip="true"
+                      :row-style="{ height: '0px' }"
+                      :cell-style="{ padding: '0px' }" :header-row-style="{ height: '0px' }"
+                      :header-cell-style="{ padding: '0px' }"
+                      style="width: 100%;height: 74vh" border tooltip-effect="dark"
+                      :data="sdqfttableData" row-key="ID"
+                      :cell-class-name="sdqftCellClass">
+              <template v-for="(item, idx) in sdqft_tableColumns">
+                <el-table-column #default="{ row, column, $index }" align="left" :label="item.label" :width="item.width">
+  <div v-if="['耗电量','单位电价','耗气量','单位气价','部门名称','科目名称'].includes(item.prop)">
+    <el-input 
+      v-model="row[item.prop]" 
+      :clearable="false"
+      :disabled="!row.isNew && ['部门名称','科目名称'].includes(item.prop)"
+      :id="`input${idx}${$index}`"
+      @keyup="sdqft_handleKeyDown($event, idx, $index, item.prop)"/>
+  </div>
+  <div v-else>{{ row[item.prop] }}</div>
+</el-table-column>
+              </template>
+
+              <el-table-column fixed="right" label="操作" width="80">
+					  <template #default="{ row, $index }">
+						<el-button @click="record_deleteRow(row,$index)" type="danger" size="small" 
+								   style="font-size: 16px;padding: 0px;width: 60px;background-color: red;">
+						  删除
+						</el-button>
+					  </template>
+					</el-table-column>
+            </el-table>
+          </el-dialog>
+
+
+
           </el-main>
         </layout-content>
         </layout>
@@ -258,12 +333,18 @@
   
   import {ref, reactive} from 'vue'
   import {hiprint} from "vue-plugin-hiprint";
+  import { useUserStore } from '@/pinia/modules/user'
   import { exportExcelFile } from '@/utils/excel'
+  import * as XLSX from 'xlsx'
   import {GetZzTab,ArtificialAdd,ArtificialAddList,ArtificialEdit,ArtificialList,ArtificialDetailList,shuidianqiList,shuidianqiDetailList,
-    shuidianqifentanList,ChromaticityAdd,ChromaticityDetailAdd,ChromaticityDetailList,MonochromaticDetailList,
+    shuidianqifentanList,ChromaticityAdd,ChromaticityDetailAdd,ChromaticityDetailList,MonochromaticDetailList,UtilitiesList,UtilitiesAdd,shuidianqiMachineDetailList
   } from '@/api/jixiaoguanli/caiwubaobiao'
-  import {ElMessage} from "element-plus";
+  import {ElMessage,ElMessageBox} from "element-plus";
   defineOptions({name: 'Company'})
+  const userStore = useUserStore()
+  const _username = ref('')
+  _username.value = userStore.userInfo.userName + '/' + userStore.userInfo.nickName
+  
   // =========== 获取左侧树侧形结构 ===========
   const treeData = ref([])
 const getDepartmentData = async () => {
@@ -348,31 +429,6 @@ console.log(node)
   // 第二层:分类节点 (如 "202410-2、水电气直接费用")
   if (parts.length === 2) {
     // const category = parts[1]
-    
-    // if (category.includes('1、月度人工数据')) {
-    //   tableStates.showrgupTable = true
-    //   tableStates.showrgdownTable = true
-    //   loadRgData() // 加载人工数据
-    // } 
-    // else if (category.includes('2、水电气直接费用')) {
-    //   tableStates.showsdqzjupTable = true
-    //   tableStates.showsdqzjdownTable = true
-    //   loadSdqzjData() // 加载水电气直接费用数据
-    // }
-    // else if (category.includes('3、水电气分摊费用')) {
-    //   tableStates.showsdqftupTable = true
-    //   tableStates.showsdqftdownTable = true
-    //   loadSdqftData() // 加载水电气分摊费用数据
-    // }
-    // else if (category.includes('4、其他待摊费用')) {
-    //   tableStates.showqtdtTable = true
-    //   loadQtdtData() // 加载其他待摊费用数据
-    // }
-    // else if (category.includes('5、车间色度数')) {
-    //   tableStates.showsdsupTable = true
-    //   tableStates.showsdsdownTable = true
-    //   loadSdsData() // 加载车间色度数数据
-    // }
     return;
   }
 
@@ -495,6 +551,385 @@ const sdsuptableRowClick = async (row) => {
   }
 }
 
+const isNewData = ref(false);//新增or修改
+const rgsjlist = ref(false)
+const rgsjtableData = ref([]);
+const rgsj_tableColumns = ref(
+    [
+      { label: '车间', prop: '车间', width: '100' },
+      { label: '一线工资总额', prop: '一线工资总额', width: '140' },
+      { label: '创建用户', prop: '创建用户', width: '130' },
+      { label: '创建时间', prop: '创建时间', width: '160' },
+      { label: '修订时间', prop: '修订时间', width: '160' },
+    ]
+)
+const DEFAULT_WORKSHOPS = ['胶印车间', '凹丝印车间', '印后车间', '检验车间'];
+const onartificial = () => {
+  rgsjlist.value = true
+}
+
+const rgsjgetProductValue = () => {
+  if(_noderq.value === ''){
+    rgsjtableData.value = [];
+    ElMessage({type: 'warning',message: '年月份输入框为空'});
+    return false;
+  }
+  ArtificialAddListdata();
+};
+//月度人工数据->数据获取
+const ArtificialAddListdata = async ()=>{
+  let Sys_ny = _noderq.value;
+  try {
+    const ArtificialAdddata = await ArtificialAddList({Sys_ny:Sys_ny});
+    if(ArtificialAdddata.data.length === 0){
+      ElMessage({type: 'warning',message: '该月无数据,改为新增数据'});
+      rgsjtableData.value = DEFAULT_WORKSHOPS.map(workshop => ({
+      车间: workshop,
+      一线工资总额: '',
+      创建用户: '',
+      创建时间: '',
+      修订时间: ''
+}));
+isNewData.value = true;
+    }else{
+      rgsjtableData.value = ArtificialAdddata.data;
+      isNewData.value = false;
+    }
+  } catch (error) {
+    console.error(error);
+  }
+} 
+
+//月度人工数据【新增or更新】
+const rgsjConfirm = async () => {
+  if (isNewData.value) {
+    await handleAddData(); // 新增数据逻辑
+  } else {
+    await handleUpdateData(); // 更新数据逻辑
+  }
+};
+
+const handleAddData = async () => {
+  const rawValueArray = rgsjtableData._rawValue;
+  const formattedData = rawValueArray.map(item => {
+    return {
+      sys_ny: _noderq.value,
+      sys_id: userStore.userInfo.nickName,
+      sist: item.车间 !== null ? item.车间 : "",
+      number: item.一线工资总额 !== null ? item.一线工资总额 : "",
+    }
+  });
+  console.log(formattedData)
+  const ArtificialAdds = await ArtificialAdd(formattedData);
+  if (ArtificialAdds.code === 0) {
+    rgsjlist.value = false;
+    ElMessage({type: 'success',message: '新增成功'})
+  } else {
+    ElMessage({type: 'error',message: '新增失败'})
+  }
+};
+
+// 更新数据方法
+const handleUpdateData = async () => {
+  const rawValueArray = rgsjtableData._rawValue;
+  const formattedData = rawValueArray.map(item => {
+    return {
+      UniqID: item.UniqID,
+      number: item.一线工资总额 !== null ? item.一线工资总额 : "",
+    }
+  });
+  console.log(formattedData)
+  const ArtificialEdits = await ArtificialEdit(formattedData);
+  if (ArtificialEdits.code === 0) {
+    rgsjlist.value = false;
+    ElMessage({type: 'success',message: '更新成功'})
+  } else {
+    ElMessage({type: 'error',message: '更新失败'})
+  }
+};
+
+
+//月度人工数据【退出】
+const rgsjCancel = () => {
+  rgsjlist.value = false;
+};
+
+
+//水电气分摊
+
+const sdqftlist = ref(false)
+const sdqfttableData = ref([]);
+const sdqft_tableColumns = ref(
+    [
+      { label: '年月', prop: '年月', width: '100' },
+      { label: '部门名称', prop: '部门名称', width: '140' },
+      { label: '科目名称', prop: '科目名称', width: '130' },
+      { label: '耗电量', prop: '耗电量', width: '160' },
+      { label: '单位电价', prop: '单位电价', width: '160' },
+      { label: '耗气量', prop: '耗气量', width: '160' },
+      { label: '单位气价', prop: '单位气价', width: '160' },
+    ]
+)
+const SDQFT_WORKSHOPS = ['胶印车间', '凹丝印车间', '印后车间', '检验车间','制造中心','制造中心','制造中心','制造中心','制造中心','制造中心','制造中心','制造中心','制造中心'];
+const SDQFT_kmmc = ['待分摊总额','待分摊总额','待分摊总额','待分摊总额','废气处理(RTO)','锅炉','空压机A','空压机B','热水锅炉','真空鼓风机A','真空鼓风机B','中央空调A(6号楼)','中央空调B(5号楼)'];
+
+const onsdqft = () => {
+  sdqftlist.value = true
+}
+
+const sdqftgetProductValue = () => {
+  if(_noderq.value === ''){
+    sdqfttableData.value = [];
+    ElMessage({type: 'warning',message: '年月份输入框为空'});
+    return false;
+  }
+  UtilitiesListdata();
+};
+//月度人工数据->数据获取
+const UtilitiesListdata = async ()=>{
+  let Sys_ny = _noderq.value;
+  try {
+    const UtilitiesListdata = await UtilitiesList({month:Sys_ny});
+    if(UtilitiesListdata.data.length === 0){
+      sdqfttableData.value = SDQFT_WORKSHOPS.map(workshop => ({
+      年月: _noderq.value,
+      部门名称: workshop,
+      科目名称: SDQFT_kmmc,
+      耗电量: '',
+      单位电价: 0.690,
+      耗气量: '',
+      单位气价: ''
+}));
+    }else{
+      sdqfttableData.value = UtilitiesListdata.data;
+      isNewData.value = false;
+    }
+  } catch (error) {
+    console.error(error);
+  }
+} 
+
+//月度人工数据【更新】
+const sdqftConfirm = async () => {
+    await sdqft_handleUpdateData(); // 新增数据逻辑
+};
+
+const sdqft_handleUpdateData = async () => {
+  const rawValueArray = sdqfttableData._rawValue;
+  const formattedData = rawValueArray.map(item => {
+    return {
+      sys_ny: _noderq.value,
+      sys_id: userStore.userInfo.nickName,
+      sist: item.部门名称 !== null ? item.部门名称 : "",
+      耗电量: item.耗电量 !== null ? item.耗电量 : "",
+      科目名称: item.科目名称 !== null ? item.科目名称 : "",
+      单位电价: item.单位电价 !== null ? item.单位电价 : "",
+      耗气量: item.耗气量 !== null ? item.耗气量 : "",
+      单位气价: item.单位气价 !== null ? item.单位气价 : "",
+
+    }
+  });
+  console.log(formattedData)
+  const UtilitiesAdds = await UtilitiesAdd(formattedData);
+  if (UtilitiesAdds.code === 0) {
+    sdqftlist.value = false;
+    ElMessage({type: 'success',message: '更新成功'})
+  } else {
+    ElMessage({type: 'error',message: '更新失败'})
+  }
+};
+
+
+ //新增行
+ const add_sdqftenterDialog = async() => {
+	  // 创建一行空数据,字段值可以根据需求初始化
+		const newRow = {
+		  '年月': _noderq.value,
+		  '部门名称': '',
+		  '科目名称': '',
+		  '耗电量': '',
+		  '单位电价': '',
+		  '耗气量': '',
+		  '单位气价': '',
+      'isNew': true
+		};
+		if (!sdqfttableData.value || !Array.isArray(sdqfttableData.value)) {
+		  sdqfttableData.value = []; // 重新初始化
+		}
+		// 将新增的行数据推入到表格数据中
+		sdqfttableData.value.push(newRow);
+  }
+  
+  // 删除行
+  const record_deleteRow = async (row, index) => {
+	  // 使用 ElMessageBox 提示确认删除
+	  ElMessageBox.confirm('确定删除此行数据吗?', '提示', {
+		  confirmButtonText: '确定',
+		  cancelButtonText: '取消',
+		  type: 'warning'
+	  }).then(async () => {
+			  // 删除当前行数据
+			  sdqfttableData.value.splice(index, 1);
+			  ElMessage({
+				  type: 'success',
+				  message: '删除成功'
+			  });
+	  }).catch(() => {
+		  // 取消删除
+		  ElMessage({
+			  type: 'info',
+			  message: '已取消删除'
+		  });
+	  });
+  }
+
+
+
+//水电气分推【退出】
+const sdqftCancel = () => {
+  sdqftlist.value = false;
+};
+
+
+const exportExcel = async (isSummary) => {
+  try {
+    // 1. 获取当前显示的表格ID
+    const tableId = getCurrentTableId(isSummary);
+    if (!tableId) {
+      ElMessage.warning('没有找到可导出的表格');
+      return;
+    }
+
+    // 2. 获取表格DOM元素
+    const el = document.getElementById(tableId);
+    if (!el) {
+      ElMessage.warning('表格元素不存在');
+      return;
+    }
+
+    // 3. 转换表格数据
+    const worksheet = XLSX.utils.table_to_sheet(el, { raw: true });
+    
+    // 4. 智能数字类型转换
+    convertToNumbers(worksheet);
+
+    // 5. 创建并导出工作簿
+    const workbook = XLSX.utils.book_new();
+    XLSX.utils.book_append_sheet(workbook, worksheet, 'Sheet1');
+    
+    // 根据表格类型生成文件名
+    const fileName = generateFileName(tableId, isSummary);
+    XLSX.writeFile(workbook, fileName);
+    
+  } catch (error) {
+    console.error('导出失败:', error);
+    ElMessage.error('导出数据失败: ' + error.message);
+  }
+};
+
+// 获取当前应该导出的表格ID
+const getCurrentTableId = (isSummary) => {
+  // 特殊处理:只有一个表格的情况(其他待摊费用)
+  if (tableStates.showqtdtTable) {
+    return 'single-qtdt';
+  }
+
+  // 常规情况:根据按钮类型选择上下表格
+  const prefix = isSummary ? 'up-' : 'down-';
+  
+  // 检查当前显示的表格
+  const visibleTables = Object.keys(tableStates).filter(key => tableStates[key]);
+  
+  // 根据表格状态映射到对应的ID
+  const tableMap = {
+    showrgupTable: 'up-rg',
+    showrgdownTable: 'down-rg',
+    showsdqzjupTable: 'up-sdqzj',
+    showsdqzjdownTable: 'down-sdqzj',
+    showsdqftupTable: 'up-sdqft',
+    showsdqftdownTable: 'down-sdqft',
+    showsdsupTable: 'up-sds',
+    showsdsdownTable: 'down-sds'
+  };
+
+  // 找到第一个匹配的可见表格
+  for (const tableKey of visibleTables) {
+    if (tableMap[tableKey] && tableMap[tableKey].startsWith(prefix)) {
+      return tableMap[tableKey];
+    }
+  }
+  
+  return null;
+};
+
+// 生成导出文件名
+const generateFileName = (tableId, isSummary) => {
+  const now = new Date();
+  const dateStr = `${now.getFullYear()}${(now.getMonth()+1).toString().padStart(2,'0')}${now.getDate().toString().padStart(2,'0')}`;
+  
+  // 从tableId提取表格类型
+  const tableType = tableId.split('-')[1] || '';
+  
+  const typeMap = {
+    'rg': '人工数据',
+    'sdqzj': '水电气直接费用',
+    'sdqft': '水电气分摊费用',
+    'sds': '车间色度数',
+    'qtdt': '其他待摊费用'
+  };
+  
+  const typeName = typeMap[tableType] || '数据';
+  const suffix = isSummary ? '汇总' : '明细';
+  
+  return `${typeName}${suffix}_${dateStr}.xlsx`;
+};
+
+// 智能数字类型转换(优化版)
+const convertToNumbers = (worksheet) => {
+  const range = XLSX.utils.decode_range(worksheet['!ref']);
+  const headerRow = range.s.r;
+  
+  // 需要排除的列(表头包含这些关键词)
+  const excludeKeywords = ['年月', '时间', '工单', '编号', '名称', '用户'];
+  
+  // 1. 先识别要排除的列
+  const excludeCols = [];
+  for (let col = range.s.c; col <= range.e.c; col++) {
+    const cellAddress = XLSX.utils.encode_cell({ r: headerRow, c: col });
+    const headerCell = worksheet[cellAddress];
+    if (headerCell) {
+      const headerText = String(headerCell.v).toLowerCase();
+      if (excludeKeywords.some(kw => headerText.includes(kw.toLowerCase()))) {
+        excludeCols.push(col);
+      }
+    }
+  }
+  
+  // 2. 转换数字(跳过排除列)
+  for (let col = range.s.c; col <= range.e.c; col++) {
+    if (excludeCols.includes(col)) continue;
+    
+    for (let row = headerRow + 1; row <= range.e.r; row++) {
+      const cellAddress = XLSX.utils.encode_cell({ r: row, c: col });
+      if (worksheet[cellAddress]) {
+        const cellValue = worksheet[cellAddress].v;
+        const numValue = parseFloat(cellValue);
+        
+        if (!isNaN(numValue)) {
+
+          worksheet[cellAddress].t = 'n';
+          worksheet[cellAddress].v = numValue;
+          // worksheet[cellAddress].z = '#,##0.00'; // 可选:设置数字格式
+        }
+      }
+    }
+  }
+};
+
+// 按钮事件绑定
+const hzToExcel = () => exportExcel(true);  // 汇总导出
+const mxToExcel = () => exportExcel(false); // 明细导出
+
 
   
   let _table_print = ref([
@@ -934,8 +1369,19 @@ const onforms = () => {
 }
 
   
+const rgsjCellClass = ({row, column, rowIndex, columnIndex}) =>{
+  if (column.label === '一线工资总额') {
+    return 'background-plan-usage-low';
+  }
+} 
+
+const sdqftCellClass = ({row, column, rowIndex, columnIndex}) =>{
+  if (column.label === '耗电量' || column.label === '单位电价' || column.label === '耗气量'|| column.label === '单位气价' ) {
+
+    return 'background-plan-usage-low';
+  }
+}
 
-  
 
   
   
@@ -997,6 +1443,10 @@ const onforms = () => {
     flex: 1;
   }
 
+/*修正工单核算参数背景*/
+:deep(.el-table__body .background-plan-usage-low div div div) {
+  background: #80FA80 !important;
+}
   
   /* 选中某行时的背景色 */
   :deep(.el-table__body tr.current-row) > td {

+ 103 - 1
src/view/yunyin/shengchanguanli/shebeiyunxing.vue

@@ -205,6 +205,41 @@
 				  <el-table-column  v-for="time in columnNames" :key="time"  :label="time" :prop="time" align="center" width="80"  ></el-table-column>
 				</el-table>
 				</el-tab-pane>
+
+				<el-tab-pane label="印版管理" @click="showTable('印版管理')" name="fifth">
+              <el-table ref="multipleTable"
+                        highlight-current-row="true"
+                        :show-overflow-tooltip="true"
+                        :row-style="{ height: '20px' }"
+                        :cell-style="{ padding: '0px' }" :header-row-style="{ height: '20px' }"
+                        :header-cell-style="{ padding: '0px' }"
+                        @row-dblclick="ybupdateCompanyFunc"
+						@row-click="ybClick"
+                        style="width: 100%;height: 40vh" border tooltip-effect="dark" :data="ybtableData" row-key="ID" @selection-change="handleSelectionChange"
+              >
+                <el-table-column type="selection" width="30" />
+                <el-table-column align="left" sortable  label="方案" prop="YB_方案"  width="100"/>
+                <el-table-column align="left" sortable  label="印件号" prop="YB_Yjno" width="100" />
+                <el-table-column align="left" sortable  label="印版类别" prop="印版类别" width="110" />
+                <el-table-column align="left" sortable  label="存货编码" prop="存货编码" width="110"/>
+				<el-table-column align="left" sortable  label="供方批号" prop="供方批号" width="110"/>
+                <el-table-column align="left" sortable  label="印版名称" prop="印版名称"  width="440"/>
+                <el-table-column align="left" sortable  label="考核印数" prop="考核印数" width="110"/>
+				<el-table-column align="left" sortable  label="领用机台" prop="领用机台" width="110"/>
+				<el-table-column align="left" sortable  label="印数" prop="印数" width="110"/>
+                <el-table-column align="left" sortable  label="建档用户" prop="Sys_id" width="120" />
+                <el-table-column align="left" sortable  label="建档日期" prop="建档日期" width="160" />
+                <el-table-column align="left" sortable  label="更新日期" prop="更新日期" width="160" />
+				<el-table-column fixed="right" label="操作" width="80">
+					  <template #default="{ row, $index }">
+						<el-button @click="record_outRow(row,$index)" type="success" size="small" 
+								   style="font-size: 16px;padding: 0px;width: 60px;">
+						  领用
+						</el-button>
+					  </template>
+					</el-table-column>
+              </el-table>
+            </el-tab-pane>
 		  </el-tabs>
 	  </div>
 
@@ -2559,7 +2594,8 @@ import{
 	gdzl_MachineList,
 	getOrderProcessCount,
 	RejectionEdit,
-	JPchanliangDetailList
+	JPchanliangDetailList,
+	getProductData
   }  from "@/api/yunyin/yunying";
 import {
 MachineTeamAdd,
@@ -8545,7 +8581,9 @@ const finishedcode=ref()
 const _gdbhlist = ref('')
 const lcd_Gd_gdbh = ref(null)
 const lcd_Gd_yjno = ref(null)
+const ybtableData = reactive([])
 const yjupdateCompanyFunc = async(row) => {
+	console.log(row)
 	lcd_Gd_gdbh.value = row['工单编号|质量信息'].replace(/\|$/, '')
 	lcd_Gd_yjno.value = row['印件号'].slice(0, 2)
 	const Procedurelist = await Procedure({ Gd_gdbh: row['工单编号|质量信息'].replace(/\|$/, '') })
@@ -8557,8 +8595,72 @@ const yjupdateCompanyFunc = async(row) => {
 	formData.value.产品名称 = row.产品名称
 	_gdbhlist.value = row['工单编号|质量信息'].split('|')[0]
 	finishedcode.value=row.产品代号
+	const res = await getProductData({product_code:row.产品代号});
+	ybtableData.splice(0, ybtableData.length, ...res.data.ybData);
+	const response = await facilityPrintDetail({ workOrder: lcd_Gd_gdbh.value,code:'',productCode:row.产品代号,page:ybpage.value,limit:ybpageSize.value });
+    // 检查接口返回的状态码
+    if (response.code === 0) {
+	ybtotal.value = response.data.total
+	 yinbanselectData.value=response.data.data
+    }
 }
 
+//印版管理领用
+const record_outRow = async (row, index) => {
+
+	  console.log(row);
+  
+	  // 使用 ElMessageBox 提示确认删除
+	  ElMessageBox.confirm('确定领出此印版?', '提示', {
+		  confirmButtonText: '确定',
+		  cancelButtonText: '取消',
+		  type: 'warning'
+	  }).then(async () => {
+		  // 点击确认领出,检查当前机台是否为空
+		  if (row.领用机台 != null || row.供方批号 === null) {
+			  ElMessage({
+				  type: 'error',
+				  message: '此印版已停用或已被领用'
+			  });
+		  } else {
+			console.log('调用领出');
+
+			const requestData = [{
+      Yb_工单编号: formData.value?.工单编号 || '',
+      Yb_存货编码: row.存货编码 || '',
+      Yb_供方批号: row.供方批号 || '',
+      Yb_领用机台: JTMC || '',
+      Yb_印数: row.印数 ? Number(row.印数).toFixed(2) : "0.00",
+      Yb_印件号: row.YB_Yjno || '',
+      Sys_id: sys_id || ''
+    }];
+
+    console.log('领出请求参数:', requestData);
+
+			  const Bomdel_del = await PrintDetailAdd(requestData);
+			  if (Bomdel_del.code === 0) {
+				  ElMessage({
+					  type: 'success',
+					  message: '领出成功'
+				  });
+				  const res = await getProductData({product_code:cpcode.value});
+				  ybtableData.splice(0, ybtableData.length, ...res.data.ybData);
+			  } else {
+				  ElMessage({
+					  type: 'error',
+					  message: '领出失败'
+				  });
+			  }
+		  }
+	  }).catch(() => {
+		  // 取消删除
+		  ElMessage({
+			  type: 'info',
+			  message: '已取消删除'
+		  });
+	  });
+  }
+
 // 删除行
 const deleteCompanyFunc = async (row) => {
     const res = await deleteCompany({ ID: row.ID })