<!-- 合同删除审批单 -->
<template>
  <modal v-model="modal" class-name="vertical-center-modal" width="700px">
    <!--  表单主要内容  -->
    <div class="title" slot="header">
      合同删除审批单
    </div>
    <div class="content">
      <div class="sub-title border">
        <span>申请信息</span>
      </div>
      <div class="row">
        <div class="col">
          <div class="label">申请人：</div>
          <div class="value">{{ data.applyUser }}</div>
        </div>
        <div class="col">
          <div class="label">申请部门：</div>
          <div class="value">{{ data.applyDepartment }}</div>
        </div>
        <div class="col">
          <div class="label">申请时间：</div>
          <div class="value">{{ data.applyDate }}</div>
        </div>
      </div>
      <div class="row">
        <div class="col">
          <div class="label">删除原因：</div>
          <div class="value">
            <Input v-model="remark" type="textarea" />
          </div>
        </div>
      </div>
      <div class="sub-title border">
        <span>合同信息</span>
      </div>
      <div class="row">
        <div class="col">
          <div class="label">申购单号：</div>
          <div class="value">
            <a href="#" @click="$emit('show-apply-bill', data.applyBillNo)">{{ data.applyBillNo }}</a>
          </div>
        </div>
      </div>
      <div class="row">
        <div class="col">
          <div class="label">合同编码：</div>
          <div class="value">{{ data.purchaseBillNo }}</div>
        </div>
      </div>
      <div class="row">
        <div class="col">
          <div class="label">物料编码：</div>
          <div class="value">{{ data.materialCode }}</div>
        </div>
      </div>
      <div class="row">
        <div class="col">
          <div class="label">物料名称：</div>
          <div class="value">{{ data.materialName }}</div>
        </div>
      </div>
      <div class="row">
        <div class="col">
          <div class="label">供应商：</div>
          <div class="value">{{ data.supplierName }}</div>
        </div>
      </div>
      <div class="row">
        <div class="col">
          <div class="label">采购数量：</div>
          <div class="value">{{ data.purchaseQty }}</div>
        </div>
        <div class="col">
          <div class="label">采购单价：</div>
          <div class="value">{{ data.price }}</div>
        </div>
        <div class="col"></div>
      </div>
      <div class="row">
        <div class="col">
          <div class="label">合同金额：</div>
          <div class="value">{{ data.totalAmount }}</div>
        </div>
      </div>
    </div>
    <div class="footer" slot="footer">
      <Button @click="cfm" class="btn" type="primary">提交</Button>
      <Button @click="cancel" class="btn">取消</Button>
    </div>
  </modal>
</template>

<script>
import MyTable from '_c/my-table/my-table'
import {
  AddPurchaseContractDel
} from '@/api/applyPurchase'

export default {
  name: 'contract-form',
  data () {
    return {
      columns: [
        {
          title: '序号',
          type: 'index',
          width: 60,
          align: 'center'
        },
        {
          title: '标签值',
          key: 'rfidCode',
          minWidth: 150,
          render: (h, params) => {
            return h('span', {
              style: {
                color: params.row.checkTagState === 1 ? 'red' : params.row.checkTagState === 2 ? '#d7d7d7' : ''
              }
            }, params.row.rfidCode)
          }
        },
        {
          title: '盘点状态',
          key: 'checkTagState',
          minWidth: 150
        },
        {
          title: '处置类型',
          key: 'tagDealType',
          minWidth: 150
        }
      ],
      list: [],
      tabIndex: 0,
      formData: {},
      remark: '',
      modal: false,
      flowsList: [],
      infoData: {
        scanfErrorTagList: []
      },
      params: {
        pageIndex: 1,
        pageSize: 20,
        total: 0
      }
    }
  },
  components: {
    MyTable
  },
  props: {
    data: {
      type: Object,
      default () {
        return {}
      }
    },
    value: {
      type: Boolean,
      default: false,
      require: true
    }
  },
  watch: {
    value: {
      handler (n) {
        this.modal = n
      },
      immediate: true
    },
    modal (n) {
      this.$emit('input', n)
      if (n) {
        console.log(this.data)
      }
    }
  },
  methods: {
    cfm () {
      if (!this.remark) return this.$Message.error('请输入删除原因！')
      AddPurchaseContractDel({
        purchaseBillNo: this.data.purchaseBillNo,
        reason: this.remark
      }).then(res => {
        if (res.code === 0) {
          this.cancel()
          this.$Message.info(res.msg || '操作成功！')
          this.$emit('getlist')
        }
      })
    },
    cancel () {
      this.remark = ''
      this.modal = false
    }
  }
}
</script>

<style lang="less" scoped>
.content {
  padding: 10px 0;
  border-radius: 5px;
  background-color: #FFFFFF;
  &.sub-content {
    background-color: #f2f2f2;
    margin-top: 3px;
    .title {
      padding-top: 0;
    }
  }
  .title {
    text-align: center;
    font-size: 16px;
    font-weight: bold;
  }
  .sub-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 10px;
    font-size: 14px;
    font-weight: bold;
    &.border {
      border-bottom: 1px solid #000000;
    }
    .go {
      font-size: 10px;
      font-weight: normal;
      color: #0000ff;
    }
    .tabs {
      margin-bottom: 1px;
      display: flex;
      justify-content: space-between;
      border: 1px solid #5d6c7b;
      border-radius: 2px;
      font-size: 12px;
      font-weight: normal;
      .tab {
        width: 50px;
        text-align: center;
        border-right: 1px solid #5d6c7b;
        cursor: pointer;
        &:last-child {
          border-right: none;
        }
        &.active {
          background-color: rgba(22, 155, 213, 1);
          color: #FFFFFF;
        }
      }
    }
  }
  .row-wrap {
    position: relative;
    .pic {
      position: absolute;
      right: 20px;
      top: 50%;
      transform: translateY(-50%);
      width: 50px;
      img {
        width: 100%;
      }
    }
  }
  .row {
    padding: 0 20px;
    margin-bottom: 5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    .col {
      flex: 1;
      display: flex;
      align-items: flex-start;
      .value {
        flex: 1;
      }
    }
  }
  .card {
    margin-bottom: 5px;
    background-color: #FFFFFF;
    border: 1px solid rgba(215, 215, 215, 1);
    border-radius: 5px;
    .border {
      border-bottom: 1px solid #5d6c7b;
    }
    .line {
      width: 100%;
      border-bottom: 1px solid #5d6c7b;
    }
  }
  .table {
    padding: 0 20px;
    padding-bottom: 20px;
    max-height: 200px;
    overflow: auto;
    table {
      border-collapse:collapse;
      border:none;
      width: 100%;
      tr {
        td,th {
          padding: 5px;
          text-align: center;
          border:solid #dcdee2 1px;
          position: relative;
          font-size: 12px;
        }
        th {
          background-color: #eeeeee;
        }
      }
    }
  }
}
/deep/ .ivu-modal-body {
  padding: 0;
  max-height: 80vh;
  overflow: auto;
}
  </style>
