From 8021767ff24c11ccaee1d9eb297829f680ac7f54 Mon Sep 17 00:00:00 2001 From: wangqing <250543222@qq.com> Date: Sun, 11 Apr 2021 20:35:35 +0800 Subject: [PATCH] fix --- src/components/generator/config.js | 34 ++-- src/router/modules/root.js | 5 + src/utils/convert.js | 26 +-- src/utils/index.js | 3 + src/views/account/login.vue | 13 +- src/views/form/ProjectForm.vue | 7 +- src/views/form/index.vue | 47 ++--- src/views/form/logic.vue | 285 +++++++++++++++++++++++++++++ src/views/form/publish.vue | 9 +- src/views/form/write.vue | 6 +- src/views/project/MyProject.vue | 8 +- 11 files changed, 370 insertions(+), 73 deletions(-) create mode 100644 src/views/form/logic.vue diff --git a/src/components/generator/config.js b/src/components/generator/config.js index 82d0fa6..30d0a44 100644 --- a/src/components/generator/config.js +++ b/src/components/generator/config.js @@ -20,7 +20,7 @@ export const formConf = { export const inputComponents = [ { // 组件的自定义配置 - typeId: 1, + typeId: 'INPUT', __config__: { label: '单行文本', labelWidth: null, @@ -53,7 +53,7 @@ export const inputComponents = [ disabled: false }, { - typeId: 2, + typeId: 'TEXTAREA', __config__: { label: '多行文本', labelWidth: null, @@ -113,7 +113,7 @@ export const inputComponents = [ // disabled: false // }, { - typeId: 4, + typeId: 'NUMBER_INPUT', __config__: { label: '计数器', showLabel: true, @@ -142,7 +142,7 @@ export const inputComponents = [ // 选择型组件 【左面板】 export const selectComponents = [ { - typeId: 5, + typeId: 'SELECT', __config__: { label: '下拉选择', showLabel: true, @@ -173,7 +173,7 @@ export const selectComponents = [ multiple: false }, { - typeId: 6, + typeId: 'CASCADER', __config__: { label: '级联选择', url: 'https://www.fastmock.site/mock/f8d7a54fb1e60561e2f720d5a810009d/fg/cascaderList', @@ -219,7 +219,7 @@ export const selectComponents = [ separator: '/' }, { - typeId: 7, + typeId: 'RADIO', __config__: { label: '单选框组', labelWidth: null, @@ -250,7 +250,7 @@ export const selectComponents = [ disabled: false }, { - typeId: 8, + typeId: 'CHECKBOX', __config__: { label: '多选框组', tag: 'el-checkbox-group', @@ -283,7 +283,7 @@ export const selectComponents = [ disabled: false }, { - typeId: 9, + typeId: 'SWITCH', __config__: { label: '开关', tag: 'el-switch', @@ -308,7 +308,7 @@ export const selectComponents = [ 'inactive-value': false }, { - typeId: 10, + typeId: 'SLIDER', __config__: { label: '滑块', tag: 'el-slider', @@ -331,7 +331,7 @@ export const selectComponents = [ range: false }, { - typeId: 11, + typeId: 'TIME', __config__: { label: '时间选择', tag: 'el-time-picker', @@ -357,7 +357,7 @@ export const selectComponents = [ 'value-format': 'HH:mm:ss' }, { - typeId: 12, + typeId: 'TIME_RANGE', __config__: { label: '时间范围', tag: 'el-time-picker', @@ -383,7 +383,7 @@ export const selectComponents = [ 'value-format': 'HH:mm:ss' }, { - typeId: 13, + typeId: 'DATE', __config__: { label: '日期选择', tag: 'el-date-picker', @@ -408,7 +408,7 @@ export const selectComponents = [ readonly: false }, { - typeId: 14, + typeId: 'DATE_RANGE', __config__: { label: '日期范围', tag: 'el-date-picker', @@ -435,7 +435,7 @@ export const selectComponents = [ readonly: false }, { - typeId: 15, + typeId: 'RATE', __config__: { label: '评分', tag: 'el-rate', @@ -458,7 +458,7 @@ export const selectComponents = [ disabled: false }, { - typeId: 16, + typeId: 'COLOR', __config__: { label: '颜色选择', tag: 'el-color-picker', @@ -479,7 +479,7 @@ export const selectComponents = [ size: 'medium' }, { - typeId: 17, + typeId: 'UPLOAD', __config__: { label: '上传', tag: 'el-upload', @@ -516,7 +516,7 @@ export const selectComponents = [ // 布局型组件 【左面板】 export const imageComponents = [ { - typeId: 18, + typeId: 'IMAGE', __config__: { label: '图片展示', showLabel: false, diff --git a/src/router/modules/root.js b/src/router/modules/root.js index 29fdc62..2654277 100644 --- a/src/router/modules/root.js +++ b/src/router/modules/root.js @@ -107,6 +107,11 @@ export default [ meta: {requireLogin: false}, component: () => import(/* webpackChunkName: 'root' */ '@/views/form/ProjectForm.vue') }, + { + path: '/s/:key', + meta: {requireLogin: false}, + component: () => import(/* webpackChunkName: 'root' */ '@/views/form/write.vue') + }, { path: '/project/write', meta: {requireLogin: false}, diff --git a/src/utils/convert.js b/src/utils/convert.js index e3b3529..d09af54 100644 --- a/src/utils/convert.js +++ b/src/utils/convert.js @@ -90,19 +90,19 @@ export function dbDataConvertForItemJson(data) { let dataParams = { //单行文本 - 1: { + 'INPUT': { 'prepend': '__slot__.prepend', 'maxlength': 'maxlength', 'append': '__slot__.append' }, // 多行文本 - 2: { + 'TEXTAREA': { 'minRows': 'autosize.minRows', 'maxRows': 'autosize.maxRows', 'maxlength': 'maxlength' }, //计数器 - 4: { + 'NUMBER_INPUT': { 'min': 'min', 'max': 'max', 'maxlength': 'maxlength', @@ -112,44 +112,44 @@ let dataParams = { 'controls-position': 'controls-position' }, //下拉选择 - 5: { + 'SELECT': { 'options': '__slot__.options', 'filterable': 'filterable', 'multiple': 'multiple' }, //级联选择 - 6: { + 'CASCADER': { 'options': 'options', 'filterable': 'filterable', 'multiple': 'props.props.multiple' }, //单选框组 - 7: { + 'RADIO': { 'options': '__slot__.options', 'filterable': 'filterable', 'multiple': 'props.props.multiple' }, //多选框组 - 8: { + 'CHECKBOX': { 'optionType': '__config__.optionType', 'size': 'size', 'options': '__slot__.options', 'max': 'max', 'min': 'min' }, //开关 - 9: {}, + 'SWITCH': {}, //滑块 - 10: { + 'SLIDER': { 'min': 'min', 'max': 'max', 'step': 'step' },//时间选择 - 11: {}, - 15: { + 'TIME': {}, + 'RATE': { 'max': 'max' }, //文件上传 - 17: { + 'UPLOAD': { 'buttonText': '__config__.buttonText', 'showTip': '__config__.showTip', 'fileSize': '__config__.fileSize', @@ -160,7 +160,7 @@ let dataParams = { }, //图片 - 18: { + 'IMAGE': { 'src': 'src', 'alt': 'alt' } diff --git a/src/utils/index.js b/src/utils/index.js index f8afff1..744fcfe 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -108,6 +108,9 @@ export function jsonClone(obj) { return parse(stringify(obj)) } +export function jsonSimpleClone(obj){ + return JSON.parse(JSON.stringify(obj)) +} // 深拷贝对象 export function deepClone(obj) { const _toString = Object.prototype.toString diff --git a/src/views/account/login.vue b/src/views/account/login.vue index c677892..fc501df 100644 --- a/src/views/account/login.vue +++ b/src/views/account/login.vue @@ -60,9 +60,10 @@ @@ -86,7 +87,9 @@ - + 忘记密码? @@ -302,9 +305,7 @@ export default { qqLoginAuthorizeUrl: '' } }, - watch: { - - }, + watch: {}, created() { this.getLoginWxQrCode() this.refreshWxQrcodeTimer = setInterval(() => { diff --git a/src/views/form/ProjectForm.vue b/src/views/form/ProjectForm.vue index 29d1843..7fd0a2e 100644 --- a/src/views/form/ProjectForm.vue +++ b/src/views/form/ProjectForm.vue @@ -121,9 +121,10 @@ export default { return projectItem }) this.formConf.fields = fields - this.formConf.title = res.data.project.name - this.formConf.description = res.data.project.describe - this.formConf.description = res.data.project.describe + if (res.data.project) { + this.formConf.title = res.data.project.name + this.formConf.description = res.data.project.describe + } if (res.data.userProjectTheme) { this.projectTheme = res.data.userProjectTheme let {submitBtnText, showNumber, btnsColor} = res.data.userProjectTheme diff --git a/src/views/form/index.vue b/src/views/form/index.vue index 4b031d0..690540a 100644 --- a/src/views/form/index.vue +++ b/src/views/form/index.vue @@ -8,22 +8,24 @@ - - 编辑 - 外观 - 设置 - 发布 - 统计 + 编辑 + 逻辑 + 外观 + 设置 + 发布 + 统计 -
- - - - - +
+ + + + + +
@@ -34,6 +36,7 @@ import theme from './theme' import setting from './setting' import publish from './publish' import statistics from './statistics' +import logic from './logic' export default { components: { @@ -41,11 +44,12 @@ export default { theme, setting, publish, - statistics + statistics, + logic }, data() { return { - activeIndex: '1', + activeTab: 'editor', isEdit: false, projectKey: '' } @@ -56,24 +60,25 @@ export default { this.projectKey = this.$route.query.key this.isEdit = !!this.$route.query.active if (this.$route.query.active) { - this.activeIndex = this.$route.query.active + this.activeTab = this.$route.query.active } }, methods: { - handleSelect(key, keyPath) { - if (key) { - this.activeIndex = key + handleSelect(type, keyPath) { + if (type) { + this.activeTab = type + this.$router.replace({path: '/project/form', query: {key: this.projectKey, active: type}}) } } } } - diff --git a/src/views/form/logic.vue b/src/views/form/logic.vue new file mode 100644 index 0000000..5ee351b --- /dev/null +++ b/src/views/form/logic.vue @@ -0,0 +1,285 @@ + + + + + + diff --git a/src/views/form/publish.vue b/src/views/form/publish.vue index 5b00ebb..f4fc423 100644 --- a/src/views/form/publish.vue +++ b/src/views/form/publish.vue @@ -30,7 +30,7 @@ v-clipboard:error="()=>{this.msgError('复制失败')}" type="primary">复制链接 - + 停止发布 @@ -77,7 +77,7 @@ export default { }, mounted() { let url = window.location.protocol + '//' + window.location.host - this.writeLink = `${url}/project/write?key=${this.projectKey}` + this.writeLink = `${url}/s/${this.projectKey}` this.getProjectStatus() }, data() { @@ -91,7 +91,7 @@ export default { this.$api.get(`/user/project/${this.projectKey}`).then(res => { if (res.data.status == 2) { this.publishStatus = true - }else{ + } else { this.publishStatus = false } }) @@ -117,7 +117,7 @@ export default { let aLink = document.createElement('a') let blob = this.base64ToBlob(content) //new Blob([content]); let evt = document.createEvent('HTMLEvents') - evt.initEvent('click', true, true)//initEvent 不加后两个参数在FF下会报错 事件类型,是否冒泡,是否阻止浏览器的默认行为 + evt.initEvent('click', true, true)//initEvent 不加后两个参数在FF下会报错 事件类型,是否冒泡,是否阻止浏览器的默认行为 aLink.download = fileName aLink.href = URL.createObjectURL(blob) // aLink.dispatchEvent(evt); @@ -152,7 +152,6 @@ export default { padding: 0px; margin: 0; background-color: #F7F7F7; - font-family: "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "微软雅黑", Arial, sans-serif; min-height: 84vh; display: flex; align-items: center; diff --git a/src/views/form/write.vue b/src/views/form/write.vue index 10ba2de..b662e04 100644 --- a/src/views/form/write.vue +++ b/src/views/form/write.vue @@ -74,7 +74,7 @@ export default { document.getElementsByTagName('head')[0].appendChild(meta) }, created() { - let key = this.$route.query.key + let key = this.$route.query.key || this.$route.params.key this.projectConfig.projectKey = key let wxCode = getQueryString('code') if (wxCode) { @@ -89,7 +89,6 @@ export default { this.wxSignature = res.data this.setWxConfig() }) - console.log(ua) }, mounted() { this.viewProjectHandle() @@ -263,12 +262,11 @@ export default { .write-container { margin: 0; padding: 0; - //height: 100%; + height: 100%; width: 100%; } - .title-icon-view { display: flex; align-items: center; diff --git a/src/views/project/MyProject.vue b/src/views/project/MyProject.vue index 8b9e438..92c3625 100644 --- a/src/views/project/MyProject.vue +++ b/src/views/project/MyProject.vue @@ -93,13 +93,13 @@ >

创建时间:{{ p.createTime | formatDate }}

- + 编辑 统计 @@ -187,7 +187,7 @@