gz_safety_app/pages/sendACarSystem/components/PlanDetails.vue

305 lines
8.1 KiB
Vue
Raw Normal View History

2024-12-24 13:02:43 +08:00
<template>
<div>
2024-12-24 17:26:08 +08:00
<uni-section title="基本信息" type="line"></uni-section>
<div class="list-cont">
<div class="list-item">
<div class="title">计划类型</div>
2025-01-17 19:35:38 +08:00
<div>{{ formData.typeName }}</div>
2024-12-24 17:26:08 +08:00
</div>
<div class="list-item">
<div class="title">项目名称</div>
<div>{{ formData.proName }}</div>
</div>
<div class="list-item">
<div class="title">项目部分</div>
2025-01-17 19:35:38 +08:00
<div>{{ formData.projectPart }}</div>
2024-12-24 17:26:08 +08:00
</div>
<div class="list-item">
2025-01-17 19:35:38 +08:00
<div class="title">施工地点</div>
<div>{{ formData.projectContent }}</div>
2024-12-24 17:26:08 +08:00
</div>
<div class="list-item">
<div class="title">需要日期</div>
2025-01-17 19:35:38 +08:00
<div>{{ formData.needDay }}</div>
2024-12-24 17:26:08 +08:00
</div>
<div class="list-item">
<div class="title">计划说明</div>
2025-01-17 19:35:38 +08:00
<div>{{ formData.remark }}</div>
2024-12-24 17:26:08 +08:00
</div>
</div>
<uni-section title="申请明细" type="line"></uni-section>
<div class="list-cont" v-for="(item, index) in tableList" :key="index">
<div class="list-item">
<span class="title"> &nbsp; &nbsp;</span>
<span>{{ item.type }}</span>
</div>
<div class="list-item">
<span class="title"> &nbsp; &nbsp;</span>
<span>{{ item.name }}</span>
</div>
<div class="list-item">
<span class="title"> &nbsp; &nbsp;</span>
2025-01-17 19:35:38 +08:00
<span>{{ item.model }}</span>
2024-12-24 17:26:08 +08:00
</div>
<div class="list-item">
<span class="title"> &nbsp; &nbsp;</span>
<span>{{ item.unit }}</span>
</div>
<div class="list-item">
<span class="title"> </span>
2025-01-17 19:35:38 +08:00
<span>{{ item.needNum }}</span>
2024-12-24 17:26:08 +08:00
</div>
<div class="list-item">
<span class="title">需要天数</span>
2025-01-17 19:35:38 +08:00
<span>{{ item.needDay }}</span>
2024-12-24 17:26:08 +08:00
</div>
<div class="list-item">
<span class="title"> &nbsp; &nbsp;</span>
<span>{{ item.remark }}</span>
</div>
</div>
<!-- btn -->
<div class="btn-wrap" v-if="opt.isPlan">
<div style="margin: 0 15px">
2025-01-17 19:35:38 +08:00
<u-button type="primary" @click="openModal"> </u-button>
2024-12-24 17:26:08 +08:00
</div>
</div>
<!-- 弹框 -->
<u-modal :show="showModal" title="指定派车供应商" showCancelButton @cancel="showModal = false" @confirm="submit">
<view class="slot-content">
<div>
2025-01-17 19:35:38 +08:00
<u-radio-group v-model="supId" placement="column" @change="groupChange">
2024-12-24 17:26:08 +08:00
<u-radio
:customStyle="{ marginBottom: '8px' }"
v-for="(item, index) in radioList"
:key="index"
:label="item.name"
2025-01-17 19:35:38 +08:00
:name="item.id"
2024-12-24 17:26:08 +08:00
></u-radio>
</u-radio-group>
</div>
</view>
</u-modal>
<!-- 空状态 -->
<u-empty v-if="tableList.length == 0" mode="data"></u-empty>
2024-12-24 13:02:43 +08:00
</div>
</template>
<script>
2025-01-17 19:35:38 +08:00
import { getDispatchCarListData, getPlanDetails, getContractSupList, addPlanSupInfo } from '@/api/carManage'
2024-12-24 17:26:08 +08:00
export default {
props: {
opt: {
type: Object,
default: () => {}
}
},
data() {
return {
showModal: false,
formData: {
2025-01-17 19:35:38 +08:00
planType: '', // 计划类型
proName: '', // 项目名称
proPart: '', // 项目部分
jobContent: '', // 工作内容
needDate: '', // 需要日期
explain: '' // 计划说明
2024-12-24 17:26:08 +08:00
},
pageNum: 1,
pageSize: 10,
total: 0,
tableList: [
{
type: '类型1',
name: '名称1',
specification: '规格1',
unit: '单位1',
num: '数量1',
date: '需要天数1',
remark: '备注1'
},
{
type: '类型2',
name: '名称2',
specification: '规格2',
unit: '单位2',
num: '数量2',
date: '需要天数2',
remark: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
}
],
2025-01-17 19:35:38 +08:00
radioList: [],
supId: '', // 供应商id
supName: '', // 供应商名称
contractId: '' // 合同id
2024-12-24 17:26:08 +08:00
}
},
mounted() {
console.log('🚀 ~ 计划详情 ~ this.opt', this.opt)
2025-01-17 19:35:38 +08:00
this.getPlanDetails()
2024-12-24 17:26:08 +08:00
},
methods: {
2025-01-17 19:35:38 +08:00
// 计划详情-到货确认单
async getDispatchCarListData() {
try {
const params = {
encryptedData: JSON.stringify({ id: this.opt.id })
}
const res = await getDispatchCarListData(params)
console.log('🚀 ~ getDispatchCarListData ~ res', res)
this.formData = res.data
this.tableList = res.data.detailsList || []
} catch (error) {
console.log('🚀 ~ getDispatchCarListData ~ error', error)
}
},
// 计划详情-派车管理
async getPlanDetails() {
try {
const params = {
encryptedData: JSON.stringify({ planId: this.opt.planId })
}
const res = await getPlanDetails(params)
console.log('🚀 ~ 计划详情-派车管理 ~ res', res)
this.formData = res.data
this.tableList = res.data.detailsList || []
} catch (error) {
console.log('🚀 ~ getPlanDetails ~ error', error)
}
},
// 获取供应商列表
async openModal() {
this.showModal = true
console.log('🚀 ~ 供应商-列表 ~ item:', this.opt)
const params = {
encryptedData: JSON.stringify({ type: this.opt.type })
}
try {
const res = await getContractSupList(params)
console.log('🚀 ~ getContractSupList ~ res', res)
this.radioList = res.data
} catch (error) {
console.log('🚀 ~ openModal ~ error', error)
}
},
groupChange() {
console.log('🚀 ~ supId', this.supId)
this.supName = this.radioList.find(item => item.id == this.supId).name
this.contractId = this.radioList.find(item => item.id == this.supId).contractId
console.log('🚀 ~ supName', this.supName, this.contractId)
},
2024-12-24 17:26:08 +08:00
submit() {
2025-01-17 19:35:38 +08:00
console.log('🚀 ~ submit ~ this.supId', this.supId)
if (!this.supId) {
uni.showToast({
title: '请选择派车供应商',
icon: 'none'
})
return
}
this.addPlanSupInfo()
},
// 确认分配供应商
async addPlanSupInfo() {
const params = {
encryptedData: JSON.stringify({
type: this.opt.type,
id: this.opt.planId,
supId: this.supId,
supName: this.supName,
contractId: this.contractId
})
}
try {
const res = await addPlanSupInfo(params)
console.log('🚀 ~ addPlanSupInfo ~ res', res)
uni.showToast({
title: '分配成功',
icon: 'success'
})
setTimeout(() => {
this.showModal = false
uni.navigateBack()
}, 1000)
} catch (error) {
console.log('🚀 ~ addPlanSupInfo ~ error', error)
}
2024-12-24 13:02:43 +08:00
}
}
2024-12-24 17:26:08 +08:00
}
2024-12-24 13:02:43 +08:00
</script>
<style lang="scss" scoped>
2024-12-24 17:26:08 +08:00
page {
padding-bottom: 70px;
}
.list-cont {
margin: 15px;
padding: 15px 0;
margin-bottom: 15px;
background-color: #fff;
border-radius: 8px;
box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.1);
.list-item {
padding: 5px 15px;
.title {
color: #999;
}
2024-12-24 13:02:43 +08:00
2024-12-24 17:26:08 +08:00
div {
line-height: 1.9;
}
span {
line-height: 1.5;
}
}
}
.btn-wrap {
width: 100%;
position: fixed;
bottom: 0;
left: 0;
background-color: #fff;
padding: 15px 0 20px;
}
.slot-content {
width: 100%;
height: 100%;
.item-wrap {
margin-bottom: 15px;
width: 100%;
height: 100%;
display: flex;
justify-content: space-between;
align-items: center;
.item {
width: 45%;
height: 30px;
display: flex;
justify-content: center;
align-items: center;
border: 1px solid #e8e8e8;
border-radius: 30px;
background-color: #f8f8f8;
color: #666;
font-size: 16px;
font-weight: 500;
transition: color 0.3s ease, background-color 0.3s ease, border 0.3s ease;
&.active {
color: $u-primary;
background-color: #f8f8f8;
border: 1px solid $u-primary;
}
}
}
}
</style>