From 0eb5f7ee6d426e31cfad7445ed3399e7977cbc37 Mon Sep 17 00:00:00 2001 From: "wu.jian2" Date: Tue, 20 Jun 2023 09:58:29 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E9=9B=86mixins?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/StoredProcedureEditForm.vue | 2 +- .../packages/js/mixins/datasetMixin.js | 144 ++++++++++++++++++ 2 files changed, 145 insertions(+), 1 deletion(-) create mode 100644 data-room-ui/packages/js/mixins/datasetMixin.js diff --git a/data-room-ui/packages/DataSetManagement/src/StoredProcedureEditForm.vue b/data-room-ui/packages/DataSetManagement/src/StoredProcedureEditForm.vue index f1c6ace3..3caa393a 100644 --- a/data-room-ui/packages/DataSetManagement/src/StoredProcedureEditForm.vue +++ b/data-room-ui/packages/DataSetManagement/src/StoredProcedureEditForm.vue @@ -568,7 +568,7 @@ import 'codemirror/lib/codemirror.css' import 'codemirror/theme/nord.css' import 'codemirror/mode/sql/sql.js' import _ from 'lodash' -import { datasetMixins} from 'packages/js/mixins/datasetMixin' +import { datasetMixins } from 'packages/js/mixins/datasetMixin' export default { name: 'StoredProcedureEditForm', diff --git a/data-room-ui/packages/js/mixins/datasetMixin.js b/data-room-ui/packages/js/mixins/datasetMixin.js new file mode 100644 index 00000000..bda80a27 --- /dev/null +++ b/data-room-ui/packages/js/mixins/datasetMixin.js @@ -0,0 +1,144 @@ +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 }