|
|
@@ -6,9 +6,11 @@
|
|
|
<!-- 按钮部分-->
|
|
|
<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="hzToExcel" >导出到Excel(汇总)</el-button>
|
|
|
- <el-button type="primary" class="bt" icon="download" @click="mxToExcel" >导出到Excel(明细)</el-button> -->
|
|
|
+ <!-- <el-input v-model="searchInfo" placeholder="搜索工单编号" clearable style="width: 200px;margin: 5px"></el-input> -->
|
|
|
+ <el-input v-model="searchInfo" placeholder="输入订单编号" style="width: 180px;" @keyup.enter="onSubmit()"></el-input>
|
|
|
+ <el-button type="primary" icon="search" @click="onSubmit" title="查询" >查询</el-button>
|
|
|
+ <el-button type="primary" class="bt" icon="download" @click="hzToExcel" >订单成品导出</el-button>
|
|
|
+ <!-- <el-button type="primary" class="bt" icon="download" @click="mxToExcel" >导出到Excel(明细)</el-button> -->
|
|
|
</el-form-item>
|
|
|
</el-form>
|
|
|
|
|
|
@@ -21,7 +23,7 @@
|
|
|
<!-- 左侧树侧形结构-->
|
|
|
<layout-sider :resize-directions="['right']" :width="220" style="margin-right: 10px;">
|
|
|
<div class="JKWTree-tree" style="height: 200px">
|
|
|
- <h3>成品入仓</h3>
|
|
|
+ <h3>产品返工次片合格率汇总</h3>
|
|
|
<el-tree :data="treeData" :props="defaultProps" class="treecolor" @node-click="handleNodeClick" @node-expand="handleNodeExpand">
|
|
|
</el-tree>
|
|
|
</div>
|
|
|
@@ -44,6 +46,7 @@
|
|
|
<el-table-column sortable align="center" label="订单编号" prop="订单编号" width="120" />
|
|
|
<el-table-column sortable align="center" label="生产款号" prop="生产款号" width="170" />
|
|
|
<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="110" /> -->
|
|
|
<el-table-column align="center" label="本月总检完工数量" prop="入仓数量" width="150" />
|
|
|
<el-table-column align="center" label="累计总检完工数量" prop="累计入仓数量" width="150" />
|
|
|
@@ -76,11 +79,11 @@
|
|
|
highlight-current-row="true" @row-dblclick="updateCompanyFunc"
|
|
|
:show-overflow-tooltip="true"
|
|
|
@selection-change="handleSelectionChange">
|
|
|
- <el-table-column sortable align="center" label="订单编号" prop="订单编号" width="120" />
|
|
|
<el-table-column sortable align="center" label="子订单编号" prop="子订单编号" width="160" />
|
|
|
<el-table-column sortable align="center" label="PO号" prop="生产款号" width="200" />
|
|
|
<el-table-column sortable align="center" label="颜色" prop="颜色" width="160" />
|
|
|
<el-table-column sortable align="center" label="颜色备注" prop="颜色备注" width="200" />
|
|
|
+ <el-table-column sortable align="center" label="制单数量" prop="zdtotal" width="120" />
|
|
|
<el-table-column align="center" label="本月总检完工数量" prop="入仓数量" width="150" />
|
|
|
<el-table-column align="center" label="累计总检完工数量" prop="累计入仓数量" width="150" />
|
|
|
<el-table-column align="center" label="裁剪数量" prop="裁剪数量" width="100" />
|
|
|
@@ -96,6 +99,46 @@
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
|
+ <el-dialog v-model="onhzexcel" title="汇总数据导出" destroy-on-close style="height: 30%;width: 20%;">
|
|
|
+ <el-form-item label="选择年月" label-width="100px">
|
|
|
+ <el-date-picker
|
|
|
+ v-model="hzrq"
|
|
|
+ type="month"
|
|
|
+ placeholder="选择年月"
|
|
|
+ :default-value="new Date()"
|
|
|
+ @change="hzonchange_data"
|
|
|
+ style="width: 200px;"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+
|
|
|
+ <template #footer>
|
|
|
+ <div class="dialog-footer" style="text-align: right;">
|
|
|
+ <el-button @click="hzcloseDialog">取消</el-button>
|
|
|
+ <el-button type="primary" @click="hzonDialog">确定</el-button>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </el-dialog>
|
|
|
+
|
|
|
+ <el-dialog v-model="onmxexcel" title="明细数据导出" destroy-on-close style="height: 30%;width: 20%;">
|
|
|
+ <el-form-item label="选择年月" label-width="100px">
|
|
|
+ <el-date-picker
|
|
|
+ v-model="mxrq"
|
|
|
+ type="month"
|
|
|
+ placeholder="选择年月"
|
|
|
+ :default-value="new Date()"
|
|
|
+ @change="mxonchange_data"
|
|
|
+ style="width: 200px;"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+
|
|
|
+ <template #footer>
|
|
|
+ <div class="dialog-footer" style="text-align: right;">
|
|
|
+ <el-button @click="mxcloseDialog">取消</el-button>
|
|
|
+ <el-button type="primary" @click="mxonDialog">确定</el-button>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </el-dialog>
|
|
|
+
|
|
|
<!-- </el-main> -->
|
|
|
</layout-content>
|
|
|
</layout>
|
|
|
@@ -105,7 +148,8 @@
|
|
|
<script setup>
|
|
|
// 全量引入格式化工具 请按需保留
|
|
|
import { Layout, LayoutSider, LayoutContent } from '@arco-design/web-vue';
|
|
|
-
|
|
|
+ import * as XLSX from 'xlsx'
|
|
|
+import FileSaver from 'file-saver'
|
|
|
import {ref, reactive} from 'vue'
|
|
|
import { exportExcelFile } from '@/utils/excel'
|
|
|
import {ElMessage} from "element-plus";
|
|
|
@@ -187,11 +231,165 @@ const tableRowClick = async(row) => {
|
|
|
mxtableData.value = res.data.result
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+const searchInfo = ref('')
|
|
|
+const onSubmit = async () => {
|
|
|
+ if (!searchInfo.value) {
|
|
|
+ ElMessage.warning('请输入订单编号');
|
|
|
+ return;
|
|
|
+ }else{
|
|
|
+ const res = await GetWfpList({search:searchInfo.value})
|
|
|
+ console.log('获取数据:', res)
|
|
|
+ if(res.code === 0){
|
|
|
+ hztableData.value = res.data.result
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+// 通用的导出Excel函数
|
|
|
+const exportToExcel = (data, filename = '导出数据.xlsx', sheetName = 'Sheet1') => {
|
|
|
+ try {
|
|
|
+ // 创建工作簿和工作表
|
|
|
+ const wb = XLSX.utils.book_new();
|
|
|
+
|
|
|
+ // 如果data是DOM元素(表格)
|
|
|
+ if (typeof data === 'object' && data.nodeType === 1) {
|
|
|
+ const worksheet = XLSX.utils.table_to_sheet(data, { raw: true });
|
|
|
+ convertColumnsToNumber(worksheet);
|
|
|
+ XLSX.utils.book_append_sheet(wb, worksheet, sheetName);
|
|
|
+ }
|
|
|
+ // 如果data是数组(接口数据)
|
|
|
+ else if (Array.isArray(data)) {
|
|
|
+ const worksheet = XLSX.utils.json_to_sheet(data);
|
|
|
+ XLSX.utils.book_append_sheet(wb, worksheet, sheetName);
|
|
|
+ }
|
|
|
+ // 如果data已经是worksheet对象
|
|
|
+ else if (data['!ref']) {
|
|
|
+ XLSX.utils.book_append_sheet(wb, data, sheetName);
|
|
|
+ } else {
|
|
|
+ throw new Error('不支持的导出数据类型');
|
|
|
+ }
|
|
|
+
|
|
|
+ // 导出文件
|
|
|
+ XLSX.writeFile(wb, filename);
|
|
|
+ return true;
|
|
|
+ } catch (error) {
|
|
|
+ console.error('导出Excel失败:', error);
|
|
|
+ ElMessage.error('导出失败: ' + error.message);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+// 列转换为数字的通用函数
|
|
|
+const convertColumnsToNumber = (worksheet, startCol = 2) => {
|
|
|
+ const range = XLSX.utils.decode_range(worksheet['!ref']);
|
|
|
+ for (let col = startCol; col <= range.e.c; col++) {
|
|
|
+ for (let row = range.s.r + 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 = Number(cellValue);
|
|
|
+
|
|
|
+ if (!isNaN(numValue) && cellValue !== '') {
|
|
|
+ worksheet[cellAddress].t = 'n';
|
|
|
+ worksheet[cellAddress].v = numValue;
|
|
|
+ worksheet[cellAddress].z = '0';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+
|
|
|
|
|
|
+const onhzexcel = ref(false)
|
|
|
+const onmxexcel = ref(false)
|
|
|
+const mxrq = ref('')
|
|
|
+const hzrq = ref('')
|
|
|
+const hzToExcel = async=> {
|
|
|
+ onhzexcel.value = true
|
|
|
+}
|
|
|
+ const hzcloseDialog = () => {
|
|
|
+ onhzexcel.value = false
|
|
|
+ }
|
|
|
+ const hzonchange_data = (val) => {
|
|
|
+ if (val) {
|
|
|
+ // 将日期对象转换为本地时间的年月格式
|
|
|
+ const year = val.getFullYear()
|
|
|
+ const month = (val.getMonth() + 1).toString().padStart(2, '0')
|
|
|
+ hzrq.value = `${year}${month}`
|
|
|
+ } else {
|
|
|
+ hzrq.value = ''
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
+const hzonDialog = async() => {
|
|
|
+ if(!hzrq.value){
|
|
|
+ ElMessage.error('请选择年月')
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ const res = await GetWfpList({sys_rq: hzrq.value})
|
|
|
+ console.log('获取数据:', res)
|
|
|
|
|
|
+ if(res.code === 0){
|
|
|
+ // 直接使用接口返回的数据导出
|
|
|
+ const success = exportToExcel(
|
|
|
+ res.data.result,
|
|
|
+ `生产数据汇总_${hzrq.value}.xlsx`,
|
|
|
+ '生产汇总'
|
|
|
+ );
|
|
|
+
|
|
|
+ if(success) {
|
|
|
+ ElMessage.success('导出成功');
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ ElMessage.error(res.msg || '获取数据失败');
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+const mxToExcel = async=> {
|
|
|
+ onmxexcel.value = true
|
|
|
+}
|
|
|
+ const mxcloseDialog = () => {
|
|
|
+ onmxexcel.value = false
|
|
|
+ }
|
|
|
+ const mxonchange_data = (val) => {
|
|
|
+ if (val) {
|
|
|
+ // 将日期对象转换为本地时间的年月格式
|
|
|
+ const year = val.getFullYear()
|
|
|
+ const month = (val.getMonth() + 1).toString().padStart(2, '0')
|
|
|
+ mxrq.value = `${year}${month}`
|
|
|
+ } else {
|
|
|
+ mxrq.value = ''
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+const mxonDialog = async() => {
|
|
|
+ if(!mxrq.value){
|
|
|
+ ElMessage.error('请选择年月')
|
|
|
+ return
|
|
|
+ }
|
|
|
|
|
|
+ const res = await GetSubOrderStats({sys_rq: mxrq.value})
|
|
|
+ console.log('获取数据:', res)
|
|
|
|
|
|
+ if(res.code === 0){
|
|
|
+ // 直接使用接口返回的数据导出
|
|
|
+ const success = exportToExcel(
|
|
|
+ res.data.result,
|
|
|
+ `生产数据汇总_${hzrq.value}.xlsx`,
|
|
|
+ '生产汇总'
|
|
|
+ );
|
|
|
+
|
|
|
+ if(success) {
|
|
|
+ ElMessage.success('导出成功');
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ ElMessage.error(res.msg || '获取数据失败');
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
|
|
|
</script>
|