diff --git a/api/app/lib/controllers/patrolManage/patrolTemplate.js b/api/app/lib/controllers/patrolManage/patrolTemplate.js
index fbeda4b..8f6d33a 100644
--- a/api/app/lib/controllers/patrolManage/patrolTemplate.js
+++ b/api/app/lib/controllers/patrolManage/patrolTemplate.js
@@ -12,6 +12,9 @@ async function getPatrolTemplate (ctx, next) {
attributes: ['id', 'name'],
}, {
model: models.CheckItems,
+ }, {
+ model: models.PatrolPlan,
+ attributes: ['name'],
}]
};
if (limit) {
@@ -129,11 +132,11 @@ async function delPatrolTemplate (ctx, next) {
const { id } = ctx.params;
const record = await models.PatrolPlan.findOne({
- where: { patrolTemplateId: id }
+ where: { templateId: id }
});
if (record) {
- errMsg = '不能删除有巡检记录的模板';
+ errMsg = '不能删除已绑定巡检计划的模板';
throw errMsg;
}
diff --git a/api/app/lib/index.js b/api/app/lib/index.js
index 4b465c3..66039c4 100644
--- a/api/app/lib/index.js
+++ b/api/app/lib/index.js
@@ -61,6 +61,9 @@ module.exports.models = function (dc) { // dc = { orm: Sequelize对象, ORM: Seq
UserResource.belongsTo(User, { foreignKey: 'userId', targetKey: 'id' });
User.hasMany(UserResource, { foreignKey: 'userId', sourceKey: 'id' });
+ PatrolPlan.belongsTo(PatrolTemplate, { foreignKey: 'templateId', targetKey: 'id' });
+ PatrolTemplate.hasMany(PatrolPlan, { foreignKey: 'templateId', sourceKey: 'id' });
+
PatrolTemplate.belongsTo(User, { foreignKey: 'createUserId', targetKey: 'id' });
User.hasMany(PatrolTemplate, { foreignKey: 'createUserId', sourceKey: 'id' });
diff --git a/web/client/src/sections/patrolManage/containers/patrolTemplate.js b/web/client/src/sections/patrolManage/containers/patrolTemplate.js
index 5338668..c0e25b5 100644
--- a/web/client/src/sections/patrolManage/containers/patrolTemplate.js
+++ b/web/client/src/sections/patrolManage/containers/patrolTemplate.js
@@ -62,7 +62,7 @@ function PatrolTemplate (props) {
}
})
}}>
-
+
>
},