|
|
@@ -0,0 +1,761 @@
|
|
|
+<template>
|
|
|
+ <div>
|
|
|
+ <layout>
|
|
|
+ <layout-header>
|
|
|
+ <div class="">
|
|
|
+ <el-form ref="elSearchFormRef" class="demo-form-inline" :rules="searchRule" >
|
|
|
+ <el-form-item>
|
|
|
+ <el-button type="primary" class="bt" icon="edit" @click="openAddDialog">新增</el-button>
|
|
|
+ <el-button type="primary" class="bt" icon="edit" @click="openEditDialog" :disabled="selectedIds.length === 0">修改</el-button>
|
|
|
+ <el-button type="danger" class="bt" icon="delete" @click="batchDeleteFunc" :disabled="selectedIds.length === 0">批量删除</el-button>
|
|
|
+ <el-button type="primary" class="bt" icon="download" @click="hzToExcel">导出到Excel</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">
|
|
|
+ <template #default="{ node, data }">
|
|
|
+ <div :style="{ color: selectedDate === data.date || selectedDate === data.month || selectedDate === data.year ? 'red' : '' }">
|
|
|
+ {{ node.label }}
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </el-tree>
|
|
|
+ </div>
|
|
|
+ </layout-sider>
|
|
|
+
|
|
|
+ <layout-content >
|
|
|
+ <el-main>
|
|
|
+ <div class="gva-table-box">
|
|
|
+ <el-table ref="multipleTable" style="width: 100%;height: 65vh" tooltip-effect="dark"
|
|
|
+ :row-style="{ height: '25px' }" :header-cell-style="{ padding: '0px' }"
|
|
|
+ :cell-style="{ padding: '0px' }" :header-row-style="{ height: '20px' }"
|
|
|
+ :data="tableData" border row-key="id"
|
|
|
+ size="small"
|
|
|
+ highlight-current-row
|
|
|
+ :current-row-key="currentRowKey"
|
|
|
+ @row-click="tableRowClick" :show-overflow-tooltip="true"
|
|
|
+ @selection-change="handleSelectionChange">
|
|
|
+ <el-table-column type="selection" width="40" :selectable="checkSelectable" />
|
|
|
+ <el-table-column align="center" label="车间" prop="车间" width="100" />
|
|
|
+ <el-table-column align="center" label="机组" prop="机组" width="130" />
|
|
|
+ <el-table-column align="center" label="机台编号" prop="机台编号" width="120" />
|
|
|
+ <el-table-column align="center" label="机台名称" prop="机台名称" width="150" />
|
|
|
+ <el-table-column align="center" label="班组" prop="班组" width="80" />
|
|
|
+ <el-table-column align="center" label="日期" prop="sczl_rq" width="120" />
|
|
|
+ <el-table-column align="center" label="理论速度" prop="theoretical_speed" width="100" />
|
|
|
+ <el-table-column align="center" label="计划生产时间" prop="scheduled_production" width="120" />
|
|
|
+ <el-table-column align="center" label="计划保养时间" prop="scheduled_maintenance" width="120" />
|
|
|
+ <el-table-column align="center" label="计划交接班时间" prop="scheduled_handover" width="140" />
|
|
|
+ <el-table-column align="center" label="设备故障时间" prop="fault" width="120" />
|
|
|
+ <el-table-column align="center" label="换型时间" prop="changeover" width="100" />
|
|
|
+ <el-table-column align="center" label="打样时间" prop="proofing" width="100" />
|
|
|
+ <el-table-column align="center" label="异常时间" prop="abnormal" width="100" />
|
|
|
+ <el-table-column align="center" label="计划产量" prop="planned_output" width="100" />
|
|
|
+ <el-table-column align="center" label="实际产量" prop="actual_output" width="100" />
|
|
|
+ <el-table-column align="center" label="不良品数量" prop="defective_product" width="120" />
|
|
|
+ <el-table-column align="center" label="操作" width="60" >
|
|
|
+ <template #default="{ row }">
|
|
|
+ <el-button size="small" type="danger" @click="deleteFunc(row)">删除</el-button>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+
|
|
|
+ <div class="gva-pagination">
|
|
|
+ <el-pagination layout="total, prev, pager, next" :current-page="page" :page-size="pageSize"
|
|
|
+ :total="total" @current-change="handleCurrentChange" @size-change="handleSizeChange" />
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </el-main>
|
|
|
+ </layout-content>
|
|
|
+ </layout>
|
|
|
+ </layout>
|
|
|
+
|
|
|
+ <el-dialog v-model="addDialogVisible" :title="isEdit ? '修改生产信息' : '新增生产信息'" width="95%" style="top: 2%" class="add-dialog">
|
|
|
+ <div class="add-header">
|
|
|
+ <el-form-item label="日期:" class="date-form-item">
|
|
|
+ <el-date-picker v-model="addDate" type="date" placeholder="选择日期" style="width: 200px;" />
|
|
|
+ </el-form-item>
|
|
|
+ <span class="hint">注:每个机台自动生成A班和B班两条数据</span>
|
|
|
+ </div>
|
|
|
+ <el-table :data="addTableData" border size="small" style="width: 100%;" :height="tableHeight" @row-click="handleAddRowClick">
|
|
|
+ <el-table-column type="selection" width="40" />
|
|
|
+ <el-table-column align="center" label="车间" prop="车间" width="100" />
|
|
|
+ <el-table-column align="center" label="机组" prop="机组" width="100" />
|
|
|
+ <el-table-column align="center" label="机台编号" prop="机台编号" width="120" />
|
|
|
+ <el-table-column align="center" label="机台名称" prop="机台名称" width="150" />
|
|
|
+ <el-table-column align="center" label="班组" prop="sczl_bzdh" width="80" />
|
|
|
+ <el-table-column align="center" label="理论速度" width="100">
|
|
|
+ <template #default="{ row }">
|
|
|
+ <template v-if="editRowKey === row.__rowKey">
|
|
|
+ <el-input v-model="row.theoretical_speed" style="width: 100%;" @input="handleNumberInput($event, row, 'theoretical_speed')" @click.stop />
|
|
|
+ </template>
|
|
|
+ <template v-else>
|
|
|
+ {{ row.theoretical_speed }}
|
|
|
+ </template>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column align="center" label="计划生产时间" width="120">
|
|
|
+ <template #default="{ row }">
|
|
|
+ <template v-if="editRowKey === row.__rowKey">
|
|
|
+ <el-input v-model="row.scheduled_production" style="width: 100%;" @input="handleNumberInput($event, row, 'scheduled_production')" @click.stop />
|
|
|
+ </template>
|
|
|
+ <template v-else>
|
|
|
+ {{ row.scheduled_production }}
|
|
|
+ </template>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column align="center" label="计划保养时间" width="120">
|
|
|
+ <template #default="{ row }">
|
|
|
+ <template v-if="editRowKey === row.__rowKey">
|
|
|
+ <el-input v-model="row.scheduled_maintenance" style="width: 100%;" @input="handleNumberInput($event, row, 'scheduled_maintenance')" @click.stop />
|
|
|
+ </template>
|
|
|
+ <template v-else>
|
|
|
+ {{ row.scheduled_maintenance }}
|
|
|
+ </template>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column align="center" label="计划交接班时间" width="140">
|
|
|
+ <template #default="{ row }">
|
|
|
+ <template v-if="editRowKey === row.__rowKey">
|
|
|
+ <el-input v-model="row.scheduled_handover" style="width: 100%;" @input="handleNumberInput($event, row, 'scheduled_handover')" @click.stop />
|
|
|
+ </template>
|
|
|
+ <template v-else>
|
|
|
+ {{ row.scheduled_handover }}
|
|
|
+ </template>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column align="center" label="设备故障时间" width="120">
|
|
|
+ <template #default="{ row }">
|
|
|
+ <template v-if="editRowKey === row.__rowKey">
|
|
|
+ <el-input v-model="row.fault" style="width: 100%;" @input="handleNumberInput($event, row, 'fault')" @click.stop />
|
|
|
+ </template>
|
|
|
+ <template v-else>
|
|
|
+ {{ row.fault }}
|
|
|
+ </template>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column align="center" label="换型时间" width="100">
|
|
|
+ <template #default="{ row }">
|
|
|
+ <template v-if="editRowKey === row.__rowKey">
|
|
|
+ <el-input v-model="row.changeover" style="width: 100%;" @input="handleNumberInput($event, row, 'changeover')" @click.stop />
|
|
|
+ </template>
|
|
|
+ <template v-else>
|
|
|
+ {{ row.changeover }}
|
|
|
+ </template>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column align="center" label="打样时间" width="100">
|
|
|
+ <template #default="{ row }">
|
|
|
+ <template v-if="editRowKey === row.__rowKey">
|
|
|
+ <el-input v-model="row.proofing" style="width: 100%;" @input="handleNumberInput($event, row, 'proofing')" @click.stop />
|
|
|
+ </template>
|
|
|
+ <template v-else>
|
|
|
+ {{ row.proofing }}
|
|
|
+ </template>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column align="center" label="异常时间" width="100">
|
|
|
+ <template #default="{ row }">
|
|
|
+ <template v-if="editRowKey === row.__rowKey">
|
|
|
+ <el-input v-model="row.abnormal" style="width: 100%;" @input="handleNumberInput($event, row, 'abnormal')" @click.stop />
|
|
|
+ </template>
|
|
|
+ <template v-else>
|
|
|
+ {{ row.abnormal }}
|
|
|
+ </template>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column align="center" label="计划产量" width="100">
|
|
|
+ <template #default="{ row }">
|
|
|
+ <template v-if="editRowKey === row.__rowKey">
|
|
|
+ <el-input v-model="row.planned_output" style="width: 100%;" @input="handleNumberInput($event, row, 'planned_output')" @click.stop />
|
|
|
+ </template>
|
|
|
+ <template v-else>
|
|
|
+ {{ row.planned_output }}
|
|
|
+ </template>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column align="center" label="实际产量" width="100">
|
|
|
+ <template #default="{ row }">
|
|
|
+ <template v-if="editRowKey === row.__rowKey">
|
|
|
+ <el-input v-model="row.actual_output" style="width: 100%;" @input="handleNumberInput($event, row, 'actual_output')" @click.stop />
|
|
|
+ </template>
|
|
|
+ <template v-else>
|
|
|
+ {{ row.actual_output }}
|
|
|
+ </template>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column align="center" label="不良品数量" width="120">
|
|
|
+ <template #default="{ row }">
|
|
|
+ <template v-if="editRowKey === row.__rowKey">
|
|
|
+ <el-input v-model="row.defective_product" style="width: 100%;" @input="handleNumberInput($event, row, 'defective_product')" @click.stop />
|
|
|
+ </template>
|
|
|
+ <template v-else>
|
|
|
+ {{ row.defective_product }}
|
|
|
+ </template>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+ <template #footer>
|
|
|
+ <div class="dialog-footer">
|
|
|
+ <div class="footer-buttons">
|
|
|
+ <el-button @click="closeAddDialog">取消</el-button>
|
|
|
+ <el-button type="primary" @click="confirmAdd">确定</el-button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+ </el-dialog>
|
|
|
+
|
|
|
+ <el-dialog v-model="exportDialogVisible" title="导出Excel" width="400px" style="top: 20%">
|
|
|
+ <div style="padding: 20px;">
|
|
|
+ <el-form-item label="日期:">
|
|
|
+ <el-date-picker v-model="exportDate" type="month" placeholder="选择月份" style="width: 100%;" />
|
|
|
+ </el-form-item>
|
|
|
+ </div>
|
|
|
+ <template #footer>
|
|
|
+ <div class="dialog-footer">
|
|
|
+ <div class="footer-buttons">
|
|
|
+ <el-button @click="exportDialogVisible = false">取消</el-button>
|
|
|
+ <el-button type="primary" @click="confirmExport">确定</el-button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </el-dialog>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ <script setup>
|
|
|
+ import { Layout, LayoutHeader, LayoutSider, LayoutContent } from '@arco-design/web-vue';
|
|
|
+ import {PisgetMenu,PisgetList,PisgetBaseData,PisbatchAdd,PisbatchDelete,PisbatchUpdate,ToExcel} from '@/api/mes/job'
|
|
|
+ import {ref, reactive, onMounted} from 'vue'
|
|
|
+ import {ElMessage, ElMessageBox} from "element-plus";
|
|
|
+ import service from '@/utils/request';
|
|
|
+ defineOptions({name: 'WorkshopInformationStatistics'})
|
|
|
+const path = `${import.meta.env.VITE_BASE_PATH}:${import.meta.env.VITE_UPLOADS_PORT}`
|
|
|
+console.log(path)
|
|
|
+ const treeData = ref([])
|
|
|
+ const defaultProps = reactive({
|
|
|
+ children: 'children',
|
|
|
+ label: 'label'
|
|
|
+ })
|
|
|
+ const selectedDate = ref('')
|
|
|
+ const tableData = ref([])
|
|
|
+ const currentRowKey = ref(null)
|
|
|
+ const requestIdCounter = ref(0)
|
|
|
+ const page = ref(1)
|
|
|
+ const pageSize = ref(9999)
|
|
|
+ const total = ref(0)
|
|
|
+ const searchInfo = ref('')
|
|
|
+ const selectedIds = ref([])
|
|
|
+ const searchRule = reactive({})
|
|
|
+
|
|
|
+ const addDialogVisible = ref(false)
|
|
|
+ const addDate = ref('')
|
|
|
+ const addTableData = ref([])
|
|
|
+ const editRowKey = ref('')
|
|
|
+ const tableHeight = ref(500)
|
|
|
+ const isEdit = ref(false)
|
|
|
+ const exportDialogVisible = ref(false)
|
|
|
+ const exportDate = ref('')
|
|
|
+
|
|
|
+ const formatDate = (date) => {
|
|
|
+ if (!date) return ''
|
|
|
+ if (typeof date === 'string') return date
|
|
|
+ const d = new Date(date)
|
|
|
+ const year = d.getFullYear()
|
|
|
+ const month = String(d.getMonth() + 1).padStart(2, '0')
|
|
|
+ const day = String(d.getDate()).padStart(2, '0')
|
|
|
+ return `${year}-${month}-${day}`
|
|
|
+ }
|
|
|
+
|
|
|
+ const fetchMenu = async () => {
|
|
|
+ try {
|
|
|
+ const res = await PisgetMenu()
|
|
|
+ if (res.code === 0) {
|
|
|
+ const data = res.data || []
|
|
|
+ treeData.value = data.map(yearItem => ({
|
|
|
+ label: yearItem.year + '年',
|
|
|
+ year: yearItem.year,
|
|
|
+ children: (yearItem.children || []).map(monthItem => ({
|
|
|
+ label: monthItem.month,
|
|
|
+ month: monthItem.month,
|
|
|
+ children: (monthItem.children || []).map(day => ({
|
|
|
+ label: day,
|
|
|
+ date: day
|
|
|
+ }))
|
|
|
+ }))
|
|
|
+ }))
|
|
|
+ }
|
|
|
+ } catch (e) {
|
|
|
+ ElMessage.error('获取菜单失败')
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ const fetchList = async (date) => {
|
|
|
+ if (!date) return
|
|
|
+ const currentRequestId = ++requestIdCounter.value
|
|
|
+ tableData.value = []
|
|
|
+ total.value = 0
|
|
|
+ try {
|
|
|
+ const res = await PisgetList({ date })
|
|
|
+ if (currentRequestId !== requestIdCounter.value) return
|
|
|
+ if (res.code === 0) {
|
|
|
+ const data = res.data || []
|
|
|
+ const seen = new Set()
|
|
|
+ const uniqueData = []
|
|
|
+ for (const item of data) {
|
|
|
+ if (item.id && !seen.has(item.id)) {
|
|
|
+ seen.add(item.id)
|
|
|
+ uniqueData.push(item)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ tableData.value = uniqueData
|
|
|
+ total.value = uniqueData.length
|
|
|
+ }
|
|
|
+ } catch (e) {
|
|
|
+ if (currentRequestId === requestIdCounter.value) {
|
|
|
+ ElMessage.error('获取数据失败')
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ const fetchBaseData = async () => {
|
|
|
+ try {
|
|
|
+ const res = await PisgetBaseData()
|
|
|
+ if (res.code === 0) {
|
|
|
+ const equipmentList = res.data || []
|
|
|
+ const tempData = []
|
|
|
+ let rowIndex = 0
|
|
|
+ equipmentList.forEach(item => {
|
|
|
+ const shiftList = item.班组列表 || ['A班', 'B班']
|
|
|
+ shiftList.forEach(shift => {
|
|
|
+ tempData.push({
|
|
|
+ __rowKey: `${item.机台编号}_${shift}_${rowIndex++}`,
|
|
|
+ 车间: item.车间,
|
|
|
+ 机组: item.机组,
|
|
|
+ 机台编号: item.机台编号,
|
|
|
+ 机台名称: item.机台名称,
|
|
|
+ sczl_jtbh: item.机台编号,
|
|
|
+ sczl_bzdh: shift,
|
|
|
+ theoretical_speed: item.理论速度 || 0,
|
|
|
+ scheduled_production: 0,
|
|
|
+ scheduled_maintenance: 0,
|
|
|
+ scheduled_handover: 0,
|
|
|
+ fault: 0,
|
|
|
+ changeover: 0,
|
|
|
+ proofing: 0,
|
|
|
+ abnormal: 0,
|
|
|
+ planned_output: 0,
|
|
|
+ actual_output: 0,
|
|
|
+ defective_product: 0
|
|
|
+ })
|
|
|
+ })
|
|
|
+ })
|
|
|
+ addTableData.value = tempData
|
|
|
+ }
|
|
|
+ } catch (e) {
|
|
|
+ ElMessage.error('获取机台数据失败')
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ const handleNodeClick = (data) => {
|
|
|
+ if (data.date) {
|
|
|
+ selectedDate.value = data.date
|
|
|
+ fetchList(data.date)
|
|
|
+ } else if (data.month) {
|
|
|
+ selectedDate.value = data.month
|
|
|
+ // fetchList(data.month)
|
|
|
+ } else if (data.year) {
|
|
|
+ selectedDate.value = data.year
|
|
|
+ // fetchList(data.year)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ const handleNodeExpand = () => {}
|
|
|
+
|
|
|
+ const checkSelectable = (row) => {
|
|
|
+ return !!row.机台编号
|
|
|
+ }
|
|
|
+
|
|
|
+ const tableRowClick = (row) => {
|
|
|
+ currentRowKey.value = row.id
|
|
|
+ }
|
|
|
+
|
|
|
+ const handleSelectionChange = (val) => {
|
|
|
+ selectedIds.value = val.map(item => item.id)
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ const handleCurrentChange = () => {}
|
|
|
+
|
|
|
+ const handleSizeChange = () => {}
|
|
|
+
|
|
|
+ const calculateTableHeight = () => {
|
|
|
+ const dialog = document.querySelector('.add-dialog')
|
|
|
+ if (dialog) {
|
|
|
+ const dialogHeader = dialog.querySelector('.el-dialog__header')
|
|
|
+ const dialogFooter = dialog.querySelector('.el-dialog__footer')
|
|
|
+ const addHeader = dialog.querySelector('.add-header')
|
|
|
+ let headerHeight = dialogHeader ? dialogHeader.offsetHeight : 60
|
|
|
+ let footerHeight = dialogFooter ? dialogFooter.offsetHeight : 60
|
|
|
+ let addHeaderHeight = addHeader ? addHeader.offsetHeight : 50
|
|
|
+ tableHeight.value = Math.max(dialog.clientHeight - headerHeight - footerHeight - addHeaderHeight - 20, 400)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ const openAddDialog = async () => {
|
|
|
+ addDate.value = ''
|
|
|
+ editRowKey.value = ''
|
|
|
+ await fetchBaseData()
|
|
|
+ addDialogVisible.value = true
|
|
|
+ setTimeout(() => {
|
|
|
+ calculateTableHeight()
|
|
|
+ window.addEventListener('resize', calculateTableHeight)
|
|
|
+ }, 200)
|
|
|
+ }
|
|
|
+
|
|
|
+ const closeAddDialog = () => {
|
|
|
+ addDialogVisible.value = false
|
|
|
+ isEdit.value = false
|
|
|
+ window.removeEventListener('resize', calculateTableHeight)
|
|
|
+ }
|
|
|
+
|
|
|
+ const handleAddRowClick = (row) => {
|
|
|
+ if (editRowKey.value === row.__rowKey) {
|
|
|
+ editRowKey.value = ''
|
|
|
+ } else {
|
|
|
+ editRowKey.value = row.__rowKey
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ const validateNumberInput = (value) => {
|
|
|
+ let cleaned = value.replace(/[^\d.]/g, '')
|
|
|
+ const parts = cleaned.split('.')
|
|
|
+ if (parts.length > 2) {
|
|
|
+ cleaned = parts[0] + '.' + parts.slice(1).join('')
|
|
|
+ }
|
|
|
+ return cleaned
|
|
|
+ }
|
|
|
+
|
|
|
+ const handleNumberInput = (value, row, field) => {
|
|
|
+ const cleaned = validateNumberInput(value)
|
|
|
+ if (cleaned !== value) {
|
|
|
+ row[field] = cleaned
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ const confirmAdd = async () => {
|
|
|
+ if (!addDate.value) {
|
|
|
+ ElMessage.warning('请选择日期')
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ const list = addTableData.value.map(row => {
|
|
|
+ const data = {
|
|
|
+ sczl_jtbh: row.sczl_jtbh,
|
|
|
+ sczl_bzdh: row.sczl_bzdh,
|
|
|
+ sczl_rq: formatDate(addDate.value),
|
|
|
+ theoretical_speed: row.theoretical_speed,
|
|
|
+ scheduled_production: row.scheduled_production,
|
|
|
+ scheduled_maintenance: row.scheduled_maintenance,
|
|
|
+ scheduled_handover: row.scheduled_handover,
|
|
|
+ fault: row.fault,
|
|
|
+ changeover: row.changeover,
|
|
|
+ proofing: row.proofing,
|
|
|
+ abnormal: row.abnormal,
|
|
|
+ planned_output: row.planned_output,
|
|
|
+ actual_output: row.actual_output,
|
|
|
+ defective_product: row.defective_product
|
|
|
+ }
|
|
|
+ if (row.id) {
|
|
|
+ data.id = row.id
|
|
|
+ }
|
|
|
+ return data
|
|
|
+ })
|
|
|
+
|
|
|
+ try {
|
|
|
+ let res
|
|
|
+ if (isEdit.value) {
|
|
|
+ res = await PisbatchUpdate({ list, sys_id: 'admin' })
|
|
|
+ } else {
|
|
|
+ res = await PisbatchAdd({ list, sys_id: 'admin' })
|
|
|
+ }
|
|
|
+ if (res.code === 0) {
|
|
|
+ ElMessage.success(isEdit.value ? '修改成功' : '新增成功')
|
|
|
+ addDialogVisible.value = false
|
|
|
+ isEdit.value = false
|
|
|
+ selectedIds.value = []
|
|
|
+ window.removeEventListener('resize', calculateTableHeight)
|
|
|
+ if (selectedDate.value) {
|
|
|
+ fetchList(selectedDate.value)
|
|
|
+ }
|
|
|
+ fetchMenu()
|
|
|
+ } else {
|
|
|
+ ElMessage.error(res.msg || (isEdit.value ? '修改失败' : '新增失败'))
|
|
|
+ }
|
|
|
+ } catch (e) {
|
|
|
+ ElMessage.error(isEdit.value ? '修改失败' : '新增失败')
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ const openEditDialog = () => {
|
|
|
+ if (selectedIds.value.length === 0) {
|
|
|
+ ElMessage.warning('请至少选择一条记录进行修改')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ const selectedRows = tableData.value.filter(item => selectedIds.value.includes(item.id))
|
|
|
+ if (selectedRows.length === 0) {
|
|
|
+ ElMessage.warning('未找到选中的记录')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ const monthRow = selectedRows.find(row => row.query_type === 'month')
|
|
|
+ if (monthRow) {
|
|
|
+ ElMessage.warning('月汇总数据不支持编辑,请选择具体日期')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ isEdit.value = true
|
|
|
+ addDate.value = selectedRows[0].sczl_rq || ''
|
|
|
+ addTableData.value = selectedRows.map((row, index) => ({
|
|
|
+ __rowKey: `${row.sczl_jtbh}_${row.sczl_bzdh}_${index}`,
|
|
|
+ id: row.id,
|
|
|
+ 车间: row.车间 || '',
|
|
|
+ 机组: row.机组 || '',
|
|
|
+ 机台编号: row.机台编号 || '',
|
|
|
+ 机台名称: row.机台名称 || '',
|
|
|
+ sczl_jtbh: row.sczl_jtbh || '',
|
|
|
+ sczl_bzdh: row.sczl_bzdh || '',
|
|
|
+ theoretical_speed: row.theoretical_speed || 0,
|
|
|
+ scheduled_production: row.scheduled_production || 0,
|
|
|
+ scheduled_maintenance: row.scheduled_maintenance || 0,
|
|
|
+ scheduled_handover: row.scheduled_handover || 0,
|
|
|
+ fault: row.fault || 0,
|
|
|
+ changeover: row.changeover || 0,
|
|
|
+ proofing: row.proofing || 0,
|
|
|
+ abnormal: row.abnormal || 0,
|
|
|
+ planned_output: row.planned_output || 0,
|
|
|
+ actual_output: row.actual_output || 0,
|
|
|
+ defective_product: row.defective_product || 0
|
|
|
+ }))
|
|
|
+ addDialogVisible.value = true
|
|
|
+ setTimeout(() => {
|
|
|
+ calculateTableHeight()
|
|
|
+ window.addEventListener('resize', calculateTableHeight)
|
|
|
+ }, 200)
|
|
|
+ }
|
|
|
+
|
|
|
+ const deleteFunc = async (row) => {
|
|
|
+ if (row.query_type === 'month') {
|
|
|
+ ElMessage.warning('月汇总数据不支持删除,请选择具体日期')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ await ElMessageBox.confirm('确定要删除这条记录吗?', '提示', {
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ type: 'warning'
|
|
|
+ })
|
|
|
+ const res = await PisbatchDelete({ ids: row.id, sys_id: 'admin' })
|
|
|
+ if (res.code === 0) {
|
|
|
+ ElMessage.success('删除成功')
|
|
|
+ if (selectedDate.value) {
|
|
|
+ fetchList(selectedDate.value)
|
|
|
+ }
|
|
|
+ fetchMenu()
|
|
|
+ } else {
|
|
|
+ ElMessage.error(res.msg || '删除失败')
|
|
|
+ }
|
|
|
+ } catch (e) {
|
|
|
+ if (e !== 'cancel') {
|
|
|
+ ElMessage.error('删除失败')
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ const batchDeleteFunc = async () => {
|
|
|
+ try {
|
|
|
+ await ElMessageBox.confirm(`确定要删除选中的 ${selectedIds.value.length} 条记录吗?`, '提示', {
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ type: 'warning'
|
|
|
+ })
|
|
|
+ const res = await PisbatchDelete({ ids: selectedIds.value.join(','), sys_id: 'admin' })
|
|
|
+ if (res.code === 0) {
|
|
|
+ ElMessage.success('删除成功')
|
|
|
+ selectedIds.value = []
|
|
|
+ if (selectedDate.value) {
|
|
|
+ fetchList(selectedDate.value)
|
|
|
+ }
|
|
|
+ fetchMenu()
|
|
|
+ } else {
|
|
|
+ ElMessage.error(res.msg || '删除失败')
|
|
|
+ }
|
|
|
+ } catch (e) {
|
|
|
+ if (e !== 'cancel') {
|
|
|
+ ElMessage.error('删除失败')
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ const hzToExcel = () => {
|
|
|
+ let defaultDate = ''
|
|
|
+ if (selectedDate.value) {
|
|
|
+ if (selectedDate.value.length === 7) {
|
|
|
+ defaultDate = selectedDate.value
|
|
|
+ } else if (selectedDate.value.length === 10) {
|
|
|
+ defaultDate = selectedDate.value.substring(0, 7)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!defaultDate) {
|
|
|
+ const now = new Date()
|
|
|
+ const year = now.getFullYear()
|
|
|
+ const month = String(now.getMonth() + 1).padStart(2, '0')
|
|
|
+ defaultDate = `${year}-${month}`
|
|
|
+ }
|
|
|
+ exportDate.value = defaultDate
|
|
|
+ exportDialogVisible.value = true
|
|
|
+ }
|
|
|
+
|
|
|
+ const confirmExport = async () => {
|
|
|
+ if (!exportDate.value) {
|
|
|
+ ElMessage.warning('请选择日期')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ const month = typeof exportDate.value === 'string' ? exportDate.value : formatDate(exportDate.value).substring(0, 7)
|
|
|
+ const res = await ToExcel({ sys_id: 'admin', month })
|
|
|
+ if (res.code === 0) {
|
|
|
+ let url = res.data.url
|
|
|
+ if (url) {
|
|
|
+if (!url.startsWith('http')) {
|
|
|
+ url = `${path}/${url}`
|
|
|
+}
|
|
|
+ const link = document.createElement('a')
|
|
|
+ link.href = url
|
|
|
+ link.download = url.split('/').pop()
|
|
|
+ link.target = '_blank'
|
|
|
+ document.body.appendChild(link)
|
|
|
+ link.click()
|
|
|
+ document.body.removeChild(link)
|
|
|
+ exportDialogVisible.value = false
|
|
|
+ ElMessage.success('导出成功')
|
|
|
+ } else {
|
|
|
+ ElMessage.warning('未获取到文件链接')
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ ElMessage.error(res.msg || '导出失败')
|
|
|
+ }
|
|
|
+ } catch (e) {
|
|
|
+ ElMessage.error('导出失败')
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ onMounted(() => {
|
|
|
+ fetchMenu()
|
|
|
+ })
|
|
|
+ </script>
|
|
|
+
|
|
|
+ <style scoped>
|
|
|
+ .add-header {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ margin-bottom: 15px;
|
|
|
+ padding: 10px;
|
|
|
+ background-color: #f5f7fa;
|
|
|
+ border-radius: 4px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .date-form-item {
|
|
|
+ margin-bottom: 0 !important;
|
|
|
+ margin-right: 15px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .date-form-item .el-form-item__label {
|
|
|
+ font-weight: bold;
|
|
|
+ padding-right: 8px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .add-header .hint {
|
|
|
+ color: #606266;
|
|
|
+ font-size: 13px;
|
|
|
+ padding-left: 10px;
|
|
|
+ border-left: 1px solid #e4e7ed;
|
|
|
+ }
|
|
|
+
|
|
|
+ :deep(.add-dialog .el-dialog__body) {
|
|
|
+ display: flex;
|
|
|
+ flex-direction: column;
|
|
|
+ max-height: calc(95vh - 100px);
|
|
|
+ overflow: hidden;
|
|
|
+ }
|
|
|
+
|
|
|
+ :deep(.add-dialog .el-dialog__body > .el-table) {
|
|
|
+ flex: 1;
|
|
|
+ min-height: 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ :deep(.add-dialog .el-input__inner) {
|
|
|
+ text-align: center;
|
|
|
+ }
|
|
|
+
|
|
|
+ .dialog-footer {
|
|
|
+ display: flex;
|
|
|
+ justify-content: flex-end;
|
|
|
+ padding: 10px 20px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .footer-buttons {
|
|
|
+ display: flex;
|
|
|
+ gap: 10px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .JKWTree-container {
|
|
|
+ display: flex;
|
|
|
+ }
|
|
|
+ .JKWTree-tree {
|
|
|
+ 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>
|
|
|
+
|