新版UI适配
This commit is contained in:
1 parent
55dfcee93e
commit
73d6daacc7
17 files changed
+1542
-1991
No files matched your search
@@ -11,17 +11,20 @@
|
||||
<el-input v-model="flowData.Remark" type="textarea" :autosize="{ minRows: 2, maxRows: 4}"></el-input>
|
||||
</el-form-item>
|
||||
</el-form> -->
|
||||
|
||||
|
||||
<v-form v-model="isFormValid" ref="dataForm" lazy-validation>
|
||||
<v-row class="pa-0 ma-0 pa-xs-4 pb-xs-4 flex-none">
|
||||
<v-col cols="12" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-text-field class="cus-v-input mr-2" dense outlined label="GUID" v-model="flowData.Id"></v-text-field>
|
||||
<v-row class="px-2" :class="{'pb-7': isMobile}">
|
||||
<v-col cols="12" class=" pb-3">
|
||||
<span class="inputLabel">GUID</span>
|
||||
<v-text-field class="cus-v-input mr-2" dense filled single-line label="GUID" v-model="flowData.Id"></v-text-field>
|
||||
</v-col>
|
||||
<v-col cols="12" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-text-field class="cus-v-input mr-2" dense outlined label="流程名称" v-model="flowData.Name"></v-text-field>
|
||||
<v-col cols="12" class=" pb-3">
|
||||
<span class="inputLabel">流程名称</span>
|
||||
<v-text-field class="cus-v-input mr-2" dense filled single-line label="流程名称" v-model="flowData.Name"></v-text-field>
|
||||
</v-col>
|
||||
<v-col cols="12" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-text-field class="cus-v-input mr-2" dense outlined label="备注" v-model="flowData.Remark"></v-text-field>
|
||||
<v-col cols="12" class=" pb-3">
|
||||
<span class="inputLabel">备注</span>
|
||||
<v-text-field class="cus-v-input mr-2" dense filled single-line label="备注" v-model="flowData.Remark"></v-text-field>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-form>
|
||||
@@ -38,6 +41,11 @@
|
||||
isFormValid: true
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
isMobile() {
|
||||
return window.innerWidth < 600;
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
init(data) {
|
||||
this.flowData = data;
|
||||
|
||||
@@ -16,36 +16,44 @@
|
||||
<el-input v-model="line.Remark" type="textarea" :autosize="{ minRows: 2, maxRows: 4}"></el-input>
|
||||
</el-form-item>
|
||||
</el-form> -->
|
||||
|
||||
|
||||
<v-form v-model="isFormValid" ref="dataForm" lazy-validation>
|
||||
<v-row class="pa-0 ma-0 pa-xs-4 pb-xs-4 flex-none">
|
||||
<v-col cols="12" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-text-field class="cus-v-input mr-2" dense outlined label="GUID" v-model="line.id"></v-text-field>
|
||||
<v-row class="px-2" :class="{'pb-7': isMobile}">
|
||||
<v-col cols="12" class=" pb-3">
|
||||
<span class="inputLabel">GUID</span>
|
||||
<v-text-field class="cus-v-input mr-2" dense filled single-line label="GUID" v-model="line.id"></v-text-field>
|
||||
</v-col>
|
||||
<v-col cols="12" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-text-field class="cus-v-input mr-2" dense outlined disabled label="源活动" v-model="line.from"></v-text-field>
|
||||
<v-col cols="12" class=" pb-3">
|
||||
<span class="inputLabel">源活动</span>
|
||||
<v-text-field class="cus-v-input mr-2" dense filled single-line disabled label="源活动" v-model="line.from"></v-text-field>
|
||||
</v-col>
|
||||
<v-col cols="12" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-text-field class="cus-v-input mr-2" dense outlined disabled label="目标活动" v-model="line.to"></v-text-field>
|
||||
<v-col cols="12" class=" pb-3">
|
||||
<span class="inputLabel">目标活动</span>
|
||||
<v-text-field class="cus-v-input mr-2" dense filled single-line disabled label="目标活动" v-model="line.to"></v-text-field>
|
||||
</v-col>
|
||||
<v-col cols="12" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-text-field class="cus-v-input mr-2" dense outlined label="名称" v-model="line.label"></v-text-field>
|
||||
<v-col cols="12" class=" pb-3">
|
||||
<span class="inputLabel">名称</span>
|
||||
<v-text-field class="cus-v-input mr-2" dense filled single-line label="名称" v-model="line.label"></v-text-field>
|
||||
</v-col>
|
||||
<v-col cols="12" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-col cols="12" class=" pb-3">
|
||||
<span class="inputLabel">操作类型</span>
|
||||
<v-select
|
||||
:items="lineTypeList"
|
||||
dense outlined
|
||||
dense filled single-line
|
||||
class="cus-v-input mr-2"
|
||||
label="操作类型"
|
||||
outlined
|
||||
color="success"
|
||||
item-color="success"
|
||||
v-model="line.type"
|
||||
></v-select>
|
||||
</v-col>
|
||||
<v-col cols="12" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-text-field class="cus-v-input mr-2" dense outlined label="任务Resource" v-model="line.hook"></v-text-field>
|
||||
<v-col cols="12" class=" pb-3">
|
||||
<span class="inputLabel">任务Resource</span>
|
||||
<v-text-field class="cus-v-input mr-2" dense filled single-line label="任务Resource" v-model="line.hook"></v-text-field>
|
||||
</v-col>
|
||||
<v-col cols="12" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-text-field class="cus-v-input mr-2" dense outlined label="备注说明" v-model="line.Remark"></v-text-field>
|
||||
<v-col cols="12" class=" pb-3">
|
||||
<span class="inputLabel">备注说明</span>
|
||||
<v-text-field class="cus-v-input mr-2" dense filled single-line label="备注说明" v-model="line.Remark"></v-text-field>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-form>
|
||||
@@ -74,6 +82,11 @@
|
||||
deep: true
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
isMobile() {
|
||||
return window.innerWidth < 600;
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
init(item, lineTypeList) {
|
||||
this.isUpdate = false;
|
||||
@@ -85,4 +98,4 @@
|
||||
},
|
||||
}
|
||||
})
|
||||
</script>
|
||||
</script>
|
||||
@@ -19,34 +19,42 @@
|
||||
</el-form> -->
|
||||
|
||||
<v-form v-model="isFormValid" ref="dataForm" lazy-validation>
|
||||
<v-row class="pa-0 ma-0 pa-xs-4 pb-xs-4 flex-none">
|
||||
<v-col cols="12" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-text-field class="cus-v-input" dense outlined label="GUID" v-model="node.id"></v-text-field>
|
||||
<v-row class="px-2" :class="{'pb-7': isMobile}">
|
||||
<v-col cols="12" class=" pb-3">
|
||||
<span class="inputLabel">GUID</span>
|
||||
<v-text-field class="cus-v-input" dense filled single-line label="GUID" v-model="node.id"></v-text-field>
|
||||
</v-col>
|
||||
<v-col cols="12" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-text-field class="cus-v-input" dense outlined label="名称" v-model="node.label"></v-text-field>
|
||||
<v-col cols="12" class=" pb-3">
|
||||
<span class="inputLabel">名称</span>
|
||||
<v-text-field class="cus-v-input" dense filled single-line label="名称" v-model="node.label"></v-text-field>
|
||||
</v-col>
|
||||
<v-col cols="12" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-text-field class="cus-v-input" dense outlined label="备注说明" v-model="node.Remark"></v-text-field>
|
||||
<v-col cols="12" class=" pb-3">
|
||||
<span class="inputLabel">备注说明</span>
|
||||
<v-text-field class="cus-v-input" dense filled single-line label="备注说明" v-model="node.Remark"></v-text-field>
|
||||
</v-col>
|
||||
|
||||
<v-col cols="12" v-if="showTask" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
|
||||
|
||||
<v-col cols="12" class=" pb-3">
|
||||
<span class="inputLabel">名称</span>
|
||||
|
||||
<v-select
|
||||
:items="assignTypeList"
|
||||
dense outlined
|
||||
dense filled single-line
|
||||
item-text="text"
|
||||
color="success"
|
||||
item-color="success"
|
||||
item-value="value"
|
||||
class="cus-v-input"
|
||||
label="指派类型"
|
||||
outlined
|
||||
v-model="node.assignType"
|
||||
></v-select>
|
||||
</v-col>
|
||||
<v-col cols="12" v-if="showTask" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-col cols="12" class=" pb-3">
|
||||
<span class="inputLabel">名称</span>
|
||||
<v-select
|
||||
:items="optionList"
|
||||
dense outlined
|
||||
color="success"
|
||||
item-color="success"
|
||||
dense filled single-line
|
||||
item-text="text"
|
||||
item-value="value"
|
||||
class="cus-v-input"
|
||||
@@ -56,22 +64,26 @@
|
||||
:disabled="!node.assignType"
|
||||
></v-select>
|
||||
</v-col>
|
||||
<v-col cols="12" v-if="showTask" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-col cols="12" class=" pb-3">
|
||||
<span class="inputLabel">名称</span>
|
||||
<!-- <v-textarea
|
||||
outlined
|
||||
filled single-line
|
||||
name="input-7-4"
|
||||
label="允许的操作"
|
||||
value=""
|
||||
rows="3"
|
||||
hide-details
|
||||
></v-textarea> -->
|
||||
<v-text-field class="cus-v-input" dense outlined label="允许的操作(英文逗号分隔)" v-model="node.lineTypeList"></v-text-field>
|
||||
<v-text-field class="cus-v-input" dense filled single-line label="允许的操作(英文逗号分隔)" v-model="node.lineTypeList"></v-text-field>
|
||||
</v-col>
|
||||
<v-col cols="12" v-if="showTask" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-col cols="12" class=" pb-3">
|
||||
<span class="inputLabel">名称</span>
|
||||
<v-select
|
||||
:items="tpl"
|
||||
dense outlined
|
||||
dense filled single-line
|
||||
item-text="text"
|
||||
color="success"
|
||||
item-color="success"
|
||||
item-value="value"
|
||||
class="cus-v-input"
|
||||
label="可写模板"
|
||||
@@ -79,12 +91,15 @@
|
||||
v-model="node.formId"
|
||||
></v-select>
|
||||
</v-col>
|
||||
<v-col cols="12" v-if="showTask" class="pa-xs-0 pb-xs-4 pb-3">
|
||||
<v-col cols="12" class=" pb-3">
|
||||
<span class="inputLabel">名称</span>
|
||||
<v-select
|
||||
:items="tpl"
|
||||
dense outlined
|
||||
dense filled single-line
|
||||
item-text="text"
|
||||
item-value="value"
|
||||
color="success"
|
||||
item-color="success"
|
||||
class="cus-v-input"
|
||||
label="隐藏模板"
|
||||
multiple
|
||||
@@ -134,8 +149,10 @@
|
||||
},
|
||||
watch: {
|
||||
},
|
||||
created() {},
|
||||
computed: {
|
||||
isMobile() {
|
||||
return window.innerWidth < 600;
|
||||
},
|
||||
showTask() {
|
||||
return ['userTask', 'receiveTask'].includes(this.node.type);
|
||||
},
|
||||
@@ -182,4 +199,4 @@
|
||||
.v-textarea textarea {
|
||||
line-height: 1.2rem;
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
@@ -31,6 +31,9 @@
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
isMobile() {
|
||||
return window.innerWidth < 600;
|
||||
},
|
||||
// 节点容器样式
|
||||
flowNodeContainer: {
|
||||
get() {
|
||||
@@ -140,4 +143,4 @@
|
||||
opacity: 0;
|
||||
cursor: crosshair;
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
@@ -1,35 +1,52 @@
|
||||
<template id="process-flow">
|
||||
<div class="process-flow-container">
|
||||
<div class="flow-menu">
|
||||
<div class="menu-item" v-for="item in menuList" draggable="true" @dragstart="drag(item)">
|
||||
<v-card class="flow-menu pa-4 mr-4" color="#f5f8fa" width="140px">
|
||||
<div block color="white" class="menu-item mb-3" v-for="item in menuList" draggable="true" @dragstart="drag(item)">
|
||||
<i :class="item.icon"></i>
|
||||
<div>{{item.name}}</div>
|
||||
</div>
|
||||
<hr>
|
||||
<div class="menu-item" @click="isConnect=true">
|
||||
<v-divider></v-divider>
|
||||
<v-btn block class="menu-item mt-3" :color="isConnect ? 'success' : 'white'" @click="isConnect=true">
|
||||
<i class="el-icon-bottom-right"></i>
|
||||
<div>连线</div>
|
||||
</div>
|
||||
<div class="menu-item" @click="isConnect=false">
|
||||
</v-btn>
|
||||
<v-btn block class="menu-item" :color="!isConnect ? 'success' : 'white'" @click="isConnect=false">
|
||||
<i class="el-icon-rank"></i>
|
||||
<div>选择</div>
|
||||
</div>
|
||||
</v-btn>
|
||||
|
||||
</div>
|
||||
<div class="flow-detail">
|
||||
</v-card>
|
||||
<v-card class="flow-detail pa-4 mr-4" color="#f5f8fa">
|
||||
<div id="flowContent" ref="flowContent" @drop="drop($event)" @dragover="allowDrop($event)" @click="editFlow()"
|
||||
@dblclick="isConnect=false">
|
||||
<flow-node v-for="node in data.nodeList" :key="node.id" :node="node" :id="node.id" :isconnect="isConnect"
|
||||
@delete-node="deleteNode" @change-node-site="changeNodeSite" @edit-node="editNode">
|
||||
</flow-node>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flow-edit" v-if="editType">
|
||||
<div class="flow-edit-content">
|
||||
<edit-node ref="nodeForm" v-show="editType=='node'" :user="user" :group="group" :tpl="tpl"></edit-node>
|
||||
<edit-line ref="lineForm" v-show="editType=='line'" @line-save="lineLabelSave"></edit-line>
|
||||
</div>
|
||||
</div>
|
||||
</v-card>
|
||||
<v-card class="flow-edit pa-4" v-if="editType" color="#f5f8fa">
|
||||
<template v-if="editType=='node' || editType=='line'">
|
||||
<div class="mb-3">
|
||||
<v-icon>mdi-application-edit-outline</v-icon>
|
||||
<span style="transform: translateY(2px); display: inline-block; ">{{editType=='node' ? '节点' : '连线'}}属性</span>
|
||||
</div>
|
||||
<v-card>
|
||||
<div class="flow-edit-content">
|
||||
<edit-node ref="nodeForm" v-show="editType=='node'" :user="user" :group="group" :tpl="tpl"></edit-node>
|
||||
<edit-line ref="lineForm" v-show="editType=='line'" @line-save="lineLabelSave"></edit-line>
|
||||
</div>
|
||||
</v-card>
|
||||
</template>
|
||||
<template v-else>
|
||||
<div class="mb-3">
|
||||
<v-icon>mdi-application-edit-outline</v-icon>
|
||||
<span style="transform: translateY(2px); display: inline-block; ">属性面板</span>
|
||||
</div>
|
||||
<div style="text-align: center;line-height: 100px; color: #999999">
|
||||
请选择节点或连接线
|
||||
</div>
|
||||
</template>
|
||||
</v-card>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
@@ -249,7 +266,7 @@
|
||||
_this.jsPlumb.importDefaults(_this.jsplumbSetting)
|
||||
// 会使整个jsPlumb立即重绘。
|
||||
_this.jsPlumb.setSuspendDrawing(false, true);
|
||||
|
||||
|
||||
// 初始化节点
|
||||
_this.loadEasyFlow()
|
||||
|
||||
@@ -466,12 +483,12 @@
|
||||
if (!lineTypeList.includes(item.type) ) {
|
||||
// 1 - 删除画布连线 | 2 - 清空line的操作属性
|
||||
// _this.jsPlumb.deleteConnection(conn)
|
||||
|
||||
|
||||
// 从 lineList 数组移除
|
||||
// _this.data.lineList.splice(index,1);
|
||||
// 不渲染表单
|
||||
// return
|
||||
|
||||
|
||||
// 默认修改类型为第一个
|
||||
if (!preNode.id.includes('start-')) {
|
||||
if (add) {
|
||||
@@ -591,10 +608,7 @@
|
||||
|
||||
.flow-menu {
|
||||
width: 100px;
|
||||
padding: 10px;
|
||||
margin: 0 10px;
|
||||
border: 1px solid #EBEEF5;
|
||||
padding: 12px;
|
||||
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, .1);
|
||||
word-break: break-all;
|
||||
border-radius: 4px;
|
||||
@@ -602,14 +616,17 @@
|
||||
|
||||
.menu-item {
|
||||
text-align: center;
|
||||
box-shadow: 0 0 4px #696969;
|
||||
margin-bottom: 8px;
|
||||
cursor: pointer;
|
||||
font-size: 14px;
|
||||
color: #606266;
|
||||
background: #FFFFFF;
|
||||
padding: 5px 0;
|
||||
border-radius: 5px;
|
||||
}
|
||||
.menu-item:hover {
|
||||
box-shadow: 0 0 10px rgba(0,0,0,0.1);
|
||||
}
|
||||
|
||||
.menu-item>i {
|
||||
font-size: 30px;
|
||||
@@ -626,14 +643,11 @@
|
||||
|
||||
.flow-edit-content {
|
||||
min-height: 100%;
|
||||
background: #FFF;
|
||||
color: #606266;
|
||||
line-height: 1.4;
|
||||
text-align: justify;
|
||||
font-size: 14px;
|
||||
border: 1px solid #EBEEF5;
|
||||
padding: 12px;
|
||||
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, .1);
|
||||
word-break: break-all;
|
||||
border-radius: 4px;
|
||||
}
|
||||
@@ -650,4 +664,4 @@
|
||||
.csslabel .label-text {
|
||||
background-color: white;
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
@@ -1,121 +1,134 @@
|
||||
<template id="form-item-list-generator">
|
||||
<div class="d-flex form-item-list-generator-content">
|
||||
<div class="componentList">
|
||||
<div class="left-component-item-title">
|
||||
<v-card :class="{'d-flex': !isMobile, 'form-item-list-generator-content': !isMobile}">
|
||||
<v-card color="#f5f8fa" :style="{'width': isMobile ? '100%' : '300px'}"
|
||||
:class="{'pa-4': !isMobile, 'pa-2': isMobile, 'mr-6': !isMobile}">
|
||||
<div class="left-component-item-title" :style="{'white-space': 'nowrap'}">
|
||||
<v-icon>mdi-puzzle-outline</v-icon>
|
||||
组件
|
||||
<span style="transform: translateY(2px); display: inline-block;">组件</span>
|
||||
</div>
|
||||
<draggable
|
||||
:group="{ name: 'componentGroup', pull: 'clone', put: false }"
|
||||
:list="componentList"
|
||||
draggable=".left-component-item"
|
||||
:clone="cloneComponent"
|
||||
@end="leftComponentDraggableOnEnd">
|
||||
<div class="left-component-item"
|
||||
v-for="(component, index) in componentList" :key="index"
|
||||
@click="addFormItem(component)">
|
||||
<div class="left-component-item-body">
|
||||
<v-icon small class="mr-1">{{ component.icon }}</v-icon>
|
||||
{{ component.title }}
|
||||
</div>
|
||||
:group="{ name: 'componentGroup', pull: 'clone', put: false }"
|
||||
:list="componentList"
|
||||
draggable=".left-component-item"
|
||||
:clone="cloneComponent"
|
||||
@end="leftComponentDraggableOnEnd">
|
||||
<div class="left-component-item"
|
||||
v-for="(component, index) in componentList" :key="index"
|
||||
@click="addFormItem(component)">
|
||||
<div class="left-component-item-body">
|
||||
<v-icon small class="mr-1">{{ component.icon }}</v-icon>
|
||||
{{ component.title }}
|
||||
</div>
|
||||
</div>
|
||||
</draggable>
|
||||
</div>
|
||||
</v-card>
|
||||
|
||||
<v-card class="formItemList">
|
||||
<v-toolbar dense flat>
|
||||
<v-btn icon @click.stop="emptyCanva" class="ml-2">
|
||||
<v-icon color="grey lighten-1" dark>mdi-delete-empty</v-icon>
|
||||
</v-btn>
|
||||
</v-toolbar>
|
||||
<draggable
|
||||
<v-card class="formItemList py-10 pl-4 pr-4" color="#f5f8fa" style="position: relative;">
|
||||
<v-btn small color="error" @click.stop="emptyCanva" class="mr-2 mt-2"
|
||||
style="position: absolute; right: 8px; top: 0;">
|
||||
<span>重置</span>
|
||||
</v-btn>
|
||||
<draggable
|
||||
v-if="formItemList.length > 0"
|
||||
:list="formItemList"
|
||||
:animation="300"
|
||||
group="componentGroup">
|
||||
<v-hover v-for="(formItem, index) in formItemList" :key="index" v-slot:default="{ hover }">
|
||||
<v-card
|
||||
@click.native="formItemSelect(formItem.id)"
|
||||
:elevation="hover ? 12 : 2"
|
||||
:class="['ma-2', selectedFormItemId === formItem.id && !hover ? 'formItem-selected' : 'formItem-body']"
|
||||
style="cursor: move"
|
||||
dense>
|
||||
<v-list-item>
|
||||
<v-hover v-for="(formItem, index) in formItemList" :key="index" v-slot:default="{ hover }">
|
||||
<v-card
|
||||
@click.native="formItemSelect(formItem.id)"
|
||||
:elevation="hover ? 12 : 2"
|
||||
:class="['my-2', selectedFormItemId === formItem.id && !hover ? 'formItem-selected' : 'formItem-body']"
|
||||
style="cursor: move"
|
||||
dense>
|
||||
<v-list-item>
|
||||
|
||||
<v-list-item-content v-if="formItem.component.type === 'singleSelect'">
|
||||
<v-radio-group :disabled="true" :label="(index+1) + formItem.component.outline">
|
||||
<v-radio hide-details v-for="(option, optionIndex) in formItem.component.property.selectOptionList"
|
||||
:key="optionIndex" :label="option.value" :value="option.value"></v-radio>
|
||||
</v-radio-group>
|
||||
</v-list-item-content>
|
||||
<v-list-item-content v-if="formItem.component.type === 'singleSelect'">
|
||||
<v-radio-group :disabled="true" :label="(index+1) + formItem.component.outline">
|
||||
<v-radio hide-details v-for="(option, optionIndex) in formItem.component.property.selectOptionList"
|
||||
:key="optionIndex" :label="option.value" :value="option.value"></v-radio>
|
||||
</v-radio-group>
|
||||
</v-list-item-content>
|
||||
|
||||
<v-list-item-content v-if="formItem.component.type === 'multipleSelect'">
|
||||
<v-list-item-title class="formItem-title">{{ index+1 }}. {{ formItem.component.outline }}</v-list-item-title>
|
||||
<div v-for="(option, optionIndex) in formItem.component.property.selectOptionList" :key="optionIndex">
|
||||
<v-checkbox hide-details style="margin-top: 0px;" :disabled="true" :label="option.value" hide-details color="red"></v-checkbox>
|
||||
</div>
|
||||
</v-list-item-content>
|
||||
<v-list-item-content v-if="formItem.component.type === 'multipleSelect'">
|
||||
<v-list-item-title class="formItem-title">{{ index + 1 }}. {{
|
||||
formItem.component.outline
|
||||
}}
|
||||
</v-list-item-title>
|
||||
<div v-for="(option, optionIndex) in formItem.component.property.selectOptionList" :key="optionIndex">
|
||||
<v-checkbox hide-details style="margin-top: 0px;" :disabled="true" :label="option.value" hide-details
|
||||
color="red"></v-checkbox>
|
||||
</div>
|
||||
</v-list-item-content>
|
||||
|
||||
<v-list-item-content v-if="formItem.component.type === 'textarea'">
|
||||
<v-textarea dense outlined placeholder="请输入答案" hide-details :disabled="true" :rows="4" :label="(index+1) + '. ' + formItem.component.outline"/>
|
||||
</v-list-item-content>
|
||||
<v-list-item-content v-if="formItem.component.type === 'textarea'">
|
||||
<v-textarea dense outlined placeholder="请输入答案" hide-details :disabled="true" :rows="4"
|
||||
:label="(index+1) + '. ' + formItem.component.outline"/>
|
||||
</v-list-item-content>
|
||||
|
||||
<v-list-item-content v-if="formItem.component.type === 'input'">
|
||||
<v-text-field class="cus-v-input" dense outlined :label="(index+1) + '. ' + formItem.component.outline" :disabled="true">
|
||||
</v-list-item-content>
|
||||
<v-list-item-content v-if="formItem.component.type === 'input'">
|
||||
<v-text-field class="cus-v-input" dense outlined :label="(index+1) + '. ' + formItem.component.outline"
|
||||
:disabled="true"></v-text-field>
|
||||
</v-list-item-content>
|
||||
|
||||
<v-list-item-action v-if="selectedFormItemId === formItem.id" class="justify-start">
|
||||
<v-btn x-small icon @click.stop="formItemCopy(index, formItem)">
|
||||
<v-icon color="primary">mdi-content-duplicate</v-icon>
|
||||
</v-btn>
|
||||
<v-btn x-small icon @click.stop="formItemDelete(formItem.id)">
|
||||
<v-icon color="error">mdi-close-box</v-icon>
|
||||
</v-btn>
|
||||
</v-list-item-action>
|
||||
</v-list-item>
|
||||
</v-card>
|
||||
</v-hover>
|
||||
</draggable>
|
||||
<v-row v-else align="center" justify="center" style="width: 100%;">
|
||||
<v-card height="100" class="ma-12" width="100%">
|
||||
<draggable :list="[]" :animation="300" group="componentGroup">
|
||||
<v-card-text class="text-center title">
|
||||
从左侧拖入或点选组件进行表单设计
|
||||
</v-card-text>
|
||||
</draggable>
|
||||
<v-list-item-action v-if="selectedFormItemId === formItem.id" class="justify-start">
|
||||
<v-btn x-small icon @click.stop="formItemCopy(index, formItem)">
|
||||
<v-icon color="primary">mdi-content-duplicate</v-icon>
|
||||
</v-btn>
|
||||
<v-btn x-small icon @click.stop="formItemDelete(formItem.id)">
|
||||
<v-icon color="error">mdi-close-box</v-icon>
|
||||
</v-btn>
|
||||
</v-list-item-action>
|
||||
</v-list-item>
|
||||
</v-card>
|
||||
</v-hover>
|
||||
</draggable>
|
||||
<v-row v-else align="center" justify="center" class="ma-0 pa-0" style="width: 100%;">
|
||||
<v-card height="100" class="ma-12" width="100%" color="#f5f8fa" style="border: 1px dashed #333333">
|
||||
<draggable :list="[]" :animation="300" group="componentGroup" style="position: relative; height: 100%;">
|
||||
<v-card-text class="text-center title draggable-placeholder">
|
||||
从左侧拖入或点选组件进行表单设计
|
||||
</v-card-text>
|
||||
</draggable>
|
||||
</v-card>
|
||||
</v-row>
|
||||
</v-row>
|
||||
</v-card>
|
||||
</v-row>
|
||||
</v-card>
|
||||
|
||||
<div class="property">
|
||||
<v-card color="#f5f8fa" :style="{'width': isMobile ? 'auto' : '300px'}" class="pa-4" :class="{'ml-6': !isMobile}">
|
||||
<div class="property-title">
|
||||
<v-icon>mdi-application-edit-outline</v-icon>组件属性
|
||||
<v-icon>mdi-application-edit-outline</v-icon>
|
||||
<span style="transform: translateY(2px); display: inline-block;">组件属性</span>
|
||||
</div>
|
||||
<div v-if="selectCanvaIndex >= 0 && formItemList[selectCanvaIndex]">
|
||||
<v-card flat v-if="formItemList[selectCanvaIndex].component.type === 'singleSelect' || formItemList[selectCanvaIndex].component.type === 'multipleSelect'">
|
||||
<v-card class="pa-4 mt-4"
|
||||
v-if="formItemList[selectCanvaIndex].component.type === 'singleSelect' || formItemList[selectCanvaIndex].component.type === 'multipleSelect'">
|
||||
<v-row no-gutters>
|
||||
<v-col cols="12">
|
||||
<v-text-field class="cus-v-input mr-2" dense outlined label="标题" v-model="formItemList[selectCanvaIndex].component.outline"></v-text-field>
|
||||
<v-text-field class="cus-v-input mr-2" dense filled single-line prefix="标题: " color="success"
|
||||
v-model="formItemList[selectCanvaIndex].component.outline"></v-text-field>
|
||||
<div style="display: flex; flex-direction: row;justify-content: space-between; align-items: center;">
|
||||
<v-subheader>选项列表</v-subheader>
|
||||
<v-btn icon @click.stop="propertyAddOption(formItemList[selectCanvaIndex].component.property.selectOptionList.length)">
|
||||
<v-subheader class="pa-0">选项列表</v-subheader>
|
||||
<v-btn icon
|
||||
@click.stop="propertyAddOption(formItemList[selectCanvaIndex].component.property.selectOptionList.length)">
|
||||
<v-icon dark color="grey lighten-1">mdi-plus-box</v-icon>
|
||||
</v-btn>
|
||||
</div>
|
||||
<v-list dense>
|
||||
<v-list-item v-for="(option, index) in formItemList[selectCanvaIndex].component.property.selectOptionList" :key="index">
|
||||
<v-list class="propertyList" dense style="max-height: 300px; overflow-y: auto;">
|
||||
<v-list-item
|
||||
class="pa-0"
|
||||
v-for="(option, index) in formItemList[selectCanvaIndex].component.property.selectOptionList"
|
||||
:key="index">
|
||||
<v-list-item-content>
|
||||
<v-text-field
|
||||
v-model="option.value"
|
||||
label="选项"
|
||||
outlined
|
||||
dense
|
||||
hide-details
|
||||
clearable
|
||||
placeholder="请输入选项"/>
|
||||
v-model="option.value"
|
||||
prefix="选项:"
|
||||
color="success"
|
||||
filled single-line
|
||||
dense
|
||||
hide-details
|
||||
clearable
|
||||
placeholder="请输入选项"/>
|
||||
</v-list-item-content>
|
||||
<v-list-item-action>
|
||||
<v-list-item-action class="ml-2">
|
||||
<v-btn icon @click.stop="propertyDeleteOption(index)">
|
||||
<v-icon color="grey lighten-1" dark>mdi-delete</v-icon>
|
||||
</v-btn>
|
||||
@@ -125,17 +138,17 @@
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-card>
|
||||
<v-card flat v-if="formItemList[selectCanvaIndex].component.type === 'textarea'">
|
||||
<v-text-field class="cus-v-input mr-2" dense outlined label="多行文本" v-model="formItemList[selectCanvaIndex].component.outline"></v-text-field>
|
||||
<v-card class="mt-5" flat v-if="formItemList[selectCanvaIndex].component.type === 'textarea'">
|
||||
<v-text-field class="cus-v-input black" dense filled single-line label="多行文本"
|
||||
v-model="formItemList[selectCanvaIndex].component.outline"></v-text-field>
|
||||
</v-card>
|
||||
<v-card flat v-if="formItemList[selectCanvaIndex].component.type === 'input'">
|
||||
<v-text-field class="cus-v-input mr-2" dense outlined label="单行文本" v-model="formItemList[selectCanvaIndex].component.outline"></v-text-field>
|
||||
<v-card class="mt-5" flat v-if="formItemList[selectCanvaIndex].component.type === 'input'">
|
||||
<v-text-field class="cus-v-input black" dense filled single-line label="单行文本"
|
||||
v-model="formItemList[selectCanvaIndex].component.outline"></v-text-field>
|
||||
</v-card>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</v-card>
|
||||
</v-card>
|
||||
</template>
|
||||
|
||||
<script src="//cdn.jsdelivr.net/npm/sortablejs@1.8.4/Sortable.min.js"></script>
|
||||
@@ -144,111 +157,131 @@
|
||||
<script>
|
||||
// 1. v-main 滚动条
|
||||
// 2. v-navigation-drawer 小屏幕 不要关闭
|
||||
Vue.component("form-item-list-generator", {
|
||||
template: '#form-item-list-generator',
|
||||
vuetify: new Vuetify(),
|
||||
name: 'form-item-list-generator',
|
||||
props: {
|
||||
formItemList: {
|
||||
type: Array,
|
||||
default: [],
|
||||
required: true,
|
||||
},
|
||||
Vue.component("form-item-list-generator", {
|
||||
template: '#form-item-list-generator',
|
||||
vuetify: new Vuetify(),
|
||||
name: 'form-item-list-generator',
|
||||
props: {
|
||||
formItemList: {
|
||||
type: Array,
|
||||
default: [],
|
||||
required: true,
|
||||
},
|
||||
data: () => ({
|
||||
componentList: [
|
||||
{ title: '单行文本', type: 'input', outline: '单行文本', property: {}, icon: 'mdi-form-textarea' },
|
||||
{ title: '多行文本', type: 'textarea', outline: '多行文本', property: {}, icon: 'mdi-form-textarea' },
|
||||
{ title: '单选', type: 'singleSelect', outline: '单选', property: { selectOptionList: [] }, icon: 'mdi-checkbox-marked-circle' },
|
||||
{ title: '多选', type: 'multipleSelect', outline: '多选', property: { selectOptionList: [] }, icon: 'mdi-checkbox-marked' },
|
||||
],
|
||||
tempComponent: null,
|
||||
},
|
||||
data: () => ({
|
||||
componentList: [
|
||||
{title: '单行文本', type: 'input', outline: '单行文本', property: {}, icon: 'mdi-form-textarea'},
|
||||
{title: '多行文本', type: 'textarea', outline: '多行文本', property: {}, icon: 'mdi-form-textarea'},
|
||||
{
|
||||
title: '单选',
|
||||
type: 'singleSelect',
|
||||
outline: '单选',
|
||||
property: {selectOptionList: []},
|
||||
icon: 'mdi-checkbox-marked-circle'
|
||||
},
|
||||
{
|
||||
title: '多选',
|
||||
type: 'multipleSelect',
|
||||
outline: '多选',
|
||||
property: {selectOptionList: []},
|
||||
icon: 'mdi-checkbox-marked'
|
||||
},
|
||||
],
|
||||
tempComponent: null,
|
||||
|
||||
|
||||
// 当 needle 是空字符串时,我们应当返回什么值呢?这是一个在面试中很好的问题。
|
||||
// 当 needle 是空字符串时,我们应当返回什么值呢?这是一个在面试中很好的问题。
|
||||
|
||||
// 对于本题而言,当 needle 是空字符串时我们应当返回 0 。这与 C 语言的 strstr() 以及 Java 的 indexOf() 定义相符。
|
||||
// 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。
|
||||
// `,
|
||||
// property: {}, icon: 'mdi-checkbox-marked-circle'
|
||||
// },
|
||||
// formItemData: {}
|
||||
// }
|
||||
// ],
|
||||
selectedFormItemId: null,
|
||||
rightPanels: [0,1,2,3,4],
|
||||
}),
|
||||
computed: {
|
||||
selectCanvaIndex () {
|
||||
const index = this.formItemList.findIndex(item => item.id === this.selectedFormItemId);
|
||||
return index;
|
||||
},
|
||||
// 对于本题而言,当 needle 是空字符串时我们应当返回 0 。这与 C 语言的 strstr() 以及 Java 的 indexOf() 定义相符。
|
||||
// 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。
|
||||
// `,
|
||||
// property: {}, icon: 'mdi-checkbox-marked-circle'
|
||||
// },
|
||||
// formItemData: {}
|
||||
// }
|
||||
// ],
|
||||
selectedFormItemId: null,
|
||||
rightPanels: [0, 1, 2, 3, 4],
|
||||
}),
|
||||
computed: {
|
||||
selectCanvaIndex() {
|
||||
const index = this.formItemList.findIndex(item => item.id === this.selectedFormItemId);
|
||||
return index;
|
||||
},
|
||||
mounted() {
|
||||
isMobile() {
|
||||
return window.innerWidth < 600;
|
||||
},
|
||||
destroyed() {},
|
||||
watch: {
|
||||
},
|
||||
mounted() {
|
||||
},
|
||||
destroyed() {
|
||||
},
|
||||
watch: {},
|
||||
async created() {
|
||||
},
|
||||
methods: {
|
||||
cloneComponent(component) {
|
||||
this.tempComponent = component;
|
||||
},
|
||||
async created() {},
|
||||
methods: {
|
||||
cloneComponent (component) {
|
||||
this.tempComponent = component;
|
||||
},
|
||||
leftComponentDraggableOnEnd (event) {
|
||||
if (event.from !== event.to) {
|
||||
const newIndex = event.newIndex;
|
||||
this.addFormItem(this.tempComponent, newIndex);
|
||||
}
|
||||
this.tempComponent = null;
|
||||
},
|
||||
addFormItem(component, targetIndex) {
|
||||
const { type } = component;
|
||||
const formItem = {
|
||||
id: `${type}_${this.uuid(8)}`,
|
||||
component: _.cloneDeep(component)
|
||||
};
|
||||
if (!this.formItemList) {
|
||||
this.formItemList = [];
|
||||
}
|
||||
if (targetIndex > -1) {
|
||||
this.formItemList.splice(targetIndex, 0, formItem);
|
||||
} else {
|
||||
this.formItemList.push(formItem);
|
||||
}
|
||||
},
|
||||
formItemSelect (id) {
|
||||
this.selectedFormItemId = id;
|
||||
},
|
||||
formItemCopy (index, formItem) {
|
||||
const newFormItem = _.cloneDeep(formItem);
|
||||
newFormItem.id = `${newFormItem.component.type}_${this.uuid(8)}`,
|
||||
this.formItemList.splice(index+1, 0, newFormItem);
|
||||
},
|
||||
emptyCanva () {
|
||||
this.formItemList.splice(0, this.formItemList.length);
|
||||
},
|
||||
formItemDelete (id) {
|
||||
const index = this.formItemList.findIndex((item) => item.id === id);
|
||||
if (index > -1) {
|
||||
this.formItemList.splice(index, 1);
|
||||
}
|
||||
},
|
||||
propertyAddOption (index) {
|
||||
this.formItemList[this.selectCanvaIndex].component.property.selectOptionList.splice(index, 0, { value: "" });
|
||||
},
|
||||
propertyDeleteOption (index) {
|
||||
this.formItemList[this.selectCanvaIndex].component.property.selectOptionList.splice(index, 1);
|
||||
},
|
||||
uuid (t=21) {
|
||||
let e="",r=crypto.getRandomValues(new Uint8Array(t));
|
||||
for(;t--;){let n=63&r[t];e+=n<36?n.toString(36):n<62?(n-26).toString(36).toUpperCase():n<63?"_":"-"};
|
||||
return e
|
||||
},
|
||||
getFormItemList () {
|
||||
return this.formItemList;
|
||||
},
|
||||
leftComponentDraggableOnEnd(event) {
|
||||
if (event.from !== event.to) {
|
||||
const newIndex = event.newIndex;
|
||||
this.addFormItem(this.tempComponent, newIndex);
|
||||
}
|
||||
this.tempComponent = null;
|
||||
},
|
||||
})
|
||||
addFormItem(component, targetIndex) {
|
||||
const {type} = component;
|
||||
const formItem = {
|
||||
id: `${type}_${this.uuid(8)}`,
|
||||
component: _.cloneDeep(component)
|
||||
};
|
||||
if (!this.formItemList) {
|
||||
this.formItemList = [];
|
||||
}
|
||||
if (targetIndex > -1) {
|
||||
this.formItemList.splice(targetIndex, 0, formItem);
|
||||
} else {
|
||||
this.formItemList.push(formItem);
|
||||
}
|
||||
},
|
||||
formItemSelect(id) {
|
||||
this.selectedFormItemId = id;
|
||||
},
|
||||
formItemCopy(index, formItem) {
|
||||
const newFormItem = _.cloneDeep(formItem);
|
||||
newFormItem.id = `${newFormItem.component.type}_${this.uuid(8)}`,
|
||||
this.formItemList.splice(index + 1, 0, newFormItem);
|
||||
},
|
||||
emptyCanva() {
|
||||
this.formItemList.splice(0, this.formItemList.length);
|
||||
},
|
||||
formItemDelete(id) {
|
||||
const index = this.formItemList.findIndex((item) => item.id === id);
|
||||
if (index > -1) {
|
||||
this.formItemList.splice(index, 1);
|
||||
}
|
||||
},
|
||||
propertyAddOption(index) {
|
||||
this.formItemList[this.selectCanvaIndex].component.property.selectOptionList.splice(index, 0, {value: ""});
|
||||
},
|
||||
propertyDeleteOption(index) {
|
||||
this.formItemList[this.selectCanvaIndex].component.property.selectOptionList.splice(index, 1);
|
||||
},
|
||||
uuid(t = 21) {
|
||||
let e = "", r = crypto.getRandomValues(new Uint8Array(t));
|
||||
for (; t--;) {
|
||||
let n = 63 & r[t];
|
||||
e += n < 36 ? n.toString(36) : n < 62 ? (n - 26).toString(36).toUpperCase() : n < 63 ? "_" : "-"
|
||||
}
|
||||
;
|
||||
return e
|
||||
},
|
||||
getFormItemList() {
|
||||
return this.formItemList;
|
||||
},
|
||||
},
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
@@ -265,31 +298,36 @@
|
||||
height: 100%;
|
||||
max-height: 100%;
|
||||
}
|
||||
|
||||
.left-component-item {
|
||||
width: 100%;
|
||||
margin: 1%;
|
||||
margin: 8px 0;
|
||||
transition: transform 0ms !important;
|
||||
}
|
||||
|
||||
.left-component-item-title {
|
||||
font-size: 14px;
|
||||
color: #222;
|
||||
margin: 6px 2px;
|
||||
font-size: 14px;
|
||||
color: #222;
|
||||
margin: 6px 2px;
|
||||
}
|
||||
|
||||
.left-component-item-body {
|
||||
padding: 8px 10px;
|
||||
background: #e0e0e0;
|
||||
font-size: 12px;
|
||||
cursor: move;
|
||||
border: 1px dashed #e0e0e0;
|
||||
border-radius: 3px;
|
||||
padding: 8px 10px;
|
||||
background: #ffffff;
|
||||
font-size: 12px;
|
||||
cursor: move;
|
||||
border: 1px dashed #ffffff;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
.left-component-item-body:hover {
|
||||
border: 1px dashed #1565c0;
|
||||
background: #e3f2fd;
|
||||
color: #1565c0;
|
||||
border: 1px dashed #4caf50;
|
||||
background: #e6fde3;
|
||||
color: #4caf50;
|
||||
}
|
||||
|
||||
.left-component-item-body:hover .v-icon {
|
||||
color: #1565c0;
|
||||
color: #4caf50;
|
||||
}
|
||||
|
||||
.formItemList {
|
||||
@@ -297,14 +335,13 @@
|
||||
overflow-y: auto;
|
||||
height: 100%;
|
||||
max-height: 100%;
|
||||
background-color: #e0e0e0 !important;
|
||||
border-radius: 0 !important;
|
||||
border: 1px dashed #999 !important;
|
||||
}
|
||||
|
||||
.formItemList .formItem-selected {
|
||||
border: 1px dashed #1565c0 !important;
|
||||
background: #e3f2fd;
|
||||
border: 1px dashed #4caf50 !important;
|
||||
background: #e6fde3;
|
||||
}
|
||||
|
||||
.formItem-title {
|
||||
white-space: normal;
|
||||
}
|
||||
@@ -315,6 +352,7 @@
|
||||
max-height: calc(100vh - 105px);
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.property .property-title {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
@@ -332,4 +370,45 @@
|
||||
min-width: 24px;
|
||||
}
|
||||
|
||||
.propertyList::-webkit-scrollbar {
|
||||
width: 5px;
|
||||
background: #f5f8fa;
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
.propertyList::-webkit-scrollbar-thumb {
|
||||
width: 5px;
|
||||
background: #606060;
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
body .theme--light.v-text-field--filled.cus-v-input.black > .v-input__control > .v-input__slot {
|
||||
background: #e6ebee;
|
||||
}
|
||||
|
||||
.draggable-placeholder {
|
||||
position: absolute;
|
||||
left: 0!important;
|
||||
top: 50%!important;
|
||||
transform: translateY(-50%)!important;
|
||||
opacity: 0.3;
|
||||
}
|
||||
|
||||
@media (max-width: 500px) {
|
||||
.left-component-item {
|
||||
width: auto;
|
||||
display: inline-block;
|
||||
margin: 8px 4px;
|
||||
transition: transform 0ms !important;
|
||||
}
|
||||
|
||||
.formItemList {
|
||||
border-top: 2px solid #cccccc !important;
|
||||
border-bottom: 2px solid #cccccc !important;
|
||||
border-radius: unset !important;
|
||||
height: auto;
|
||||
max-height: none;
|
||||
overflow: hidden;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -79,6 +79,13 @@
|
||||
height: 500px;
|
||||
max-height: 500px;
|
||||
overflow-y: auto;
|
||||
border: 2px solid rgb(226, 226, 226);
|
||||
}
|
||||
@media (max-width: 500px) {
|
||||
.tpl-form-design-container {
|
||||
width: 100%;
|
||||
height: auto;
|
||||
max-height: none;
|
||||
overflow-y: hidden;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user