<template>
  <div>
    <el-dialog
      :close-on-click-modal="false"
      title="重复提醒"
      :visible.sync="dialogVisible"
      width="840px"
      :before-close="handleClose"
    >
      <div>
        <div class="top">
          <span>
            <span style="color:red">以下质检码被 (
              <span style="color:blue">
                上架/铺货/销售
              </span>
              )使用过
            </span>
            。现在不能再次使用，可使用
            <span style="color:blue">替换上架功能</span>
            继续上架。
          </span>
        </div>
        <div class="mid">
          <el-table

            :data="repeatdata"

            style="width: 100%"
          >
            <el-table-column label="">
              <el-table-column
                align="center"
                prop="num"
                label="序号"
                width="80"
              />
              <el-table-column
                align="center"
                prop="qc_code"
                label="质检码"
                width="180"
              />
            </el-table-column>
            <el-table-column label="当前机器" align="center">
              <el-table-column
                align="center"
                prop="imei"
                label="imei/sn"
                width="180"
              />
              <el-table-column
                align="center"
                prop="op_status2"
                label="状态"
                width="80"
              >
                <template slot-scope="slot">
                  <!-- <el-tag> {{ change(row) }}</el-tag> -->
                  <span v-if="slot.row.op_status2">
                    <el-tag> {{ change(slot.row.op_status2) }}</el-tag>
                  </span>
                  <span v-else>
                    <el-tag> {{ slot.row.op_status2 }}</el-tag>
                  </span>
                </template>
              </el-table-column>
            </el-table-column>
            <el-table-column label="质检码已被使用" align="center">
              <el-table-column
                align="center"
                prop="serial_number"
                label="编号"
                width="180"
              />
              <el-table-column
                align="center"
                prop="op_status1"
                label="状态"
                width="80"
              >
                <template slot-scope="slot">
                  <span v-if="slot.row.op_status1">
                    <el-tag> {{ change(slot.row.op_status1) }}</el-tag>
                  </span>
                  <span v-else>
                    <el-tag> {{ slot.row.op_status1 }}</el-tag>
                  </span>
                </template>
              </el-table-column>
            </el-table-column>

          </el-table>
        </div>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="cancleemit">取 消</el-button>
        <el-button type="primary" @click="surerepeat()">确认替换上架</el-button>

      </span>
    </el-dialog>
  </div>
</template>

<script>
import { zz_new_status, rollback_get_tracking, replace_qc_code } from '@/api/machineList' // 获取列表信息接口
export default {
  name: 'Repeat',
  components: {

  },
  props: {
    dialogVisible: {
      type: Boolean,
      default: () => {
        return false
      }
    },
    repeatdata: {
      type: Array,
      default: () => {
        return []
      }
    }
  },
  data() {
    return {

    }
  },
  mounted() {

  },
  methods: {
    change(v) { // 机器状态过滤
      if (v === 10) {
        return '采购待入库'
      } else if (v === 11) {
        return '待分拣'
      } else if (v === 12) {
        return '采购退货'
      }  else if (v === 13) {
        return '质检中'
      } else if (v === 14) {
        return '调拨中'
      } else if (v === 15) {
        return '质检完成'
      } else if (v === 16) {
        return '采购待退货'
      } else if (v === 21) {
        return '现场维修中'
      } else if (v === 22) {
        return '寄修待回机'
      } else if (v === 23) {
        return '维修完成'
      } else if (v === 31) {
        return '销售'
      } else if (v === 32) {
        return '上架'
      } else if (v === 33) {
        return '铺货'
      } else if (v === 34) {
        return '销售退货(已收货)'
      } else if (v === 35) {
        return '下架'
      } else if (v === 36) {
        return '配件销售'
      } else if (v === 37) {
        return '预售'
      } else if (v === 38) {
        return '寄卖中'
      } else if (v === 20) {
        return '待维修'
      } else if (v === 42) {
        return '销售退货(待收货)'
      } else if (v === 51) {
        return '手动出库'
      } else if (row.instorage_type === 3) {
        return '代卖'
      } else {
        return '未入库'
      }
    },
    cancleemit() {
      this.$emit('close')
    },
    handleClose() {
      this.dialogVisible = false
    },
    surerepeat() {
      const sales_reshelves_id = this.repeatdata.map(v => {
        return v.sales_reshelves_id
      })
      const params = {
        sales_reshelves_id: sales_reshelves_id
      }
      replace_qc_code(params).then(res => {
        if (res.errcode == 0) {
        setTimeout(() => {
          this.$emit('choose')
        }, 500);
          // this.$message.success('您已成功将质检码替换，请重新上架')
        }
      })
      this.dialogVisible = false
    }
  }

}
</script>

<style>

</style>
