<template>
  <div>
    <el-dialog center width="80%" :before-close="()=>{$emit('update:showSpecialNeedsConsLook',false)}"
               :visible.sync="showSpecialNeedsConsLook">
      <div class="content">
        <h1>{{ consNum }} 特需-查看</h1>
        <el-row v-for="item in echoList">
          <el-col :span="24">
            {{ $t("特需") }}:
            <dict-tag :type="DICT_TYPE.ORDER_SPECIAL_NEEDS" :value="item.advanceType" />-
            <span v-if="item.deleted">已删除</span>
            <dict-tag v-else :type="DICT_TYPE.CONS_SPECIAL_NEEDS_STATUS" :value="item.needStatus" />
          </el-col>
          <el-col :span="24">
            {{ $t("备注") }}:{{ item.remarks }}
          </el-col>
          <el-col :span="24">
            {{ $t("金额") }}:{{ item.expectedFee }}{{ item.expectedFeeCurrencyName }}-
            <dict-tag :type="DICT_TYPE.PAYMENT_TYPE" :value="item.payType" />
          </el-col>
          <el-col :span="6">
            {{ $t("创建人") }}:{{ item.creatorName }}
          </el-col>
          <el-col :span="6">
            {{ $t("创建时间") }}:{{ parseTime(item.createTime) }}
          </el-col>
          <el-col :span="6">
            {{ $t("处理人") }}:{{ item.auditorName }}
          </el-col>
          <el-col :span="6">
            {{ $t("处理时间") }}:{{ parseTime(item.auditorTime) }}
          </el-col>
        </el-row>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button @click="$emit('update:showSpecialNeedsConsLook',false)">{{ $t("取消") }}</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { DICT_TYPE } from "@/utils/dict"
import { selectAllSpecialListByConsId } from "@/api/ecw/consSpecialNeed"
import { getCurrencyList } from "@/api/ecw/currency"

export default {
  name: "specialNeedsCons",
  props: {
    consId: {
      type: [String, Number]
    },
    consNum: [String, Number],
    showSpecialNeedsConsLook: Boolean
  },
  data() {
    return {
      DICT_TYPE,
      remarks: "",
      echoList: [],
      currencyList: []
    }
  },
  methods: {},
  watch: {
    showSpecialNeedsConsLook(val) {
      getCurrencyList().then((res) => (this.currencyList = res.data))
      if (val) {
        const that = this
        //特需回显
        selectAllSpecialListByConsId(this.consId).then(r => {
          r.data.forEach(row => {
            row.expectedFeeCurrencyName = that.currencyList.filter(item => item.id == row.expectedFeeCurrency)[0]["titleEn"]
          })
          console.log(r.data)
          that.echoList = r.data
        })
      } else {
        this.echoList = []
      }
    }
  }
}
</script>

<style scoped lang="scss">
.el-row {
  margin-bottom: 20px;

  &:last-child {
    margin-bottom: 0;
  }
}

.el-col {
  margin-bottom: 10px;
}
</style>
