WIP: 修改Insert和Fit Peak接口和逻辑,增加BaseLine的Accept接口
This commit is contained in:
		
							parent
							
								
									b4782e98df
								
							
						
					
					
						commit
						7cc143bbd4
					
				| 
						 | 
					@ -6,16 +6,29 @@
 | 
				
			||||||
          <a-checkbox v-if="slot.isCheckbox" :key="index" v-model="record[slot.dataIndex]">
 | 
					          <a-checkbox v-if="slot.isCheckbox" :key="index" v-model="record[slot.dataIndex]">
 | 
				
			||||||
            Fixed
 | 
					            Fixed
 | 
				
			||||||
          </a-checkbox>
 | 
					          </a-checkbox>
 | 
				
			||||||
          <a-input v-else :key="index" v-model="record[slot.dataIndex]" :readOnly="slot.isStatic"></a-input>
 | 
					          <a-input
 | 
				
			||||||
 | 
					            v-else
 | 
				
			||||||
 | 
					            :key="index"
 | 
				
			||||||
 | 
					            v-model="record[slot.dataIndex]"
 | 
				
			||||||
 | 
					            :readOnly="slot.isStatic"
 | 
				
			||||||
 | 
					            @change="handleInput(record, slot.dataIndex)"
 | 
				
			||||||
 | 
					          ></a-input>
 | 
				
			||||||
        </template>
 | 
					        </template>
 | 
				
			||||||
      </custom-table>
 | 
					      </custom-table>
 | 
				
			||||||
    </a-spin>
 | 
					    </a-spin>
 | 
				
			||||||
    <div slot="custom-footer">
 | 
					    <div slot="custom-footer">
 | 
				
			||||||
      <a-space>
 | 
					      <a-space>
 | 
				
			||||||
        <a-button type="primary" :disabled="isCanceling || isLoading" :loading="isAcceptting" @click="handlePeaks">
 | 
					        <a-button
 | 
				
			||||||
 | 
					          type="primary"
 | 
				
			||||||
 | 
					          :disabled="isCanceling || isLoading"
 | 
				
			||||||
 | 
					          :loading="isAcceptting"
 | 
				
			||||||
 | 
					          @click="handlePeaks(true)"
 | 
				
			||||||
 | 
					        >
 | 
				
			||||||
          Peaks
 | 
					          Peaks
 | 
				
			||||||
        </a-button>
 | 
					        </a-button>
 | 
				
			||||||
        <a-button :disabled="isAcceptting || isLoading" :loading="isCanceling" @click="handleCancel">Cancel</a-button>
 | 
					        <a-button :disabled="isAcceptting || isLoading" :loading="isCanceling" @click="handlePeaks(false)"
 | 
				
			||||||
 | 
					          >Cancel</a-button
 | 
				
			||||||
 | 
					        >
 | 
				
			||||||
      </a-space>
 | 
					      </a-space>
 | 
				
			||||||
    </div>
 | 
					    </div>
 | 
				
			||||||
  </custom-modal>
 | 
					  </custom-modal>
 | 
				
			||||||
| 
						 | 
					@ -25,6 +38,7 @@
 | 
				
			||||||
import { getAction, postAction } from '@/api/manage'
 | 
					import { getAction, postAction } from '@/api/manage'
 | 
				
			||||||
import ModalMixin from '@/mixins/ModalMixin'
 | 
					import ModalMixin from '@/mixins/ModalMixin'
 | 
				
			||||||
import SampleDataMixin from '@/views/spectrumAnalysis/SampleDataMixin'
 | 
					import SampleDataMixin from '@/views/spectrumAnalysis/SampleDataMixin'
 | 
				
			||||||
 | 
					import { cloneDeep } from 'lodash'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const columns = [
 | 
					const columns = [
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
| 
						 | 
					@ -116,8 +130,14 @@ const columns = [
 | 
				
			||||||
export default {
 | 
					export default {
 | 
				
			||||||
  mixins: [ModalMixin, SampleDataMixin],
 | 
					  mixins: [ModalMixin, SampleDataMixin],
 | 
				
			||||||
  props: {
 | 
					  props: {
 | 
				
			||||||
    curChan: {
 | 
					    channel_1: {
 | 
				
			||||||
      type: Number
 | 
					      type: Number
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    channel_2: {
 | 
				
			||||||
 | 
					      type: Number
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    isInsertPeak: {
 | 
				
			||||||
 | 
					      type: Boolean
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
  data() {
 | 
					  data() {
 | 
				
			||||||
| 
						 | 
					@ -129,18 +149,20 @@ export default {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
  methods: {
 | 
					  methods: {
 | 
				
			||||||
    // 接收
 | 
					    async handlePeaks(accept) {
 | 
				
			||||||
    async handlePeaks() {
 | 
					 | 
				
			||||||
      try {
 | 
					      try {
 | 
				
			||||||
        this.isAcceptting = true
 | 
					        this.isAcceptting = true
 | 
				
			||||||
        const { inputFileName: fileName } = this.sampleData
 | 
					        const { inputFileName: fileName } = this.sampleData
 | 
				
			||||||
        const { success, result, message } = await postAction('/gamma/acceptResults', {
 | 
					        const { success, result, message } = await postAction('/gamma/acceptResults', {
 | 
				
			||||||
          fileName,
 | 
					          fileName,
 | 
				
			||||||
          accept: true
 | 
					          accept,
 | 
				
			||||||
 | 
					          oldPeaks: this.oldPeaks,
 | 
				
			||||||
 | 
					          newPeak: this.newPeaks,
 | 
				
			||||||
 | 
					          flag: this.isInsertPeak ? 'insert' : 'fit'
 | 
				
			||||||
        })
 | 
					        })
 | 
				
			||||||
        if (success) {
 | 
					        if (success) {
 | 
				
			||||||
          this.visible = false
 | 
					          this.visible = false
 | 
				
			||||||
          this.$emit('result', result)
 | 
					          this.$emit(accept ? 'result' : 'cancel', result)
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
          this.$message.error(message)
 | 
					          this.$message.error(message)
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
| 
						 | 
					@ -151,46 +173,51 @@ export default {
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // 取消
 | 
					    // 值变化
 | 
				
			||||||
    async handleCancel() {
 | 
					    handleInput(record, index) {
 | 
				
			||||||
      try {
 | 
					      const find = this.newPeaks.find(item => item.index == record.lab)
 | 
				
			||||||
        this.isCanceling = true
 | 
					      if (find) {
 | 
				
			||||||
        const { inputFileName: fileName } = this.sampleData
 | 
					        const table2NewPeakMap = {
 | 
				
			||||||
        const { success, result, message } = await postAction('/gamma/acceptResults', {
 | 
					          energy: 'energy',
 | 
				
			||||||
          fileName,
 | 
					          netArea: 'area',
 | 
				
			||||||
          accept: false,
 | 
					          fwhm: 'fwhm'
 | 
				
			||||||
          oldPeak: this.oldPeaks
 | 
					 | 
				
			||||||
        })
 | 
					 | 
				
			||||||
        if (success) {
 | 
					 | 
				
			||||||
          this.visible = false
 | 
					 | 
				
			||||||
          this.$emit('cancel', result)
 | 
					 | 
				
			||||||
        } else {
 | 
					 | 
				
			||||||
          this.$message.error(message)
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
      } catch (error) {
 | 
					
 | 
				
			||||||
        console.error(error)
 | 
					        find[table2NewPeakMap[index]] = record[index]
 | 
				
			||||||
      } finally {
 | 
					 | 
				
			||||||
        this.isCanceling = false
 | 
					 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    async getData() {
 | 
					    async getData() {
 | 
				
			||||||
 | 
					      const { sampleId, inputFileName: fileName } = this.sampleData
 | 
				
			||||||
      try {
 | 
					      try {
 | 
				
			||||||
 | 
					        let url = '/gamma/fitPeak'
 | 
				
			||||||
 | 
					        let params = {
 | 
				
			||||||
 | 
					          left: this.channel_1,
 | 
				
			||||||
 | 
					          right: this.channel_2,
 | 
				
			||||||
 | 
					          fileName
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // 如果是Insert Peak
 | 
				
			||||||
 | 
					        if (this.isInsertPeak) {
 | 
				
			||||||
 | 
					          url = '/gamma/insertPeak'
 | 
				
			||||||
 | 
					          params = {
 | 
				
			||||||
 | 
					            sampleId,
 | 
				
			||||||
 | 
					            fileName,
 | 
				
			||||||
 | 
					            curChan: Math.ceil(this.channel_1)
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        this.isLoading = true
 | 
					        this.isLoading = true
 | 
				
			||||||
        const { sampleId, inputFileName } = this.sampleData
 | 
					        const { success, result, message } = await getAction(url, params)
 | 
				
			||||||
        const { success, result, message } = await getAction('/gamma/insertPeak', {
 | 
					 | 
				
			||||||
          sampleId,
 | 
					 | 
				
			||||||
          fileName: inputFileName,
 | 
					 | 
				
			||||||
          curChan: Math.ceil(this.curChan)
 | 
					 | 
				
			||||||
        })
 | 
					 | 
				
			||||||
        if (success) {
 | 
					        if (success) {
 | 
				
			||||||
          const { oldPeaks, tablePeaksList } = result
 | 
					          const { newPeaks, oldPeaks, tablePeaksList } = result
 | 
				
			||||||
          tablePeaksList.forEach(item => {
 | 
					          tablePeaksList.forEach(item => {
 | 
				
			||||||
            item.energy = Number(item.energy).toPrecision(6)
 | 
					            item.energy = Number(item.energy).toPrecision(6)
 | 
				
			||||||
            item.netArea = Number(item.netArea).toPrecision(6)
 | 
					            item.netArea = Number(item.netArea).toPrecision(6)
 | 
				
			||||||
            item.fwhm = Number(item.fwhm).toPrecision(6)
 | 
					            item.fwhm = Number(item.fwhm).toPrecision(6)
 | 
				
			||||||
          })
 | 
					          })
 | 
				
			||||||
          this.list = tablePeaksList
 | 
					          this.list = tablePeaksList
 | 
				
			||||||
 | 
					          this.newPeaks = newPeaks
 | 
				
			||||||
          this.oldPeaks = oldPeaks
 | 
					          this.oldPeaks = oldPeaks
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
          this.$message.error(message)
 | 
					          this.$message.error(message)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -181,7 +181,9 @@
 | 
				
			||||||
    <!-- Fit Peaks and Baseline弹窗 开始 -->
 | 
					    <!-- Fit Peaks and Baseline弹窗 开始 -->
 | 
				
			||||||
    <fit-peaks-and-base-line-modal
 | 
					    <fit-peaks-and-base-line-modal
 | 
				
			||||||
      v-model="fitPeaksAndBaselineModalVisible"
 | 
					      v-model="fitPeaksAndBaselineModalVisible"
 | 
				
			||||||
      :curChan="currChannel"
 | 
					      :channel_1="channel_1"
 | 
				
			||||||
 | 
					      :channel_2="channel_2"
 | 
				
			||||||
 | 
					      :isInsertPeak="isInsertPeak"
 | 
				
			||||||
      @result="handleInsertSuccess"
 | 
					      @result="handleInsertSuccess"
 | 
				
			||||||
      @cancel="handleCancelSuccess"
 | 
					      @cancel="handleCancelSuccess"
 | 
				
			||||||
    />
 | 
					    />
 | 
				
			||||||
| 
						 | 
					@ -461,6 +463,11 @@ export default {
 | 
				
			||||||
      model: cloneDeep(nuclideIdentifyModal),
 | 
					      model: cloneDeep(nuclideIdentifyModal),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      currChannel: undefined, // 当currChannel前选中的channel
 | 
					      currChannel: undefined, // 当currChannel前选中的channel
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      channel_1: undefined, // 用于Fit Peaks And Baseline Modal的道值
 | 
				
			||||||
 | 
					      channel_2: undefined,
 | 
				
			||||||
 | 
					      isInsertPeak: false, // 是否是插入Peak
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      selectedTableItem: undefined, // 当前选中的表格项
 | 
					      selectedTableItem: undefined, // 当前选中的表格项
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      isModifying: false, // 正在修改控制点
 | 
					      isModifying: false, // 正在修改控制点
 | 
				
			||||||
| 
						 | 
					@ -636,6 +643,9 @@ export default {
 | 
				
			||||||
          return
 | 
					          return
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        this.channel_1 = left
 | 
				
			||||||
 | 
					        this.channel_2 = right
 | 
				
			||||||
 | 
					        this.isInsertPeak = false
 | 
				
			||||||
        this.fitPeaksAndBaselineModalVisible = true
 | 
					        this.fitPeaksAndBaselineModalVisible = true
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        this.isFitting = false
 | 
					        this.isFitting = false
 | 
				
			||||||
| 
						 | 
					@ -737,7 +747,10 @@ export default {
 | 
				
			||||||
        return
 | 
					        return
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      this.channel_1 = this.currChannel
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      this.fitPeaksAndBaselineModalVisible = true
 | 
					      this.fitPeaksAndBaselineModalVisible = true
 | 
				
			||||||
 | 
					      this.isInsertPeak = true
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // 点击 Fit Peak XXX 弹窗中的 Peaks 按钮
 | 
					    // 点击 Fit Peak XXX 弹窗中的 Peaks 按钮
 | 
				
			||||||
| 
						 | 
					@ -772,13 +785,13 @@ export default {
 | 
				
			||||||
      series.push(this.buildBaseLine(channelBaseLineChart))
 | 
					      series.push(this.buildBaseLine(channelBaseLineChart))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      // 推入旧的Count
 | 
					      // 推入旧的Count
 | 
				
			||||||
      series.push(this.buildCountLine(channelCountChart))
 | 
					      series.push(this.buildCountLine(this.channelCountChart))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      // 推入Peak
 | 
					      // 推入Peak
 | 
				
			||||||
      series.push(...this.buildPeaks(channelPeakChart))
 | 
					      series.push(...this.buildPeaks(channelPeakChart))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      // 推入旧的基线控制点
 | 
					      // 推入旧的基线控制点
 | 
				
			||||||
      series.push(this.buildCtrlPoint(channelBaseCPChart))
 | 
					      series.push(this.buildCtrlPoint(this.channelBaseCPChart))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      this.thumbnailOption.series = this.buildBarChart(barChart)
 | 
					      this.thumbnailOption.series = this.buildBarChart(barChart)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1278,27 +1291,43 @@ export default {
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // 确定对Baseline Control Points 的操作
 | 
					    // 确定对Baseline Control Points 的操作
 | 
				
			||||||
    handleAccept() {
 | 
					    async handleAccept() {
 | 
				
			||||||
      this.BaseCtrls = cloneDeep(this.baseCtrls_Copy)
 | 
					      this.BaseCtrls = cloneDeep(this.baseCtrls_Copy)
 | 
				
			||||||
      const { baseline, xctrl, yctrl } = this.BaseCtrls
 | 
					      const { baseline, xctrl, yctrl } = this.BaseCtrls
 | 
				
			||||||
      this.channelBaseLineChart.pointlist = baseline.map((val, index) => {
 | 
					      // this.channelBaseLineChart.pointlist = baseline.map((val, index) => {
 | 
				
			||||||
        return {
 | 
					      //   return {
 | 
				
			||||||
          x: index + 1,
 | 
					      //     x: index + 1,
 | 
				
			||||||
          y: val
 | 
					      //     y: val
 | 
				
			||||||
        }
 | 
					      //   }
 | 
				
			||||||
      })
 | 
					      // })
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      this.channelBaseCPChart = xctrl.map((val, index) => {
 | 
					      // this.channelBaseCPChart = xctrl.map((val, index) => {
 | 
				
			||||||
        return {
 | 
					      //   return {
 | 
				
			||||||
          color: this.channelBaseCPChart[0].color,
 | 
					      //     color: this.channelBaseCPChart[0].color,
 | 
				
			||||||
          name: index.toString(),
 | 
					      //     name: index.toString(),
 | 
				
			||||||
          point: {
 | 
					      //     point: {
 | 
				
			||||||
            x: val,
 | 
					      //       x: val,
 | 
				
			||||||
            y: yctrl[index]
 | 
					      //       y: yctrl[index]
 | 
				
			||||||
          },
 | 
					      //     },
 | 
				
			||||||
          size: 4
 | 
					      //     size: 4
 | 
				
			||||||
 | 
					      //   }
 | 
				
			||||||
 | 
					      // })
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      const { inputFileName: fileName } = this.sampleData
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      try {
 | 
				
			||||||
 | 
					        const { success, result, message } = await postAction('/gamma/acceptBaseLine', {
 | 
				
			||||||
 | 
					          ...this.BaseCtrls,
 | 
				
			||||||
 | 
					          fileName
 | 
				
			||||||
 | 
					        })
 | 
				
			||||||
 | 
					        if(success) {
 | 
				
			||||||
 | 
					          console.log('%c [  ]-1312', 'font-size:13px; background:pink; color:#bf2c9f;', result)
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					          this.$message.error(message)
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
      })
 | 
					      } catch (error) {
 | 
				
			||||||
 | 
					        console.error(error)
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      this.handleSwitchOperation()
 | 
					      this.handleSwitchOperation()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user