detail.vue 7.37 KB
<template>
  <view class="page">
    <scroll-view class="scroll" scroll-y>
      <view class="detail-page">
        <view class="section">
          <text class="row company">{{ form.orderingUnitName }}</text>
          <view :class="['status', `status_${form.status}`]" />
          <view class="row"><text class="label">试样种类</text><text class="value">{{ form.sampleTypeName }}</text></view>
          <view class="row"><text class="label">客户类型</text><text class="value">{{ form.customerTypeName }}</text></view>
          <view class="row"><text class="label">生产厂</text><text class="value">{{ form.workshopName }}</text></view>
          <view class="row"><text class="label">所属品种</text><text class="value">{{ form.belongingBreed }}</text></view>
          <view class="row"><text class="label">原供货同行</text><text class="value">{{ form.originalSupplierPeer }}</text>
          </view>
        </view>

        <!-- 产品 -->
        <view class="section2">
          <Product mode="view" :list="form.productSampleConfirmationSlipDetailList" />
        </view>

        <view class="section3">
          <view class="view-total">
            <view class="head">合计</view>
            <view class="row">
              <view class="row2">
                <text class="label">数量</text><text class="value">{{ form.totalQuantity }}</text>
              </view>
            </view>
          </view>
        </view>

        <view class="section">
          <view class="row"><text class="label">数量</text><text class="value">{{ form.totalQuantity }}</text></view>
          <view class="row"><text class="label">本次试样数量是否超规定</text><text class="value">{{ form.sampleQuantityRegulation ?
              '是' : '否' }}</text></view>
          <view class="row"><text class="label">试样规格个数是否超规定</text><text class="value">{{
            form.specificationQuantityRegulation ? '是' : '否' }}</text></view>
          <view class="row"><text class="label">试样次数</text><text class="value">{{ form.sampleFrequency }}</text></view>
          <view class="row"><text class="label">前期不合格描述</text><text class="value">{{ form.earlyNonconformityDescription
              }}</text></view>
        </view>
      </view>
    </scroll-view>
    <detail-buttons :buttons="displayButtons" @click="handleButtonClick" />
  </view>
</template>

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

export default {
  name: 'ConfirmationFormDetail',
  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' },
      ]
    }
  },
  computed: {
    statusFlags() {
      const m = this.form || {}
      const e = String(m.status || '')
      // showAudit 这个字段就是后端自己判断的  制单人所在区域 所有人 权限
      return {
        canEdit: !e && m.showAudit || false,
        canAudit: e === 'AUDIT' && m.showExamine || false,
        canAuditDetail: !!e || false,
      }
    },
    displayButtons() {
      const f = this.statusFlags
      return [
        { ...this.buttons[0], visible: f.canEdit }, // 不需要额外的角色权限
        { ...this.buttons[1], visible: f.canAuditDetail && this.$auth.hasPermi('sample-order:confirmation-form:review') },
        { ...this.buttons[2], visible: f.canAudit && this.$auth.hasPermi('sample-order:confirmation-form:approve') },
      ]
    }
  },
  onLoad(query) {
    const id = (query && (query.id || query.code)) || ''
    if (id) this.loadDetail(id)
  },
  methods: {
    async loadDetail(id) {
      try {
        const res = await getDetailApi(id)
        this.form = res.data || {}
      } catch (e) {
        this.form = {}
      }
    },
    handleButtonClick(btn) {
      if (!btn || btn.disabled) return
      const map = {
        edit: () => this.onEdit(),
        auditDetail: () => this.onAuditDetail(),
        audit: () => this.onAudit(),
      }
      const fn = map[btn.event]
      if (typeof fn === 'function') fn()
    },
    onEdit() {
      const id = this.form.id || this.form.code
      if (id) uni.navigateTo({ url: `/pages/confirmation_form/modify?id=${id}` })
    },
    onAuditDetail() {
      uni.setStorageSync('sourceBusinessId', this.form.id)
      uni.navigateTo({ url: '/pages/flow/audit_detail' })
    },
    onAudit() {
      uni.setStorageSync('sourceBusinessId', this.form.id)
      uni.navigateTo({ url: '/pages/flow/audit' })
    },

  }
}
</script>

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

.scroll {
  flex: 1;
  background: #f3f3f3;
}

.detail-page {
  padding-bottom: 150rpx;
}

.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');
    }

  }
}

.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: 10rpx;
    margin-bottom: 32rpx;
    line-height: 50rpx;
  }

  .label {
    max-width: 400rpx;
    margin-right: 20rpx;
    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;
    word-break: break-all;
  }
}

.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;
  }
}

.section2 {
  background: #f1f1f1;
}


.section3 {
    padding: 0 32rpx;
    background-color: #fff;
    margin: 20rpx 0;
}

.view-total {
    padding-bottom: 20rpx;

    .head {
        font-size: 32rpx;
        font-weight: 600;
        line-height: 50rpx;
        color: rgba(0, 0, 0, 0.9);
        padding-bottom: 16rpx;
        margin-bottom: 24rpx;
        border-bottom: 1px dashed #E7E7E7;
    }

    .row {
        display: flex;
        margin-bottom: 24rpx;
        line-height: 32rpx;

        .row2 {
            width: 50%;
        }

        .label {
            width: 180rpx;
            margin-right: 14rpx;
            color: rgba(0, 0, 0, 0.6);
            font-size: 28rpx;
        }

        .value {
            flex: 1;
            color: rgba(0, 0, 0, 0.9);
            font-size: 28rpx;
            white-space: pre-wrap;
            word-break: break-all;
        }
    }
}
</style>