image-info.vue 3.33 KB
Newer Older
wangcong committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
<template>
  <div class="invoice-image-info">
    <div class="title-wrapper">
      <ImageTab :options="tabList" v-model="tabKey" />
      <div class="button-wrapper">
        <Button :disabled="isInfoEdit || imageInfo.checkFlag == 2" size="small" @click="isInfoEdit = true">修改</Button>
        <Button :disabled="!isInfoEdit" size="small" @click="handleSave">保存</Button>
        <Button
          v-if="!hideVerification(imageInfo)"
          :disabled="isInfoEdit || imageInfo.checkFlag == 2"
          size="small"
          @click="handleVerification"
        >
          查验
        </Button>
      </div>
    </div>
    <ImageInfoPanel :loading="loading" :imageInfo="imageInfo" :isInfoEdit="isInfoEdit" />
  </div>
</template>

<script>
import ImageTab from './image-tab.vue'
import ImageInfoPanel from './image-info-panel.vue'
import { verificationTypeList } from '../utils'
export default {
  components: {
    ImageTab,
    ImageInfoPanel,
  },
  props: {
    currentSelectedRow: {
      type: Object,
      default: () => ({}),
    }
  },
  data() {
    
    return {
      isInfoEdit: false,
      imageInfoList: [],
      imageInfo: {},
      tabKey: 0,
      tabList: [],
      loading: false,
    }
  },
  computed: {
  },
  watch: {
    tabKey(val) {
      this.imageInfo = { ...this.imageInfoList[val] }
    },
  },
  created() {
    this.queryImageInfo()
  },
  methods: {
    
    hideVerification(imageInfo) {
      if (verificationTypeList.includes(imageInfo.billType)) {
        return false
      }
      return true
    },
    handleVerification() {
      this.loading = true
      window.GMS.$http.post(
        `/yxgl/verification`,
        { ...this.imageInfo }
      ).then((res) => {
        if (res.data && res.data.code != 0) {
          this.$Message.error(res.data.msg)
        }
      }).finally(() => {
        this.queryImageInfo()
      })
    },
    handleSave() {
      this.isInfoEdit = false
      window.GMS.$http.post(
        `/yxgl/saveDetails`,
        { ...this.imageInfo }
      ).finally(() => {
        this.queryImageInfo()
      })
    },
    queryImageInfo() {
      this.loading = true
      window.GMS.$http.post(
        `/yxgl/selectDetails`,
        { ...this.currentSelectedRow }
      ).then((res) => {
        this.loading = false
        this.imageInfoList = res?.data?.rows || []
        this.tabList = this.imageInfoList.map((o, index) => ({
          label: `发票${index + 1}`,
          value: index,
        }))
        this.tabKey = 0
        this.imageInfo = { ...(res?.data?.rows?.[this.tabKey] || {}) }
        this.$emit('load-info', this.imageInfoList)
      })
    },
  },
};
</script>

<style lang="less">
.invoice-image-info {
  padding: 16px 16px 0px 16px;
  .title-wrapper {
    position: relative;
    height: 46px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #e8e8e8;
    margin-bottom: 16px;
    &::before {
      position: absolute;
      left: 0;
      top: 15px;
      content: "";
      width: 3px;
      height: 16px;
      background: #4bc0c6;
    }
    .title {
      margin-left: 12px;
      height: 22px;
      font-size: 16px;
      font-weight: 500;
      color: #555555;
      line-height: 22px;
    }
    .button-wrapper {
      button {
        &:not(:last-child) {
          margin-right: 10px;
        }
      }
    }
  }
  
}
</style>