Browse Source

物资-食材采购统计模块

huangguoce 20 hours atrás
parent
commit
43dd8773dc

+ 57 - 0
src/api/psi/FoodPurchaseService.js

@@ -10,6 +10,15 @@ export default class FoodPurchaseService {
 		});
 	}
 
+	exportFile(params) {
+		return request({
+			url: prefix + "/psi/foodPurchase/exportFile",
+			method: "get",
+			params,
+			responseType: "blob",
+		});
+	}
+
 	save(data) {
 		return request({
 			url: prefix + "/psi/foodPurchase/save",
@@ -18,6 +27,22 @@ export default class FoodPurchaseService {
 		});
 	}
 
+	saveChange(data) {
+		return request({
+			url: prefix + "/psi/foodPurchase/saveChange",
+			method: "post",
+			data,
+		});
+	}
+
+	approveChange(data) {
+		return request({
+			url: prefix + "/psi/foodPurchase/approveChange",
+			method: "post",
+			data,
+		});
+	}
+
 	findById(id) {
 		return request({
 			url: prefix + "/psi/foodPurchase/findById",
@@ -26,6 +51,30 @@ export default class FoodPurchaseService {
 		});
 	}
 
+	findChangeById(id) {
+		return request({
+			url: prefix + "/psi/foodPurchase/findChangeById",
+			method: "get",
+			params: { id },
+		});
+	}
+
+	prepareChange(sourceBasicId) {
+		return request({
+			url: prefix + "/psi/foodPurchase/prepareChange",
+			method: "get",
+			params: { sourceBasicId },
+		});
+	}
+
+	removeChange(id) {
+		return request({
+			url: prefix + "/psi/foodPurchase/removeChange",
+			method: "get",
+			params: { id },
+		});
+	}
+
 	remove(id) {
 		return request({
 			url: prefix + "/psi/foodPurchase/remove",
@@ -42,6 +91,14 @@ export default class FoodPurchaseService {
 		});
 	}
 
+	updateChangeStatusById(data) {
+		return request({
+			url: prefix + "/psi/foodPurchase/updateChangeStatusById",
+			method: "post",
+			data,
+		});
+	}
+
 	statistics(params) {
 		return request({
 			url: prefix + "/psi/foodPurchase/statistics",

+ 7 - 2
src/views/flowable/task/TaskForm.vue

@@ -744,6 +744,7 @@ export default {
 		// Process_1775013293806 进销存-领用申请
 		// Process_1775013611447 进销存-领用退回申请
 		// Process_1775549295075 进销存-报损申请
+		// Process_1776049799724 进销存-食材采购统计
 		// 驳回
 		reject(vars) {
 			if (this.procDefId.includes('Process_1667978088459') ||
@@ -846,7 +847,9 @@ export default {
 				this.procDefId.includes('Process_1775006048278') ||
 				this.procDefId.includes('Process_1775013293806') ||
 				this.procDefId.includes('Process_1775013611447') ||
-				this.procDefId.includes('Process_1775549295075')
+				this.procDefId.includes('Process_1775549295075') ||
+				this.procDefId.includes('Process_1776049799724')
+
 			) {
 				console.log('进入新版驳回')
 				this.$confirm(`确定驳回流程吗?`, '提示', {
@@ -1005,7 +1008,9 @@ export default {
 				this.procDefId.includes('Process_1775006048278') ||
 				this.procDefId.includes('Process_1775013293806') ||
 				this.procDefId.includes('Process_1775013611447') ||
-				this.procDefId.includes('Process_1775549295075')
+				this.procDefId.includes('Process_1775549295075') ||
+				this.procDefId.includes('Process_1776049799724')
+
 			) {
 				if (this.formType === '2') {
 					vars = { ...vars, agree: false }

File diff suppressed because it is too large
+ 681 - 340
src/views/psiManagement/foodPurchase/FoodPurchaseForm.vue


+ 215 - 278
src/views/psiManagement/foodPurchase/FoodPurchaseList.vue

@@ -1,92 +1,43 @@
 <template>
 	<div class="page">
-		<el-form
-			v-if="searchVisible"
-			ref="searchForm"
-			:model="searchForm"
-			:inline="true"
-			class="query-form m-b-10"
-			@keyup.enter.native="refreshList"
-			@submit.native.prevent
-		>
+		<el-form v-if="searchVisible" ref="searchForm" :model="searchForm" :inline="true" class="query-form m-b-10"
+			@keyup.enter.native="refreshList" @submit.native.prevent>
 			<el-form-item label="采购编号" prop="purchaseNo">
-				<el-input
-					v-model="searchForm.purchaseNo"
-					clearable
-					placeholder="请输入采购编号"
-				/>
+				<el-input v-model="searchForm.purchaseNo" clearable placeholder="请输入采购编号" />
 			</el-form-item>
 			<el-form-item label="采购人" prop="handledBy">
-				<UserSelect
-					:limit="1"
-					:modelValue="searchForm.handledBy"
-					@update:modelValue="
-						(value) => (searchForm.handledBy = value)
-					"
-				/>
+				<UserSelect :limit="1" :modelValue="searchForm.handledBy"
+					@update:modelValue="(value) => (searchForm.handledBy = value)" />
 			</el-form-item>
 			<el-form-item label="采购时间" prop="purchaseTimes">
-				<el-date-picker
-					v-model="searchForm.purchaseTimes"
-					type="datetimerange"
-					format="YYYY-MM-DD HH:mm:ss"
-					value-format="YYYY-MM-DD HH:mm:ss"
-					range-separator="至"
-					start-placeholder="开始时间"
-					end-placeholder="结束时间"
-					placement="bottom-start"
-				/>
-			</el-form-item>
-			<el-form-item
-				v-if="showHideItem"
-				label="采购部门"
-				prop="handledByOffice"
-			>
-				<SelectTree
-					ref="officeTree"
-					:props="{
-						value: 'id',
-						label: 'name',
-						children: 'children',
-					}"
-					:url="`/system-server/sys/office/treeData?type=2`"
-					:value="searchForm.handledByOffice"
-					size="default"
-					:accordion="true"
-					@getValue="(value) => (searchForm.handledByOffice = value)"
-				/>
+				<el-date-picker v-model="searchForm.purchaseTimes" type="datetimerange" format="YYYY-MM-DD HH:mm:ss"
+					value-format="YYYY-MM-DD HH:mm:ss" range-separator="至" start-placeholder="开始时间"
+					end-placeholder="结束时间" placement="bottom-start" />
 			</el-form-item>
+			<!-- <el-form-item v-if="showHideItem" label="采购部门" prop="handledByOffice">
+				<SelectTree ref="officeTree" :props="{
+					value: 'id',
+					label: 'name',
+					children: 'children',
+				}" :url="`/system-server/sys/office/treeData?type=2`" :value="searchForm.handledByOffice" size="default"
+					:accordion="true" @getValue="(value) => (searchForm.handledByOffice = value)" />
+			</el-form-item> -->
 			<el-form-item v-if="showHideItem" label="修改状态" prop="status">
-				<el-select
-					v-model="searchForm.status"
-					clearable
-					placeholder="请选择状态"
-					style="width: 100%"
-				>
-					<el-option
-						v-for="item in $dictUtils.getDictList('cw_status')"
-						:key="item.value"
-						:label="item.label"
-						:value="item.value"
-					/>
+				<el-select v-model="searchForm.status" clearable placeholder="请选择状态" style="width: 100%">
+					<el-option v-for="item in $dictUtils.getDictList('cw_status')" :key="item.value" :label="item.label"
+						:value="item.value" />
 				</el-select>
 			</el-form-item>
 			<el-form-item>
-				<el-button
-					type="default"
-					:icon="showHideIcon"
-					@click="showHide"
-					>{{ showHideName }}</el-button
-				>
-				<el-button
-					type="primary"
-					icon="el-icon-search"
-					@click="refreshList"
-					>查询</el-button
-				>
-				<el-button icon="el-icon-refresh-right" @click="resetSearch"
-					>重置</el-button
-				>
+				<el-button type="default" :icon="showHideIcon" @click="showHide">
+					{{ showHideName }}
+				</el-button>
+				<el-button type="primary" icon="el-icon-search" @click="refreshList">
+					查询
+				</el-button>
+				<el-button icon="el-icon-refresh-right" @click="resetSearch">
+					重置
+				</el-button>
 			</el-form-item>
 		</el-form>
 
@@ -95,108 +46,68 @@
 				<div class="statistics-label">当前筛选范围采购金额</div>
 				<div class="statistics-value">{{ statisticTotalPrice }}</div>
 			</div>
-			<el-button type="primary" plain @click="refreshStatistics"
-				>刷新统计</el-button
-			>
+			<el-button type="primary" plain @click="refreshStatistics">
+				刷新统计
+			</el-button>
 		</div>
 
 		<div class="jp-table top">
 			<vxe-toolbar :refresh="{ query: refreshList }" custom>
 				<template #buttons>
-					<el-button
-						v-if="hasPermission('psi:foodPurchase:add')"
-						type="primary"
-						icon="el-icon-plus"
-						@click="start"
-					>
+					<el-button v-if="hasPermission('psi:foodPurchase:add')" type="primary" icon="el-icon-plus"
+						@click="start">
 						新增
 					</el-button>
+					<el-button v-if="hasPermission('psi:foodPurchase:export')" type="warning" icon="el-icon-download"
+						plain @click="exportFile">
+						导出
+					</el-button>
 				</template>
 				<template #tools>
-					<vxe-button
-						text
-						type="primary"
-						icon="vxe-icon-search"
-						class="tool-btn"
-						:title="searchVisible ? '收起搜索' : '展开搜索'"
-						@click="searchVisible = !searchVisible"
-					/>
+					<vxe-button text type="primary" icon="vxe-icon-search" class="tool-btn"
+						:title="searchVisible ? '收起搜索' : '展开搜索'" @click="searchVisible = !searchVisible" />
 				</template>
 			</vxe-toolbar>
 
 			<div style="height: calc(100% - 90px)">
-				<vxe-table
-					ref="clientTable"
-					:key="tableKey"
-					border="inner"
-					auto-resize
-					resizable
-					height="auto"
-					:loading="loading"
-					show-header-overflow
-					show-overflow
-					highlight-hover-row
-					:menu-config="{}"
-					:sort-config="{ remote: true }"
-					:data="dataList"
-					:checkbox-config="{}"
-					@sort-change="sortChangeHandle"
-				>
+				<vxe-table ref="clientTable" :key="tableKey" border="inner" auto-resize resizable height="auto"
+					:loading="loading" show-header-overflow show-overflow highlight-hover-row :menu-config="{}"
+					:sort-config="{ remote: true }" :data="dataList" :checkbox-config="{}"
+					@sort-change="sortChangeHandle">
 					<vxe-column type="seq" width="60" title="序号" />
-					<vxe-column
-						min-width="180"
-						align="center"
-						title="采购编号"
-						field="purchaseNo"
-					>
+					<vxe-column min-width="180" align="center" title="采购编号" field="purchaseNo">
 						<template #default="scope">
-							<el-link
-								v-if="hasPermission('psi:foodPurchase:list')"
-								type="primary"
-								:underline="false"
-								@click="view(scope.row.id)"
-							>
+							<el-link v-if="hasPermission('psi:foodPurchase:list')" type="primary" :underline="false"
+								@click="view(scope.row.id)">
 								{{ scope.row.purchaseNo }}
 							</el-link>
 							<span v-else>{{ scope.row.purchaseNo }}</span>
 						</template>
 					</vxe-column>
-					<vxe-column
-						min-width="180"
-						align="center"
-						title="采购时间"
-						field="purchaseTime"
-					/>
-					<vxe-column
-						min-width="160"
-						align="center"
-						title="采购金额"
-						field="totalPrice"
-					/>
-					<vxe-column
-						min-width="160"
-						align="center"
-						title="采购人"
-						field="handledByName"
-					/>
-					<vxe-column
-						min-width="140"
-						align="center"
-						title="修改状态"
-						field="status"
-					>
+					<vxe-column min-width="180" align="center" title="采购时间" field="purchaseTime" />
+					<vxe-column min-width="160" align="center" title="采购金额" field="totalPrice" />
+					<!-- <vxe-column min-width="180" align="center" title="待变更时间" field="changePurchaseTime">
 						<template #default="scope">
-							<el-button
-								effect="dark"
-								:type="
-									$dictUtils.getDictLabel(
-										'cw_status_flag',
-										scope.row.status,
-										''
-									)
-								"
-								@click="detail(scope.row)"
-							>
+							<span v-if="scope.row.status != '5' && scope.row.status != '0'">
+								{{ scope.row.changePurchaseTime }}
+							</span>
+							<span v-else class="text-gray">-</span>
+						</template>
+					</vxe-column>
+					<vxe-column min-width="160" align="center" title="待变更金额" field="changeTotalPrice">
+						<template #default="scope">
+							<span v-if="scope.row.status != '5' && scope.row.status != '0'">
+								{{ scope.row.changeTotalPrice }}
+							</span>
+							<span v-else class="text-gray">-</span>
+						</template>
+					</vxe-column> -->
+					<vxe-column min-width="160" align="center" title="采购人" field="handledByName" />
+					<vxe-column min-width="140" align="center" title="修改状态" field="status">
+						<template #default="scope">
+							<el-button effect="dark"
+								:type="$dictUtils.getDictLabel('cw_status_flag', scope.row.status, '')"
+								@click="detail(scope.row)">
 								{{
 									$dictUtils.getDictLabel(
 										"cw_status",
@@ -207,106 +118,67 @@
 							</el-button>
 						</template>
 					</vxe-column>
-					<vxe-column
-						title="操作"
-						width="240"
-						fixed="right"
-						align="center"
-					>
+					<vxe-column title="操作" width="320" fixed="right" align="center">
 						<template #default="scope">
-							<el-button
-								v-if="
-									hasPermission('psi:foodPurchase:edit') &&
-									['0', '1', '3', '5'].includes(
-										scope.row.status || '0'
-									)
-								"
-								text
-								type="primary"
-								size="small"
-								@click="push(scope.row)"
-							>
-								修改
+							<el-button v-if="
+								hasPermission('psi:foodPurchase:edit') &&
+								['0', '1', '3', '5'].includes(scope.row.status || '0')
+							" text type="primary" size="small" @click="push(scope.row)">
+								申请修改
 							</el-button>
-							<el-button
-								v-if="
-									hasPermission('psi:foodPurchase:edit') &&
-									scope.row.status === '4'
-								"
-								text
-								type="primary"
-								size="small"
-								@click="adjust(scope.row)"
-							>
+							<el-button v-if="
+								hasPermission('psi:foodPurchase:edit') &&
+								scope.row.status === '4'
+							" text type="primary" size="small" @click="adjust(scope.row)">
 								驳回调整
 							</el-button>
-							<el-button
-								v-if="
-									hasPermission('psi:foodPurchase:edit') &&
-									scope.row.status === '2'
-								"
-								text
-								type="primary"
-								size="small"
-								@click="reback(scope.row)"
-							>
+							<el-button v-if="
+								hasPermission('psi:foodPurchase:edit') &&
+								scope.row.status === '2'
+							" text type="primary" size="small" @click="reback(scope.row)">
 								撤回
 							</el-button>
-							<el-button
-								v-if="
-									hasPermission('psi:foodPurchase:del') &&
-									scope.row.status !== '2'
-								"
-								text
-								type="primary"
-								size="small"
-								@click="del(scope.row.id)"
-							>
+							<el-button v-if="
+								hasPermission('psi:foodPurchase:edit') &&
+								scope.row.changeId &&
+								['1', '3', '4'].includes(scope.row.status || '')
+							" text type="primary" size="small" @click="terminateChange(scope.row)">
+								终止申请
+							</el-button>
+							<el-button v-if="
+								hasPermission('psi:foodPurchase:del') &&
+								!scope.row.changeId &&
+								scope.row.status !== '2'
+							" text type="primary" size="small" @click="del(scope.row.id)">
 								删除
 							</el-button>
-							<el-button
-								v-if="
-									scope.row.status === '2' &&
-									checkIsAudit(scope.row)
-								"
-								text
-								type="primary"
-								size="small"
-								@click="examine(scope.row)"
-							>
+							<el-button v-if="
+								scope.row.status === '2' &&
+								checkIsAudit(scope.row)
+							" text type="primary" size="small" @click="examine(scope.row)">
 								审核
 							</el-button>
 						</template>
 					</vxe-column>
 				</vxe-table>
 
-				<vxe-pager
-					background
-					:current-page="tablePage.currentPage"
-					:page-size="tablePage.pageSize"
-					:total="tablePage.total"
-					:page-sizes="[
+				<vxe-pager background :current-page="tablePage.currentPage" :page-size="tablePage.pageSize"
+					:total="tablePage.total" :page-sizes="[
 						10,
 						20,
 						100,
 						1000,
 						{ label: '全量数据', value: 1000000 },
-					]"
-					:layouts="[
+					]" :layouts="[
 						'PrevPage',
 						'JumpNumber',
 						'NextPage',
 						'FullJump',
 						'Sizes',
 						'Total',
-					]"
-					@page-change="currentChangeHandle"
-				/>
+					]" @page-change="currentChangeHandle" />
 
-				<UpdateFoodPurchaseForm
-					ref="updateFoodPurchaseForm"
-					@refreshList="refreshList"
-				/>
+				<UpdateFoodPurchaseForm ref="updateFoodPurchaseForm" @refreshList="refreshList" />
 			</div>
 		</div>
 	</div>
@@ -371,6 +243,9 @@ export default {
 		this.refreshList();
 	},
 	methods: {
+		getEditBusinessTable() {
+			return "psi_management_food_purchase_change";
+		},
 		showHide() {
 			this.showHideItem = !this.showHideItem;
 			this.showHideIcon = this.showHideItem
@@ -408,7 +283,7 @@ export default {
 				});
 			this.refreshStatistics();
 			this.checkIsAdmin();
-			processService.getByName("进销存-食材采购修改").then((data) => {
+			processService.getByName("食材采购统计-修改").then((data) => {
 				if (!this.commonJS.isEmpty(data.id)) {
 					this.processDefinitionAuditId = data.id;
 					this.procDefAuditKey = data.key;
@@ -470,43 +345,45 @@ export default {
 			} else if (row.status === "4") {
 				status = "reapplyFlag";
 			}
-			taskService
-				.getTaskDef({
-					procDefId: this.processDefinitionAuditId,
-					businessId: row.id,
-					businessTable: "psi_management_food_purchase_basic",
-				})
-				.then((data) => {
-					this.$router.push({
-						path: "/flowable/task/TaskForm",
-						query: {
-							...pick(
-								data,
-								"formType",
-								"formUrl",
-								"procDefKey",
-								"taskDefKey",
-								"procInsId",
-								"procDefId",
-								"taskId",
-								"status",
-								"title"
-							),
-							procDefId: this.processDefinitionAuditId,
-							procDefKey: this.procDefAuditKey,
-							title,
-							formType: data.formType,
-							formUrl: data.formUrl,
-							formTitle: processTitle,
-							businessTable: "psi_management_food_purchase_basic",
-							businessId: row.id,
-							isShow: "false",
-							status,
-							routePath:
-								"/psiManagement/foodPurchase/FoodPurchaseList",
-						},
+			this.foodPurchaseService.prepareChange(row.id).then((biz) => {
+				taskService
+					.getTaskDef({
+						procDefId: this.processDefinitionAuditId,
+						businessId: biz.businessId,
+						businessTable: this.getEditBusinessTable(),
+					})
+					.then((data) => {
+						this.$router.push({
+							path: "/flowable/task/TaskForm",
+							query: {
+								...pick(
+									data,
+									"formType",
+									"formUrl",
+									"procDefKey",
+									"taskDefKey",
+									"procInsId",
+									"procDefId",
+									"taskId",
+									"status",
+									"title"
+								),
+								procDefId: this.processDefinitionAuditId,
+								procDefKey: this.procDefAuditKey,
+								title,
+								formType: data.formType,
+								formUrl: data.formUrl,
+								formTitle: processTitle,
+								businessTable: this.getEditBusinessTable(),
+								businessId: biz.businessId,
+								isShow: "false",
+								status,
+								routePath:
+									"/psiManagement/foodPurchase/FoodPurchaseList",
+							},
+						});
 					});
-				});
+			});
 		},
 		detail(row) {
 			if (!row.procInsId || ["0", "1"].includes(row.status || "0")) {
@@ -537,7 +414,10 @@ export default {
 							readOnly: true,
 							title: "食材采购修改流程详情",
 							formTitle: "食材采购修改流程详情",
-							businessId: row.id,
+							businessId: row.changeId || row.id,
+							businessTable: row.changeId
+								? this.getEditBusinessTable()
+								: "psi_management_food_purchase_basic",
 							status: "reback",
 						},
 					});
@@ -549,7 +429,7 @@ export default {
 				cancelButtonText: "取消",
 				type: "warning",
 			}).then(() => {
-				this.foodPurchaseService.findById(row.id).then((data) => {
+				this.foodPurchaseService.findChangeById(row.changeId).then((data) => {
 					if (data.status !== "2") {
 						this.$message.error("数据已发生变化,请刷新后重试");
 						this.refreshList();
@@ -557,7 +437,10 @@ export default {
 					}
 					processService.revokeProcIns(row.procInsId).then((msg) => {
 						this.foodPurchaseService
-							.updateStatusById({ status: "3", id: row.id })
+							.updateChangeStatusById({
+								status: "3",
+								id: row.changeId,
+							})
 							.then(() => {
 								this.$message.success(msg);
 								this.refreshList();
@@ -566,27 +449,58 @@ export default {
 				});
 			});
 		},
+		terminateChange(row) {
+			this.$confirm("确定终止该修改申请吗?终止后会删除修改数据,并恢复展示原始数据。", "提示", {
+				confirmButtonText: "确定",
+				cancelButtonText: "取消",
+				type: "warning",
+			}).then(async () => {
+				try {
+					if (!row.changeId) {
+						this.$message.error("修改单不存在,请刷新后重试");
+						this.refreshList();
+						return;
+					}
+					const changeData = await this.foodPurchaseService.findChangeById(row.changeId);
+					if (this.commonJS.isEmpty(changeData.id)) {
+						this.$message.error("修改单不存在,请刷新后重试");
+						this.refreshList();
+						return;
+					}
+					if (changeData.status === "2" && row.procInsId) {
+						await processService.stop(row.procInsId, "终止食材采购修改申请");
+					}
+					const msg = await this.foodPurchaseService.removeChange(row.changeId);
+					this.$message.success(msg || "操作成功");
+					this.refreshList();
+				} catch (error) {
+					if (error) {
+						this.refreshList();
+					}
+				}
+			});
+		},
 		adjust(row) {
-			this.foodPurchaseService.findById(row.id).then((data) => {
+			this.foodPurchaseService.findChangeById(row.changeId).then((data) => {
 				if (data.status !== "4") {
 					this.$message.error("数据已发生变化,请刷新后重试");
 					this.refreshList();
 					return;
 				}
-				this.todo(row);
+				this.todo(row, false);
 			});
 		},
 		examine(row) {
-			this.foodPurchaseService.findById(row.id).then((data) => {
+			this.foodPurchaseService.findChangeById(row.changeId).then((data) => {
 				if (data.status !== "2") {
 					this.$message.error("数据已发生变化,请刷新后重试");
 					this.refreshList();
 					return;
 				}
-				this.todo(row);
+				this.todo(row, true);
 			});
 		},
-		todo(row) {
+		todo(row, formReadOnly = true) {
 			taskService.getTaskDefInfo({ taskId: row.taskId }).then((data) => {
 				this.$router.push({
 					path: "/flowable/task/TaskForm",
@@ -605,10 +519,11 @@ export default {
 							"businessId"
 						),
 						isShow: false,
-						formReadOnly: true,
+						formReadOnly,
 						formTitle: `${data.taskName}`,
 						cUser: false,
 						title: `审批【${data.taskName || ""}】`,
+						businessTable: this.getEditBusinessTable(),
 						routePath:
 							"/psiManagement/foodPurchase/FoodPurchaseList",
 					},
@@ -622,6 +537,28 @@ export default {
 			}
 			return false;
 		},
+		exportFile() {
+			const options = {
+				filename: `${this.moment(new Date()).format("YYYY-MM-DD")}食材采购数据导出`,
+				sheetName: "食材采购数据导出",
+				mode: "all",
+			};
+			this.loading = true;
+			this.foodPurchaseService
+				.exportFile({
+					current: this.tablePage.currentPage,
+					size: this.tablePage.pageSize,
+					orders: this.tablePage.orders,
+					...options,
+					...this.searchForm,
+				})
+				.then((res) => {
+					this.$utils.downloadExcel(res, options.filename);
+				})
+				.finally(() => {
+					this.loading = false;
+				});
+		},
 	},
 };
 </script>