update BaseSearchForm
This commit is contained in:
@@ -1,47 +1,69 @@
|
||||
// import i18n from '@/i18n'
|
||||
|
||||
export default {
|
||||
name: 'StatusComponent',
|
||||
name: "StatusComponent",
|
||||
props: {
|
||||
injectData: {
|
||||
type: Object,
|
||||
default: () => ({})
|
||||
}
|
||||
default: () => ({}),
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
statusText: [
|
||||
'正常',
|
||||
'异常',
|
||||
'损坏',
|
||||
"正常",
|
||||
"异常",
|
||||
"损坏",
|
||||
// more...
|
||||
],
|
||||
statusType: [
|
||||
'success',
|
||||
'warning',
|
||||
'danger',
|
||||
"success",
|
||||
"warning",
|
||||
"danger",
|
||||
// more...
|
||||
]
|
||||
}
|
||||
],
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
isEnabled() {
|
||||
return this.injectData && (this.injectData.enabled === 1 || this.injectData.enabled.toString() === '1')
|
||||
// isEnabled() {
|
||||
// return (
|
||||
// this.injectData &&
|
||||
// (this.injectData[this.injectData.head.prop ?? "enabled"] === 1 ||
|
||||
// this.injectData[this.injectData.head.prop ?? "enabled"].toString() === "1")
|
||||
// );
|
||||
// },
|
||||
propValue() {
|
||||
return this.injectData[this.injectData.head.prop ?? "enabled"] ?? 9527
|
||||
},
|
||||
type() {
|
||||
if (this.propValue === 9527) {
|
||||
return 'danger'
|
||||
}
|
||||
return this.statusType[this.propValue]
|
||||
},
|
||||
text() {
|
||||
if (this.propValue === 9527) {
|
||||
return '未知状态'
|
||||
}
|
||||
return this.statusText[this.propValue]
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
console.log('[component] StatusComponent: ', this.injectData)
|
||||
// console.log("[component] StatusComponent: ", this.injectData);
|
||||
},
|
||||
methods: {
|
||||
// 发射事件
|
||||
emit(opt) { }
|
||||
emit(opt) { },
|
||||
},
|
||||
render: function (h) {
|
||||
return h('el-tag',
|
||||
return h(
|
||||
"el-tag",
|
||||
{
|
||||
props:
|
||||
{ size: 'small', type: this.isEnabled ? this.statusType[0] : this.statusType[1] }
|
||||
// props: { size: "small", type: this.isEnabled ? this.statusType[0] : this.statusType[1] },
|
||||
props: { size: "small", type: this.type },
|
||||
},
|
||||
this.isEnabled ? this.statusText[0] : this.statusText[1])
|
||||
}
|
||||
}
|
||||
// this.isEnabled ? this.statusText[0] : this.statusText[1]
|
||||
this.text
|
||||
);
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user