detail.vue 6.95 KB
<template>
  <view class="page">
    <scroll-view class="scroll" scroll-y>
      <view class="detail-page">
        <view class="section">
          <text class="row company">{{ form.customerName }}</text>
          <view class="row"><text class="label">订单编号</text><text class="value">{{ form.orderNo }}</text></view>
          <view class="row"><text class="label">生产厂</text><text class="value">{{ form.workshopName }}</text></view>
        </view>
 
        <!-- 产品 -->
        <view class="section2">
          <Product mode="view" :list="form.detailList" />
        </view>

      </view>
    </scroll-view>
    <!-- <detail-buttons :buttons="displayButtons" @click="handleButtonClick" /> -->
  </view>
</template>

<script>
import { getDetailApi } from '@/api/feedback_form.js'
import Product from './product.vue'
import DetailButtons from '@/components/detail-buttons/index.vue'
import { downloadFile } from '@/utils/downloadFile.js'
import {
  getDicByCodes
} from '@/utils/dic'
import {
  getDicName
} from '@/utils/dic.js'

export default {
  name: 'FeedbackFormDetail',
  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' },
      ],
      dicOptions: {
        SAMPLE_RESULT: [],
        SAMPLE_RESULT_SUB: []
      },
      sampleResultLocal: [],
      sampleResultSubLocal: []
    }
  },
  computed: {
    // statusFlags() {
    //   const m = this.form || {}
    //   const e = String(m.status || '')
    //   return {
    //     // 跟踪单编辑:1:审核状态为空、已驳回   2:showAudit为true  3:需要加角色权限
    //     canEdit: (!e || e === 'REFUSE') && m.showAudit || false,
    //     canAudit: e === 'AUDIT' && m.showExamine || false,
    //     canAuditDetail: !!e || false,
    //   }
    // },
    // displayButtons() {
    //   const f = this.statusFlags;
    //   console.log('displayButtons_f', f)
    //   return [
    //     { ...this.buttons[0], visible: f.canEdit && this.$auth.hasPermi('sample-order:follow-up-form:modify') },
    //     { ...this.buttons[1], visible: f.canAuditDetail && this.$auth.hasPermi('sample-order:follow-up-form:review') },
    //     { ...this.buttons[2], visible: f.canAudit && this.$auth.hasPermi('sample-order:follow-up-form:approve') },
    //   ]
    // }
  },
  onLoad(query) {
    const id = (query && (query.id || query.code)) || ''
    if (id) {
      this.loadDetail(id)
      // this.loadAllDicData()
    }
  },
  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/follow_up_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' })
    },
    downloadFile,
    getDicName,
    loadAllDicData() {
      const dicCodes = ['SAMPLE_RESULT', 'SAMPLE_RESULT_SUB']
      return getDicByCodes(dicCodes).then(results => {
        this.dicOptions.SAMPLE_RESULT = results.SAMPLE_RESULT.data || []
        this.dicOptions.SAMPLE_RESULT_SUB = results.SAMPLE_RESULT_SUB.data || []
        this.sampleResultLocal = (this.dicOptions.SAMPLE_RESULT || []).map(it => ({
          value: it.code,
          text: it.name
        }))
        this.sampleResultSubLocal = (this.dicOptions.SAMPLE_RESULT_SUB || []).map(it => ({
          value: it.code,
          text: it.name
        }))
      }).catch(() => {
        this.dicOptions = {
          SAMPLE_RESULT: [],
          SAMPLE_RESULT_SUB: []
        }
        this.sampleResultLocal = []
        this.sampleResultSubLocal = []
      })
    },
  }
}
</script>

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

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

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

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

    &.act {
      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;
  }
}

.section2 {
  background: #f1f1f1;
  margin-bottom: 20rpx;
}


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