|
|
@@ -8,6 +8,7 @@
|
|
|
<el-form-item>
|
|
|
<el-button type="primary" icon="Download" @click="exportToExcel3" style="margin: 5px;float: right;">导出到Excel(明细)</el-button>
|
|
|
<el-button type="primary" icon="Download" @click="exportToExcel2" style="margin: 5px;float: right;">月度明细</el-button>
|
|
|
+ <el-button type="primary" icon="Download" @click="exportToExcel" style="margin: 5px;float: right;">月度色度数汇总</el-button>
|
|
|
</el-form-item>
|
|
|
</el-form>
|
|
|
</div>
|
|
|
@@ -137,7 +138,7 @@ import LuckyExcel from 'luckyexcel';
|
|
|
import { Layout, LayoutSider, LayoutContent } from '@arco-design/web-vue';
|
|
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
|
|
import { ref, reactive, computed, nextTick, watch,onMounted } from 'vue'
|
|
|
-import {OutputSstatisticsMenu,MachineProductDetail,MachineProduction} from "@/api/DecisionSupport/decision.js"
|
|
|
+import {OutputSstatisticsMenu,MachineProductDetail,MachineProduction,ChromaticityNumber} from "@/api/DecisionSupport/decision.js"
|
|
|
import { useUserStore } from '@/pinia/modules/user'
|
|
|
defineOptions({name: 'Company'})
|
|
|
const userStore = useUserStore()
|
|
|
@@ -219,6 +220,63 @@ const exportToExcel2 = () => {
|
|
|
}
|
|
|
|
|
|
|
|
|
+const exportToExcel = async () => {
|
|
|
+ try {
|
|
|
+ // 获取接口数据
|
|
|
+ const res = await ChromaticityNumber({month: noderq.value});
|
|
|
+
|
|
|
+ // 检查接口返回数据
|
|
|
+ if (res.code !== 0 || !res.data || !Array.isArray(res.data)) {
|
|
|
+ console.error('接口数据异常', res);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 准备Excel数据
|
|
|
+ const excelData = res.data.map(item => ({
|
|
|
+ '工序名称': item.工序名称 || '',
|
|
|
+ '墨色': item.墨色 ? Number(item.墨色) : 0, // 确保墨色是数字类型
|
|
|
+ '车间': item.车间 || ''
|
|
|
+ }));
|
|
|
+
|
|
|
+ // 创建工作簿
|
|
|
+ const wb = XLSX.utils.book_new();
|
|
|
+ const ws = XLSX.utils.json_to_sheet(excelData);
|
|
|
+
|
|
|
+ // 设置列宽(可选)
|
|
|
+ ws['!cols'] = [
|
|
|
+ { wch: 20 }, // 工序名称列宽
|
|
|
+ { wch: 15 }, // 墨色列宽
|
|
|
+ { wch: 15 } // 车间列宽
|
|
|
+ ];
|
|
|
+
|
|
|
+ // 设置墨色列为数字格式
|
|
|
+ Object.keys(ws).forEach(address => {
|
|
|
+ if (address.startsWith('B')) { // B列是墨色列(第二列)
|
|
|
+ const cell = ws[address];
|
|
|
+ if (cell.t !== 'n') { // 如果不是数字类型
|
|
|
+ cell.t = 'n'; // 设置为数字类型
|
|
|
+ cell.z = '0'; // 设置数字格式为整数
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ // 添加工作表到工作簿
|
|
|
+ XLSX.utils.book_append_sheet(wb, ws, '墨色数据');
|
|
|
+
|
|
|
+ // 导出Excel
|
|
|
+ const filename = `墨色数据_${noderq.value}.xlsx`;
|
|
|
+ const wbout = XLSX.write(wb, { bookType: 'xlsx', type: 'array' });
|
|
|
+
|
|
|
+ FileSaver.saveAs(new Blob([wbout], { type: 'application/octet-stream' }), filename);
|
|
|
+
|
|
|
+ return wbout;
|
|
|
+ } catch (e) {
|
|
|
+ console.error('导出失败:', e);
|
|
|
+ throw e;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
// =========== 左侧树侧形结构 ===========
|
|
|
@@ -252,7 +310,7 @@ DataListdata();
|
|
|
|
|
|
//点击左侧树形获取编号
|
|
|
const tableData = reactive([])
|
|
|
-const _Gd_khdh = ref(null)
|
|
|
+const noderq = ref('')
|
|
|
const params = ref({})
|
|
|
const params2 = ref({})
|
|
|
const tabledate2 = ref([])
|
|
|
@@ -275,6 +333,7 @@ const handleNodeClick = async (node) => {
|
|
|
|
|
|
tabledate2.value=[]
|
|
|
if(node.children !==undefined ){
|
|
|
+ noderq.value = node.label
|
|
|
jqtabledata.value = []
|
|
|
tabledate2.value = []
|
|
|
params.value.mouth= node.label
|