From fd210e8f352a51c722f902f80ed294134a04458c Mon Sep 17 00:00:00 2001 From: wenlele Date: Tue, 13 Jun 2023 09:00:55 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=A1=E6=89=B9=E4=BA=BA=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/app/lib/controllers/resourceConsumption/index.js | 7 ++++++- api/app/lib/index.js | 4 +++- .../src/sections/resourceConsumption/containers/approve.js | 2 +- .../resourceConsumption/containers/myApplication.js | 6 +++--- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/api/app/lib/controllers/resourceConsumption/index.js b/api/app/lib/controllers/resourceConsumption/index.js index 57280f9..cc0995d 100644 --- a/api/app/lib/controllers/resourceConsumption/index.js +++ b/api/app/lib/controllers/resourceConsumption/index.js @@ -16,6 +16,11 @@ function getApproveList (opts) { distinct: true, include: [{ model: models.User, + as:'applyUser', + attributes: ['id', 'name'] + },{ + model: models.User, + as:'approveUser', attributes: ['id', 'name'] },] } @@ -23,7 +28,7 @@ function getApproveList (opts) { option.where.resourceName = { $iLike: `%${resourceName}%` } } if (applyBy) { - option.include[0].where = { '$user.name$': { $iLike: `%${applyBy}%` } } + option.include[0].where = { '$applyUser.name$': { $iLike: `%${applyBy}%` } } } if (applyById) { option.where.applyBy = applyById diff --git a/api/app/lib/index.js b/api/app/lib/index.js index 1f86f45..08387ac 100644 --- a/api/app/lib/index.js +++ b/api/app/lib/index.js @@ -85,5 +85,7 @@ module.exports.models = function (dc) { BusinessMetadataDatabase.belongsTo(User, { foreignKey: 'createBy', targetKey: 'id' }); BusinessMetadataFile.belongsTo(User, { foreignKey: 'createBy', targetKey: 'id' }); BusinessMetadataRestapi.belongsTo(User, { foreignKey: 'createBy', targetKey: 'id' }); - ResourceConsumption.belongsTo(User, { foreignKey: 'applyBy', targetKey: 'id' }); + + ResourceConsumption.belongsTo(User, { foreignKey: 'applyBy', targetKey: 'id' ,as:"applyUser"}); + ResourceConsumption.belongsTo(User, { foreignKey: 'approveBy', targetKey: 'id',as:'approveUser' }); }; diff --git a/web/client/src/sections/resourceConsumption/containers/approve.js b/web/client/src/sections/resourceConsumption/containers/approve.js index e2bd3c2..36cb578 100644 --- a/web/client/src/sections/resourceConsumption/containers/approve.js +++ b/web/client/src/sections/resourceConsumption/containers/approve.js @@ -40,7 +40,7 @@ function Approve ({ loading, clientHeight, actions, dispatch, }) { }, { title: '申请人', dataIndex: 'applyBy', - render: (text, record) => record?.user?.name + render: (text, record) => record?.applyUser?.name }, { title: '需求描述', dataIndex: 'requirements', diff --git a/web/client/src/sections/resourceConsumption/containers/myApplication.js b/web/client/src/sections/resourceConsumption/containers/myApplication.js index 57563a1..2454d2d 100644 --- a/web/client/src/sections/resourceConsumption/containers/myApplication.js +++ b/web/client/src/sections/resourceConsumption/containers/myApplication.js @@ -35,9 +35,9 @@ function MyApplication ({ loading, clientHeight, actions, dispatch, user }) { title: '资源名称', dataIndex: 'resourceName', }, { - title: '申请人', - dataIndex: 'applyBy', - render: (text, record) => record?.user?.name + title: '审批人', + dataIndex: 'approveBy', + render: (text, record) => record?.approveUser?.name }, { title: '需求描述', dataIndex: 'requirements',