init commit & 混料程序模块
This commit is contained in:
1
src/components/noTemplateComponents/README.md
Normal file
1
src/components/noTemplateComponents/README.md
Normal file
@@ -0,0 +1 @@
|
||||
用于存放没有模板的组件,一般用于表格中或弹窗里的组件插入
|
||||
31
src/components/noTemplateComponents/detailComponent.js
Normal file
31
src/components/noTemplateComponents/detailComponent.js
Normal file
@@ -0,0 +1,31 @@
|
||||
// import i18n from '@/i18n'
|
||||
|
||||
export default {
|
||||
name: 'TableTextComponent',
|
||||
props: {
|
||||
injectData: {
|
||||
type: Object,
|
||||
default: () => ({})
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
// for i18n inject:
|
||||
// defaultText: i18n.t('viewdetail')
|
||||
defaultText: '查看详情'
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
emitClick() {
|
||||
// console.log('inject data:' ,this.injectData)
|
||||
this.$emit('emit-data', {
|
||||
type: this.injectData.head?.actionName || 'view-detail-action',
|
||||
data: this.injectData.head?.emitFullData ? this.injectData : this.injectData.id
|
||||
})
|
||||
}
|
||||
},
|
||||
render: function (h) {
|
||||
// console.log('button content:', this.injectData)
|
||||
return h('span', null, [h('el-button', { props: { type: 'text' }, style: { paddingLeft: 0 }, on: { click: this.emitClick } }, this.injectData.head?.buttonContent || this.defaultText)])
|
||||
}
|
||||
}
|
||||
98
src/components/noTemplateComponents/operationComponent.js
Normal file
98
src/components/noTemplateComponents/operationComponent.js
Normal file
@@ -0,0 +1,98 @@
|
||||
// import i18n from '@/i18n'
|
||||
|
||||
export default {
|
||||
name: 'TableOperations',
|
||||
props: {
|
||||
injectData: {
|
||||
type: Object,
|
||||
default: () => ({})
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
btnTypes: {
|
||||
add: 'primary',
|
||||
delete: 'danger',
|
||||
detail: 'info'
|
||||
// add more...
|
||||
},
|
||||
colors: {
|
||||
delete: '#FF5454',
|
||||
preview: '#f09843',
|
||||
design: '#99089f',
|
||||
// 'view-trend': 'red'
|
||||
// add more...
|
||||
},
|
||||
text: {
|
||||
// TODO: i18n
|
||||
// edit: i18n.t('edit'),
|
||||
// detail: i18n.t('detail'),
|
||||
// delete: i18n.t('delete'),
|
||||
// viewAttr: i18n.t('viewattr'),
|
||||
// preview: i18n.t('preview'),
|
||||
// design: i18n.t('design'),
|
||||
edit: '编辑',
|
||||
detail: '详情',
|
||||
delete: '删除',
|
||||
viewAttr: '查看属性',
|
||||
preview: '预览',
|
||||
design: '设计',
|
||||
'view-trend': '查看趋势'
|
||||
// add more...
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// 发射事件
|
||||
emit(opt) {
|
||||
let emitFull = false
|
||||
let eventType = 'default'
|
||||
let customField
|
||||
if (typeof opt === 'object') {
|
||||
eventType = opt.name
|
||||
customField = opt.emitField || 'id'
|
||||
emitFull = opt.emitFull || false
|
||||
} else {
|
||||
eventType = opt
|
||||
}
|
||||
this.$emit('emit-data', { type: eventType, data: emitFull ? this.injectData : customField ? this.injectData[customField] : this.injectData.id })
|
||||
}
|
||||
},
|
||||
render: function (h) {
|
||||
let btns = []
|
||||
for (const opt of this.injectData.head?.options) {
|
||||
const optIsObj = typeof opt === 'object'
|
||||
|
||||
if (optIsObj) {
|
||||
// 可能需要验证权限,如 opt.permission 选项
|
||||
// 注意:为空字符串或null/undefined都会不验证权限
|
||||
if (!opt.permission || (opt.permission && this.$hasPermission(opt.permission))) {
|
||||
btns.push(
|
||||
h('el-button',
|
||||
{
|
||||
props: { type: 'text' },
|
||||
style: { color: this.colors[optionStr.name] || '#409EFF' },
|
||||
on: { click: this.emit.bind(null, opt) }
|
||||
},
|
||||
this.text[opt.name]
|
||||
)
|
||||
)
|
||||
}
|
||||
} else {
|
||||
// 此时 opt 是一个 string,且默认有操作权限
|
||||
btns.push(
|
||||
h('el-button',
|
||||
{
|
||||
props: { type: 'text' },
|
||||
style: { color: this.colors[opt] || '#409EFF' },
|
||||
on: { click: this.emit.bind(null, opt) }
|
||||
},
|
||||
this.text[opt]
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
return h('span', null, btns)
|
||||
}
|
||||
}
|
||||
2
src/components/noTemplateComponents/richInput.js
Normal file
2
src/components/noTemplateComponents/richInput.js
Normal file
@@ -0,0 +1,2 @@
|
||||
// 富文本组件
|
||||
export default {}
|
||||
47
src/components/noTemplateComponents/statusComponent.js
Normal file
47
src/components/noTemplateComponents/statusComponent.js
Normal file
@@ -0,0 +1,47 @@
|
||||
// import i18n from '@/i18n'
|
||||
|
||||
export default {
|
||||
name: 'StatusComponent',
|
||||
props: {
|
||||
injectData: {
|
||||
type: Object,
|
||||
default: () => ({})
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
statusText: [
|
||||
'正常',
|
||||
'异常',
|
||||
'损坏',
|
||||
// more...
|
||||
],
|
||||
statusType: [
|
||||
'success',
|
||||
'warning',
|
||||
'danger',
|
||||
// more...
|
||||
]
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
isEnabled() {
|
||||
return this.injectData && (this.injectData.enabled === 1 || this.injectData.enabled.toString() === '1')
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
console.log('[component] StatusComponent: ', this.injectData)
|
||||
},
|
||||
methods: {
|
||||
// 发射事件
|
||||
emit(opt) { }
|
||||
},
|
||||
render: function (h) {
|
||||
return h('el-tag',
|
||||
{
|
||||
props:
|
||||
{ type: this.isEnabled ? this.statusType[0] : this.statusType[1] }
|
||||
},
|
||||
this.isEnabled ? this.statusText[0] : this.statusText[1])
|
||||
}
|
||||
}
|
||||
2
src/components/noTemplateComponents/switchBtn.js
Normal file
2
src/components/noTemplateComponents/switchBtn.js
Normal file
@@ -0,0 +1,2 @@
|
||||
// 表格中的开关
|
||||
export default {}
|
||||
2
src/components/noTemplateComponents/textBtn.js
Normal file
2
src/components/noTemplateComponents/textBtn.js
Normal file
@@ -0,0 +1,2 @@
|
||||
// 表格中的可点击文本
|
||||
export default {}
|
||||
Reference in New Issue
Block a user