154 lines
3.9 KiB
Vue
Raw Normal View History

2025-05-21 13:44:54 +08:00
<template>
<div class="container">
2025-06-11 14:38:40 +08:00
<img :src="goodDetail.imgPath" alt="" class="img" />
2025-05-21 13:44:54 +08:00
<el-form label-width="120px" class="form">
2025-06-11 14:38:40 +08:00
<h1 style="margin: 0 0 20px 50px">请选择溯源农产品申请</h1>
<el-form-item label="溯源商品">
2025-06-11 14:38:40 +08:00
<el-select v-model="batch" placeholder="请选择商品" filterable :width="200">
<el-option v-for="(item, index) in goodsList" :key="index" :label="item.goodName" :value="item.id">
<el-tooltip :content="item.goodName" placement="top">
<span>{{ item.goodNames }}</span>
</el-tooltip>
</el-option>
2025-05-21 13:44:54 +08:00
</el-select>
</el-form-item>
<el-form-item label="溯源码">
<el-button type="primary" @click="uploadTraceCode">
<template #icon>
<el-icon><Upload /></el-icon>
2025-05-21 13:44:54 +08:00
</template>
点击上传
</el-button>
</el-form-item>
<el-form-item label="产品名称">
<el-input v-model="productName" placeholder="自动获取..." disabled />
</el-form-item>
<el-form-item label="检测时间">
<el-input v-model="detectTime" placeholder="自动获取..." disabled />
</el-form-item>
<el-form-item label="检测站">
<el-input v-model="station" placeholder="自动获取..." disabled />
</el-form-item>
<el-form-item label="产地信息">
<el-input v-model="origin" placeholder="自动获取..." disabled />
</el-form-item>
<el-form-item>
<el-button type="primary" style="border-radius: 8px" @click="submit">提交</el-button>
</el-form-item>
</el-form>
</div>
</template>
<script setup>
import { useRouter, useRoute } from 'vue-router';
import { ref, onMounted, reactive } from 'vue';
2025-05-21 13:44:54 +08:00
import { ElMessage } from 'element-plus';
import { getAssetsFile } from '@/utils/index.js';
import { goodList, saveRecords } from '@/apis/brand.js';
2025-06-11 14:38:40 +08:00
import { authDetail } from '../../../apis/brand.js';
2025-05-21 13:44:54 +08:00
const router = useRouter();
const route = useRoute();
const productId = route.query.id;
2025-05-21 13:44:54 +08:00
const product = ref({ name: '加载中...', id: productId });
2025-06-11 14:38:40 +08:00
const goodDetail = ref({});
2025-05-21 13:44:54 +08:00
const goodsList = reactive([]);
2025-05-21 13:44:54 +08:00
onMounted(() => {
// 模拟加载产品数据
product.value = {
id: productId,
name: productId == 1 ? '有机苹果' : '绿色蔬菜',
};
goodList().then((res) => {
if (res.code === 200) {
goodsList.splice(0, goodsList.length, ...res.data);
for (let i in goodsList) {
goodsList[i].goodNames = goodsList[i].goodName.length > 15 ? goodsList[i].goodName.substring(0, 15) + '...' : goodsList[i].goodName;
}
}
});
2025-06-11 14:38:40 +08:00
authDetail(productId).then((res) => {
if (res.code === 200) {
goodDetail.value = res.data;
}
});
2025-05-21 13:44:54 +08:00
});
const batch = ref('');
const productName = ref('');
const detectTime = ref('');
const station = ref('');
const origin = ref('');
function backToList() {
router.push(`/sub-operation-service/brand/apply`);
}
function uploadTraceCode() {
console.log('上传溯源码');
}
function submit() {
// console.log('提交申请:', {
// product: productId,
// batch: batch.value,
// detectTime: detectTime.value,
// station: station.value,
// origin: origin.value,
// });
let obj = {
goodsId: batch.value,
brandId: productId,
};
saveRecords(obj).then((res) => {
if (res.code === 200) {
// console.log(res);
ElMessage.success('提交成功!');
}
2025-05-21 13:44:54 +08:00
});
}
</script>
<style scoped lang="scss">
.container {
padding: 20px;
background-color: #fff;
position: relative;
height: 100%;
:deep(.el-breadcrumb__inner a) {
color: #25bf82;
}
}
.img {
width: 200px;
height: 200px;
position: absolute;
2025-06-11 14:38:40 +08:00
top: 20px;
2025-05-21 13:44:54 +08:00
left: 20px;
}
.form {
width: 60%;
margin: 0 auto;
}
:deep(.form .el-form-item__content) {
max-width: 300px;
}
:deep(.form .el-input, .form .el-select) {
width: 100%;
max-width: 300px;
}
</style>