123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- import _ from 'lodash'
- const datasetMixins = {
- props: {
- isEdit: {
- type: Boolean,
- default: false
- },
- datasetId: {
- type: String,
- default: null
- },
- datasetName: {
- type: String,
- default: ''
- },
- typeId: {
- type: String,
- default: ''
- },
- appCode: {
- type: String,
- default: ''
- }
- },
- data () {
- return {
- dataForm: {},
- dataPreviewList: [],
- structurePreviewList: [],
- structurePreviewListCopy: [],
- typeName: '',
- categoryData: [],
- current: 1,
- size: 10,
- totalCount: 0,
- fieldDescVisible: false,
- fieldsetVisible: false,
- tableLoading: false,
- saveLoading: false,
- saveText: '',
- typeSelect: [
- { value: 'String' },
- { value: 'Integer' },
- { value: 'Double' },
- { value: 'Long' },
- { value: 'Date' }
- ],
- }
- },
- methods: {
- /**
- * 使用字段名填充字段描述
- */
- fieldDescFill () {
- this.structurePreviewList.forEach(field => {
- if (field.fieldDesc === '' || !field.hasOwnProperty('fieldDesc')) {
- field.fieldDesc = field.fieldName
- }
- })
- this.save('form')
- this.fieldDescVisible = false
- },
- /**
- * 打开字段描述编辑弹窗
- */
- fieldDescEdit () {
- this.fieldDescVisible = false
- this.fieldsetVisible = true
- },
- /**
- * 跳过字段描述编辑直接保存
- */
- toSave () {
- this.save('form', true)
- this.fieldDescVisible = false
- },
- /**
- * 取消编辑字段
- */
- cancelField () {
- this.structurePreviewListCopy = _.cloneDeep(this.structurePreviewList)
- this.fieldsetVisible = false
- },
- /**
- * 保存字段设置
- */
- setField () {
- this.structurePreviewList = _.cloneDeep(this.structurePreviewListCopy)
- this.fieldsetVisible = false
- },
- /**
- * 清空分类选择
- */
- clearType () {
- this.typeName = ''
- this.dataForm.typeId = ''
- },
- /**
- * 分类展开高亮
- * @param $event
- */
- setCurrentNode ($event) {
- if ($event) {
- const key = this.dataForm.typeId || null
- this.$refs.categorySelectTree.setCurrentKey(key)
- }
- },
- /**
- * 分类选择
- * @param value
- */
- selectParentCategory (value) {
- this.dataForm.typeId = value.id
- this.typeName = value.name
- this.$refs.selectParentName.blur()
- },
- goBack () {
- this.$emit('back')
- },
- // 每页大小改变触发
- sizeChangeHandle (value) {
- this.size = value
- this.current = 1
- this.datasetTest(false)
- },
- // 当前页数改变
- currentChangeHandle (value) {
- this.current = value
- this.datasetTest(false)
- },
- // 表头添加提示
- renderHeader (h, { column, index }) {
- const labelLong = column.label.length // 表头label长度
- const size = 14 // 根据需要定义标尺,直接使用字体大小确定就行,也可以根据需要定义
- column.minWidth = labelLong * size < 120 ? 120 : labelLong * size // 根据label长度计算该表头最终宽度
- return h('span', { class: 'cell-content', style: { width: '100%' } }, [column.label])
- },
- openNewWindow (url) {
- window.open(url, '_blank')
- }
- }
- }
- export { datasetMixins }
|