尝试解决选人问题
This commit is contained in:
parent
81b9647dce
commit
38f7bdfe8f
|
@ -14,7 +14,6 @@ Component({
|
||||||
*/
|
*/
|
||||||
methods: {
|
methods: {
|
||||||
delete(res) {
|
delete(res) {
|
||||||
console.log(res)
|
|
||||||
let index = res.currentTarget.id
|
let index = res.currentTarget.id
|
||||||
let list = this.data.list
|
let list = this.data.list
|
||||||
list.splice(index, 1)
|
list.splice(index, 1)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<view class='container'>
|
<view class='container'>
|
||||||
<view class='scroll-wrapper'>
|
<view class='scroll-wrapper'>
|
||||||
<scroll-view scroll-x style='scroll'>
|
<scroll-view scroll-x style='scroll'>
|
||||||
<text id='{{index}}' class='text' wx:for='{{list}}' wx:key='{{index}}' bindtap='delete'>{{item.name}}</text> </scroll-view>
|
<text id='{{index}}' class='text' wx:for='{{list}}' wx:key="index" bindtap='delete'>{{item.name}}</text></scroll-view>
|
||||||
</view>
|
</view>
|
||||||
<text class='btn' bindtap='confirm'>确定</text>
|
<text class='btn' bindtap='confirm'>确定</text>
|
||||||
</view>
|
</view>
|
|
@ -34,7 +34,6 @@ Page({
|
||||||
success: res => {
|
success: res => {
|
||||||
if (res.statusCode === 200) {
|
if (res.statusCode === 200) {
|
||||||
let list = res.data.data
|
let list = res.data.data
|
||||||
console.log(list)
|
|
||||||
this.setData({
|
this.setData({
|
||||||
currentList: list,
|
currentList: list,
|
||||||
originalList:list
|
originalList:list
|
||||||
|
@ -45,12 +44,9 @@ Page({
|
||||||
},
|
},
|
||||||
|
|
||||||
clickItem(res) {
|
clickItem(res) {
|
||||||
console.log(res)
|
|
||||||
let index = res.currentTarget.id;
|
let index = res.currentTarget.id;
|
||||||
let item = this.data.currentList[index]
|
let item = this.data.currentList[index]
|
||||||
|
|
||||||
console.log("item", item)
|
|
||||||
|
|
||||||
if (!item.isPeople) {
|
if (!item.isPeople) {
|
||||||
//children的长度为0时,请求服务器
|
//children的长度为0时,请求服务器
|
||||||
if (item.children.length === 0) {
|
if (item.children.length === 0) {
|
||||||
|
@ -60,6 +56,7 @@ Page({
|
||||||
this.setData({
|
this.setData({
|
||||||
currentList: item.children
|
currentList: item.children
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
//将当前的索引存入索引目录中。索引多一个表示目录多一级
|
//将当前的索引存入索引目录中。索引多一个表示目录多一级
|
||||||
|
@ -70,7 +67,8 @@ Page({
|
||||||
indexList: indexes
|
indexList: indexes
|
||||||
})
|
})
|
||||||
//清空上次选中的元素列表,并设置上一层的选中状态给lastTimeSelect
|
//清空上次选中的元素列表,并设置上一层的选中状态给lastTimeSelect
|
||||||
this.setLastTimeSelectList();
|
// this.setLastTimeSelectList();
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -100,7 +98,8 @@ Page({
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
//清空上次选中的元素列表,并设置上一层的选中状态给lastTimeSelect
|
//清空上次选中的元素列表,并设置上一层的选中状态给lastTimeSelect
|
||||||
this.setLastTimeSelectList();
|
//this.setLastTimeSelectList();
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -126,7 +125,6 @@ Page({
|
||||||
success: res => {
|
success: res => {
|
||||||
if (res.statusCode === 200) {
|
if (res.statusCode === 200) {
|
||||||
let list = res.data.data
|
let list = res.data.data
|
||||||
console.log(res.list)
|
|
||||||
this.setData({
|
this.setData({
|
||||||
currentList: list
|
currentList: list
|
||||||
})
|
})
|
||||||
|
@ -198,12 +196,10 @@ Page({
|
||||||
this.setData({
|
this.setData({
|
||||||
originalList: originalList
|
originalList: originalList
|
||||||
})
|
})
|
||||||
console.log("originalList", originalList)
|
|
||||||
},
|
},
|
||||||
|
|
||||||
//选框变化回调
|
//选框变化回调
|
||||||
checkChange(res) {
|
checkChange(res) {
|
||||||
console.log(res)
|
|
||||||
let values = res.detail.value
|
let values = res.detail.value
|
||||||
let selectItems = []
|
let selectItems = []
|
||||||
//将值取出拼接成 id,name 格式
|
//将值取出拼接成 id,name 格式
|
||||||
|
@ -211,8 +207,6 @@ Page({
|
||||||
let arrs = value.split(",")
|
let arrs = value.split(",")
|
||||||
selectItems.push({ id: arrs[0], name: arrs[1] })
|
selectItems.push({ id: arrs[0], name: arrs[1] })
|
||||||
})
|
})
|
||||||
console.log("selectItems", selectItems)
|
|
||||||
console.log("lastTimeSelect", this.lastTimeSelect)
|
|
||||||
|
|
||||||
//将本次选择的与上次选择的比对,本次比上次多说明新增了,本次比上次少说明删除了,找出被删除的那条数据,在footer中也删除
|
//将本次选择的与上次选择的比对,本次比上次多说明新增了,本次比上次少说明删除了,找出被删除的那条数据,在footer中也删除
|
||||||
if (selectItems.length > this.lastTimeSelect.length) {
|
if (selectItems.length > this.lastTimeSelect.length) {
|
||||||
|
@ -235,7 +229,6 @@ Page({
|
||||||
})
|
})
|
||||||
if (!flag) {
|
if (!flag) {
|
||||||
diffItem = item
|
diffItem = item
|
||||||
console.log("diff=", item)
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
//找出被删除的元素在 selectList 中的位置
|
//找出被删除的元素在 selectList 中的位置
|
||||||
|
@ -253,19 +246,16 @@ Page({
|
||||||
selectList: list
|
selectList: list
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
console.log("selectList", this.data.selectList)
|
|
||||||
//更新 currentList 选中状态并重新挂载在数据树上,以保存选择状态
|
//更新 currentList 选中状态并重新挂载在数据树上,以保存选择状态
|
||||||
this.updateCurrentList(this.data.currentList, this.data.selectList)
|
this.updateCurrentList(this.data.currentList, this.data.selectList)
|
||||||
},
|
},
|
||||||
|
|
||||||
//footer点击删除回调
|
//footer点击删除回调
|
||||||
footerDelete(res) {
|
footerDelete(res) {
|
||||||
console.log(res)
|
|
||||||
this.setData({
|
this.setData({
|
||||||
selectList: res.detail.selectList
|
selectList: res.detail.selectList
|
||||||
})
|
})
|
||||||
|
|
||||||
console.log('selectList', this.data.selectList)
|
|
||||||
this.updateCurrentList(this.data.currentList, res.detail.selectList)
|
this.updateCurrentList(this.data.currentList, res.detail.selectList)
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -280,7 +270,6 @@ Page({
|
||||||
wx.navigateBack({
|
wx.navigateBack({
|
||||||
delta: 1
|
delta: 1
|
||||||
})
|
})
|
||||||
console.log("selectdone", selectList)
|
|
||||||
},
|
},
|
||||||
|
|
||||||
//更新 currentList 并将更新后的列表挂载在数据树上
|
//更新 currentList 并将更新后的列表挂载在数据树上
|
||||||
|
@ -291,13 +280,12 @@ Page({
|
||||||
selectids.push(selectList[i]['id'])
|
selectids.push(selectList[i]['id'])
|
||||||
}
|
}
|
||||||
for (var i = 0; i < currentList.length; i++) {
|
for (var i = 0; i < currentList.length; i++) {
|
||||||
if (selectids.indexOf(currentList[i]['id'].toString())>=0){
|
if (currentList[i].isPeople && selectids.indexOf(currentList[i]['id'].toString())>=0){
|
||||||
currentList[i]['checked']=true
|
currentList[i]['checked'] = true
|
||||||
}else{
|
}else{
|
||||||
currentList[i]['checked'] = false
|
currentList[i]['checked'] = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log(currentList)
|
|
||||||
this.setData({
|
this.setData({
|
||||||
currentList: currentList
|
currentList: currentList
|
||||||
})
|
})
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<view class='people-wrapper'>
|
<view class='people-wrapper'>
|
||||||
<scroll-view scroll-y class='scrollview'>
|
<scroll-view scroll-y class='scrollview'>
|
||||||
<checkbox-group bindchange="checkChange">
|
<checkbox-group bindchange="checkChange">
|
||||||
<view class='item' wx:for='{{currentList}}' wx:key='{{item.id}}'>
|
<view class='item' wx:for='{{currentList}}' wx:key='index'>
|
||||||
<checkbox checked='{{item.checked}}' value='{{item.id + "," + item.name}}' wx:if='{{item.isPeople}}'> </checkbox>
|
<checkbox checked='{{item.checked}}' value='{{item.id + "," + item.name}}' wx:if='{{item.isPeople}}'> </checkbox>
|
||||||
<view id='{{index}}' class='item-content' bindtap='clickItem'>
|
<view id='{{index}}' class='item-content' bindtap='clickItem'>
|
||||||
<image class='img' wx:if='{{!item.isPeople}}' src='../images/part.png'></image>
|
<image class='img' wx:if='{{!item.isPeople}}' src='../images/part.png'></image>
|
||||||
|
|
|
@ -1,59 +1,59 @@
|
||||||
{
|
{
|
||||||
"description": "项目配置文件。",
|
"description": "项目配置文件。",
|
||||||
"setting": {
|
"setting": {
|
||||||
"urlCheck": false,
|
"urlCheck": false,
|
||||||
"es6": true,
|
"es6": true,
|
||||||
"enhance": false,
|
"postcss": true,
|
||||||
"postcss": true,
|
"minified": true,
|
||||||
"preloadBackgroundData": false,
|
"newFeature": true,
|
||||||
"minified": true,
|
"coverView": true,
|
||||||
"newFeature": true,
|
"nodeModules": true,
|
||||||
"coverView": true,
|
"autoAudits": false,
|
||||||
"nodeModules": true,
|
"showShadowRootInWxmlPanel": true,
|
||||||
"autoAudits": false,
|
"scopeDataCheck": false,
|
||||||
"showShadowRootInWxmlPanel": true,
|
"checkInvalidKey": true,
|
||||||
"scopeDataCheck": false,
|
"checkSiteMap": true,
|
||||||
"uglifyFileName": false,
|
"uploadWithSourceMap": true,
|
||||||
"checkInvalidKey": true,
|
"babelSetting": {
|
||||||
"checkSiteMap": true,
|
"ignore": [],
|
||||||
"uploadWithSourceMap": true,
|
"disablePlugins": [],
|
||||||
"compileHotReLoad": false,
|
"outputPath": ""
|
||||||
"useMultiFrameRuntime": false,
|
},
|
||||||
"useApiHook": true,
|
"useIsolateContext": true,
|
||||||
"babelSetting": {
|
"useCompilerModule": false,
|
||||||
"ignore": [],
|
"userConfirmedUseCompilerModuleSwitch": false,
|
||||||
"disablePlugins": [],
|
"enhance": false,
|
||||||
"outputPath": ""
|
"preloadBackgroundData": false,
|
||||||
},
|
"uglifyFileName": false,
|
||||||
"useIsolateContext": true,
|
"compileHotReLoad": false,
|
||||||
"useCompilerModule": true,
|
"useMultiFrameRuntime": false,
|
||||||
"userConfirmedUseCompilerModuleSwitch": false,
|
"useApiHook": true,
|
||||||
"packNpmManually": false,
|
"packNpmManually": false,
|
||||||
"packNpmRelationList": []
|
"packNpmRelationList": []
|
||||||
},
|
},
|
||||||
"compileType": "miniprogram",
|
"compileType": "miniprogram",
|
||||||
"libVersion": "2.9.4",
|
"libVersion": "2.9.4",
|
||||||
"appid": "wx5c39b569f01c27db",
|
"appid": "wx5c39b569f01c27db",
|
||||||
"projectname": "aqyj",
|
"projectname": "aqyj",
|
||||||
"isGameTourist": false,
|
"isGameTourist": false,
|
||||||
"simulatorType": "wechat",
|
"simulatorType": "wechat",
|
||||||
"simulatorPluginLibVersion": {},
|
"simulatorPluginLibVersion": {},
|
||||||
"condition": {
|
"condition": {
|
||||||
"search": {
|
"search": {
|
||||||
"current": -1,
|
"current": -1,
|
||||||
"list": []
|
"list": []
|
||||||
},
|
},
|
||||||
"conversation": {
|
"conversation": {
|
||||||
"current": -1,
|
"current": -1,
|
||||||
"list": []
|
"list": []
|
||||||
},
|
},
|
||||||
"game": {
|
"game": {
|
||||||
"currentL": -1,
|
"currentL": -1,
|
||||||
"list": []
|
"list": []
|
||||||
},
|
},
|
||||||
"miniprogram": {
|
"miniprogram": {
|
||||||
"current": -1,
|
"current": -1,
|
||||||
"list": []
|
"list": []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue