style:单选多选
Showing
2 changed files
with
37 additions
and
40 deletions
1 | <!-- | 1 | <!-- |
2 | * @Description: | 2 | * @Description: |
3 | * @Autor: renchao | 3 | * @Autor: renchao |
4 | * @LastEditTime: 2023-11-16 14:11:46 | 4 | * @LastEditTime: 2024-01-17 13:32:55 |
5 | --> | 5 | --> |
6 | <template> | 6 | <template> |
7 | <!-- 主体权利信息查询 --> | 7 | <!-- 主体权利信息查询 --> |
... | @@ -39,7 +39,7 @@ | ... | @@ -39,7 +39,7 @@ |
39 | <!-- 表格 --> | 39 | <!-- 表格 --> |
40 | <div class="from-clues-content loadingtext"> | 40 | <div class="from-clues-content loadingtext"> |
41 | <lb-table ref="table" @row-click="handleRowClick" :page-size="pageData.pageSize" :calcHeight="300" | 41 | <lb-table ref="table" @row-click="handleRowClick" :page-size="pageData.pageSize" :calcHeight="300" |
42 | :current-page.sync="pageData.currentPage" :total="tableData.total" @size-change="handleSizeChange" @select="select" | 42 | :current-page.sync="pageData.currentPage" :total="tableData.total" @size-change="handleSizeChange" |
43 | @p-current-change="handleCurrentChange" @selection-change="handleSelectionChange" :column="tableData.columns" | 43 | @p-current-change="handleCurrentChange" @selection-change="handleSelectionChange" :column="tableData.columns" |
44 | :data="tableData.data"> | 44 | :data="tableData.data"> |
45 | </lb-table> | 45 | </lb-table> |
... | @@ -67,6 +67,7 @@ | ... | @@ -67,6 +67,7 @@ |
67 | }, | 67 | }, |
68 | data () { | 68 | data () { |
69 | return { | 69 | return { |
70 | radioVal: '', | ||
70 | loading: false, | 71 | loading: false, |
71 | queryForm: defaultParameters.defaultParameters(), | 72 | queryForm: defaultParameters.defaultParameters(), |
72 | tableData: { | 73 | tableData: { |
... | @@ -79,6 +80,28 @@ | ... | @@ -79,6 +80,28 @@ |
79 | }, | 80 | }, |
80 | mounted () { | 81 | mounted () { |
81 | sendThis(this); | 82 | sendThis(this); |
83 | if (this.sqywInfo.sqywdylx == "1") { | ||
84 | this.tableData.columns = [{ | ||
85 | label: '选择', | ||
86 | width: '50px', | ||
87 | render: (h, scope) => { | ||
88 | return ( | ||
89 | <div class="orgColumn"> | ||
90 | <el-radio onChange={() => { this.handleChange(scope.row) }} v-model={this.radioVal} label={scope.row.bdcdyid}> | ||
91 |   | ||
92 | </el-radio> | ||
93 | </div> | ||
94 | ) | ||
95 | } | ||
96 | }].concat(datas.columns()) | ||
97 | } else { | ||
98 | this.tableData.columns = | ||
99 | [{ | ||
100 | type: 'selection', | ||
101 | label: '全选', | ||
102 | width: '50' | ||
103 | }].concat(datas.columns()) | ||
104 | } | ||
82 | }, | 105 | }, |
83 | methods: { | 106 | methods: { |
84 | /** | 107 | /** |
... | @@ -151,21 +174,9 @@ | ... | @@ -151,21 +174,9 @@ |
151 | this.bdcdysz = val; | 174 | this.bdcdysz = val; |
152 | } | 175 | } |
153 | }, | 176 | }, |
154 | /** | 177 | handleChange () { |
155 | * @description: select | 178 | let arr = this.tableData.data.filter(item => item.bdcdyid == this.radioVal) |
156 | * @param {*} selection | 179 | this.bdcdysz = arr |
157 | * @param {*} row | ||
158 | * @author: renchao | ||
159 | */ | ||
160 | select (selection, row) { | ||
161 | if (this.sqywInfo.sqywdylx == "1") { | ||
162 | // 清除 所有勾选项 | ||
163 | this.$refs.table.clearSelection() | ||
164 | // 当表格数据都没有被勾选的时候 就返回 | ||
165 | // 主要用于将当前勾选的表格状态清除 | ||
166 | if (selection.length == 0) return | ||
167 | this.$refs.table.toggleRowSelection(row, true); | ||
168 | } | ||
169 | }, | 180 | }, |
170 | /** | 181 | /** |
171 | * @description: handleRowClick | 182 | * @description: handleRowClick |
... | @@ -174,26 +185,12 @@ | ... | @@ -174,26 +185,12 @@ |
174 | */ | 185 | */ |
175 | handleRowClick (row) { | 186 | handleRowClick (row) { |
176 | // 如果状态是1,那就是单选 | 187 | // 如果状态是1,那就是单选 |
188 | let refs = 'table'; | ||
177 | if (this.sqywInfo.sqywdylx == "1") { | 189 | if (this.sqywInfo.sqywdylx == "1") { |
178 | const bdcdysz = this.bdcdysz | 190 | this.bdcdysz = [row] |
179 | this.$refs.table.clearSelection() | 191 | this.radioVal = row.bdcdyid |
180 | if (bdcdysz.length == 1) { | ||
181 | bdcdysz.forEach(item => { | ||
182 | // 判断 如果当前的一行被勾选, 再次点击的时候就会取消选中 | ||
183 | if (item == row) { | ||
184 | this.$refs.table.toggleRowSelection(row, false); | ||
185 | } | ||
186 | // 不然就让当前的一行勾选 | ||
187 | else { | ||
188 | this.$refs.table.toggleRowSelection(row, true); | ||
189 | } | ||
190 | }) | ||
191 | } | ||
192 | else { | ||
193 | this.$refs.table.toggleRowSelection(row, true); | ||
194 | } | ||
195 | } else { | 192 | } else { |
196 | this.$refs.table.toggleRowSelection(row); | 193 | this.$refs[refs].toggleRowSelection(row) |
197 | } | 194 | } |
198 | }, | 195 | }, |
199 | /** | 196 | /** | ... | ... |
1 | /* | 1 | /* |
2 | * @Description: | 2 | * @Description: |
3 | * @Autor: renchao | 3 | * @Autor: renchao |
4 | * @LastEditTime: 2024-01-17 10:02:13 | 4 | * @LastEditTime: 2024-01-17 13:31:22 |
5 | */ | 5 | */ |
6 | import filter from '@/utils/filter.js' | 6 | import filter from '@/utils/filter.js' |
7 | let vm = null | 7 | let vm = null |
... | @@ -15,10 +15,10 @@ class data extends filter { | ... | @@ -15,10 +15,10 @@ class data extends filter { |
15 | } | 15 | } |
16 | columns () { | 16 | columns () { |
17 | return [ | 17 | return [ |
18 | { | 18 | // { |
19 | type: 'selection', | 19 | // type: 'selection', |
20 | selectable: this.selected | 20 | // selectable: this.selected |
21 | }, | 21 | // }, |
22 | { | 22 | { |
23 | label: '序号', | 23 | label: '序号', |
24 | type: 'index', | 24 | type: 'index', | ... | ... |
-
Please register or sign in to post a comment