violationPopup.js 2.05 KB
// packageEquity/pages/receptionDetail/components/violationPopup/violationPopup.js
import api from "~/utils/request/request.js";
Component({

  /**
   * 组件的属性列表
   */
  properties: {
    batchId:Number,
    show: {
      type: Boolean,
      value: false,
      observer(n) {
        this.setData({
          violationReason: '',
          wghsStatus: 2
        })
      }
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    radioList: [{
        text: '已违规',
        value: 2
      },
      {
        text: '未违规',
        value: 0
      },
    ],
    violationReason: '',
    wghsStatus: 2
  },

  /**
   * 组件的方法列表
   */
  methods: {
    async confirm() {
      if (this.submitStatus) return
      try {
        wx.$util.showLoading('提交中...')
        this.submitStatus = true
        const {
          violationReason,
          wghsStatus,
          batchId
        } = this.data, {
          data,
          code,
          message
        } = await api.post('dj.api.smartcarlife.recepiton.violationConfirmation', {
          batchId,
          wghsStatus,
          violationReason
        })
        if (code == 0) {
          if (data) {
            this.submitStatus = false
            wx.hideLoading()
            wx.showToast({
              title: '录音已确认完成',
              mask: true
            })
            setTimeout(() => {
              this.setData({
                show: false
              })
              wx.$router.back(page => {
                page.refreshListData && page.refreshListData()
              })
            }, 1500)
          } else throw message
        } else throw message
      } catch (error) {
        wx.hideLoading()
        wx.$util.showToast(error)
        this.submitStatus = false
      }
    },
    bindKeyInput(e) {
      let {
        value
      } = e.detail
      this.setData({
        violationReason: value
      })
    },
    change(e) {
      let {
        value
      } = e.currentTarget.dataset
      this.setData({
        wghsStatus: value
      })
    }
  }
})