index.vue 15.9 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 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575
<template>
	<div class="NCC-common-layout">
		<div class="NCC-common-layout-center">
			<!-- 查询条件 -->
			<el-row class="NCC-common-search-box" :gutter="16">
				<el-form @submit.native.prevent>
					<el-col :span="6">
						<el-form-item label="流水类型">
							<el-select v-model="query.flowType" placeholder="请选择流水类型" clearable>
								<el-option label="送出" :value="0" />
								<el-option label="送回" :value="1" />
							</el-select>
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="批次号">
							<el-input v-model="query.batchNumber" placeholder="请输入批次号" clearable />
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="门店">
							<el-select v-model="query.storeId" placeholder="请选择门店" clearable filterable>
								<el-option v-for="item in storeList" :key="item.id" :label="item.fullName" :value="item.id" />
							</el-select>
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="产品类型">
							<el-input v-model="query.productType" placeholder="请输入产品类型" clearable />
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="清洗商">
							<el-select v-model="query.laundrySupplierId" placeholder="请选择清洗商" clearable filterable>
								<el-option v-for="item in supplierList" :key="item.id" :label="item.supplierName+'('+item.productType+')'" :value="item.id" />
							</el-select>
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="开始时间">
							<el-date-picker v-model="query.startTime" type="datetime" placeholder="选择开始时间" value-format="yyyy-MM-dd HH:mm:ss" style="width: 100%" />
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="结束时间">
							<el-date-picker v-model="query.endTime" type="datetime" placeholder="选择结束时间" value-format="yyyy-MM-dd HH:mm:ss" style="width: 100%" />
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label="是否有效">
							<el-select v-model="query.isEffective" placeholder="是否有效" clearable>
								<el-option label="有效" :value="1" />
								<el-option label="无效" :value="0" />
							</el-select>
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item>
							<el-button type="primary" icon="el-icon-search" @click="search()">查询</el-button>
							<el-button icon="el-icon-refresh-right" @click="reset()">重置</el-button>
						</el-form-item>
					</el-col>
				</el-form>
			</el-row>
			<!-- 列表 -->
			<div class="NCC-common-layout-main NCC-flex-main">
				<div class="NCC-common-head">
					<div>
						<el-button type="primary" icon="el-icon-plus" @click="addSend()">创建送出记录</el-button>
						<el-button type="success" icon="el-icon-refresh" @click="addReturn()">创建送回记录</el-button>
						<el-button type="warning" icon="el-icon-warning" @click="viewDifference()">查看差异记录</el-button>
						<span class="total-price-sum">
							<i class="el-icon-money"></i>
							总费用合计:<strong>{{ totalPriceSum }}</strong>
						</span>
					</div>
					<div class="NCC-common-head-right">
						<el-tooltip effect="dark" content="刷新" placement="top">
							<el-link icon="icon-ym icon-ym-Refresh NCC-common-head-icon" :underline="false"
								@click="initData()" />
						</el-tooltip>
						<screenfull isContainer />
					</div>
				</div>
				<NCC-table v-loading="loading" :data="list"
					:header-cell-style="{ background: '#f5f7fa', color: '#606266' }">
					<el-table-column label="流水类型" align="center" width="100">
						<template slot-scope="scope">
							<el-tag :type="scope.row.flowType === 0 ? 'primary' : 'success'" size="small">
								<i :class="scope.row.flowType === 0 ? 'el-icon-upload2' : 'el-icon-download'" style="margin-right: 4px;"></i>
								{{ scope.row.flowTypeName || '无' }}
							</el-tag>
						</template>
					</el-table-column>
					<el-table-column label="批次号" align="center" width="180">
						<template slot-scope="scope">
							<div class="batch-info">
								<i class="el-icon-tickets batch-icon"></i>
								<span class="text-nowrap">{{ scope.row.batchNumber || '无' }}</span>
							</div>
						</template>
					</el-table-column>
					<el-table-column label="门店名称" align="center" width="180">
						<template slot-scope="scope">
							<div class="store-info">
								<i class="el-icon-office-building store-icon"></i>
								<span class="text-nowrap">{{ scope.row.storeName || '无' }}</span>
							</div>
						</template>
					</el-table-column>
					<el-table-column label="产品类型" align="center" width="100">
						<template slot-scope="scope">
							<div class="product-type-info">
								<i class="el-icon-goods product-type-icon"></i>
								<span class="text-nowrap">{{ scope.row.productType || '无' }}</span>
							</div>
						</template>
					</el-table-column>
					<el-table-column label="清洗商名称" align="center">
						<template slot-scope="scope">
							<div class="supplier-info">
								<i class="el-icon-s-shop supplier-icon"></i>
								<span class="text-nowrap">{{ scope.row.laundrySupplierName || '无' }}</span>
							</div>
						</template>
					</el-table-column>
					<el-table-column label="数量" align="center" width="100">
						<template slot-scope="scope">
							<div class="quantity-info">
								<i class="el-icon-s-data quantity-icon"></i>
								<span>{{ scope.row.quantity || 0 }}</span>
							</div>
						</template>
					</el-table-column>
					<el-table-column label="清洗单价" align="center" width="120">
						<template slot-scope="scope">
							<div class="price-info">
								<i class="el-icon-coin price-icon"></i>
								<span>{{ scope.row.laundryPrice || 0 }}</span>
							</div>
						</template>
					</el-table-column>
					<el-table-column label="总费用" align="center" width="120">
						<template slot-scope="scope">
							<div class="total-price-info" v-if="scope.row.flowType === 0">
								<i class="el-icon-money total-price-icon"></i>
								<span>{{ scope.row.totalPrice || 0 }}</span>
							</div>
							<span v-else>无</span>
						</template>
					</el-table-column>
					<el-table-column label="备注" align="center" min-width="150">
						<template slot-scope="scope">
							<div class="remark-info">
								<i class="el-icon-document remark-icon"></i>
								<span class="text-nowrap">{{ scope.row.remark || '无' }}</span>
							</div>
						</template>
					</el-table-column>
					<el-table-column label="是否有效" align="center" width="100">
						<template slot-scope="scope">
							<el-tag :type="scope.row.isEffective === 1 ? 'success' : 'info'" size="small">
								{{ scope.row.isEffective === 1 ? '有效' : '无效' }}
							</el-tag>
						</template>
					</el-table-column>
					<el-table-column label="创建人" align="center">
						<template slot-scope="scope">
							<div class="user-info">
								<i class="el-icon-user user-icon"></i>
								<span class="text-nowrap">{{ scope.row.createUserName || '无' }}</span>
							</div>
						</template>
					</el-table-column>
					<el-table-column label="送出/送回时间" align="center" width="180">
						<template slot-scope="scope">
							<div class="time-info">
								<i class="el-icon-time time-icon"></i>
								<span class="text-nowrap">
									{{ scope.row.flowType === 0 
										? (scope.row.sendTime ? formatDateTime(scope.row.sendTime) : '无')
										: (scope.row.returnTime ? formatDateTime(scope.row.returnTime) : '无')
									}}
								</span>
							</div>
						</template>
					</el-table-column>
					<el-table-column label="创建时间" align="center" width="180" prop="createTime">
						<template slot-scope="scope">
							<div class="time-info">
								<i class="el-icon-time time-icon"></i>
								<span class="text-nowrap">{{ formatDateTime(scope.row.createTime) || '无' }}</span>
							</div>
						</template>
					</el-table-column>
					<el-table-column label="操作" width="200" align="left" fixed="right">
						<template slot-scope="scope">
							<div class="action-buttons">
								<el-button type="text" icon="el-icon-view" @click="viewDetail(scope.row)" class="view-btn">
									详情
								</el-button>
								<el-button type="text" icon="el-icon-edit" @click="editRecord(scope.row)" class="edit-btn">
									编辑
								</el-button>
								<el-button type="text" icon="el-icon-close" @click="cancelRecord(scope.row)" class="cancel-btn">
									作废
								</el-button>
							</div>
						</template>
					</el-table-column>
				</NCC-table>
				<pagination :total="total" :page.sync="query.currentPage"
					:limit.sync="query.pageSize" @pagination="initData" />
			</div>
		</div>
		<!-- 送出记录弹窗 -->
		<SendDialog v-if="sendDialogVisible" ref="SendDialog" @refresh="refresh" />
		<!-- 送回记录弹窗 -->
		<ReturnDialog v-if="returnDialogVisible" ref="ReturnDialog" @refresh="refresh" />
		<!-- 详情弹窗 -->
		<DetailDialog v-if="detailDialogVisible" ref="DetailDialog" />
		<!-- 差异记录弹窗 -->
		<DifferenceDialog v-if="differenceDialogVisible" ref="DifferenceDialog" />
		<!-- 编辑弹窗 -->
		<EditDialog v-if="editDialogVisible" ref="EditDialog" @refresh="refresh" />
		<!-- 作废弹窗 -->
		<CancelDialog v-if="cancelDialogVisible" ref="CancelDialog" @refresh="refresh" />
	</div>
</template>

<script>
import request from '@/utils/request'
import { getStoreSelector } from '@/api/extend/store'
import SendDialog from './send-dialog.vue'
import ReturnDialog from './return-dialog.vue'
import DetailDialog from './detail-dialog.vue'
import DifferenceDialog from './difference-dialog.vue'
import EditDialog from './edit-dialog.vue'
import CancelDialog from './cancel-dialog.vue'

export default {
	components: { SendDialog, ReturnDialog, DetailDialog, DifferenceDialog, EditDialog, CancelDialog },
	data() {
		return {
			list: [],
			loading: false,
			total: 0,
			query: {
				currentPage: 1,
				pageSize: 20,
				flowType: undefined,
				batchNumber: undefined,
				storeId: undefined,
				productType: undefined,
				laundrySupplierId: undefined,
				startTime: undefined,
				endTime: undefined,
				isEffective: undefined
			},
			storeList: [],
			supplierList: [],
			sendDialogVisible: false,
			returnDialogVisible: false,
			detailDialogVisible: false,
			differenceDialogVisible: false,
			editDialogVisible: false,
			cancelDialogVisible: false
		}
	},
	computed: {
		// 计算总费用合计(只计算送出类型的记录)
		totalPriceSum() {
			return this.list
				.filter(item => item.flowType === 0) // 只计算送出类型
				.reduce((sum, item) => {
					const price = parseFloat(item.totalPrice) || 0
					return sum + price
				}, 0)
				.toFixed(2)
		}
	},
	created() {
		this.initStoreList()
		this.initSupplierList()
		this.initData()
	},
	methods: {
		// 初始化门店列表
		initStoreList() {
			getStoreSelector().then(res => {
				if (res.code == 200 && res.data && res.data.list) {
					this.storeList = res.data.list
				}
			}).catch(() => {
				this.storeList = []
			})
		},
		// 初始化清洗商列表
		initSupplierList() {
			request({
				url: '/api/Extend/LqLaundrySupplier/GetList',
				method: 'GET',
				data: { currentPage: 1, pageSize: 1000, isEffective: 1 }
			}).then(res => {
				if (res.code == 200 && res.data && res.data.list) {
					this.supplierList = res.data.list
				}
			}).catch(() => {
				this.supplierList = []
			})
		},
		// 初始化数据
		initData() {
			this.loading = true
			let query = { ...this.query }
			// 移除空值
			Object.keys(query).forEach(key => {
				if (query[key] === undefined || query[key] === null || query[key] === '') {
					delete query[key]
				}
			})
			request({
				url: '/api/Extend/LqLaundryFlow/GetList',
				method: 'GET',
				data: query
			}).then(res => {
				if (res.code == 200 && res.data) {
					this.list = res.data.list || []
					this.total = res.data.pagination ? res.data.pagination.total : 0
				} else {
					this.list = []
					this.total = 0
				}
				this.loading = false
			}).catch(() => {
				this.loading = false
				this.list = []
				this.total = 0
			})
		},
		// 查询
		search() {
			this.query.currentPage = 1
			this.initData()
		},
		// 重置
		reset() {
			this.query = {
				currentPage: 1,
				pageSize: 20,
				flowType: undefined,
				batchNumber: undefined,
				storeId: undefined,
				productType: undefined,
				laundrySupplierId: undefined,
				startTime: undefined,
				endTime: undefined,
				isEffective: undefined
			}
			this.initData()
		},
		// 创建送出记录
		addSend() {
			this.sendDialogVisible = true
			this.$nextTick(() => {
				this.$refs.SendDialog.init()
			})
		},
		// 创建送回记录
		addReturn() {
			this.returnDialogVisible = true
			this.$nextTick(() => {
				this.$refs.ReturnDialog.init()
			})
		},
		// 查看详情
		viewDetail(row) {
			this.detailDialogVisible = true
			this.$nextTick(() => {
				this.$refs.DetailDialog.init(row.id)
			})
		},
		// 查看差异记录
		viewDifference() {
			this.differenceDialogVisible = true
			this.$nextTick(() => {
				this.$refs.DifferenceDialog.init()
			})
		},
		// 编辑记录
		editRecord(row) {
			this.editDialogVisible = true
			this.$nextTick(() => {
				this.$refs.EditDialog.init(row)
			})
		},
		// 作废记录
		cancelRecord(row) {
			this.cancelDialogVisible = true
			this.$nextTick(() => {
				this.$refs.CancelDialog.init(row)
			})
		},
		// 刷新
		refresh() {
			this.sendDialogVisible = false
			this.returnDialogVisible = false
			this.editDialogVisible = false
			this.cancelDialogVisible = false
			this.initData()
		},
		// 格式化日期时间
		formatDateTime(dateTime) {
			if (!dateTime) return ''
			const date = new Date(dateTime)
			const year = date.getFullYear()
			const month = String(date.getMonth() + 1).padStart(2, '0')
			const day = String(date.getDate()).padStart(2, '0')
			const hours = String(date.getHours()).padStart(2, '0')
			const minutes = String(date.getMinutes()).padStart(2, '0')
			const seconds = String(date.getSeconds()).padStart(2, '0')
			return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`
		}
	}
}
</script>

<style lang="scss" scoped>
// 通用文本不换行样式
.text-nowrap {
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	max-width: 100%;
}

// 信息显示样式
.batch-info,
.store-info,
.product-type-info,
.supplier-info,
.quantity-info,
.price-info,
.total-price-info,
.remark-info,
.user-info,
.time-info {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
}

.batch-icon {
	color: #409EFF;
	font-size: 16px;
}

.store-icon {
	color: #409EFF;
	font-size: 16px;
}

.product-type-icon {
	color: #67C23A;
	font-size: 16px;
}

.supplier-icon {
	color: #409EFF;
	font-size: 16px;
}

.quantity-icon {
	color: #E6A23C;
	font-size: 16px;
}

.price-icon {
	color: #E6A23C;
	font-size: 16px;
}

.total-price-icon {
	color: #F56C6C;
	font-size: 16px;
}

.remark-icon {
	color: #909399;
	font-size: 16px;
}

.user-icon {
	color: #909399;
	font-size: 16px;
}

.time-icon {
	color: #909399;
	font-size: 16px;
}

// 总费用合计样式
.total-price-sum {
	margin-left: 20px;
	padding: 8px 16px;
	background-color: #f0f9ff;
	border: 1px solid #409EFF;
	border-radius: 4px;
	color: #409EFF;
	font-size: 14px;
	display: inline-flex;
	align-items: center;
	gap: 6px;

	i {
		font-size: 16px;
	}

	strong {
		color: #F56C6C;
		font-size: 16px;
		font-weight: 600;
	}
}

// 操作按钮样式
.action-buttons {
	display: flex;
	align-items: center;
	gap: 8px;
}

.view-btn {
	color: #409EFF;

	&:hover {
		color: #66b1ff;
	}
}

.edit-btn {
	color: #409EFF;

	&:hover {
		color: #66b1ff;
	}
}

.cancel-btn {
	color: #F56C6C;

	&:hover {
		color: #f78989;
	}
}

// 表格行悬停效果
::v-deep .el-table__row:hover {
	background-color: #f5f7fa;
}

// 表格头部样式
::v-deep .el-table__header-wrapper {
	.el-table__header {
		th {
			background-color: #f5f7fa;
			color: #606266;
			font-weight: 600;
		}
	}
}
</style>