diff --git a/src/api/base/orderManage.js b/src/api/base/orderManage.js index 732e13c7..00174a7d 100644 --- a/src/api/base/orderManage.js +++ b/src/api/base/orderManage.js @@ -34,6 +34,15 @@ export function workOrderList(query) { }) } +// 条件获得工单列表 +export function getFreeWOlist(query) { + return request({ + url: '/base/core-work-order/getFreeWOlist', + method: 'get', + params: query + }) +} + // 获得订单分页 export function getOrderPage(query) { return request({ diff --git a/src/api/quality/deviceParameters.js b/src/api/quality/deviceParameters.js index ae1c87fb..848e20b5 100644 --- a/src/api/quality/deviceParameters.js +++ b/src/api/quality/deviceParameters.js @@ -1,7 +1,7 @@ /* * @Author: zhp * @Date: 2023-10-18 09:33:57 - * @LastEditTime: 2023-11-03 09:31:17 + * @LastEditTime: 2024-03-15 15:18:09 * @LastEditors: zhp * @Description: */ @@ -33,3 +33,12 @@ export function exportEnergyPlcExcel(query) { responseType: 'blob' }) } + +export function exportEquipmentTraceabilityExcel(query) { + return request({ + url: '/analysis/equipment-analysis/export-excel', + method: 'get', + params: query, + responseType: 'blob' + }) +} diff --git a/src/utils/dict.js b/src/utils/dict.js index 8f707c71..ddd97161 100644 --- a/src/utils/dict.js +++ b/src/utils/dict.js @@ -104,7 +104,7 @@ export const DICT_TYPE = { ORDER_PRIORITY: 'order_priority', PACK_SPEC: 'pack_spec', WORK_ORDER_STATUS: 'work_order_status', - + // ============== EQUIPMENT - 设备模块 ============= MAINTAIN_TYPE: 'maintain_type', FAULT_LEVEL: 'fault-level', @@ -116,7 +116,9 @@ export const DICT_TYPE = { ENVIRONMENT_CHECK_UNIT: 'environment_check_unit', // ============== GROUP - 班组模块 ============= - WORK_SHOP: 'workshop' + WORK_SHOP: 'workshop', + // ============== GROUP - 质量模块 ============= + MATERIAL_GRADE: 'material_grade' } /** diff --git a/src/views/energy/base/energyQuantityManual/components/energyQuantityManualAdd.vue b/src/views/energy/base/energyQuantityManual/components/energyQuantityManualAdd.vue index d211ed01..7956cb8b 100644 --- a/src/views/energy/base/energyQuantityManual/components/energyQuantityManualAdd.vue +++ b/src/views/energy/base/energyQuantityManual/components/energyQuantityManualAdd.vue @@ -4,38 +4,23 @@ - + - + - + @@ -46,17 +31,17 @@ import moment from 'moment' import InputArea from './InputArea' import SelectArea from './SelectArea' const tableProps = [ - { - prop: 'tableName', - label: '表名', - subcomponent: SelectArea - }, - { - prop: 'readingQuantity', - label: '抄表数', - subcomponent: InputArea - } - ] + { + prop: 'tableName', + label: '表名*', + subcomponent: SelectArea + }, + { + prop: 'readingQuantity', + label: '抄表数*', + subcomponent: InputArea + } +] export default { name: 'EnergyQuantityManualAdd', props: { @@ -72,7 +57,7 @@ export default { return { tableProps, tableData: [], - addButtonShow:'新增', + addButtonShow: '新增', form: { id: '', energyTypeId: '', @@ -98,16 +83,16 @@ export default { obj.tableName = params.tableName + '' obj.readingQuantity = 0 this.tableData.push(obj) - }else { + } else { this.isEdit = true this.form.id = params.id this.addButtonShow = '' - energyQuantityManualGet({id: this.form.id}).then(res => { + energyQuantityManualGet({ id: this.form.id }).then(res => { if (res.code === 0) { this.form.energyTypeId = res.data.energyTypeId this.form.recordTime = res.data.recordTime ? res.data.recordTime : null let obj = {} - obj.tableName = res.data.tableName ? res.data.tableName+'' : '' + obj.tableName = res.data.tableName ? res.data.tableName + '' : '' obj.readingQuantity = res.data.readingQuantity this.tableData.push(obj) } @@ -130,10 +115,10 @@ export default { if (this.tableData.length === 0) { this.$modal.msgError("抄表数据不能为空"); return false - }else{ + } else { for (let item of this.tableData) { console.log(item) - if (!item.tableName || (!item.readingQuantity && item.readingQuantity!==0)) { + if (!item.tableName || (!item.readingQuantity && item.readingQuantity !== 0)) { this.$modal.msgError("抄表数据有空值,请检查"); return false } @@ -142,11 +127,11 @@ export default { if (this.isEdit) { // 编辑 energyQuantityManualUpdate({ - id:this.form.id, - energyTypeId:this.form.energyTypeId, - recordTime:this.form.recordTime, - tableName:this.tableData[0].tableName, - readingQuantity:this.tableData[0].readingQuantity + id: this.form.id, + energyTypeId: this.form.energyTypeId, + recordTime: this.form.recordTime, + tableName: this.tableData[0].tableName, + readingQuantity: this.tableData[0].readingQuantity }).then((res) => { if (res.code === 0) { this.$modal.msgSuccess("操作成功"); @@ -155,9 +140,9 @@ export default { }) } else { energyQuantityManualCreate({ - energyTypeId:this.form.energyTypeId, - recordTime:this.form.recordTime, - data:this.tableData + energyTypeId: this.form.energyTypeId, + recordTime: this.form.recordTime, + data: this.tableData }).then((res) => { if (res.code === 0) { this.$modal.msgSuccess("操作成功"); diff --git a/src/views/energy/base/energyQuantityManual/index.vue b/src/views/energy/base/energyQuantityManual/index.vue index 49f6329b..26a19624 100644 --- a/src/views/energy/base/energyQuantityManual/index.vue +++ b/src/views/energy/base/energyQuantityManual/index.vue @@ -2,44 +2,20 @@
- + - - + + - + - - + +
@@ -68,7 +44,7 @@ const tableProps = [ }, { prop: 'tableName', - label: '水/气表名', + label: '能源表名', filter: publicFormatter('table_name'), minWidth: 110 }, @@ -142,25 +118,25 @@ export default { // 班次基础信息列表 list: [], tableBtn: [ - this.$auth.hasPermi('base:energy-quantity-manual:create') + this.$auth.hasPermi('base:energy-quantity-manual:create') ? { - type: 'meterReading', - btnName: '抄表' - } + type: 'meterReading', + btnName: '抄表' + } : undefined, this.$auth.hasPermi('base:energy-quantity-manual:update') ? { - type: 'edit', - btnName: '编辑' - } + type: 'edit', + btnName: '编辑' + } : undefined, this.$auth.hasPermi('base:energy-quantity-manual:delete') ? { - type: 'delete', - btnName: '删除' - } + type: 'delete', + btnName: '删除' + } : undefined - ].filter((v)=>v), + ].filter((v) => v), // 查询参数 queryParams: { pageNo: 1, @@ -209,10 +185,10 @@ export default { break default: this.$modal.confirm('是否确认导出').then(() => { - return energyQuantityManualExport({...this.queryParams}); - }).then(response => { - this.$download.excel(response, '能源报表.xls'); - }).catch(() => {}) + return energyQuantityManualExport({ energyTypeId: this.queryParams.energyTypeId, recordTime: this.queryParams.recordTime }); + }).then(response => { + this.$download.excel(response, '能源报表.xls'); + }).catch(() => { }) } }, /** 查询列表 */ @@ -281,13 +257,13 @@ export default { /** 删除按钮操作 */ handleDelete(row) { console.log(row.id) - this.$modal.confirm('是否确认删除能源类型为"' + row.energyType + '"的数据项?').then(function() { - return energyQuantityManualDelete({id: row.id}); - }).then(() => { - this.queryParams.pageNo = 1; - this.getList(); - this.$modal.msgSuccess("删除成功"); - }).catch(() => {}); + this.$modal.confirm('是否确认删除能源类型为"' + row.energyType + '"的数据项?').then(function () { + return energyQuantityManualDelete({ id: row.id }); + }).then(() => { + this.queryParams.pageNo = 1; + this.getList(); + this.$modal.msgSuccess("删除成功"); + }).catch(() => { }); } } }; diff --git a/src/views/energy/base/energyQuantityRealtime/index.vue b/src/views/energy/base/energyQuantityRealtime/index.vue index 956c4077..a8b9e6ed 100644 --- a/src/views/energy/base/energyQuantityRealtime/index.vue +++ b/src/views/energy/base/energyQuantityRealtime/index.vue @@ -2,27 +2,12 @@
- + - - + +
@@ -71,7 +56,8 @@ export default { type: 'select', label: '能源类型', selectOptions: [], - param: 'energyTypeId' + param: 'energyTypeId', + filterable: true }, { type: 'datePicker', @@ -129,7 +115,7 @@ export default { let arr = location.href.split('?')[1].split('&') this.formConfig[1].defaultSelect = [arr[0].split('=')[1], arr[1].split('=')[1]] } else { - this.formConfig[1].defaultSelect = [Date.now() - 7*24*3600000, Date.now()] + this.formConfig[1].defaultSelect = [Date.now() - 7 * 24 * 3600000, Date.now()] } this.queryParams.startTime = this.formConfig[1].defaultSelect[0] this.queryParams.endTime = this.formConfig[1].defaultSelect[1] @@ -146,7 +132,7 @@ export default { let arr = location.href.split('?')[1].split('&') this.formConfig[1].defaultSelect = [arr[0].split('=')[1], arr[1].split('=')[1]] } else { - this.formConfig[1].defaultSelect = [Date.now() - 7*24*3600000, Date.now()] + this.formConfig[1].defaultSelect = [Date.now() - 7 * 24 * 3600000, Date.now()] } this.queryParams.startTime = this.formConfig[1].defaultSelect[0] this.queryParams.endTime = this.formConfig[1].defaultSelect[1] diff --git a/src/views/energy/base/energyType/components/energyTypeAdd.vue b/src/views/energy/base/energyType/components/energyTypeAdd.vue index 1b808543..01ddcee0 100644 --- a/src/views/energy/base/energyType/components/energyTypeAdd.vue +++ b/src/views/energy/base/energyType/components/energyTypeAdd.vue @@ -16,10 +16,7 @@ - @@ -28,9 +25,9 @@ - - - + + + @@ -38,56 +35,33 @@ - + - - + + - + - - + + - - + + @@ -153,9 +127,11 @@ export default { name: '', code: '', unit: '', + singlePrice: 0, pricingMethod: 2, - leaderName: '', - push: false + dim: '', + push: false, + description: '' }, isEdit: false, //是否是编辑 rules: { @@ -182,22 +158,24 @@ export default { if (id) { this.isEdit = true this.form.id = id - getEnergyType( id ).then((res) => { + getEnergyType(id).then((res) => { if (res.code === 0) { this.form.name = res.data.name this.form.code = res.data.code this.form.unit = res.data.unit this.form.pricingMethod = res.data.pricingMethod - this.form.leaderName = res.data.leaderName - this.form.push = res.data.push ? true : false - switch(this.form.pricingMethod) { + this.form.push = res.data.push ? true : false + this.form.description = res.data.description + switch (this.form.pricingMethod) { case 0: this.tableData1 = res.data.segPriceList || [] break; case 1: this.tableData2 = res.data.usedPriceList || [] + this.form.dim = res.data.dim break; default: + this.form.singlePrice = res.data.singlePrice || 0 } } }) @@ -234,7 +212,7 @@ export default { emitButtonClick1() { let n = this.tableData1.length let obj = {} - obj.startTime = n === 0 ? '' : this.tableData1[n-1].endTime + obj.startTime = n === 0 ? '' : this.tableData1[n - 1].endTime obj.endTime = '' obj.price = 0 this.tableData1.push(obj) @@ -242,7 +220,7 @@ export default { emitButtonClick2() { let n = this.tableData2.length let obj = {} - obj.startUsed = n === 0 ? 0 : this.tableData2[n-1].endUsed + obj.startUsed = n === 0 ? 0 : this.tableData2[n - 1].endUsed obj.endUsed = 0 obj.price = 0 this.tableData2.push(obj) @@ -259,7 +237,7 @@ export default { submitForm() { this.$refs['form'].validate((valid) => { if (valid) { - switch(this.form.pricingMethod) { + switch (this.form.pricingMethod) { case 0:// 时间段 if (this.tableData1.length === 0) { this.$modal.msgError('时间段表格数据不能为空') @@ -289,7 +267,7 @@ export default { default:// 固定单价 if (!this.form.singlePrice) { this.$modal.msgError('单价有误请检查,请检查') - return false + return false } } console.log(this.form) @@ -302,11 +280,11 @@ export default { unit: this.form.unit, pricingMethod: this.form.pricingMethod, description: this.form.description, - dim: this.form.pricingMethod === 1 ? this.form.dim: '', + dim: this.form.pricingMethod === 1 ? this.form.dim : '', singlePrice: this.form.pricingMethod === 2 ? this.form.singlePrice : '', - segPriceList: this.form.pricingMethod === 0 ? this.tableData1: [], - usedPriceList: this.form.pricingMethod === 1 ? this.tableData2: [], - push:this.form.push ? 1 : 0 + segPriceList: this.form.pricingMethod === 0 ? this.tableData1 : [], + usedPriceList: this.form.pricingMethod === 1 ? this.tableData2 : [], + push: this.form.push ? 1 : 0 }).then((res) => { if (res.code === 0) { this.$modal.msgSuccess("操作成功"); @@ -320,11 +298,11 @@ export default { unit: this.form.unit, pricingMethod: this.form.pricingMethod, description: this.form.description, - dim: this.form.pricingMethod === 1 ? this.form.dim: '', + dim: this.form.pricingMethod === 1 ? this.form.dim : '', singlePrice: this.form.pricingMethod === 2 ? this.form.singlePrice : '', - segPriceList: this.form.pricingMethod === 0 ? this.tableData1: [], - usedPriceList: this.form.pricingMethod === 1 ? this.tableData2: [], - push:this.form.push ? 1 : 0 + segPriceList: this.form.pricingMethod === 0 ? this.tableData1 : [], + usedPriceList: this.form.pricingMethod === 1 ? this.tableData2 : [], + push: this.form.push ? 1 : 0 }).then((res) => { if (res.code === 0) { this.$modal.msgSuccess("操作成功"); diff --git a/src/views/group/monitoring/groupTeamView/components/groupTeamViewDetail.vue b/src/views/group/monitoring/groupTeamView/components/groupTeamViewDetail.vue index 3e46b185..de22d382 100644 --- a/src/views/group/monitoring/groupTeamView/components/groupTeamViewDetail.vue +++ b/src/views/group/monitoring/groupTeamView/components/groupTeamViewDetail.vue @@ -1,6 +1,6 @@ @@ -192,14 +188,14 @@ const tableProps = [ filter: publicFormatter('workshop') }, { - prop: 'planQuantity', - label: '计划加工量', - width: 100 + prop: 'planAssignmentQuantity', + label: '计划分配数量', + width: 110 }, { - prop: 'actualQuantity', - label: '实际加工量', - width: 100 + prop: 'actualAssignmentQuantity', + label: '实际分配数量', + width: 110 }, { prop: 'actualArea', @@ -266,16 +262,16 @@ export default { id: this.orderGroupId }).then(res => { this.orderGroupMsg = res.data - if ( res.data.orderIdNum && res.data.orderIdNum > 0) { + if (res.data.orderIdNum && res.data.orderIdNum > 0) { this.orderMsg = res.data.orderDetailVOS - }else{ + } else { this.orderMsg = [] } }) }, // 返回 returnOrderManage() { - this.$router.push({path: '/order/base/order-group'}) + this.$router.push({ path: '/order/base/order-group' }) } } } @@ -285,43 +281,51 @@ export default { height: calc(100vh - 120px - 8px); background-color: rgb(242, 244, 249); overflow: auto; - .box1, .box2 { + + .box1, + .box2 { background-color: #fff; border-radius: 9px; + .blodTip { height: 16px; font-size: 14px; font-weight: 600; - color: rgba(0,0,0,0.85); + color: rgba(0, 0, 0, 0.85); margin-bottom: 8px; } + .lightTip { height: 16px; font-size: 14px; font-weight: 400; - color: rgba(102,102,102,0.75); + color: rgba(102, 102, 102, 0.75); margin-bottom: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } } + .box2 { height: 415px; padding: 12px 16px 0; margin: 8px 0; } + .box1 { height: 215px; padding: 16px 16px 0 16px; } + .boxTitle { display: inline-block; font-size: 16px; font-weight: 400; color: #000000; - margin:0 10px 20px 0; + margin: 0 10px 20px 0; } + .blueTitle { content: ''; display: inline-block; diff --git a/src/views/order/base/orderManage/components/addWorkOrder.vue b/src/views/order/base/orderManage/components/addWorkOrder.vue index ea46e766..e340cfe3 100644 --- a/src/views/order/base/orderManage/components/addWorkOrder.vue +++ b/src/views/order/base/orderManage/components/addWorkOrder.vue @@ -5,13 +5,10 @@ - - - + + + @@ -23,12 +20,8 @@ - - + + @@ -42,36 +35,28 @@ - + - + - + - + @@ -79,18 +64,15 @@ - + - + @@ -99,10 +81,7 @@ - @@ -111,11 +90,7 @@ - + @@ -123,45 +98,39 @@ - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/views/report/glass/inputTable.vue b/src/views/report/glass/inputTable.vue index d5d6614a..6a68c98e 100644 --- a/src/views/report/glass/inputTable.vue +++ b/src/views/report/glass/inputTable.vue @@ -1,7 +1,7 @@ @@ -9,10 +9,10 @@
编辑 - 返回 + 返回 保存 - + - + +
@@ -112,7 +114,7 @@ const cols = [ label: '本周', }, { - prop: 'originalGlassPassHis ', + prop: 'originalGlassPassHis', label: '上周', }, { @@ -130,6 +132,10 @@ const cols = [ type: Array, default: () => [], }, + id: { + type: String, + default:'exportTable' + }, time: { type: Array, default: () => [], @@ -150,6 +156,7 @@ const cols = [ data() { return { cols, + remark:null, edit: false, }; }, @@ -195,16 +202,44 @@ const cols = [ } } }, - methods: { + methods: { + handleReturn() { + // this.disabled = true + this.edit = false + }, + handleChange(e) { + // console.log(q) + console.log(e); + }, updateData() { + let obj = {} this.data.forEach((ele, index) => { + if (ele.det === false) { + this.data[index].lineId = '' + this.data[index].remark = this.remark + obj = ele + delete this.data[index].dailyOutputTrend + delete this.data[index].originalGlassStatisticsTrend + delete this.data[index].actualProductTrend + delete this.data[index].originalGlassPassTrend + this.data.splice(index, 1) + } + }) + let updateArr = this.data + updateArr.forEach((ele, index) => { delete ele.dailyOutputTrend delete ele.originalGlassStatisticsTrend delete ele.actualProductTrend delete ele.originalGlassPassTrend }); - updateGlass(this.data).then(response => { - updateGlassRemark(this.sum).then(res => { + // this.data.forEach((ele, index) => { + // delete ele.dailyOutputTrend + // delete ele.originalGlassStatisticsTrend + // delete ele.actualProductTrend + // delete ele.originalGlassPassTrend + // }); + updateGlass(updateArr).then(response => { + updateGlassRemark(obj).then(res => { this.$modal.msgSuccess("修改成功"); this.edit = false; this.$emit("refreshDataList"); diff --git a/src/views/report/glass/month.vue b/src/views/report/glass/month.vue index 011a2c4b..9b099a73 100644 --- a/src/views/report/glass/month.vue +++ b/src/views/report/glass/month.vue @@ -29,7 +29,8 @@ import { parseTime } from '../../core/mixins/code-filter'; import { getGlassPage, exportGlasscExcel } from '@/api/report/glass'; import inputTable from './inputTable.vue'; import { getCorePLList } from '@/api/base/coreProductionLine'; - +import FileSaver from 'file-saver' +import * as XLSX from 'xlsx' export default { components: { inputTable }, data() { @@ -72,29 +73,61 @@ export default { // console.log(date) this.changeTime(date) // console.log(date.valueOf()); + }, + multipliedByHundred(str) { + if (str) { + let floatVal = parseFloat(str); + if (isNaN(floatVal)) { + return 0; + } + floatVal = Math.round(str * 10000) / 100; + let strVal = floatVal.toString(); + let searchVal = strVal.indexOf('.'); + if (searchVal < 0) { + searchVal = strVal.length; + strVal += '.'; + } + while (strVal.length <= searchVal + 2) { + strVal += '0'; + } + return parseFloat(strVal); + } + }, // 获取数据列表 async getDataList() { this.dataListLoading = true; - await this.urlOptions.getDataListURL(this.listQuery).then(response => { - this.tableData = response.data.filter(item => { - this.proLineList.forEach(it => { - if (item.lineId === it.id) { + if (this.listQuery.reportTime.length == 0) { + this.$message({ + message: '请选择时间', + type: 'warning' + }) + return false + } + await this.urlOptions.getDataListURL(this.listQuery).then(res => { + res.data.forEach((ele, index) => { + if (ele.det === false) { + res.data[index].lineName = '合计' + this.remark = res.data[index].remark + res.data[index].dailyOutputTrend = res.data[index].dailyOutputTrend != 0 ? this.multipliedByHundred(res.data[index].dailyOutputTrend) + '%' : res.data[index].dailyOutputTrend == 0 ? 0 : undefined + res.data[index].originalGlassStatisticsTrend = res.data[index].originalGlassStatisticsTrend != 0 ? this.multipliedByHundred(res.data[index].originalGlassStatisticsTrend) + '%' : res.data[index].originalGlassStatisticsTrend == 0 ? 0 : undefined + res.data[index].actualProductTrend = res.data[index].actualProductTrend != 0 ? this.multipliedByHundred(res.data[index].actualProductTrend) + '%' : res.data[index].actualProductTrend == 0 ? 0 : undefined + res.data[index].originalGlassPassTrend = res.data[index].originalGlassPassTrend != 0 ? this.multipliedByHundred(res.data[index].originalGlassPassTrend) + '%' : res.data[index].originalGlassPassTrend == 0 ? 0 : undefined + } + }) + res.data.forEach(item => { + this.proLineList.forEach(it => { + if (item.lineId === it.id) { + console.log(item) item.lineName = it.name - item.dailyOutputTrend = item.dailyOutputTrend ? parseFloat((item.dailyOutputTrend * 100).toFixed(2)) + '%' : null - item.originalGlassStatisticsTrend = item.originalGlassStatisticsTrend ? parseFloat((item.originalGlassStatisticsTrend * 100).toFixed(2)) + '%' : null - item.actualProductTrend = item.actualProductTrend ? parseFloat((item.originalGlassStatisticsTrend * 100).toFixed(2)) + '%' : null - item.originalGlassPassTrend = item.originalGlassPassTrend ? parseFloat((item.originalGlassStatisticsTrend * 100).toFixed(2)) + '%' : null - } - }) - if (item.det === false) { - this.all = { - id: item.id, - remark: item.remark - } - } - return item.det === true - }); + item.dailyOutputTrend = item.dailyOutputTrend != 0 ? this.multipliedByHundred(item.dailyOutputTrend) + '%' : item.dailyOutputTrend == 0 ? 0 : undefined + item.originalGlassStatisticsTrend = item.originalGlassStatisticsTrend != 0 ? this.multipliedByHundred(item.originalGlassStatisticsTrend) + '%' : item.originalGlassStatisticsTrend == 0 ? 0 : undefined + item.actualProductTrend = item.actualProductTrend != 0 ? this.multipliedByHundred(item.actualProductTrend) + '%' : item.actualProductTrend == 0 ? 0 : undefined + item.originalGlassPassTrend = item.originalGlassPassTrend != 0 ? this.multipliedByHundred(item.originalGlassPassTrend) + '%' : item.originalGlassPassTrend == 0 ? 0 : undefined + } + }) + }) + this.tableData = res.data this.listQuery.total = response.data.length; this.dataListLoading = false; }); @@ -165,16 +198,32 @@ export default { /** 导出按钮操作 */ handleExport() { // 处理查询参数 - let params = { ...this.listQuery }; - params.pageNo = undefined; - params.pageSize = undefined; - this.$modal.confirm('是否确认导出所有数据项?').then(() => { - this.exportLoading = true; - return this.urlOptions.exportURL(params); - }).then(response => { - this.$download.excel(response, '原片生产周报.xls'); - this.exportLoading = false; - }).catch(() => { }); + var xlsxParam = { raw: true }; + /* 从表生成工作簿对象 */ + var wb = XLSX.utils.table_to_book( + document.querySelector("#exportTable"), + xlsxParam + ); + /* 获取二进制字符串作为输出 */ + var wbout = XLSX.write(wb, { + bookType: "xlsx", + bookSST: true, + type: "array", + }); + try { + FileSaver.saveAs( + //Blob 对象表示一个不可变、原始数据的类文件对象。 + //Blob 表示的不一定是JavaScript原生格式的数据。 + //File 接口基于Blob,继承了 blob 的功能并将其扩展使其支持用户系统上的文件。 + //返回一个新创建的 Blob 对象,其内容由参数中给定的数组串联组成。 + new Blob([wbout], { type: "application/octet-stream" }), + //设置导出文件名称 + "许昌安彩月原片生产汇总.xlsx" + ); + } catch (e) { + if (typeof console !== "undefined") console.log(e, wbout); + } + return wbout; } }, }; diff --git a/src/views/report/glass/weekly.vue b/src/views/report/glass/weekly.vue index 8c85adbf..7df919b7 100644 --- a/src/views/report/glass/weekly.vue +++ b/src/views/report/glass/weekly.vue @@ -31,7 +31,8 @@ import { parseTime } from '../../core/mixins/code-filter'; import { getGlassPage, exportGlasscExcel } from '@/api/report/glass'; import inputTable from './inputTable.vue'; import { getCorePLList } from '@/api/base/coreProductionLine'; - +import FileSaver from 'file-saver' +import * as XLSX from 'xlsx' export default { components: { inputTable }, data() { @@ -163,29 +164,61 @@ export default { // this.endTimeStamp = this.timeFun(timeStamp + (24 * 60 * 60 * 1000) * 5); //结束时间 // this.changeTime(reportTime) } + }, + multipliedByHundred(str) { + if (str) { + let floatVal = parseFloat(str); + if (isNaN(floatVal)) { + return 0; + } + floatVal = Math.round(str * 10000) / 100; + let strVal = floatVal.toString(); + let searchVal = strVal.indexOf('.'); + if (searchVal < 0) { + searchVal = strVal.length; + strVal += '.'; + } + while (strVal.length <= searchVal + 2) { + strVal += '0'; + } + return parseFloat(strVal); + } + }, // 获取数据列表 async getDataList() { this.dataListLoading = true; - await this.urlOptions.getDataListURL(this.listQuery).then(response => { - this.tableData = response.data.filter(item => { - this.proLineList.forEach(it => { - if (item.lineId === it.id) { + if (this.listQuery.reportTime.length == 0) { + this.$message({ + message: '请选择时间', + type: 'warning' + }) + return false + } + await this.urlOptions.getDataListURL(this.listQuery).then(res => { + res.data.forEach((ele, index) => { + if (ele.det === false) { + res.data[index].lineName = '合计' + this.remark = res.data[index].remark + res.data[index].dailyOutputTrend = res.data[index].dailyOutputTrend != 0 ? this.multipliedByHundred(res.data[index].dailyOutputTrend) + '%' : res.data[index].dailyOutputTrend == 0 ? 0 : undefined + res.data[index].originalGlassStatisticsTrend = res.data[index].originalGlassStatisticsTrend != 0 ? this.multipliedByHundred(res.data[index].originalGlassStatisticsTrend) + '%' : res.data[index].originalGlassStatisticsTrend == 0 ? 0 : undefined + res.data[index].actualProductTrend = res.data[index].actualProductTrend != 0 ? this.multipliedByHundred(res.data[index].actualProductTrend) + '%' : res.data[index].actualProductTrend == 0 ? 0 : undefined + res.data[index].originalGlassPassTrend = res.data[index].originalGlassPassTrend != 0 ? this.multipliedByHundred(res.data[index].originalGlassPassTrend) + '%' : res.data[index].originalGlassPassTrend == 0 ? 0 : undefined + } + }) + res.data.forEach(item => { + this.proLineList.forEach(it => { + if (item.lineId === it.id) { + console.log(item) item.lineName = it.name - item.dailyOutputTrend = item.dailyOutputTrend ? parseFloat((item.dailyOutputTrend * 100).toFixed(2)) + '%' : null - item.originalGlassStatisticsTrend = item.originalGlassStatisticsTrend ? parseFloat((item.originalGlassStatisticsTrend * 100).toFixed(2)) + '%' : null - item.actualProductTrend = item.actualProductTrend ? parseFloat((item.originalGlassStatisticsTrend * 100).toFixed(2)) + '%' : null - item.originalGlassPassTrend = item.originalGlassPassTrend ? parseFloat((item.originalGlassStatisticsTrend * 100).toFixed(2)) + '%' : null - } - }) - if (item.det === false) { - this.all = { - id: item.id, - remark: item.remark - } - } - return item.det === true - }); + item.dailyOutputTrend = item.dailyOutputTrend != 0 ? this.multipliedByHundred(item.dailyOutputTrend) + '%' : item.dailyOutputTrend == 0 ? 0 : undefined + item.originalGlassStatisticsTrend = item.originalGlassStatisticsTrend != 0 ? this.multipliedByHundred(item.originalGlassStatisticsTrend) + '%' : item.originalGlassStatisticsTrend == 0 ? 0 : undefined + item.actualProductTrend = item.actualProductTrend != 0 ? this.multipliedByHundred(item.actualProductTrend) + '%' : item.actualProductTrend == 0 ? 0 : undefined + item.originalGlassPassTrend = item.originalGlassPassTrend != 0 ? this.multipliedByHundred(item.originalGlassPassTrend) + '%' : item.originalGlassPassTrend == 0 ? 0 : undefined + } + }) + }) + this.tableData = res.data this.listQuery.total = response.data.length; this.dataListLoading = false; }); @@ -230,16 +263,32 @@ export default { /** 导出按钮操作 */ handleExport() { // 处理查询参数 - let params = { ...this.listQuery }; - params.pageNo = undefined; - params.pageSize = undefined; - this.$modal.confirm('是否确认导出所有数据项?').then(() => { - this.exportLoading = true; - return this.urlOptions.exportURL(params); - }).then(response => { - this.$download.excel(response, '原片生产周报.xls'); - this.exportLoading = false; - }).catch(() => { }); + var xlsxParam = { raw: true }; + /* 从表生成工作簿对象 */ + var wb = XLSX.utils.table_to_book( + document.querySelector("#exportTable"), + xlsxParam + ); + /* 获取二进制字符串作为输出 */ + var wbout = XLSX.write(wb, { + bookType: "xlsx", + bookSST: true, + type: "array", + }); + try { + FileSaver.saveAs( + //Blob 对象表示一个不可变、原始数据的类文件对象。 + //Blob 表示的不一定是JavaScript原生格式的数据。 + //File 接口基于Blob,继承了 blob 的功能并将其扩展使其支持用户系统上的文件。 + //返回一个新创建的 Blob 对象,其内容由参数中给定的数组串联组成。 + new Blob([wbout], { type: "application/octet-stream" }), + //设置导出文件名称 + "许昌安彩周原片生产汇总.xlsx" + ); + } catch (e) { + if (typeof console !== "undefined") console.log(e, wbout); + } + return wbout; } }, }; diff --git a/src/views/report/glass/year.vue b/src/views/report/glass/year.vue index c9146476..6bff74f9 100644 --- a/src/views/report/glass/year.vue +++ b/src/views/report/glass/year.vue @@ -26,7 +26,8 @@ import { parseTime } from '../../core/mixins/code-filter'; import { getGlassPage, exportGlasscExcel } from '@/api/report/glass'; import inputTable from './inputTable.vue'; import { getCorePLList } from '@/api/base/coreProductionLine'; - +import FileSaver from 'file-saver' +import * as XLSX from 'xlsx' export default { components: { inputTable }, data() { @@ -74,29 +75,61 @@ export default { // 产线列表 const res = await getCorePLList(); this.proLineList = res.data; - }, + }, + multipliedByHundred(str) { + if (str) { + let floatVal = parseFloat(str); + if (isNaN(floatVal)) { + return 0; + } + floatVal = Math.round(str * 10000) / 100; + let strVal = floatVal.toString(); + let searchVal = strVal.indexOf('.'); + if (searchVal < 0) { + searchVal = strVal.length; + strVal += '.'; + } + while (strVal.length <= searchVal + 2) { + strVal += '0'; + } + return parseFloat(strVal); + } + + }, // 获取数据列表 async getDataList() { this.dataListLoading = true; - await this.urlOptions.getDataListURL(this.listQuery).then(response => { - this.tableData = response.data.filter(item => { - this.proLineList.forEach(it => { + if (this.listQuery.reportTime.length == 0) { + this.$message({ + message: '请选择时间', + type: 'warning' + }) + return false + } + await this.urlOptions.getDataListURL(this.listQuery).then(res => { + res.data.forEach((ele, index) => { + if (ele.det === false) { + res.data[index].lineName = '合计' + this.remark = res.data[index].remark + res.data[index].dailyOutputTrend = res.data[index].dailyOutputTrend != 0 ? this.multipliedByHundred(res.data[index].dailyOutputTrend) + '%' : res.data[index].dailyOutputTrend == 0 ? 0 : undefined + res.data[index].originalGlassStatisticsTrend = res.data[index].originalGlassStatisticsTrend != 0 ? this.multipliedByHundred(res.data[index].originalGlassStatisticsTrend) + '%' : res.data[index].originalGlassStatisticsTrend == 0 ? 0 : undefined + res.data[index].actualProductTrend = res.data[index].actualProductTrend != 0 ? this.multipliedByHundred(res.data[index].actualProductTrend) + '%' : res.data[index].actualProductTrend == 0 ? 0 : undefined + res.data[index].originalGlassPassTrend = res.data[index].originalGlassPassTrend != 0 ? this.multipliedByHundred(res.data[index].originalGlassPassTrend) + '%' : res.data[index].originalGlassPassTrend == 0 ? 0 : undefined + } + }) + res.data.forEach(item => { + this.proLineList.forEach(it => { if (item.lineId === it.id) { - item.dailyOutputTrend = item.dailyOutputTrend ? parseFloat((item.dailyOutputTrend * 100).toFixed(2)) + '%' : null - item.originalGlassStatisticsTrend = item.originalGlassStatisticsTrend ? parseFloat((item.originalGlassStatisticsTrend * 100).toFixed(2)) + '%' : null - item.actualProductTrend = item.actualProductTrend ? parseFloat((item.originalGlassStatisticsTrend * 100).toFixed(2)) + '%' : null - item.originalGlassPassTrend = item.originalGlassPassTrend ? parseFloat((item.originalGlassStatisticsTrend * 100).toFixed(2)) + '%' : null - item.lineName = it.name - } - }) - if (item.det === false) { - this.all = { - id: item.id, - remark: item.remark - } - } - return item.det === true - }); + console.log(item) + item.lineName = it.name + item.dailyOutputTrend = item.dailyOutputTrend != 0 ? this.multipliedByHundred(item.dailyOutputTrend) + '%' : item.dailyOutputTrend == 0 ? 0 : undefined + item.originalGlassStatisticsTrend = item.originalGlassStatisticsTrend != 0 ? this.multipliedByHundred(item.originalGlassStatisticsTrend) + '%' : item.originalGlassStatisticsTrend == 0 ? 0 : undefined + item.actualProductTrend = item.actualProductTrend != 0 ? this.multipliedByHundred(item.actualProductTrend) + '%' : item.actualProductTrend == 0 ? 0 : undefined + item.originalGlassPassTrend = item.originalGlassPassTrend != 0 ? this.multipliedByHundred(item.originalGlassPassTrend) + '%' : item.originalGlassPassTrend == 0 ? 0 : undefined + } + }) + }) + this.tableData = res.data this.listQuery.total = response.data.length; this.dataListLoading = false; }); @@ -139,16 +172,32 @@ export default { /** 导出按钮操作 */ handleExport() { // 处理查询参数 - let params = { ...this.listQuery }; - params.pageNo = undefined; - params.pageSize = undefined; - this.$modal.confirm('是否确认导出所有数据项?').then(() => { - this.exportLoading = true; - return this.urlOptions.exportURL(params); - }).then(response => { - this.$download.excel(response, '原片生产周报.xls'); - this.exportLoading = false; - }).catch(() => { }); + var xlsxParam = { raw: true }; + /* 从表生成工作簿对象 */ + var wb = XLSX.utils.table_to_book( + document.querySelector("#exportTable"), + xlsxParam + ); + /* 获取二进制字符串作为输出 */ + var wbout = XLSX.write(wb, { + bookType: "xlsx", + bookSST: true, + type: "array", + }); + try { + FileSaver.saveAs( + //Blob 对象表示一个不可变、原始数据的类文件对象。 + //Blob 表示的不一定是JavaScript原生格式的数据。 + //File 接口基于Blob,继承了 blob 的功能并将其扩展使其支持用户系统上的文件。 + //返回一个新创建的 Blob 对象,其内容由参数中给定的数组串联组成。 + new Blob([wbout], { type: "application/octet-stream" }), + //设置导出文件名称 + "许昌安彩年原片生产汇总.xlsx" + ); + } catch (e) { + if (typeof console !== "undefined") console.log(e, wbout); + } + return wbout; } }, }; diff --git a/src/views/report/productionDayReport/index.vue b/src/views/report/productionDayReport/index.vue index 0d8e23d0..2dcd82e4 100644 --- a/src/views/report/productionDayReport/index.vue +++ b/src/views/report/productionDayReport/index.vue @@ -1,13 +1,13 @@