mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/fe-manage.git
synced 2025-12-09 19:06:45 +08:00
zcwy-dev 补充
This commit is contained in:
22375
package-lock.json
generated
Normal file
22375
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
136
src/components/common/BaseSlotTable.vue
Normal file
136
src/components/common/BaseSlotTable.vue
Normal file
@@ -0,0 +1,136 @@
|
||||
<template>
|
||||
<a-table :customRow="customRow" class="ant-table-striped"
|
||||
:row-class-name="(_, index) => (index % 2 === 1 ? 'table-striped' : null)" row-key="id" :columns="columns"
|
||||
:data-source="data" :loading="loading" :pagination="pagination" :row-selection="rowSelection">
|
||||
<template #operation="{ record }">
|
||||
<slot :record="record"></slot>
|
||||
</template>
|
||||
</a-table>
|
||||
</template>
|
||||
<script setup>
|
||||
import { defineProps, defineExpose, ref, computed, onMounted, defineEmits, nextTick } from "vue";
|
||||
import { useRowsPageNoInit } from "@/api/request";
|
||||
import { useResetRef } from "@/utils/useCommon";
|
||||
|
||||
const props = defineProps({
|
||||
type: {
|
||||
type: String,
|
||||
default: ""
|
||||
},
|
||||
columns: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
},
|
||||
url: {
|
||||
type: String,
|
||||
default: ""
|
||||
},
|
||||
pageKey: {
|
||||
type: String,
|
||||
default: "pageNo"
|
||||
},
|
||||
params: {
|
||||
type: Object,
|
||||
default: () => ({})
|
||||
},
|
||||
init: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
request: {
|
||||
type: Function,
|
||||
default: useRowsPageNoInit
|
||||
}
|
||||
});
|
||||
const emit = defineEmits(["update:params", "update:selectedRowKeys", "update:selectedRows"]);
|
||||
const rowSelectKeys = ref([]);
|
||||
const selectsData = ref([]);
|
||||
const params = useResetRef({ [props.pageKey]: 1, pageSize: 10 });
|
||||
const postParam = computed(() => ({ ...params.value, ...props.params }));
|
||||
|
||||
const { data, loading, total, fetch: onFetch } = props.request(props.url, postParam);
|
||||
|
||||
const rowSelection = computed(() => (props.type ? {
|
||||
type: props.type,
|
||||
columnWidth: 20,
|
||||
selectedRowKeys: rowSelectKeys.value,
|
||||
onChange: onSelectChange,
|
||||
preserveSelectedRowKeys: true,
|
||||
} : null));
|
||||
|
||||
const customRow = (record) => ({
|
||||
onClick: () => {
|
||||
if (props.type === "checkbox") {
|
||||
if (rowSelectKeys.value.some(t => t === record.id)) {
|
||||
rowSelectKeys.value = rowSelectKeys.value.filter(t => t !== record.id);
|
||||
selectsData.value = selectsData.value.filter(t => t.id !== record.id);
|
||||
} else {
|
||||
rowSelectKeys.value.push(record.id);
|
||||
selectsData.value.push(record);
|
||||
}
|
||||
} else {
|
||||
rowSelectKeys.value = [record.id];
|
||||
selectsData.value = [record];
|
||||
}
|
||||
emit("update:selectedRowKeys", [...rowSelectKeys.value]);
|
||||
emit("update:selectedRows", [...selectsData.value]);
|
||||
}
|
||||
});
|
||||
|
||||
onMounted(() => props.init && nextTick(onFetch));
|
||||
|
||||
function onSelectChange(e, l) {
|
||||
rowSelectKeys.value = e;
|
||||
selectsData.value = l;
|
||||
emit("update:selectedRowKeys", e);
|
||||
emit("update:selectedRows", l);
|
||||
}
|
||||
|
||||
const pagination = computed(() => ({
|
||||
total: total.value,
|
||||
showSizeChanger: false,
|
||||
current: params.value[props.pageKey],
|
||||
pageSize: params.value.pageSize,
|
||||
onChange: changePagination,
|
||||
}));
|
||||
const changePagination = (e) => {
|
||||
params.value[props.pageKey] = e;
|
||||
nextTick(onFetch);
|
||||
};
|
||||
|
||||
function reset(v) {
|
||||
params.reset();
|
||||
v && emit("update:params", { ...v });
|
||||
nextTick(onFetch);
|
||||
}
|
||||
|
||||
function resetSelected() {
|
||||
rowSelectKeys.value = [];
|
||||
selectsData.value = [];
|
||||
emit("update:selectedRowKeys", []);
|
||||
emit("update:selectedRows", []);
|
||||
}
|
||||
|
||||
function clear(v) {
|
||||
rowSelectKeys.value = [];
|
||||
selectsData.value = [];
|
||||
params.reset();
|
||||
v && emit("update:params", { ...v });
|
||||
emit("update:selectedRowKeys", []);
|
||||
emit("update:selectedRows", []);
|
||||
}
|
||||
|
||||
const toLoading = () => loading.value = true;
|
||||
|
||||
function remove(i) {
|
||||
rowSelectKeys.value.splice(i, 1);
|
||||
selectsData.value.splice(i, 1);
|
||||
emit("update:selectedRowKeys", rowSelectKeys.value);
|
||||
emit("update:selectedRows", selectsData.value);
|
||||
}
|
||||
|
||||
const fetch = () => nextTick(onFetch);
|
||||
|
||||
defineExpose({ fetch, reset, resetSelected, clear, toLoading, remove });
|
||||
|
||||
</script>
|
||||
@@ -282,7 +282,7 @@
|
||||
<!-- 二维码弹窗 -->
|
||||
</template>
|
||||
|
||||
<script>
|
||||
<script lang="jsx">
|
||||
import { toRefs, reactive } from "vue";
|
||||
import SignQR from "./SignQR.vue";
|
||||
import TwoDimensionalCode from "../../components/TwoDimensionalCode";
|
||||
|
||||
@@ -114,7 +114,7 @@
|
||||
</a-drawer>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
<script lang="jsx">
|
||||
import { toRefs, reactive, onMounted, onUnmounted } from "vue";
|
||||
import { message } from "ant-design-vue";
|
||||
// import * as api from "../../../api/index";
|
||||
|
||||
@@ -120,7 +120,7 @@
|
||||
<CheckAnsware v-model:CAvisible="CAvisible" :datasource="datasource1"/>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
<script lang="jsx">
|
||||
import { toRefs, reactive } from "vue";
|
||||
import { message } from "ant-design-vue";
|
||||
import EScore from "../ExportScore.vue";
|
||||
|
||||
@@ -126,7 +126,7 @@
|
||||
</a-drawer>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
<script lang="jsx">
|
||||
import { toRefs, reactive } from "vue";
|
||||
import { message } from "ant-design-vue";
|
||||
import ExportAchievement from "../ExportAchievement.vue";
|
||||
|
||||
@@ -133,7 +133,7 @@
|
||||
:downloadUrl="downloadUrl"
|
||||
/>
|
||||
</template>
|
||||
<script setup>
|
||||
<script setup lang="jsx">
|
||||
import {computed, defineEmits, ref, watch} from "vue";
|
||||
import * as api from "@/api/index1";
|
||||
import BaseTable from "@/components/common/BaseTable";
|
||||
|
||||
@@ -158,7 +158,7 @@
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
<script lang="jsx">
|
||||
import { toRefs, reactive } from "vue";
|
||||
import { message } from "ant-design-vue";
|
||||
import CKWork from "../CheckWork.vue";
|
||||
|
||||
@@ -132,7 +132,7 @@
|
||||
:basicdata="datasource.info" />
|
||||
</template>
|
||||
|
||||
<script>
|
||||
<script lang="jsx">
|
||||
import { toRefs, reactive, onMounted, onUnmounted } from "vue";
|
||||
import { message } from "ant-design-vue";
|
||||
// import * as api from "../../../api/index";
|
||||
|
||||
@@ -119,7 +119,7 @@
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
<script lang="jsx">
|
||||
import { toRefs, reactive, onMounted, onUnmounted } from "vue";
|
||||
import { message } from "ant-design-vue";
|
||||
// import * as api from "../../../api/index";
|
||||
|
||||
@@ -132,7 +132,7 @@
|
||||
:basicdata="datasource.info" />
|
||||
</template>
|
||||
|
||||
<script>
|
||||
<script lang="jsx">
|
||||
import { toRefs, reactive, onMounted, onUnmounted } from "vue";
|
||||
import { message } from "ant-design-vue";
|
||||
import ViewAssess from "../ViewAssess";
|
||||
|
||||
@@ -112,7 +112,7 @@
|
||||
</a-drawer>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
<script lang="jsx">
|
||||
import { toRefs, reactive, onMounted, onUnmounted } from "vue";
|
||||
import { message } from "ant-design-vue";
|
||||
// import * as api from "../../../api/index";
|
||||
|
||||
@@ -125,7 +125,7 @@
|
||||
</a-drawer>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
<script lang="jsx">
|
||||
import { toRefs, reactive } from "vue";
|
||||
import { message } from "ant-design-vue";
|
||||
import ExportAchievement from "../ExportAchievement.vue";
|
||||
|
||||
@@ -82,7 +82,7 @@
|
||||
<CheckAnsware v-model:CAvisible="CAvisible" :datasource="datasource1" />
|
||||
</template>
|
||||
|
||||
<script>
|
||||
<script lang="jsx">
|
||||
import { toRefs, reactive } from "vue";
|
||||
import { message } from "ant-design-vue";
|
||||
import EScore from "../ExportScore.vue";
|
||||
|
||||
@@ -150,7 +150,7 @@
|
||||
</a-drawer>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
<script setup lang="jsx">
|
||||
import {computed, defineEmits, ref, watch} from "vue";
|
||||
import * as api from "@/api/index1";
|
||||
import BaseTable from "@/components/common/BaseTable";
|
||||
|
||||
@@ -101,7 +101,7 @@
|
||||
<ExportHomeWork v-model:exportHomeWorkV="exportHomeWorkV" :downloadUrl="downloadUrl" />
|
||||
</template>
|
||||
|
||||
<script>
|
||||
<script lang="jsx">
|
||||
import { toRefs, reactive } from "vue";
|
||||
import { message } from "ant-design-vue";
|
||||
import CKWork from "../CheckWork.vue";
|
||||
|
||||
@@ -120,7 +120,7 @@
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
<script lang="jsx">
|
||||
import { toRefs, reactive, onMounted, onUnmounted } from "vue";
|
||||
import { message } from "ant-design-vue";
|
||||
import SeeStu from "@/components/drawers/SeeStu";
|
||||
|
||||
@@ -119,7 +119,7 @@
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
<script lang="jsx">
|
||||
import { toRefs, reactive, onMounted, onUnmounted } from "vue";
|
||||
import { message } from "ant-design-vue";
|
||||
// import * as api from "../../../api/index";
|
||||
|
||||
Reference in New Issue
Block a user