Commit 2eecde67 authored by JingChao's avatar JingChao

layout

parent 0b9f23da
...@@ -43,13 +43,13 @@ export default { ...@@ -43,13 +43,13 @@ export default {
Vue.$vux.loading.hide() Vue.$vux.loading.hide()
vm.isLoading = false vm.isLoading = false
// 弹出操作失败 // 弹出操作失败
Vue.$vux.toast.show({ /* Vue.$vux.toast.show({
text: '操作失败', text: '操作失败',
type: 'warn', type: 'warn',
time: vm.SHOW_TIMES, time: vm.SHOW_TIMES,
isShowMask: vm.IS_SHOW_MASK, isShowMask: vm.IS_SHOW_MASK,
position: 'middle', position: 'middle',
}) }) */
} }
}, 10000) }, 10000)
}, },
...@@ -68,7 +68,6 @@ export default { ...@@ -68,7 +68,6 @@ export default {
showLongTop: function (content) { showLongTop: function (content) {
let vm = this let vm = this
let text = content || '操作失败' let text = content || '操作失败'
if (!process.env.isMobilePlatform) {
Vue.$vux.toast.show({ Vue.$vux.toast.show({
text: text, text: text,
type: 'text', type: 'text',
...@@ -76,11 +75,6 @@ export default { ...@@ -76,11 +75,6 @@ export default {
isShowMask: vm.IS_SHOW_MASK, isShowMask: vm.IS_SHOW_MASK,
position: 'top', position: 'top',
}) })
} else {
window.plugins.toast.showLongTop(content, function (success) {
}, function (error) { // eslint-disable-line
})
}
}, },
/** /**
...@@ -90,7 +84,6 @@ export default { ...@@ -90,7 +84,6 @@ export default {
showLongCenter: function (content) { showLongCenter: function (content) {
let vm = this let vm = this
let text = content || '操作失败' let text = content || '操作失败'
if (!process.env.isMobilePlatform) {
Vue.$vux.toast.show({ Vue.$vux.toast.show({
text: text, text: text,
type: 'text', type: 'text',
...@@ -98,11 +91,6 @@ export default { ...@@ -98,11 +91,6 @@ export default {
isShowMask: vm.IS_SHOW_MASK, isShowMask: vm.IS_SHOW_MASK,
position: 'middle', position: 'middle',
}) })
} else {
window.plugins.toast.showLongCenter(content, function (success) {
}, function (error) { // eslint-disable-line
})
}
}, },
/** /**
* 长时间中部提示toast * 长时间中部提示toast
...@@ -111,7 +99,6 @@ export default { ...@@ -111,7 +99,6 @@ export default {
showLongBottom: function (content) { showLongBottom: function (content) {
let vm = this let vm = this
let text = content || '操作失败' let text = content || '操作失败'
if (!process.env.isMobilePlatform) {
Vue.$vux.toast.show({ Vue.$vux.toast.show({
text: text, text: text,
time: vm.SHOW_TIMES, time: vm.SHOW_TIMES,
...@@ -119,11 +106,6 @@ export default { ...@@ -119,11 +106,6 @@ export default {
isShowMask: vm.IS_SHOW_MASK, isShowMask: vm.IS_SHOW_MASK,
position: 'bottom', position: 'bottom',
}) })
} else {
window.plugins.toast.showLongBottom(content, function (success) {
}, function (error) { // eslint-disable-line
})
}
}, },
/** /**
* 成功提示框 * 成功提示框
...@@ -160,7 +142,6 @@ export default { ...@@ -160,7 +142,6 @@ export default {
* @param confirmObject.onConfirm 确定函数 * @param confirmObject.onConfirm 确定函数
*/ */
showConfirm: function (confirmObject) { showConfirm: function (confirmObject) {
if (!process.env.isMobilePlatform) {
let def = { let def = {
title: confirmObject.title || '提示', title: confirmObject.title || '提示',
content: confirmObject.content || '', content: confirmObject.content || '',
...@@ -174,21 +155,6 @@ export default { ...@@ -174,21 +155,6 @@ export default {
}, },
} }
Vue.$vux.confirm.show(def) Vue.$vux.confirm.show(def)
} else {
let message = confirmObject.content || ''
let onConfirm = function (index) {
confirmObject.onConfirm(index)
}
let title = confirmObject.title || '提示'
navigator.notification.confirm(
message, // message
function (index) {
onConfirm(index - 1)
},
title, // title
['取消', '确定'] // buttonLabels
)
}
}, },
/* /*
* 弹出确认的窗口 * 弹出确认的窗口
...@@ -198,7 +164,6 @@ export default { ...@@ -198,7 +164,6 @@ export default {
* *
*/ */
showPopup: function (confirmObject) { showPopup: function (confirmObject) {
if (!process.env.isMobilePlatform) {
let def = { let def = {
title: confirmObject.title || '提示', title: confirmObject.title || '提示',
content: confirmObject.content || '', content: confirmObject.content || '',
...@@ -209,19 +174,6 @@ export default { ...@@ -209,19 +174,6 @@ export default {
}, },
} }
Vue.$vux.confirm.show(def) Vue.$vux.confirm.show(def)
} else {
let alertDismissed = function (index) {
confirmObject.onConfirm()
}
let title = confirmObject.title || '提示'
let message = confirmObject.content || ''
navigator.notification.alert(
message, // message
alertDismissed, // callback
title || '提示', // title
'确定' // buttonName
)
}
}, },
/** /**
* @param actionObject.titleText 弹出框的标题可空 * @param actionObject.titleText 弹出框的标题可空
......
.has-footer { .has-footer {
padding-bottom: 1.6rem; padding-bottom: 0.88rem;
.scrollContent{ .scrollContent{
padding-bottom: 1.76rem; padding-bottom: 1.76rem;
} }
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
bottom: 1.68rem; bottom: 1.68rem;
} }
.has-footer { .has-footer {
padding-bottom: 2rem; padding-bottom: 1.6rem;
.scrollContent{ .scrollContent{
padding-bottom: 2.84rem; padding-bottom: 2.84rem;
} }
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
bottom: 1.68rem; bottom: 1.68rem;
} }
.has-footer { .has-footer {
padding-bottom: 2rem; padding-bottom: 1.6rem;
.scrollContent{ .scrollContent{
padding-bottom: 2.84rem; padding-bottom: 2.84rem;
} }
......
/* eslint-disable */ /* eslint-disable */
/** /**
* YDUI 可伸缩布局方案 * YDUI 可伸缩布局方案
* rem计算方式:设计图尺寸px / 100 = 实际rem 例: 100px = 1rem * rem计算方式:设计图尺寸px / 50 = 实际rem 例: 100px = 2rem
*/ */
!(function(window) { !(function(window) {
/* 设计图文档宽度 */ /* 设计图文档宽度 */
......
/**
* @Author think
* @Date 2019-07-16 20:00
*/
<template>
<section class="h-form">
<s-tab
v-for="com in layoutConfig" v-if="com.configType==='TAB' && com.layoutFiledList.length"
:key="com.configId"
:default-active="tabIndex" v-model="tabIndex" :class="com.cssClass" :has-border="showTabBorder"
:show-divider="showTabDivider"
@tabClick="layoutTabClick"
@click.native="tabNativeClick(com)">
<tab-item v-for="(tab,key) in com.layoutFiledList" :key="key"><section v-html="tab.tabContent || tab.filedName"/></tab-item>
</s-tab>
<h-content :class="{'has-footer':hasBottom}">
<list-item
v-for="(com, index) in layoutConfig" v-if="com.configType==='FORM' && com.layoutFiledList.length" v-show="tabFromHide(com)" :key="index"
:class="com.cssClass">
<item v-show="showFormTitle" class="form-title" @click.native="hideFormClick(index)">
<div slot="name">{{ com.configName }}</div>
<img
slot="right-icon" :class="{'hide-down-icon':!com.hideForm,'hide-up-icon':com.hideForm}"
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"
:showContent="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
v-if="filed.filedType==='INPUT'" slot="content"
:readonly="filed.inputMode==='readOnly'"
:placeholder="filed.placeholder" v-model="data[com.configCode][filed.filedCode]" :type="filed.inputType" :name="filed.filedCode">
<input
v-else-if="filed.filedType==='SELECT'"
slot="content" :name="filed.filedCode"
v-model="data[com.configCode][filed.filedCode+'_n']" :placeholder="filed.placeholder" readonly @click="showSelect(com,filed)">
<input
v-else-if="filed.filedType=='TIME'"
slot="content" :name="filed.filedCode"
v-model="data[com.configCode][filed.filedCode]" :placeholder="filed.placeholder" readonly @click="showTime(com,filed)">
<h-switch v-else-if="filed.filedType==='SWITCH'" slot="content" v-model="data[com.configCode][filed.filedCode]" :name="filed.filedCode"/>
<div v-else slot="content" v-html="data[com.configCode][filed.filedCode]"/>
<img v-if="filed.rightIcon" slot="right-icon" :src="filed.rightIcon" class="right-icon">
</item>
</list-item>
</h-content>
<bottom-tab
v-for="(com, index) in layoutConfig" v-if="com.configType==='bottomTab' && com.layoutFiledList.length" :key="index" :show-divider="showBtnDivider"
:class="com.cssClass">
<tab-button v-for="(btn, index) in com.layoutFiledList" :key="index" :class="btn.cssClass"><section v-html="btn.btnContent || btn.filedName"/></tab-button>
</bottom-tab>
</section>
</template>
<script>
export default {
name: 'HForm',
props: {
layoutData: {
type: Array,
default: () => [],
},
showFormTitle: {
type: Boolean,
default: true,
},
showTabDivider: {
type: Boolean,
default: false,
},
showTabBorder: {
type: Boolean,
default: false,
},
showBtnDivider: {
type: Boolean,
default: true,
},
formData: {
type: Object,
default: () => {},
},
},
data () {
return {
tabIndex: 0,
data: {},
layoutConfig: [],
activeTab: null,
activeTabFiled: null,
hasBottom: false,
}
},
computed: {
defaultTabActive () {
return this.tabIndex
},
},
created () {
let vm = this
if (vm.layoutData.length && vm.layoutData[0].layoutConfigList.length) {
vm.layoutConfig = vm.layoutData[0].layoutConfigList
vm.layoutConfig.forEach((com, index) => {
if (com.configType === 'bottomTab') {
vm.hasBottom = true
}
if (com.configType === 'FORM') {
let form = com
let temp = {}
if (form.layoutFiledList.length) {
let filed = form.layoutFiledList
filed.forEach((filed, index) => {
if (vm.formData[form.configCode]) {
temp[filed.filedCode] = vm.formData[form.configCode][filed.filedCode]
} else {
temp[filed.filedCode] = filed.defaultValue
}
if (filed.filedType === 'SELECT') {
if (vm.formData[form.configCode]) {
temp[filed.filedCode + '_n'] = vm.formData[form.configCode][filed.filedCode + '_n']
}
}
if (filed.filedType === 'SWITCH') {
temp[filed.filedCode] = !!filed.defaultValue
}
})
vm.$set(vm.data, [form.configCode], temp)
}
} else if (com.configType === 'TAB') {
vm.activeTab = com.configCode
vm.activeTabFiled = com.layoutFiledList.length ? com.layoutFiledList[vm.tabIndex].filedCode : ''
}
})
vm.$emit('input', vm.data)
}
},
methods: {
proportionArray (proportion) {
return proportion.split(',')
},
layoutTabClick (index) {
let vm = this
vm.tabIndex = index
this.$emit('tabClick', index)
},
tabNativeClick (com) {
let vm = this
vm.activeTab = com.configCode
vm.activeTabFiled = com.layoutFiledList.length ? com.layoutFiledList[vm.tabIndex].filedCode : ''
},
hideFormClick (index) {
let vm = this
vm.layoutConfig[index]['hideForm'] = !vm.layoutConfig[index]['hideForm']
},
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) {
this.$emit('showSelect', com.configCode, filed.filedCode)
},
showTime (com, filed) {
this.$emit('showTime', com.configCode, filed.filedCode)
},
},
}
</script>
<style lang="less">
.h-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>
...@@ -26,6 +26,7 @@ import HFile from './HFile/index' ...@@ -26,6 +26,7 @@ import HFile from './HFile/index'
import BottomTab from './BottomTab/index' import BottomTab from './BottomTab/index'
import TabButton from './BottomTab/tab-button' import TabButton from './BottomTab/tab-button'
import Modal from './Modal/Modal' import Modal from './Modal/Modal'
import HForm from './HForm/index'
import errLoadingPic from '../common/picture/errloading.jpg' import errLoadingPic from '../common/picture/errloading.jpg'
...@@ -57,4 +58,5 @@ export default (Vue) => { ...@@ -57,4 +58,5 @@ export default (Vue) => {
Vue.component('radio-group', RadioGroup) Vue.component('radio-group', RadioGroup)
Vue.component('h-radio', Radio) Vue.component('h-radio', Radio)
Vue.component('h-file', HFile) Vue.component('h-file', HFile)
Vue.component('h-form', HForm)
} }
...@@ -23,6 +23,7 @@ import Stab from './components/STab/index' ...@@ -23,6 +23,7 @@ import Stab from './components/STab/index'
import TabItem from './components/STab/tab-item' import TabItem from './components/STab/tab-item'
import TabButton from './components/BottomTab/tab-button' import TabButton from './components/BottomTab/tab-button'
import HFile from './components/HFile/index' import HFile from './components/HFile/index'
import HForm from './components/HForm/index'
import componentInstall from './components/component' import componentInstall from './components/component'
// compontenPlugins // compontenPlugins
...@@ -64,6 +65,7 @@ export { ...@@ -64,6 +65,7 @@ export {
BottomTab, BottomTab,
TabButton, TabButton,
HFile, HFile,
HForm,
ActionSheetPlugin, ActionSheetPlugin,
ShowPicturePlugin, ShowPicturePlugin,
SelectPlugin, SelectPlugin,
......
...@@ -12,130 +12,81 @@ ...@@ -12,130 +12,81 @@
<div slot="center">From</div> <div slot="center">From</div>
<div slot="right" class="h-header-btn">右边</div> <div slot="right" class="h-header-btn">右边</div>
</h-header> </h-header>
<h-content> <h-form
<section v-for="(com, index) in layoutData" :key="index"> :layout-data="layoutData" :show-form-title="showFormTitle" :show-btn-divider="true"
<s-tab :show-tab-divider="true" :formData.sync="data" v-model="data" @tabClick="tabClick"
v-if="com.configType==='TAB' && com.layoutFiledList.length" @showSelect="showSelect" @showTime="showTime"/>
: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>
<list-item v-if="com.configType==='FORM' && com.layoutFiledList.length" v-show="tabFromHide(com)" :class="com.cssClass">
<item v-show="showFormTitle" class="form-title" @click.native="hideFormClick(index)">
<div slot="name">{{ com.configName }}</div>
<img
slot="right-icon" :class="{'hide-down-icon':!com.hideForm,'hide-up-icon':com.hideForm}"
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"
:has-content="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
v-if="filed.filedType==='INPUT'" slot="content"
:readonly="filed.inputMode==='readOnly'"
:placeholder="filed.placeholder" :value="filed.defaultValue" :type="filed.inputType" :name="filed.filedName">
<input
v-else-if="filed.filedType==='SELECT'"
slot="content" :name="filed.filedName"
readonly @click="showSelect(com,filed)">
<input
v-else-if="filed.filedType=='TIME'"
slot="content" :name="filed.filedName"
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>
</list-item>
</section>
</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" :class="com.cssClass">
<tab-button v-for="(btn, index) in com.layoutFiledList" :key="index" :class="btn.cssClass"><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 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 {
tabIndex: 1, tabIndex: 1,
showFormTitle: true, showFormTitle: true,
layoutData: null, layoutData: [...layoutData],
data: {}, data: {
activeTab: null, contract: {
activeTabFiled: null, postion: '01',
postion_n: '技术顾问',
},
},
postionList: [
{code: '01', code_name: '技术顾问'},
{code: '02', code_name: '技术经理'},
{code: '03', code_name: '项目经理'},
],
} }
}, },
created () { created () {
let vm = this
if (layoutData.rows && layoutData.rows[0].layoutConfigList.length) {
vm.layoutData = layoutData.rows[0].layoutConfigList
vm.layoutData.forEach((com, index) => {
if (com.configType === 'FORM') {
let form = com
let temp = {}
if (form.layoutFiledList.length) {
let filed = form.layoutFiledList
filed.forEach((filed, index) => {
temp[filed.filedCode] = filed.defaultValue
if (filed.type === 'select') {
temp[filed.filedCode + '_n'] = filed.defaultValueN
}
})
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: {
proportionArray (proportion) { tabClick (index) {
return proportion.split(',') this.tabIndex = index
}, },
layoutTabClick (index) { showPostion (configCode, filedCode) {
let vm = this let vm = this
vm.tabIndex = index vm.hlsPopup.selectList({
list: vm.postionList,
code: filedCode,
object: vm.data[configCode],
returnItem (index) {
vm.data[configCode][filedCode] = vm.postionList[index].code
vm.data[configCode][filedCode + '_n'] = vm.postionList[index].code_name
}, },
tabClick (com) { })
let vm = this
vm.activeTab = com.configCode
vm.activeTabFiled = com.layoutFiledList.length ? com.layoutFiledList[vm.tabIndex].filedCode : ''
}, },
showSelect (configCode, filedCode) {
hideFormClick (index) {
let vm = this let vm = this
vm.layoutData[index]['hideForm'] = !vm.layoutData[index]['hideForm'] switch (filedCode) {
case 'postion':
vm.showPostion(configCode, filedCode)
break
default:
}
}, },
tabFromHide (com) { showOrderDate (configCode, filedCode) {
let vm = this let vm = this
if (com.tabConfigCode && com.tabFiledCode) { vm.hlsPopup.showTime({
if (com.tabConfigCode === vm.activeTab && com.tabFiledCode === vm.activeTabFiled) { callback (time) {
return true vm.data[configCode][filedCode] = time
}
} return false
}, },
showSelect (com, filed) { })
}, },
showTime (com, filed) { showTime (configCode, filedCode) {
let vm = this
switch (filedCode) {
case 'order_date':
vm.showOrderDate(configCode, filedCode)
break
default:
}
}, },
}, },
} }
...@@ -143,43 +94,5 @@ export default { ...@@ -143,43 +94,5 @@ export default {
<style lang="less"> <style lang="less">
.form { .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>
{ [
"rows": [
{ {
"_token": "5c7ed163aabdb97edbb4023503ad33f8", "_token": "5c7ed163aabdb97edbb4023503ad33f8",
"objectVersionNumber": null, "objectVersionNumber": null,
...@@ -548,7 +547,7 @@ ...@@ -548,7 +547,7 @@
"layoutId": "1", "layoutId": "1",
"configCode": "SAVE_BUTTON", "configCode": "SAVE_BUTTON",
"configName": "底部按钮", "configName": "底部按钮",
"configType": "BOTTOM-BUTTON", "configType": "bottomTab",
"configOrder": "40", "configOrder": "40",
"tabFlag": "N", "tabFlag": "N",
"tabConfigId": null, "tabConfigId": null,
...@@ -620,7 +619,4 @@ ...@@ -620,7 +619,4 @@
} }
] ]
} }
], ]
"success": true,
"total": 1
}
...@@ -275,7 +275,7 @@ export default { ...@@ -275,7 +275,7 @@ export default {
date = timeObject.nowDate date = timeObject.nowDate
} }
if (timeObject.format) { if (timeObject.format) {
format = timeObject.format format = timeObject.format || 'YYYY-MM-DD'
} }
Vue.$vux.datetime.show({ Vue.$vux.datetime.show({
cancelText: '取消', cancelText: '取消',
......
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