From 5a0afa9f5169f02678a25e3e71248fcaf2229ead Mon Sep 17 00:00:00 2001 From: liujiangyong Date: Fri, 24 Feb 2023 09:19:15 +0800 Subject: [PATCH] =?UTF-8?q?fix=208544=20=E6=A3=80=E6=9F=A5=E9=A1=B9?= =?UTF-8?q?=E8=A2=AB=E5=BA=94=E7=94=A8=E5=90=8E=E7=A6=81=E6=AD=A2=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E6=98=BE=E7=A4=BA=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/app/lib/controllers/patrolManage/checkItems.js | 2 ++ api/app/lib/index.js | 2 +- api/app/lib/models/check_items.js | 2 +- api/app/lib/models/check_items_group.js | 2 +- weapp/package/inspectionInput/inspectionInput.js | 2 +- .../src/sections/patrolManage/containers/checkItems.js | 9 ++++++--- .../sections/patrolManage/containers/patrolTemplate.js | 2 +- 7 files changed, 13 insertions(+), 8 deletions(-) diff --git a/api/app/lib/controllers/patrolManage/checkItems.js b/api/app/lib/controllers/patrolManage/checkItems.js index dc7da16..738987c 100644 --- a/api/app/lib/controllers/patrolManage/checkItems.js +++ b/api/app/lib/controllers/patrolManage/checkItems.js @@ -50,6 +50,8 @@ async function getCheckItems(ctx, next) { required: true, model: models.CheckItemsGroup, attributes: ['id', 'name'], + }, { + model: models.PatrolTemplate }] } if (name) { diff --git a/api/app/lib/index.js b/api/app/lib/index.js index 5b95ba3..faf68b5 100644 --- a/api/app/lib/index.js +++ b/api/app/lib/index.js @@ -71,7 +71,7 @@ module.exports.models = function (dc) { // dc = { orm: Sequelize对象, ORM: Seq PatrolTemplate.belongsTo(User, { foreignKey: 'createUserId', targetKey: 'id' }); User.hasMany(PatrolTemplate, { foreignKey: 'createUserId', sourceKey: 'id' }); - CheckItems.belongsToMany(PatrolTemplate, { through: PatrolTemplateCheckItems, foreignKey: 'templateId', otherKey: 'checkItemsId' }); + CheckItems.belongsToMany(PatrolTemplate, { through: PatrolTemplateCheckItems, foreignKey: 'checkItemsId', otherKey: 'templateId' }); PatrolTemplate.belongsToMany(CheckItems, { through: PatrolTemplateCheckItems, foreignKey: 'templateId', otherKey: 'checkItemsId' }); UserResource.belongsTo(Resource, { foreignKey: 'resourceId', targetKey: 'code' }); diff --git a/api/app/lib/models/check_items.js b/api/app/lib/models/check_items.js index eee21a5..3ea26ba 100644 --- a/api/app/lib/models/check_items.js +++ b/api/app/lib/models/check_items.js @@ -4,7 +4,7 @@ module.exports = dc => { const DataTypes = dc.ORM; const sequelize = dc.orm; - const CheckItems = sequelize.define("check_items", { + const CheckItems = sequelize.define("checkItems", { id: { field: "id", type: DataTypes.INTEGER, diff --git a/api/app/lib/models/check_items_group.js b/api/app/lib/models/check_items_group.js index 3cb1399..aa19b0e 100644 --- a/api/app/lib/models/check_items_group.js +++ b/api/app/lib/models/check_items_group.js @@ -4,7 +4,7 @@ module.exports = dc => { const DataTypes = dc.ORM; const sequelize = dc.orm; - const CheckItemsGroup = sequelize.define("check_items_group", { + const CheckItemsGroup = sequelize.define("checkItemsGroup", { id: { field: "id", type: DataTypes.INTEGER, diff --git a/weapp/package/inspectionInput/inspectionInput.js b/weapp/package/inspectionInput/inspectionInput.js index cf00504..513b84c 100644 --- a/weapp/package/inspectionInput/inspectionInput.js +++ b/weapp/package/inspectionInput/inspectionInput.js @@ -63,7 +63,7 @@ Page({ // 获取巡检模板 getPatrolTemplate(templateId) { Request.get(getPatrolTemplate(templateId)).then(res => { - const checkItems = res.rows[0].check_items; + const checkItems = res.rows[0].checkItems; const inspectContent = {}; for (const c of checkItems) { inspectContent[c.name] = { diff --git a/web/client/src/sections/patrolManage/containers/checkItems.js b/web/client/src/sections/patrolManage/containers/checkItems.js index eda9181..d596ba2 100644 --- a/web/client/src/sections/patrolManage/containers/checkItems.js +++ b/web/client/src/sections/patrolManage/containers/checkItems.js @@ -67,7 +67,7 @@ function CheckItems(props) { search: false, width: 150, render: (_, record) => { - return
{record?.check_items_group?.name}
+ return
{record?.checkItemsGroup?.name}
} }, { title: '操作', @@ -84,7 +84,7 @@ function CheckItems(props) { { delItems(record.id) }}> - + }, @@ -106,7 +106,10 @@ function CheckItems(props) { name: params?.name })); setDataSource(res?.payload.data?.rows); - return { ...res }; + return { + ...res, + total: res.payload.data.count ? res.payload.data.count : 0, + }; }} onReset={() => { }} search={{ diff --git a/web/client/src/sections/patrolManage/containers/patrolTemplate.js b/web/client/src/sections/patrolManage/containers/patrolTemplate.js index 48f11a9..b892b20 100644 --- a/web/client/src/sections/patrolManage/containers/patrolTemplate.js +++ b/web/client/src/sections/patrolManage/containers/patrolTemplate.js @@ -42,7 +42,7 @@ function PatrolTemplate (props) { key: 'checkItems', ellipsis: true, render: (_, r) => { - return r?.check_items ? r?.check_items.map(c => {c.name}) : '-' + return r?.checkItems ? r?.checkItems.map(c => {c.name}) : '-' } }, { title: '操作',