detail.vue 7.03 KB
<template>
	<view class="page">
		<scroll-view class="scroll" scroll-y>
			<view class="detail-page">
				<view class="section">
					<text class="row customer">{{ form.customer.name }}</text>
					<view :class="['status', `status_${form.status}`]" />
					<view class="row"><text class="label">生产厂</text><text class="value">{{ form.workshop.name }}</text>
					</view>
					<view class="row"><text class="label">科办</text><text class="value">{{ form.office.name }}</text>
					</view>
					<view class="row"><text class="label">客户类型</text><text
							class="value">{{ getDicName('ENTERPRISE_TYPE', form.customerType, customerTypeOptions) }}</text>
					</view>
					<view class="row"><text class="label">产品品种</text><text
							class="value">{{ form.productVariety.name }}</text></view>
					<view class="row"><text class="label">月用量</text><text class="value">{{ form.monthlyUsage }}</text>
					</view>
					<view class="row"><text class="label">目标量</text><text class="value">{{ form.targetQuantity }}</text>
					</view>
					<view class="row"><text class="label">行业</text><text class="value">{{ form.industry }}</text></view>
					<view class="row"><text class="label">创建日期</text><text class="value">{{ form.createTime  }}</text>
					</view>
				</view>
				<view class="section">
					<view class="row"><text class="label">牌号</text><text class="value">{{ form.mark }}</text></view>
					<view class="row"><text class="label">厚度</text><text class="value">{{ form.thickness }}</text>
					</view>
					<view class="row"><text class="label">宽度</text><text class="value">{{ form.width }}</text></view>
					<view class="row"><text class="label">材质要求</text><text
							class="value">{{ form.materialRequire }}</text></view>
					<view class="row"><text class="label">品质要求</text><text
							class="value">{{ form.qualityRequire }}</text></view>
					<view class="row"><text class="label">同行</text><text class="value">{{ form.peer }}</text></view>
				</view>
				<view class="section">
					<view class="row"><text class="label">核价模式</text><text class="value">{{ form.pricingMode }}</text>
					</view>
					<view class="row"><text class="label">结算天数</text><text class="value">{{ form.settleDays }}</text>
					</view>
				</view>
				<view class="section">
					<view class="row"><text class="label">责任人</text><text class="value">{{ form.chargeUserName }}</text>
					</view>
				</view>
			</view>
		</scroll-view>
		<detail-buttons :buttons="buttons" @click="handleButtonClick" />
	</view>
</template>

<script>
	import {
		getDetailApi,
		statusOptions
	} from '@/api/devManage.js'
	import {
		getDicName
	} from '@/utils/dic.js'
	import {
		getDicByCodeApi
	} from '@/api/base.js'
	import DetailButtons from '@/components/detail-buttons/index.vue'

	export default {
		name: 'DevManageDetail',
		components: {
			DetailButtons
		},
		data() {
			return {
				form: {
					workshop: {},
					office: {},
					customer: {},
					customerType: '',
					chargeUserId: '',
					chargeUserIdName: '',
					productVariety: {},
					monthlyUsage: '',
					targetQuantity: '',
					industry: '',
					mark: '',
					thickness: '',
					width: '',
					materialRequire: '',
					qualityRequire: '',
					peer: '',
					pricingMode: '',
					settleDays: '',
					createTime: '',
					status: ''
				},
				customerTypeOptions: [],
				buttons: [{
						text: '编辑',
						visible: true,
						variant: 'outline',
						event: 'edit',
						style: {
							color: 'red',
							border: '2rpx dashed #2979ff'
						}
					},
					{
						text: '审核详情',
						visible: true,
						variant: 'outline',
						event: 'auditDetail'
					},
					{
						text: '审核',
						visible: true,
						variant: 'danger',
						event: 'audit'
					},
					{
						text: '取消',
						visible: true,
						variant: 'outline',
						event: 'cancel'
					}
				],
			}
		},
		created() {
			this.loadCustomerTypeOptions()
		},
		onShow() {
			uni.$on('dev_manage_detail_reload', this.onReload)
		},
		onUnload() {
			uni.$off('dev_manage_detail_reload', this.onReload)
		},
		onLoad(query) {
			const id = (query && (query.id || query.code)) || ''
			if (id) this.loadDetail(id)
		},
		methods: {
			onReload(payload) {
				const id = (payload && (payload.id || payload.code)) || this.form.id || this.form.code || ''
				if (id) this.loadDetail(id)
			},
			async loadDetail(id) {
				try {
					const res = await getDetailApi(id)
					console.log('getDetailApi res', res)
					const data = res.data || {};
					this.form = {
						...data
					}
				} catch (e) {
					console.error('loadDetail error', e)
				}
			},
			async loadCustomerTypeOptions() {
				try {
					const res = await getDicByCodeApi('ENTERPRISE_TYPE')
					const list = res.data || []
					this.customerTypeOptions = Array.isArray(list) ? list : []
				} catch (e) {
					this.customerTypeOptions = []
				}
			},
			getDicName: getDicName,
			handleButtonClick(btn) {
				if (!btn || btn.disabled) return
				if (typeof btn.onClick === 'function') return btn.onClick(this.form, btn.params)
				const e = btn.event || ''
				if (e === 'edit') return this.onEdit(btn && btn.params)
				if (e === 'auditDetail') return this.onAuditDetail(btn && btn.params)
				if (e === 'audit') return this.onAudit(btn && btn.params)
				if (e === 'cancel') return this.onCancel(btn && btn.params)
			},
			onEdit() {
				const id = this.form.id || this.form.code || ''
				const query = id ? ('?id=' + encodeURIComponent(id)) : ''
				uni.navigateTo({
					url: '/pages/dev_manage/modify' + query
				})
			},
			onAuditDetail() {
				uni.showToast({
					title: '审核详情',
					icon: 'none'
				})
			},
			onAudit() {
				uni.showToast({
					title: '审核',
					icon: 'none'
				})
			},
			onCancel() {
				uni.navigateBack()
			}
		}
	}
</script>

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

	.scroll {
		flex: 1;
		padding: 8rpx 0 144rpx 0;
	}

	.detail-page {
		background: #f3f3f3;
	}

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

			&_1 {
				background-image: url('/static/images/dev_manage/status_1.png');
			}

			&_2 {
				background-image: url('/static/images/dev_manage/status_2.png');
			}

			&_3 {
				background-image: url('/static/images/dev_manage/status_3.png');
			}

			&_4 {
				background-image: url('/static/images/dev_manage/status_4.png');
			}

		}

		.row {
			display: flex;
			margin-bottom: 28rpx;

			&:last-child {
				margin-bottom: 0;
			}

			&.customer {
				font-size: 36rpx;
				font-weight: 600;
				color: rgba(0, 0, 0, 0.9);
			}

			.label {
				width: 120rpx;
				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;
			}
		}
	}
</style>