<template>
  <div class="edit-add-detail">
    <div class="crumbs">
      <Breadcrumb
        :breadcrumbOpt="breadcrumbOpt"
        svg-name="#icon-business"
        @breadcrumb-click="handleClose"
      />
    </div>
    <div class="form-content">
      <el-form
        ref="formInfo"
        :model="parameter"
        label-width="auto"
        label-position="right"
      >
        <div class="rows">
          <div class="rows-left">
            <div class="rows-hr"></div>
          </div>
          <div class="rows-title">
            <div class="text-overflow">基本信息</div>
          </div>
        </div>
        <el-row :gutter="24">
          <el-col :span="8">
            <el-form-item label="对账单号" prop="isdCode">
              <el-input
                readonly
                v-model="parameter.isdCode"
                placeholder="自动申成对账单号"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="发起单位" prop="matCompanyName">
              <el-input
                clearable
                v-model="parameter.matCompanyName"
                placeholder="请输入发起单位"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="发起人" prop="matUserName">
              <el-input
                clearable
                v-model="parameter.matUserName"
                placeholder="请输入发起人"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="24">
          <el-col :span="8">
            <el-form-item label="发起人联系方式" prop="matCompanyPhone">
              <el-input
                clearable
                type="number"
                v-model="parameter.matCompanyPhone"
                placeholder="请输入发起人联系方式"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="对账单位" prop="vendorName">
              <el-input v-model="parameter.vendorName" placeholder=""></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="收货单" prop="receiptId">
              <el-input
                v-model="parameter.receiptId"
                placeholder="请选择收货单"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="24">
          <el-col :span="8">
            <el-form-item label="含税总金额" prop="totalAmount">
              <el-input
                v-model="parameter.totalAmount"
                readonly
                placeholder="由收货单自动计算"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="不含税总金额" prop="amount">
              <el-input
                v-model="parameter.amount"
                readonly
                placeholder="由收货单自动计算"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="合计税额" prop="taxAmount">
              <el-input
                v-model="parameter.taxAmount"
                readonly
                placeholder="由收货单自动计算"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <div class="rows">
          <div class="rows-left">
            <div class="rows-hr"></div>
          </div>
          <div class="rows-title">
            <div class="text-overflow">物料信息</div>
          </div>
        </div>
        <el-table
          ref="singleTable"
          :data="parameter.isdDetail"
          style="width: 100%"
          border
          highlight-current-row
          size="small"
          :cell-style="{'text-align': 'center'}"
          :header-cell-style="{'text-align': 'center'}"
        >
          <el-table-column fixed type="index" width="55" label="序号" />
          <el-table-column
            label="企业物料编号"
            min-width="100"
            show-overflow-tooltip
            prop="matCode"
          >
          </el-table-column>
          <el-table-column
            label="平台物料编号"
            min-width="100"
            show-overflow-tooltip
            prop="matPlatcode"
          >
          </el-table-column>
          <el-table-column
            label="物料名称"
            min-width="80"
            show-overflow-tooltip
            prop="matName"
          >
          </el-table-column>
          <el-table-column
            label="物料牌号"
            min-width="100"
            show-overflow-tooltip
            prop="matMaterial"
          >
          </el-table-column>
          <el-table-column
            label="规格型号"
            min-width="80"
            show-overflow-tooltip
            prop="matSpec"
          >
          </el-table-column>
          <el-table-column
            label="计划编号"
            min-width="100"
            show-overflow-tooltip
            prop="planCode"
          >
          </el-table-column>
          <el-table-column label="计量单位" min-width="100" prop="matUnit">
          </el-table-column>
          <el-table-column label="收货数量" min-width="130" prop="isdQuantity">
          </el-table-column>
          <el-table-column label="税率(%)" min-width="110" prop="taxRate">
          </el-table-column>
          <el-table-column
            label="含税单价(元)"
            min-width="130"
            prop="taxInprice"
          >
          </el-table-column>
          <el-table-column
            label="含税金额(元)"
            min-width="130"
            prop="taxInvalue"
          >
          </el-table-column>
          <el-table-column
            label="不含税单价(元)"
            min-width="130"
            prop="isdPrice"
          >
          </el-table-column>
          <el-table-column
            label="不含税金额(元)"
            min-width="130"
            prop="isdAmount"
          >
          </el-table-column>
          <el-table-column label="税额(元)" min-width="110" prop="taxValue">
          </el-table-column>

          <el-table-column
            label="基础扩展"
            min-width="100"
            show-overflow-tooltip
            prop="matBaseExt"
          >
          </el-table-column>
          <el-table-column
            label="其他扩展"
            min-width="100"
            show-overflow-tooltip
            prop="matOtherExt"
          >
          </el-table-column>
          <el-table-column
            label="挂账时间"
            min-width="100"
            show-overflow-tooltip
            prop="pendingTime"
          >
          </el-table-column>
          <el-table-column
            label="收货地址"
            min-width="100"
            show-overflow-tooltip
            prop="unloadAddress"
          >
          </el-table-column>
          <el-table-column
            label="企业补充说明"
            min-width="110"
            prop="purNote"
            show-overflow-tooltip
          >
          </el-table-column>
          <el-table-column
            label="供货方补充说明"
            min-width="110"
            prop="vendorNote"
            show-overflow-tooltip
          >
          </el-table-column>
        </el-table>
      </el-form>
    </div>
    <div
      slot="footer"
      class="footer"
    >
      <el-button @click="handleClose">{{ $t('domestic.cancel') }}</el-button>
      <!-- <el-button
        type="danger"
        plain
        @click="handlerefuse()"
        v-if="parameter.status === 3"
        >拒绝</el-button
      > -->
      <el-button
        type="primary"
        plain
        @click="handleconfrim()"
        v-if="parameter.status === 3"
        >确认</el-button
      >
    </div>
  </div>
</template>

<script>
import Breadcrumb from '@/components/Breadcrumb/index.vue'
import reconciliationManagement from '@/api/BasicDataManagement/reconciliationManagement.js'
import utils from '@/utils.js'
export default {
  name: 'confirmationStatementDetail',
  components: {Breadcrumb},
  data() {
    return {
      breadcrumbOpt: [{breadcrumbName: '对账单确认'}, {breadcrumbName: '详情'}],
      parameter: {},
    }
  },
  created() {
    if (this.$route.query.detailRows) {
      let row = JSON.parse(JSON.stringify(this.$route.query.detailRows))
      this.selectOne(row)
    }
  },
  mounted() {},
  methods: {
    handlerefuse() {
      this.$prompt('请输入拒绝原因', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
      })
        .then(({value}) => {
          if (value) {
            this.refuse(value)
          } else {
            this.$message({
              type: 'warning',
              message: '请输入拒绝原因！',
            })
            return
          }
        })
        .catch(() => {})
    },
    selectOne(row) {
      reconciliationManagement.selectOne(row.id).then((res) => {
        console.log(res, '1111')
        this.parameter = res.data.value
        if (!this.parameter.isdDetail) {
          this.parameter.isdDetail = []
        }
      })
    },
    // 关闭//面包屑点击
    handleClose() {
      this.$router.push({
        name: 'confirmationStatement',
        params: {
          pageBean: this.$route.query.pageBean,
        },
      })
      this.parameter = {}
    },
    //详情
    detail(val) {
      if (val) {
        this.modifychoData(val)
      }
    },
    //获取详情
    modifychoData(val) {},
    //撤回
    withdrawBtn() {
      this.$confirm('确定要撤回吗?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      }).then(() => {
        reconciliationManagement
          .batchReceipt(this.parameter.id)
          .then((res) => {
            if (res.data.state) {
              this.$message.success('撤回成功！')
              this.$router.go(-1)
            }
          })
      })
    },
    //确认
    handleconfrim() {
      this.$confirm('是否确认对账单数据?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      }).then(() => {
        this.$http.post('${portal}/bizReconciliation/v1/updateStatus?ids='+this.parameter.id+'&status='+4).then(res=>{
            if (res.data.state) {
              this.$message.success('确认成功！')
              this.$router.go(-1)
            }
          })
      })
    },
    //拒绝
    refuse(refuse) {
      reconciliationManagement
        .batchRefuset(this.parameter.id, refuse)
        .then((res) => {
          if (res.data.state) {
            this.$message.success('已拒绝！')
            this.$router.go(-1)
          }
        })
    },
  },
}
</script>
<style lang="scss" scoped>
::v-deep .el-form-item__label {
  width: 120px;
  font-size: 14px;
  color: #828282;
  font-weight: 500;
}
::v-deep .el-form-item__content span {
  font-size: 14px;
  color: #000;
  font-weight: 500;
}
::v-deep .el-form-item {
  margin-bottom: 10px;
}
/deep/.el-row {
  display: flex;
  justify-content: center;
}
.rows {
  display: flex;
  align-items: center;
  border-bottom: 1px solid #ebebeb;
  margin-bottom: 16px;
  padding: 10px 0;

  .rows-left {
    margin-right: 10px;

    .rows-hr {
      width: 3px;
      height: 18px;
      background-color: #0e6eff;
      border-radius: 2px;
    }
  }

  .rows-title {
    .text-overflow {
      width: 100%;
      font-size: 16px;
    }
  }
}

</style>
