From b4b1b8a3c275d7d0b7edf893788646494f667edf Mon Sep 17 00:00:00 2001 From: fengyuan_yang <1976974459@qq.com> Date: Tue, 25 Nov 2025 16:09:26 +0800 Subject: [PATCH] =?UTF-8?q?2025-11-25=20=E4=BB=93=E5=BA=93=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E5=A2=9E=E5=8A=A0"=E4=BB=93=E5=82=A8=E7=AD=96?= =?UTF-8?q?=E7=95=A5=E9=85=8D=E7=BD=AE=E3=80=81=E6=9D=83=E9=99=90=E6=8E=88?= =?UTF-8?q?=E6=9D=83"=E6=8C=89=E9=92=AE=201=E3=80=81=E4=BB=93=E5=82=A8?= =?UTF-8?q?=E7=AD=96=E7=95=A5=E9=85=8D=E7=BD=AE=20=20=201.1=E5=9F=BA?= =?UTF-8?q?=E7=A1=80=E6=95=B0=E6=8D=AE=E8=A1=A8=EF=BC=9AStorageZoneConfig?= =?UTF-8?q?=20=20=201.2=E4=BF=9D=E5=AD=98=E5=90=8E=E6=8F=92=E5=85=A5?= =?UTF-8?q?=EF=BC=9AWareHouseStorageZoneConfig=202=E3=80=81=E6=9D=83?= =?UTF-8?q?=E9=99=90=E6=8E=88=E6=9D=83=20=20=202.1AccessWarehouse?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/modules/warehouse/warehouse.vue | 925 +++++++++++++++++++++- 1 file changed, 916 insertions(+), 9 deletions(-) diff --git a/src/views/modules/warehouse/warehouse.vue b/src/views/modules/warehouse/warehouse.vue index 72c6545..00a2054 100644 --- a/src/views/modules/warehouse/warehouse.vue +++ b/src/views/modules/warehouse/warehouse.vue @@ -66,23 +66,24 @@ :show-overflow-tooltip="item.showOverflowTooltip" :align="item.align" :fixed="item.fixed==''?false:item.fixed" - :width="item.columnWidth" + :min-width="item.columnWidth" :label="item.columnLabel"> {{scope.row[item.columnProp]}} - + - {{buttons.edit}} - {{buttons.delete}} + {{buttons.edit}} | + {{buttons.delete}} | + 仓储策略配置 | + 权限授权 @@ -127,6 +128,313 @@ + + + + + + + + + + + + + + + 查询 + 重置 + + + + + + + + + + 可选策略 + ({{ availableConfigList.length }}) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 已配置策略 + ({{ selectedConfigList.length }}) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 查询 + 重置 + + + + + + + + + + 可选用户 + ({{ availableUserList.length }}) + + + + + + + + + + + + + + + + + + + + + + + + + + + + 已授权用户 + ({{ selectedUserList.length }}) + + + + + + + + + + + + + + + + @@ -268,7 +576,7 @@ import { tableName: "wareHouseTable", columnProp: "wareHouseName", headerAlign: "center", - align: "center", + align: "left", columnLabel: "仓库名称", columnHidden: false, columnImage: false, @@ -276,6 +584,7 @@ import { sortLv: 0, status: true, fixed: '', + columnWidth : 200, }, { userId: this.$store.state.user.name, @@ -292,6 +601,7 @@ import { sortLv: 0, status: true, fixed: '', + columnWidth : 80, }, { userId: this.$store.state.user.name, @@ -308,6 +618,7 @@ import { sortLv: 0, status: true, fixed: '', + columnWidth : 120, }, /* { userId: this.$store.state.user.name, @@ -358,6 +669,7 @@ import { sortLv: 0, status: true, fixed: '', + columnWidth : 80, }, ], // 展示列集 @@ -545,7 +857,30 @@ import { totalPage: 0, dataListLoading: false, dataListSelections: [], - addOrUpdateVisible: false + addOrUpdateVisible: false, + // 仓储策略配置相关 + storageConfigDialogVisible: false, + currentWarehouse: null, + availableConfigList: [], + availableConfigListAll: [], // 保存所有可选策略 + selectedConfigList: [], + availableConfigSelections: [], + selectedConfigSelections: [], + configQuery: { + configCode: '', + configName: '' + }, + // 权限授权相关 + accessAuthDialogVisible: false, + availableUserList: [], + availableUserListAll: [], // 保存所有可选用户 + selectedUserList: [], + availableUserSelections: [], + selectedUserSelections: [], + userQuery: { + username: '', + userDisplay: '' + } } }, mounted() { @@ -961,6 +1296,380 @@ import { }, finishDownload() { + }, + // ==================== 仓储策略配置 ==================== + // 打开仓储策略配置对话框 + async openStorageConfigDialog(row) { + this.currentWarehouse = row; + this.configQuery = { + configCode: '', + configName: '' + }; + this.storageConfigDialogVisible = true; + + // 加载可选策略列表和已配置策略列表 + await this.loadStorageConfigLists(); + }, + + // 加载仓储策略列表 + async loadStorageConfigLists() { + try { + // 加载可选策略(从StorageZoneConfig表) + const {data: availableData} = await this.$http({ + url: this.$http.adornUrl('warehouse/getStorageZoneConfigList'), + method: 'post', + data: this.$http.adornData({ + site: this.currentWarehouse.site + }) + }); + + // 加载已配置策略(从WareHouseStorageZoneConfig表) + const {data: selectedData} = await this.$http({ + url: this.$http.adornUrl('warehouse/getWarehouseStorageConfigList'), + method: 'post', + data: this.$http.adornData({ + site: this.currentWarehouse.site, + warehouseId: this.currentWarehouse.wareHouseId + }) + }); + + if (selectedData && selectedData.code === 0) { + this.selectedConfigList = selectedData.list || []; + } + + // 过滤掉已配置的策略 + if (availableData && availableData.code === 0) { + const selectedCodes = this.selectedConfigList.map(item => item.configCode); + this.availableConfigListAll = (availableData.list || []).filter(item => + !selectedCodes.includes(item.configCode) + ); + this.availableConfigList = this.availableConfigListAll; + } + } catch (error) { + this.$message.error('加载仓储策略列表失败'); + console.error(error); + } + }, + + // 查询可选策略 + searchAvailableConfigs() { + const configCode = this.configQuery.configCode.trim().toLowerCase(); + const configName = this.configQuery.configName.trim().toLowerCase(); + + if (!configCode && !configName) { + this.availableConfigList = this.availableConfigListAll; + return; + } + + this.availableConfigList = this.availableConfigListAll.filter(item => { + const matchCode = !configCode || (item.configCode && item.configCode.toLowerCase().includes(configCode)); + const matchName = !configName || (item.configName && item.configName.toLowerCase().includes(configName)); + return matchCode && matchName; + }); + }, + + // 重置策略查询 + resetConfigQuery() { + this.configQuery = { + configCode: '', + configName: '' + }; + this.availableConfigList = this.availableConfigListAll; + }, + + // 可选策略表格行点击 + availableConfigClickRow(row) { + this.$refs.availableConfigTable.toggleRowSelection(row); + }, + + // 可选策略选择变化 + availableConfigSelectionChange(val) { + this.availableConfigSelections = val; + }, + + // 已配置策略表格行点击 + selectedConfigClickRow(row) { + this.$refs.selectedConfigTable.toggleRowSelection(row); + }, + + // 已配置策略选择变化 + selectedConfigSelectionChange(val) { + this.selectedConfigSelections = val; + }, + + // 添加仓储策略 + async addStorageConfig() { + if (!this.availableConfigSelections || this.availableConfigSelections.length === 0) { + this.$message.warning('请选择要添加的策略'); + return; + } + + try { + const configList = this.availableConfigSelections.map(item => ({ + site: this.currentWarehouse.site, + buNo: this.currentWarehouse.buNo, + warehouseId: this.currentWarehouse.wareHouseId, + configCode: item.configCode, + active: 'Y', + remark: item.configName + (item.description ? ' - ' + item.description : '') + })); + + const {data} = await this.$http({ + url: this.$http.adornUrl('warehouse/saveWarehouseStorageConfig'), + method: 'post', + data: this.$http.adornData(configList, false) + }); + + if (data && data.code === 0) { + this.$message.success('添加成功'); + // 清空选择 + this.availableConfigSelections = []; + // 重新加载列表(会自动过滤) + await this.loadStorageConfigLists(); + // 如果有查询条件,重新应用查询 + if (this.configQuery.configCode || this.configQuery.configName) { + this.searchAvailableConfigs(); + } + } else { + this.$message.error(data.msg || '添加失败'); + } + } catch (error) { + this.$message.error('添加失败'); + console.error(error); + } + }, + + // 移除仓储策略 + async removeStorageConfig() { + if (!this.selectedConfigSelections || this.selectedConfigSelections.length === 0) { + this.$message.warning('请选择要移除的策略'); + return; + } + + this.$confirm('确定要移除选中的策略吗?', '提示', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning' + }).then(async () => { + try { + const configCodes = this.selectedConfigSelections.map(item => item.configCode); + + const {data} = await this.$http({ + url: this.$http.adornUrl('warehouse/deleteWarehouseStorageConfig'), + method: 'post', + data: this.$http.adornData({ + site: this.currentWarehouse.site, + warehouseId: this.currentWarehouse.wareHouseId, + configCodes: configCodes + }, false) + }); + + if (data && data.code === 0) { + this.$message.success('移除成功'); + // 清空选择 + this.selectedConfigSelections = []; + // 重新加载列表(会自动过滤) + await this.loadStorageConfigLists(); + // 如果有查询条件,重新应用查询 + if (this.configQuery.configCode || this.configQuery.configName) { + this.searchAvailableConfigs(); + } + } else { + this.$message.error(data.msg || '移除失败'); + } + } catch (error) { + this.$message.error('移除失败'); + console.error(error); + } + }).catch(() => {}); + }, + + // ==================== 权限授权 ==================== + // 打开权限授权对话框 + async openAccessAuthDialog(row) { + this.currentWarehouse = row; + this.userQuery = { + username: '', + userDisplay: '' + }; + this.accessAuthDialogVisible = true; + + // 加载用户列表 + await this.loadAccessAuthLists(); + }, + + // 加载权限授权列表 + async loadAccessAuthLists() { + try { + // 加载可选用户(从sys_user表) + const {data: availableData} = await this.$http({ + url: this.$http.adornUrl('sys/user/list'), + method: 'get', + params: this.$http.adornParams({ + page: 1, + limit: 10000 + }) + }); + + // 加载已授权用户(从AccessWarehouse表) + const {data: selectedData} = await this.$http({ + url: this.$http.adornUrl('warehouse/getAccessWarehouseList'), + method: 'post', + data: this.$http.adornData({ + site: this.currentWarehouse.site, + warehouseId: this.currentWarehouse.wareHouseId + }) + }); + + if (selectedData && selectedData.code === 0) { + this.selectedUserList = selectedData.list || []; + } + + // 过滤掉已授权的用户 + if (availableData && availableData.code === 0) { + const selectedUserIds = this.selectedUserList.map(item => item.userid); + this.availableUserListAll = (availableData.page.list || []).filter(item => + !selectedUserIds.includes(item.username) + ); + this.availableUserList = this.availableUserListAll; + } + } catch (error) { + this.$message.error('加载用户列表失败'); + console.error(error); + } + }, + + // 查询可选用户 + searchAvailableUsers() { + const username = this.userQuery.username.trim().toLowerCase(); + const userDisplay = this.userQuery.userDisplay.trim().toLowerCase(); + + if (!username && !userDisplay) { + this.availableUserList = this.availableUserListAll; + return; + } + + this.availableUserList = this.availableUserListAll.filter(item => { + const matchUsername = !username || (item.username && item.username.toLowerCase().includes(username)); + const matchDisplay = !userDisplay || (item.userDisplay && item.userDisplay.toLowerCase().includes(userDisplay)); + return matchUsername && matchDisplay; + }); + }, + + // 重置用户查询 + resetUserQuery() { + this.userQuery = { + username: '', + userDisplay: '' + }; + this.availableUserList = this.availableUserListAll; + }, + + // 可选用户表格行点击 + availableUserClickRow(row) { + this.$refs.availableUserTable.toggleRowSelection(row); + }, + + // 可选用户选择变化 + availableUserSelectionChange(val) { + this.availableUserSelections = val; + }, + + // 已授权用户表格行点击 + selectedUserClickRow(row) { + this.$refs.selectedUserTable.toggleRowSelection(row); + }, + + // 已授权用户选择变化 + selectedUserSelectionChange(val) { + this.selectedUserSelections = val; + }, + + // 添加权限授权 + async addAccessAuth() { + if (!this.availableUserSelections || this.availableUserSelections.length === 0) { + this.$message.warning('请选择要授权的用户'); + return; + } + + try { + const userList = this.availableUserSelections.map(item => ({ + site: this.currentWarehouse.site, + buNo: this.currentWarehouse.buNo, + warehouseId: this.currentWarehouse.wareHouseId, + userid: item.username, + userName: item.userDisplay + })); + + console.log(userList) + const {data} = await this.$http({ + url: this.$http.adornUrl('warehouse/saveAccessWarehouse'), + method: 'post', + data: this.$http.adornData(userList, false) + }); + + if (data && data.code === 0) { + this.$message.success('授权成功'); + // 清空选择 + this.availableUserSelections = []; + // 重新加载列表(会自动过滤) + await this.loadAccessAuthLists(); + // 如果有查询条件,重新应用查询 + if (this.userQuery.username || this.userQuery.userDisplay) { + this.searchAvailableUsers(); + } + } else { + this.$message.error(data.msg || '授权失败'); + } + } catch (error) { + this.$message.error('授权失败'); + console.error(error); + } + }, + + // 移除权限授权 + async removeAccessAuth() { + if (!this.selectedUserSelections || this.selectedUserSelections.length === 0) { + this.$message.warning('请选择要移除的用户'); + return; + } + + this.$confirm('确定要移除选中用户的授权吗?', '提示', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning' + }).then(async () => { + try { + const userIds = this.selectedUserSelections.map(item => item.userid); + + const {data} = await this.$http({ + url: this.$http.adornUrl('warehouse/deleteAccessWarehouse'), + method: 'post', + data: this.$http.adornData({ + site: this.currentWarehouse.site, + warehouseId: this.currentWarehouse.wareHouseId, + userIds: userIds + }, false) + }); + + if (data && data.code === 0) { + this.$message.success('移除成功'); + // 清空选择 + this.selectedUserSelections = []; + // 重新加载列表(会自动过滤) + await this.loadAccessAuthLists(); + // 如果有查询条件,重新应用查询 + if (this.userQuery.username || this.userQuery.userDisplay) { + this.searchAvailableUsers(); + } + } else { + this.$message.error(data.msg || '移除失败'); + } + } catch (error) { + this.$message.error('移除失败'); + console.error(error); + } + }).catch(() => {}); } }, created() { @@ -971,7 +1680,7 @@ import { } } -