yqform-edit 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.prettierrc +20 -0
- package/LICENSE +21 -0
- package/README.md +27 -0
- package/dist/demo.html +10 -0
- package/dist/fonts/element-icons.535877f5.woff +0 -0
- package/dist/fonts/element-icons.732389de.ttf +0 -0
- package/dist/yqform-edit.common.js +73796 -0
- package/dist/yqform-edit.css +1 -0
- package/dist/yqform-edit.umd.js +73806 -0
- package/dist/yqform-edit.umd.min.js +23 -0
- package/package.json +59 -0
- package/src/App.vue +126 -0
- package/src/assets/global.scss +12 -0
- package/src/assets/images/content/add.png +0 -0
- package/src/assets/images/content/arrow-left.png +0 -0
- package/src/assets/images/content/arrow-right.png +0 -0
- package/src/assets/images/content/delete.png +0 -0
- package/src/assets/images/content/edit.png +0 -0
- package/src/assets/images/content/electricity.png +0 -0
- package/src/assets/images/content/item_plus.png +0 -0
- package/src/assets/images/content/radio_checked.png +0 -0
- package/src/assets/images/content/radio_uncheck.png +0 -0
- package/src/assets/images/content/slider_btn.png +0 -0
- package/src/assets/images/content/wifi.png +0 -0
- package/src/assets/logo.png +0 -0
- package/src/components/common/content/components/form-item/components/Picker.vue +144 -0
- package/src/components/common/content/components/form-item/form-item.vue +829 -0
- package/src/components/common/content/components/form-item/index.js +5 -0
- package/src/components/common/content/components/input-box/input-box.vue +29 -0
- package/src/components/common/content/content.vue +504 -0
- package/src/components/common/content/index.js +5 -0
- package/src/components/common/rightConfig/formConfig.vue +319 -0
- package/src/components/dynamic-form/components/component-content.vue +530 -0
- package/src/components/dynamic-form/components/component-options.vue +1112 -0
- package/src/components/dynamic-form/components/component-type.vue +588 -0
- package/src/components/dynamic-form/dynamic-form.vue +120 -0
- package/src/components/dynamic-form/index.js +40 -0
- package/src/index.js +69 -0
- package/src/main.js +62 -0
- package/src/store/e7ingForm.js +10 -0
- package/src/store/getters.js +22 -0
- package/src/store/index.js +10 -0
- package/src/store/mutations.js +106 -0
- package/src/store/state.js +321 -0
- package/src/utils/index.js +23 -0
package/package.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "yqform-edit",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"main": "dist/yqform-edit.umd.min.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"serve": "vue-cli-service serve",
|
|
8
|
+
"build": "vue-cli-service build",
|
|
9
|
+
"lint": "vue-cli-service lint",
|
|
10
|
+
"lib": "vue-cli-service build --target lib src/index.js"
|
|
11
|
+
},
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"@vant/area-data": "^1.3.2",
|
|
14
|
+
"@vant/touch-emulator": "^1.4.0",
|
|
15
|
+
"babel-plugin-component": "^1.1.1",
|
|
16
|
+
"core-js": "^3.6.5",
|
|
17
|
+
"dayjs": "^1.11.5",
|
|
18
|
+
"element-ui": "^2.15.10",
|
|
19
|
+
"lodash": "^4.17.21",
|
|
20
|
+
"vant": "^2.12.50",
|
|
21
|
+
"vue": "^2.6.14",
|
|
22
|
+
"vuedraggable": "^2.24.3",
|
|
23
|
+
"vuex": "^3.4.0"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@vue/cli-plugin-babel": "~4.5.17",
|
|
27
|
+
"@vue/cli-plugin-eslint": "~4.5.17",
|
|
28
|
+
"@vue/cli-plugin-vuex": "~4.5.17",
|
|
29
|
+
"@vue/cli-service": "~4.5.17",
|
|
30
|
+
"babel-eslint": "^10.1.0",
|
|
31
|
+
"babel-plugin-import": "^1.13.5",
|
|
32
|
+
"eslint": "^6.7.2",
|
|
33
|
+
"eslint-plugin-vue": "^6.2.2",
|
|
34
|
+
"sass": "^1.54.9",
|
|
35
|
+
"sass-loader": "10.1.1",
|
|
36
|
+
"vue-template-compiler": "^2.6.11"
|
|
37
|
+
},
|
|
38
|
+
"eslintConfig": {
|
|
39
|
+
"root": true,
|
|
40
|
+
"env": {
|
|
41
|
+
"node": true
|
|
42
|
+
},
|
|
43
|
+
"extends": [
|
|
44
|
+
"plugin:vue/essential",
|
|
45
|
+
"eslint:recommended"
|
|
46
|
+
],
|
|
47
|
+
"parserOptions": {
|
|
48
|
+
"parser": "babel-eslint"
|
|
49
|
+
},
|
|
50
|
+
"rules": {}
|
|
51
|
+
},
|
|
52
|
+
"browserslist": [
|
|
53
|
+
"> 1%",
|
|
54
|
+
"last 2 versions",
|
|
55
|
+
"not dead"
|
|
56
|
+
],
|
|
57
|
+
"_id": "questionnaire@0.1.0",
|
|
58
|
+
"readme": "ERROR: No README data found!"
|
|
59
|
+
}
|
package/src/App.vue
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div id="app">
|
|
3
|
+
<DynamicForm :form="form" ref="dynamicForm" />
|
|
4
|
+
</div>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script>
|
|
8
|
+
import DynamicForm from '@/components/dynamic-form/dynamic-form.vue'
|
|
9
|
+
|
|
10
|
+
export default {
|
|
11
|
+
name: 'E7ingForm',
|
|
12
|
+
emits: ['handleCoverImg'],
|
|
13
|
+
components: { DynamicForm },
|
|
14
|
+
props: {
|
|
15
|
+
pid: {
|
|
16
|
+
type: String,
|
|
17
|
+
required: false,
|
|
18
|
+
},
|
|
19
|
+
// 自定义题目的类型数组
|
|
20
|
+
expendQuestion: {
|
|
21
|
+
type: Array,
|
|
22
|
+
required: false,
|
|
23
|
+
},
|
|
24
|
+
// 请求下拉框数据的函数
|
|
25
|
+
remotePicker: {
|
|
26
|
+
type: Function,
|
|
27
|
+
required: false,
|
|
28
|
+
},
|
|
29
|
+
// 传入的表单
|
|
30
|
+
form: {
|
|
31
|
+
type: Object,
|
|
32
|
+
default: function () {
|
|
33
|
+
return {
|
|
34
|
+
spec: {
|
|
35
|
+
name: '',
|
|
36
|
+
theme: {
|
|
37
|
+
name: 'show',
|
|
38
|
+
color: '#07c160',
|
|
39
|
+
header: '',
|
|
40
|
+
footer: '',
|
|
41
|
+
},
|
|
42
|
+
unit: '页',
|
|
43
|
+
},
|
|
44
|
+
groups: [
|
|
45
|
+
{
|
|
46
|
+
gid: 'templeteData',
|
|
47
|
+
spec: {
|
|
48
|
+
title: '',
|
|
49
|
+
subtitle: '',
|
|
50
|
+
unit: '页',
|
|
51
|
+
},
|
|
52
|
+
items: [],
|
|
53
|
+
},
|
|
54
|
+
],
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
data() {
|
|
60
|
+
return {
|
|
61
|
+
formData: {
|
|
62
|
+
spec: {
|
|
63
|
+
name: '',
|
|
64
|
+
theme: {
|
|
65
|
+
name: 'show',
|
|
66
|
+
color: '#07c160',
|
|
67
|
+
header: '',
|
|
68
|
+
footer: '',
|
|
69
|
+
},
|
|
70
|
+
unit: '页',
|
|
71
|
+
},
|
|
72
|
+
groups: [
|
|
73
|
+
{
|
|
74
|
+
gid: 'templeteData',
|
|
75
|
+
spec: {
|
|
76
|
+
title: '',
|
|
77
|
+
subtitle: '',
|
|
78
|
+
unit: '页',
|
|
79
|
+
},
|
|
80
|
+
items: [],
|
|
81
|
+
},
|
|
82
|
+
],
|
|
83
|
+
},
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
provide() {
|
|
87
|
+
return {
|
|
88
|
+
getImgFile: this.emitsImgsFun,
|
|
89
|
+
pid: this.pid,
|
|
90
|
+
expendQuestion: this.expendQuestion,
|
|
91
|
+
remotePicker: this.remotePicker,
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
methods: {
|
|
95
|
+
emitsImgsFun(file, type, handle) {
|
|
96
|
+
this.$emit('handleCoverImg', file, type, handle)
|
|
97
|
+
},
|
|
98
|
+
resetPage() {
|
|
99
|
+
this.$refs.dynamicForm.resetPage()
|
|
100
|
+
},
|
|
101
|
+
goPage(index) {
|
|
102
|
+
this.$refs.dynamicForm.setPageIndex(index)
|
|
103
|
+
},
|
|
104
|
+
clearDepend() {
|
|
105
|
+
this.$refs.dynamicForm.clearDepend()
|
|
106
|
+
},
|
|
107
|
+
setCurrentKey(key) {
|
|
108
|
+
this.$refs.dynamicForm.setItemIndex(key)
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
created() {
|
|
112
|
+
if (Object.keys(this.form).length == 0) {
|
|
113
|
+
this.form.spec = this.formData.spec
|
|
114
|
+
this.form.groups = this.formData.groups
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
mounted() {},
|
|
118
|
+
}
|
|
119
|
+
</script>
|
|
120
|
+
<style lang="scss" scoped>
|
|
121
|
+
#app {
|
|
122
|
+
display: flex;
|
|
123
|
+
justify-content: center;
|
|
124
|
+
margin-top: 20px;
|
|
125
|
+
}
|
|
126
|
+
</style>
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<!-- 下拉框 -->
|
|
3
|
+
<div class="picker-box" v-if="item.type === 'picker'">
|
|
4
|
+
<div class="picker-text-area" :class="pickerVisible ? 'visible-style' : ''" @click="itemClick">
|
|
5
|
+
<div class="text">
|
|
6
|
+
<span class="placeholder" v-if="!textValue">{{ item.placeholder }}</span>
|
|
7
|
+
<span class="time-text" v-else>{{ textValue }}</span>
|
|
8
|
+
</div>
|
|
9
|
+
<div class="icon">
|
|
10
|
+
<van-icon name="arrow-up" v-if="pickerVisible" />
|
|
11
|
+
<van-icon name="arrow-down" v-else />
|
|
12
|
+
</div>
|
|
13
|
+
</div>
|
|
14
|
+
<div class="select-area" v-if="pickerVisible">
|
|
15
|
+
<div
|
|
16
|
+
class="picker-option"
|
|
17
|
+
:class="index === item.options.length - 1 ? 'last-option' : ''"
|
|
18
|
+
v-for="option, index of item.options"
|
|
19
|
+
:key="option.key"
|
|
20
|
+
@click="selectPicker(option)"
|
|
21
|
+
>
|
|
22
|
+
<div class="content">{{ option.content }}</div>
|
|
23
|
+
<div class="check">
|
|
24
|
+
<van-icon name="success" v-if="option.id === pickerSelected.id" />
|
|
25
|
+
</div>
|
|
26
|
+
</div>
|
|
27
|
+
</div>
|
|
28
|
+
</div>
|
|
29
|
+
</template>
|
|
30
|
+
|
|
31
|
+
<script>
|
|
32
|
+
|
|
33
|
+
export default {
|
|
34
|
+
name: 'picker-box',
|
|
35
|
+
props: {
|
|
36
|
+
item: {
|
|
37
|
+
type: Object,
|
|
38
|
+
required: true
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
data() {
|
|
42
|
+
return {
|
|
43
|
+
pickerOption: [],
|
|
44
|
+
textValue: '',
|
|
45
|
+
// 已选下拉
|
|
46
|
+
pickerSelected: {},
|
|
47
|
+
// 下拉
|
|
48
|
+
pickerVisible: false,
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
watch: {
|
|
52
|
+
item: {
|
|
53
|
+
handler (newItem) {
|
|
54
|
+
if (newItem.type === 'picker') {
|
|
55
|
+
this.pickerOption = []
|
|
56
|
+
newItem.options.forEach(i => {
|
|
57
|
+
this.pickerOption.push({
|
|
58
|
+
text: i.content,
|
|
59
|
+
value: i.label
|
|
60
|
+
})
|
|
61
|
+
})
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
deep: true,
|
|
65
|
+
immediate: true
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
methods: {
|
|
69
|
+
// 选择下拉
|
|
70
|
+
selectPicker (option) {
|
|
71
|
+
this.pickerSelected = option
|
|
72
|
+
this.textValue = option.content
|
|
73
|
+
this.pickerVisible = false
|
|
74
|
+
},
|
|
75
|
+
// 点击选项时
|
|
76
|
+
itemClick () {
|
|
77
|
+
this.pickerVisible = !this.pickerVisible
|
|
78
|
+
},
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
</script>
|
|
82
|
+
|
|
83
|
+
<style scoped lang="scss">
|
|
84
|
+
.picker-box {
|
|
85
|
+
.picker-text-area {
|
|
86
|
+
box-sizing: content-box;
|
|
87
|
+
height: 25px;
|
|
88
|
+
line-height: 25px;
|
|
89
|
+
padding: 10px 16px;
|
|
90
|
+
border: 1px solid rgba(225, 225, 230, 1);
|
|
91
|
+
border-radius: 3px;
|
|
92
|
+
display: flex;
|
|
93
|
+
justify-content: space-between;
|
|
94
|
+
.text {
|
|
95
|
+
font-size: 14px;
|
|
96
|
+
font-weight: 400;
|
|
97
|
+
letter-spacing: 0px;
|
|
98
|
+
color: rgba(54, 54, 54, 1);
|
|
99
|
+
overflow: hidden;
|
|
100
|
+
text-overflow: ellipsis;
|
|
101
|
+
white-space: nowrap;
|
|
102
|
+
word-break: break-all;
|
|
103
|
+
.placeholder {
|
|
104
|
+
color: rgba(200, 201, 204, 1);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
.icon {
|
|
108
|
+
color: rgba(150, 151, 153, 1);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
.visible-style {
|
|
112
|
+
border-bottom: none;
|
|
113
|
+
border-bottom-left-radius: none;
|
|
114
|
+
border-bottom-right-radius: none;
|
|
115
|
+
}
|
|
116
|
+
.select-area {
|
|
117
|
+
width: 100%;
|
|
118
|
+
border: 1px solid rgba(225, 225, 230, 1);
|
|
119
|
+
border-top: none;
|
|
120
|
+
overflow: hidden;
|
|
121
|
+
.picker-option {
|
|
122
|
+
display: flex;
|
|
123
|
+
justify-content: space-between;
|
|
124
|
+
width: 90%;
|
|
125
|
+
margin: 5px auto;
|
|
126
|
+
min-height: 25px;
|
|
127
|
+
line-height: 25px;
|
|
128
|
+
font-size: 14px;
|
|
129
|
+
font-weight: 400;
|
|
130
|
+
letter-spacing: 0px;
|
|
131
|
+
word-break: break-all;
|
|
132
|
+
color: rgba(54, 54, 54, 1);
|
|
133
|
+
border-bottom: 1px solid rgba(225, 225, 230, 1);
|
|
134
|
+
.check {
|
|
135
|
+
margin: auto 5px;
|
|
136
|
+
color: rgba(29, 184, 123, 1);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
.last-option {
|
|
140
|
+
border-bottom: none;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
</style>
|