yudao-dev/src/components/tableInnerComponents.js
2024-03-27 16:28:09 +08:00

61 lines
1.1 KiB
JavaScript

/**
* 本文件保存一些 BaseTable 会用到的组件
*/
// 操作按钮
export const TableBtn = {
name: 'TableBtn',
props: ['injectData'],
data() {
return {};
},
methods: {
handleClick() {
this.$emit('emitData', {
action: this.injectData.label,
value: this.injectData,
});
},
},
render: function (h) {
return (
<el-button
type="text"
onClick={this.handleClick}>
{this.injectData.entryText}
</el-button>
);
},
};
// 余量
export const RemainBox = {
name: 'RemainBox',
props: ['injectData'],
data() {
return {};
},
computed: {
value() {
return this.injectData[this.injectData.prop] || null;
},
color() {
if (this.value) {
const v = +this.value;
return v < 0 ? '#FF5454' : v >= 0 && v < 2 ? '#FFD767' : '#37D97F';
}
return 'unset';
},
},
render: function (h) {
return (
<div
style={`background: ${
this.color
}; position:absolute; inset: 0; padding: 0 10px; display: flex; align-items: center; color: ${'#fff'}`}>
{this.injectData[this.injectData.prop]?.toFixed(0) || ''}
</div>
);
},
};