dbsd_kczx/src/views/kc/ktgl/KcKechengbiaoList.vue

301 lines
10 KiB
Vue
Raw Normal View History

2023-03-30 23:29:42 +08:00
<template>
<div>
<!--查询区域-->
2023-04-16 22:22:15 +08:00
<div class="jeecg-basic-table-form-container" v-if="!props.isNoSearch">
2023-03-30 23:29:42 +08:00
<a-form @keyup.enter.native="searchQuery" :model="queryParam" :label-col="labelCol" :wrapper-col="wrapperCol">
<a-row :gutter="24">
2023-04-01 22:06:31 +08:00
<a-col :lg="8">
2023-04-16 14:17:50 +08:00
<a-form-item label="开课单位">
<!-- <a-input placeholder="请输入开课单位" v-model:value="queryParam.kkdw"></a-input> -->
<j-dict-select-tag placeholder="请选择开课单位" v-model:value="queryParam.kkdw" dictCode="kc_kkdw_view,kkdw,id"/>
2023-04-01 22:06:31 +08:00
</a-form-item>
</a-col>
<a-col :lg="8">
2023-04-16 14:17:50 +08:00
<a-form-item label="星期">
<j-dict-select-tag placeholder="请选择星期" v-model:value="queryParam.week" dictCode="week"/>
</a-form-item>
</a-col>
<a-col :lg="8">
<a-form-item label="节次">
<j-dict-select-tag placeholder="请选择节次" v-model:value="queryParam.hh" dictCode="skjc"/>
</a-form-item>
</a-col>
<a-col :lg="8">
<a-form-item label="课程性质">
<!-- <a-input placeholder="请输入课程性质" v-model:value="queryParam.kcxz"></a-input> -->
<j-dict-select-tag v-model:value="queryParam.kcxz" dictCode="kcxz" placeholder="请选择课程性质"/>
</a-form-item>
</a-col>
<a-col :lg="8">
<a-form-item label="课程名称或教师名">
<a-input placeholder="请输入课程名称或教师名" v-model:value="queryParam.searchInput"></a-input>
</a-form-item>
</a-col>
<!-- <a-col :lg="8">
2023-04-01 22:06:31 +08:00
<a-form-item label="授课教师">
<a-input placeholder="请输入授课教师" v-model:value="queryParam.skjs"></a-input>
</a-form-item>
2023-04-16 14:17:50 +08:00
</a-col> -->
2023-04-01 22:06:31 +08:00
<!--<template v-if="toggleSearchStatus">-->
<!--</template>-->
<a-col :xl="6" :lg="7" :md="8" :sm="24">
<span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
<a-col :lg="6">
<a-button type="primary" preIcon="ant-design:search-outlined" @click="searchQuery">查询</a-button>
<a-button type="primary" preIcon="ant-design:reload-outlined" @click="searchReset" style="margin-left: 8px">重置</a-button>
<!--<a @click="toggleSearchStatus = !toggleSearchStatus" style="margin-left: 8px">
{{ toggleSearchStatus ? '收起' : '展开' }}
<Icon :icon="toggleSearchStatus ? 'ant-design:up-outlined' : 'ant-design:down-outlined'" />
</a>-->
</a-col>
</span>
</a-col>
2023-03-30 23:29:42 +08:00
</a-row>
</a-form>
</div>
2023-04-16 14:17:50 +08:00
<vxe-toolbar>
<template #buttons>
2023-04-16 22:22:15 +08:00
<a-button type="primary" class="pl1r" @click="handleAdd" preIcon="ant-design:plus-outlined" v-if="!props.isNoSearch"> 新增</a-button>
2023-04-16 14:17:50 +08:00
<a-button type="primary" class="pl1r" @click="handleEdit" preIcon="ant-design:plus-outlined"> 修改</a-button>
<a-button type="danger" class="pl1r" @click="batchHandleDelete" preIcon="ant-design:delete-outlined">删除</a-button>
</template>
</vxe-toolbar>
<JVxeTable
ref="tableRef"
row-number
row-selection
keep-source
clickSelectRow
bordered
rowSelectionType="radio"
:loading="loading"
:dataSource="dataSource"
:columns="columns"
:pagination="pagination"
style="margin-top: 8px"
2023-04-16 22:22:15 +08:00
@page-change="handlePageChange"
@value-change="valueChange"
@select-row-change="selectRowChange"
2023-04-16 14:17:50 +08:00
>
</JVxeTable>
2023-03-30 23:29:42 +08:00
<!-- 表单区域 -->
<KcKechengbiaoModal ref="registerModal" @success="handleSuccess"></KcKechengbiaoModal>
2023-04-16 22:22:15 +08:00
<!--引用表格-->
2023-04-01 22:06:31 +08:00
<KcKetangbiaoList v-show="selectedRows[0]" :currentRowKey="selectedRows[0]"/>
2023-03-30 23:29:42 +08:00
</div>
</template>
<script lang="ts" name="ktgl-kcKechengbiao" setup>
2023-04-16 22:22:15 +08:00
import { ref, reactive, onMounted, watch } from 'vue';
2023-04-16 14:17:50 +08:00
// import { BasicTable, useTable, TableAction } from '/@/components/Table';
// import { useListPage } from '/@/ho oks/system/useListPage';
2023-04-16 22:22:15 +08:00
import { propTypes } from '/@/utils/propTypes';
2023-04-01 22:06:31 +08:00
import { useMessage } from '/@/hooks/web/useMessage';
2023-04-16 22:22:15 +08:00
import { columns } from './KcKechengbiao.data';
import { list, batchDelete, saveOrUpdate } from './KcKechengbiao.api';
2023-03-30 23:29:42 +08:00
import KcKechengbiaoModal from './components/KcKechengbiaoModal.vue'
2023-04-01 22:06:31 +08:00
import JDictSelectTag from '/@/components/Form/src/jeecg/components/JDictSelectTag.vue';
import KcKetangbiaoList from './KcKetangbiaoList.vue'
2023-03-30 23:29:42 +08:00
2023-04-16 22:22:15 +08:00
import { JVxeTableInstance } from '/@/components/jeecg/JVxeTable/types';
2023-04-16 14:17:50 +08:00
import { filterObj } from '/@/utils/common/compUtils';
2023-04-16 22:22:15 +08:00
//--------------------------------------变量区---------------------------------------------------------------------------
2023-04-16 14:17:50 +08:00
2023-04-16 22:22:15 +08:00
const props = defineProps({
searchParam: propTypes.object.def({}),
isNoSearch: propTypes.bool.def(false)
});
2023-04-16 14:17:50 +08:00
2023-04-16 22:22:15 +08:00
const tableRef = ref<JVxeTableInstance>();
const loading = ref(false);
2023-04-16 14:17:50 +08:00
2023-04-16 22:22:15 +08:00
const selectedRows = ref([]);
const selectedRowKeys = ref([]);
2023-04-16 14:17:50 +08:00
const dataSource = ref<any[]>([]);
const pagination = reactive({
current: 1,
pageSize: 5,
pageSizeOptions: ['10', '20', '30', '100', '200'],
total: 0,
});
2023-04-16 22:22:15 +08:00
const queryParam = ref<any>({ });
const filterInfo = ref<any>({ xnxq: '2022-2023-2' });
const registerModal = ref();
const labelCol = reactive({ xs: { span: 24 }, sm: { span: 7 }, });
const wrapperCol = reactive({ xs: { span: 24 }, sm: { span: 16 }, });
2023-04-16 14:17:50 +08:00
2023-04-16 22:22:15 +08:00
const { createMessage } = useMessage();
2023-04-16 14:17:50 +08:00
2023-04-16 22:22:15 +08:00
//--------------------------------------变量区END------------------------------------------------------------------------
//--------------------------------------初始化---------------------------------------------------------------------------
2023-04-16 14:17:50 +08:00
2023-04-16 22:22:15 +08:00
onMounted(() => {
loadData(1);
})
2023-04-16 14:17:50 +08:00
2023-04-16 22:22:15 +08:00
watch(() => props.searchParam, async (newRow, oldRow) => {
reload();
});
//--------------------------------------初始化END---------------------------------------------------------------------------
//--------------------------------------与后台交互---------------------------------------------------------------------------
function loadData(pageNo?){
loading.value = true;
if(pageNo == 1){
pagination.current = 1;
}
//参数
let { current, pageSize } = pagination;
let param = { column: 'createTime', order: 'desc', pageNo: current, pageSize, ...queryParam.value, ...filterInfo.value, ...props.searchParam }
list(filterObj(param)).then(res => {
dataSource.value = res?.records??[];
pagination.total = res?.total??0;
//如果是隐藏模式,则直接选中
if(props.isNoSearch){
selectedRows.value = Array<never>(dataSource.value[0]);
console.log('tableRef =>',tableRef);
}
}).finally(() => {
// 这里是无论成功或失败都会执行的方法在这里关闭loading
loading.value = false;
});
}
// 部分数据保存
function saveByCell({ value, key, id }) {
createMessage.loading({ content: `正在保存!`, key: '_save_fake_data', duration: 0, });
const params = { id, };
params[key] = value;
return new Promise((resolve) => {
saveOrUpdate(params ,true).then(res => {
if (res.success) {
createMessage.success({ content: `记录已保存`, key: '_save_fake_data', duration: 2, });
resolve(true);
} else {
createMessage.error({ content: `保存失败:${res.message}`, key: '_save_fake_data', duration: 2, });
resolve(false);
}
});
});
}
//--------------------------------------与后台交互---------------------------------------------------------------------------
//--------------------------------------表格功能事件---------------------------------------------------------------------------
function selectRowChange({ selectedRows: rows, $table }) {
2023-04-16 14:17:50 +08:00
if(rows && rows[0]){
selectedRows.value = Array<never>(rows[0])
}else{
selectedRows.value = [];
}
}
function handlePageChange(event) {
2023-04-16 22:22:15 +08:00
// 重新赋值,分页
2023-04-16 14:17:50 +08:00
pagination.current = event.current;
pagination.pageSize = event.pageSize;
//查询数据
2023-04-16 22:22:15 +08:00
loadData();
2023-04-16 14:17:50 +08:00
}
function valueChange({ value, col, row }) {
let key = col?.key
let id = row?.id
2023-04-16 22:22:15 +08:00
//异步改数据
2023-04-16 14:17:50 +08:00
saveByCell({ value, key, id })
}
2023-04-16 22:22:15 +08:00
//--------------------------------------表格功能事件---------------------------------------------------------------------------
//--------------------------------------按钮以及其他功能---------------------------------------------------------------------------
2023-04-16 14:17:50 +08:00
2023-04-16 22:22:15 +08:00
/**
* 查询
*/
function searchQuery() {
reload();
2023-04-16 14:17:50 +08:00
}
2023-04-16 22:22:15 +08:00
/**
* 重置
*/
function searchReset() {
queryParam.value = {};
selectedRowKeys.value = [];
//刷新数据
reload();
}
2023-04-16 14:17:50 +08:00
2023-04-16 22:22:15 +08:00
//刷新列表数据
2023-04-16 14:17:50 +08:00
function reload() {
loadData(1);
}
2023-04-01 22:06:31 +08:00
2023-03-30 23:29:42 +08:00
/**
* 新增事件
*/
function handleAdd() {
registerModal.value.disableSubmit = false;
registerModal.value.add();
}
/**
* 编辑事件
*/
2023-04-12 23:21:42 +08:00
function handleEdit() {
let record = selectedRows.value[0];
if(!record){
createMessage.error('请您至少选择一条记录进行操作。');
return;
}
2023-03-30 23:29:42 +08:00
registerModal.value.disableSubmit = false;
registerModal.value.edit(record);
}
/**
* 批量删除事件
*/
async function batchHandleDelete() {
2023-04-12 23:21:42 +08:00
let record = selectedRows.value[0];
if(!record){
createMessage.error('请您至少选择一条记录进行操作。');
return;
}
2023-03-30 23:29:42 +08:00
await batchDelete({ ids: selectedRowKeys.value }, handleSuccess);
}
/**
* 成功回调
*/
function handleSuccess() {
(selectedRowKeys.value = []) && reload();
}
2023-04-16 22:22:15 +08:00
//--------------------------------------按钮以及其他功能---------------------------------------------------------------------------
2023-03-30 23:29:42 +08:00
</script>
<style lang="less" scoped>
.jeecg-basic-table-form-container {
.table-page-search-submitButtons {
display: block;
margin-bottom: 24px;
white-space: nowrap;
}
.query-group-cust{
width: calc(50% - 15px);
min-width: 100px !important;
}
.query-group-split-cust{
width: 30px;
display: inline-block;
text-align: center
}
}
2023-04-16 14:17:50 +08:00
.pl1r {
margin-left: 1rem;
}
2023-03-30 23:29:42 +08:00
</style>