Files
jjx-web-sign-only/pages/spot/goods/detail.vue
T
2026-10-08 18:20:51 +08:00

649 lines
24 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<view>
<top-bar></top-bar>
<common-header></common-header>
<category-bar></category-bar>
<view class="page-nav">
<el-breadcrumb separator="/">
<el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
<el-breadcrumb-item>
<navigator style="display: inline-block;" url="/pages/spot/goods/goods">现货市场</navigator>
</el-breadcrumb-item>
</el-breadcrumb>
</view>
<view class="card">
<div class="card-header">
<view class="card-header-left">
<image class="logo" :src="product.user.businessCard.logo" mode="aspectFit"
v-if="product.user.businessCard"></image>
<view class="info">
<template v-if="product.user">
<view v-if="product.user.accountType === 1" class="info-name">
{{ product.user.person.personName }}
</view>
<view v-if="product.user.accountType === 2"
class="info-name flex justify-start items-center">
<text class="mr-25">{{ product.user.company.companyName }}</text>
<el-button type="primary" v-if="product.user.showInYellow === 1" size="small"
@click="navTo(`/pages/yellowPage/info?id=${product.user._id}`)">查看主页
</el-button>
</view>
</template>
<view class="info-update">
<view class="info-update-time">
{{ product._add_time_str }}
</view>
<view class="info-update-business">
主营业务:{{
(product.user.company.mainSpotCategory && product.user.company.mainSpotCategory.length > 0) ? product.user.company.mainSpotCategory.join() : ''
}}
</view>
</view>
</view>
</view>
<view class="card-header-right flex flex-col justify-center items-center">
<text class="mb-20 text-main">{{ product.quoteNum }}家已申请合作</text>
<el-button v-if="vk.getVuex('$user.userInfo._id') !== product.userId" @click="toCooperate"
type="primary">申请合作
</el-button>
<el-button v-else @click="showDialog = true"
type="primary">查看合作申请
</el-button>
</view>
</div>
<view class="card-body">
<div class="part-head">
<h3>现货详情</h3>
</div>
<!-- <template v-if="product.user">-->
<!-- <view v-if="product.user.accountType == 1" class="card-body-name">{{-->
<!-- product.user.person.personName-->
<!-- }}-->
<!-- </view>-->
<!-- <view v-if="product.user.accountType == 2" class="card-body-name">-->
<!-- {{ product.user.company.companyName }}-->
<!-- </view>-->
<!-- </template>-->
<view class="card-body-stock">库存约:{{ product.stock }}吨</view>
<view class="card-body-address">
供货地:{{
product.address.province.name + "-" + product.address.city.name + "-" + product.address.area.name
}}
</view>
</view>
<view class="card-body">
<div class="part-head">
<h3>报价有效期</h3>
</div>
<view class="card-body-stock">截止: {{
dayjs(product.answerEndTime).format('YYYY-MM-DD HH:mm:ss')
}}
</view>
</view>
<view class="card-body">
<div class="part-head">
<h3>产品规格单价</h3>
</div>
<ul class="el-upload-list el-upload-list--text">
<li @click="downloadFile(item)" v-for="(item,index) in product.files" :key="index" tabindex="0"
class="el-upload-list__item is-success">
<a class="el-upload-list__item-name">
<i class="el-icon-document"></i>
{{ item | getFileName }}
</a>
</li>
</ul>
</view>
<view class="card-body">
<div class="part-head">
<h3>产品现场图片</h3>
</div>
<el-image :preview-src-list="product.images" v-for="(item, index) in product.images" :key="index"
:src="item" style="width: 100px; height: 100px" class="mr-10 mb-15" fit="cover"/>
</view>
<view class="card-body">
<div class="part-head">
<h3>已收到的合作申请</h3>
</div>
<vk-data-table :data="product.cooperateList" :columns="table1.columns"
:customRightBtns="table1.customRightBtns"></vk-data-table>
</view>
</view>
<Gap/>
<common-footer></common-footer>
<el-dialog :visible.sync="showDialog" width="70%" :show-close="false">
<view slot="title" class="text-main text-40 m-30 flex justify-between items-center">
<text>收到的申请合作列表</text>
<el-button type="primary" @click.native="showDialog = false">关闭</el-button>
</view>
<view class="mt-15" v-if="product">
<view class="request-header">
<text class="flex-1">企业</text>
<text class="flex-1">申请人</text>
<text class="flex-1">联系方式</text>
<text class="flex-1">合作留言</text>
<text class="flex-1">申请时间</text>
<text class="flex-1">操作</text>
</view>
<view class="quote" v-for="(item, index) in product.cooperateList" :key="index">
<text class="flex-1">{{
item.user.userId !== product.userId ? item.user.company.companyName.replace(/^(.)(.).*(.)(.)(.)(.)$/, "$1$2***$3$4$5$6") : item.user.person.personName.replace(/^(.).*(.)$/, "$1*$2")
}}
</text>
<text class="flex-1">{{ item.name }}</text>
<text class="flex-1">{{ item.mobile }}</text>
<text class="flex-1">{{ item.remark }}</text>
<text class="flex-1">{{ item._add_time_str }}</text>
<text class="flex-1">
<el-button type="primary" @click.native="doShowInfo(item)">查看申请详情</el-button>
</text>
</view>
</view>
</el-dialog>
<el-dialog :visible.sync="form1.props.show" title="申请合作" width="60%" mode="form">
<el-form ref="form" :model="formData" label-width="120px">
<el-form-item label="企业名称" v-if="parseInt(vk.getVuex('$user.userInfo.accountType')) === 2">
<el-input v-model="formData.companyName" placeholder="请输入企业名称"/>
</el-form-item>
<el-form-item label="联系人姓名">
<el-input v-model="formData.name" placeholder="请输入联系人姓名"/>
</el-form-item>
<el-form-item label="联系人电话">
<el-input v-model="formData.mobile" placeholder="请输入联系人电话"/>
</el-form-item>
<el-form-item label="合作留言">
<el-input v-model="formData.remark" placeholder="请输入合作留言"/>
</el-form-item>
<el-form-item label="附件">
<vk-data-upload v-model="formData.files" list-type="text"
accept=".jpg,.jpeg,.png,.xlsx,.doc,.docx,.pdf"/>
</el-form-item>
</el-form>
<view class="text-center">
<el-button type="primary" @click.native="addCoop">确定</el-button>
</view>
<!-- <vk-data-form ref="form1" v-model="form1.data" :action="form1.props.action" :columns="form1.props.columns"-->
<!-- :rules="form1.props.rules" :form-type="form1.props.formType"-->
<!-- :loading.sync="form1.props.loading" :show-cancel="false"-->
<!-- :beforeAction="form1.props.beforeAction" :auto-close="true" label-width="140px"-->
<!-- @success="onFormSuccess">-->
<!-- </vk-data-form>-->
</el-dialog>
<vk-data-dialog
v-model="showInfo"
title="申请详情"
width="60%"
top="14vh"
center
:close-on-click-modal="true"
>
<vk-data-detail-table
:data="info"
:columns="infoColumns"
size="medium"
label-width="150px"
></vk-data-detail-table>
<template v-slot:footer>
<el-button @click="showInfo = false">关闭</el-button>
</template>
</vk-data-dialog>
</view>
</template>
<script>
import Gap from "../../../components/gap/gap.vue";
import dayjs from "dayjs";
export default {
components: {Gap},
data() {
return {
showDialog: false,
showInfo: false,
info: null,
allChildCate: [],
infoColumns: [
{key: "user.company.companyName", title: "企业", type: "text"},
{key: "name", title: "联系人", type: "text"},
{key: "mobile", title: "联系方式", type: "text"},
{key: "remark", title: "合作留言", type: "text"},
{
key: "files", title: "附件", type: "html",
formatter: (val = [], row, column, index) => {
let content = ''
val.forEach((item, itemIndex) => {
content += `<a href="${item}" target="_blank">预览:文件${itemIndex + 1}</a> `
})
return content
}
},
{
key: "_add_time_str",
title: "申请时间",
type: "text",
align: "left",
},
],
product: {
name: '现货详情',
address: {
province: {},
city: {},
area: {},
},
user: {
businessCard: {},
},
cooperateList: []
},
formData: {
companyName: '',
name: '',
mobile: '',
remark: '',
accountType: parseInt(vk.getVuex('$user.userInfo.accountType')),
goodsId: null,
goodsUserId: null,
files: [],
},
// 表单相关开始-----------------------------------------------------------
form1: {
// 表单请求数据,此处可以设置默认值
data: {
companyName: '',
name: '',
mobile: '',
remark: '',
},
// 表单属性
props: {
// 表单请求地址
action: "client/spot/goods/kh/addCooperate",
// 表单字段显示规则
columns: [
{
key: "companyName",
title: "企业名称",
type: "text",
showRule: (formData) => {
return parseInt(vk.getVuex('$user.userInfo.accountType')) === 2
},
},
{
key: "name",
title: "联系人姓名",
type: "text",
},
{
key: "mobile",
title: "联系人电话",
type: "text",
},
{
key: "remark",
title: "合作留言",
type: "textarea",
maxlength: 200,
showWordLimit: true,
},
],
// 表单验证规则
rules: {
text: [
{
required: true,
message: "text不能为空",
trigger: "change"
},
{
required: true,
message: "text不能为空",
trigger: "change"
},
]
},
// add 代表添加 update 代表修改
formType: "",
// 表单是否在请求中
loading: false,
// 是否显示表单1 的弹窗
show: false,
beforeAction: (formData) => {
formData.goodsId = this.product._id
formData.goodsUserId = this.product.userId
return formData
},
}
},
// 表单相关结束-----------------------------------------------------------
table1: {
// 表格数据
data: [],
// 表格字段显示规则
columns: [
{
key: "user.company.companyName",
title: "企业",
type: "text",
formatter: (val, row, column, index) => {
if (val) {
if (vk.getVuex('$user.userInfo._id') === this.product.userId) {
return val
}
return val.slice(0, 2) + "******";
}
return ''
}
},
{
key: "name",
title: "申请人",
type: "text",
formatter: (val, row, column, index) => {
if (vk.getVuex('$user.userInfo._id') === this.product.userId) {
return val
}
return val.slice(0, 1) + "**";
}
},
{
key: "mobile",
title: "联系方式",
type: "text",
formatter: (val, row, column, index) => {
if (vk.getVuex('$user.userInfo._id') === this.product.userId) {
return val
}
return "******";
}
},
{
key: "remark",
title: "合作留言",
type: "textarea",
},
{
key: "_add_time",
title: "申请时间",
type: "time",
},
],
customRightBtns: [{
title: '查看',
type: 'primary',
icon: 'el-icon-search',
disabled: (item) => {
return vk.getVuex('$user.userInfo._id') !== this.product.userId
},
onClick: (item) => {
this.doShowInfo(item)
}
},]
},
}
},
onLoad({id}) {
// 获取现货数据
this.getCategoryTreeData(id)
// 获取用户数据
vk.userCenter.getCurrentUserInfo({
success: (data) => {
this.form1.data = _.pick(data.userInfo, [
'fadadaConfirm', 'person', 'company', 'manager', 'businessCard', 'accountType'
])
// 成功后的逻辑
console.log('form1: ', {
...this.form1.data
});
if (data.userInfo.accountType === 1) {
this.formData.name = data.userInfo.person.personName
this.formData.mobile = data.userInfo.person.mobile
} else {
this.formData.companyName = data.userInfo.company.companyName
this.formData.mobile = data.userInfo.company.mobile
if (data.userInfo.manager) this.formData.name = data.userInfo.manager.personName
}
}
});
},
methods: {
dayjs,
getCategoryTreeData(id) {
vk.callFunction({
url: 'client/spot/category/pub/getTree',
title: '请求中...',
data: {},
success: (data) => {
this.allChildCate = []
data.rows.forEach(item => {
item.children.forEach(child => {
this.allChildCate.push(child)
})
})
this.getInfo(id)
}
});
},
getInfo(id) {
vk.callFunction({
url: 'client/spot/goods/pub/getDetail',
title: '请求中...',
data: {
_id: id,
},
success: (data) => {
this.product = data.data
this.product.user.company.mainSpotCategory = []
if (this.product.user.company && this.product.user.company.mainSpotCategoryIds) {
this.allChildCate.forEach(child => {
if (this.product.user.company.mainSpotCategoryIds.includes(child._id)) {
this.product.user.company.mainSpotCategory.push(child.name)
}
})
}
}
});
},
downloadFile(url) {
location.href = url
},
async toCooperate() {
const {userInfo, accountNum} = await vk.callFunction({
url: 'user/kh/getMyUserInfo'
})
if (!userInfo.fadadaConfirm || [-1, 2].includes(userInfo.authStatus)) {
this.$confirm('您尚未认证, 是否前往个人中心认证?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
vk.navigateTo({url: '/pages/user/user?menu=fadada'});
})
} else if (vk.pubfn.isNull(userInfo.businessCard)) {
this.$confirm('您尚未认证和完善名片,是否前往个人中心?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
vk.navigateTo({url: '/pages/user/user?menu=fadada'});
})
} else if (accountNum === 0) {
this.$confirm('请先到个人中心添加收款账户', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
vk.navigateTo({url: '/pages/user/user?menu=account'});
})
} else {
this.form1.props.show = true
}
// vk.navigateTo('/pages/spot/goods/cooperate?id=' + this.product._id);
},
getCertUrl() {
vk.callFunction({
url: 'client/fadada.getVerifyUrl',
success: (res) => {
location.href = res.data.url
}
});
},
doShowInfo(info) {
this.info = info
this.showInfo = true
},
addCoop() {
if (!this.formData.name) return this.$message.error('请填写联系人姓名')
if (!this.formData.mobile) return this.$message.error('请填写联系方式')
this.formData.goodsId = this.product._id
this.formData.goodsUserId = this.product.userId
vk.callFunction({
url: 'client/spot/goods/kh/addCooperate',
data: this.formData
})
this.form1.props.show = false
this.$message.success('提交成功')
this.getInfo(this.product._id)
},
navTo(url) {
vk.navigateTo({url})
}
},
filters: {
getFileName(url) {
const arr = url.split("/")
return arr[arr.length - 1]
}
}
}
</script>
<style scoped lang="scss">
.card {
width: 1200px;
margin: 20px auto;
background-color: #FFFFFF;
padding: 30px;
}
.card-body {
padding-top: 30px;
.card-body-name {
font-size: 18px;
font-weight: bold;
}
.card-body-stock {
font-size: 14px;
margin: 20px 0;
}
.card-body-address {
font-size: 14px;
}
}
.card-header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 0 60rpx 0;
border-bottom: 1px solid rgba(187, 187, 187, 0.37);
&-left {
display: flex;
align-items: center;
}
.logo {
width: 80px;
height: 80px;
}
.info {
padding-left: 30px;
}
.info-name {
font-size: 24px;
}
.info-update {
margin-top: 10px;
display: flex;
color: #A7A7A7;
font-size: 14px;
}
.info-update-time {
margin-right: 30px;
}
}
.part-head {
margin-bottom: 12px;
}
.part-head h3 {
line-height: 28px;
color: #a92924;
font-size: 20px;
text-indent: 15px;
position: relative;
}
.part-head h3:before {
content: " ";
width: 4px;
height: 16px;
background: #a92924;
display: inline-block;
position: absolute;
top: 6px;
left: 0;
}
.request-header {
border: 1px solid #EDEDED;
background-color: #FFF8F1;
display: flex;
align-items: center;
justify-content: center;
padding: 15px;
margin-top: 30px;
text {
text-align: center;
}
}
.quote {
border-left: 1px solid #EDEDED;
border-right: 1px solid #EDEDED;
border-bottom: 1px solid #EDEDED;
display: flex;
align-items: center;
justify-content: center;
padding: 15px;
text {
text-align: center;
}
}
</style>