Lou
2023-11-16 3a178cdd49413cbe2551ca0d4a11cf2629d082cb
编写逻辑获取权限菜单,网格巡查数据交互
10 files modified
1 files added
433 ■■■■■ changed files
api/patrol/patrol.js 11 ●●●●● patch | view | raw | blame | history
api/system/index.js 12 ●●●●● patch | view | raw | blame | history
common/setting.js 6 ●●●● patch | view | raw | blame | history
http/api.js 16 ●●●●● patch | view | raw | blame | history
mixin/uploadMixin.js 4 ●●●● patch | view | raw | blame | history
pages/home/index.vue 170 ●●●●● patch | view | raw | blame | history
store/index.js 38 ●●●●● patch | view | raw | blame | history
subPackage/label/index.vue 1 ●●●● patch | view | raw | blame | history
subPackage/task/index.vue 14 ●●●●● patch | view | raw | blame | history
subPackage/user/role/index.vue 43 ●●●● patch | view | raw | blame | history
subPackage/workbench/views/patrol.vue 118 ●●●●● patch | view | raw | blame | history
api/patrol/patrol.js
@@ -1,5 +1,15 @@
import http from '@/http/api.js'
// 添加巡查
export const addPartrol = (data) => {
    return http.request({
        url: '/blade-gridPatrolRecord/gridPatrolRecord/save',
        method: 'POST',
        data:data
    })
}
// 获取全部巡查类型
export const getAllPatrolType = () => {
    return http.request({
@@ -7,7 +17,6 @@
        method: 'GET'
    })
}
/**
 * 获取巡查任务列表
api/system/index.js
New file
@@ -0,0 +1,12 @@
import http from '@/http/api.js'
//获取轮播图
export const getBannerList = (params) => {
    return http.request({
        url: '/blade-rotation/rotation/page',
        method: 'GET',
        params: {
            ...params
        }
    })
}
common/setting.js
@@ -12,9 +12,9 @@
    // devUrl: 'https://sk.hubeishuiyi.cn',
    // devUrl: 'http://192.168.1.156:9528',
    // devUrl:'http://192.168.1.50:9528',
    devUrl: 'http://192.168.0.102:9528',
    // devUrl: 'https://srgdjczzxtpt.com:2080/api',
    minioBaseUrl: "http://60.220.177.113:9000/jczz/",
    // devUrl: 'http://192.168.0.102:9528',
    devUrl: 'https://srgdjczzxtpt.com:2080/api',
    minioBaseUrl: "https://srgdjczzxtpt.com:2080/gminio/jczz/",
    // 数据中台接口url
    // dataCenterUrl: 'http://10.10.2.192/services',
    dataCenterUrl: 'https://sk.hubeishuiyi.cn/services',
http/api.js
@@ -68,11 +68,12 @@
    return Promise.reject(config)
})
uni.showLoading({
    title:"加载中..."
})
// uni.showLoading({
//     title:"加载中..."
// })
http.interceptors.response.use((response) => {
    // 若有数据返回则通过
    if (response.data.access_token || response.data.key) {
        return response.data
@@ -120,7 +121,6 @@
        const currentPage = pages[pages.length - 1]
        uni.setStorageSync("responIndex", 0)
        uni.clearStorageSync()
        uni.redirectTo({
            url: `/pages/login/login-account?redirect=/${currentPage.route}`
        })
@@ -140,9 +140,11 @@
        //         }
        //     }
        // })
    }else {
        uni.showToast({
            title: '系统繁忙,请稍后再试',
            icon: 'none'
        });
    }
    return Promise.reject(response)
})
mixin/uploadMixin.js
@@ -1,5 +1,5 @@
import {
    devUrl,
    minioBaseUrl,
    clientId,
    clientSecret
} from '@/common/setting'
@@ -22,7 +22,7 @@
                maxCount: "5",
                previewFullImage: true,
                uploadText: "上传中",
                url: devUrl + "/blade-resource/oss/endpoint/put-file-attach",
                url: minioBaseUrl + "/blade-resource/oss/endpoint/put-file-attach",
                header: {},
            },
        }
pages/home/index.vue
@@ -14,7 +14,7 @@
            </view>
            <view class="" v-if="roleType != 1">
                <u-grid :border="false" :col="curSelectSite.addressType != 2?4:2">
                    <u-grid-item v-for="(i,k) in cellList" :key="k" @click.native="toPage(i)">
                    <!-- <u-grid-item v-for="(i,k) in cellList" :key="k" @click.native="toPage(i)">
                        <u-icon :name="i.icon" :size="45"></u-icon>
                        <text class="f-26 mt-20">{{i.text}}</text>
                    </u-grid-item>
@@ -26,7 +26,12 @@
                    <u-grid-item @click.native="navTo()" v-if="curSelectSite.addressType != 2">
                        <u-icon name="/static/icon/nav-04.png" width="90rpx" height="90rpx"></u-icon>
                        <text class="f-26 mt-20">租客上报</text>
                    </u-grid-item> -->
                    <u-grid-item @click.native="navTo()" v-for="(i,k) in liveList"   :key="k">
                        <u-icon :name="i.source" width="90rpx" height="90rpx"></u-icon>
                        <text class="f-26 mt-20">{{i.name}}</text>
                    </u-grid-item>
                </u-grid>
                <view class="section flex j-c-s-b mt-40">
@@ -67,7 +72,7 @@
                </view>
            </view>
            <view class="" v-if="hasMenu('楼盘表').length>0">
            <view class=""  v-if="hasMenu('楼盘表').length">
                <view class="caption">
                    <view class="flex a-i-c">
                        <view class="line"></view>
@@ -204,6 +209,10 @@
        getCountFrequencyNumber,
        getCountTypeNumber
    } from "@/api/task/task";
    import { getBannerList } from "@/api/system/index"
    import { uploadUrl } from "@/common/setting"
    export default {
        data() {
            return {
@@ -212,16 +221,17 @@
                    'http://220.176.210.217:9000/jczz/upload/20231111/cc093afc5e21639ef5b251eb865c24f4.png',
                    'http://220.176.210.217:9000/jczz/upload/20231111/cc093afc5e21639ef5b251eb865c24f4.png'
                ],
                cellList: [{
                cellList: [
                    {
                        icon: "/static/icon/nav-01.png",
                        text: "标签报事",
                        path: '/subPackage/label/index'
                    },
                    // {
                    //     icon: "/static/icon/nav-02.png",
                    //     text: "报事报修",
                    //     path: '/subPackage/bs/views/repair'
                    // },
                    {
                        icon: "/static/icon/nav-02.png",
                        text: "报事报修",
                        path: '/subPackage/bs/views/repair'
                    },
                    {
                        icon: "/static/icon/nav-03.png",
                        text: "便民热线",
@@ -356,15 +366,18 @@
                notice: [],
                frequencyNumber: {},
                typeNumber: {},
                selectSiteIndex: [0, 0]
                selectSiteIndex: [0, 0],
                liveList:[],   //生活菜单
                contactList:[]   //便民服务联系方式
            }
        },
        onLoad() {
            this.getBanner();
            this.init()
            uni.$on('refresh', () => {
                console.log("<====>")
                this.selectSiteIndex = [0, 0]
                this.init()
            })
@@ -372,9 +385,8 @@
        computed: {
            hasMenu() {
                return (name) => {
                    let resultArr = []
                    resultArr = this.getMenu(name, this.menuList, resultArr)
                    if (resultArr.length > 0) {
                    let resultArr = this.getMenu(name,this.menuList)
                    if (resultArr.length) {
                        return resultArr
                    } else {
                        return []
@@ -393,6 +405,18 @@
                },
                deep: true,
                immediate: true
            },
            'curSelectSite.addressType':{
                handler(newVal,oldVal){
                   if(newVal){
                       this.$store.dispatch("getMenuList").then(res=>{
                            this.getMenuList();
                       });
                   }
                },
                deep: true,
                immediate: true
            }
        },
@@ -401,16 +425,30 @@
            //初始化
            init() {
                this.curSelectSite = {}
                this.menuList = uni.getStorageSync("menu")
                this.selectRole = uni.getStorageSync("activeRole")
                console.log(uni.getStorageSync("activeRole"))
                this.getMenuList()
                this.getSiteList()
                this.getNoticeList()
                this.getFrequencyNumber()
                this.getTypeNumber()
            },
            getBanner(){
                getBannerList({
                    current:1,
                    size:5
                }).then(res=>{
                     let data = res.data.records;
                     if(data.length){
                         for(let i of data){
                             i.url = `${uploadUrl}${i.url}`
                         }
                         this.bannerList = data;
                     }
                })
            },
            async getFrequencyNumber() {
                const res = await getCountFrequencyNumber()
                this.frequencyNumber = res.data
@@ -518,72 +556,83 @@
                this.curHouseCode = e.value[0].id
                console.log("curSite=>", this.curSelectSite);
            },
            getMenu(menuName, menuList, resultArr) {
            getMenu(menuName) {
                // console.log(menuList, menuName)
                for (var i = 0; i < menuList.length; i++) {
                    if (menuList[i].name == menuName) {
                        resultArr.push(menuList[i])
                    } else {
                        if (menuList[i].children && menuList[i].children.length) {
                            this.getMenu(menuName, menuList[i].children, resultArr);
                        }
                // for (var i = 0; i < menuList.length; i++) {
                //     if (menuList[i].name == menuName) {
                //         resultArr.push(menuList[i])
                //     } else {
                //         if (menuList[i].children && menuList[i].children.length) {
                //             this.getMenu(menuName, menuList[i].children, resultArr);
                //         }
                //     }
                // }
                let list = [];
                for(let i of this.menuList){
                    if(i.name == menuName){
                        if(i.children && i.children.length){
                             list = i.children;
                            break;
                         }
                    }
                }
                return resultArr
                return list;
            },
            //获取首页菜单
            getMenuList() {
                console.log("当前角色菜单", this.menuList)
                this.getPhoneList()
                this.getLiveList()
                this.getWorkbenchList()
                // console.log("当前角色菜单", this.menuList)
                // this.getPhoneList()
                // this.getLiveList()
                this.menuList = uni.getStorageSync("menu")
                this.liveList = this.hasMenu('生活')
                this.contactList = this.hasMenu('快捷拨号');
                // this.jobList = this.hasMenu('工作台')
                // this.getWorkbenchList()
            },
            getPhoneList() {
                this.gridDataList = []
                const resultArr = this.hasMenu('快捷拨号')
                if (resultArr.length == 0) {
                    return
                const resultArr = this.hasMenu('快捷拨号');
                if (resultArr.length) {
                    this.contactList = resultArr;
                }
                const topMenu = resultArr[0]
                topMenu.children.forEach(menu => {
                    this.gridDataList.push({
                        title: menu.name,
                        data: "无数据",
                        phone: "无"
                    })
                })
                // const topMenu = resultArr[0]
                // topMenu.children.forEach(menu => {
                //     this.gridDataList.push({
                //         title: menu.name,
                //         data: "无数据",
                //         phone: "无"
                //     })
                // })
            },
            //获取生活菜单
            getLiveList() {
                this.liveList = []
                const resultArr = this.hasMenu('生活')
                if (resultArr.length == 0) {
                    return
                console.log(resultArr);
                if (resultArr.length) {
                    this.liveList = resultArr;
                }
                const topMenu = resultArr[0]
                topMenu.children.forEach(menu => {
                    this.liveList.push({
                        imgUrl: menu.source,
                        title: menu.name,
                    })
                })
                // const topMenu = resultArr[0];
                // console.log("topMenu====>",topMenu);
                // this.liveList = topMenu.children;
                // topMenu.children.forEach(menu => {
                //     this.liveList.push({
                //         imgUrl: menu.source,
                //         title: menu.name,
                //     })
                // })
            },
            //获取工作台菜单
            getWorkbenchList() {
                // this.jobList = []
                const resultArr = this.hasMenu('工作台')
                if (resultArr.length == 0) {
                    return
                }
                const topMenu = resultArr[0]
                const jobList = this.hasMenu('工作台')
                // const topMenu = resultArr[0]
                // topMenu.children.forEach(menu => {
                //     this.jobList.push({
                //         imgUrl: menu.source,
@@ -634,6 +683,7 @@
                }
            },
            //扫一扫
            scan() {
                const that = this
                uni.scanCode({
store/index.js
@@ -1,7 +1,9 @@
import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
import {
        dynamicMenu,
    } from "@/api/system/role.js"
let lifeData = {};
try {
@@ -53,7 +55,8 @@
        // tabbarIndex: uni.getStorageSync("tabbarIndex") || 0,
        hasUpdate: false, //true为不可登录,需要更新,false则是最新版
        menu: [],
        siteInfo:{}    //社区信息
        siteInfo:{}    ,//社区信息
        labelMenuList:[]      //标签报事菜单
    },
    mutations: {
@@ -120,8 +123,39 @@
        setSiteInfo(state,val){
            state.siteInfo = val;
            uni.setStorageSync('siteInfo', val)
        },
        //标签报事菜单
        setLabelReporMenutList(state,val){
            state.labelMenuList = val;
            uni.setStorageSync('labelMenuList',val);
        }
        
    },
    actions:{
        getMenuList({commit}){
            return new Promise((resolve,reject)=>{
                dynamicMenu(this.state.activeRole.id).then(res=>{
                    if(res.code == 200){
                        let data = res.data;
                        let menu = data.filter(e => e.name == 'app')[0].children;
                        commit("SET_MENU",menu);
                        let liveList = menu.filter(item=>item.name == '生活')
                        let labelList = [];
                        if(liveList.length && liveList[0].children){
                            for(let i of liveList[0].children){
                                if(i.name == "标签报事" && i.children.length){
                                    commit("setLabelReporMenutList",i.children)
                                    break;
                                }
                            }
                        }
                        resolve("success")
                    }else {
                        reject("fail")
                    }
                })
            })
        }
    }
})
subPackage/label/index.vue
@@ -105,6 +105,7 @@
        
        onLoad(){
            this.siteInfo = uni.getStorageSync("siteInfo");
            this.navList = uni.getStorageSync("labelMenuList");
        },
        
        onShow() {
subPackage/task/index.vue
@@ -91,6 +91,7 @@
</template>
<script>
    import { getCountFrequencyNumber } from "@/api/task/task.js"
    export default {
        data() {
            return {
@@ -99,7 +100,20 @@
                }]
            }
        },
        onLoad(){
            this.getCount();
        },
        methods:{
            getCount(){
                getCountFrequencyNumber().then(res=>{
                    console.log(res);
                })
            }
        }
    }
</script>
subPackage/user/role/index.vue
@@ -74,29 +74,28 @@
            },
            async submit() {
                const that = this
                //保存当前激活的角色
                store.commit("setActiveRole", this.selectRole)
                //获取角色菜单
                const res = await dynamicMenu(this.selectRole.id)
                //把菜单存入store中
                let data = res.data
                const appMenu = data.filter(e => e.name == 'app')[0].children
                console.log("菜单:", appMenu)
                store.commit("SET_MENU", appMenu)
                uni.showToast({
                    title: "切换身份成功",
                    icon: "success",
                    duration: data.duration || 1500,
                    success: () => {
                        uni.$emit("refresh")
                        setTimeout(() => {
                            this.$u.func.globalNavigator("/pages/home/index", "switchTab")
                        }, 1000)
                    }
                })
                this.$store.commit("setActiveRole", this.selectRole)
                // const res = await dynamicMenu(this.selectRole.id)
                // let data = res.data
                // const appMenu = data.filter(e => e.name == 'app')[0].children
                // console.log("菜单:", appMenu)
                // store.commit("SET_MENU", appMenu)
                this.$store.dispatch("getMenuList").then(res=>{
                    uni.showToast({
                        title: "切换身份成功",
                        icon: "success",
                        duration:1500,
                        success: () => {
                            uni.$emit("refresh")
                            setTimeout(() => {
                                this.$u.func.globalNavigator("/pages/home/index", "switchTab")
                            }, 1000)
                        }
                    })
                });
            }
        }
    }
subPackage/workbench/views/patrol.vue
@@ -1,30 +1,29 @@
<template>
    <view>
        <view class="content bgc-ff">
            <u-form labelPosition="left" :model="info" :rules="rules" ref="uForm" labelWidth="90"
            <u-form labelPosition="left" :model="info" :rules="rules" ref="form" labelWidth="90"
                :labelStyle="{fontSize:'28rpx'}">
                <u-form-item label="标题" prop="info.title" borderBottom ref="item1">
                    <u-input v-model="info.title" border="none" placeholder="请输入标题" placeholderClass="f-28 c-99"
                <u-form-item label="巡查标题" prop="info.name" borderBottom  required>
                    <u-input v-model="info.name" border="none" placeholder="请输入标题" placeholderClass="f-28 c-99"
                        inputAlign="right"></u-input>
                </u-form-item>
                <u-form-item label="内容" borderBottom ref="item1">
                    <u-input  type="textarea" v-model="info.address" border="none"  placeholderClass="f-28 c-99"
                <u-form-item label="巡查内容" borderBottom prop="context"  required>
                    <u-input type="textarea" v-model="info.context" border="none" placeholderClass="f-28 c-99"
                        inputAlign="right">
                    </u-input>
                </u-form-item>
                <u-form-item label="走访时间" prop="applyTime" borderBottom  required @click="showSelectDate = true">
                    <u-input v-model="info.applyTime" disabled disabledColor="#ffffff" border="none" placeholder="请输入"
                <u-form-item label="巡查时间" prop="patrolTime" borderBottom required  @click="showSelectDate = true">
                    <u-input v-model="info.patrolTime" disabled disabledColor="#ffffff" border="none" placeholder="请输入"
                        placeholderClass="f-28 c-99" inputAlign="right"></u-input>
                    <u-icon slot="right" name="arrow-right"></u-icon>
                </u-form-item>
            </u-form>
        </view>
        <view class="upload bgc-ff">
            <view class="f-28">走访图片</view>
            <view class="f-28">巡查图片</view>
            <view class="mt-20">
                <u-upload :fileList="images" :previewFullImage="uploadConfig.previewFullImage"
                <u-upload :fileList="form.images" :previewFullImage="uploadConfig.previewFullImage"
                    :accept="uploadConfig.acceptImg" :multiple="uploadConfig.multiple" :maxCount="uploadConfig.maxCount"
                    :capture="uploadConfig.capture" @afterRead="afterReadImg" @delete="deletePic">
                    <view class="upload-item upload-icon flex_base">
@@ -33,12 +32,12 @@
                </u-upload>
            </view>
        </view>
        <u-datetime-picker ref="datetimePicker" :show="showSelectDate" v-model="applyTime" mode="datetime"
            :formatter="formatter" @confirm="confirmDate"  @cancel="showSelectDate = false"></u-datetime-picker>
        <u-datetime-picker ref="datetimePicker" :show="showSelectDate" v-model="patrolTime" mode="datetime"
            :formatter="formatter" @confirm="confirmDate" @cancel="showSelectDate = false"></u-datetime-picker>
        <view class="footer">
            <button class="footer-btn">提交</button>
            <button class="footer-btn" @click="submitInfo">提交</button>
        </view>
    </view>
@@ -47,48 +46,84 @@
<script>
    import uploadMixin from "@/mixin/uploadMixin";
    import {
        addPartrol
    } from "@/api/patrol/patrol.js"
    export default {
        mixins: [uploadMixin],
        data() {
            return {
                form: {
                    images: []
                },
                info: {
                    title: "",
                    content: ""
                    name: "",
                    context: "",
                    patrolTime:""
                },
                rules: {
                    'title': {
                    'name': {
                        type: 'string',
                        required: true,
                        message: '请输入工作主题',
                        message: '请输入巡查标题',
                        trigger: ['blur', 'change']
                    },
                    'content': {
                    'context': {
                        type: 'string',
                        required: true,
                        message: '请输入工作内容',
                        message: '请输入巡查内容',
                        trigger: ['blur', 'change']
                    },
                    'patrolTime': {
                        type: 'string',
                        required: true,
                        message: '请选择巡查时间',
                        trigger: ['blur', 'change']
                    }
                },
                images: [
                ],
                showSelectDate:false
                showSelectDate: false,
                patrolTime: Number(new Date())
            }
        },
        methods:{
        methods: {
            confirmDate(e) {
                this.showSelectDate = false;
                this.info.applyTime = uni.$u.timeFormat(e.value, 'yyyy-mm-dd hh:MM:ss')
                this.info.patrolTime = uni.$u.timeFormat(e.value, 'yyyy-mm-dd hh:MM:ss')
            },
            getLocation(){
                uni.chooseLocation({
                    success:(res)=>{
                        console.log(res);
                    }
            checkImages() {
                if (this.form.images.length) {
                    this.$set(this.info, "url", this.setImages())
                }
            },
            setImages() {
                let urls = [];
                for (let i of this.form.images) {
                    urls.push(i.url);
                }
                return urls.join(",")
            },
            submitInfo() {
                this.$refs.form.validate().then(valid => {
                    this.checkImages();
                    addPartrol(this.info).then(res => {
                        uni.showToast({
                            icon: 'success',
                            title: '提交成功',
                            success() {
                                setTimeout(() => {
                                    uni.navigateBack()
                                }, 1000)
                            }
                        })
                    })
                })
            }
        }
@@ -104,23 +139,26 @@
        margin: 20rpx 30rpx;
        padding: 0 30rpx;
    }
    .row{
        padding:20rpx 0;
        border-bottom:1px solid
    .row {
        padding: 20rpx 0;
        border-bottom: 1px solid
    }
    .location-btn{
        width:116rpx;
        height:46rpx;
    .location-btn {
        width: 116rpx;
        height: 46rpx;
        line-height: 46rpx;
        border-radius: 4rpx;
        border:1px solid currentColor;
        padding:0;
        border: 1px solid currentColor;
        padding: 0;
        background-color: #fff;
    }
    .upload {
        margin: 0 30rpx;
        padding: 30rpx;
        .upload-item {
            width: 140rpx;
            height: 140rpx;