|
|
@@ -0,0 +1,635 @@
|
|
|
+<template>
|
|
|
+ <div>
|
|
|
+ <layout>
|
|
|
+ <layout-header>
|
|
|
+ <div class="">
|
|
|
+ <!-- 按钮部分-->
|
|
|
+ <el-form ref="elSearchFormRef" class="demo-form-inline" :rules="searchRule" >
|
|
|
+ <el-form-item>
|
|
|
+ <el-input v-model="searchInfo" placeholder="搜索工单编号" clearable style="width: 200px;margin: 5px"></el-input>
|
|
|
+ <el-button type="primary" class="bt" icon="download" @click="cbToExcel" >导出到Excel</el-button>
|
|
|
+ <el-button type="primary" class="bt" @click="onADD" >新增</el-button>
|
|
|
+ <el-button type="primary" class="bt" :disabled="!selectedIds" @click="onDelete" >删除</el-button>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ </div>
|
|
|
+ </layout-header>
|
|
|
+
|
|
|
+ <layout>
|
|
|
+ <!-- 左侧树侧形结构-->
|
|
|
+ <layout-sider :resize-directions="['right']" :width="190" style="margin-right: 10px;">
|
|
|
+ <div class="JKWTree-tree" style="height: 200px">
|
|
|
+ <h3>成本参数管理</h3>
|
|
|
+ <el-tree :data="treeData" :props="defaultProps" @node-click="handleNodeClick" @node-expand="handleNodeExpand">
|
|
|
+ </el-tree>
|
|
|
+ </div>
|
|
|
+ </layout-sider>
|
|
|
+
|
|
|
+ <!-- 右侧区域 -->
|
|
|
+ <layout-content >
|
|
|
+ <el-main>
|
|
|
+ <div class="gva-table-box">
|
|
|
+ <!-- 表格数据 -->
|
|
|
+ <el-table ref="multipleTable" style="width: 100%;height: 70vh" tooltip-effect="dark"
|
|
|
+ :row-style="{ height: '25px' }" :header-cell-style="{ padding: '0px' }"
|
|
|
+ :cell-style="{ padding: '0px' }" :header-row-style="{ height: '20px' }"
|
|
|
+ :data="cbtableData" border row-key="ID"
|
|
|
+ size="small" id="cbtable"
|
|
|
+ :cell-class-name="gxbgCellClass"
|
|
|
+ highlight-current-row="true" @row-dblclick="updateCompanyFunc"
|
|
|
+ @row-click="tableRowClick" :show-overflow-tooltip="true"
|
|
|
+ @selection-change="handleSelectionChange">
|
|
|
+ <el-table-column type="selection" width="30" />
|
|
|
+ <el-table-column sortable align="center" label="使用部门" prop="使用部门" width="120" />
|
|
|
+ <el-table-column sortable align="center" label="设备编号" prop="设备编号" width="120" />
|
|
|
+ <el-table-column align="center" label="设备名称" prop="设备名称" width="200" />
|
|
|
+ <el-table-column align="center" label="原值" prop="原值" width="100" />
|
|
|
+ <el-table-column align="center" label="年折旧额" prop="年折旧额" width="110" />
|
|
|
+ <el-table-column align="center" label="年折旧月数" prop="年折旧月数" width="100" />
|
|
|
+ <el-table-column align="center" label="月标准工时" prop="月标准工时" width="110" />
|
|
|
+ <el-table-column align="center" label="小时折旧额" prop="小时折旧额" width="110" />
|
|
|
+ <el-table-column align="center" label="最高限速" prop="最高限速" width="110" />
|
|
|
+ <el-table-column align="center" label="产能系数" prop="产能系数" width="110" />
|
|
|
+ <el-table-column align="center" label="MES地址" prop="MES地址" width="110" />
|
|
|
+ <el-table-column align="center" label="通讯口" prop="通讯口" width="110" />
|
|
|
+ <el-table-column align="center" label="通道号" prop="通道号" width="110" />
|
|
|
+ <el-table-column align="center" label="创建用户" prop="创建用户" width="110" />
|
|
|
+ <el-table-column align="center" label="创建时间" prop="创建时间" width="110" />
|
|
|
+ <el-table-column align="center" label="修改时间" prop="修改时间" width="110" />
|
|
|
+ </el-table>
|
|
|
+
|
|
|
+ <!-- 分页 -->
|
|
|
+ <div class="gva-pagination">
|
|
|
+ <el-pagination layout="total" :current-page="page" :page-size="pageSize"
|
|
|
+ :total="total" @current-change="handleCurrentChange" @size-change="handleSizeChange" />
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <!-- 设备折旧参数维护弹出框 -->
|
|
|
+ <el-dialog
|
|
|
+ v-model="dialogMachineVisible"
|
|
|
+ :before-close="sbcloseDialog"
|
|
|
+ :title="type === 'create' ? '设备折旧参数维护新增' : '设备折旧参数维护修改'"
|
|
|
+ destroy-on-close
|
|
|
+ style="width: 60%; margin: 5vh auto;"
|
|
|
+ >
|
|
|
+ <el-form :model="machineForm" label-width="120px">
|
|
|
+ <!-- 第一行:部门 -->
|
|
|
+ <el-row :gutter="20">
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label="使用部门">
|
|
|
+ <el-input v-model="machineForm.使用部门" @keyup.enter="getbm()" placeholder="请输入使用部门" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+
|
|
|
+ <!-- 第二行:设备信息 -->
|
|
|
+ <el-row :gutter="20">
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label="设备编号">
|
|
|
+ <el-input v-model="machineForm.设备编号" placeholder="请输入设备编号" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="12">
|
|
|
+ <el-form-item label="设备名称">
|
|
|
+ <el-input v-model="machineForm.设备名称" placeholder="请输入设备名称" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+
|
|
|
+ <!-- 第三行:供应商 -->
|
|
|
+ <el-row :gutter="20">
|
|
|
+ <el-col :span="18">
|
|
|
+ <el-form-item label="供应商">
|
|
|
+ <el-input v-model="machineForm.供应商" placeholder="请输入供应商" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+
|
|
|
+ <!-- 第四行:出厂编号 -->
|
|
|
+ <el-row :gutter="20">
|
|
|
+ <el-col :span="18">
|
|
|
+ <el-form-item label="出厂编号">
|
|
|
+ <el-input v-model="machineForm.出厂编号" placeholder="请输入出厂编号" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+
|
|
|
+ <!-- 第五行:执行人员 -->
|
|
|
+ <el-row :gutter="20">
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label="安装日期">
|
|
|
+ <el-date-picker
|
|
|
+ v-model="machineForm.安装日期"
|
|
|
+ type="date"
|
|
|
+ placeholder="选择安装日期"
|
|
|
+ style="width: 100%"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label="资产编号">
|
|
|
+ <el-input v-model="machineForm.资产编号" placeholder="请输入资产编号" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label="设备等级">
|
|
|
+ <el-select v-model="machineForm.设备等级" placeholder="请选择设备等级" style="width: 100%">
|
|
|
+ <el-option label="A" value="A" />
|
|
|
+ <el-option label="B" value="B" />
|
|
|
+ <el-option label="C" value="C" />
|
|
|
+ <el-option label="D" value="D" />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+
|
|
|
+ <!-- 第六行:保养信息 -->
|
|
|
+ <el-row :gutter="20">
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label="原值(元)">
|
|
|
+ <el-input v-model="machineForm.原值" placeholder="请输入原值" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+
|
|
|
+ <!-- 第六行:验收信息 -->
|
|
|
+ <el-row :gutter="20">
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label="年折旧额(元)">
|
|
|
+ <el-input v-model="machineForm.年折旧额" placeholder="请输入年折旧额" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label="年折旧月数">
|
|
|
+ <el-input v-model="machineForm.年折旧月数" placeholder="请输入年折旧月数" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+
|
|
|
+
|
|
|
+ <!-- 第七行:工时信息 -->
|
|
|
+ <el-row :gutter="20">
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label="月标准工时(小时)">
|
|
|
+ <el-input v-model="machineForm.月标准工时" placeholder="请输入月标准工时" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label="小时折旧额(元)">
|
|
|
+ <el-input v-model="machineForm.小时折旧额" placeholder="请输入小时折旧额" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label="最高限速">
|
|
|
+ <el-input v-model="machineForm.最高限速" placeholder="请输入最高限速" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="产能系数">
|
|
|
+ <el-input v-model="machineForm.产能系数" placeholder="请输入产能系数" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+
|
|
|
+ <el-row :gutter="20">
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label="关联地址">
|
|
|
+ <el-input v-model="machineForm.关联地址" placeholder="请输入关联地址" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label="通讯端口">
|
|
|
+ <el-input v-model="machineForm.通讯端口" placeholder="请输入通讯端口" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label="通道号">
|
|
|
+ <el-input v-model="machineForm.通道号" placeholder="通道号" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+
|
|
|
+ </el-form>
|
|
|
+
|
|
|
+ <!-- 弹窗底部按钮 -->
|
|
|
+ <template #footer>
|
|
|
+ <div class="dialog-footer" style="width: 100%;">
|
|
|
+ <el-button @click="sbcloseDialog" style="width: 100px; height: 40px;">关 闭</el-button>
|
|
|
+ <el-button type="primary" @click="sbenterDialog" style="width: 100px; height: 40px;">确 定</el-button>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </el-dialog>
|
|
|
+
|
|
|
+ <!-- 选择部门弹出框 -->
|
|
|
+ <el-dialog
|
|
|
+ v-model="deptDialogVisible"
|
|
|
+ title="选择部门"
|
|
|
+ width="30%"
|
|
|
+ >
|
|
|
+ <el-tree
|
|
|
+ :data="deptTreeData"
|
|
|
+ :props="defaultProps"
|
|
|
+ @node-click="handleDeptSelect"
|
|
|
+ highlight-current
|
|
|
+ />
|
|
|
+ </el-dialog>
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ </el-main>
|
|
|
+ </layout-content>
|
|
|
+ </layout>
|
|
|
+ </layout>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ <script setup>
|
|
|
+ // 全量引入格式化工具 请按需保留
|
|
|
+ import { Layout, LayoutSider, LayoutContent } from '@arco-design/web-vue';
|
|
|
+ import {getDepartment,getCPTab,getCPList,getCPDetail,getCPUpdate,getCPAdd,getCPDelete} from "@/api/mes/job.js"
|
|
|
+ import dayjs, { Dayjs } from 'dayjs';
|
|
|
+ import {gdzl_MachineList} from "@/api/yunyin/yunying.js"
|
|
|
+ import {ref, reactive} from 'vue'
|
|
|
+ import { exportExcelFile } from '@/utils/excel'
|
|
|
+ import { ElMessage, ElMessageBox } from 'element-plus'
|
|
|
+ import { useUserStore } from '@/pinia/modules/user'
|
|
|
+ import * as XLSX from 'xlsx'
|
|
|
+ import FileSaver from 'file-saver'
|
|
|
+ const userStore = useUserStore()
|
|
|
+ const sys_id='['+userStore.userInfo.userName+'/'+userStore.userInfo.nickName+']'
|
|
|
+ defineOptions({name: 'Company'})
|
|
|
+
|
|
|
+ // =========== 获取左侧树侧形结构 ===========
|
|
|
+ const treeData = ref([]);
|
|
|
+const defaultProps = {
|
|
|
+ children: 'children',
|
|
|
+ label: 'label'
|
|
|
+};
|
|
|
+const getTreeData = async () => {
|
|
|
+ try {
|
|
|
+ const response = await getCPTab();
|
|
|
+
|
|
|
+ if (response.code === 0) {
|
|
|
+ // 将接口数据转换为树形结构
|
|
|
+ treeData.value = [{
|
|
|
+ label: '主力设备成本参数设置',
|
|
|
+ children: response.data.map(item => ({
|
|
|
+ label: item,
|
|
|
+ }))
|
|
|
+ }];
|
|
|
+ } else {
|
|
|
+ console.error('获取车间数据失败:', response.msg);
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ console.error('获取车间数据异常:', error);
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+// 初始化时调用
|
|
|
+getTreeData();
|
|
|
+
|
|
|
+const cbtableData = ref([])
|
|
|
+const handleNodeClick = async (nodeData) => {
|
|
|
+ console.log('点击节点:', nodeData);
|
|
|
+ if(!nodeData.children){
|
|
|
+ const res = await getCPList({sist:nodeData.label})
|
|
|
+ if(res.code===0){
|
|
|
+ cbtableData.value = res.data
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+ //新增
|
|
|
+ const machineForm = reactive({
|
|
|
+ })
|
|
|
+const dialogMachineVisible = ref(false)
|
|
|
+const type = ref('create') // 'create' 或 'edit'
|
|
|
+const deptDialogVisible = ref(false) // 部门选择弹窗控制
|
|
|
+const deptTreeData = ref([]) // 部门树数据
|
|
|
+ const onADD = () => {
|
|
|
+ // 新增逻辑
|
|
|
+ console.log('新增按钮点击');
|
|
|
+ type.value = 'create'
|
|
|
+ dialogMachineVisible.value = true
|
|
|
+ }
|
|
|
+
|
|
|
+//双击打开修改弹窗
|
|
|
+const updateCompanyFunc = async (row) => {
|
|
|
+ type.value = 'update'
|
|
|
+ const res = await getCPDetail({ UniqId: row.UniqId })
|
|
|
+ if (res.code === 0) {
|
|
|
+ Object.assign(machineForm, res.data)
|
|
|
+ machineForm.安装日期 = dayjs(machineForm.安装日期)
|
|
|
+ }
|
|
|
+ dialogMachineVisible.value = true
|
|
|
+ }
|
|
|
+
|
|
|
+//弹窗确定
|
|
|
+const sbenterDialog = async () => {
|
|
|
+ console.log(':', machineForm)
|
|
|
+ const params = {
|
|
|
+ 使用部门: machineForm.使用部门,
|
|
|
+ 设备编号: machineForm.设备编号,
|
|
|
+ 设备名称: machineForm.设备名称,
|
|
|
+ 供应商:machineForm.供应商,
|
|
|
+ 出厂编号: machineForm.出厂编号,
|
|
|
+ 安装日期: dayjs(machineForm.安装日期).format('YYYY-MM-DD'),
|
|
|
+ 资产编号: machineForm.资产编号,
|
|
|
+ 设备等级: machineForm.设备等级,
|
|
|
+ 原值: machineForm.原值,
|
|
|
+ 年折旧额: machineForm.年折旧额,
|
|
|
+ 年折旧月数: machineForm.年折旧月数,
|
|
|
+ 月标准工时: machineForm.月标准工时,
|
|
|
+ 小时折旧额: machineForm.小时折旧额,
|
|
|
+ 最高限速: machineForm.最高限速,
|
|
|
+ 产能系数: machineForm.产能系数,
|
|
|
+ 关联地址: machineForm.关联地址,
|
|
|
+ 通讯端口: machineForm.通讯端口,
|
|
|
+ 通道号: machineForm.通道号,
|
|
|
+ sys_id: sys_id,
|
|
|
+ }
|
|
|
+console.log(params)
|
|
|
+console.log(type.value)
|
|
|
+ if (type.value === 'create') {
|
|
|
+ console.log('新增')
|
|
|
+ // 新增
|
|
|
+ try {
|
|
|
+ const response = await getCPAdd(params)
|
|
|
+ if (response.code === 0) {
|
|
|
+ ElMessage.success('新增成功')
|
|
|
+ sbcloseDialog()
|
|
|
+ } else {
|
|
|
+ ElMessage.error(response.msg || '新增失败')
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+
|
|
|
+ }
|
|
|
+ }else if (type.value === 'update') {
|
|
|
+ // 新增
|
|
|
+ console.log('修改')
|
|
|
+ params.UniqId = machineForm.UniqId
|
|
|
+ try {
|
|
|
+ const response = await getCPUpdate(params)
|
|
|
+ if (response.code === 0) {
|
|
|
+ ElMessage.success('修改成功')
|
|
|
+ sbcloseDialog()
|
|
|
+ } else {
|
|
|
+ ElMessage.error(response.msg || '修改失败')
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+//关闭弹窗
|
|
|
+const sbcloseDialog = async () => {
|
|
|
+ dialogMachineVisible.value = false
|
|
|
+}
|
|
|
+
|
|
|
+//删除
|
|
|
+const selectedIds = ref('')
|
|
|
+
|
|
|
+// 选择表格
|
|
|
+const handleSelectionChange = (selection) => {
|
|
|
+ selectedIds.value = selection.map(item => item.UniqId).join(',')
|
|
|
+ console.log('选中的ID:', selectedIds.value)
|
|
|
+}
|
|
|
+
|
|
|
+// 删除操作
|
|
|
+const onDelete = async () => {
|
|
|
+ if (!selectedIds.value.length) {
|
|
|
+ ElMessage.warning('请先选择要删除的记录')
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ await ElMessageBox.confirm('确定要删除选中的记录吗?', '提示', {
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ type: 'warning'
|
|
|
+ })
|
|
|
+
|
|
|
+ // 调用删除API,假设是批量删除接口
|
|
|
+ const res = await getCPDelete({ UniqId: selectedIds.value })
|
|
|
+
|
|
|
+ if (res.code === 0) {
|
|
|
+ ElMessage.success('删除成功')
|
|
|
+ // 删除成功后刷新表格数据
|
|
|
+ // 清空选中
|
|
|
+ selectedIds.value = []
|
|
|
+ } else {
|
|
|
+ ElMessage.error(res.msg || '删除失败')
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ if (error !== 'cancel') {
|
|
|
+ console.error('删除失败:', error)
|
|
|
+ ElMessage.error('删除操作已取消')
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+// 获取部门数据
|
|
|
+const getbm = async () => {
|
|
|
+ try {
|
|
|
+ const res = await getDepartment()
|
|
|
+ if (res.code === 0) {
|
|
|
+ // 转换数据结构为Tree需要的格式
|
|
|
+ deptTreeData.value = res.data.map(item => ({
|
|
|
+ label: item,
|
|
|
+ value: item
|
|
|
+ }))
|
|
|
+ deptDialogVisible.value = true // 显示部门选择弹窗
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ console.error('请求出错:', error)
|
|
|
+ ElMessage.error('获取部门失败')
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// 部门选择处理
|
|
|
+const handleDeptSelect = (data) => {
|
|
|
+
|
|
|
+ machineForm.使用部门 = data.label
|
|
|
+ deptDialogVisible.value = false
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+// 导出
|
|
|
+const cbToExcel = () => {
|
|
|
+ const el = document.getElementById('cbtable');
|
|
|
+ const filename = '成本参数统计.xlsx'; // 修改文件名更符合内容
|
|
|
+
|
|
|
+
|
|
|
+ // 1. 获取原始表格数据
|
|
|
+ const wb = XLSX.utils.table_to_book(el, { raw: true });
|
|
|
+ const ws = wb.Sheets[wb.SheetNames[0]];
|
|
|
+
|
|
|
+ // 2. 定义需要转换为数字的列(基于原始列字母)
|
|
|
+ const originalNumberColumns = {
|
|
|
+ 'D': 2,
|
|
|
+ 'E': 3,
|
|
|
+ 'F': 0,
|
|
|
+ 'G': 0,
|
|
|
+ 'H': 3,
|
|
|
+ 'I': 0,
|
|
|
+ 'J': 0,
|
|
|
+ 'L': 0,
|
|
|
+ 'M': 0,
|
|
|
+ };
|
|
|
+
|
|
|
+ // 3. 创建新工作表(左移后的数据)
|
|
|
+ const newWs = {};
|
|
|
+ const range = XLSX.utils.decode_range(ws['!ref']);
|
|
|
+
|
|
|
+ // 调整列范围(删除A列)
|
|
|
+ range.s.c = 0; // 从A列开始(原B列)
|
|
|
+ range.e.c -= 1; // 结束列减1
|
|
|
+ newWs['!ref'] = XLSX.utils.encode_range(range);
|
|
|
+
|
|
|
+ // 复制其他工作表属性(排除A列)
|
|
|
+ if (ws['!cols']) newWs['!cols'] = ws['!cols'].slice(1);
|
|
|
+ if (ws['!rows']) newWs['!rows'] = ws['!rows'];
|
|
|
+ if (ws['!merges']) newWs['!merges'] = ws['!merges'];
|
|
|
+
|
|
|
+ // 4. 左移所有列数据(A列→删除,B列→A列,C列→B列...)
|
|
|
+ Object.keys(ws).forEach(address => {
|
|
|
+ if (!address.startsWith('!')) {
|
|
|
+ const col = address.charAt(0);
|
|
|
+ const row = address.slice(1);
|
|
|
+
|
|
|
+ if (col !== 'A') { // 跳过A列
|
|
|
+ // 计算新列字母(左移一列)
|
|
|
+ const newCol = String.fromCharCode(col.charCodeAt(0) - 1);
|
|
|
+ const newAddress = newCol + row;
|
|
|
+
|
|
|
+ // 复制单元格数据
|
|
|
+ newWs[newAddress] = { ...ws[address] };
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ // 5. 转换数字格式(基于左移后的列字母)
|
|
|
+ Object.keys(newWs).forEach(address => {
|
|
|
+ const col = address.charAt(0);
|
|
|
+ const originalCol = String.fromCharCode(col.charCodeAt(0));
|
|
|
+
|
|
|
+ if (originalNumberColumns[originalCol] !== undefined) {
|
|
|
+ const cell = newWs[address];
|
|
|
+ const num = parseFloat(cell.v);
|
|
|
+
|
|
|
+ if (!isNaN(num)) {
|
|
|
+ cell.t = 'n';
|
|
|
+ cell.v = num;
|
|
|
+ cell.z = originalNumberColumns[originalCol] === 0
|
|
|
+ ? '0'
|
|
|
+ : `0.${'0'.repeat(originalNumberColumns[originalCol])}`;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ // 6. 更新工作簿并导出
|
|
|
+ wb.Sheets[wb.SheetNames[0]] = newWs;
|
|
|
+ const wbout = XLSX.write(wb, { bookType: 'xlsx', bookSST: true, type: 'array' });
|
|
|
+
|
|
|
+ try {
|
|
|
+ FileSaver.saveAs(new Blob([wbout], { type: 'application/octet-stream' }), filename);
|
|
|
+ } catch (e) {
|
|
|
+ console.error('导出失败:', e);
|
|
|
+ }
|
|
|
+ return wbout;
|
|
|
+
|
|
|
+};
|
|
|
+
|
|
|
+ </script>
|
|
|
+
|
|
|
+ <style scoped>
|
|
|
+ .form-container {
|
|
|
+ display: flex;
|
|
|
+ flex-wrap: wrap;
|
|
|
+ }
|
|
|
+
|
|
|
+ .form-column {
|
|
|
+ /*flex: 1;*/
|
|
|
+ margin-right: 15px; /* 调整列之间的间距 */
|
|
|
+ }
|
|
|
+
|
|
|
+ /* 左侧输入框宽度调整 */
|
|
|
+ .form-column .el-form-item .el-input {
|
|
|
+ width: 150px; /* 调整左侧输入框的宽度 */
|
|
|
+ }
|
|
|
+
|
|
|
+ :deep(.hui-plan-usage-lows div) {
|
|
|
+ color: #8c939d !important;
|
|
|
+ }
|
|
|
+ :deep(.lan-plan-usage-lows div) {
|
|
|
+ color: blue !important;
|
|
|
+ font-weight: bold;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /* 媒体查询,根据需要调整断点 */
|
|
|
+ @media screen and (max-width: 768px) {
|
|
|
+ .form-column {
|
|
|
+ flex: 1 0 100%; /* 在小屏幕下变成单列布局 */
|
|
|
+ margin-right: 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /*:deep(.el-table td .cell) {*/
|
|
|
+ /* line-height: 30px !important;*/
|
|
|
+ /*}*/
|
|
|
+ .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;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /* 选中某行时的背景色 */
|
|
|
+ :deep(.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;
|
|
|
+ }
|
|
|
+ </style>
|
|
|
+
|