diff --git a/.gitignore b/.gitignore index f14792a..e4d0e60 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ .DS_Store node_modules/ dist/ +convenience-prod/ npm-debug.log* yarn-debug.log* yarn-error.log* diff --git a/src/api/convenience.js b/src/api/convenience.js index 87f1d40..da8a4b0 100644 --- a/src/api/convenience.js +++ b/src/api/convenience.js @@ -2,7 +2,7 @@ import request from '@/utils/request' /** * 工单列表 - * @param {YW_Content_Code,YW_Type_Code} data + * @param {Object}} data * @returns */ export function list(data) { @@ -26,7 +26,7 @@ export function typeList() { /** * 发起办事 - * @param {residentInformation,eventTypeId,sponsor,remark,Attachment} data + * @param {Object} data * @returns */ export function add(data) { @@ -39,7 +39,7 @@ export function add(data) { /** * 工单详情 - * @param {工单id} id + * @param {String} id * @returns */ export function info(id) { @@ -52,7 +52,7 @@ export function info(id) { /** * 工单操作 - * @param {id,version,type,ids,remark,attachmentList,approve,evaluation} data + * @param {Object} data * @returns */ export function update(data) { @@ -65,7 +65,7 @@ export function update(data) { /** * 获取沟通人员列表 - * @param {id} data + * @param {String} data * @returns */ export function communicationList(data) { diff --git a/src/api/region.js b/src/api/region.js index d66e186..a7b988a 100644 --- a/src/api/region.js +++ b/src/api/region.js @@ -1,13 +1,14 @@ import request from "@/utils/request"; /** - * 行政区域 + * 行政区域列表 * @param {*} data * @returns */ export function getRegions() { return request({ - url: "/api/convenience/residentInformation/region/list", + // /api/convenience/v2/region/list + url: "/api/convenience/v2/region/list", method: "get" }); } diff --git a/src/api/residentInformation.js b/src/api/residentInformation.js index ad4a074..dcd5fe4 100644 --- a/src/api/residentInformation.js +++ b/src/api/residentInformation.js @@ -38,4 +38,17 @@ export function updateResidentInfo(data) { data }); } + +/** + * 居民信息删除 + * @param {*} id + * @returns + */ +export function deleteResident(id) { + return request({ + url: "/api/convenience/residentInformation", + method: "delete", + params:id + }); +} \ No newline at end of file diff --git a/src/api/staff.js b/src/api/staff.js index 011c87a..942cf8b 100644 --- a/src/api/staff.js +++ b/src/api/staff.js @@ -1,4 +1,4 @@ -import request from '@/utils/request' +import request from "@/utils/request"; /** * 通讯录 @@ -6,10 +6,18 @@ import request from '@/utils/request' */ export function staffList() { return request({ - url: '/api/convenience/v2/staff/list', - method: 'post' - }) + url: "/api/convenience/v2/staff/list", + method: "post", + data: { category: "CONVENIENCE" } + }); } +// export function staffList(data) { +// return request({ +// url: '/api/convenience/v2/staff/list', +// method: 'post', +// data +// }) +// } /** * 个人信息详情 @@ -18,8 +26,8 @@ export function staffList() { */ export function info(data) { return request({ - url: '/api/convenience/v2/staff/info', - method: 'get', + url: "/api/convenience/v2/staff/info", + method: "get", params: data - }) + }); } diff --git a/src/main.js b/src/main.js index 68152c1..0c14220 100644 --- a/src/main.js +++ b/src/main.js @@ -22,6 +22,8 @@ import './icons' // icon import './permission' // permission control import './utils/error-log' // error log +import has from './utils/permissionFilter.js' + import * as filters from './filters' // global filters /** diff --git a/src/router/index.js b/src/router/index.js index eb60e4a..e8c7b76 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -92,7 +92,7 @@ export const constantRoutes = [ meta: { title: "工单管理", icon: "convenience", - roles: ["admin", "editor"] + // roles: ["admin", "editor"] }, children: [ { @@ -142,7 +142,7 @@ export const constantRoutes = [ meta: { title: "工作手册管理", icon: "list", - roles: ["admin", "editor"] + // roles: ["admin", "editor"] }, children: [ { @@ -158,30 +158,7 @@ export const constantRoutes = [ } ] }, - { - path: "/residentInformation", - component: Layout, - name: "ResidentInformation", - redirect: "/residentInformation/list", - meta: { - title: "居民信息管理", - icon: "jmInfo", - roles: ["ESIDENT_ADMIN"] - }, - children: [ - { - path: "list", - component: () => import("@/views/residentInformation/list"), - name: "residentInformationList", - meta: { - title: "居民信息列表", - icon: "jmInfo", - affix: true, - parentTitle: "居民信息管理" - } - } - ] - } + // { // path: "/staff", // component: Layout, @@ -246,6 +223,31 @@ export const constantRoutes = [ * the routes that need to be dynamically loaded based on user roles */ export const asyncRoutes = [ + { + path: "/residentInformation", + component: Layout, + name: "ResidentInformation", + redirect: "/residentInformation/list", + meta: { + title: "居民信息管理", + icon: "jmInfo", + roles: ["SSS"] + // roles: ["RESIDENT_ADMIN"] + }, + children: [ + { + path: "list", + component: () => import("@/views/residentInformation/list"), + name: "residentInformationList", + meta: { + title: "居民信息列表", + icon: "jmInfo", + affix: true, + parentTitle: "居民信息管理" + } + } + ] + }, // { // path: '/permission', // component: Layout, diff --git a/src/store/getters.js b/src/store/getters.js index 8fcf5a5..1716593 100644 --- a/src/store/getters.js +++ b/src/store/getters.js @@ -7,6 +7,7 @@ const getters = { token: state => state.user.token, avatar: state => state.user.avatar, name: state => state.user.name, + regionIds: state=>state.user.regionIds, introduction: state => state.user.introduction, roles: state => state.user.roles, permission_routes: state => state.permission.routes, diff --git a/src/store/modules/permission.js b/src/store/modules/permission.js index aeb5ee5..13841cb 100644 --- a/src/store/modules/permission.js +++ b/src/store/modules/permission.js @@ -50,7 +50,7 @@ const actions = { generateRoutes({ commit }, roles) { return new Promise(resolve => { let accessedRoutes - if (roles.includes('admin')) { + if (roles.includes('RESIDENT_ADMIN')) { accessedRoutes = asyncRoutes || [] } else { accessedRoutes = filterAsyncRoutes(asyncRoutes, roles) diff --git a/src/store/modules/user.js b/src/store/modules/user.js index 993730b..5261257 100644 --- a/src/store/modules/user.js +++ b/src/store/modules/user.js @@ -1,56 +1,57 @@ -import { login, logout, getInfo } from '@/api/user' -import { getToken, setToken, removeToken } from '@/utils/auth' -import router, { resetRouter } from '@/router' +import { login, logout, getInfo } from "@/api/user"; +import { getToken, setToken, removeToken } from "@/utils/auth"; +import router, { resetRouter } from "@/router"; const state = { token: getToken(), - name: '', - avatar: '', - introduction: '', - roles: [] -} + name: "", + avatar: "", + introduction: "", + roles: [], + regionIds: "" +}; const mutations = { SET_TOKEN: (state, token) => { - state.token = token + state.token = token; }, SET_INTRODUCTION: (state, introduction) => { - state.introduction = introduction + state.introduction = introduction; }, SET_NAME: (state, name) => { - // console.log(name); - state.name = name + state.name = name; }, SET_AVATAR: (state, avatar) => { - state.avatar = avatar + state.avatar = avatar; }, SET_ROLES: (state, roles) => { - // console.log(roles); - state.roles = roles + state.roles = roles; + }, + SET_REGIONIDS: (state, regionIds) => { + state.regionIds = regionIds; } -} +}; const actions = { setToken({ commit }, token) { - commit('SET_TOKEN', token) - setToken(token) - // commit("SET_ROLES", ['admin']); + commit("SET_TOKEN", token); + setToken(token); }, // user login login({ commit }, userInfo) { - const { username, password } = userInfo + const { username, password } = userInfo; return new Promise((resolve, reject) => { login({ username: username.trim(), password: password }) .then(response => { - const { data } = response - commit('SET_TOKEN', data.token) - setToken(data.token) - resolve() + const { data } = response; + commit("SET_TOKEN", data.token); + setToken(data.token); + resolve(); }) .catch(error => { - reject(error) - }) - }) + reject(error); + }); + }); }, // get user info @@ -59,20 +60,22 @@ const actions = { getInfo({}) .then(res => { // console.log(); - let roles = res.d.isResidentsAdministrator; - roles.push('admin') - commit('SET_ROLES', roles) + let roles = res.d.isResidentsAdministrator || []; + roles.push("admin"); + commit("SET_ROLES", roles); // commit('SET_ROLES', ['admin']) // console.log(['admin',...res.isResidentsAdministrator]); - sessionStorage.setItem('id', res.d.id) - commit('SET_NAME', res.d.name) - commit('SET_AVATAR', res.d.avatar) - resolve({ roles}) + sessionStorage.setItem("Permissions", JSON.stringify(roles)); + sessionStorage.setItem("id", res.d.id); + commit("SET_NAME", res.d.name); + commit("SET_AVATAR", res.d.avatar); + commit("SET_REGIONIDS",res.d.regionIds) + resolve({ roles }); }) .catch(error => { - reject(error) - }) - }) + reject(error); + }); + }); }, // user logout @@ -80,14 +83,14 @@ const actions = { // return new Promise((resolve, reject) => { // logout(state.token) // .then(() => { - commit('SET_TOKEN', '') - commit('SET_ROLES', []) - removeToken() - resetRouter() + commit("SET_TOKEN", ""); + commit("SET_ROLES", []); + removeToken(); + resetRouter(); // reset visited views and cached views // to fixed https://github.com/PanJiaChen/vue-element-admin/issues/2485 - dispatch('tagsView/delAllViews', null, { root: true }) + dispatch("tagsView/delAllViews", null, { root: true }); // resolve() // }) @@ -100,40 +103,40 @@ const actions = { // remove token resetToken({ commit }) { return new Promise(resolve => { - commit('SET_TOKEN', '') - console.log('resetToken') - commit('SET_ROLES', []) - removeToken() - resolve() - }) + commit("SET_TOKEN", ""); + console.log("resetToken"); + commit("SET_ROLES", []); + removeToken(); + resolve(); + }); }, // dynamically modify permissions async changeRoles({ commit, dispatch }, role) { - const token = role + '-token' + const token = role + "-token"; - commit('SET_TOKEN', token) - setToken(token) + commit("SET_TOKEN", token); + setToken(token); - const { roles } = await dispatch('getInfo') + const { roles } = await dispatch("getInfo"); - resetRouter() + resetRouter(); // generate accessible routes map based on roles - const accessRoutes = await dispatch('permission/generateRoutes', roles, { + const accessRoutes = await dispatch("permission/generateRoutes", roles, { root: true - }) + }); // dynamically add accessible routes - router.addRoutes(accessRoutes) + router.addRoutes(accessRoutes); // reset visited views and cached views - dispatch('tagsView/delAllViews', null, { root: true }) + dispatch("tagsView/delAllViews", null, { root: true }); } -} +}; export default { namespaced: true, state, mutations, actions -} +}; diff --git a/src/utils/permissionFilter.js b/src/utils/permissionFilter.js new file mode 100644 index 0000000..0e37e6b --- /dev/null +++ b/src/utils/permissionFilter.js @@ -0,0 +1,30 @@ +import Vue from "vue"; + +/** 权限指令**/ +const has = Vue.directive("has", { + // bind:只调用一次,指令第一次绑定到元素时调用。在这里可以进行一次性的初始化设置。 + // inserted:被绑定元素插入父节点时调用 + // (仅保证父节点存在,但不一定已被插入文档中)。 + // update:所在组件的 VNode 更新时调用,但是可能发生在其子 VNode + // 更新之前。指令的值可能发生了改变,也可能没有。但是你可以通过比较更新前后的值来忽略不必要的模板更新。 + inserted: function(el, binding, vnode) { + // 获取按钮权限 + if (!Vue.prototype.$_has(binding.value)) { + console.log(el); + el.parentNode.removeChild(el); + } + } +}); +// 权限检查方法 +Vue.prototype.$_has = function(value) { + let isExist = false; + const btnPermissionsStr = sessionStorage.getItem("Permissions"); + if (btnPermissionsStr === undefined || btnPermissionsStr === null) { + return false; + } + if (btnPermissionsStr.indexOf(value) > -1) { + isExist = true; + } + return isExist; +}; +export { has }; diff --git a/src/views/convenience/add.vue b/src/views/convenience/add.vue index b5b0729..b5914fa 100644 --- a/src/views/convenience/add.vue +++ b/src/views/convenience/add.vue @@ -12,7 +12,7 @@ diff --git a/src/views/convenience/detail.vue b/src/views/convenience/detail.vue index 05ffc32..5b62ecf 100644 --- a/src/views/convenience/detail.vue +++ b/src/views/convenience/detail.vue @@ -677,10 +677,24 @@ >
+ + + 取消 提交 + @@ -774,6 +794,8 @@ import { import { parseTime } from "@/utils"; import { staffList } from "@/api/staff"; import AliOss from "@/components/AliOSS/index.vue"; +// import { getRegions } from "@/api/region"; +// import { mapGetters } from "vuex"; export default { filters: { @@ -832,6 +854,9 @@ export default { return statusMap[status]; } }, + // computed: { + // ...mapGetters(["regionIds"]) + // }, components: { AliOss }, @@ -902,8 +927,14 @@ export default { cxPop: false, audioSources: [ "http://storage.myntv.cn/files20210415_142012.m4a" - // 'https://img.tukuppt.com/newpreview_music/08/99/49/5c897788e421b53181.mp3' - ] + ], + regionSearchVal: undefined, + regions: [], + staffQuery: { + regionIds: "", + isAll: false, + category: "CONVENIENCE" + } }; }, created() { @@ -911,6 +942,7 @@ export default { this.getStaffList(); this.getCommunicationList(); this.getTypeList(); + // this.getRegionList(); }, methods: { getInfo() { @@ -1065,7 +1097,18 @@ export default { }); }, getStaffList() { - staffList().then(res => { + // let payload = Object.assign({}, this.staffQuery); + // let arr = payload.regionIds.split(","); + // arr.map((item, index) => { + // if (item === "false") { + // arr.splice(index, 1); + // } + // }); + // payload.regionIds = arr.join(","); + + // staffList(payload).then(res => { + // this.staffOptions = []; + staffList().then(res => { res.d.records.map(item => { const obj = { label: item.name, @@ -1166,6 +1209,24 @@ export default { // evaluation: undefined }, handleApprovalReminder() { + // this.regionSearchVal = []; + // this.getStaffList(); + // this.dialogApprovalReminder = true; + // const tempLen = this.regionIds.split(",").length; + // switch (tempLen) { + // case 1: + // this.regionSearchVal.push(this.regionIds, false); + // break; + // case 2: + // this.regionSearchVal.push(this.regionIds, false); + // break; + // case 3: + // this.regionSearchVal.push(this.regionIds); + // break; + // default: + // this.regionSearchVal = []; + // break; + // } this.dialogApprovalReminder = true; }, handleConfirmApprovalReminder() { @@ -1283,6 +1344,9 @@ export default { this.payload.ids.push(this.bzjr); break; } + // this.$refs.updateForm.validate(valid => { + // console.log(valid); + // }); update(this.payload).then(res => { if (res.c === 200) { this.$notify.success("操作成功"); @@ -1356,12 +1420,63 @@ export default { this.$nextTick(() => { const tempRef = this.$refs.eventTypeRef; - console.log(tempRef); if (tempRef) tempRef.toggleMenu(); // tempRef.$el.style.display = "inline-block"; // this.$refs.eventTypeRef.focusFirstNode(); }, 100); - } + }, + // getRegionList() { + // getRegions().then(res => { + // const tempData = res.d; + // const countyArr = []; // 县,1 + // tempData.map(county => { + // const countyObj = { + // value: county.root.id, + // label: county.root.name, + // disabled: !county.root.check, + // // children: [{value:true,label:'全县'},{value:false,label:'本县'}], + // children: [ + // { + // value: false, + // label: county.root.name, + // disabled: false + // // children: [] + // } + // ] + // }; + // countyArr.push(countyObj); + // county.node.map(town => { + // const townObj = { + // value: town.root.id, + // label: town.root.name, + // disabled: !town.root.check, + // // children: [{value:true,label:'全镇'},{value:false,label:'本镇'}], + // children: [ + // { + // value: false, + // label: town.root.name, + // disabled: false + // // children: [] + // } + // ] + // }; + // countyObj.children.push(townObj); + // town.node.map(country => { + // townObj.children.push({ + // value: country.root.id, + // label: country.root.name, + // disabled: !country.root.check + // }); + // }); + // }); + // }); + // this.regions = countyArr; + // }); + // }, + // handleRegionChange(val) { + // this.staffQuery.regionIds = val.join(","); + // this.getStaffList(); + // } }, beforeRouteLeave(to, from, next) { clearInterval(this.acceptanceInterval); diff --git a/src/views/login/index.vue b/src/views/login/index.vue index 9daa23e..5fd2b49 100644 --- a/src/views/login/index.vue +++ b/src/views/login/index.vue @@ -126,6 +126,8 @@ export default { // password: '111111' // }, loginForm: { + // username: "", //18882564006 + // captcha: "", username: "18882564006", //18882564006 captcha: "111111", appVersion: "1.0.0", diff --git a/src/views/residentInformation/list.vue b/src/views/residentInformation/list.vue index e031bcd..5628c9b 100644 --- a/src/views/residentInformation/list.vue +++ b/src/views/residentInformation/list.vue @@ -2,6 +2,8 @@
+ + 是否是便民工作人员 --> 是否是便民工作人员 @@ -70,28 +73,31 @@ >新增 - + + - + + - + + - + @@ -101,8 +107,9 @@ @@ -134,10 +148,9 @@ :close-on-click-modal="false" :title="textMap[dialogStatus]" :visible.sync="dialogAddVisible" - width="30%" + :close-on-press-escape="false" + width="60%" > - - - - - + + + + + - - - + + + - - - + + + - - - - 未知 - + + + + 未知 + - - - + + + - - - + + + - - - + + + + + + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - - - + + + - - - + + + - - - + + + + + + + +