diff --git a/src/api/model/cm.js b/src/api/model/cm.js index cf9940e3..f50827e6 100644 --- a/src/api/model/cm.js +++ b/src/api/model/cm.js @@ -101,6 +101,14 @@ export default { `${config.API_URL}/cm/labeltemplate/${id}/send_to_coder/`, data); } + }, + sendToHanslaser:{ + name: "下发到激光", + req: async function(id, data){ + return await http.post( + `${config.API_URL}/cm/labeltemplate/${id}/send_to_hanslaser/`, + data); + } } } } diff --git a/src/api/model/em.js b/src/api/model/em.js index 405c35e0..17fc615b 100644 --- a/src/api/model/em.js +++ b/src/api/model/em.js @@ -126,6 +126,14 @@ export default { data); } }, + get_svs_char: { + name: "获取数据识别", + req: async function(data){ + return await http.get( + `${config.API_URL}/em/equipment/get_svs_char/`, + data); + } + } }, //巡检记录 einspect: { diff --git a/src/config/route.js b/src/config/route.js index 5e652bc8..5975be6d 100644 --- a/src/config/route.js +++ b/src/config/route.js @@ -3528,6 +3528,7 @@ const routes = [ path: "/statistic/task_rate", meta: { title: "任务进度", + hidden: true, // icon: "el-icon-DataAnalysis", perms: ["statistic_wpm"], }, @@ -3595,6 +3596,7 @@ const routes = [ name: "user_statistics", meta: { title: "绩效统计", + hidden: true, icon: "el-icon-trend-charts", perms: ["statistic_kpi"], }, diff --git a/src/layout/components/userbar.vue b/src/layout/components/userbar.vue index 3e9c6c9e..16902e1a 100644 --- a/src/layout/components/userbar.vue +++ b/src/layout/components/userbar.vue @@ -1,15 +1,36 @@ + + + + diff --git a/src/views/bigScreen/index_photon.vue b/src/views/bigScreen/index_photon.vue index 7eceb216..11aa755a 100644 --- a/src/views/bigScreen/index_photon.vue +++ b/src/views/bigScreen/index_photon.vue @@ -463,10 +463,21 @@ export default { percentage: 100, count_guan: 0, }, + isUnmounted: false, + pieChart: null, + line1Chart: null, + line2Chart: null, + line3Chart: null, + bar1Chart: null, + onResize: null, + onCanvasMouseMove: null, + onCanvasClick: null, + canvasEl: null, }; }, mounted() { loadBabylon().then(() => { + if (this.isUnmounted) return; this.initView(); }) }, @@ -536,27 +547,22 @@ export default { that.showTime(); }, 1000); that.notokTimer = setInterval(() => { + if (that.isUnmounted) return; let pieDom = document.getElementById("pie"); - if (pieDom) { - if (that.deptName == "10车间") { - that.deptName = "7车间"; - } else { - that.deptName = "10车间"; - } - let deptData = []; - if (that.deptName == "7车间") { - deptData = that.dept7Data; - } else { - deptData = that.dept10Data; - } - that.pieoption.series.data = deptData; - let pieoption = that.pieoption; - - let pieChart = echarts.init(pieDom); - pieChart.clear(); - pieChart.setOption(pieoption, true); + if (!pieDom) return; + if (that.deptName == "10车间") { + that.deptName = "7车间"; + } else { + that.deptName = "10车间"; } - }, 5000); + let deptData = + that.deptName == "7车间" ? that.dept7Data : that.dept10Data; + that.pieoption.series.data = deptData; + if (!that.pieChart || that.pieChart.isDisposed()) { + that.pieChart = echarts.init(pieDom); + } + that.pieChart.setOption(that.pieoption, true); + }, 60000); that.timerData = setInterval(() => { that.getDeptDetail(); }, 60000); @@ -592,8 +598,12 @@ export default { that.getCountDept7(); //左1---本周交付数 let chartDom = document.getElementById("line1"); + if (!chartDom) return; chartDom.style.height = this.blockHeight; - let myChart = echarts.init(chartDom); + if (!that.line1Chart || that.line1Chart.isDisposed()) { + that.line1Chart = echarts.init(chartDom); + } + let myChart = that.line1Chart; let option = { tooltip: { trigger: "axis", @@ -862,8 +872,12 @@ export default { } //柱状图折线 let line3Dom = document.getElementById("line3"); + if (!line3Dom) return; line3Dom.style.height = this.blockHeight; - let line3Chart = echarts.init(line3Dom); + if (!that.line3Chart || that.line3Chart.isDisposed()) { + that.line3Chart = echarts.init(line3Dom); + } + let line3Chart = that.line3Chart; let line3option = { tooltip: { trigger: "axis", @@ -1217,7 +1231,7 @@ export default { // 添加抓取事件 const hl1 = new BABYLON.HighlightLayer("hl1", scene); const hl1Click = new BABYLON.HighlightLayer("hl1Click", scene); - canvas.addEventListener("mousemove", (event) => { + that.onCanvasMouseMove = (event) => { // 使用 scene.pick 检测鼠标拾取 const pickResult = scene.pick( scene.pointerX, @@ -1292,8 +1306,9 @@ export default { } else { that.infoVisibel = false; } - }); - canvas.addEventListener("click", (event) => { + }; + canvas.addEventListener("mousemove", that.onCanvasMouseMove); + that.onCanvasClick = (event) => { // 使用 scene.pick 检测鼠标拾取 const pickResult = scene.pick( scene.pointerX, @@ -1364,7 +1379,8 @@ export default { } } } - }); + }; + canvas.addEventListener("click", that.onCanvasClick); return scene; }; const scene = createScene(); //Call the createScene function @@ -1374,9 +1390,9 @@ export default { }); this.engine = engine; this.scene = scene; - window.addEventListener("resize", function () { - engine.resize(); - }); + this.canvasEl = canvas; + this.onResize = () => engine.resize(); + window.addEventListener("resize", this.onResize); }, getDeptData(name) { this.infoVisibel = true; @@ -1505,8 +1521,12 @@ export default { let that = this; //左边2 let bar1 = document.getElementById("bar1"); + if (!bar1) return; bar1.style.height = this.blockHeight; - let bar1Chart = echarts.init(bar1); + if (!that.bar1Chart || that.bar1Chart.isDisposed()) { + that.bar1Chart = echarts.init(bar1); + } + let bar1Chart = that.bar1Chart; let bar1option = { tooltip: { trigger: "axis", @@ -1655,8 +1675,12 @@ export default { bar1Chart.setOption(bar1option); //左3 let line2Dom = document.getElementById("line2"); + if (!line2Dom) return; line2Dom.style.height = this.blockHeight; - let line2Chart = echarts.init(line2Dom); + if (!that.line2Chart || that.line2Chart.isDisposed()) { + that.line2Chart = echarts.init(line2Dom); + } + let line2Chart = that.line2Chart; let line2option = { tooltip: { trigger: "axis", @@ -1845,8 +1869,12 @@ export default { line2Chart.setOption(line2option); //饼状图 let pieDom = document.getElementById("pie"); + if (!pieDom) return; pieDom.style.height = this.blockHeight; - let pieChart = echarts.init(pieDom); + if (!that.pieChart || that.pieChart.isDisposed()) { + that.pieChart = echarts.init(pieDom); + } + let pieChart = that.pieChart; let pieoption = { color: [ "rgb(237,224,45)", @@ -1914,22 +1942,53 @@ export default { }, }, beforeUnmount() { - let that = this; - clearInterval(that.timerTime); - clearInterval(that.timerData); - clearInterval(that.notokTimer); - that.timerTime = null; - that.timerData = null; - that.notokTimer = null; - }, - beforeDestoryed() { - let that = this; - clearInterval(that.timerTime); - clearInterval(that.timerData); - clearInterval(that.notokTimer); - that.timerTime = null; - that.timerData = null; - that.notokTimer = null; + this.isUnmounted = true; + // 定时器 + clearInterval(this.timerTime); + clearInterval(this.timerData); + clearInterval(this.notokTimer); + clearInterval(this.heightTimer); + this.timerTime = null; + this.timerData = null; + this.notokTimer = null; + this.heightTimer = null; + // echarts 实例 + [ + this.pieChart, + this.line1Chart, + this.line2Chart, + this.line3Chart, + this.bar1Chart, + ].forEach((c) => { + if (c && !c.isDisposed()) c.dispose(); + }); + this.pieChart = this.line1Chart = this.line2Chart = this.line3Chart = this.bar1Chart = null; + // 事件监听器 + if (this.onResize) { + window.removeEventListener("resize", this.onResize); + this.onResize = null; + } + if (this.canvasEl) { + if (this.onCanvasMouseMove) { + this.canvasEl.removeEventListener("mousemove", this.onCanvasMouseMove); + } + if (this.onCanvasClick) { + this.canvasEl.removeEventListener("click", this.onCanvasClick); + } + this.canvasEl = null; + } + this.onCanvasMouseMove = null; + this.onCanvasClick = null; + // babylon 引擎 + if (this.scene) { + try { this.scene.dispose(); } catch (e) {} + this.scene = null; + } + if (this.engine) { + try { this.engine.stopRenderLoop(); } catch (e) {} + try { this.engine.dispose(); } catch (e) {} + this.engine = null; + } }, }; diff --git a/src/views/inm/mioitem_form.vue b/src/views/inm/mioitem_form.vue index 7ee5c7b8..1f52f301 100644 --- a/src/views/inm/mioitem_form.vue +++ b/src/views/inm/mioitem_form.vue @@ -90,6 +90,7 @@ v-model="selectBatch" value-key="id" clearable + :multiple="project_code=='gz'&&form.type == 'sale_out'" filterable remote = "true" :style="divStyle" @@ -581,6 +582,13 @@ export default { that.form.count = Number(that.selectObj.count_canmio); that.mTracking = that.selectObj.material_.tracking; that.selectBatchChange(that.selectObj) + }else if(that.type == "sale_out"&&that.project_code=='gz'){ + that.form.material = that.selectObj.id; + that.form.unit = that.selectObj.unit; + that.form.unit_price = that.selectObj.unit_price; + that.mTracking = that.selectObj.tracking; + that.selectBatch = []; + that.getBatchOptions(); }else{ var type = this.form.type; that.form.material = that.selectObj.id; @@ -616,6 +624,26 @@ export default { let that = this; that.wprList = []; that.mioitems = []; + // gz 销售发货:多选批次 + if(that.form.type == 'sale_out' && that.project_code == 'gz' && Array.isArray(items)){ + if(items.length === 0){ + that.form.batch = ""; + that.form.mb = ""; + that.form.count = 0; + that.batchcount = 0; + that.form.warehouse = ""; + that.inputBatchDisable = false; + return; + } + let totalCount = items.reduce((sum, it) => sum + Number(it.count_canmio || 0), 0); + that.form.batch = items.map(it => it.batch).join(','); + that.form.mb = items.map(it => it.id).join(','); + that.form.count = totalCount; + that.batchcount = totalCount; + that.form.warehouse = items[0].warehouse; + that.inputBatchDisable = true; + return; + } if(items){ if(that.form.type == 'sale_out'&&that.project_code=='bxerp'){ let count = 0; @@ -876,7 +904,21 @@ export default { try { let res; if (that.mode == "add") { - res = await that.$API.inm.mioitem.create.req(that.form); + if(that.form.type == 'sale_out' && that.project_code == 'gz' && Array.isArray(that.selectBatch) && that.selectBatch.length > 0){ + let payload = that.selectBatch.map(b => ({ + mio: that.mioId, + material: that.form.material, + batch: b.batch, + mb: b.id, + count: Number(b.count_canmio), + warehouse: b.warehouse, + unit_price: that.form.unit_price, + note: that.form.note || '' + })); + res = await that.$API.inm.mioitem.create.req(payload); + } else { + res = await that.$API.inm.mioitem.create.req(that.form); + } } else if (that.mode == "edit") { res = await that.$API.inm.mioitem.update.req(that.form.id,that.form); } diff --git a/src/views/statistics/bxerp/fenjian.vue b/src/views/statistics/bxerp/fenjian.vue index b30df3f0..92b64fbf 100644 --- a/src/views/statistics/bxerp/fenjian.vue +++ b/src/views/statistics/bxerp/fenjian.vue @@ -31,6 +31,11 @@ clearable style="width: 200px;" > + {{scope.row.data.分检_缺陷项_扭转角不合格?scope.row.data.分检_缺陷项_扭转角不合格:0}} - + + + + - + @@ -141,17 +151,30 @@ export default { batch__contains:'', last_time__gte:'', last_time__lte:'', + handler:'' }, apiObj: this.$API.wpm.wpr.query, options:[], tableData:[], + toolList:{}, }; }, + mounted() { + this.getToolings(); + }, methods: { + getToolings(){ + let that = this; + that.$API.em.equipment.list.req({ page: 0,type:10,cate__code:'7'}).then((res) => { + res.forEach((item) => { + that.toolList[item.id] = item.number; + }); + }); + }, handleQuery(){ let that = this; let querys = [[{field:"wm",value:false,compare:"isnull"},{field:"data__分检_日期",compare:"isnull",value:false},{field:"data__has_key",compare:"",value:"分检_批次号"}]]; - let obj = {},obj1 = {},obj2 = {},obj3 = {},obj4 = {}; + let obj = {},obj1 = {},obj2 = {},obj3 = {},obj4 = {},obj5 = {}; obj.field = 'data__分检_批次号'; obj.value = that.query.batch__contains; obj.compare = ''; @@ -172,6 +195,10 @@ export default { obj4.value = that.query.number__contains; obj4.compare = 'contains'; + obj5.field = 'data__分检_操作人'; + obj5.value = that.query.handler; + obj5.compare = ''; + if(that.query.batch__contains!==''&&that.query.batch__contains!==null){ querys[0].push(obj); } @@ -187,6 +214,9 @@ export default { if(that.query.number__contains!==''&&that.query.number__contains!==null){ querys[0].push(obj4); } + if(that.query.handler!==''&&that.query.handler!==null){ + querys[0].push(obj5); + } that.params.querys = querys; this.$refs.table.queryData(that.params); }, diff --git a/src/views/statistics/bxerp/workHoursNZ.vue b/src/views/statistics/bxerp/workHoursNZ.vue index b367ffa8..f6b14023 100644 --- a/src/views/statistics/bxerp/workHoursNZ.vue +++ b/src/views/statistics/bxerp/workHoursNZ.vue @@ -17,6 +17,16 @@ placeholder="结束时间" style="margin-left: 2px; width: 150px" /> + + -
+
+
+
@@ -100,11 +102,15 @@ export default { text: '', }, grid: { - top: '80px' + top: '150px' }, tooltip: { trigger: 'axis' }, + legend: { + top: 30, + left: 10, + }, xAxis: { type: 'category', data: [] @@ -112,7 +118,6 @@ export default { yAxis: { type: 'value' }, - lenged: [], series: [{ data: [0, 0, 0, 0, 0, 0, 0], stack: 'Ad', @@ -146,13 +151,11 @@ export default { that.start_date = year + '-' + month + '-01'; that.end_date = year + '-' + month + '-' + days; that.queryDate = year + '-' + month; - let duration = that.endWeekNum - that.firstWeekNum + 1; - for (let i = 1; i <= duration; i++) { + for (let i = that.firstWeekNum; i <= that.endWeekNum; i++) { that.xAxisOrigin.push('第' + i + '周'); } that.xAxisData = that.xAxisOrigin; let height = document.getElementById('mainDom').clientHeight; - console.log('height',height); height= height-60; that.tableHeight = height; document.getElementById('bachart1').style.height = height + 'px'; @@ -170,12 +173,12 @@ export default { } setTimeout(() => { try { - myChart.setOption(option); + myChart.clear(); + myChart.setOption(option, true); } catch (error) { } }, 500) }, queryTypeChange(value) { - console.log(value) this.queryDate = ''; }, getWeekOfYear(a,b,c) { @@ -197,19 +200,18 @@ export default { query: { start_date: that.start_date, end_date: that.end_date, mgroup_name: "混料", is_count_utask: -1 }, }; let option = deepCopy(that.basicOption); - option.xAxis.data = that.xAxisData; option.title.text = '混料统计'; + let dateLabels = that.xAxisData; let exec = that.queryType == '月' ? 'lineWeek' : 'lineMonth'; that.$API.bi.dataset.exec.req(exec, obj).then((res) => { let dataList = res.data2.ds0 ? res.data2.ds0 : []; that.dataList = dataList; if (dataList.length > 0) { option.series = []; - let seriesData = [], nameList = []; + let nameList = []; dataList.forEach(ite => { if (nameList.indexOf(ite.物料名) > -1) { } else { nameList.push(ite.物料名); - seriesData.push([0,0,0,0,0,0,0,0,0,0,0,0]) let obj = {}; obj.text = ite.物料名; obj.value = ite.物料名; @@ -230,11 +232,15 @@ export default { that.specsFilters.push(obj3); } }) + let seriesData = []; + for (let i = 0; i < dateLabels.length; i++) { + seriesData.push(new Array(modelList.length).fill(0)); + } dataList.forEach(item => { let indexX = 0, indexY = 0; if (that.queryType == '月') { - indexX = nameList.indexOf(item.物料名); - indexY = item.周 - that.firstWeekNum; + indexX = item.周 - that.firstWeekNum; + indexY = modelList.indexOf(item.型号); if(dateList.indexOf(item.周)>-1){}else{ dateList.push(item.周); let obj = {}; @@ -244,22 +250,33 @@ export default { } } else { that.dateFilters = [1,2,3,4,5,6,7,8,9,10,11,12]; - indexX = nameList.indexOf(item.物料名); - indexY = item.月 - 1; + indexX = item.月 - 1; + indexY = modelList.indexOf(item.型号); + } + if (indexX >= 0 && indexX < seriesData.length && indexY >= 0) { + seriesData[indexX][indexY] += item.合格数; } - seriesData[indexX][indexY] += item.合格数; }); + option.xAxis.data = modelList; for (let n = 0; n < seriesData.length; n++) { let obj = {}; - obj.name = nameList[n]; - obj.stack = 'Ad'; + obj.name = dateLabels[n]; obj.type = 'bar'; - obj.barWidth = '15px'; + obj.barWidth = '10px'; obj.data = seriesData[n]; option.series.push(obj) } + let chartDom = document.getElementById('bachart1'); + if (chartDom) { + let parentWidth = that.$refs.chartScroll ? that.$refs.chartScroll.clientWidth : chartDom.parentElement.clientWidth; + let needWidth = modelList.length * dateLabels.length * 15; + chartDom.style.width = Math.max(parentWidth, needWidth) + 'px'; + let inst = echarts.getInstanceByDom(chartDom); + if (inst) inst.resize(); + } that.setChart("bachart1", option); } else { + option.xAxis.data = []; that.setChart("bachart1", option); } }); @@ -361,4 +378,8 @@ export default { right: 8px; z-index: 10; } +.chart-scroll { + width: 100%; + overflow-x: auto; +} diff --git a/src/views/statistics/pass_num.vue b/src/views/statistics/pass_num.vue index 34c89c79..b1a066e6 100644 --- a/src/views/statistics/pass_num.vue +++ b/src/views/statistics/pass_num.vue @@ -2,7 +2,7 @@
- + -
+
+
+
@@ -55,7 +57,7 @@ @@ -107,7 +109,9 @@ -
+
+
+
@@ -121,7 +125,7 @@ @@ -173,7 +177,9 @@ -
+
+
+
@@ -187,7 +193,7 @@ @@ -278,6 +284,9 @@ export default { tooltip: { trigger: "axis", }, + legend: { + top: 30, + }, xAxis: { type: "category", data: [], @@ -285,13 +294,10 @@ export default { yAxis: { type: "value", }, - lenged: [], series: [ { data: [0, 0, 0, 0, 0, 0, 0], - stack: "Ad", type: "bar", - barWidth: "15px", }, ], }, @@ -343,8 +349,7 @@ export default { that.start_date = year + "-" + month + "-01"; that.end_date =year + "-" + month + "-" + days; that.queryDate = year + "-" + month; - let duration = that.endWeekNum - that.firstWeekNum + 1; - for (let i = 1; i <= duration; i++) { + for (let i = that.firstWeekNum; i <= that.endWeekNum; i++) { that.xAxisOrigin.push("第" + i + "周"); } that.xAxisData = that.xAxisOrigin; @@ -366,6 +371,7 @@ export default { } setTimeout(() => { try { + myChart.resize(); myChart.setOption(option); } catch (error) {} }, 500); @@ -391,8 +397,8 @@ export default { that.modelFilters6 = []; that.specsFilters6 = []; let option = deepCopy(that.basicOption); - option.xAxis.data = that.xAxisData; option.title.text = "6车间"; + let dateLabels = that.xAxisData; let exec = that.queryType == "月" ? "lineWeek" : "lineMonth"; let obj = { query: { @@ -406,12 +412,11 @@ export default { that.tableData6 = tableData6; if (tableData6.length > 0) { option.series = []; - let seriesData = [],nameList = []; + let nameList = []; tableData6.forEach((ite) => { if (nameList.indexOf(ite.物料名) > -1) { }else { nameList.push(ite.物料名); - seriesData.push([]); let obj = {}; obj.text = ite.物料名; obj.value = ite.物料名; @@ -439,15 +444,19 @@ export default { that.modelFilters6.push(obj4); } }); + let seriesData = []; + let prodData = []; + for (let i = 0; i < dateLabels.length; i++) { + seriesData.push(new Array(nameList.length).fill(0)); + prodData.push(new Array(nameList.length).fill(0)); + } if (that.queryType == "月") { tableData6.forEach((item) => { - let indexX = nameList.indexOf(item.物料名); - let indexY = item.周 - that.firstWeekNum; - if(seriesData[indexX][indexY]){ - seriesData[indexX][indexY] += item.合格数; - }else{ - seriesData[indexX][indexY] =0; + let indexX = item.周 - that.firstWeekNum; + let indexY = nameList.indexOf(item.物料名); + if (indexX >= 0 && indexX < seriesData.length && indexY >= 0) { seriesData[indexX][indexY] += item.合格数; + prodData[indexX][indexY] += Number(item.生产数) || 0; } if(dateList.indexOf(item.周)>-1){}else{ dateList.push(item.周); @@ -460,27 +469,105 @@ export default { } else { that.dateFilters6 = [1,2,3,4,5,6,7,8,9,10,11,12]; tableData6.forEach((item) => { - let indexX = nameList.indexOf(item.物料名); - let indexY = item.month - 1; - if(seriesData[indexX][indexY]){ - seriesData[indexX][indexY] += item.合格数; - }else{ - seriesData[indexX][indexY] =0; + let indexX = item.月 - 1; + let indexY = nameList.indexOf(item.物料名); + if (indexX >= 0 && indexX < seriesData.length && indexY >= 0) { seriesData[indexX][indexY] += item.合格数; + prodData[indexX][indexY] += Number(item.生产数) || 0; } }); } + option.xAxis = { type: "category", data: nameList }; + option.yAxis = [ + { type: "value" }, + { type: "value", min: -233.33, max: 100, show: false } + ]; + option.legend = { top: 30, data: dateLabels }; + let barWidth = 10; + let barGap = 0; + let chartDom = document.getElementById("bachart3"); + if (chartDom) { + chartDom.style.width = (nameList.length * dateLabels.length * 15) + "px"; + } for (let n = 0; n < seriesData.length; n++) { let obj = {}; - obj.name = nameList[n]; - obj.stack = "Ad"; + obj.name = dateLabels[n]; obj.type = "bar"; - obj.barWidth = "15px"; + obj.barWidth = barWidth; + obj.barGap = "0%"; obj.data = seriesData[n]; option.series.push(obj); } + let totalSeries = seriesData.length; + let curveData = []; + let ratesByMat = []; + for (let mat = 0; mat < nameList.length; mat++) { + let rates = []; + for (let s = 0; s < totalSeries; s++) { + let pass = seriesData[s][mat]; + let prod = prodData[s][mat]; + rates.push(prod > 0 ? Math.round((pass / prod) * 100) : null); + } + curveData.push({ value: [mat].concat(rates) }); + ratesByMat.push(rates); + } + option.tooltip = { + trigger: "axis", + formatter: function (params) { + if (!params || params.length === 0) return ""; + let cat = params[0].axisValueLabel; + let matIdx = params[0].dataIndex; + let rates = ratesByMat[matIdx] || []; + let html = '
' + cat + '
'; + let barIdx = 0; + params.forEach(function (p) { + if (p.seriesType !== "bar") return; + let rate = rates[barIdx]; + let rateStr = (rate !== null && rate !== undefined) ? rate + "%" : "-"; + html += '
' + + '' + + p.seriesName + ': ' + p.value + '    合格率 ' + rateStr + + '
'; + barIdx++; + }); + return html; + } + }; + option.series.push({ + name: "合格率", + type: "custom", + xAxisIndex: 0, + yAxisIndex: 1, + silent: true, + z: 5, + data: curveData, + renderItem: function (params, api) { + let materialIdx = api.value(0); + let centerX = api.coord([materialIdx, 0])[0]; + let groupWidth = totalSeries * barWidth + (totalSeries - 1) * barGap; + let halfGroup = groupWidth / 2; + let slotWidth = barWidth + barGap; + let pts = []; + for (let s = 0; s < totalSeries; s++) { + let rate = api.value(s + 1); + if (rate === null || rate === undefined) continue; + let xPx = centerX - halfGroup + barWidth / 2 + s * slotWidth; + let yPx = api.coord([0, rate])[1]; + pts.push([xPx, yPx]); + } + if (pts.length < 2) return null; + return { + type: "polyline", + shape: { points: pts, smooth: 0.3 }, + style: { stroke: "#333", lineWidth: 1.5, fill: "none" } + }; + } + }); that.setChart("bachart3", option); } else { + option.xAxis.data = []; + let chartDom = document.getElementById("bachart3"); + if (chartDom) chartDom.style.width = "100%"; that.setChart("bachart3", option); } }); @@ -500,8 +587,8 @@ export default { }, }; let option = deepCopy(that.basicOption); - option.xAxis.data = that.xAxisData; option.title.text = "预制棒(7车间)"; + let dateLabels = that.xAxisData; let exec = that.queryType == "月" ? "lineWeek" : "lineMonth"; that.$API.bi.dataset.exec.req(exec, obj).then((res) => { console.log("7生产车间统计:", res); @@ -509,13 +596,11 @@ export default { that.tableData7 = tableData7; if (tableData7.length > 0) { option.series = []; - let seriesData = [], - nameList = []; + let nameList = []; tableData7.forEach((ite) => { if (nameList.indexOf(ite.物料名) > -1) { } else { nameList.push(ite.物料名); - seriesData.push([]); let obj = {}; obj.text = ite.物料名; obj.value = ite.物料名; @@ -536,12 +621,18 @@ export default { that.specsFilters7.push(obj3); } }); + let seriesData = []; + let prodData = []; + for (let i = 0; i < dateLabels.length; i++) { + seriesData.push(new Array(nameList.length).fill(0)); + prodData.push(new Array(nameList.length).fill(0)); + } tableData7.forEach((item) => { let indexX = 0, indexY = 0; if (that.queryType == "月") { - indexX = nameList.indexOf(item.物料名); - indexY = item.周 - that.firstWeekNum; + indexX = item.周 - that.firstWeekNum; + indexY = nameList.indexOf(item.物料名); if(dateList.indexOf(item.周)>-1){}else{ dateList.push(item.周); let obj = {}; @@ -551,27 +642,105 @@ export default { } } else { that.dateFilters7 = [1,2,3,4,5,6,7,8,9,10,11,12]; - indexX = nameList.indexOf(item.物料名); - indexY = item.月 - 1; + indexX = item.月 - 1; + indexY = nameList.indexOf(item.物料名); } - if(seriesData[indexX][indexY]){ - seriesData[indexX][indexY] += item.合格数; - }else{ - seriesData[indexX][indexY] =0; + if (indexX >= 0 && indexX < seriesData.length && indexY >= 0) { seriesData[indexX][indexY] += item.合格数; + prodData[indexX][indexY] += Number(item.生产数) || 0; } }); + option.xAxis = { type: "category", data: nameList }; + option.yAxis = [ + { type: "value" }, + { type: "value", min: -233.33, max: 100, show: false } + ]; + option.legend = { top: 30, data: dateLabels }; + let barWidth = 10; + let barGap = 0; + let chartDom = document.getElementById("bachart1"); + if (chartDom) { + chartDom.style.width = (nameList.length * dateLabels.length * 15) + "px"; + } for (let n = 0; n < seriesData.length; n++) { let obj = {}; - obj.name = nameList[n]; - obj.stack = "Ad"; + obj.name = dateLabels[n]; obj.type = "bar"; - obj.barWidth = "15px"; + obj.barWidth = barWidth; + obj.barGap = "0%"; obj.data = seriesData[n]; option.series.push(obj); } + let totalSeries = seriesData.length; + let curveData = []; + let ratesByMat = []; + for (let mat = 0; mat < nameList.length; mat++) { + let rates = []; + for (let s = 0; s < totalSeries; s++) { + let pass = seriesData[s][mat]; + let prod = prodData[s][mat]; + rates.push(prod > 0 ? Math.round((pass / prod) * 100) : null); + } + curveData.push({ value: [mat].concat(rates) }); + ratesByMat.push(rates); + } + option.tooltip = { + trigger: "axis", + formatter: function (params) { + if (!params || params.length === 0) return ""; + let cat = params[0].axisValueLabel; + let matIdx = params[0].dataIndex; + let rates = ratesByMat[matIdx] || []; + let html = '
' + cat + '
'; + let barIdx = 0; + params.forEach(function (p) { + if (p.seriesType !== "bar") return; + let rate = rates[barIdx]; + let rateStr = (rate !== null && rate !== undefined) ? rate + "%" : "-"; + html += '
' + + '' + + p.seriesName + ': ' + p.value + '    合格率 ' + rateStr + + '
'; + barIdx++; + }); + return html; + } + }; + option.series.push({ + name: "合格率", + type: "custom", + xAxisIndex: 0, + yAxisIndex: 1, + silent: true, + z: 5, + data: curveData, + renderItem: function (params, api) { + let materialIdx = api.value(0); + let centerX = api.coord([materialIdx, 0])[0]; + let groupWidth = totalSeries * barWidth + (totalSeries - 1) * barGap; + let halfGroup = groupWidth / 2; + let slotWidth = barWidth + barGap; + let pts = []; + for (let s = 0; s < totalSeries; s++) { + let rate = api.value(s + 1); + if (rate === null || rate === undefined) continue; + let xPx = centerX - halfGroup + barWidth / 2 + s * slotWidth; + let yPx = api.coord([0, rate])[1]; + pts.push([xPx, yPx]); + } + if (pts.length < 2) return null; + return { + type: "polyline", + shape: { points: pts, smooth: 0.3 }, + style: { stroke: "#333", lineWidth: 1.5, fill: "none" } + }; + } + }); that.setChart("bachart1", option); } else { + option.xAxis.data = []; + let chartDom = document.getElementById("bachart1"); + if (chartDom) chartDom.style.width = "100%"; that.setChart("bachart1", option); } }); @@ -584,8 +753,8 @@ export default { that.modelFilters = []; that.specsFilters = []; let option = deepCopy(that.basicOption); - option.xAxis.data = that.xAxisData; option.title.text = "预制管(10车间)"; + let dateLabels = that.xAxisData; let obj = { query: { start_date: that.start_date, @@ -599,13 +768,11 @@ export default { that.tableData10 = tableData10; if (tableData10.length > 0) { option.series = []; - let seriesData = [], - nameList = []; + let nameList = []; tableData10.forEach((ite) => { if (nameList.indexOf(ite.物料名) > -1) { } else { nameList.push(ite.物料名); - seriesData.push([]); let obj = {}; obj.text = ite.物料名; obj.value = ite.物料名; @@ -626,12 +793,18 @@ export default { that.specsFilters.push(obj3); } }); + let seriesData = []; + let prodData = []; + for (let i = 0; i < dateLabels.length; i++) { + seriesData.push(new Array(nameList.length).fill(0)); + prodData.push(new Array(nameList.length).fill(0)); + } tableData10.forEach((item) => { let indexX = 0, indexY = 0; if (that.queryType == "月") { - indexX = nameList.indexOf(item.物料名); - indexY = item.周 - that.firstWeekNum; + indexX = item.周 - that.firstWeekNum; + indexY = nameList.indexOf(item.物料名); if(dateList.indexOf(item.周)>-1){}else{ dateList.push(item.周); let obj = {}; @@ -641,27 +814,105 @@ export default { } } else { that.dateFilters = [1,2,3,4,5,6,7,8,9,10,11,12]; - indexX = nameList.indexOf(item.物料名); - indexY = item.月 - 1; + indexX = item.月 - 1; + indexY = nameList.indexOf(item.物料名); } - if(seriesData[indexX][indexY]){ - seriesData[indexX][indexY] += item.合格数; - }else{ - seriesData[indexX][indexY] =0; + if (indexX >= 0 && indexX < seriesData.length && indexY >= 0) { seriesData[indexX][indexY] += item.合格数; + prodData[indexX][indexY] += Number(item.生产数) || 0; } }); + option.xAxis = { type: "category", data: nameList }; + option.yAxis = [ + { type: "value" }, + { type: "value", min: -233.33, max: 100, show: false } + ]; + option.legend = { top: 30, data: dateLabels }; + let barWidth = 10; + let barGap = 0; + let chartDom = document.getElementById("bachart2"); + if (chartDom) { + chartDom.style.width = (nameList.length * dateLabels.length * 15) + "px"; + } for (let n = 0; n < seriesData.length; n++) { let obj = {}; - obj.name = nameList[n]; - obj.stack = "Ad"; + obj.name = dateLabels[n]; obj.type = "bar"; - obj.barWidth = "15px"; + obj.barWidth = barWidth; + obj.barGap = "0%"; obj.data = seriesData[n]; option.series.push(obj); } + let totalSeries = seriesData.length; + let curveData = []; + let ratesByMat = []; + for (let mat = 0; mat < nameList.length; mat++) { + let rates = []; + for (let s = 0; s < totalSeries; s++) { + let pass = seriesData[s][mat]; + let prod = prodData[s][mat]; + rates.push(prod > 0 ? Math.round((pass / prod) * 100) : null); + } + curveData.push({ value: [mat].concat(rates) }); + ratesByMat.push(rates); + } + option.tooltip = { + trigger: "axis", + formatter: function (params) { + if (!params || params.length === 0) return ""; + let cat = params[0].axisValueLabel; + let matIdx = params[0].dataIndex; + let rates = ratesByMat[matIdx] || []; + let html = '
' + cat + '
'; + let barIdx = 0; + params.forEach(function (p) { + if (p.seriesType !== "bar") return; + let rate = rates[barIdx]; + let rateStr = (rate !== null && rate !== undefined) ? rate + "%" : "-"; + html += '
' + + '' + + p.seriesName + ': ' + p.value + '    合格率 ' + rateStr + + '
'; + barIdx++; + }); + return html; + } + }; + option.series.push({ + name: "合格率", + type: "custom", + xAxisIndex: 0, + yAxisIndex: 1, + silent: true, + z: 5, + data: curveData, + renderItem: function (params, api) { + let materialIdx = api.value(0); + let centerX = api.coord([materialIdx, 0])[0]; + let groupWidth = totalSeries * barWidth + (totalSeries - 1) * barGap; + let halfGroup = groupWidth / 2; + let slotWidth = barWidth + barGap; + let pts = []; + for (let s = 0; s < totalSeries; s++) { + let rate = api.value(s + 1); + if (rate === null || rate === undefined) continue; + let xPx = centerX - halfGroup + barWidth / 2 + s * slotWidth; + let yPx = api.coord([0, rate])[1]; + pts.push([xPx, yPx]); + } + if (pts.length < 2) return null; + return { + type: "polyline", + shape: { points: pts, smooth: 0.3 }, + style: { stroke: "#333", lineWidth: 1.5, fill: "none" } + }; + } + }); that.setChart("bachart2", option); } else { + option.xAxis.data = []; + let chartDom = document.getElementById("bachart2"); + if (chartDom) chartDom.style.width = "100%"; that.setChart("bachart2", option); } }); @@ -734,9 +985,8 @@ export default { that.end_date =that.queryDate +"-" +days; that.firstWeekNum = that.getWeekOfYear(year,month,1); that.endWeekNum = that.getWeekOfYear(year,month,days); - let duration = that.endWeekNum - that.firstWeekNum + 1; let xAxisData = []; - for (let i = 1; i <= duration; i++) { + for (let i = that.firstWeekNum; i <= that.endWeekNum; i++) { xAxisData.push("第" + i + "周"); } that.xAxisData = xAxisData; @@ -828,12 +1078,17 @@ export default { diff --git a/src/views/statistics/stock_statistics.vue b/src/views/statistics/stock_statistics.vue index 574cf4b6..69bf8836 100644 --- a/src/views/statistics/stock_statistics.vue +++ b/src/views/statistics/stock_statistics.vue @@ -28,7 +28,7 @@ :filter-method="filterModel1" filter-placement="bottom-end" /> - diff --git a/src/views/wpm_bx/mlog_detail.vue b/src/views/wpm_bx/mlog_detail.vue index c12df44e..94e296b9 100644 --- a/src/views/wpm_bx/mlog_detail.vue +++ b/src/views/wpm_bx/mlog_detail.vue @@ -392,7 +392,7 @@ style="width: 100%;height: 500px;" > -
+
{ + that.addTemplate[item.defect_name] = false; + let obj = Object.assign({}, item); + obj.canEdit = that.processType=='20'?false:true; + that.qct_defects.push(obj); + }) + that.qct_defects_origin = that.qct_defects; that.getList(); }); }, diff --git a/src/views/wpm_bx/mlogbw_check_table.vue b/src/views/wpm_bx/mlogbw_check_table.vue index c9822508..d63ff6f6 100644 --- a/src/views/wpm_bx/mlogbw_check_table.vue +++ b/src/views/wpm_bx/mlogbw_check_table.vue @@ -22,6 +22,7 @@ 检验 批量操作 + 数字识别
{{ test_file_name }} @@ -51,13 +52,16 @@ 序号 - 物料批次 - 物料编号 + 物料批次 + 物料编号 生产设备 扭转日期 工装 {{ item.testitem_name }} - {{ item.defect_name }} + + {{ item.defect_name }} + {{ getDefectCount(item.defect_name) }} + 备注 操作 @@ -70,11 +74,11 @@ {{ index + 1 }} - + {{ row.mlogb__batch }} - + {{ row.number }} ——{{ row.wpr_number_out }} @@ -411,6 +415,9 @@ export default { wprInputText:"", project_code:"", test_file_name:"", + ocr_ip:"", + ocr_port:"", + ocr_unit:"", canMultiple:false, selectedAll:false, checkAll: false, @@ -467,10 +474,7 @@ export default { watch: {}, computed: { allColumnOptions() { - const cols = [ - { key: 'batch', label: '物料批次' }, - { key: 'number', label: '物料编号' }, - ]; + const cols = []; if (this.route_code === 'niuzhuan') { cols.push({ key: 'equip', label: '生产设备' }); cols.push({ key: 'time', label: '扭转日期' }); @@ -540,6 +544,9 @@ export default { },500) that.actionMenuClickHandler = (event) => that.handleDocumentClick(event); document.addEventListener("click", that.actionMenuClickHandler, true); + that.ocr_ip = localStorage.getItem("ocr_ip") || ""; + that.ocr_port = localStorage.getItem("ocr_port") || ""; + that.ocr_unit = localStorage.getItem("ocr_unit") || ""; }, beforeUnmount() { @@ -697,7 +704,6 @@ export default { }, timeChange(row){ let that = this; - console.log('row',row) let index = that.mlogbwlist.indexOf(row); if(row.work_start_time!==''&&row.work_start_time!==null&&row.work_start_time!==undefined){ let waveNum = 1; @@ -1118,6 +1124,93 @@ that.$API.wpm.prints.req(printer_ip, obj).then((response) => { that.wprNumber = ""; that.setVisible=true; }, + + + //扫描这里更新:添加数字化识别,调用一个接口,并且返回number和设备数据,然后根据number将这一行放到第一行并编辑这一行,并且把设备数据放到对应位置 + digital(){ + let that = this; + //第一步:调用接口获取数字识别设备返回的number + if(!that.ocr_ip || !that.ocr_port || !that.ocr_unit){ + that.$message.warning('请先在右上角"数字识别设置"配置IP、端口号和位号'); + return; + } + that.$API.em.equipment.get_svs_char.req({ + host: that.ocr_ip, + port: that.ocr_port, + flow_unit: that.ocr_unit + }).then((res) => { + if(res.char){ + that.mlogbwlist.forEach((item,index) => { + if(item.number==res.char){ + let obj = Object.assign({},item);S + obj.isEdit = true; + that.mlogbwlist.splice(index,1); + that.wprInputText = ""; + that.mlogbwlist.unshift(obj); + that.$nextTick(() => { + that.selectedindexes.push(obj.id); + that.selectWprList.push(item); + }) + //第二步:获取投影仪设备的监测数据 + //先判断是否有需要检测设备的检测项,若有,赋值,若无,跳过 + if(that.qct_testitems.length>0 && !!that.setForm.cd_req_addr){ + that.$API.em.cd.req({method:that.setForm.cd_req_addr}).then((res) => { + that.qct_testitems.forEach(item0 => { + if(item0.testitem_cd_expr!=null){ + that.mlogbwlist[0][item0.testitem_name]= eval(item0.testitem_cd_expr); + item0.cd_expr = true; + that.qct_defects.forEach(item => { + if(item.rule_expression!==''&&item.rule_expression!==undefined&&item.rule_expression!==null){ + let str = item.rule_expression.replace(/`/g, ''); + str = str.replace(/\${(.*?)}/g, 'row.\$1'); + let judge = false; + try { + judge = eval(str); + that.mlogbwlist[0][item.defect_name] = judge; + }catch (error) { + console.error(error); + } + }else{ + that.mlogbwlist[0][item.defect_name] = false; + } + }); + } + }) + let arrs= that.qct_testitems.filter(item => item.testitem_cd_expr!=null) + if(arrs.length>0){ + that.seveAuto(0); + } + }).catch((err) => { + this.$notify.error({ + title: '获取数据失败', + message: err.data + }) + return err; + }); + } + } + }) + } + }).catch((err) => { + that.$notify.error({ + title: '数字识别获取失败', + message: err.data + }) + return err; + }); + }, + seveAuto(index){ + let that= this; + let arr2 = that.mlogbwlist.filter(item => item.cd_expr==true); + if(arr2.length>0){ + that.formTableSave(that.mlogbwlist[index],index); + }else{ + setTimeout(() => { + that.seveAuto(index); + }, 500); + } + }, + //扫描物料将这一行放到第一行并编辑这一行 wprinputChange(){ let that = this; @@ -1155,6 +1248,7 @@ that.$API.wpm.prints.req(printer_ip, obj).then((response) => { that.qct_testitems.forEach(item0 => { if(item0.testitem_cd_expr!=null){ that.mlogbwlist[index][item0.testitem_name]= eval(item0.testitem_cd_expr); + that.mlogbwlist[index].cd_expr = true; that.qct_defects.forEach(item => { if(item.rule_expression!==''&&item.rule_expression!==undefined&&item.rule_expression!==null){ let str = item.rule_expression.replace(/`/g, ''); @@ -1172,6 +1266,10 @@ that.$API.wpm.prints.req(printer_ip, obj).then((response) => { }); } }) + let arrs= that.qct_testitems.filter(item => {return item.testitem_cd_expr!=null;}) + if(arrs.length>0){ + that.seveAuto(index); + } }).catch((err) => { this.$notify.error({ title: '获取数据失败', @@ -1254,7 +1352,6 @@ that.$API.wpm.prints.req(printer_ip, obj).then((response) => { fullscreen: true, text: "解析中...请稍等", }); - console.log(res); this.$API.wpm.mlog.change.req(that.mlogId,{ test_file: res.path }).then((res) => { loading.close(); this.$message.success("导入成功"); @@ -1264,6 +1361,15 @@ that.$API.wpm.prints.req(printer_ip, obj).then((response) => { this.$message.error("导入失败,请重新尝试"); }); }, + getDefectCount(defectName){ + let count = 0; + this.mlogbwlist.forEach(row => { + if(row[defectName]){ + count++; + } + }); + return count; + }, hasNull(){ let that = this; let canSubmit = true; diff --git a/src/views/wpm_bx/wprList.vue b/src/views/wpm_bx/wprList.vue index 05b26178..0803b913 100644 --- a/src/views/wpm_bx/wprList.vue +++ b/src/views/wpm_bx/wprList.vue @@ -95,6 +95,7 @@ > diff --git a/src/views/wpm_gx/mlog_form.vue b/src/views/wpm_gx/mlog_form.vue index ba0fede9..3cebe28e 100644 --- a/src/views/wpm_gx/mlog_form.vue +++ b/src/views/wpm_gx/mlog_form.vue @@ -6,265 +6,261 @@ style="width: 80%;" @closed="$emit('closed')" > - - - - - - + + + + + + + + + + + + - - - - - - - - - - [{{ item.routepack_name }}]{{ item.name }} - - - - - - - - - - - - - - - - - - - [{{ item.routepack_name }}]{{ item.name }} + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - {{item.name}} - {{item.number}} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 保存 - 取消 - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {{item.name}} + {{item.number}} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 保存 + 取消 + diff --git a/src/views/wpm_gx/mlogb_form.vue b/src/views/wpm_gx/mlogb_form.vue index d3bf8cba..8f98c24a 100644 --- a/src/views/wpm_gx/mlogb_form.vue +++ b/src/views/wpm_gx/mlogb_form.vue @@ -6,185 +6,181 @@ destroy-on-close @closed="$emit('closed')" > - - - - - - - - - [{{ item.routepack_name }}]{{ item.name }} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 保存 - 取消 - - + + + + + + + [{{ item.routepack_name }}]{{ item.name }} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 保存 + 取消 +