修改清空表格选项-liyuchen

This commit is contained in:
李宇辰 2023-04-17 18:11:08 +08:00
parent 7ef200e879
commit 933ed73ed7
1 changed files with 9 additions and 2 deletions

View File

@ -11,7 +11,7 @@
search search
</el-button> </el-button>
</div> </div>
<el-table :data="state.tableData.data" :row-key="getRowKeys" @selection-change="handleSelectionChange"> <el-table :data="state.tableData.data" :row-key="getRowKeys" @selection-change="handleSelectionChange" ref="tableRef">
<el-table-column type="selection" width="55" :reserve-selection="true"/> <el-table-column type="selection" width="55" :reserve-selection="true"/>
<el-table-column property="dictValue" label="DisasterType" width="150" /> <el-table-column property="dictValue" label="DisasterType" width="150" />
<el-table-column property="disasterCountry" label="DisasterCountry" width="200" /> <el-table-column property="disasterCountry" label="DisasterCountry" width="200" />
@ -43,9 +43,10 @@
<script setup> <script setup>
import en from 'element-plus/dist/locale/en.mjs' import en from 'element-plus/dist/locale/en.mjs'
import {getPage,updateDisasterManage} from '/@/api/disasterInfo/index.js'; import {getPage,updateDisasterManage} from '/@/api/disasterInfo/index.js';
import {reactive} from "vue"; import {reactive, ref} from "vue";
import {ElMessage} from "element-plus"; import {ElMessage} from "element-plus";
const emit = defineEmits(['callback']); const emit = defineEmits(['callback']);
const tableRef = ref();
const state = reactive({ const state = reactive({
isShowDialog:false, isShowDialog:false,
table:false, table:false,
@ -86,11 +87,17 @@ const getDisaterInfo = () => {
// //
const closeDialog = () => { const closeDialog = () => {
state.isShowDialog = false; state.isShowDialog = false;
state.multipleSelection = [];
tableRef.value.clearSelection();
}; };
const onCancel = () => { const onCancel = () => {
closeDialog(); closeDialog();
} }
const onSubmit = () => { const onSubmit = () => {
if(state.multipleSelection.length == 0){
ElMessage.warning("Please check the data first");
return false;
}
//{"id":"","chiefId":""} //{"id":"","chiefId":""}
const saveRes = state.multipleSelection.map(item=> ({id:item.id,chiefId:state.chiefId})) const saveRes = state.multipleSelection.map(item=> ({id:item.id,chiefId:state.chiefId}))
updateDisasterManage(saveRes).then(res=>{ updateDisasterManage(saveRes).then(res=>{