Browse Source

fix 8544 检查项被应用后禁止删除显示优化

master
liujiangyong 2 years ago
parent
commit
5a0afa9f51
  1. 2
      api/app/lib/controllers/patrolManage/checkItems.js
  2. 2
      api/app/lib/index.js
  3. 2
      api/app/lib/models/check_items.js
  4. 2
      api/app/lib/models/check_items_group.js
  5. 2
      weapp/package/inspectionInput/inspectionInput.js
  6. 9
      web/client/src/sections/patrolManage/containers/checkItems.js
  7. 2
      web/client/src/sections/patrolManage/containers/patrolTemplate.js

2
api/app/lib/controllers/patrolManage/checkItems.js

@ -50,6 +50,8 @@ async function getCheckItems(ctx, next) {
required: true, required: true,
model: models.CheckItemsGroup, model: models.CheckItemsGroup,
attributes: ['id', 'name'], attributes: ['id', 'name'],
}, {
model: models.PatrolTemplate
}] }]
} }
if (name) { if (name) {

2
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' }); PatrolTemplate.belongsTo(User, { foreignKey: 'createUserId', targetKey: 'id' });
User.hasMany(PatrolTemplate, { foreignKey: 'createUserId', sourceKey: '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' }); PatrolTemplate.belongsToMany(CheckItems, { through: PatrolTemplateCheckItems, foreignKey: 'templateId', otherKey: 'checkItemsId' });
UserResource.belongsTo(Resource, { foreignKey: 'resourceId', targetKey: 'code' }); UserResource.belongsTo(Resource, { foreignKey: 'resourceId', targetKey: 'code' });

2
api/app/lib/models/check_items.js

@ -4,7 +4,7 @@
module.exports = dc => { module.exports = dc => {
const DataTypes = dc.ORM; const DataTypes = dc.ORM;
const sequelize = dc.orm; const sequelize = dc.orm;
const CheckItems = sequelize.define("check_items", { const CheckItems = sequelize.define("checkItems", {
id: { id: {
field: "id", field: "id",
type: DataTypes.INTEGER, type: DataTypes.INTEGER,

2
api/app/lib/models/check_items_group.js

@ -4,7 +4,7 @@
module.exports = dc => { module.exports = dc => {
const DataTypes = dc.ORM; const DataTypes = dc.ORM;
const sequelize = dc.orm; const sequelize = dc.orm;
const CheckItemsGroup = sequelize.define("check_items_group", { const CheckItemsGroup = sequelize.define("checkItemsGroup", {
id: { id: {
field: "id", field: "id",
type: DataTypes.INTEGER, type: DataTypes.INTEGER,

2
weapp/package/inspectionInput/inspectionInput.js

@ -63,7 +63,7 @@ Page({
// 获取巡检模板 // 获取巡检模板
getPatrolTemplate(templateId) { getPatrolTemplate(templateId) {
Request.get(getPatrolTemplate(templateId)).then(res => { Request.get(getPatrolTemplate(templateId)).then(res => {
const checkItems = res.rows[0].check_items; const checkItems = res.rows[0].checkItems;
const inspectContent = {}; const inspectContent = {};
for (const c of checkItems) { for (const c of checkItems) {
inspectContent[c.name] = { inspectContent[c.name] = {

9
web/client/src/sections/patrolManage/containers/checkItems.js

@ -67,7 +67,7 @@ function CheckItems(props) {
search: false, search: false,
width: 150, width: 150,
render: (_, record) => { render: (_, record) => {
return <div>{record?.check_items_group?.name}</div> return <div>{record?.checkItemsGroup?.name}</div>
} }
}, { }, {
title: '操作', title: '操作',
@ -84,7 +84,7 @@ function CheckItems(props) {
<Popconfirm <Popconfirm
title="确认删除?" title="确认删除?"
onConfirm={() => { delItems(record.id) }}> onConfirm={() => { delItems(record.id) }}>
<Button type="link" danger>删除</Button> <Button type="link" danger disabled={record && record.patrolTemplates && record.patrolTemplates.length}>删除</Button>
</Popconfirm> </Popconfirm>
</> </>
}, },
@ -106,7 +106,10 @@ function CheckItems(props) {
name: params?.name name: params?.name
})); }));
setDataSource(res?.payload.data?.rows); setDataSource(res?.payload.data?.rows);
return { ...res }; return {
...res,
total: res.payload.data.count ? res.payload.data.count : 0,
};
}} }}
onReset={() => { }} onReset={() => { }}
search={{ search={{

2
web/client/src/sections/patrolManage/containers/patrolTemplate.js

@ -42,7 +42,7 @@ function PatrolTemplate (props) {
key: 'checkItems', key: 'checkItems',
ellipsis: true, ellipsis: true,
render: (_, r) => { render: (_, r) => {
return r?.check_items ? r?.check_items.map(c => <Tag>{c.name}</Tag>) : '-' return r?.checkItems ? r?.checkItems.map(c => <Tag>{c.name}</Tag>) : '-'
} }
}, { }, {
title: '操作', title: '操作',

Loading…
Cancel
Save