feat: Calibration剩下的两个弹窗中的各操作和接口对接
This commit is contained in:
		
							parent
							
								
									890bc9fa73
								
							
						
					
					
						commit
						dcc75bd800
					
				
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| 
						 | 
				
			
			@ -43,7 +43,7 @@ export default {
 | 
			
		|||
      try {
 | 
			
		||||
        this.isLoading = true
 | 
			
		||||
        const { inputFileName: fileName } = this.sampleData
 | 
			
		||||
        const { success, result, message } = await getAction('/gamma/viewGenralComment', {
 | 
			
		||||
        const { success, result, message } = await getAction('/gamma/viewGeneralComment', {
 | 
			
		||||
          fileName
 | 
			
		||||
        })
 | 
			
		||||
        if (success) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -115,6 +115,7 @@
 | 
			
		|||
                <div class="title">
 | 
			
		||||
                  Possible Nuclide
 | 
			
		||||
                </div>
 | 
			
		||||
                <a-spin :spinning="!!(selectedTableItem && selectedTableItem._loading)">
 | 
			
		||||
                  <div class="content">
 | 
			
		||||
                    <template v-if="selectedTableItem && selectedTableItem._possible">
 | 
			
		||||
                      <div
 | 
			
		||||
| 
						 | 
				
			
			@ -128,6 +129,7 @@
 | 
			
		|||
                      </div>
 | 
			
		||||
                    </template>
 | 
			
		||||
                  </div>
 | 
			
		||||
                </a-spin>
 | 
			
		||||
              </div>
 | 
			
		||||
              <div class="identify-item">
 | 
			
		||||
                <div class="title">
 | 
			
		||||
| 
						 | 
				
			
			@ -187,9 +189,8 @@ import PeakCommentModal from './components/PeakCommentModal.vue'
 | 
			
		|||
import FitPeaksAndBaseLineModal from './components/FitPeaksAndBaselineModal.vue'
 | 
			
		||||
import NuclideReviewModal from './components/NuclideReviewModal.vue'
 | 
			
		||||
import ModalMixin from '@/mixins/ModalMixin'
 | 
			
		||||
import { getAction } from '@/api/manage'
 | 
			
		||||
import { getAction, postAction } from '@/api/manage'
 | 
			
		||||
import { cloneDeep } from 'lodash'
 | 
			
		||||
import Response from './Response.json'
 | 
			
		||||
import { findSeriesByName, getXAxisAndYAxisByPosition, rangeNumber } from '@/utils/chartHelper'
 | 
			
		||||
import SampleDataMixin from '@/views/spectrumAnalysis/SampleDataMixin'
 | 
			
		||||
import GeneralCommentModal from './components/GeneralCommentModal.vue'
 | 
			
		||||
| 
						 | 
				
			
			@ -410,7 +411,6 @@ export default {
 | 
			
		|||
      sampleId: -1,
 | 
			
		||||
 | 
			
		||||
      peakCommentModalVisible: false, // Comment 弹窗是否显示
 | 
			
		||||
      curRow: -1,
 | 
			
		||||
      generalCommentModalVisible: false, // Comment 弹窗是否显示
 | 
			
		||||
 | 
			
		||||
      btnGroupType: 1, // 右侧 Peak 中的按钮组切换
 | 
			
		||||
| 
						 | 
				
			
			@ -446,7 +446,6 @@ export default {
 | 
			
		|||
        this.isLoading = true
 | 
			
		||||
        this.option.series = []
 | 
			
		||||
 | 
			
		||||
        // const { success, result, message } = Response
 | 
			
		||||
        const { success, result, message } = await getAction('/gamma/InteractiveTool', {
 | 
			
		||||
          sampleId: this.sampleId,
 | 
			
		||||
          fileName: this.fileName
 | 
			
		||||
| 
						 | 
				
			
			@ -676,6 +675,7 @@ export default {
 | 
			
		|||
      this.model.identifiedNuclide = ''
 | 
			
		||||
 | 
			
		||||
      if (!row._possible) {
 | 
			
		||||
        this.$set(row, '_loading', true)
 | 
			
		||||
        try {
 | 
			
		||||
          const { success, result, message } = await getAction('/gamma/getSelPosNuclide', {
 | 
			
		||||
            sampleId: this.sampleId,
 | 
			
		||||
| 
						 | 
				
			
			@ -691,6 +691,8 @@ export default {
 | 
			
		|||
          }
 | 
			
		||||
        } catch (error) {
 | 
			
		||||
          console.error(error)
 | 
			
		||||
        } finally {
 | 
			
		||||
          row._loading = false
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
| 
						 | 
				
			
			@ -706,14 +708,11 @@ export default {
 | 
			
		|||
    },
 | 
			
		||||
 | 
			
		||||
    // 显示peak comment弹窗
 | 
			
		||||
    handleAddPeakComment () {
 | 
			
		||||
    handleAddPeakComment() {
 | 
			
		||||
      if (!this.selectedKeys.length) {
 | 
			
		||||
        this.$message.warn('Please Select a Peak that You Want to Add Comment!')
 | 
			
		||||
        return
 | 
			
		||||
      }
 | 
			
		||||
      const [willDelKey] = this.selectedKeys
 | 
			
		||||
      const findIndex = this.list.findIndex(item => item.index == willDelKey)
 | 
			
		||||
      this.curRow = findIndex
 | 
			
		||||
      this.peakCommentModalVisible = true
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -925,8 +924,6 @@ export default {
 | 
			
		|||
        title: 'Warning',
 | 
			
		||||
        content: 'Are you sure to delete this peak?',
 | 
			
		||||
        onOk: async () => {
 | 
			
		||||
          const [willDelKey] = this.selectedKeys
 | 
			
		||||
          const findIndex = this.list.findIndex(item => item.index == willDelKey)
 | 
			
		||||
          // this.list.splice(findIndex, 1)
 | 
			
		||||
          // this.selectedKeys = []
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -945,7 +942,7 @@ export default {
 | 
			
		|||
            const { inputFileName: fileName } = this.sampleData
 | 
			
		||||
            const { success, result, message } = await getAction('/gamma/deletePeak', {
 | 
			
		||||
              fileName,
 | 
			
		||||
              curRow: findIndex
 | 
			
		||||
              curRow: this.curRow
 | 
			
		||||
            })
 | 
			
		||||
            if (success) {
 | 
			
		||||
              console.log('%c [  ]-935', 'font-size:13px; background:pink; color:#bf2c9f;', result)
 | 
			
		||||
| 
						 | 
				
			
			@ -1334,26 +1331,73 @@ export default {
 | 
			
		|||
    handleAccept() {},
 | 
			
		||||
 | 
			
		||||
    // 右下角添加当前选中的nuclide
 | 
			
		||||
    handleAddNuclide() {
 | 
			
		||||
    async handleAddNuclide() {
 | 
			
		||||
      const nuclides = this.selectedTableItem.nuclides
 | 
			
		||||
      const possibleNuclide = this.model.possibleNuclide
 | 
			
		||||
      if (this.selectedTableItem && !nuclides.includes(possibleNuclide)) {
 | 
			
		||||
      if (!nuclides.includes(possibleNuclide)) {
 | 
			
		||||
        if (this.selectedTableItem._adding) {
 | 
			
		||||
          return
 | 
			
		||||
        }
 | 
			
		||||
        try {
 | 
			
		||||
          this.$set(this.selectedTableItem, '_adding', true)
 | 
			
		||||
          const { inputFileName: fileName } = this.sampleData
 | 
			
		||||
          const { success, message } = await postAction('/gamma/addNuclide', {
 | 
			
		||||
            curRow: this.curRow,
 | 
			
		||||
            nuclideName: possibleNuclide,
 | 
			
		||||
            fileName,
 | 
			
		||||
            list_identify: nuclides
 | 
			
		||||
          })
 | 
			
		||||
          if (success) {
 | 
			
		||||
            nuclides.push(possibleNuclide)
 | 
			
		||||
          } else {
 | 
			
		||||
            this.$message.error(message)
 | 
			
		||||
          }
 | 
			
		||||
        } catch (error) {
 | 
			
		||||
          console.error(error)
 | 
			
		||||
        } finally {
 | 
			
		||||
          this.selectedTableItem._adding = false
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    // 右下角删除当前选中的nuclide
 | 
			
		||||
    handleDelNuclide() {
 | 
			
		||||
      const [willDelKey] = this.selectedKeys
 | 
			
		||||
      const find = this.list.find(item => item.index == willDelKey)
 | 
			
		||||
      console.log('%c [ find ]-762', 'font-size:13px; background:pink; color:#bf2c9f;', find)
 | 
			
		||||
      if (find) {
 | 
			
		||||
        const nuclides = find.nuclides
 | 
			
		||||
    async handleDelNuclide() {
 | 
			
		||||
      if (!this.model.identifiedNuclide) {
 | 
			
		||||
        return
 | 
			
		||||
      }
 | 
			
		||||
      const nuclides = this.selectedTableItem.nuclides
 | 
			
		||||
      if (this.selectedTableItem._deleting) {
 | 
			
		||||
        return
 | 
			
		||||
      }
 | 
			
		||||
      const findIndex = nuclides.findIndex(nuclide => nuclide == this.model.identifiedNuclide)
 | 
			
		||||
      if (-1 !== findIndex) {
 | 
			
		||||
        try {
 | 
			
		||||
          this.$set(this.selectedTableItem, '_deleting', true)
 | 
			
		||||
          const { inputFileName: fileName } = this.sampleData
 | 
			
		||||
          const { success, message } = await postAction('/gamma/deleteNuclide', {
 | 
			
		||||
            curRow: this.curRow,
 | 
			
		||||
            nuclideName: this.model.identifiedNuclide,
 | 
			
		||||
            fileName,
 | 
			
		||||
            list_identify: nuclides
 | 
			
		||||
          })
 | 
			
		||||
          if (success) {
 | 
			
		||||
            nuclides.splice(findIndex, 1)
 | 
			
		||||
          } else {
 | 
			
		||||
            this.$message.error(message)
 | 
			
		||||
          }
 | 
			
		||||
        } catch (error) {
 | 
			
		||||
          console.error(error)
 | 
			
		||||
        } finally {
 | 
			
		||||
          this.selectedTableItem._deleting = false
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  computed: {
 | 
			
		||||
    curRow() {
 | 
			
		||||
      const [selectedKey] = this.selectedKeys
 | 
			
		||||
      const findIndex = this.list.findIndex(item => item.index == selectedKey)
 | 
			
		||||
      return findIndex
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
</script>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,6 +1,7 @@
 | 
			
		|||
<template>
 | 
			
		||||
  <custom-modal v-model="visible" :width="1280" title="Efficiency Calibration" :footer="null">
 | 
			
		||||
    <div class="efficiency-calibration">
 | 
			
		||||
  <custom-modal v-model="visible" :width="1280" title="Efficiency Calibration" :footer="null" destroy-on-close>
 | 
			
		||||
    <a-spin :spinning="isLoading">
 | 
			
		||||
      <div class="energy-calibration">
 | 
			
		||||
        <div class="left">
 | 
			
		||||
          <!-- Calibration Data -->
 | 
			
		||||
          <title-over-border title="Calibration Data">
 | 
			
		||||
| 
						 | 
				
			
			@ -21,29 +22,33 @@
 | 
			
		|||
                }"
 | 
			
		||||
              >
 | 
			
		||||
                <a-form-model-item label="Energy">
 | 
			
		||||
                <a-input></a-input>
 | 
			
		||||
                  <a-input type="number" v-model="model.energy"></a-input>
 | 
			
		||||
                </a-form-model-item>
 | 
			
		||||
                <a-form-model-item label="Efficiency">
 | 
			
		||||
                <a-input></a-input>
 | 
			
		||||
                  <a-input type="number" v-model="model.efficiency"></a-input>
 | 
			
		||||
                </a-form-model-item>
 | 
			
		||||
                <a-form-model-item :label="' '">
 | 
			
		||||
                <a-button type="primary">Insert</a-button>
 | 
			
		||||
                  <a-button type="primary" @click="handleInsert">Insert</a-button>
 | 
			
		||||
                </a-form-model-item>
 | 
			
		||||
                <a-form-model-item :label="' '">
 | 
			
		||||
                <a-button type="primary">Modify</a-button>
 | 
			
		||||
                  <a-button type="primary" @click="handleModify">Modify</a-button>
 | 
			
		||||
                </a-form-model-item>
 | 
			
		||||
                <a-form-model-item :label="' '">
 | 
			
		||||
                <a-button type="primary">Delete</a-button>
 | 
			
		||||
                  <a-button type="primary" @click="handleDelete">Delete</a-button>
 | 
			
		||||
                </a-form-model-item>
 | 
			
		||||
              </a-form-model>
 | 
			
		||||
              <!-- 表格 -->
 | 
			
		||||
            <a-table
 | 
			
		||||
              <custom-table
 | 
			
		||||
                :columns="columns"
 | 
			
		||||
              :dataSource="list"
 | 
			
		||||
                :list="list"
 | 
			
		||||
                :pagination="false"
 | 
			
		||||
                size="small"
 | 
			
		||||
                :class="list.length ? 'has-data' : ''"
 | 
			
		||||
                :scroll="{ y: 182 }"
 | 
			
		||||
            ></a-table>
 | 
			
		||||
                :selectedRowKeys.sync="selectedRowKeys"
 | 
			
		||||
                :canDeselect="false"
 | 
			
		||||
                @rowClick="handleRowClick"
 | 
			
		||||
              ></custom-table>
 | 
			
		||||
              <!-- 表格结束 -->
 | 
			
		||||
              <div class="operators">
 | 
			
		||||
                <div>
 | 
			
		||||
| 
						 | 
				
			
			@ -51,44 +56,50 @@
 | 
			
		|||
                  <a-button type="primary">Save</a-button>
 | 
			
		||||
                </div>
 | 
			
		||||
                <div>
 | 
			
		||||
                <a-select :value="''">
 | 
			
		||||
                  <a-select-option value="">
 | 
			
		||||
                    Interpolation
 | 
			
		||||
                  <a-select v-model="funcId" @change="recalculate">
 | 
			
		||||
                    <a-select-option v-for="(func, index) in functions" :key="index" :value="func.value">
 | 
			
		||||
                      {{ func.label }}
 | 
			
		||||
                    </a-select-option>
 | 
			
		||||
                  </a-select>
 | 
			
		||||
                <a-button type="primary">Apply</a-button>
 | 
			
		||||
                  <a-button type="primary" @click="handleApply">Apply</a-button>
 | 
			
		||||
                </div>
 | 
			
		||||
              </div>
 | 
			
		||||
            </div>
 | 
			
		||||
          </title-over-border>
 | 
			
		||||
          <!-- Equation -->
 | 
			
		||||
          <title-over-border class="mt-20" title="Equation">
 | 
			
		||||
          <div class="equation">
 | 
			
		||||
            Efficiency = 59.541 + (88.034 - 59.541) * (E - 1) / (0.058243 - 1)
 | 
			
		||||
          </div>
 | 
			
		||||
            <div class="equation" v-html="equation"></div>
 | 
			
		||||
          </title-over-border>
 | 
			
		||||
          <!-- curve -->
 | 
			
		||||
          <title-over-border class="mt-20" title="curve">
 | 
			
		||||
            <div class="curve">
 | 
			
		||||
            <custom-chart :option="option" />
 | 
			
		||||
              <custom-chart :option="option" :opts="opts" />
 | 
			
		||||
            </div>
 | 
			
		||||
          </title-over-border>
 | 
			
		||||
        </div>
 | 
			
		||||
        <div class="right">
 | 
			
		||||
          <title-over-border title="Data Source" style="height: 100%">
 | 
			
		||||
            <div class="data-source">
 | 
			
		||||
            <div class="data-source-main">
 | 
			
		||||
              <div class="title">PHD</div>
 | 
			
		||||
              <div class="content"></div>
 | 
			
		||||
              <div class="content">
 | 
			
		||||
                <div
 | 
			
		||||
                  class="item"
 | 
			
		||||
                  :class="item == currSelectedDataSource ? 'active' : ''"
 | 
			
		||||
                  v-for="(item, index) in dataSourceList"
 | 
			
		||||
                  :key="index"
 | 
			
		||||
                  @click="handleDataSourceClick(item)"
 | 
			
		||||
                >
 | 
			
		||||
                  {{ item }}
 | 
			
		||||
                </div>
 | 
			
		||||
              </div>
 | 
			
		||||
              <div class="footer mt-20">
 | 
			
		||||
              <a-button type="primary">Set to Current</a-button>
 | 
			
		||||
              <div class="mt-20">PHD</div>
 | 
			
		||||
                <a-button type="primary" @click="handleSetToCurrent">Set to Current</a-button>
 | 
			
		||||
                <div class="mt-20">{{ appliedDataSource }}</div>
 | 
			
		||||
              </div>
 | 
			
		||||
            </div>
 | 
			
		||||
          </title-over-border>
 | 
			
		||||
        </div>
 | 
			
		||||
      </div>
 | 
			
		||||
    </a-spin>
 | 
			
		||||
  </custom-modal>
 | 
			
		||||
</template>
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -96,6 +107,10 @@
 | 
			
		|||
import ModalMixin from '@/mixins/ModalMixin'
 | 
			
		||||
import TitleOverBorder from '../TitleOverBorder.vue'
 | 
			
		||||
import CustomChart from '@/components/CustomChart/index.vue'
 | 
			
		||||
import { getAction, postAction } from '@/api/manage'
 | 
			
		||||
import { cloneDeep } from 'lodash'
 | 
			
		||||
import { buildLineSeries } from '@/utils/chartHelper'
 | 
			
		||||
import SampleDataMixin from '../../SampleDataMixin'
 | 
			
		||||
 | 
			
		||||
const columns = [
 | 
			
		||||
  {
 | 
			
		||||
| 
						 | 
				
			
			@ -107,7 +122,7 @@ const columns = [
 | 
			
		|||
    dataIndex: 'efficiency'
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    title: 'Fit',
 | 
			
		||||
    title: 'Fit(keV)',
 | 
			
		||||
    dataIndex: 'fit'
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
| 
						 | 
				
			
			@ -124,7 +139,7 @@ const initialOption = {
 | 
			
		|||
    left: 70
 | 
			
		||||
  },
 | 
			
		||||
  title: {
 | 
			
		||||
    text: 'Energy(keV)',
 | 
			
		||||
    text: 'Channel',
 | 
			
		||||
    textStyle: {
 | 
			
		||||
      color: '#8FD4F8',
 | 
			
		||||
      fontSize: 14,
 | 
			
		||||
| 
						 | 
				
			
			@ -133,9 +148,20 @@ const initialOption = {
 | 
			
		|||
    right: 10,
 | 
			
		||||
    bottom: 0
 | 
			
		||||
  },
 | 
			
		||||
  tooltip: {
 | 
			
		||||
    trigger: 'axis',
 | 
			
		||||
    formatter: params => {
 | 
			
		||||
      const [x, y] = params[0].value
 | 
			
		||||
      const energy = parseInt(x)
 | 
			
		||||
      const efficiency = y.toFixed(3)
 | 
			
		||||
      return `<div class="channel">Energy: ${energy}</div>
 | 
			
		||||
              <div class="energy">Efficiency: ${efficiency}</div>`
 | 
			
		||||
    },
 | 
			
		||||
    className: 'figure-chart-option-tooltip'
 | 
			
		||||
  },
 | 
			
		||||
  xAxis: {
 | 
			
		||||
    min: 42,
 | 
			
		||||
    max: 2740,
 | 
			
		||||
    min: 1,
 | 
			
		||||
    max: 'dataMax',
 | 
			
		||||
    axisLabel: {
 | 
			
		||||
      color: '#fff'
 | 
			
		||||
    },
 | 
			
		||||
| 
						 | 
				
			
			@ -163,7 +189,7 @@ const initialOption = {
 | 
			
		|||
    splitLine: {
 | 
			
		||||
      show: false
 | 
			
		||||
    },
 | 
			
		||||
    name: 'Efficiency',
 | 
			
		||||
    name: 'keV',
 | 
			
		||||
    nameLocation: 'center',
 | 
			
		||||
    nameGap: 50,
 | 
			
		||||
    nameTextStyle: {
 | 
			
		||||
| 
						 | 
				
			
			@ -171,48 +197,319 @@ const initialOption = {
 | 
			
		|||
      fontSize: 14
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  series: [
 | 
			
		||||
    {
 | 
			
		||||
      type: 'line',
 | 
			
		||||
      symbol: 'square',
 | 
			
		||||
      itemStyle: {
 | 
			
		||||
        color: '#FF0000' // 设置符号的颜色
 | 
			
		||||
      },
 | 
			
		||||
      lineStyle: {
 | 
			
		||||
        color: '#C2CC11' // 设置折线的颜色
 | 
			
		||||
      },
 | 
			
		||||
      data: [
 | 
			
		||||
        [42, 0],
 | 
			
		||||
        [100, 0.2],
 | 
			
		||||
        [978, 0.1]
 | 
			
		||||
      ]
 | 
			
		||||
    }
 | 
			
		||||
  ]
 | 
			
		||||
  series: []
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const functions = [
 | 
			
		||||
  {
 | 
			
		||||
    label: 'Interpolation',
 | 
			
		||||
    value: 1
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    label: 'HT Efficiency',
 | 
			
		||||
    value: 5
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    label: 'Log Polynomial',
 | 
			
		||||
    value: 6
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    label: 'Invlog Polynomial',
 | 
			
		||||
    value: 8
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    label: 'HAE Efficiency(1-3)',
 | 
			
		||||
    value: 93
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    label: 'HAE Efficiency(1-2)',
 | 
			
		||||
    value: 94
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    label: 'HAE Efficiency(1-2-3)',
 | 
			
		||||
    value: 95
 | 
			
		||||
  }
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
export default {
 | 
			
		||||
  components: { TitleOverBorder, CustomChart },
 | 
			
		||||
  mixins: [ModalMixin],
 | 
			
		||||
  mixins: [ModalMixin, SampleDataMixin],
 | 
			
		||||
  data() {
 | 
			
		||||
    this.columns = columns
 | 
			
		||||
    this.functions = functions
 | 
			
		||||
 | 
			
		||||
    return {
 | 
			
		||||
      list: [
 | 
			
		||||
        {
 | 
			
		||||
          energy: 'energy',
 | 
			
		||||
          efficiency: 'efficiency',
 | 
			
		||||
          fit: 'fit',
 | 
			
		||||
          delta: 'delta'
 | 
			
		||||
      isLoading: false,
 | 
			
		||||
      equation: '',
 | 
			
		||||
      dataSourceList: [],
 | 
			
		||||
      list: [],
 | 
			
		||||
      option: cloneDeep(initialOption),
 | 
			
		||||
      selectedRowKeys: [],
 | 
			
		||||
      model: {},
 | 
			
		||||
      currSelectedDataSource: '',
 | 
			
		||||
      appliedDataSource: '',
 | 
			
		||||
      opts: {
 | 
			
		||||
        notMerge: true
 | 
			
		||||
      },
 | 
			
		||||
      ECutAnalysis_Low: -1,
 | 
			
		||||
      G_energy_span: -1,
 | 
			
		||||
      funcId: 1
 | 
			
		||||
    }
 | 
			
		||||
      ],
 | 
			
		||||
      option: initialOption
 | 
			
		||||
  },
 | 
			
		||||
  methods: {
 | 
			
		||||
    async getData(currentText) {
 | 
			
		||||
      try {
 | 
			
		||||
        this.isLoading = true
 | 
			
		||||
        const { sampleId, inputFileName: fileName } = this.sampleData
 | 
			
		||||
        const { success, result, message } = await getAction('/gamma/EfficiencyCalibration', {
 | 
			
		||||
          sampleId,
 | 
			
		||||
          fileName,
 | 
			
		||||
          currentText
 | 
			
		||||
        })
 | 
			
		||||
        this.isLoading = false
 | 
			
		||||
        if (success) {
 | 
			
		||||
          console.log('%c [  ]-220', 'font-size:13px; background:pink; color:#bf2c9f;', result)
 | 
			
		||||
          const { list_dataSource, ECutAnalysis_Low, G_energy_span } = result
 | 
			
		||||
          this.dataSourceList = list_dataSource
 | 
			
		||||
          if (!currentText) {
 | 
			
		||||
            this.currSelectedDataSource = list_dataSource[list_dataSource.length - 1]
 | 
			
		||||
            this.appliedDataSource = list_dataSource[list_dataSource.length - 1]
 | 
			
		||||
          }
 | 
			
		||||
 | 
			
		||||
          this.ECutAnalysis_Low = ECutAnalysis_Low
 | 
			
		||||
          this.G_energy_span = G_energy_span
 | 
			
		||||
 | 
			
		||||
          this.handleResult(result)
 | 
			
		||||
        } else {
 | 
			
		||||
          this.$message.error(message)
 | 
			
		||||
        }
 | 
			
		||||
      } catch (error) {
 | 
			
		||||
        console.error(error)
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    handleResult(result) {
 | 
			
		||||
      const { AllData, equation, param, table, uncert } = result
 | 
			
		||||
      // 有数据
 | 
			
		||||
      if (AllData) {
 | 
			
		||||
        const [linePoint, scatterPoint] = AllData
 | 
			
		||||
        this.equation = equation
 | 
			
		||||
        this.param = param
 | 
			
		||||
        this.uncert = uncert
 | 
			
		||||
 | 
			
		||||
        this.list = table
 | 
			
		||||
        this.generateTableId()
 | 
			
		||||
 | 
			
		||||
        const series = []
 | 
			
		||||
        series.push(
 | 
			
		||||
          buildLineSeries(
 | 
			
		||||
            'LineSeries',
 | 
			
		||||
            linePoint.pointlist.map(({ x, y }) => [x, y]),
 | 
			
		||||
            `rgb(${linePoint.color})`
 | 
			
		||||
          )
 | 
			
		||||
        )
 | 
			
		||||
        series.push({
 | 
			
		||||
          type: 'scatter',
 | 
			
		||||
          data: scatterPoint.pointlist.map(({ x, y }) => {
 | 
			
		||||
            return {
 | 
			
		||||
              value: [x, y],
 | 
			
		||||
              itemStyle: {
 | 
			
		||||
                color: scatterPoint.color,
 | 
			
		||||
                borderWidth: 0
 | 
			
		||||
              }
 | 
			
		||||
            }
 | 
			
		||||
          }),
 | 
			
		||||
          emphasis: {
 | 
			
		||||
            disabled: true
 | 
			
		||||
          },
 | 
			
		||||
          animation: false,
 | 
			
		||||
          zlevel: 20
 | 
			
		||||
        })
 | 
			
		||||
        this.option.series = series
 | 
			
		||||
      }
 | 
			
		||||
      // 没数据
 | 
			
		||||
      else {
 | 
			
		||||
        this.option.series = []
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    beforeModalOpen() {
 | 
			
		||||
      this.selectedRowKeys = []
 | 
			
		||||
      this.funcId = 1
 | 
			
		||||
      this.getData()
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    // 表格单行点击
 | 
			
		||||
    handleRowClick(row) {
 | 
			
		||||
      this.model = cloneDeep(row)
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    // 插入
 | 
			
		||||
    handleInsert() {
 | 
			
		||||
      const energy = parseFloat(this.model.energy)
 | 
			
		||||
      const efficiency = parseFloat(this.model.efficiency)
 | 
			
		||||
 | 
			
		||||
      if (Number.isNaN(energy) || Number.isNaN(efficiency)) {
 | 
			
		||||
        this.$message.warn('Format is invalid.')
 | 
			
		||||
        return
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      if (energy <= this.ECutAnalysis_Low || energy >= this.G_energy_span) {
 | 
			
		||||
        this.$message.warn('Energy is out of analysis range.')
 | 
			
		||||
        return
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      let i,
 | 
			
		||||
        num = this.list.length
 | 
			
		||||
      for (i = 0; i < num; ++i) {
 | 
			
		||||
        const currEnergy = this.list[i].energy
 | 
			
		||||
        if (Math.abs(currEnergy - energy) < 0.001) {
 | 
			
		||||
          this.$message.warn('The centroid has already existed!')
 | 
			
		||||
          return
 | 
			
		||||
        } else if (currEnergy > energy) {
 | 
			
		||||
          break
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      this.list.splice(i, 0, {
 | 
			
		||||
        energy: energy,
 | 
			
		||||
        efficiency
 | 
			
		||||
      })
 | 
			
		||||
 | 
			
		||||
      this.uncert.splice(i, 0, 0.5)
 | 
			
		||||
 | 
			
		||||
      this.selectedRowKeys = [i]
 | 
			
		||||
      this.generateTableId()
 | 
			
		||||
 | 
			
		||||
      this.recalculate()
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    // 生成table中数据的id,用以选中
 | 
			
		||||
    generateTableId() {
 | 
			
		||||
      this.list.forEach((item, index) => {
 | 
			
		||||
        item.id = index
 | 
			
		||||
      })
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    // 修改
 | 
			
		||||
    handleModify() {
 | 
			
		||||
      if (this.selectedRowKeys.length) {
 | 
			
		||||
        const energy = parseFloat(this.model.energy)
 | 
			
		||||
        const efficiency = parseFloat(this.model.efficiency)
 | 
			
		||||
 | 
			
		||||
        if (Number.isNaN(energy) || Number.isNaN(efficiency)) {
 | 
			
		||||
          this.$message.warn('Format is invalid.')
 | 
			
		||||
          return
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (energy <= this.ECutAnalysis_Low || energy >= this.G_energy_span) {
 | 
			
		||||
          this.$message.warn('Energy is out of analysis range.')
 | 
			
		||||
          return
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        const [currSelectedIndex] = this.selectedRowKeys
 | 
			
		||||
 | 
			
		||||
        this.list[currSelectedIndex].energy = energy
 | 
			
		||||
        this.list[currSelectedIndex].efficiency = efficiency
 | 
			
		||||
 | 
			
		||||
        this.uncert[currSelectedIndex] = 0
 | 
			
		||||
 | 
			
		||||
        this.recalculate()
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    // 删除
 | 
			
		||||
    handleDelete() {
 | 
			
		||||
      if (this.selectedRowKeys.length) {
 | 
			
		||||
        const [currSelectedIndex] = this.selectedRowKeys
 | 
			
		||||
 | 
			
		||||
        this.list.splice(currSelectedIndex, 1)
 | 
			
		||||
        this.uncert.splice(currSelectedIndex, 1)
 | 
			
		||||
        this.generateTableId()
 | 
			
		||||
        if (this.list.length) {
 | 
			
		||||
          const selectedKey = this.selectedRowKeys[0]
 | 
			
		||||
          if (selectedKey > this.list.length - 1) {
 | 
			
		||||
            this.selectedRowKeys[0] = selectedKey - 1
 | 
			
		||||
          }
 | 
			
		||||
        } else {
 | 
			
		||||
          this.selectedRowKeys = []
 | 
			
		||||
        }
 | 
			
		||||
        this.recalculate()
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    // 重新计算
 | 
			
		||||
    async recalculate() {
 | 
			
		||||
      try {
 | 
			
		||||
        this.isLoading = true
 | 
			
		||||
        const { sampleId, inputFileName: fileName } = this.sampleData
 | 
			
		||||
        const { success, result, message } = await postAction('/gamma/changeDataEfficiency', {
 | 
			
		||||
          sampleId,
 | 
			
		||||
          fileName,
 | 
			
		||||
          m_vCurEnergy: this.list.map(item => item.energy),
 | 
			
		||||
          m_vCurEffi: this.list.map(item => item.efficiency),
 | 
			
		||||
          m_vCurUncert: this.uncert,
 | 
			
		||||
          m_curParam: this.param,
 | 
			
		||||
          funcId: this.funcId
 | 
			
		||||
        })
 | 
			
		||||
        if (success) {
 | 
			
		||||
          this.handleResult(result)
 | 
			
		||||
        } else {
 | 
			
		||||
          this.$message.error(message)
 | 
			
		||||
        }
 | 
			
		||||
      } catch (error) {
 | 
			
		||||
        console.error(error)
 | 
			
		||||
      } finally {
 | 
			
		||||
        this.isLoading = false
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    // 应用
 | 
			
		||||
    async handleApply() {
 | 
			
		||||
      try {
 | 
			
		||||
        let curCalName = this.currSelectedDataSource
 | 
			
		||||
        // 如果沒选中以Input开头的,也就是选中了PHD之类的
 | 
			
		||||
        if (!curCalName.includes('Input')) {
 | 
			
		||||
          curCalName = `Input ${this.dataSourceList.filter(item => item.includes('Input')).length + 1}`
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        const { sampleId, inputFileName: fileName } = this.sampleData
 | 
			
		||||
        const { success, result, message } = await postAction('/gamma/applyDataEfficiency', {
 | 
			
		||||
          m_vCurEnergy: this.list.map(item => item.energy),
 | 
			
		||||
          m_vCurEffi: this.list.map(item => item.efficiency),
 | 
			
		||||
          m_vCurUncert: this.uncert,
 | 
			
		||||
          m_curParam: this.param,
 | 
			
		||||
          curCalName,
 | 
			
		||||
          sampleId,
 | 
			
		||||
          fileName
 | 
			
		||||
        })
 | 
			
		||||
        if (success) {
 | 
			
		||||
          this.handleDataSourceClick(curCalName)
 | 
			
		||||
        } else {
 | 
			
		||||
          this.$message.error(message)
 | 
			
		||||
        }
 | 
			
		||||
      } catch (error) {
 | 
			
		||||
        console.error(error)
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    // 右侧DataSource中的选项点击
 | 
			
		||||
    handleDataSourceClick(item) {
 | 
			
		||||
      this.currSelectedDataSource = item
 | 
			
		||||
      this.getData(item)
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    handleSetToCurrent() {
 | 
			
		||||
      this.appliedDataSource = this.currSelectedDataSource
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
</script>
 | 
			
		||||
 | 
			
		||||
<style lang="less" scoped>
 | 
			
		||||
.efficiency-calibration {
 | 
			
		||||
.energy-calibration {
 | 
			
		||||
  display: flex;
 | 
			
		||||
  margin-top: 5px;
 | 
			
		||||
 | 
			
		||||
  .left {
 | 
			
		||||
    flex: 1;
 | 
			
		||||
| 
						 | 
				
			
			@ -286,10 +583,11 @@ export default {
 | 
			
		|||
    }
 | 
			
		||||
 | 
			
		||||
    .equation {
 | 
			
		||||
      height: 32px;
 | 
			
		||||
      line-height: 32px;
 | 
			
		||||
      text-align: center;
 | 
			
		||||
      height: 40px;
 | 
			
		||||
      background-color: #1b5465;
 | 
			
		||||
      display: flex;
 | 
			
		||||
      justify-content: center;
 | 
			
		||||
      align-items: center;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    .curve {
 | 
			
		||||
| 
						 | 
				
			
			@ -302,16 +600,21 @@ export default {
 | 
			
		|||
    margin-left: 20px;
 | 
			
		||||
 | 
			
		||||
    .data-source {
 | 
			
		||||
      .title {
 | 
			
		||||
      .content {
 | 
			
		||||
        height: 330px;
 | 
			
		||||
        background-color: #275466;
 | 
			
		||||
        overflow: auto;
 | 
			
		||||
 | 
			
		||||
        .item {
 | 
			
		||||
          height: 32px;
 | 
			
		||||
          line-height: 32px;
 | 
			
		||||
        background-color: #296d81;
 | 
			
		||||
          padding: 0 5px;
 | 
			
		||||
      }
 | 
			
		||||
          cursor: pointer;
 | 
			
		||||
 | 
			
		||||
      .content {
 | 
			
		||||
        height: 300px;
 | 
			
		||||
        background-color: #275466;
 | 
			
		||||
          &.active {
 | 
			
		||||
            background-color: #296d81;
 | 
			
		||||
          }
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      .footer {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -212,25 +212,33 @@ export default {
 | 
			
		|||
      appliedDataSource: '',
 | 
			
		||||
      opts: {
 | 
			
		||||
        notMerge: true
 | 
			
		||||
      }
 | 
			
		||||
      },
 | 
			
		||||
 | 
			
		||||
      rg_high: -1,
 | 
			
		||||
      rg_low: -1
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  methods: {
 | 
			
		||||
    async getData() {
 | 
			
		||||
    async getData(currentText) {
 | 
			
		||||
      try {
 | 
			
		||||
        this.isLoading = true
 | 
			
		||||
        const { sampleId, inputFileName: fileName } = this.sampleData
 | 
			
		||||
        const { success, result, message } = await getAction('/gamma/energyCalibration', {
 | 
			
		||||
          sampleId,
 | 
			
		||||
          fileName
 | 
			
		||||
          fileName,
 | 
			
		||||
          currentText
 | 
			
		||||
        })
 | 
			
		||||
        this.isLoading = false
 | 
			
		||||
        if (success) {
 | 
			
		||||
          console.log('%c [  ]-220', 'font-size:13px; background:pink; color:#bf2c9f;', result)
 | 
			
		||||
          const { list_dataSource } = result
 | 
			
		||||
          const { list_dataSource, rg_high, rg_low } = result
 | 
			
		||||
          this.dataSourceList = list_dataSource
 | 
			
		||||
          this.currSelectedDataSource = list_dataSource[0]
 | 
			
		||||
          this.appliedDataSource = list_dataSource[0]
 | 
			
		||||
          if (!currentText) {
 | 
			
		||||
            this.currSelectedDataSource = list_dataSource[list_dataSource.length - 1]
 | 
			
		||||
            this.appliedDataSource = list_dataSource[list_dataSource.length - 1]
 | 
			
		||||
          }
 | 
			
		||||
 | 
			
		||||
          this.rg_high = rg_high
 | 
			
		||||
          this.rg_low = rg_low
 | 
			
		||||
 | 
			
		||||
          this.handleResult(result)
 | 
			
		||||
        } else {
 | 
			
		||||
| 
						 | 
				
			
			@ -306,7 +314,7 @@ export default {
 | 
			
		|||
        return
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      if (centroid <= 100 || centroid >= 16342) {
 | 
			
		||||
      if (centroid <= this.rg_low || centroid >= this.rg_high) {
 | 
			
		||||
        this.$message.warn('Centroid must be in the range of analysis!')
 | 
			
		||||
        return
 | 
			
		||||
      }
 | 
			
		||||
| 
						 | 
				
			
			@ -354,7 +362,7 @@ export default {
 | 
			
		|||
          return
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (centroid <= 100 || centroid >= 16342) {
 | 
			
		||||
        if (centroid <= this.rg_low || centroid >= this.rg_high) {
 | 
			
		||||
          this.$message.warn('Centroid must be in the range of analysis!')
 | 
			
		||||
          return
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			@ -435,7 +443,7 @@ export default {
 | 
			
		|||
          fileName
 | 
			
		||||
        })
 | 
			
		||||
        if (success) {
 | 
			
		||||
          this.dataSourceList.push(curCalName)
 | 
			
		||||
          this.handleDataSourceClick(curCalName)
 | 
			
		||||
        } else {
 | 
			
		||||
          this.$message.error(message)
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			@ -447,6 +455,7 @@ export default {
 | 
			
		|||
    // 右侧DataSource中的选项点击
 | 
			
		||||
    handleDataSourceClick(item) {
 | 
			
		||||
      this.currSelectedDataSource = item
 | 
			
		||||
      this.getData(item)
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    handleSetToCurrent() {
 | 
			
		||||
| 
						 | 
				
			
			@ -459,6 +468,7 @@ export default {
 | 
			
		|||
<style lang="less" scoped>
 | 
			
		||||
.energy-calibration {
 | 
			
		||||
  display: flex;
 | 
			
		||||
  margin-top: 5px;
 | 
			
		||||
 | 
			
		||||
  .left {
 | 
			
		||||
    flex: 1;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -290,6 +290,7 @@ export default {
 | 
			
		|||
.nuclide-library {
 | 
			
		||||
  display: flex;
 | 
			
		||||
  gap: 20px;
 | 
			
		||||
  margin-top: 5px;
 | 
			
		||||
 | 
			
		||||
  &-list {
 | 
			
		||||
    padding: 5px;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,6 +1,7 @@
 | 
			
		|||
<template>
 | 
			
		||||
  <custom-modal v-model="visible" :width="1280" title="Resolution Calibration" :footer="null">
 | 
			
		||||
    <div class="resolution-calibration">
 | 
			
		||||
  <custom-modal v-model="visible" :width="1280" title="Resolution Calibration" :footer="null" destroy-on-close>
 | 
			
		||||
    <a-spin :spinning="isLoading">
 | 
			
		||||
      <div class="energy-calibration">
 | 
			
		||||
        <div class="left">
 | 
			
		||||
          <!-- Calibration Data -->
 | 
			
		||||
          <title-over-border title="Calibration Data">
 | 
			
		||||
| 
						 | 
				
			
			@ -20,30 +21,34 @@
 | 
			
		|||
                  }
 | 
			
		||||
                }"
 | 
			
		||||
              >
 | 
			
		||||
              <a-form-model-item label="Energy  ">
 | 
			
		||||
                <a-input></a-input>
 | 
			
		||||
                <a-form-model-item label="Energy">
 | 
			
		||||
                  <a-input type="number" v-model="model.energy"></a-input>
 | 
			
		||||
                </a-form-model-item>
 | 
			
		||||
                <a-form-model-item label="FWHM">
 | 
			
		||||
                <a-input></a-input>
 | 
			
		||||
                  <a-input type="number" v-model="model.fwhm"></a-input>
 | 
			
		||||
                </a-form-model-item>
 | 
			
		||||
                <a-form-model-item :label="' '">
 | 
			
		||||
                <a-button type="primary">Insert</a-button>
 | 
			
		||||
                  <a-button type="primary" @click="handleInsert">Insert</a-button>
 | 
			
		||||
                </a-form-model-item>
 | 
			
		||||
                <a-form-model-item :label="' '">
 | 
			
		||||
                <a-button type="primary">Modify</a-button>
 | 
			
		||||
                  <a-button type="primary" @click="handleModify">Modify</a-button>
 | 
			
		||||
                </a-form-model-item>
 | 
			
		||||
                <a-form-model-item :label="' '">
 | 
			
		||||
                <a-button type="primary">Delete</a-button>
 | 
			
		||||
                  <a-button type="primary" @click="handleDelete">Delete</a-button>
 | 
			
		||||
                </a-form-model-item>
 | 
			
		||||
              </a-form-model>
 | 
			
		||||
              <!-- 表格 -->
 | 
			
		||||
            <a-table
 | 
			
		||||
              <custom-table
 | 
			
		||||
                :columns="columns"
 | 
			
		||||
              :dataSource="list"
 | 
			
		||||
                :list="list"
 | 
			
		||||
                :pagination="false"
 | 
			
		||||
                size="small"
 | 
			
		||||
                :class="list.length ? 'has-data' : ''"
 | 
			
		||||
                :scroll="{ y: 182 }"
 | 
			
		||||
            ></a-table>
 | 
			
		||||
                :selectedRowKeys.sync="selectedRowKeys"
 | 
			
		||||
                :canDeselect="false"
 | 
			
		||||
                @rowClick="handleRowClick"
 | 
			
		||||
              ></custom-table>
 | 
			
		||||
              <!-- 表格结束 -->
 | 
			
		||||
              <div class="operators">
 | 
			
		||||
                <div>
 | 
			
		||||
| 
						 | 
				
			
			@ -51,39 +56,45 @@
 | 
			
		|||
                  <a-button type="primary">Save</a-button>
 | 
			
		||||
                </div>
 | 
			
		||||
                <div>
 | 
			
		||||
                <a-button type="primary">Apply</a-button>
 | 
			
		||||
                  <a-button type="primary" @click="handleApply">Apply</a-button>
 | 
			
		||||
                </div>
 | 
			
		||||
              </div>
 | 
			
		||||
            </div>
 | 
			
		||||
          </title-over-border>
 | 
			
		||||
          <!-- Equation -->
 | 
			
		||||
          <title-over-border class="mt-20" title="Equation">
 | 
			
		||||
          <div class="equation">
 | 
			
		||||
            FWHM = (0.514363 + E * 0/00281408)<sup>1/2</sup>
 | 
			
		||||
          </div>
 | 
			
		||||
            <div class="equation" v-html="equation"></div>
 | 
			
		||||
          </title-over-border>
 | 
			
		||||
          <!-- curve -->
 | 
			
		||||
          <title-over-border class="mt-20" title="curve">
 | 
			
		||||
            <div class="curve">
 | 
			
		||||
            <custom-chart :option="option" />
 | 
			
		||||
              <custom-chart :option="option" :opts="opts" />
 | 
			
		||||
            </div>
 | 
			
		||||
          </title-over-border>
 | 
			
		||||
        </div>
 | 
			
		||||
        <div class="right">
 | 
			
		||||
          <title-over-border title="Data Source" style="height: 100%">
 | 
			
		||||
            <div class="data-source">
 | 
			
		||||
            <div class="data-source-main">
 | 
			
		||||
              <div class="title">PHD</div>
 | 
			
		||||
              <div class="content"></div>
 | 
			
		||||
              <div class="content">
 | 
			
		||||
                <div
 | 
			
		||||
                  class="item"
 | 
			
		||||
                  :class="item == currSelectedDataSource ? 'active' : ''"
 | 
			
		||||
                  v-for="(item, index) in dataSourceList"
 | 
			
		||||
                  :key="index"
 | 
			
		||||
                  @click="handleDataSourceClick(item)"
 | 
			
		||||
                >
 | 
			
		||||
                  {{ item }}
 | 
			
		||||
                </div>
 | 
			
		||||
              </div>
 | 
			
		||||
              <div class="footer mt-20">
 | 
			
		||||
              <a-button type="primary">Set to Current</a-button>
 | 
			
		||||
              <div class="mt-20">CalResUpdate</div>
 | 
			
		||||
                <a-button type="primary" @click="handleSetToCurrent">Set to Current</a-button>
 | 
			
		||||
                <div class="mt-20">{{ appliedDataSource }}</div>
 | 
			
		||||
              </div>
 | 
			
		||||
            </div>
 | 
			
		||||
          </title-over-border>
 | 
			
		||||
        </div>
 | 
			
		||||
      </div>
 | 
			
		||||
    </a-spin>
 | 
			
		||||
  </custom-modal>
 | 
			
		||||
</template>
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -91,6 +102,10 @@
 | 
			
		|||
import ModalMixin from '@/mixins/ModalMixin'
 | 
			
		||||
import TitleOverBorder from '../TitleOverBorder.vue'
 | 
			
		||||
import CustomChart from '@/components/CustomChart/index.vue'
 | 
			
		||||
import { getAction, postAction } from '@/api/manage'
 | 
			
		||||
import { cloneDeep } from 'lodash'
 | 
			
		||||
import { buildLineSeries } from '@/utils/chartHelper'
 | 
			
		||||
import SampleDataMixin from '../../SampleDataMixin'
 | 
			
		||||
 | 
			
		||||
const columns = [
 | 
			
		||||
  {
 | 
			
		||||
| 
						 | 
				
			
			@ -128,9 +143,20 @@ const initialOption = {
 | 
			
		|||
    right: 10,
 | 
			
		||||
    bottom: 0
 | 
			
		||||
  },
 | 
			
		||||
  tooltip: {
 | 
			
		||||
    trigger: 'axis',
 | 
			
		||||
    formatter: params => {
 | 
			
		||||
      const [x, y] = params[0].value
 | 
			
		||||
      const energy = parseInt(x)
 | 
			
		||||
      const fwhm = y.toFixed(3)
 | 
			
		||||
      return `<div class="channel">Energy: ${energy}</div>
 | 
			
		||||
              <div class="energy">Fwhm: ${fwhm}</div>`
 | 
			
		||||
    },
 | 
			
		||||
    className: 'figure-chart-option-tooltip'
 | 
			
		||||
  },
 | 
			
		||||
  xAxis: {
 | 
			
		||||
    min: 42,
 | 
			
		||||
    max: 2740,
 | 
			
		||||
    min: 1,
 | 
			
		||||
    max: 'dataMax',
 | 
			
		||||
    axisLabel: {
 | 
			
		||||
      color: '#fff'
 | 
			
		||||
    },
 | 
			
		||||
| 
						 | 
				
			
			@ -166,48 +192,283 @@ const initialOption = {
 | 
			
		|||
      fontSize: 14
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  series: [
 | 
			
		||||
    {
 | 
			
		||||
      type: 'line',
 | 
			
		||||
      symbol: 'square',
 | 
			
		||||
      itemStyle: {
 | 
			
		||||
        color: '#FF0000' // 设置符号的颜色
 | 
			
		||||
      },
 | 
			
		||||
      lineStyle: {
 | 
			
		||||
        color: '#C2CC11' // 设置折线的颜色
 | 
			
		||||
      },
 | 
			
		||||
      data: [
 | 
			
		||||
        [42, 0],
 | 
			
		||||
        [100, 0.2],
 | 
			
		||||
        [978, 0.1]
 | 
			
		||||
      ]
 | 
			
		||||
    }
 | 
			
		||||
  ]
 | 
			
		||||
  series: []
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export default {
 | 
			
		||||
  components: { TitleOverBorder, CustomChart },
 | 
			
		||||
  mixins: [ModalMixin],
 | 
			
		||||
  mixins: [ModalMixin, SampleDataMixin],
 | 
			
		||||
  data() {
 | 
			
		||||
    this.columns = columns
 | 
			
		||||
    return {
 | 
			
		||||
      list: [
 | 
			
		||||
        {
 | 
			
		||||
          energy: 'energy',
 | 
			
		||||
          fwhm: 'fwhm',
 | 
			
		||||
          fit: 'fit',
 | 
			
		||||
          delta: 'delta'
 | 
			
		||||
      isLoading: false,
 | 
			
		||||
      equation: '',
 | 
			
		||||
      dataSourceList: [],
 | 
			
		||||
      list: [],
 | 
			
		||||
      option: cloneDeep(initialOption),
 | 
			
		||||
      selectedRowKeys: [],
 | 
			
		||||
      model: {},
 | 
			
		||||
      currSelectedDataSource: '',
 | 
			
		||||
      appliedDataSource: '',
 | 
			
		||||
      opts: {
 | 
			
		||||
        notMerge: true
 | 
			
		||||
      },
 | 
			
		||||
      ECutAnalysis_Low: -1,
 | 
			
		||||
      G_energy_span: -1
 | 
			
		||||
    }
 | 
			
		||||
      ],
 | 
			
		||||
      option: initialOption
 | 
			
		||||
  },
 | 
			
		||||
  methods: {
 | 
			
		||||
    async getData(currentText) {
 | 
			
		||||
      try {
 | 
			
		||||
        this.isLoading = true
 | 
			
		||||
        const { sampleId, inputFileName: fileName } = this.sampleData
 | 
			
		||||
        const { success, result, message } = await getAction('/gamma/resolutionCalibration', {
 | 
			
		||||
          sampleId,
 | 
			
		||||
          fileName,
 | 
			
		||||
          currentText
 | 
			
		||||
        })
 | 
			
		||||
        this.isLoading = false
 | 
			
		||||
        if (success) {
 | 
			
		||||
          console.log('%c [  ]-220', 'font-size:13px; background:pink; color:#bf2c9f;', result)
 | 
			
		||||
          const { list_dataSource, ECutAnalysis_Low, G_energy_span } = result
 | 
			
		||||
          this.dataSourceList = list_dataSource
 | 
			
		||||
          if (!currentText) {
 | 
			
		||||
            this.currSelectedDataSource = list_dataSource[list_dataSource.length - 1]
 | 
			
		||||
            this.appliedDataSource = list_dataSource[list_dataSource.length - 1]
 | 
			
		||||
          }
 | 
			
		||||
 | 
			
		||||
          this.ECutAnalysis_Low = ECutAnalysis_Low
 | 
			
		||||
          this.G_energy_span = G_energy_span
 | 
			
		||||
 | 
			
		||||
          this.handleResult(result)
 | 
			
		||||
        } else {
 | 
			
		||||
          this.$message.error(message)
 | 
			
		||||
        }
 | 
			
		||||
      } catch (error) {
 | 
			
		||||
        console.error(error)
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    handleResult(result) {
 | 
			
		||||
      const { AllData, equation, param, table, uncert } = result
 | 
			
		||||
      // 有数据
 | 
			
		||||
      if (AllData) {
 | 
			
		||||
        const [linePoint, scatterPoint] = AllData
 | 
			
		||||
        this.equation = equation
 | 
			
		||||
        this.param = param
 | 
			
		||||
        this.uncert = uncert
 | 
			
		||||
 | 
			
		||||
        this.list = table
 | 
			
		||||
        this.generateTableId()
 | 
			
		||||
 | 
			
		||||
        const series = []
 | 
			
		||||
        series.push(
 | 
			
		||||
          buildLineSeries(
 | 
			
		||||
            'LineSeries',
 | 
			
		||||
            linePoint.pointlist.map(({ x, y }) => [x, y]),
 | 
			
		||||
            `rgb(${linePoint.color})`
 | 
			
		||||
          )
 | 
			
		||||
        )
 | 
			
		||||
        series.push({
 | 
			
		||||
          type: 'scatter',
 | 
			
		||||
          data: scatterPoint.pointlist.map(({ x, y }) => {
 | 
			
		||||
            return {
 | 
			
		||||
              value: [x, y],
 | 
			
		||||
              itemStyle: {
 | 
			
		||||
                color: scatterPoint.color,
 | 
			
		||||
                borderWidth: 0
 | 
			
		||||
              }
 | 
			
		||||
            }
 | 
			
		||||
          }),
 | 
			
		||||
          emphasis: {
 | 
			
		||||
            disabled: true
 | 
			
		||||
          },
 | 
			
		||||
          animation: false,
 | 
			
		||||
          zlevel: 20
 | 
			
		||||
        })
 | 
			
		||||
        this.option.series = series
 | 
			
		||||
      }
 | 
			
		||||
      // 没数据
 | 
			
		||||
      else {
 | 
			
		||||
        this.option.series = []
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    beforeModalOpen() {
 | 
			
		||||
      this.selectedRowKeys = []
 | 
			
		||||
      this.getData()
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    // 表格单行点击
 | 
			
		||||
    handleRowClick(row) {
 | 
			
		||||
      this.model = cloneDeep(row)
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    // 插入
 | 
			
		||||
    handleInsert() {
 | 
			
		||||
      const energy = parseFloat(this.model.energy)
 | 
			
		||||
      const fwhm = parseFloat(this.model.fwhm)
 | 
			
		||||
 | 
			
		||||
      if (Number.isNaN(energy) || Number.isNaN(fwhm)) {
 | 
			
		||||
        this.$message.warn('Format is invalid.')
 | 
			
		||||
        return
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      if (energy <= this.ECutAnalysis_Low || energy >= this.G_energy_span) {
 | 
			
		||||
        this.$message.warn('Energy is out of analysis range.')
 | 
			
		||||
        return
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      let i,
 | 
			
		||||
        num = this.list.length
 | 
			
		||||
      for (i = 0; i < num; ++i) {
 | 
			
		||||
        const currEnergy = this.list[i].energy
 | 
			
		||||
        if (Math.abs(currEnergy - energy) < 0.001) {
 | 
			
		||||
          this.$message.warn('The centroid has already existed!')
 | 
			
		||||
          return
 | 
			
		||||
        } else if (currEnergy > energy) {
 | 
			
		||||
          break
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      this.list.splice(i, 0, {
 | 
			
		||||
        energy: energy,
 | 
			
		||||
        fwhm
 | 
			
		||||
      })
 | 
			
		||||
 | 
			
		||||
      this.uncert.splice(i, 0, 0.5)
 | 
			
		||||
 | 
			
		||||
      this.selectedRowKeys = [i]
 | 
			
		||||
      this.generateTableId()
 | 
			
		||||
 | 
			
		||||
      this.recalculate()
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    // 生成table中数据的id,用以选中
 | 
			
		||||
    generateTableId() {
 | 
			
		||||
      this.list.forEach((item, index) => {
 | 
			
		||||
        item.id = index
 | 
			
		||||
      })
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    // 修改
 | 
			
		||||
    handleModify() {
 | 
			
		||||
      if (this.selectedRowKeys.length) {
 | 
			
		||||
        const energy = parseFloat(this.model.energy)
 | 
			
		||||
        const fwhm = parseFloat(this.model.fwhm)
 | 
			
		||||
 | 
			
		||||
        if (Number.isNaN(energy) || Number.isNaN(fwhm)) {
 | 
			
		||||
          this.$message.warn('Format is invalid.')
 | 
			
		||||
          return
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (energy <= this.ECutAnalysis_Low || energy >= this.G_energy_span) {
 | 
			
		||||
          this.$message.warn('Energy is out of analysis range.')
 | 
			
		||||
          return
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        const [currSelectedIndex] = this.selectedRowKeys
 | 
			
		||||
 | 
			
		||||
        this.list[currSelectedIndex].energy = energy
 | 
			
		||||
        this.list[currSelectedIndex].fwhm = fwhm
 | 
			
		||||
 | 
			
		||||
        this.uncert[currSelectedIndex] = 0
 | 
			
		||||
 | 
			
		||||
        this.recalculate()
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    // 删除
 | 
			
		||||
    handleDelete() {
 | 
			
		||||
      if (this.selectedRowKeys.length) {
 | 
			
		||||
        const [currSelectedIndex] = this.selectedRowKeys
 | 
			
		||||
 | 
			
		||||
        this.list.splice(currSelectedIndex, 1)
 | 
			
		||||
        this.uncert.splice(currSelectedIndex, 1)
 | 
			
		||||
        this.generateTableId()
 | 
			
		||||
        if (this.list.length) {
 | 
			
		||||
          const selectedKey = this.selectedRowKeys[0]
 | 
			
		||||
          if (selectedKey > this.list.length - 1) {
 | 
			
		||||
            this.selectedRowKeys[0] = selectedKey - 1
 | 
			
		||||
          }
 | 
			
		||||
        } else {
 | 
			
		||||
          this.selectedRowKeys = []
 | 
			
		||||
        }
 | 
			
		||||
        this.recalculate()
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    // 重新计算
 | 
			
		||||
    async recalculate() {
 | 
			
		||||
      try {
 | 
			
		||||
        this.isLoading = true
 | 
			
		||||
        const { sampleId, inputFileName: fileName } = this.sampleData
 | 
			
		||||
        const { success, result, message } = await postAction('/gamma/changeDataResolution', {
 | 
			
		||||
          sampleId,
 | 
			
		||||
          fileName,
 | 
			
		||||
          m_vCurEnergy: this.list.map(item => item.energy),
 | 
			
		||||
          m_vCurReso: this.list.map(item => item.fwhm),
 | 
			
		||||
          m_vCurUncert: this.uncert,
 | 
			
		||||
          m_curParam: this.param
 | 
			
		||||
        })
 | 
			
		||||
        if (success) {
 | 
			
		||||
          this.handleResult(result)
 | 
			
		||||
        } else {
 | 
			
		||||
          this.$message.error(message)
 | 
			
		||||
        }
 | 
			
		||||
      } catch (error) {
 | 
			
		||||
        console.error(error)
 | 
			
		||||
      } finally {
 | 
			
		||||
        this.isLoading = false
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    // 应用
 | 
			
		||||
    async handleApply() {
 | 
			
		||||
      try {
 | 
			
		||||
        let curCalName = this.currSelectedDataSource
 | 
			
		||||
        // 如果沒选中以Input开头的,也就是选中了PHD之类的
 | 
			
		||||
        if (!curCalName.includes('Input')) {
 | 
			
		||||
          curCalName = `Input ${this.dataSourceList.filter(item => item.includes('Input')).length + 1}`
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        const { sampleId, inputFileName: fileName } = this.sampleData
 | 
			
		||||
        const { success, result, message } = await postAction('/gamma/applyDataResolution', {
 | 
			
		||||
          m_vCurEnergy: this.list.map(item => item.energy),
 | 
			
		||||
          m_vCurReso: this.list.map(item => item.fwhm),
 | 
			
		||||
          m_vCurUncert: this.uncert,
 | 
			
		||||
          m_curParam: this.param,
 | 
			
		||||
          curCalName,
 | 
			
		||||
          sampleId,
 | 
			
		||||
          fileName
 | 
			
		||||
        })
 | 
			
		||||
        if (success) {
 | 
			
		||||
          this.handleDataSourceClick(curCalName)
 | 
			
		||||
        } else {
 | 
			
		||||
          this.$message.error(message)
 | 
			
		||||
        }
 | 
			
		||||
      } catch (error) {
 | 
			
		||||
        console.error(error)
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    // 右侧DataSource中的选项点击
 | 
			
		||||
    handleDataSourceClick(item) {
 | 
			
		||||
      this.currSelectedDataSource = item
 | 
			
		||||
      this.getData(item)
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    handleSetToCurrent() {
 | 
			
		||||
      this.appliedDataSource = this.currSelectedDataSource
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
</script>
 | 
			
		||||
 | 
			
		||||
<style lang="less" scoped>
 | 
			
		||||
.resolution-calibration {
 | 
			
		||||
.energy-calibration {
 | 
			
		||||
  display: flex;
 | 
			
		||||
  margin-top: 5px;
 | 
			
		||||
 | 
			
		||||
  .left {
 | 
			
		||||
    flex: 1;
 | 
			
		||||
| 
						 | 
				
			
			@ -281,10 +542,11 @@ export default {
 | 
			
		|||
    }
 | 
			
		||||
 | 
			
		||||
    .equation {
 | 
			
		||||
      height: 32px;
 | 
			
		||||
      line-height: 32px;
 | 
			
		||||
      text-align: center;
 | 
			
		||||
      height: 40px;
 | 
			
		||||
      background-color: #1b5465;
 | 
			
		||||
      display: flex;
 | 
			
		||||
      justify-content: center;
 | 
			
		||||
      align-items: center;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    .curve {
 | 
			
		||||
| 
						 | 
				
			
			@ -297,16 +559,21 @@ export default {
 | 
			
		|||
    margin-left: 20px;
 | 
			
		||||
 | 
			
		||||
    .data-source {
 | 
			
		||||
      .title {
 | 
			
		||||
      .content {
 | 
			
		||||
        height: 330px;
 | 
			
		||||
        background-color: #275466;
 | 
			
		||||
        overflow: auto;
 | 
			
		||||
 | 
			
		||||
        .item {
 | 
			
		||||
          height: 32px;
 | 
			
		||||
          line-height: 32px;
 | 
			
		||||
        background-color: #296d81;
 | 
			
		||||
          padding: 0 5px;
 | 
			
		||||
      }
 | 
			
		||||
          cursor: pointer;
 | 
			
		||||
 | 
			
		||||
      .content {
 | 
			
		||||
        height: 300px;
 | 
			
		||||
        background-color: #275466;
 | 
			
		||||
          &.active {
 | 
			
		||||
            background-color: #296d81;
 | 
			
		||||
          }
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      .footer {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user