detail.vue 8.06 KB
<template>
  <view class="page">
    <scroll-view class="scroll" scroll-y>
      <view class="detail-page">
        <view class="section">
          <text class="row company">{{ form.orderNo }}</text>
          <view :class="['status', `status_${form.status}`]" />
          <view class="row"><text class="label">订货单位</text><text class="value">{{ form.orderingUnitName }}</text>
          </view>
          <view class="row"><text class="label">订货日期</text><text class="value">{{ form.orderDate }}</text></view>
          <view class="row"><text class="label">申请撤单日期</text><text class="value">{{ form.documentPreparationDate }}</text></view>
          <view class="row"><text class="label">所属办</text><text class="value">{{ form.deptName }}</text></view>
        </view>

        <!-- 产品 -->
        <view class="mgb10">
          <Product mode="view" :list="form.purchaseOrderRevokeLineList" :totalQuantity="form.totalQuantity || 0" :totalRevokeQuantity="form.totalRevokeQuantity || 0"/>
        </view>
       
        <view class="section">
          <view class="row"><text class="label">撤销原因</text><text class="value">{{ form.revokeReason }}</text></view>
        </view>
        
        <view class="section">
          <view class="row"><text class="label">撤销确认凭证</text><text class="value act">{{ form.confirmationVoucherFileName }}</text></view>
        </view>
      </view>
    </scroll-view>
    <detail-buttons :buttons="displayButtons" @click="handleButtonClick" />
  </view>
</template>

<script>
import { getDetailApi, cancelApi } from '@/api/revoke_list.js'
import Product from './product.vue'
import DetailButtons from '@/components/detail-buttons/index.vue'

export default {
  name: 'RevokeListDetail',
  components: { Product, DetailButtons },
  data() {
    return {
      form: {},
      buttons: [
        { text: '编辑', visible: true, variant: 'outline', event: 'edit' },
        { text: '审核详情', visible: true, variant: 'outline', event: 'auditDetail' },
        { text: '审核', visible: true, variant: 'primary', event: 'audit' },
        { text: '取消', visible: true, variant: 'outline', event: 'cancel', style: { color: 'rgba(0,0,0,0.9)', border: '1px solid #DCDCDC' } },
      ]
    }
  },
  computed: {
    statusFlags() {
      const m = this.form || {}
      const e = String(m.status || '')
      return {
        isRefuse: e === 'REFUSE',
        isAudit: e === 'AUDIT',
        canEdit: e === 'REFUSE' && !!m.revokeCreateBy,
        canAudit: e === 'AUDIT' && !!m.showExamine,
        canCancel: e === 'REFUSE' && !!m.revokeCreateBy,
      }
    },
    displayButtons() {
      const f = this.statusFlags
      return [
        { ...this.buttons[0], visible: f.canEdit && this.$auth.hasPermi('order-manage:revoke-list:modify') },
        { ...this.buttons[1], visible: this.$auth.hasPermi('order-manage:revoke-list:review') },
        { ...this.buttons[2], visible: f.canAudit && this.$auth.hasPermi('order-manage:revoke-list:approve') },
        { ...this.buttons[3], visible: f.canCancel && this.$auth.hasPermi('order-manage:revoke-list:cancel') },
      ]
    }
  },
  created() {
  },
  onLoad(query) {
    const id = (query && (query.id || query.code)) || ''
    if (id) this.loadDetail(id)
  },
  methods: {
    async loadDetail(id) {
      try {
        const res = await getDetailApi(id)
        const data = res.data || {}
        this.form = { ...data }
      } catch (e) {
        this.form = {}
      }
    },
    handleButtonClick(btn) {
      if (!btn || btn.disabled) return
      const map = {
        edit: () => this.onEdit(),
        auditDetail: () => this.onAuditDetail(),
        audit: () => this.onAudit(),
        cancel: () => this.onCancel(),
      }
      const fn = map[btn.event]
      if (typeof fn === 'function') fn()
    },
    getBusinessId() {
      return (this.form && (this.form.id || this.form.code)) || ''
    },
    onEdit() {
      const id = this.getBusinessId()
      const query = id ? ('?id=' + encodeURIComponent(id)) : ''
      uni.navigateTo({ url: '/pages/revoke_list/modify' + query })
    },
    onAuditDetail() {
      const CACHE_KEY = 'sourceBusinessId'
      uni.setStorageSync(CACHE_KEY, this.getBusinessId())
      uni.navigateTo({ url: '/pages/flow/audit_detail' })
    },
    onAudit() {
      const CACHE_KEY = 'sourceBusinessId'
      uni.setStorageSync(CACHE_KEY, this.getBusinessId())
      uni.navigateTo({ url: '/pages/flow/audit' })
    },
    onCancel() {
      const id = this.getBusinessId()
      if (!id) return
      uni.showModal({
        title: '系统提示',
        content: '是否确定取消该流程?',
        confirmText: '确定',
        cancelText: '取消',
        success: (res) => {
          if (res && res.confirm) {
            cancelApi(id).then(() => {
              uni.showToast({ title: '已取消', icon: 'none' })
              setTimeout(() => { uni.redirectTo({ url: '/pages/revoke_list/index' }) }, 300)
            }).catch(() => {
              uni.showToast({ title: '取消失败', icon: 'none' })
            })
          }
        }
      })
    },
  }
}
</script>

<style lang="scss" scoped>
.page {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.scroll {
  flex: 1;
  padding: 8rpx 0 144rpx 0;
}

.detail-page {
  background: #f3f3f3;
}

.section {
  padding: 32rpx;
  background: #fff;
  margin-bottom: 20rpx;
  position: relative;

  .status {
    position: absolute;
    top: 16rpx;
    right: 52rpx;
    width: 180rpx;
    height: 146rpx;
    background-repeat: no-repeat;
    background-size: 100% 100%;
    background-position: center;

   &_AUDIT {
      background-image: url('~@/static/images/dev_manage/status_1.png');
    }

    &_PASS {
      background-image: url('~@/static/images/dev_manage/status_2.png');
    }

    &_REFUSE {
      background-image: url('~@/static/images/dev_manage/status_3.png');
    }

    &_CANCEL {
      background-image: url('~@/static/images/dev_manage/status_4.png');
    }

  }
}

.mgb10 {
  margin-bottom: 20rpx;
}

.row {
  display: flex;
  margin-bottom: 28rpx;

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

  &.company {
    font-size: 36rpx;
    font-weight: 600;
    color: rgba(0, 0, 0, 0.9);
    padding-top: 32rpx;
    line-height: 50rpx;
  }

  .label {
    max-width: 420rpx;
    line-height: 32rpx;
    font-size: 28rpx;
    color: rgba(0, 0, 0, 0.6);
  }

  .value {
    flex: 1;
    line-height: 32rpx;
    font-size: 28rpx;
    color: rgba(0, 0, 0, 0.9);
    text-align: right;

    &.act {
      color: $theme-primary;
    }

    .category {
      display: inline-block;
      padding: 4rpx 12rpx;
      border-radius: 6rpx;
      font-size: 24rpx;
      width: auto;

      &.category_A {
        background: #FFF0ED;
        color: #D54941;
      }

      &.category_B {
        background: #FFF1E9;
        color: #E37318;
      }

      &.category_C {
        background: #F2F3FF;
        color: $theme-primary;
      }

      &.category_D {
        background: #E3F9E9;
        color: #2BA471;
      }
    }
  }
}

.card {
  padding: 16rpx 0 8rpx;
  border-top: 1rpx solid #f0f0f0;
}

.history-header {
  display: flex;
  background: #F7F7F7;
  padding: 20rpx 52rpx 20rpx 32rpx;

  .col {
    font-size: 28rpx;
    color: rgba(0, 0, 0, 0.9);
    line-height: 40rpx;
  }

  .col1 {
    width: 20%;
  }

  .col2 {
    width: 50%;
    text-align: center;
  }

  .col3 {
    width: 30%;
    text-align: right;
  }
}

.history-row {
  display: flex;
  padding: 20rpx 52rpx 20rpx 32rpx;
  border-bottom: 1rpx solid #f7f7f7;

  .col {
    font-size: 28rpx;
    color: rgba(0, 0, 0, 0.9);
    line-height: 40rpx;
  }

  .col1 {
    width: 20%;
  }

  .col2 {
    width: 50%;
    text-align: center;
  }

  .col3 {
    width: 30%;
    text-align: right;
  }

  .link {
    color: $theme-primary;
  }
}

.title-header {
  background-color: #fff;
  display: flex;
  align-items: center;
  padding: 32rpx 32rpx 22rpx;
  border-bottom: 1rpx dashed #f0f0f0;

  &_icon {
    width: 32rpx;
    height: 28rpx;
    margin-right: 16rpx;
  }

  span {
    color: rgba(0, 0, 0, 0.9);
    font-size: 32rpx;
    line-height: 44rpx;
    font-weight: 600;
  }
}
</style>