v1.2.1版本,优化调整了很多,整改验收阶段新加字段
This commit is contained in:
@@ -200,19 +200,28 @@
|
||||
</view>
|
||||
|
||||
<!-- 从检查库添加的检查项卡片 -->
|
||||
<view class="check-card" v-for="(item, index) in checkItems" :key="'lib-' + index">
|
||||
<view class="check-card library-card" v-for="(item, index) in libraryCheckItems" :key="'lib-' + item.pointId">
|
||||
<view class="card-tag library-tag">检查库</view>
|
||||
<view class="check-info">
|
||||
<view class="info-row">
|
||||
<text class="info-label">关联表名:</text>
|
||||
<text class="info-value">{{ item.tableName }}</text>
|
||||
<text class="info-label">来源检查库:</text>
|
||||
<text class="info-value">{{ item.sourceLibraryName || '-' }}</text>
|
||||
</view>
|
||||
<view class="info-row">
|
||||
<text class="info-label">检查项数量:</text>
|
||||
<text class="info-value">{{ item.count }}项</text>
|
||||
<text class="info-label">检查项名称:</text>
|
||||
<text class="info-value">{{ item.name }}</text>
|
||||
</view>
|
||||
<view class="info-row">
|
||||
<text class="info-label">检查内容:</text>
|
||||
<text class="info-value">{{ item.point }}</text>
|
||||
</view>
|
||||
<view class="info-row">
|
||||
<text class="info-label">参考法规:</text>
|
||||
<text class="info-value">{{ item.regulation || '-' }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="check-action">
|
||||
<button class="btn-delete" @click="deleteCheckItem(index)">删除</button>
|
||||
<button class="btn-delete" @click="deleteLibraryCheckItem(index)">删除</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -647,15 +656,25 @@ const onEndDateConfirm = (e) => {
|
||||
// 手动添加的检查项列表
|
||||
const manualCheckItems = ref([]);
|
||||
|
||||
// 从检查库添加的检查项
|
||||
const checkItems = ref([]);
|
||||
// 从检查库展开添加的检查项(每一条检查点一项)
|
||||
const libraryCheckItems = ref([]);
|
||||
|
||||
// 检查项数量(手动添加的数量 + 检查库的数量)
|
||||
// 检查项数量(手动添加 + 检查库展开项)
|
||||
const checkItemCount = computed(() => {
|
||||
const libraryCount = checkItems.value.reduce((sum, item) => sum + item.count, 0);
|
||||
return manualCheckItems.value.length + libraryCount;
|
||||
return manualCheckItems.value.length + libraryCheckItems.value.length;
|
||||
});
|
||||
|
||||
const getExistingPointIds = () => {
|
||||
const ids = new Set();
|
||||
manualCheckItems.value.forEach((item) => {
|
||||
if (item.id) ids.add(Number(item.id));
|
||||
});
|
||||
libraryCheckItems.value.forEach((item) => {
|
||||
if (item.pointId) ids.add(Number(item.pointId));
|
||||
});
|
||||
return ids;
|
||||
};
|
||||
|
||||
// 删除手动添加的检查项(调用接口删除)
|
||||
const deleteManualCheckItem = (item, index) => {
|
||||
uni.showModal({
|
||||
@@ -691,15 +710,15 @@ const deleteManualCheckItem = (item, index) => {
|
||||
});
|
||||
};
|
||||
|
||||
// 删除检查库中的检查项(只从本地暂存删除,不调用接口)
|
||||
const deleteCheckItem = (index) => {
|
||||
// 删除检查库展开的检查项(只从本地暂存删除,不调用接口)
|
||||
const deleteLibraryCheckItem = (index) => {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要删除该检查项吗?',
|
||||
confirmColor: '#F56C6C',
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
checkItems.value.splice(index, 1);
|
||||
libraryCheckItems.value.splice(index, 1);
|
||||
uni.showToast({ title: '删除成功', icon: 'success' });
|
||||
}
|
||||
}
|
||||
@@ -955,37 +974,92 @@ const toggleLibrarySelect = (item) => {
|
||||
}
|
||||
};
|
||||
|
||||
// 拉取检查库详情全部分页数据
|
||||
const fetchLibraryDetailAll = async (libraryId) => {
|
||||
const pageSize = 50;
|
||||
let pageNum = 1;
|
||||
let allRecords = [];
|
||||
let total = 0;
|
||||
|
||||
while (true) {
|
||||
const res = await getCheckItemListDetail({
|
||||
id: libraryId,
|
||||
pageNum,
|
||||
pageSize
|
||||
});
|
||||
if (res.code !== 0 || !res.data) break;
|
||||
|
||||
const records = res.data.records || [];
|
||||
total = Number(res.data.total) || 0;
|
||||
allRecords = [...allRecords, ...records];
|
||||
|
||||
if (records.length === 0 || allRecords.length >= total) break;
|
||||
pageNum += 1;
|
||||
}
|
||||
|
||||
return allRecords;
|
||||
};
|
||||
|
||||
const getLibraryDisplayName = (libraryId, records) => {
|
||||
const library = libraryList.value.find((item) => String(item.id) === String(libraryId));
|
||||
if (library?.name) return library.name;
|
||||
if (records.length > 0) return records[0].name || '';
|
||||
return '';
|
||||
};
|
||||
|
||||
const appendLibraryRecords = (libraryId, records, sourceLibraryName) => {
|
||||
const existingPointIds = getExistingPointIds();
|
||||
let addedCount = 0;
|
||||
|
||||
records.forEach((record) => {
|
||||
if (!record.pointId) return;
|
||||
const pointId = Number(record.pointId);
|
||||
if (existingPointIds.has(pointId)) return;
|
||||
|
||||
existingPointIds.add(pointId);
|
||||
libraryCheckItems.value.push({
|
||||
pointId,
|
||||
itemId: record.itemId,
|
||||
sourceLibraryId: libraryId,
|
||||
sourceLibraryName,
|
||||
name: record.name || '',
|
||||
point: record.point || '',
|
||||
industry: record.industry || '',
|
||||
leadDept: record.leadDept || '',
|
||||
regulation: record.regulation || ''
|
||||
});
|
||||
addedCount += 1;
|
||||
});
|
||||
|
||||
return addedCount;
|
||||
};
|
||||
|
||||
// 添加选中的检查库
|
||||
const addSelectedLibrary = async () => {
|
||||
if (selectedLibraries.value.length === 0) {
|
||||
uni.showToast({ title: '请选择检查库', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
uni.showLoading({ title: '加载中...' });
|
||||
|
||||
|
||||
try {
|
||||
// 遍历选中的检查库,获取详情
|
||||
let totalAdded = 0;
|
||||
|
||||
for (const id of selectedLibraries.value) {
|
||||
const res = await getCheckItemListDetail({ id: id });
|
||||
if (res.code === 0 && res.data) {
|
||||
const records = res.data.records || [];
|
||||
const total = res.data.total || 0;
|
||||
// 获取关联表名(第一项的name)
|
||||
const tableName = records.length > 0 ? records[0].name : '';
|
||||
|
||||
// 添加到检查项列表
|
||||
checkItems.value.push({
|
||||
itemId: id,
|
||||
tableName: tableName,
|
||||
count: total,
|
||||
details: records // 保存详情数据,以便后续使用
|
||||
});
|
||||
}
|
||||
const records = await fetchLibraryDetailAll(id);
|
||||
const sourceLibraryName = getLibraryDisplayName(id, records);
|
||||
totalAdded += appendLibraryRecords(id, records, sourceLibraryName);
|
||||
}
|
||||
|
||||
|
||||
uni.hideLoading();
|
||||
uni.showToast({ title: '添加成功', icon: 'success' });
|
||||
|
||||
if (totalAdded === 0) {
|
||||
uni.showToast({ title: '没有可添加的新检查项', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
|
||||
uni.showToast({ title: `已添加${totalAdded}项`, icon: 'success' });
|
||||
showLibraryPopup.value = false;
|
||||
selectedLibraries.value = [];
|
||||
} catch (error) {
|
||||
@@ -1032,22 +1106,16 @@ const handleSave = async () => {
|
||||
return;
|
||||
}
|
||||
|
||||
// 构建 items 数组(关联检查项id列表)
|
||||
// 构建 checkPointIds 数组(检查点 id 列表)
|
||||
const items = [];
|
||||
// 添加手动添加的检查项id
|
||||
manualCheckItems.value.forEach(item => {
|
||||
manualCheckItems.value.forEach((item) => {
|
||||
if (item.id) {
|
||||
items.push(item.id );
|
||||
items.push(Number(item.id));
|
||||
}
|
||||
});
|
||||
// 添加从检查库选择的检查项详情中的所有项的 itemId
|
||||
checkItems.value.forEach(lib => {
|
||||
if (lib.details && lib.details.length > 0) {
|
||||
lib.details.forEach(detail => {
|
||||
if (detail.itemId) {
|
||||
items.push(detail.itemId);
|
||||
}
|
||||
});
|
||||
libraryCheckItems.value.forEach((item) => {
|
||||
if (item.pointId) {
|
||||
items.push(Number(item.pointId));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1070,13 +1138,13 @@ const handleSave = async () => {
|
||||
'每季度一次': 4
|
||||
};
|
||||
|
||||
// 构建 itemIds 数组(从检查库选择的检查库id列表)
|
||||
const itemIds = [];
|
||||
checkItems.value.forEach(lib => {
|
||||
if (lib.itemId) {
|
||||
itemIds.push(lib.itemId);
|
||||
}
|
||||
});
|
||||
// 构建 itemIds 数组(从检查库选择的检查库 id 列表,去重)
|
||||
const itemIds = [...new Set(
|
||||
libraryCheckItems.value
|
||||
.map((item) => item.sourceLibraryId)
|
||||
.filter(Boolean)
|
||||
.map((id) => Number(id))
|
||||
)];
|
||||
|
||||
// 构建提交参数
|
||||
const params = {
|
||||
@@ -1271,7 +1339,8 @@ onMounted(() => {
|
||||
}
|
||||
|
||||
// 手动添加的检查项卡片(带第x项标签)
|
||||
.manual-card {
|
||||
.manual-card,
|
||||
.library-card {
|
||||
padding-top: 50rpx;
|
||||
|
||||
.card-tag {
|
||||
@@ -1286,6 +1355,10 @@ onMounted(() => {
|
||||
}
|
||||
}
|
||||
|
||||
.library-card .library-tag {
|
||||
background: #67C23A;
|
||||
}
|
||||
|
||||
// 添加按钮组
|
||||
.add-btns {
|
||||
display: flex;
|
||||
|
||||
Reference in New Issue
Block a user