<template>
<div>
  <el-radio-group v-model="model">
    <el-radio v-for="item in nodelist" :key="item.value" :label="item.value">{{item.label}}</el-radio>
  </el-radio-group>
  <p v-if="errShow" style="color: red">{{errMsg}}</p>
</div>
</template>
<script>
import Request from '~/utils/request'

export default {
  props: ['txSriNo'],
  data: function () {
    return {
      nodelist: [],
      model: '',
      errShow: false,
      errMsg: ''
    }
  },
  mounted: function () {
    console.log('mounted')
    this.getList()
  },
  // watch: {
  //   'dialogVisible': function() {
  //     // if (this.dialogVisible && this.nodelist.length == 0 && this.txSriNo) {
  //     //   this.getList()
  //     // }
  //     if (!this.dialogVisible) {
  //       this.errShow = false
  //       this.errMsg = ''
  //     }
  //   }
  // },
  methods: {
    getList: function () {
      Request.get('/v1/pm/process/taskBackQry/'+ this.txSriNo).then(res => {
        if (res.code == '000000' && res.data && res.data.length > 0) {
          this.nodelist = []
          res.data.forEach(item => {
            if (item.taskName && item.returnNodeNo) {
              this.nodelist.push(
                 {
                    label: item.taskName || item.taskDesc || '',
                    value: item.returnNodeNo || item.taskId || ''
                  }
              )
            }
            return
          })
        }
      })
    },
    check: function () {
      if (this.model) {
        this.errShow = false
        this.errMsg = ''
        return this.model
      } else {
        this.errShow = true
        this.errMsg = '请选择需要打回的节点'
        return false
      }
    }
  }
}
</script>