mirror of
https://github.com/WeBankFinTech/fes.js.git
synced 2025-04-06 03:59:53 +08:00
feat: table 添加action disable 功能
This commit is contained in:
parent
2ae642fd72
commit
c287a54575
@ -16,6 +16,7 @@
|
|||||||
<Column prop="age" name="年龄" sort />
|
<Column prop="age" name="年龄" sort />
|
||||||
<Column prop="adr" name="地址" />
|
<Column prop="adr" name="地址" />
|
||||||
<Column prop="status" name="等级" />
|
<Column prop="status" name="等级" />
|
||||||
|
<Column name="操作" :action="action" />
|
||||||
</Wb-table>
|
</Wb-table>
|
||||||
<Wb-button class="mt20" @click="getSelectedTr">获取选择的行</Wb-button>
|
<Wb-button class="mt20" @click="getSelectedTr">获取选择的行</Wb-button>
|
||||||
</div>
|
</div>
|
||||||
@ -255,12 +256,24 @@ export default {
|
|||||||
func: function () {
|
func: function () {
|
||||||
console.log(this)
|
console.log(this)
|
||||||
console.log(arguments)
|
console.log(arguments)
|
||||||
|
},
|
||||||
|
disabled(trData) {
|
||||||
|
if (trData.name === '张晓刚') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
text: '删除',
|
text: '删除',
|
||||||
func: function () {
|
func: function () {
|
||||||
console.log(this)
|
console.log(this)
|
||||||
console.log(arguments)
|
console.log(arguments)
|
||||||
|
},
|
||||||
|
disabled(trData) {
|
||||||
|
if (trData.name !== '张晓刚') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}],
|
}],
|
||||||
component: function (trData, tdData) {
|
component: function (trData, tdData) {
|
||||||
@ -337,6 +350,12 @@ export default {
|
|||||||
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
disabledCell(trData) {
|
||||||
|
if (trData.name === '张晓刚') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
},
|
||||||
formatDate: function (data) {
|
formatDate: function (data) {
|
||||||
var year = data.getFullYear();
|
var year = data.getFullYear();
|
||||||
var m = data.getMonth();
|
var m = data.getMonth();
|
||||||
|
14238
packages/fes-ui/package-lock.json
generated
Normal file
14238
packages/fes-ui/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,19 +1,19 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="ui-table-action">
|
<div class="ui-table-action">
|
||||||
<Wb-button
|
<Wb-button
|
||||||
v-for="(item, index) in col.action"
|
v-for="(item, index) in actions"
|
||||||
:key="index"
|
:key="index"
|
||||||
@click.stop="fireAction(item, $event)"
|
:disabled="item._disabled"
|
||||||
class="ui-table-action-text"
|
:class="['ui-table-action-text', item.disabledClassName, item._disabled && 'disabled']"
|
||||||
type="text"
|
type="text"
|
||||||
|
@click.stop="fireAction(item, $event)"
|
||||||
>
|
>
|
||||||
{{item.text}}
|
{{ item.text }}
|
||||||
</Wb-button>
|
</Wb-button>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import WbButton from '../button';
|
import WbButton from '../button';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
WbButton
|
WbButton
|
||||||
@ -28,9 +28,25 @@ export default {
|
|||||||
default: undefined
|
default: undefined
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
actions() {
|
||||||
|
return this.col.action.map((item) => {
|
||||||
|
let _disabled = false;
|
||||||
|
if (typeof item.disabled === 'boolean') {
|
||||||
|
_disabled = item.disabled;
|
||||||
|
}
|
||||||
|
if (typeof item.disabled === 'function') {
|
||||||
|
_disabled = item.disabled(this.trData);
|
||||||
|
}
|
||||||
|
return Object.assign({_disabled}, item);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
fireAction(item, event) {
|
fireAction(item, event) {
|
||||||
this.$emit('on-click', item, this.trData, event);
|
if (!item._disabled) {
|
||||||
|
this.$emit('on-click', item, this.trData, event);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -73,6 +73,10 @@ $table-head-background-color: $background-color-base;
|
|||||||
&:first-child {
|
&:first-child {
|
||||||
padding-left: 0;
|
padding-left: 0;
|
||||||
}
|
}
|
||||||
|
&.disabled {
|
||||||
|
cursor: not-allowed;
|
||||||
|
color: #657180;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.ui-table-column-sorter {
|
.ui-table-column-sorter {
|
||||||
margin-left: 4px;
|
margin-left: 4px;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user