fix:添加树结构、云诉求调整

This commit is contained in:
HH 2024-06-04 16:44:39 +08:00
parent 1ff800d718
commit 9bd4faaf3a
12 changed files with 443 additions and 13 deletions

View File

@ -45,7 +45,8 @@
"ec-canvas": "/ec-canvas/ec-canvas", "ec-canvas": "/ec-canvas/ec-canvas",
"cu-custom": "/colorui/components/cu-custom", "cu-custom": "/colorui/components/cu-custom",
"empty": "/components/empty/empty", "empty": "/components/empty/empty",
"title-bar": "/components/title-bar/index" "title-bar": "/components/title-bar/index",
"tree-node": "components/tree-node/index"
}, },
"requiredPrivateInfos": ["getLocation","chooseLocation"], "requiredPrivateInfos": ["getLocation","chooseLocation"],
"permission": { "permission": {

View File

@ -0,0 +1,188 @@
// components/tree/index.js
Component({
/**
* 组件的属性列表
*/
properties: {
dataTree: {
type: Array,
value: []
},
pros: {
type: Object,
value: {
key: 'name',
val: 'id'
}
},
checkrule: {
type: Array,
value: []
},
treeListIndex: { // 当期树形列表的索引
type: Number,
value: 1
},
isOpenAll: { // 是否展开全部节点
type: Boolean,
value: false
}
},
observers: {
'dataTree': function (params) {
var arr = []
if (this.properties.checkrule.length > 0) {
this.setData({
allChoiceIdList: this.properties.checkrule
})
arr = this.showcheck(params)
} else {
arr = params
}
this.setData({
tree: this._initSourceData(arr),
arr: JSON.parse(JSON.stringify(params)),
})
}
},
/**
* 组件的初始数据
*/
data: {
tree: [],
arr:[],
allChoiceIdList: [] // 所有选中的id数组
},
/**
* 组件的方法列表
*/
methods: {
isOpen(e) {
const open = 'tree[' + e.currentTarget.dataset.index + '].open'
this.setData({
[open]: !this.data.tree[e.currentTarget.dataset.index].open
})
},
_initSourceData(nodes) {
nodes.forEach(element => {
if (element.checked === undefined) element.checked = 0
element.open = this.properties.isOpenAll // 是否展开
if (element.children && element.children.length > 0) element.children = this._initSourceData(element.children)
})
return nodes
},
// 选择
select(e) {
let arr = JSON.parse(JSON.stringify(this.data.arr))
let item = e.currentTarget.dataset.item
item = this._handleClickItem(item)
this.data.tree = this._updateTree(arr, item)
this.setData({
tree: this.data.tree
})
// this.data.allChoiceIdList = this.getAllChoiceId(this.data.tree)
this.triggerEvent('select', {item}, )
// this.triggerEvent('clickItem', {
// item: item
// }, {
// bubbles: true,
// composed: true
// })
},
// 选择冒泡事件
handleSelect(e) {
let currentTap = e.detail.item
this.triggerEvent('select', {
item: currentTap})
},
/**
* @method 处理点击选择
* @param {Object} node 节点对象
* @returns {Object} node 处理完毕的节点
* @description 有子节点则全选中或全取消当前为最底层单节点则选中或单取消
*/
_handleClickItem(node) {
switch (node.checked) {
case 0:
node.checked = 1
break;
case 1:
node.checked = 0
break;
default:
node.checked = 1
break;
}
return node
},
/**
* @method 更新tree
* @param {Array} tree 节点树
* @param {Object} newItem 需要替换新节点
* @description 找到tree中目标进行替换
*/
_updateTree(tree, newItem) {
if (!tree || tree.length <= 0) return
for (let i = 0; i < tree.length; i++) {
if (tree[i][this.properties.pros.val] === newItem[this.properties.pros.val]) {
tree[i] = newItem
break
} else {
if (tree[i].children && tree[i].children.length > 0) {
tree[i].children = this._updateTree(tree[i].children, newItem)
}
}
}
return tree
},
/**
* @method 获取子节点的状态
* @param {Array} node 节点数组
*/
getChildState(node) {
let all = true;
let none = true;
for (let i = 0, j = node.length; i < j; i++) {
const n = node[i];
if (n.checked === 1 || n.checked === -1) {
none = none && false;
}
if (n.checked === 0 || n.checked === -1) {
all = all && false
}
}
return {
all,
none,
half: !all && !none
};
},
// 获取所有选中的节点id
getAllChoiceId(nodes, res = []) {
for (let i = 0; i < nodes.length; i++) {
if (nodes[i].checked === 1) res.push(nodes[i][this.properties.pros.val])
if (nodes[i].children && nodes[i].children.length > 0) this.getAllChoiceId(nodes[i].children, res)
}
console.log(res,888888888)
// return res
},
//回显选中的
showcheck(nodes) {
for (let i = 0; i < nodes.length; i++) {
if (this.properties.checkrule.indexOf(nodes[i][this.properties.pros.val]) > -1) {
nodes[i].checked = 1
}
if (nodes[i].children && nodes[i].children.length > 0) this.showcheck(nodes[i].children)
}
return nodes
},
getData() {
return this.data.tree
}
}
})

View File

@ -0,0 +1,6 @@
{
"component": true,
"usingComponents": {
"tree-node": "./index"
}
}

View File

@ -0,0 +1,20 @@
<!--components/tree-node/index.wxml-->
<view wx:for="{{tree}}" wx:key="id" class="tree_container">
<!-- 一级菜单 -->
<view style="margin-left: {{treeListIndex*40}}rpx" class="tree-item">
<view class="tree-item-onOff" wx:if="{{item.children && item.children.length > 0}}" catchtap="isOpen" data-index="{{index}}">
<image src="/images/expand.png" class="expand {{item.open ? '' : 'collapse'}}" />
</view>
<view class="tree-item-onOff" wx:else></view>
<view class="tree-item-name" catchtap="select" data-item="{{item}}" data-index="{{index}}">
<image wx:if="{{item.checked == 1}}" src="/images/checkbox-checked.png" class="check-box"></image>
<image wx:if="{{item.checked == 0||item.checked==-1}}" src="/images/checkbox.png" class="check-box"></image>
<text class="tree-item-title {{item.checked === 1 ? 'tree-item-name-select' : '' }}">{{item[pros.key]}}</text>
</view>
</view>
<!-- 二级菜单 -->
<tree-node wx:if="{{item.children && item.children.length > 0 && item.open }}" data-parent="{{item}}" dataTree='{{ item.children }}' isOpenAll="{{isOpenAll}}" treeListIndex="{{treeListIndex+1}}" catch:select="handleSelect" pros="{{pros}}" />
</view>
<view wx:if="{{tree.length == 0}}">
暂无数据
</view>

View File

@ -0,0 +1,58 @@
/* components/tree/index.wxss */
/* modules/attestation/pages/checkrule/index.wxss */
.tree_container {
width: auto;
box-sizing: border-box;
overflow: scroll;
background: #fff;
}
.tree-item {
width: auto;
box-sizing: border-box;
overflow-x: scroll;
padding: 10rpx 0;
display: flex;
justify-content: flex-start;
align-items: center;
}
.tree-item-name {
display: flex;
justify-content: flex-start;
align-items: center;
flex: 8;
}
.tree-item-title {
margin-left: 24rpx;
color: #1c2438;
font-size: 32rpx;
word-break: break-all;
}
.tree-item-onOff {
width: 40rpx;
display: flex;
justify-content: center;
align-items: center;
}
.collapse {
transform: rotate(-90deg);
}
.expand {
width: 36rpx;
height: 36rpx;
}
.check-box {
height: 30rpx;
width: 30rpx;
margin-left: 30rpx;
}
.tree-item-name-select {
color: #0079FE;
}

View File

@ -24,6 +24,15 @@ Page({
}, },
typeId:'', typeId:'',
//树结构
areaCode:'',
areaPathName:'',
unitTreepros: {
key: 'orgname',
val: 'orgcode'
},
unitTreelist: [],
// 地区数据 // 地区数据
areamultiIndex: [0, 0, 0], areamultiIndex: [0, 0, 0],
@ -61,6 +70,20 @@ Page({
this.data.typeId = params.currentTarget.dataset.item.typeId; this.data.typeId = params.currentTarget.dataset.item.typeId;
this.getList(params.currentTarget.dataset.item.typeId); this.getList(params.currentTarget.dataset.item.typeId);
}, },
handleselectunit(e) {
// e.detail 选中的id数组
this.data.page = 1;
this.data.list = [];
let postData = this.data.postData; // 获取当前的 postData 对象
postData.orgcode = e.detail.item.orgcode;
postData.areaPathName = e.detail.item.orgname;
this.setData({
postData: postData,
showTypePop:false
}); // 设置更新后的 postData 对象
this.getList(this.data.typeId);
},
/** /**
* 查看详情 * 查看详情
*/ */
@ -101,6 +124,7 @@ Page({
if (res.code == 1) { if (res.code == 1) {
console.log(res,'res===>'); console.log(res,'res===>');
this.data.TypeData = res.data[0].children; this.data.TypeData = res.data[0].children;
this.data.unitTreelist = res.data;
this.setData(this.data) this.setData(this.data)
} }
}) })
@ -165,7 +189,6 @@ Page({
// endTime:this.data.endTime, // endTime:this.data.endTime,
// startTime:this.data.startTime, // startTime:this.data.startTime,
typeId:id, typeId:id,
typeId:'',
// userId:this.data.userInfo.userId, // userId:this.data.userInfo.userId,
condition:this.data.search, condition:this.data.search,
}; };
@ -176,9 +199,10 @@ Page({
console.log(params,'params==>'); console.log(params,'params==>');
app.axios("GET", "app", `/people/peopleInfoByType`, params).then(res => { app.axios("GET", "app", `/people/peopleInfoByType`, params).then(res => {
if (res.code == 1) { if (res.code == 1) {
this.data.freshIng = false; this.setData({
this.data.list = [...this.data.list,...res.data.list]; list:[...this.data.list,...res.data.list],
this.setData(this.data); freshIng:false,
});
} }
}) })
}, },

View File

@ -1,5 +1,6 @@
{ {
"usingComponents": { "usingComponents": {
"tree-node":"/components/tree-node/index"
}, },
"navigationStyle": "custom" "navigationStyle": "custom"
} }

View File

@ -32,7 +32,8 @@
</view> </view>
<text class="lab">所属社区</text> <text class="lab">所属社区</text>
<text>{{TypeData[postData.type-1].orgname}}</text> <text>{{ postData.areaPathName }}</text>
<!-- <text>{{TypeData[postData.type-1].orgname}}</text> -->
<!-- <picker mode="multiSelector" bindchange="areabindMultiPickerChange" bindcolumnchange="areabindMultiPickerColumnChange" <!-- <picker mode="multiSelector" bindchange="areabindMultiPickerChange" bindcolumnchange="areabindMultiPickerColumnChange"
value="{{areamultiIndex}}" range="{{areanewArr}}"> value="{{areamultiIndex}}" range="{{areanewArr}}">
<view class="picker picker1"> <view class="picker picker1">
@ -81,13 +82,15 @@
</view> </view>
<radio-group class="block" style="max-height: 50vh;overflow-y: scroll;"> <radio-group class="block" style="max-height: 50vh;overflow-y: scroll;">
<view class="cu-list menu text-left"> <!-- <view class="cu-list menu text-left">
<view class="cu-item" wx:for="{{TypeData}}" wx:key> <view class="cu-item" wx:for="{{TypeData}}" wx:key>
<label catchtap="typeChange" data-index="{{index}}" class="flex justify-between align-center flex-sub"> <label catchtap="typeChange" data-index="{{index}}" class="flex justify-between align-center flex-sub">
<view class="flex-sub">{{item.orgname}}</view> <view class="flex-sub">{{item.orgname}}</view>
</label> </label>
</view> </view>
</view> </view> -->
<tree-node id="tree" dataTree="{{unitTreelist}}" pros="{{unitTreepros}}" bindselect="handleselectunit" isOpenAll="true" />
</radio-group> </radio-group>
</view> </view>
</view> </view>

View File

@ -9,7 +9,10 @@ Page({
data: { data: {
topBarH: app.globalData.CustomBar, topBarH: app.globalData.CustomBar,
postData: {}, postData: {},
userInfo:{} userInfo:{},
uuid:'',
files:[],
baseUrl:app.FILE_SERVER_URL,
}, },
/** /**
* 输入内容 * 输入内容
@ -31,7 +34,7 @@ Page({
}; };
let params= { let params= {
...this.data.postData, ...this.data.postData,
difficultyId:this.data.postData.difficultyId||'', difficultyId:this.data.postData.difficultyId||this.data.uuid,
userId:this.data.userInfo.userId, userId:this.data.userInfo.userId,
}; };
app.axios("POST", "app", "/difficultyAppeal/addDifficulty", params).then(res => { app.axios("POST", "app", "/difficultyAppeal/addDifficulty", params).then(res => {
@ -106,8 +109,81 @@ Page({
getDetail:function (id) { getDetail:function (id) {
app.axios("GET", "app", `/difficultyAppeal/difficultyDetail/${id}`).then(res => { app.axios("GET", "app", `/difficultyAppeal/difficultyDetail/${id}`).then(res => {
this.data.postData = res.data; this.data.postData = res.data;
this.getFiles();
this.setData(this.data); this.setData(this.data);
}); });
},
/**
* 选择文件
*/
chooseFile: function () {
wx.chooseImage({
count: 1,
type: 'all',
success: (res) => {
const tempFilePaths = res.tempFiles;
const path = tempFilePaths[0].path;
this.postImg(path)
}
})
},
/**
* 上传图片
*/
postImg(filePath) {
wx.showLoading({
title: '文件上传中...',
})
app.uploadFile(this.data.uuid, app.FileType.resumptionAcs, filePath).then(res => {
wx.hideLoading();
this.getFiles();
})
},
/**
* 获取图片
*/
getFiles: function () {
app.axios("GET", "common", "/upload/getFile", {
otcid: this.data.postData.difficultyId || this.data.uuid,
otctype: app.FileType.resumptionAcs
}).then(res => {
if (res.code == 1) {
this.data.files = res.data;
this.setData(this.data)
}
})
},
/**
* 删除图片
* @param {*} params
*/
deleteFile: function (e) {
var id = e.currentTarget.dataset.id;
wx.showModal({
title: '删除提示',
content: '是否要删除该附件?',
success: (res) => {
if (res.confirm) {
app.axios("GET", 'common', "/upload/delFile", {
documentId: id,
}).then(res => {
if (res.code == 1) {
this.getFiles();
}
})
}
}
})
},
/**
* 状态切换
*/
changeHtstate(e) {
var htstate = e.currentTarget.dataset.htstate
this.data.postData.dangerState = htstate
this.setData(this.data)
}, },
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
@ -117,8 +193,8 @@ Page({
this.getDetail(options.difficultyId); this.getDetail(options.difficultyId);
} }
// this.data.isUserDetail = options.user; // this.data.isUserDetail = options.user;
// this.data.uuid = Utils.uuid();
// this.setData(this.data) // this.setData(this.data)
this.data.uuid = Utils.uuid();
this.data.userInfo = app.globalData.userInfo; this.data.userInfo = app.globalData.userInfo;
this.setData(this.data); this.setData(this.data);
}, },

View File

@ -6,8 +6,32 @@
<text class="single"></text> <text class="single"></text>
<text class="title">困难诉求</text> <text class="title">困难诉求</text>
</view> </view>
<textarea bindinput="inputContent" data-name="content" value="{{postData.content}}" style="color: #333333;" class="put v-div" placeholder="请输入困难诉求"></textarea> <textarea bindinput="inputContent" data-name="content" value="{{postData.content}}" style="color: #333333;" class="put v-div" placeholder="请输入困难诉求"></textarea>
<view class="h-div v-center header">
<text class="single"></text>
<text class="title">状态</text>
</view>
<view class="content">
<view class="btn">
<button class="rectified {{postData.dangerState==2?'checkedButton':''}}" data-htstate="{{2}}" bindtap="changeHtstate" style="padding: 0;">已取消</button>
<button class="not_rectified {{postData.dangerState==3?'checkedButton':''}}" data-htstate="{{3}}" bindtap="changeHtstate" style="padding: 0;">已处理</button>
</view>
</view>
<!-- 附件 -->
<view class="h-div v-center header">
<text class="single"></text>
<text class="title flex">附件</text>
<text catchtap="chooseFile" class="title cuIcon-roundadd" style="font-weight: normal;color: #5DA6F4;">添加图片</text>
</view>
<view class="grid">
<view class="img" wx:for="{{files}}" style="position: relative;">
<text wx:if="{{!postData.dynamicsId}}" catchtap="deleteFile" data-id="{{item.sysdocumentid}}" class="cuIcon-delete del" style="color:red;"></text>
<image class="img" src="{{baseUrl+item.filepath}}" catchtap="filePre" data-url="{{item.filepath}}" />
</view>
</view>
</view> </view>
<view class="space"></view> <view class="space"></view>
</scroll-view> </scroll-view>

View File

@ -120,3 +120,32 @@ scroll-view {
margin-left: 20rpx; margin-left: 20rpx;
background-color: red; background-color: red;
} }
.content {
padding-top: 5px;
padding-bottom: 15px;
}
.content .btn {
display: flex;
height: 35px;
margin-top: 15px;
}
.content .btn button {
width: 40%;
}
.rectified,
.not_rectified {
font-size: 14px;
color: #999999;
line-height: 35px;
font-weight: normal;
border-radius: 5px;
background-color: #fff;
border: 1px solid #999;
}
.checkedButton {
background-color: #62BB62;
color: #fff;
border: none;
}

View File

@ -1,6 +1,6 @@
{ {
"description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
"projectname": "daofu-applet-gov", "projectname": "daofu-applet",
"setting": { "setting": {
"compileHotReLoad": true, "compileHotReLoad": true,
"urlCheck": false "urlCheck": false