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: '操作',