dbsd_kczx/src/views/kc/szkc/components/YcKechengbiaoList.vue

215 lines
6.6 KiB
Vue
Raw Normal View History

2023-05-27 10:45:45 +08:00
<template>
<div>
<!--查询区域-->
<div class="jeecg-basic-table-form-container" v-if="!props.isNoSearch">
<a-form @keyup.enter.native="searchQuery" :model="queryParam" :label-col="labelCol" :wrapper-col="wrapperCol">
<a-row :gutter="24">
<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 :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-col>
</span>
</a-col>
</a-row>
</a-form>
</div>
<vxe-toolbar>
<template #buttons>
</template>
</vxe-toolbar>
<JVxeTable
ref="tableRef"
row-number
row-selection
keep-source
clickSelectRow
rowSelectionType="checkbox"
bordered
:loading="loading"
:dataSource="dataSource"
:columns="columns"
:pagination="pagination"
style="margin-top: 8px"
@page-change="handlePageChange"
@value-change="valueChange"
@select-row-change="selectRowChange"
>
</JVxeTable>
</div>
</template>
<script lang="ts" name="ktgl-kcKechengbiao" setup>
import { ref, reactive, onMounted, watch } from 'vue';
import { propTypes } from '/@/utils/propTypes';
import { useMessage } from '/@/hooks/web/useMessage';
import { columns } from './XzKechengbiao.data';
import { list, batchDelete,deleteOne, saveOrUpdate } from './XzKechengbiao.api';
import JDictSelectTag from '/@/components/Form/src/jeecg/components/JDictSelectTag.vue';
import { JVxeTableInstance } from '/@/components/jeecg/JVxeTable/types';
import { filterObj } from '/@/utils/common/compUtils';
import { defHttp } from '/@/utils/http/axios';
const emit = defineEmits(['register', 'ok']);
//--------------------------------------变量区---------------------------------------------------------------------------
const props = defineProps({
searchParam: propTypes.object.def({}),
isNoSearch: propTypes.bool.def(false)
});
const tableRef = ref<JVxeTableInstance>();
const loading = ref(false);
const selectedRows = ref<any[]>([]);
const selectedRowKeys = ref([]);
const dataSource = ref<any[]>([]);
const pagination = reactive({
current: 1,
pageSize: 10,
pageSizeOptions: ['10', '20', '30', '100', '200'],
total: 0,
});
const queryParam = ref<any>({ });
const filterInfo = ref<any>({ });
const registerModal = ref();
const labelCol = reactive({ xs: { span: 24 }, sm: { span: 7 }, });
const wrapperCol = reactive({ xs: { span: 24 }, sm: { span: 16 }, });
const { createMessage } = useMessage();
//--------------------------------------变量区END------------------------------------------------------------------------
//--------------------------------------初始化---------------------------------------------------------------------------
function add(){
reload()
}
async function submitForm() {
const list = selectedRows.value
for(var i=0;i<list.length;i++){
const info = list[i];
info.szkc = '1'
await saveOrUpdate(info, false).then((res) => {})
}
var url = "/kcSzkc/kcSzkc/addBatch";
var params = {};
defHttp.post({ url: url, params }, { isTransformResponse: false });
createMessage.success("操作成功");
emit('ok');
}
onMounted(() => {
loadData(1);
})
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 = {ywcol:'le20',szkc:'1',kkdw:'马列教研室', column: 'kcbh', 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;
}).finally(() => {
// 这里是无论成功或失败都会执行的方法在这里关闭loading
loading.value = false;
});
}
// 部分数据保存
//--------------------------------------与后台交互---------------------------------------------------------------------------
//--------------------------------------表格功能事件---------------------------------------------------------------------------
function selectRowChange(event) {
selectedRows.value = event.selectedRows;
}
function handlePageChange(event) {
// 重新赋值,分页
pagination.current = event.current;
pagination.pageSize = event.pageSize;
//查询数据
loadData();
}
function valueChange({ value, col, row }) {
let key = col?.key
let id = row?.id
}
//--------------------------------------表格功能事件---------------------------------------------------------------------------
//--------------------------------------按钮以及其他功能---------------------------------------------------------------------------
/**
* 查询
*/
function searchQuery() {
reload();
}
/**
* 重置
*/
function searchReset() {
queryParam.value = {};
selectedRowKeys.value = [];
//刷新数据
reload();
}
//刷新列表数据
function reload() {
loadData(1);
}
defineExpose({
add,
submitForm,
});
//--------------------------------------按钮以及其他功能---------------------------------------------------------------------------
</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
}
}
.pl1r {
margin-left: 1rem;
}
</style>