| | |
| | | el: '#app', |
| | | data: function () { |
| | | return { |
| | | tableData: [], // 生成的表格数据 |
| | | formData: { // 表单数据 |
| | | temperatureData: {} // 存储温度数据 |
| | | }, |
| | | headers: [], |
| | | showZr: false, |
| | | waterOptions: [ |
| | | { value: '常温水', text: '常温水' }, |
| | | { value: '0', text: '0℃' }, |
| | | { value: '5', text: '5℃' }, |
| | | { value: '15', text: '15℃' }, |
| | | { value: '35', text: '35℃' }, |
| | | { value: '55', text: '55℃' }, |
| | | { value: '75', text: '75℃' }, |
| | | { value: '100', text: '100℃' } |
| | | { value: '0℃', text: '0℃' }, |
| | | { value: '5℃', text: '5℃' }, |
| | | { value: '15℃', text: '15℃' }, |
| | | { value: '35℃', text: '35℃' }, |
| | | { value: '55℃', text: '55℃' }, |
| | | { value: '75℃', text: '75℃' }, |
| | | { value: '100℃', text: '100℃' } |
| | | ], |
| | | flowOptions: [ |
| | | { value: '100', text: '100ml' }, |
| | | { value: '200', text: '200ml' }, |
| | | { value: '300', text: '300ml' }, |
| | | { value: '400', text: '400ml' }, |
| | | { value: '500', text: '500ml' }, |
| | | { value: '600', text: '600ml' }, |
| | | { value: '700', text: '700ml' }, |
| | | { value: '800', text: '800ml' }, |
| | | { value: '900', text: '900ml' }, |
| | | { value: '1000', text: '1000ml' } |
| | | { value: '100ml', text: '100ml' }, |
| | | { value: '200ml', text: '200ml' }, |
| | | { value: '300ml', text: '300ml' }, |
| | | { value: '400ml', text: '400ml' }, |
| | | { value: '500ml', text: '500ml' }, |
| | | { value: '600ml', text: '600ml' }, |
| | | { value: '700ml', text: '700ml' }, |
| | | { value: '800ml', text: '800ml' }, |
| | | { value: '900ml', text: '900ml' }, |
| | | { value: '1000ml', text: '1000ml' } |
| | | ], |
| | | selectedWater: [],// 已选水温值 |
| | | selectedFlow: [], // 已选流量值 |
| | |
| | | that.init();//刷新检验项目 |
| | | }) |
| | | }, |
| | | createTb() { |
| | | // 清空旧数据 |
| | | this.tableData = []; |
| | | this.formData.temperatureData = {}; |
| | | |
| | | // 校验选择 |
| | | if (this.selectedWater.length === 0 || this.selectedFlow.length === 0) { |
| | | this.$toast.fail('请先选择水温和流量'); |
| | | return; |
| | | } |
| | | |
| | | // 生成表头 |
| | | const headers = ['设定温度','实际温度', ...this.selectedFlow.sort().map(f => f )]; |
| | | this.headers = headers; |
| | | |
| | | // 生成行数据 |
| | | this.tableData = this.selectedWater.sort((a,b) => a - b).map(water => { |
| | | const row = { |
| | | temperature: water === '常温水' ? water : water, |
| | | values: this.selectedFlow.map(flow => ({ |
| | | flow: flow, |
| | | value: '' // 初始空值 |
| | | })) |
| | | }; |
| | | |
| | | // 初始化表单数据 |
| | | this.formData.temperatureData[water] = {}; |
| | | this.selectedFlow.forEach(flow => { |
| | | this.formData.temperatureData[water][flow] = ''; |
| | | }); |
| | | |
| | | return row; |
| | | }); |
| | | |
| | | // 自动滚动到表格区域 |
| | | setTimeout(() => { |
| | | const tableEl = document.getElementById('temperature-table'); |
| | | if (tableEl) tableEl.scrollIntoView({ behavior: 'smooth' }); |
| | | }, 100); |
| | | }, |
| | | } |
| | | }) |
| | | }) |