|
|
@@ -1,10 +1,9 @@
|
|
|
import type VbModalVue from '@@@/modal/VbModal.vue';
|
|
|
<script setup lang="ts">
|
|
|
-import apis from "@a"
|
|
|
-
|
|
|
const props = withDefaults(
|
|
|
defineProps<{
|
|
|
modelValue?: any[] | any
|
|
|
+ selectList?: any[] | any
|
|
|
tableOpts: {
|
|
|
columns: any[]
|
|
|
queryParams: any
|
|
|
@@ -32,6 +31,7 @@ const props = withDefaults(
|
|
|
)
|
|
|
const emits = defineEmits<{
|
|
|
(e: "update:modelValue", v: any[]): void
|
|
|
+ (e: "update:selectList", v: any[]): void
|
|
|
(e: "confirm", v: any[]): void
|
|
|
}>()
|
|
|
|
|
|
@@ -75,23 +75,25 @@ function onCheckboxChange(isChecked: boolean, row: any) {
|
|
|
if (isChecked) {
|
|
|
selectList.value.push(convertData(row))
|
|
|
} else {
|
|
|
- selectList.value = selectList.value.filter((item: any) => item.roleId != row.roleId)
|
|
|
+ selectList.value = selectList.value.filter((item: any) => item[props.tagId] != row[props.tagId])
|
|
|
}
|
|
|
- selectIds.value = selectList.value.map((v: any) => String(v.roleId))
|
|
|
+ selectIds.value = selectList.value.map((v: any) => String(v[props.tagId]))
|
|
|
+ emits("update:selectList", selectList.value)
|
|
|
}
|
|
|
function onCheckboxAll(isChecked: boolean, rows: any[]) {
|
|
|
if (isChecked) {
|
|
|
rows.forEach((row) => {
|
|
|
- if (!selectList.value.some((item: any) => item.roleId === row.roleId)) {
|
|
|
+ if (!selectList.value.some((item: any) => item[props.tagId] === row[props.tagId])) {
|
|
|
selectList.value.push(convertData(row))
|
|
|
}
|
|
|
})
|
|
|
} else {
|
|
|
selectList.value = selectList.value.filter((item: any) => {
|
|
|
- return !rows.some((row) => row.roleId == item.roleId)
|
|
|
+ return !rows.some((row) => row[props.tagId] == item[props.tagId])
|
|
|
})
|
|
|
}
|
|
|
- selectIds.value = selectList.value.map((v: any) => String(v.roleId))
|
|
|
+ selectIds.value = selectList.value.map((v: any) => String(v[props.tagId]))
|
|
|
+ emits("update:selectList", selectList.value)
|
|
|
}
|
|
|
|
|
|
function handleCloseTag(item: any) {
|
|
|
@@ -112,6 +114,7 @@ function initSelectData() {
|
|
|
if (props.optionSelectFun) {
|
|
|
props.optionSelectFun(ids).then((res: any) => {
|
|
|
selectList.value = res.data ? res.data.map((v: any) => convertData(v)) : []
|
|
|
+ emits("update:selectList", selectList.value)
|
|
|
})
|
|
|
}
|
|
|
let i = 0,
|
|
|
@@ -171,6 +174,7 @@ function open() {
|
|
|
handleQuery()
|
|
|
modalRef.value.show()
|
|
|
}
|
|
|
+
|
|
|
function close() {
|
|
|
tableRef.value.clearSelecteds()
|
|
|
selectList.value = []
|
|
|
@@ -209,7 +213,6 @@ defineExpose({
|
|
|
</transition-group>
|
|
|
<VbDataTable
|
|
|
ref="tableRef"
|
|
|
- v-model:selected-rows="selectList"
|
|
|
v-model:query-params="queryParams"
|
|
|
:search-form-items="tableOpts.searchFormItems"
|
|
|
:columns="tableOpts.columns"
|
|
|
@@ -225,7 +228,9 @@ defineExpose({
|
|
|
@checkbox-change="onCheckboxChange"
|
|
|
@checkbox-all="onCheckboxAll"
|
|
|
table-box-height="70vh">
|
|
|
- <template #status="{ row }"></template>
|
|
|
+ <template v-for="(_, name) in $slots" #[name]="{ row }">
|
|
|
+ <slot :name="name" :row="row" />
|
|
|
+ </template>
|
|
|
</VbDataTable>
|
|
|
</template>
|
|
|
</VbModal>
|