| | |
| | | el: '#app', |
| | | data: function () { |
| | | return { |
| | | tableTbData: [], // "制热性能"生成的表格数据 |
| | | formTbData: { // 表单数据 |
| | | temperatureData: {} // 存储的实际温度、实际流量数据 |
| | | }, |
| | | indexZrxx:0,//制热性能index |
| | | headers: [], |
| | | showZr: false, |
| | | waterOptions: [ |
| | | { value: '100℃', text: '100℃' }, |
| | | { value: '99℃', text: '99℃' }, |
| | | { value: '90℃', text: '90℃' }, |
| | | { value: '85℃', text: '85℃' }, |
| | | { value: '80℃', text: '80℃' }, |
| | | { value: '75℃', text: '75℃' }, |
| | | { value: '65℃', text: '65℃' }, |
| | | { value: '60℃', text: '60℃' }, |
| | | { value: '55℃', text: '55℃' }, |
| | | { value: '45℃', text: '45℃' }, |
| | | { value: '42℃', text: '42℃' }, |
| | | { value: '常温水', text: '常温水' }, |
| | | { value: '冰水', text: '冰水' }, |
| | | { value: '70℃', text: '70℃' }, |
| | | { value: '50℃', text: '50℃' }, |
| | | { value: '微冷', text: '微冷' } |
| | | ],//水温选项 |
| | | flowOptions: [ |
| | | { value: '50ml', text: '50ml' }, |
| | | { value: '120ml', text: '120ml' }, |
| | | { value: '150ml', text: '150ml' }, |
| | | { value: '160ml', text: '160ml' }, |
| | | { value: '250ml', text: '250ml' }, |
| | | { value: '260ml', text: '260ml' }, |
| | | { value: '350ml', text: '350ml' }, |
| | | { value: '360ml', text: '360ml' }, |
| | | { value: '450ml', text: '450ml' }, |
| | | { value: '550ml', text: '550ml' }, |
| | | { value: '750ml', text: '750ml' }, |
| | | { value: '999ml', text: '999ml' }, |
| | | { value: '一分钟流量', text: '一分钟流量' }, |
| | | { value: '三分钟流量', text: '三分钟流量' } |
| | | ],//流量选项 |
| | | selectedWater: [],// 已选水温值 |
| | | selectedFlow: [], // 已选流量值 |
| | | isLoading: false, |
| | | userInfo: { |
| | | "loginGuid": '', |
| | |
| | | this.inputValue = value.replace(/[^\d.]/g, '') // 1. 去除非数字和小数点 |
| | | .replace(/(\..*)\./g, '$1') // 2. 禁止多个小数点 |
| | | .replace(/^\./g, ''); |
| | | }, |
| | | |
| | | |
| | | openZrPopup(index) { |
| | | this.showZr = true; |
| | | this.indexZrxx = this.tabActive; |
| | | this.loadTableConfig(); |
| | | }, |
| | | closeZrPopup() { |
| | | this.showZr = false; |
| | | // this.selectedWater = []; // 关闭时清空选择 |
| | | // this.selectedFlow = []; // 关闭时清空选择 |
| | | }, |
| | | //针对没有上下限值的数据,只需选择合格或不合格.按钮触发 |
| | | handleQualified(isQualified) { |
| | |
| | | let data = res.data.tbBillList[0]; |
| | | if (data) { |
| | | that.formData = data; |
| | | that.remarks = that.formData.fngDesc; |
| | | that.remarks = that.formData.fnGDesc; |
| | | that.AxiosHttp("post", 'Ipqc/getJYItem', { |
| | | //id: that.formData.guid, |
| | | releaseNo: that.formData.releaseNo |
| | |
| | | submit() { |
| | | var that = this; |
| | | that.ttrre = true; |
| | | that.AxiosHttp("post", 'MesQaItemsDetect01Manager/EditModelSubmit', { |
| | | that.AxiosHttp("post", 'FqcManager/EditModelSubmit', { |
| | | guid: that.formData.guid |
| | | }, true, 1).then(function (res1) { |
| | | if (res1.rtnData.outSum == 1) { |
| | |
| | | that.init();//刷新检验项目 |
| | | }) |
| | | }, |
| | | createTb() { |
| | | // 清空旧数据 |
| | | this.tableTbData = []; |
| | | this.formTbData.temperatureData = {}; |
| | | |
| | | // 校验选择 |
| | | if (this.selectedWater.length === 0 || this.selectedFlow.length === 0) { |
| | | this.$toast.fail('请先选择水温和流量'); |
| | | return; |
| | | } |
| | | |
| | | // 生成表头 |
| | | // 修改headers生成逻辑 ↓ |
| | | const headers = [ |
| | | '设定温度', |
| | | '实际温度(℃)', |
| | | ...this.selectedFlow.sort().map(f => `${f}`) |
| | | ]; |
| | | this.headers = headers; |
| | | console.log(this.headers); |
| | | // 生成行数据 |
| | | this.tableTbData = this.selectedWater.sort((a,b) => a - b).map(water => { |
| | | const row = { |
| | | temperature: water === '常温水' ? water : water, |
| | | values: Object.fromEntries([ |
| | | ['temp', ''], // 固定温度字段 |
| | | ...this.selectedFlow.map(flow => [flow, '']) |
| | | ]) |
| | | }; |
| | | |
| | | // 初始化表单数据结构 |
| | | this.$set(this.formTbData.temperatureData, water, {}); |
| | | // 添加固定字段”实际温度“初始化 |
| | | this.$set(this.formTbData.temperatureData[water], 'temp', ''); |
| | | this.selectedFlow.forEach(flow => { |
| | | this.$set(this.formTbData.temperatureData[water], flow, ''); |
| | | }); |
| | | |
| | | return row; |
| | | }); |
| | | |
| | | // 自动滚动到表格区域 |
| | | setTimeout(() => { |
| | | const tableEl = document.getElementById('temperature-table'); |
| | | if (tableEl) tableEl.scrollIntoView({ behavior: 'smooth' }); |
| | | }, 100); |
| | | console.log(this.formTbData); |
| | | }, |
| | | // 新增保存配置方法 |
| | | saveTableConfig() { |
| | | const that = this; |
| | | that.isLoading = true; |
| | | |
| | | that.AxiosHttp("post", 'Ipqc/SaveTableConfig', { |
| | | selectedWater: (that.selectedWater), |
| | | selectedFlow: (that.selectedFlow), |
| | | tableData: (that.formTbData.temperatureData), |
| | | mxguid: that.tableData[that.indexZrxx].guid // 使用主表ID关联 |
| | | }, true).then(res1 => { |
| | | if (res1.status === 0) { |
| | | that.$notify({ type: 'success', message: '配置保存成功' }); |
| | | } else { |
| | | that.$toast.fail(res1.rtnMsg); |
| | | } |
| | | that.isLoading = false; |
| | | }).catch(error => { |
| | | that.$toast.fail("网络错误,请重试!"); |
| | | that.isLoading = false; |
| | | }); |
| | | }, |
| | | // 新增加载配置方法 |
| | | loadTableConfig() { |
| | | const that = this; |
| | | that.isLoading = true; |
| | | var mxguid = that.tableData[that.indexZrxx].guid; |
| | | |
| | | |
| | | that.AxiosHttp("post", 'Ipqc/GetTableConfig', { |
| | | mxguid: mxguid, |
| | | }, true).then(res1 => { |
| | | if (res1.status === 0 && res1.data) { |
| | | // 解析存储的数据 |
| | | that.selectedWater = JSON.parse(res1.data.selectedWater || '[]'); |
| | | that.selectedFlow = JSON.parse(res1.data.selectedFlow || '[]'); |
| | | that.formTbData.temperatureData = JSON.parse(res1.data.tableData || '{}'); |
| | | |
| | | // 调用新的渲染方法 |
| | | this.renderExistingTable(); |
| | | } |
| | | that.isLoading = false; |
| | | }).catch(error => { |
| | | that.isLoading = false; |
| | | that.$toast.fail("加载配置失败"); |
| | | }); |
| | | }, |
| | | |
| | | // 新增渲染已有数据表格的方法 |
| | | renderExistingTable() { |
| | | const that = this; |
| | | console.log(that.formTbData.temperatureData); |
| | | // 从现有数据反向推导选择项 |
| | | const existingWaters = Object.keys(that.formTbData.temperatureData); |
| | | const existingFlows = existingWaters.length > 0 |
| | | ? Object.keys(that.formTbData.temperatureData[existingWaters[0]]) |
| | | .filter(k => k !== 'temp') |
| | | : []; |
| | | |
| | | // 生成表头(保留原始createTb的格式) |
| | | that.headers = [ |
| | | '设定温度', |
| | | '实际温度(℃)', |
| | | ...existingFlows.map(f => `${f}`) |
| | | ]; |
| | | |
| | | // 生成行数据(保留原始结构) |
| | | that.tableTbData = existingWaters.map(water => { |
| | | const values = that.formTbData.temperatureData[water]; |
| | | return { |
| | | temperature: water, |
| | | values: Object.fromEntries([ |
| | | ['temp', values.temp || ''], |
| | | ...existingFlows.map(flow => [flow, values[flow] || '']) |
| | | ]) |
| | | }; |
| | | }); |
| | | console.log(that.formTbData.temperatureData); |
| | | // 保留原始滚动逻辑 |
| | | setTimeout(() => { |
| | | const tableEl = document.getElementById('temperature-table'); |
| | | if (tableEl) tableEl.scrollIntoView({ behavior: 'smooth' }); |
| | | }, 100); |
| | | console.log(that.formTbData.temperatureData); |
| | | }, |
| | | } |
| | | }) |
| | | }) |