|
@@ -41,7 +41,7 @@
|
|
|
</div>
|
|
</div>
|
|
|
<div class="flex1 ov-hd d-flex flex-cln">
|
|
<div class="flex1 ov-hd d-flex flex-cln">
|
|
|
<div class="flex1 ov-hd">
|
|
<div class="flex1 ov-hd">
|
|
|
- <vxe-table ref="tableLeftRef" :loading="loading" border :data="list" height="100%" :column-config="{ resizable: true }" :row-config="{keyField: 'id',isCurrent: true, isHover: true}" :checkbox-config="{ checkRowKeys: checkRowKeys, highlight: true, range: true, trigger: 'row', reserve: true }">
|
|
|
|
|
|
|
+ <vxe-table ref="tableLeftRef" :loading="loading" border :data="list" height="100%" :column-config="{ resizable: true }" :row-config="{keyField: 'id',isCurrent: true, isHover: true}" :checkbox-config="{ highlight: true, range: true, trigger: 'row', reserve: true }">
|
|
|
<vxe-column type="checkbox" width="60"></vxe-column>
|
|
<vxe-column type="checkbox" width="60"></vxe-column>
|
|
|
<!-- 序号 -->
|
|
<!-- 序号 -->
|
|
|
<vxe-column type="seq" width="60" title="序号" align="center" />
|
|
<vxe-column type="seq" width="60" title="序号" align="center" />
|
|
@@ -97,7 +97,8 @@ const props = defineProps({
|
|
|
show: propTypes.bool.def(false),
|
|
show: propTypes.bool.def(false),
|
|
|
title: propTypes.string.def('选择检测项目'),
|
|
title: propTypes.string.def('选择检测项目'),
|
|
|
width: propTypes.string.def('80vw'),
|
|
width: propTypes.string.def('80vw'),
|
|
|
- info: propTypes.any.def(null)
|
|
|
|
|
|
|
+ info: propTypes.any.def(null),
|
|
|
|
|
+ items: propTypes.array.def([]) // 已选检测项目
|
|
|
});
|
|
});
|
|
|
const treeItemsRef = ref<any>();
|
|
const treeItemsRef = ref<any>();
|
|
|
const treeStandardsRef = ref<any>();
|
|
const treeStandardsRef = ref<any>();
|
|
@@ -114,18 +115,19 @@ const total = ref(0);
|
|
|
const list = ref<any>([]);
|
|
const list = ref<any>([]);
|
|
|
const targetList = ref<any>([]);
|
|
const targetList = ref<any>([]);
|
|
|
const itemsData = ref<any>([]);
|
|
const itemsData = ref<any>([]);
|
|
|
|
|
+// 是否打开过刚才id
|
|
|
|
|
+const mapIdsOpened = ref<any>({});
|
|
|
const getList = async () => {
|
|
const getList = async () => {
|
|
|
loading.value = true;
|
|
loading.value = true;
|
|
|
const res = await itemsList(queryParams.value);
|
|
const res = await itemsList(queryParams.value);
|
|
|
if (!res || res.code !== 200) return;
|
|
if (!res || res.code !== 200) return;
|
|
|
- list.value = res.rows;
|
|
|
|
|
- res.rows.forEach((item: any) => {
|
|
|
|
|
- if (targetList.value.some((target: any) => target.id === item.id)) {
|
|
|
|
|
- tableLeftRef.value?.setCheckboxRow([item], true);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ res.rows.forEach(element => {
|
|
|
|
|
+ mapIdsOpened.value[element.id] = true;
|
|
|
});
|
|
});
|
|
|
|
|
+ list.value = res.rows
|
|
|
total.value = res.total;
|
|
total.value = res.total;
|
|
|
loading.value = false;
|
|
loading.value = false;
|
|
|
|
|
+ tableLeftRef.value?.setCheckboxRow(targetList.value, true);
|
|
|
};
|
|
};
|
|
|
const handleQuery = () => {
|
|
const handleQuery = () => {
|
|
|
queryParams.value.pageNum = 1;
|
|
queryParams.value.pageNum = 1;
|
|
@@ -190,26 +192,18 @@ const submitForm = async () => {
|
|
|
const tableLeftRef = ref<any>();
|
|
const tableLeftRef = ref<any>();
|
|
|
const tableRightRef = ref<any>();
|
|
const tableRightRef = ref<any>();
|
|
|
const transferRight = () => {
|
|
const transferRight = () => {
|
|
|
- targetList.value = tableLeftRef.value?.getCheckboxReserveRecords(true).concat(tableLeftRef.value?.getCheckboxRecords());
|
|
|
|
|
|
|
+ // 去重
|
|
|
|
|
+ const newsList = tableLeftRef.value?.getCheckboxReserveRecords(true).concat(tableLeftRef.value?.getCheckboxRecords());
|
|
|
|
|
+ // 过滤没打开过的
|
|
|
|
|
+ const noOpenList = targetList.value.filter((item: any) => !mapIdsOpened.value[item.id]);
|
|
|
|
|
+ // 合并newsList和noOpenList
|
|
|
|
|
+ targetList.value = newsList
|
|
|
};
|
|
};
|
|
|
const transferLeft = () => {
|
|
const transferLeft = () => {
|
|
|
targetList.value = targetList.value.filter((item: any) => !tableRightRef.value?.getCheckboxRecords().includes(item));
|
|
targetList.value = targetList.value.filter((item: any) => !tableRightRef.value?.getCheckboxRecords().includes(item));
|
|
|
tableLeftRef.value?.setCheckboxRow(tableRightRef.value?.getCheckboxRecords(), false);
|
|
tableLeftRef.value?.setCheckboxRow(tableRightRef.value?.getCheckboxRecords(), false);
|
|
|
tableRightRef.value.setCheckboxRow(tableRightRef.value?.getCheckboxRecords(), false);
|
|
tableRightRef.value.setCheckboxRow(tableRightRef.value?.getCheckboxRecords(), false);
|
|
|
};
|
|
};
|
|
|
-// 清空全部已选
|
|
|
|
|
-const clearAll = () => {
|
|
|
|
|
- tableLeftRef.value?.clearCheckboxRow();
|
|
|
|
|
- tableRightRef.value?.clearCheckboxRow();
|
|
|
|
|
- targetList.value = [];
|
|
|
|
|
-};
|
|
|
|
|
-const checkRowKeys = ref<any>([]);
|
|
|
|
|
-// const c
|
|
|
|
|
-// 设置已选
|
|
|
|
|
-const setSelectItems = (val: any) => {
|
|
|
|
|
- targetList.value = val;
|
|
|
|
|
- checkRowKeys.value = val.map((item: any) => item.id);
|
|
|
|
|
-};
|
|
|
|
|
watch(
|
|
watch(
|
|
|
() => props.show,
|
|
() => props.show,
|
|
|
(val) => {
|
|
(val) => {
|
|
@@ -221,10 +215,18 @@ watch(
|
|
|
},
|
|
},
|
|
|
{ immediate: true }
|
|
{ immediate: true }
|
|
|
);
|
|
);
|
|
|
-defineExpose({
|
|
|
|
|
- clearAll,
|
|
|
|
|
- setSelectItems
|
|
|
|
|
-});
|
|
|
|
|
|
|
+watch(
|
|
|
|
|
+ () => props.items,
|
|
|
|
|
+ (val) => {
|
|
|
|
|
+ console.log(val);
|
|
|
|
|
+ if (val && val.length) {
|
|
|
|
|
+ targetList.value = val;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ targetList.value = [];
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ { immediate: true }
|
|
|
|
|
+);
|
|
|
</script>
|
|
</script>
|
|
|
<style lang="scss" scoped>
|
|
<style lang="scss" scoped>
|
|
|
.tree-wrap {
|
|
.tree-wrap {
|