fix: 优化、修改某些代码
This commit is contained in:
		
							parent
							
								
									bdaf65ca99
								
							
						
					
					
						commit
						0c06c5af79
					
				| 
						 | 
				
			
			@ -133,6 +133,7 @@ import BetaGammaQcFlags from './components/SubOperators/BetaGammaQcFlags.vue'
 | 
			
		|||
import PopOverWithIcon from './components/SubOperators/PopOverWithIcon.vue'
 | 
			
		||||
import Spectra from './components/SubOperators/Spectra.vue'
 | 
			
		||||
import CustomSelect from '@/components/CustomSelect/index.vue'
 | 
			
		||||
import axios from 'axios'
 | 
			
		||||
 | 
			
		||||
const StatisticsType = {
 | 
			
		||||
  'Collection Time': 'Colloc_Time',
 | 
			
		||||
| 
						 | 
				
			
			@ -219,6 +220,9 @@ export default {
 | 
			
		|||
      currSample: {},
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  destroyed() {
 | 
			
		||||
    this.cancelLastRequest()
 | 
			
		||||
  },
 | 
			
		||||
  methods: {
 | 
			
		||||
    handleGetFlag(val, obj) {
 | 
			
		||||
      this.resultDisplay.forEach((item) => {
 | 
			
		||||
| 
						 | 
				
			
			@ -234,10 +238,16 @@ export default {
 | 
			
		|||
      const { dbName, sampleId } = this.sample
 | 
			
		||||
      try {
 | 
			
		||||
        this.isLoading = true
 | 
			
		||||
        const { success, result, message } = await getAction('/spectrumAnalysis/getDBSpectrumChart', {
 | 
			
		||||
          dbName,
 | 
			
		||||
          sampleId,
 | 
			
		||||
        })
 | 
			
		||||
        this.cancelLastRequest()
 | 
			
		||||
        const cancelToken = this.createCancelToken()
 | 
			
		||||
        const { success, result, message } = await getAction(
 | 
			
		||||
          '/spectrumAnalysis/getDBSpectrumChart',
 | 
			
		||||
          {
 | 
			
		||||
            dbName,
 | 
			
		||||
            sampleId,
 | 
			
		||||
          },
 | 
			
		||||
          cancelToken
 | 
			
		||||
        )
 | 
			
		||||
        if (success) {
 | 
			
		||||
          this.sampleDetail = result
 | 
			
		||||
          this.changeChartByType('sample')
 | 
			
		||||
| 
						 | 
				
			
			@ -264,7 +274,13 @@ export default {
 | 
			
		|||
      }
 | 
			
		||||
      try {
 | 
			
		||||
        this.isLoading = true
 | 
			
		||||
        const { success, result, message } = await getAction('/spectrumAnalysis/getFileSpectrumChart', params)
 | 
			
		||||
        this.cancelLastRequest()
 | 
			
		||||
        const cancelToken = this.createCancelToken()
 | 
			
		||||
        const { success, result, message } = await getAction(
 | 
			
		||||
          '/spectrumAnalysis/getFileSpectrumChart',
 | 
			
		||||
          params,
 | 
			
		||||
          cancelToken
 | 
			
		||||
        )
 | 
			
		||||
        if (success) {
 | 
			
		||||
          this.sampleDetail = result
 | 
			
		||||
          this.changeChartByType('sample')
 | 
			
		||||
| 
						 | 
				
			
			@ -277,6 +293,19 @@ export default {
 | 
			
		|||
      }
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    cancelLastRequest() {
 | 
			
		||||
      if (this._cancelToken && typeof this._cancelToken == 'function') {
 | 
			
		||||
        this._cancelToken()
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    createCancelToken() {
 | 
			
		||||
      const cancelToken = new axios.CancelToken((c) => {
 | 
			
		||||
        this._cancelToken = c
 | 
			
		||||
      })
 | 
			
		||||
      return cancelToken
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    changeChartByType(val) {
 | 
			
		||||
      if (val === 'qc' && !this.sample.qcFileStatus) {
 | 
			
		||||
        this.$message.warning('No qc spectrum file!')
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -411,8 +411,7 @@ export default {
 | 
			
		|||
 | 
			
		||||
      // 改为不可刷选状态
 | 
			
		||||
      chart.dispatchAction({
 | 
			
		||||
        type: 'takeGlobalCursor',
 | 
			
		||||
        rushOption: false
 | 
			
		||||
        type: 'takeGlobalCursor'
 | 
			
		||||
      })
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,7 +3,7 @@
 | 
			
		|||
    <a-spin :spinning="isLoading">
 | 
			
		||||
      <pre>{{ content }}</pre>
 | 
			
		||||
    </a-spin>
 | 
			
		||||
    <div slot="custom-footer" style="text-align: center;">
 | 
			
		||||
    <div slot="custom-footer" style="text-align: center">
 | 
			
		||||
      <a-space :size="20">
 | 
			
		||||
        <a-button type="primary" @click="handleOk">Export</a-button>
 | 
			
		||||
        <a-button @click="visible = false">Cancel</a-button>
 | 
			
		||||
| 
						 | 
				
			
			@ -14,25 +14,25 @@
 | 
			
		|||
 | 
			
		||||
<script>
 | 
			
		||||
import ModalMixin from '@/mixins/ModalMixin'
 | 
			
		||||
import { getAction } from '../../../../api/manage'
 | 
			
		||||
import { saveAs } from 'file-saver';
 | 
			
		||||
import { getAction, postAction } from '../../../../api/manage'
 | 
			
		||||
import { saveAs } from 'file-saver'
 | 
			
		||||
import SampleDataMixin from '../../SampleDataMixin'
 | 
			
		||||
export default {
 | 
			
		||||
  mixins: [ModalMixin, SampleDataMixin],
 | 
			
		||||
  props: {
 | 
			
		||||
    type: {
 | 
			
		||||
      type: Number
 | 
			
		||||
      type: Number,
 | 
			
		||||
    },
 | 
			
		||||
    extraData: {
 | 
			
		||||
      type: Object,
 | 
			
		||||
      default: () => ({})
 | 
			
		||||
    }
 | 
			
		||||
      default: () => ({}),
 | 
			
		||||
    },
 | 
			
		||||
  },
 | 
			
		||||
  data() {
 | 
			
		||||
    return {
 | 
			
		||||
      content: '',
 | 
			
		||||
      isLoading: true,
 | 
			
		||||
      fileName: ''
 | 
			
		||||
      fileName: '',
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  methods: {
 | 
			
		||||
| 
						 | 
				
			
			@ -56,15 +56,22 @@ export default {
 | 
			
		|||
        this.content = ''
 | 
			
		||||
        this.isLoading = true
 | 
			
		||||
        const { sampleId, inputFileName: fileName } = this.sampleData
 | 
			
		||||
        const res = await getAction(url, {
 | 
			
		||||
        const method = this.type == 4? postAction : getAction
 | 
			
		||||
        const res = await method(url, {
 | 
			
		||||
          sampleId,
 | 
			
		||||
          fileName,
 | 
			
		||||
          ...this.extraData
 | 
			
		||||
          ...this.extraData,
 | 
			
		||||
        })
 | 
			
		||||
        if (res.success) {
 | 
			
		||||
          this.content = res.result
 | 
			
		||||
 | 
			
		||||
        if (typeof res == 'string') {
 | 
			
		||||
          this.content = res
 | 
			
		||||
        } else {
 | 
			
		||||
          this.content = ""
 | 
			
		||||
          const { success, result, message } = res
 | 
			
		||||
          if (success) {
 | 
			
		||||
            this.content = result
 | 
			
		||||
          } else {
 | 
			
		||||
            this.$message.error(message)
 | 
			
		||||
          }
 | 
			
		||||
        }
 | 
			
		||||
      } catch (error) {
 | 
			
		||||
        console.error(error)
 | 
			
		||||
| 
						 | 
				
			
			@ -77,9 +84,9 @@ export default {
 | 
			
		|||
      this.getContent()
 | 
			
		||||
    },
 | 
			
		||||
    handleOk() {
 | 
			
		||||
      this.fileName=""
 | 
			
		||||
      this.fileName = ''
 | 
			
		||||
      if (this.content) {
 | 
			
		||||
        let strData = new Blob([this.content], { type: 'text/plain;charset=utf-8' });
 | 
			
		||||
        let strData = new Blob([this.content], { type: 'text/plain;charset=utf-8' })
 | 
			
		||||
        // if (this.type == 1 || this.type == 3) {
 | 
			
		||||
        //   saveAs(strData, `${this.type == 1 ?'Gamma-':'Beta-'} ARR.txt`)
 | 
			
		||||
        // } else {
 | 
			
		||||
| 
						 | 
				
			
			@ -88,25 +95,25 @@ export default {
 | 
			
		|||
        let _this = this
 | 
			
		||||
        this.$confirm({
 | 
			
		||||
          title: 'Please enter file name',
 | 
			
		||||
          content:  h => <a-input v-model={_this.fileName} />,
 | 
			
		||||
          content: (h) => <a-input v-model={_this.fileName} />,
 | 
			
		||||
          okText: 'Cancle',
 | 
			
		||||
          cancelText: 'Save',
 | 
			
		||||
          okButtonProps: {style: {backgroundColor: "#b98326", color: "#fff", borderColor: "transparent"}},
 | 
			
		||||
          cancelButtonProps: {style: {color: "#fff", backgroundColor: "#31aab0", borderColor: "transparent"}},
 | 
			
		||||
          okButtonProps: { style: { backgroundColor: '#b98326', color: '#fff', borderColor: 'transparent' } },
 | 
			
		||||
          cancelButtonProps: { style: { color: '#fff', backgroundColor: '#31aab0', borderColor: 'transparent' } },
 | 
			
		||||
          onOk() {
 | 
			
		||||
            console.log('Cancel');
 | 
			
		||||
            console.log('Cancel')
 | 
			
		||||
          },
 | 
			
		||||
          onCancel() {
 | 
			
		||||
            if (_this.fileName) {
 | 
			
		||||
              saveAs(strData, `${_this.fileName}.txt`)
 | 
			
		||||
            }
 | 
			
		||||
          },
 | 
			
		||||
        });
 | 
			
		||||
        })
 | 
			
		||||
      } else {
 | 
			
		||||
        this.$message.warning("No data can be saved!")
 | 
			
		||||
        this.$message.warning('No data can be saved!')
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
    },
 | 
			
		||||
  },
 | 
			
		||||
}
 | 
			
		||||
</script>
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -451,6 +451,14 @@ export default {
 | 
			
		|||
  methods: {
 | 
			
		||||
    beforeModalOpen() {
 | 
			
		||||
      this.customToolTip.visible = false
 | 
			
		||||
      const gammaSeries = this.gammaSpectrumChartOption.series
 | 
			
		||||
      gammaSeries[0].data = []
 | 
			
		||||
      gammaSeries[1].data = []
 | 
			
		||||
 | 
			
		||||
      const betaSeries = this.betaSpectrumChartOption.series
 | 
			
		||||
      betaSeries[0].data = []
 | 
			
		||||
      betaSeries[1].data = []
 | 
			
		||||
      
 | 
			
		||||
      this.getDetail()
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -202,6 +202,8 @@ export default {
 | 
			
		|||
    this.$bus.$on('accept', this.handleAccept)
 | 
			
		||||
  },
 | 
			
		||||
  destroyed() {
 | 
			
		||||
    this.cancelLastRequest()
 | 
			
		||||
 | 
			
		||||
    this.$bus.$off('colorChange', this.handleColorChange)
 | 
			
		||||
    this.$bus.$off('gammaRefresh', this.handleRefresh)
 | 
			
		||||
    this.$bus.$off('accept', this.handleAccept)
 | 
			
		||||
| 
						 | 
				
			
			@ -219,8 +221,8 @@ export default {
 | 
			
		|||
        this.handleResetState()
 | 
			
		||||
 | 
			
		||||
        // const { success, result, message } = Response
 | 
			
		||||
 | 
			
		||||
        const cancelToken = this.cancelLastRequest()
 | 
			
		||||
        this.cancelLastRequest()
 | 
			
		||||
        const cancelToken = this.createCancelToken()
 | 
			
		||||
 | 
			
		||||
        const { success, result, message } = await getAction(
 | 
			
		||||
          '/gamma/gammaByDB',
 | 
			
		||||
| 
						 | 
				
			
			@ -247,7 +249,9 @@ export default {
 | 
			
		|||
        this.isLoading = true
 | 
			
		||||
        this.handleResetState()
 | 
			
		||||
        // const { success, result, message } = Response
 | 
			
		||||
        const cancelToken = this.cancelLastRequest()
 | 
			
		||||
 | 
			
		||||
        this.cancelLastRequest()
 | 
			
		||||
        const cancelToken = this.createCancelToken()
 | 
			
		||||
 | 
			
		||||
        const { success, result, message } = await getAction(
 | 
			
		||||
          '/gamma/gammaByFile',
 | 
			
		||||
| 
						 | 
				
			
			@ -271,10 +275,13 @@ export default {
 | 
			
		|||
      if (this._cancelToken && typeof this._cancelToken == 'function') {
 | 
			
		||||
        this._cancelToken()
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
      return new axios.CancelToken((c) => {
 | 
			
		||||
    createCancelToken() {
 | 
			
		||||
      const cancelToken = new axios.CancelToken((c) => {
 | 
			
		||||
        this._cancelToken = c
 | 
			
		||||
      })
 | 
			
		||||
      return cancelToken
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    dataProsess(result) {
 | 
			
		||||
| 
						 | 
				
			
			@ -1165,7 +1172,7 @@ export default {
 | 
			
		|||
 | 
			
		||||
    /**
 | 
			
		||||
     * 根据energy获取channel
 | 
			
		||||
     * @param {number} energy 
 | 
			
		||||
     * @param {number} energy
 | 
			
		||||
     */
 | 
			
		||||
    getChannelByEnergy(energy) {
 | 
			
		||||
      let channel = 0
 | 
			
		||||
| 
						 | 
				
			
			@ -1197,6 +1204,7 @@ export default {
 | 
			
		|||
      this.option.series = []
 | 
			
		||||
      this.option.xAxis.name = 'Channel'
 | 
			
		||||
      this.option.yAxis.type = 'value'
 | 
			
		||||
      this.thumbnailOption.yAxis.type = 'value'
 | 
			
		||||
 | 
			
		||||
      if (this.option.series.length) {
 | 
			
		||||
        const spectrumLineSeries = findSeriesByName(this.option.series, 'Spectrum')
 | 
			
		||||
| 
						 | 
				
			
			@ -1214,7 +1222,7 @@ export default {
 | 
			
		|||
 | 
			
		||||
    /**
 | 
			
		||||
     * 颜色改变
 | 
			
		||||
     * @param {*} colorConfig 
 | 
			
		||||
     * @param {*} colorConfig
 | 
			
		||||
     */
 | 
			
		||||
    handleColorChange(colorConfig) {
 | 
			
		||||
      // 如果还没加载完,加载新的
 | 
			
		||||
| 
						 | 
				
			
			@ -1267,8 +1275,8 @@ export default {
 | 
			
		|||
 | 
			
		||||
    /**
 | 
			
		||||
     * 根据series名修改颜色
 | 
			
		||||
     * @param {*} seriesName 
 | 
			
		||||
     * @param {*} color 
 | 
			
		||||
     * @param {*} seriesName
 | 
			
		||||
     * @param {*} color
 | 
			
		||||
     */
 | 
			
		||||
    changeColorBySeriesName(seriesName, color) {
 | 
			
		||||
      const series = findSeriesByName(this.option.series, seriesName)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user