Commit 1c176d77 authored by 王波's avatar 王波

容器支持表单顺序展示

parent c4121f4b
...@@ -14,7 +14,7 @@ Component({ ...@@ -14,7 +14,7 @@ Component({
imageLimit: [250, 250], imageLimit: [250, 250],
prizeDataType: null, prizeDataType: null,
typeChecked: [], typeChecked: [],
type:'' type: ''
}, },
didMount() { }, didMount() { },
didUpdate() { }, didUpdate() { },
...@@ -29,20 +29,33 @@ Component({ ...@@ -29,20 +29,33 @@ Component({
up(e) { up(e) {
const index = e.target.dataset.idx; const index = e.target.dataset.idx;
const { onChange, list, dataName } = this.props; const { onChange, list, dataName } = this.props;
const upPrize = list[index-1]
const nowPrize = list[index] const nowPrize = list[index]
list[index-1] = nowPrize if(index === 0 ){
//最顶级往上,则移动到最后
list.splice(index,1)
list.push(nowPrize)
} else {
const upPrize = list[index - 1]
list[index - 1] = nowPrize
list[index] = upPrize list[index] = upPrize
}
onChange && onChange(list, dataName); onChange && onChange(list, dataName);
}, },
down(e) { down(e) {
const index = e.target.dataset.idx; const index = e.target.dataset.idx;
const { onChange, list, dataName } = this.props; const { onChange, list, dataName } = this.props;
const downPrize = list[index+1]
const nowPrize = list[index] const nowPrize = list[index]
list[index+1] = nowPrize if(index === list.length - 1){
//最底部往下,则移动到最上面
list.splice(index,1)
list.unshift(nowPrize)
} else {
const downPrize = list[index + 1]
list[index + 1] = nowPrize
list[index] = downPrize list[index] = downPrize
}
onChange && onChange(list, dataName); onChange && onChange(list, dataName);
}, },
addPrize() { addPrize() {
......
...@@ -8,16 +8,20 @@ ...@@ -8,16 +8,20 @@
<view class="edit-content"> <view class="edit-content">
<form class="edit-content-form" inline="true" labelTextAlign="right" labelCol="{{labelCol}}"> <form class="edit-content-form" inline="true" labelTextAlign="right" labelCol="{{labelCol}}">
<% for(var i = 0; i < configList.length; ++i) {%>
<%-configList[i].template%><% } %> <% for(var i = 0; i < configHtmlList.length; ++i) {%>
<!-- 容器组件 --> <% if(boxhtmlDatas[i].type == 'Box')% {>
<% for(var i = 0; i < boxhtmlDatas.length; ++i) {%>
<%- ` <%- `
<form-item label='${boxhtmlDatas[i].name}'> <form-item label='${boxhtmlDatas[i].name}'>
${boxhtmlDatas[i].value} ${boxhtmlDatas[i].value}
</form-item> </form-item>
` `
%><% } %> %>
<%} else {%>
<%-configList[i].template%><% } %>
<% } %>
<% } %>
<view class="submit-btn"> <view class="submit-btn">
<button a:if="{{!isEnd}}" onTap="onSubmit" type="primary">确定</button> <button a:if="{{!isEnd}}" onTap="onSubmit" type="primary">确定</button>
......
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