index.vue 5.28 KB
<!--
 * @Date: 2024-07-23 18:31:35
 * @LastEditors: hookehuyr hookehuyr@gmail.com
 * @LastEditTime: 2024-08-13 10:18:33
 * @FilePath: /temple_material_request/src/components/materialDetail/index.vue
 * @Description: 物资详情页面
-->
<template>
  <div class="material-detail-page">
    <van-popup
      v-model:show="showRight"
      position="right"
      :style="{ height: '100%', width: '100%' }"
    >
      <div style="margin-top: 3rem; background-color: white; position: relative;">
        <div style="display: flex; justify-content: center; align-items: center;">
          <div v-if="!goodInfo.cover" style="padding: 2rem 5rem; padding-bottom: 2rem; border: 1px solid #F2EDE6; background-color: #FFFDF6; text-align: center;">
            <van-image
              width="6rem"
              height="6rem"
              fit="contain"
              src="https://cdn.ipadbiz.cn/oa/pic/%E7%89%A9%E8%B5%84%E5%9B%BE@2x.png"
            />
            <div style="color: #e0d0ba; margin-top: 1rem;">物资图正在整理中</div>
          </div>
          <div v-else>
            <van-image
              width="15rem"
              height="12rem"
              fit="contain"
              :src="goodInfo.cover"
            />
          </div>
        </div>
        <div style="text-align: center; font-weight: bold; color: #A67939; font-size: 1.15rem; margin: 1.5rem auto;">{{ goodInfo.name }}</div>
        <div style="color: #1C1C1C; background-color: #F2F2F2; font-size: 1rem; font-weight: bold; padding: 0.5rem 1.5rem;">基本信息</div>
        <div style="padding: 1rem;">
          <van-row style="margin-bottom: 0.5rem;">
            <van-col span="8" style="color: #AFAFAF;">编码</van-col>
            <van-col span="16">{{ goodInfo.coding }}</van-col>
          </van-row>
          <van-row style="margin-bottom: 0.5rem;">
            <van-col span="8" style="color: #AFAFAF;">规格</van-col>
            <van-col span="16">{{ goodInfo.spec }}</van-col>
          </van-row>
          <van-row style="margin-bottom: 0.5rem;">
            <van-col span="8" style="color: #AFAFAF;">单位</van-col>
            <van-col span="16">{{ goodInfo.specification }}</van-col>
          </van-row>
          <van-row style="margin-bottom: 0.5rem;">
            <van-col span="8" style="color: #AFAFAF;">分类</van-col>
            <van-col span="16">
              <div v-if="goodInfo.category_name">{{ goodInfo.category_name }}</div>
              <div v-else>/</div>
            </van-col>
          </van-row>
          <van-row style="margin-bottom: 0.5rem;">
            <van-col span="8" style="color: #AFAFAF;">描述</van-col>
            <van-col span="16">
              <div v-if="goodInfo.description" v-html="goodInfo.description"></div>
              <div v-else>/</div>
            </van-col>
          </van-row>
          <van-row style="margin-bottom: 0.5rem;">
            <van-col span="8" style="color: #AFAFAF;">条码</van-col>
            <van-col span="16">
              <div v-if="goodInfo.bar_code">{{ goodInfo.bar_code }}</div>
              <div v-else>/</div>
            </van-col>
          </van-row>
          <van-row style="margin-bottom: 0.5rem;">
            <van-col span="8" style="color: #AFAFAF;">价格</van-col>
            <van-col span="16">
              <div v-if="goodInfo.price">{{ goodInfo.price }}</div>
              <div v-else>/</div>
            </van-col>
          </van-row>
          <van-row style="margin-bottom: 0.5rem;">
            <van-col span="8" style="color: #AFAFAF;">是否可定</van-col>
            <van-col span="16">
              <div v-if="goodInfo.is_ordered">可定</div>
              <div v-else>不可定</div>
            </van-col>
          </van-row>
          <van-row style="margin-bottom: 0.5rem;">
            <van-col span="8" style="color: #AFAFAF;">状态</van-col>
            <van-col span="16">
              <div v-if="goodInfo.status === 9">上架</div>
              <div v-else>下架</div>
            </van-col>
          </van-row>
        </div>
        <div style="height: 4rem;"></div>
        <div style="padding: 1rem; position: sticky; bottom: 10px; left:0; right: 0;">
          <van-button block :color="styleColor.baseColor" @click="onClose">关闭</van-button>
        </div>
      </div>
    </van-popup>
  </div>
</template>

<script setup>
import { ref } from 'vue'
import { useRoute, useRouter } from 'vue-router'

import { Cookies, $, _, axios, storeToRefs, mainStore, Toast, useTitle } from '@/utils/generatePackage.js'
//import { } from '@/utils/generateModules.js'
//import { } from '@/utils/generateIcons.js'
//import { } from '@/composables'
import { getSkuInfoAPI } from "@/api/material";
import { styleColor } from "@/constant.js";

const $route = useRoute();
const $router = useRouter();
useTitle($route.meta.title);

const props = defineProps({
  show: Boolean,
  goodId: Number,
});

const emit = defineEmits(['close']);
const showRight = ref(false);
const onClose = () => {
  emit('close');
}

const goodInfo = ref({});

// 监听字段变化
watch(
  () => props.show,
  async (v) => {
    showRight.value = v;
    if (v) {
      const { code, data } = await getSkuInfoAPI({ i: props.goodId });
      if (code) {
        // 物资信息
        goodInfo.value = data;
      }
    }
  }
);
</script>

<style lang="less" scoped>
.material-detail-page {}
</style>