Browse Source

表格勾选操作

pull/69/head
zq 2 months ago
parent
commit
1eb7c5cb17
  1. 71
      src/views/agent/siteServiceList.vue

71
src/views/agent/siteServiceList.vue

@ -10,9 +10,10 @@
<!-- page header --> <!-- page header -->
<div class="pageheader"> <div class="pageheader">
<div class="pageheader-left"> <div class="pageheader-left">
<el-checkbox @change="toggleAllSelection">全选</el-checkbox> <el-checkbox @change="toggleAllSelection" :indeterminate="isIndeterminate" v-model="selectAll">全选</el-checkbox>
<span class="checked-text">共80条已选0条</span> <span class="checked-text">{{ serviceList.length }}已选{{ selectedCount }}</span>
<GuipButton type="ignore" :btnstyle="btnInfostyleObj">批量删除</GuipButton>
<GuipButton type="ignore" :btnstyle="btnInfostyleObj" @click="bantchDelete">批量删除</GuipButton>
</div> </div>
<div class="pageheader-right"> <div class="pageheader-right">
<GuipButton type="primary" :btnstyle="btnstyleObj" @click="jumpAdd(1)">添加查重服务</GuipButton> <GuipButton type="primary" :btnstyle="btnstyleObj" @click="jumpAdd(1)">添加查重服务</GuipButton>
@ -23,11 +24,11 @@
<!-- page content --> <!-- page content -->
<el-form> <el-form>
<GuipTable :tableData="serviceList" ref="multipleTable" autoColumn="true" :loading="tableLoading"> <GuipTable :tableData="serviceList" ref="multipleTable" autoColumn="true" :loading="tableLoading"
@selection-change="handleSelectionChange" @select="handleSelect">
<el-table-column label="选择" width="70" header-align="center" align="center"> <el-table-column type="selection" width="100">
<template slot-scope="scope"> <template slot="header">
<el-checkbox @change="toggleSelection(scope.row)"></el-checkbox> <span class="selection-header-text">选择</span>
</template> </template>
</el-table-column> </el-table-column>
@ -164,6 +165,9 @@ export default {
}, },
data() { data() {
return { return {
selectedRows:[],//
selectAll: false,//
isIndeterminate: false,///
// AUTH // AUTH
token: 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE3NTAwNTM3MjQsIm5iZiI6MTc1MDA1MzcyNCwiZXhwIjoxNzUyNjQ1NzI0LCJ1c2VyIjoic3VidXNlciIsImxvZ2luX3R5cGUiOjAsImFpZCI6IjEifQ.xyIqBLelB-k6jCifgRevBJTyg_Qrm6m1e4OcHhOpepU', token: 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE3NTAwNTM3MjQsIm5iZiI6MTc1MDA1MzcyNCwiZXhwIjoxNzUyNjQ1NzI0LCJ1c2VyIjoic3VidXNlciIsImxvZ2luX3R5cGUiOjAsImFpZCI6IjEifQ.xyIqBLelB-k6jCifgRevBJTyg_Qrm6m1e4OcHhOpepU',
// //
@ -219,6 +223,11 @@ export default {
mounted() { mounted() {
this.getSiteServiceList(); this.getSiteServiceList();
}, },
computed: {
selectedCount() {
return this.selectedRows.length;
},
},
methods: { methods: {
jumpAdd(type){ jumpAdd(type){
this.$router.push(this.serviceAddUrl + '?type=' + type + '&uid=' + this.uid) this.$router.push(this.serviceAddUrl + '?type=' + type + '&uid=' + this.uid)
@ -226,9 +235,6 @@ export default {
toggleAllSelection() { toggleAllSelection() {
this.$refs.multipleTable.$refs.guiptable.toggleAllSelection(); this.$refs.multipleTable.$refs.guiptable.toggleAllSelection();
}, },
toggleSelection(row){
console.log(row)
},
// //
getSiteServiceList() { getSiteServiceList() {
this.tableLoading = true this.tableLoading = true
@ -250,6 +256,10 @@ export default {
console.error(error, 'error') console.error(error, 'error')
}) })
}, },
//
bantchDelete(){
console.log(this.selectedRows,'全部的选中项');
},
onSwitchChange(row){ onSwitchChange(row){
row.is_display = row.is_display == 1 ? 0 : 1 row.is_display = row.is_display == 1 ? 0 : 1
@ -259,6 +269,21 @@ export default {
obj.is_display = row.is_display obj.is_display = row.is_display
this.saveRequest('/agentnew/ajax_set_service_display_index', obj, row) this.saveRequest('/agentnew/ajax_set_service_display_index', obj, row)
}, },
handleSelect(selection, row) {
console.log('操作的行:', row);
console.log('当前所有选中行:', selection);
},
//
handleSelectionChange(rows) {
this.selectedRows = rows;
//
const allSelected = rows.length === this.serviceList.length;
const noneSelected = rows.length === 0;
this.selectAll = allSelected;
this.isIndeterminate = !noneSelected && !allSelected;
},
// //
handleEditClick(row, index, type) { handleEditClick(row, index, type) {
// //
@ -423,6 +448,30 @@ export default {
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
::v-deep .el-table__header-wrapper .el-checkbox {
display: none;
}
/* 隐藏表头的复选框 */
::v-deep .el-table__header-wrapper .el-checkbox {
display: none !important;
}
/* 确保选择文字可见 */
::v-deep .selection-header-text {
display: inline-block;
margin-left: 8px;
/* 调整位置 */
font-size: 14px;
color: #606266;
font-weight: bold;
}
/* 调整表头单元格的padding */
::v-deep .el-table .el-table__header th {
padding: 8px 0;
/* 根据需要调整 */
}
.flex-service-title{ .flex-service-title{
margin-bottom: 12px; margin-bottom: 12px;
} }

Loading…
Cancel
Save