update
init
This commit is contained in:
@@ -0,0 +1,77 @@
|
||||
<template>
|
||||
<div v-if="!showAddView">
|
||||
<BasicTables @register="registerTable" :row-selection="rowSelection">
|
||||
<template #btn>
|
||||
<a-button type="primary" @click="handleAdd">新增</a-button>
|
||||
<a-button type="primary" @click="handleEdit">修改</a-button>
|
||||
<a-button type="primary" @click="handleDelete">删除</a-button>
|
||||
</template>
|
||||
</BasicTables>
|
||||
</div>
|
||||
<div v-if="showAddView">
|
||||
<tab16Add :update="addOrEdit" :userId="props.userInfo.id" :tab16Info="tab16Info" @go-back="goBack"></tab16Add>
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { BasicTables } from '/@/components/Table';
|
||||
import { useListPage } from '/@/hooks/system/useListPages';
|
||||
import { tab16Column } from '/@/views/archivesManage/employee/fileMaintenance/maintenance.data';
|
||||
import tab16Add from '/@/views/archivesManage/employee/fileMaintenance/components/tab16/tab16Add.vue';
|
||||
import { ref } from 'vue';
|
||||
import { message } from 'ant-design-vue';
|
||||
import { tab16ListApi, tab16DeleteApi } from '/@/views/archivesManage/employee/fileMaintenance/maintenance.api';
|
||||
|
||||
const props = defineProps({
|
||||
userInfo: {
|
||||
type: Object,
|
||||
default: () => ({}),
|
||||
},
|
||||
});
|
||||
const tab16Info = ref();
|
||||
const { tableContext, onExportXls } = useListPage({
|
||||
tableProps: {
|
||||
api: tab16ListApi,
|
||||
columns: tab16Column,
|
||||
btnArr: ['add', 'edit', 'delete', 'search', 'export', 'print'],
|
||||
showIndexColumn: true,
|
||||
beforeFetch: (params) => {
|
||||
params.userId = props.userInfo.id;
|
||||
return params;
|
||||
},
|
||||
},
|
||||
});
|
||||
const showAddView = ref(false);
|
||||
const addOrEdit = ref(false);
|
||||
const [registerTable, { reload, getForm }, { rowSelection, selectedRowKeys, selectedRows }] = tableContext;
|
||||
function goBack() {
|
||||
showAddView.value = false;
|
||||
selectedRowKeys.value = [];
|
||||
selectedRows.value = [];
|
||||
reload();
|
||||
}
|
||||
function handleAdd() {
|
||||
showAddView.value = true;
|
||||
tab16Info.value = {};
|
||||
}
|
||||
function handleEdit() {
|
||||
console.log(selectedRows.value);
|
||||
if (selectedRowKeys.value.length != 1) {
|
||||
message.warning('请选择一条数据');
|
||||
return;
|
||||
}
|
||||
tab16Info.value = selectedRows.value[0];
|
||||
addOrEdit.value = true;
|
||||
showAddView.value = true;
|
||||
}
|
||||
function handleDelete() {
|
||||
console.log(selectedRows.value);
|
||||
if (selectedRowKeys.value.length == 0) {
|
||||
message.warning('请选择需要删除的记录');
|
||||
return;
|
||||
}
|
||||
const idArr = selectedRows.value.map((item) => {
|
||||
return item.id;
|
||||
});
|
||||
tab16DeleteApi({ ids: idArr }, reload);
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user