Commit 565bd136 authored by JingChao's avatar JingChao

动态配置

parent fd2ae777
...@@ -159,7 +159,7 @@ export default { ...@@ -159,7 +159,7 @@ export default {
content: '*'; content: '*';
color: #D24E4E; color: #D24E4E;
height: 8px; height: 8px;
padding-top: 4px; padding-top: 2px;
margin-left: 2px; margin-left: 2px;
} }
} }
......
...@@ -75,9 +75,9 @@ export default { ...@@ -75,9 +75,9 @@ export default {
}, },
mounted () { mounted () {
let vm = this let vm = this
setTimeout(()=>{ setTimeout(() => {
this.items[vm.current].$el.classList.add('activated') this.items[vm.current].$el.classList.add('activated')
},100) }, 100)
this.scrollToActiveTab(vm.current, this.items[vm.current].$el.clientWidth) this.scrollToActiveTab(vm.current, this.items[vm.current].$el.clientWidth)
}, },
methods: { methods: {
......
...@@ -45,9 +45,9 @@ ...@@ -45,9 +45,9 @@
<script> <script>
import layoutData from '../common/layout' import layoutData from '../common/layout'
import ButtonTab from "vux/src/components/button-tab/button-tab";
export default { export default {
components: {ButtonTab},
data() { data() {
return { return {
layoutData: [], layoutData: [],
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
*/ */
<template> <template>
<h-view> <h-view class="form">
<h-header> <h-header>
<div slot="left" class="h-header-btn" @click="$hlsExit()"> <div slot="left" class="h-header-btn" @click="$hlsExit()">
<i class="ion-ios-arrow-back"/> <i class="ion-ios-arrow-back"/>
...@@ -13,158 +13,173 @@ ...@@ -13,158 +13,173 @@
<div slot="right" class="h-header-btn">右边</div> <div slot="right" class="h-header-btn">右边</div>
</h-header> </h-header>
<h-content> <h-content>
<section v-for="(com, index) in component" :key="index"> <section v-for="(com, index) in layoutData" :key="index">
<section v-if="com.name=='tab'"> <s-tab
<s-tab v-if="com.item" :class="com.class"> v-if="com.configType==='TAB' && com.layoutFiledList.length"
<tab-item v-for="(tab,key) in com.item" :key="key">{{ tab.name }}</tab-item> :default-active="tabIndex" :class="com.cssClass" @tabClick="layoutTabClick"
@click.native="tabClick(com)">
<tab-item v-for="(tab,key) in com.layoutFiledList" :key="key"><section v-html="tab.tabContent || tab.filedName"/></tab-item>
</s-tab> </s-tab>
</section> <list-item v-if="com.configType==='FORM' && com.layoutFiledList.length" v-show="tabFromHide(com)" :class="com.cssClass">
<section v-else-if="com.name=='form'"> <item v-show="showFormTitle" class="form-title" @click.native="hideFormClick(index)">
<list-item v-if="com.fileds" :class="com.class"> <div slot="name">{{ com.configName }}</div>
<item v-for="(filed, index) in com.fileds" :key="index" :class="filed.class"> <img
<div slot="name" :class="{'required':filed.request}">{{ filed.description }}</div> slot="right-icon" :class="{'hide-down-icon':!com.hideForm,'hide-up-icon':com.hideForm}"
<div slot="content"> class="right-icon " src="@/assets/image/right-arrow@2x.png">
</item>
<item
v-for="(filed, index) in com.layoutFiledList"
v-show="!com.hideForm" :key="index" :class="filed.cssClass" :has-border="filed.hasBorder"
:hasContent="filed.showContent" :proportion="proportionArray(filed.proportion)" :showName="filed.showName"
:showArrow="filed.showArrow"
:item-height="filed.filedHeight">
<img v-if="filed.leftIcon" slot="left-icon" :src="filed.leftIcon" class="left-icon">
<div slot="name" :class="{'required':filed.inputMode=='required'}">{{ filed.filedName }}</div>
<input <input
v-if="filed.type=='input'" v-model="data[com.dataName][filed.name]" :request="filed.request" v-if="filed.filedType==='INPUT'" slot="content"
:readonly="filed.readonly" :readonly="filed.inputMode==='readOnly'"
:placeholder="filed.placeholder"> :placeholder="filed.placeholder" :value="filed.defaultValue" :type="filed.inputType" :name="filed.filedName">
<input <input
v-if="filed.type=='select'" v-model="data[com.dataName][filed.name+'_n']" readonly="true" v-else-if="filed.filedType==='SELECT'"
@click="showSelect(filed.selectList,filed.name,com.dataName)"> slot="content" :name="filed.filedName"
readonly @click="showSelect(com,filed)">
<input <input
v-if="filed.type=='time'" v-model="data[com.dataName][filed.name]" readonly="true" v-else-if="filed.filedType=='TIME'"
@click="showTime(com.dataName,filed)"> slot="content" :name="filed.filedName"
</div> readonly @click="showTime(com,filed)">
<h-switch v-else-if="filed.filedType==='SWITCH'" slot="content"/>
<div v-else slot="content" v-html="filed.defaultValue"/>
<img v-if="filed.rightIcon" slot="right-icon" :src="filed.rightIcon" class="right-icon">
</item> </item>
</list-item> </list-item>
</section> </section>
</section>
</h-content> </h-content>
<section v-for="(com, index) in layoutData" :key="index">
<bottom-tab v-if="com.configType==='BOTTOM-BUTTON' && com.layoutFiledList.length" :show-divider="true">
<tab-button v-for="(btn, index) in com.layoutFiledList" :key="index"><section v-html="btn.btnContent || btn.filedName"/></tab-button>
</bottom-tab>
</section>
</h-view> </h-view>
</template> </template>
<script> <script>
import layoutData from './layout.json'
import ButtonTab from 'vux/src/components/button-tab/button-tab'
export default { export default {
name: 'Form', name: 'Form',
components: { ButtonTab },
data () { data () {
return { return {
component: [ tabIndex: 1,
{ showFormTitle: true,
name: 'tab', layoutData: null,
class: '',
item: [
{
name: 'APP',
}, {
name: 'WeiXin',
}, {
name: 'Vue',
},
],
},
{
name: 'form',
readonly: false,
class: '',
dataName: 'person',
fileds: [
{
class: '',
type: 'input',
description: '手机号',
name: 'phone',
defaultValue: '',
request: false,
readonly: false,
placeholder: '请输入手机号',
}, {
class: '',
type: 'input',
description: '姓名',
name: 'name',
defaultValue: 'li',
request: true,
readonly: false,
}, {
class: '',
type: 'select',
description: '性别',
name: 'sex',
defaultValue: 'N',
defaultValueN: '男',
request: false,
readonly: false,
selectList: [{
code: 'man',
code_name: '男',
}, {
code: 'woman',
code_name: '女',
}],
}, {
class: '',
type: 'time',
description: '出生时间',
name: 'brithDay',
defaultValue: '2003-05-26',
request: true,
format: 'yyyy-mm-dd',
},
],
},
],
data: {}, data: {},
activeTab: null,
activeTabFiled: null,
} }
}, },
created () { created () {
let vm = this let vm = this
vm.component.forEach((com, index) => { if (layoutData.rows && layoutData.rows[0].layoutConfigList.length) {
if (com.name === 'form') { vm.layoutData = layoutData.rows[0].layoutConfigList
vm.layoutData.forEach((com, index) => {
if (com.configType === 'FORM') {
let form = com let form = com
let temp = { let temp = {}
readonly: form['readonly'], if (form.layoutFiledList.length) {
} let filed = form.layoutFiledList
if (form.fileds.length) { filed.forEach((filed, index) => {
let fileds = form.fileds temp[filed.filedCode] = filed.defaultValue
fileds.forEach((filed, index) => {
temp[filed.name] = filed.defaultValue
if (filed.type === 'select') { if (filed.type === 'select') {
temp[filed.name + '_n'] = filed.defaultValueN temp[filed.filedCode + '_n'] = filed.defaultValueN
} }
}) })
vm.$set(this.data, [form.dataName], temp) vm.$set(this.data, [form.configCode], temp)
} }
} else if (com.configType === 'TAB') {
vm.activeTab = com.configCode
vm.activeTabFiled = com.layoutFiledList.length ? com.layoutFiledList[vm.tabIndex].filedCode : ''
} }
}) })
}
}, },
methods: { methods: {
showSelect (list, code, dataName) { proportionArray (proportion) {
return proportion.split(',')
},
layoutTabClick (index) {
let vm = this let vm = this
vm.hlsPopup.selectList({ vm.tabIndex = index
list: list,
code: code,
object: {},
returnItem (index, obj) {
vm.data[dataName][code] = list[index].code
vm.data[dataName][code + '_n'] = list[index].code_name
}, },
}) tabClick (com) {
let vm = this
vm.activeTab = com.configCode
vm.activeTabFiled = com.layoutFiledList.length ? com.layoutFiledList[vm.tabIndex].filedCode : ''
}, },
showTime (dataName, filed) {
hideFormClick (index) {
let vm = this let vm = this
vm.hlsPopup.showTime({ vm.layoutData[index]['hideForm'] = !vm.layoutData[index]['hideForm']
format: filed.format,
callback (value) {
vm.data[dataName][filed.name] = value
}, },
}) tabFromHide (com) {
let vm = this
if (com.tabConfigCode && com.tabFiledCode) {
if (com.tabConfigCode === vm.activeTab && com.tabFiledCode === vm.activeTabFiled) {
return true
}
} return false
},
showSelect (com, filed) {
},
showTime (com, filed) {
}, },
}, },
} }
</script> </script>
<style scoped lang="less"> <style lang="less">
.form {
.hls-switch-tab {
.tab-content {
.h-tab-item {
.h-item{
img{
width: 20px;
}
}
}
}
}
.content {
.form-title {
.contents {
.add-name {
font-weight: 500;
}
}
}
.hls-item {
.contents {
.add-content {
.right-icon {
height: 12px;
}
.hide-up-icon {
transform: rotate(90deg);
}
.hide-down-icon {
transform: rotate(-90deg);
}
}
}
}
}
}
</style> </style>
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
</div> </div>
<div v-show="item.isFromeMe" class="message-wrap"> <div v-show="item.isFromeMe" class="message-wrap">
<img v-show="userImg" :src="userImg" class="head-pic-right"> <img v-show="userImg" :src="userImg" class="head-pic-right">
<img v-show="!userImg" src="../assets/image/robot/user7.png" class="head-pic-right"> <img v-show="!userImg" src="@/assets/image/robot/user7.png" class="head-pic-right">
<span class="triangle-right"/> <span class="triangle-right"/>
<p class="message-right" v-text="item.content"/> <p class="message-right" v-text="item.content"/>
</div> </div>
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment