diff --git a/app.json b/app.json index e20bd8a..93144d9 100644 --- a/app.json +++ b/app.json @@ -45,7 +45,8 @@ "ec-canvas": "/ec-canvas/ec-canvas", "cu-custom": "/colorui/components/cu-custom", "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"], "permission": { diff --git a/components/tree-node/index.js b/components/tree-node/index.js new file mode 100644 index 0000000..997c347 --- /dev/null +++ b/components/tree-node/index.js @@ -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 + } + } +}) \ No newline at end of file diff --git a/components/tree-node/index.json b/components/tree-node/index.json new file mode 100644 index 0000000..ec68c39 --- /dev/null +++ b/components/tree-node/index.json @@ -0,0 +1,6 @@ +{ + "component": true, + "usingComponents": { + "tree-node": "./index" + } +} \ No newline at end of file diff --git a/components/tree-node/index.wxml b/components/tree-node/index.wxml new file mode 100644 index 0000000..5bab006 --- /dev/null +++ b/components/tree-node/index.wxml @@ -0,0 +1,20 @@ + + + + + + + + + + + + {{item[pros.key]}} + + + + + + + 暂无数据 + diff --git a/components/tree-node/index.wxss b/components/tree-node/index.wxss new file mode 100644 index 0000000..577410d --- /dev/null +++ b/components/tree-node/index.wxss @@ -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; +} \ No newline at end of file diff --git a/pages/statistic/j-b-x-x/index/index.js b/pages/statistic/j-b-x-x/index/index.js index 1d964d4..b72964c 100644 --- a/pages/statistic/j-b-x-x/index/index.js +++ b/pages/statistic/j-b-x-x/index/index.js @@ -24,6 +24,15 @@ Page({ }, typeId:'', + //树结构 + areaCode:'', + areaPathName:'', + unitTreepros: { + key: 'orgname', + val: 'orgcode' + }, + unitTreelist: [], + // 地区数据 areamultiIndex: [0, 0, 0], @@ -61,6 +70,20 @@ Page({ this.data.typeId = 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) { console.log(res,'res===>'); this.data.TypeData = res.data[0].children; + this.data.unitTreelist = res.data; this.setData(this.data) } }) @@ -165,7 +189,6 @@ Page({ // endTime:this.data.endTime, // startTime:this.data.startTime, typeId:id, - typeId:'', // userId:this.data.userInfo.userId, condition:this.data.search, }; @@ -176,9 +199,10 @@ Page({ console.log(params,'params==>'); app.axios("GET", "app", `/people/peopleInfoByType`, params).then(res => { if (res.code == 1) { - this.data.freshIng = false; - this.data.list = [...this.data.list,...res.data.list]; - this.setData(this.data); + this.setData({ + list:[...this.data.list,...res.data.list], + freshIng:false, + }); } }) }, diff --git a/pages/statistic/j-b-x-x/index/index.json b/pages/statistic/j-b-x-x/index/index.json index ea853c4..02e59f1 100644 --- a/pages/statistic/j-b-x-x/index/index.json +++ b/pages/statistic/j-b-x-x/index/index.json @@ -1,5 +1,6 @@ { "usingComponents": { + "tree-node":"/components/tree-node/index" }, "navigationStyle": "custom" } \ No newline at end of file diff --git a/pages/statistic/j-b-x-x/index/index.wxml b/pages/statistic/j-b-x-x/index/index.wxml index 116d610..db85261 100644 --- a/pages/statistic/j-b-x-x/index/index.wxml +++ b/pages/statistic/j-b-x-x/index/index.wxml @@ -32,7 +32,8 @@ 所属社区 - {{TypeData[postData.type-1].orgname}} + {{ postData.areaPathName }} + + + \ No newline at end of file diff --git a/pages/the-masses/escalation/index.js b/pages/the-masses/escalation/index.js index f29fdbf..512b310 100644 --- a/pages/the-masses/escalation/index.js +++ b/pages/the-masses/escalation/index.js @@ -9,7 +9,10 @@ Page({ data: { topBarH: app.globalData.CustomBar, postData: {}, - userInfo:{} + userInfo:{}, + uuid:'', + files:[], + baseUrl:app.FILE_SERVER_URL, }, /** * 输入内容 @@ -31,7 +34,7 @@ Page({ }; let params= { ...this.data.postData, - difficultyId:this.data.postData.difficultyId||'', + difficultyId:this.data.postData.difficultyId||this.data.uuid, userId:this.data.userInfo.userId, }; app.axios("POST", "app", "/difficultyAppeal/addDifficulty", params).then(res => { @@ -106,8 +109,81 @@ Page({ getDetail:function (id) { app.axios("GET", "app", `/difficultyAppeal/difficultyDetail/${id}`).then(res => { this.data.postData = res.data; + this.getFiles(); 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.data.isUserDetail = options.user; - // this.data.uuid = Utils.uuid(); // this.setData(this.data) + this.data.uuid = Utils.uuid(); this.data.userInfo = app.globalData.userInfo; this.setData(this.data); }, diff --git a/pages/the-masses/escalation/index.wxml b/pages/the-masses/escalation/index.wxml index cc427f0..da70502 100644 --- a/pages/the-masses/escalation/index.wxml +++ b/pages/the-masses/escalation/index.wxml @@ -6,8 +6,32 @@ 困难诉求 - + + + + 状态 + + + + + + + + + + + + 附件 + 添加图片 + + + + + + + + diff --git a/pages/the-masses/escalation/index.wxss b/pages/the-masses/escalation/index.wxss index aba9fab..af0edeb 100644 --- a/pages/the-masses/escalation/index.wxss +++ b/pages/the-masses/escalation/index.wxss @@ -119,4 +119,33 @@ scroll-view { .option_div view:nth-child(2){ margin-left: 20rpx; 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; } \ No newline at end of file diff --git a/project.private.config.json b/project.private.config.json index bae8d40..f0c4f0b 100644 --- a/project.private.config.json +++ b/project.private.config.json @@ -1,6 +1,6 @@ { "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", - "projectname": "daofu-applet-gov", + "projectname": "daofu-applet", "setting": { "compileHotReLoad": true, "urlCheck": false