detail.vue 17.1 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420
<template>
	<view class="page">
		<scroll-view class="scroll" scroll-y>
			<view class="detail-page">
				<view class="section">
					<text class="row company">{{ safeText(form.unitName) }}</text>
					<view class="row"><text class="label">公司性质</text><text class="value">{{ safeText(companyNatureName) }}</text></view>
					<view v-if="showCompanyNatureOther" class="row"><text class="label">其他</text><text class="value">{{ safeText(form.companyNatureOther) }}</text></view>
					<view class="row"><text class="label">开户行</text><text class="value">{{ safeText(form.bankName) }}</text></view>
					<view class="row"><text class="label">账号</text><text class="value">{{ safeText(form.bankAccount) }}</text></view>
					<view class="row"><text class="label">注册资金(万元)</text><text class="value">{{ safeText(form.registeredCapital) }}</text></view>
					<view class="row"><text class="label">法人代表</text><text class="value">{{ safeText(form.legalRepresentative) }}</text></view>
					<view class="row"><text class="label">公司成立时间</text><text class="value">{{ safeText(form.companyEstablishedTime) }}</text></view>
					<view class="row"><text class="label">地址</text><text class="value">{{ safeText(form.address) }}</text></view>
					<view class="row"><text class="label">业务负责人</text><text class="value">{{ safeText(form.businessPrincipal) }}</text></view>
					<view class="row"><text class="label">职务</text><text class="value">{{ safeText(form.businessPrincipalPosition) }}</text></view>
					<view class="row"><text class="label">电话</text><text class="value">{{ safeText(form.businessPrincipalPhone) }}</text></view>
					<view class="row"><text class="label">法人与业务负责人关系</text><text class="value">{{ safeText(form.legalBusinessRelation) }}</text></view>
				</view>

				<view class="title-header">
					<image class="title-header_icon" src="/static/images/title.png" />
					<span>资产状况</span>
				</view>
				<view class="section">
					<view class="row"><text class="label">生产厂房及办公楼产权</text><text class="value">{{ safeText(form.factoryOfficeProperty) }}</text></view>
					<view class="row"><text class="label">生产厂房及办公楼面积</text><text class="value">{{ safeText(form.factoryOfficeArea) }}</text></view>
					<view class="row"><text class="label">仓库或货场产权</text><text class="value">{{ safeText(form.warehouseYardProperty) }}</text></view>
					<view class="row"><text class="label">仓库或货场产权面积</text><text class="value">{{ safeText(form.warehouseYardArea) }}</text></view>
					<view class="row"><text class="label">主要生产设备</text><text class="value pre">{{ safeText(form.mainEquipment) }}</text></view>
					<view class="row"><text class="label">正常库存量</text><text class="value">{{ safeText(form.normalInventory) }}</text></view>
				</view>

				<view class="title-header">
					<image class="title-header_icon" src="/static/images/title.png" />
					<span>生产经营环节风险调查</span>
				</view>
				<view class="section">
					<view class="row"><text class="label">主要品种</text><text class="value">{{ safeText(form.mainVarieties) }}</text></view>
					<view class="row"><text class="label">月度收购量</text><text class="value">{{ safeText(form.monthlyPurchaseVolume) }}</text></view>
					<view class="row"><text class="label">收购来源</text><text class="value">{{ safeText(purchaseSourceName) }}</text></view>
					<view class="row"><text class="label">入库品名</text><text class="value">{{ safeText(form.stockInProductName) }}</text></view>
					<view class="row"><text class="label">产品名称</text><text class="value">{{ safeText(form.productName) }}</text></view>
					<view class="row"><text class="label">产能</text><text class="value">{{ safeText(form.capacity) }}</text></view>
					<view class="row"><text class="label">销售渠道</text><text class="value">{{ safeText(form.salesChannel) }}</text></view>
					<view class="row"><text class="label">操作方式</text><text class="value">{{ safeText(operationModeName) }}</text></view>
					<view class="row"><text class="label">是否享有优惠政策</text><text class="value">{{ boolText(form.hasPreferentialPolicy) }}</text></view>
					<view class="row"><text class="label">是否投资期货</text><text class="value">{{ boolText(form.investInFutures) }}</text></view>
					<view class="row"><text class="label">是否有被处罚记录</text><text class="value">{{ boolText(form.hasPenaltyRecord) }}</text></view>
					<view class="row"><text class="label">经营范围是否相符</text><text class="value">{{ boolText(form.businessScopeMatch) }}</text></view>
					<view class="row"><text class="label">常见料质问题</text><text class="value pre">{{ safeText(form.commonMaterialIssue) }}</text></view>
					<view class="row"><text class="label">合作中的其它问题</text><text class="value pre">{{ safeText(form.otherIssue) }}</text></view>
				</view>

				<view class="title-header">
					<image class="title-header_icon" src="/static/images/title.png" />
					<span>与我司的合作状况</span>
				</view>
				<view class="section">
					<view class="row"><text class="label">首次合作年份</text><text class="value">{{ safeText(form.firstCooperationYear) }}</text></view>
					<view class="row"><text class="label">是否新开发</text><text class="value">{{ safeText(isNewDevelopmentName) }}</text></view>
					<view class="row"><text class="label">计划落空不良记录</text><text class="value">{{ boolText(form.hasFailedPlanRecord) }}</text></view>
					<view class="row"><text class="label">履行不到位现象</text><text class="value">{{ boolText(form.hasPlanPerformanceIssue) }}</text></view>
					<view class="row"><text class="label">进销账务如何处理</text><text class="value pre">{{ safeText(form.accountingProcess) }}</text></view>
					<view class="row"><text class="label">开票品名是否一致</text><text class="value">{{ boolText(form.invoiceNameMatch) }}</text></view>
					<view class="row"><text class="label">出库流程是否规范</text><text class="value">{{ boolText(form.outboundProcessStandard) }}</text></view>
					<view class="row"><text class="label">运输方式</text><text class="value">{{ safeText(form.transportMode) }}</text></view>
				</view>

				<view class="title-header">
					<image class="title-header_icon" src="/static/images/title.png" />
					<span>其他</span>
				</view>
				<view class="section">
					<view class="row"><text class="label">资信调查人</text><text class="value">{{ safeText(form.investigatorName) }}</text></view>
					<view class="row"><text class="label">采购处</text><text class="value">{{ safeText(purchaseDepartmentName) }}</text></view>
					<view class="row"><text class="label">评审有效期</text><text class="value">{{ safeText(form.reviewValidUntil) }}</text></view>
					<view class="row">
						<text class="label">附件</text>
						<view class="value">
							<view v-if="!attachments.length" class="value">-</view>
							<view v-for="item in attachments" :key="item.id || item.name" class="file-item" @click="onDownload(item)">
								<text class="value act">{{ item.name }}</text>
							</view>
						</view>
					</view>
				</view>
			</view>
		</scroll-view>
        <detail-buttons :buttons="displayButtons" @click="handleButtonClick" />
	</view>
</template>

<script>
import { downloadFile } from '@/utils/downloadFile.js'
import DetailButtons from '@/components/detail-buttons/index.vue'
import { getDicByCodes, getDicName } from '@/utils/dic.js'
import { domesticCustomerCreditCancelApi, domesticCustomerCreditGetApi } from '@/api/procure-manage/domesticCustomerCredit.js'
import { getPurchaseDeptApi } from '@/api/procure-manage/domesticCustomerCredit.js'

export default {
	name: 'DomesticTradeDetail',
    components: {
        DetailButtons
    },
	data() {
		return {
			id: '',
			loading: false,
			form: {},
			dicOptions: {
				COMPANY_NATURE: [],
				DEVELOP_NEW: [],
				OPERATION_METHOD: [],
				PURCHASE_SOURCE: []
			},
			purchaseDeptOptions: [],
            buttons: [{
				text: '审核详情',
				visible: true,
				variant: 'outline',
				event: 'auditDetail',
			},{
				text: '审核',
				visible: true,
				variant: 'primary',
				event: 'audit',
			},{
                text: '编辑',
                visible: true,
                variant: 'outline',
                event: 'edit',
            },{
                text: '取消',
                visible: true,
                variant: 'outline',
                event: 'cancel',
            }]
		}
	},
	computed: {
        displayButtons() {
			const s = this.form && this.form.status || false
            return [
                { ...this.buttons[0], visible: s  && this.$auth.hasPermi('procure-manage:domestic-trade:review') },
                { ...this.buttons[1], visible: s === 'AUDIT' && this.$auth.hasPermi('procure-manage:domestic-trade:approve') },
                { ...this.buttons[2], visible: this.$auth.hasPermi('procure-manage:domestic-trade:modify') },
                { ...this.buttons[3], visible: this.$auth.hasPermi('procure-manage:domestic-trade:cancel') },
            ]
        },
		companyNatureOptions() {
			return this.dicToSheetOptions(this.dicOptions.COMPANY_NATURE)
		},
		attachments() {
			const f = this.form || {}
			const ids = f.attachmentFileIds != null ? String(f.attachmentFileIds) : ''
			const names = f.attachmentFileNames != null ? String(f.attachmentFileNames) : ''
			const idArr = ids ? ids.split(',').map(s => s.trim()).filter(Boolean) : []
			const nameArr = names ? names.split(',') : []
			if (idArr.length) {
				return idArr.map((id, i) => ({ id, name: (nameArr[i] != null ? String(nameArr[i]) : '') }))
			}
			const legacy = Array.isArray(f.attachments) ? f.attachments : []
			return legacy.filter(it => it && (it.id || it.name)).map(it => ({ id: it.id || '', name: it.name || '' }))
		},
		showCompanyNatureOther() {
			const v = String((this.form && this.form.companyNature) || '')
			return v.split(',').includes('OTHER')
		},
		companyNatureName() {
			return this.safeText(this.form.companyNatureName) || this.labelsOf(this.companyNatureOptions, this.form.companyNature)
		},
		purchaseSourceName() {
			const v = this.form && this.form.purchaseSource != null ? String(this.form.purchaseSource) : ''
			return v ? getDicName('PURCHASE_SOURCE', v, this.dicOptions.PURCHASE_SOURCE) : '-'
		},
		operationModeName() {
			const v = this.form && this.form.operationMode != null ? String(this.form.operationMode) : ''
			return v ? getDicName('OPERATION_METHOD', v, this.dicOptions.OPERATION_METHOD) : '-'
		},
		isNewDevelopmentName() {
			const v = this.form && this.form.isNewDevelopment != null ? String(this.form.isNewDevelopment) : ''
			return v ? getDicName('DEVELOP_NEW', v, this.dicOptions.DEVELOP_NEW) : '-'
		},
		purchaseDepartmentName() {
			const v = this.form && this.form.purchaseDepartment != null ? String(this.form.purchaseDepartment) : ''
			if (!v) return '-'
			const found = (this.purchaseDeptOptions || []).find(o => String(o.value) === v)
			return found ? String(found.label || '') : v
		}
	},
	created() {
		this.loadDicData()
		this.loadPurchaseDeptOptions()
	},
	onShow() {
		const options = (this.$route && this.$route.query) ? this.$route.query : {}
		const id = options && options.id ? String(options.id) : ''
		this.id = id
		this.loadDetail()
	},
	methods: {
		async loadDicData() {
			try {
				const results = await getDicByCodes(['COMPANY_NATURE', 'DEVELOP_NEW', 'OPERATION_METHOD', 'PURCHASE_SOURCE'])
				this.dicOptions = {
					COMPANY_NATURE: (results.COMPANY_NATURE && results.COMPANY_NATURE.data) || [],
					DEVELOP_NEW: (results.DEVELOP_NEW && results.DEVELOP_NEW.data) || [],
					OPERATION_METHOD: (results.OPERATION_METHOD && results.OPERATION_METHOD.data) || [],
					PURCHASE_SOURCE: (results.PURCHASE_SOURCE && results.PURCHASE_SOURCE.data) || []
				}
			} catch (e) {
				this.dicOptions = { COMPANY_NATURE: [], DEVELOP_NEW: [], OPERATION_METHOD: [], PURCHASE_SOURCE: [] }
			}
		},
		async loadPurchaseDeptOptions() {
			try {
				const res = await getPurchaseDeptApi()
				const list = (res && res.data) ? res.data : []
				this.purchaseDeptOptions = (Array.isArray(list) ? list : []).map(it => ({
					label: it && it.name != null ? String(it.name) : '',
					value: it && it.id != null ? String(it.id) : ''
				})).filter(it => it.value)
			} catch (e) {
				this.purchaseDeptOptions = []
			}
		},
		dicToSheetOptions(items) {
			const list = Array.isArray(items) ? items : []
			return list.map(it => ({ label: it && it.name != null ? String(it.name) : '', value: it && it.code != null ? String(it.code) : '' })).filter(it => it.value)
		},
        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 === 'audit') return this.onAudit(btn && btn.params)
            if (e === 'auditDetail') return this.onAuditDetail(btn && btn.params)
            if (e === 'cancel') return this.onCancel(btn && btn.params)
        },
        onEdit(params) {
            uni.navigateTo({ url: '/pages/domestic_trade/modify?id=' + this.id })
        },
		onAudit(params) {
			const id = this.id || (this.form && this.form.id) || ''
			if (!id) return
			const CACHE_KEY = 'sourceBusinessId'
			const TYPE = 'contractType'
			uni.setStorageSync(TYPE, 'CUSTOMER_CREDIT_IN')
			uni.setStorageSync(CACHE_KEY, id)
			uni.navigateTo({ url: '/pages/flow/audit' })
		},
		onAuditDetail(params) {
			const id = this.id || (this.form && this.form.id) || ''
			if (!id) return
			const CACHE_KEY = 'sourceBusinessId'
			const TYPE = 'contractType'
			uni.setStorageSync(TYPE, 'CUSTOMER_CREDIT_IN')
			uni.setStorageSync(CACHE_KEY, id)
			uni.navigateTo({ url: '/pages/flow/audit_detail' })
		},
		onCancel(params) {
			const id = this.id || (this.form && this.form.id) || ''
			if (!id) return
			uni.showModal({
				title: '系统提示',
				content: '是否确定取消该流程?',
				confirmText: '确定',
				cancelText: '取消',
				success: (res) => {
					if (res && res.confirm) {
						domesticCustomerCreditCancelApi(id).then(() => {
							uni.showToast({ title: '已取消', icon: 'none' })
							try { uni.setStorageSync('DOMESTIC_TRADE_LIST_NEED_REFRESH', '1') } catch (e) {}
							setTimeout(() => { uni.redirectTo({ url: '/pages/domestic_trade/index' }) }, 300)
						}).catch((e) => {
							uni.showToast({ title: (e && e.msg) || '取消失败', icon: 'none' })
						})
					}
				}
			})
		},
		boolText(v) {
			if (v === true) return '是'
			if (v === false) return '否'
			return '-'
		},
		safeText(v) {
			const s = v == null ? '' : String(v)
			return s.trim() ? s : ''
		},
		labelsOf(options, csv) {
			const v = csv == null ? '' : String(csv)
			if (!v) return '-'
			const parts = v.split(',').filter(Boolean)
			if (!parts.length) return '-'
			const labels = []
			;(options || []).forEach(opt => {
				const ov = opt && opt.value != null ? String(opt.value) : ''
				if (ov && parts.includes(ov)) labels.push(opt.label != null ? String(opt.label) : '')
			})
			return labels.filter(Boolean).join(',') || '-'
		},
		async loadDetail() {
			this.loading = true
			try {
				const res = await domesticCustomerCreditGetApi(this.id)
				const data = (res && res.data) ? res.data : {}
				const u = (this.$store && this.$store.state && this.$store.state.user) ? this.$store.state.user : {}
				if (!data.investigatorName && data.investigatorId && u && String(u.id || '') === String(data.investigatorId || '')) {
					data.investigatorName = u && u.name ? String(u.name) : ''
				}
				this.form = data
			} catch (e) {
				this.form = {}
				uni.showToast({ title: '详情加载失败', icon: 'none' })
			} finally {
				this.loading = false
			}
		},
		onDownload(item) {
			if (!item || !item.id) return
			downloadFile(item.id, item.name || 'download')
		}
	}
}
</script>

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

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

.detail-page {
	background: #f3f3f3;
}

.title-header {
	display: flex;
	align-items: center;
	padding: 24rpx 32rpx 12rpx;

	.title-header_icon {
		width: 36rpx;
		height: 36rpx;
		margin-right: 12rpx;
	}

	span {
		font-size: 34rpx;
		font-weight: 600;
		color: rgba(0, 0, 0, 0.9);
	}
}

.section {
	padding: 32rpx;
	background: #fff;
	margin-bottom: 20rpx;
}

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

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

	&.company {
		font-size: 36rpx;
		font-weight: 600;
		color: rgba(0, 0, 0, 0.9);
		padding-top: 8rpx;
		line-height: 50rpx;
	}

	.label {
		max-width: 420rpx;
		margin-right: 20rpx;
		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;
		word-break: break-all;

		&.act {
			color: $theme-primary;
		}

		&.pre {
			white-space: pre-wrap;
		}
	}
}
.title-header {
    background-color: #ffffff;
}
.file-item {
	margin-bottom: 12rpx;

	&:last-child {
		margin-bottom: 0;
	}
}
</style>