From 1a1441ac952022bd9160cf81a02fb569a85f0235 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=8E=E6=B0=B8=E9=A1=BA?= <971387674@qq.com> Date: Tue, 8 Nov 2022 15:56:34 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A0=8F=E7=9B=AE=E6=9D=83=E9=99=90=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E7=9A=84=E7=BC=96=E5=86=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pc4mobx/organization/apis/columnPermission.js | 6 + .../components/permissionItem.js | 168 ++++++++++-------- .../components/columnPermission/index.js | 15 +- .../organization/stores/columnPermission.js | 152 ++++++++-------- 4 files changed, 190 insertions(+), 151 deletions(-) diff --git a/pc4mobx/organization/apis/columnPermission.js b/pc4mobx/organization/apis/columnPermission.js index 9d00988..ed88720 100644 --- a/pc4mobx/organization/apis/columnPermission.js +++ b/pc4mobx/organization/apis/columnPermission.js @@ -6,3 +6,9 @@ export const getTableEdit = (params) => { export const userDefineCardItemSave = (params) => { return WeaTools.callApi('/api/hrm/carddisplay/saveCustomCard', 'POST', params); } +export const hasRight = (params) => { + return WeaTools.callApi('/api/bs/hrmorganization/cardAccess/hasRight', 'POST', params); +} +export const getTable = (params) => { + return WeaTools.callApi('/api/bs/hrmorganization/cardAccess/getTable', 'POST', params); +} diff --git a/pc4mobx/organization/components/columnPermission/components/permissionItem.js b/pc4mobx/organization/components/columnPermission/components/permissionItem.js index 44dc123..7bc51e4 100644 --- a/pc4mobx/organization/components/columnPermission/components/permissionItem.js +++ b/pc4mobx/organization/components/columnPermission/components/permissionItem.js @@ -1,87 +1,103 @@ import React, { Component } from "react"; +import { toJS } from 'mobx'; +import { inject, observer } from "mobx-react"; import { WeaTableEdit } from "ecCom"; +@inject("columnPermission") +@observer class PermissionItem extends Component { + componentDidMount() { + this.init(); + } + + init = () => { + const { columnPermission } = this.props; + columnPermission.loadTabOneRelatedData(); + }; + render() { - const columns = [ - { - title: "栏目", - dataIndex: "column", - key: "column", - com: [ - { label: "", type: "TEXT", viewAttr: 1, key: "column" } - ] - }, - { - title: "是否启用", - dataIndex: "isused", - key: "isused", - com: [ - { - type: "CHECKBOX", - key: "isused", - viewAttr: 1 - } - ] - }, - { - title: "所有人可见", - dataIndex: "all", - key: "all", - com: [ - { - type: "CHECKBOX", - key: "all" - } - ] - }, - { - title: "上级可见", - dataIndex: "highVisible", - key: "highVisible", - com: [ - { - type: "CHECKBOX", - key: "highVisible" - } - ] - }, - { - title: "所有上级可见", - dataIndex: "allVisible", - key: "allVisible", - com: [ - { - type: "CHECKBOX", - key: "allVisible" - } - ] - }, - { - title: "查看自定义", - dataIndex: "customRole", - key: "customRole", - com: [ - { label: "", type: "TEXT", viewAttr: 1, key: "customRole" } - ] - } - ]; - const datas = [ - { - id: "1", - column: "基本信息", - isused: false, - all: false, - highVisible: true, - allVisible: false, - customRole: "角色1" - } - ]; + const { columnPermission } = this.props, { tabOneRelatedData } = columnPermission; + const { datas, columns } = tabOneRelatedData; + // const columns = [ + // { + // title: "栏目", + // dataIndex: "column", + // key: "column", + // com: [ + // { label: "", type: "TEXT", viewAttr: 1, key: "column" } + // ] + // }, + // { + // title: "是否启用", + // dataIndex: "isused", + // key: "isused", + // com: [ + // { + // type: "CHECKBOX", + // key: "isused", + // viewAttr: 1 + // } + // ] + // }, + // { + // title: "所有人可见", + // dataIndex: "all", + // key: "all", + // com: [ + // { + // type: "CHECKBOX", + // key: "all" + // } + // ] + // }, + // { + // title: "上级可见", + // dataIndex: "highVisible", + // key: "highVisible", + // com: [ + // { + // type: "CHECKBOX", + // key: "highVisible" + // } + // ] + // }, + // { + // title: "所有上级可见", + // dataIndex: "allVisible", + // key: "allVisible", + // com: [ + // { + // type: "CHECKBOX", + // key: "allVisible" + // } + // ] + // }, + // { + // title: "查看自定义", + // dataIndex: "customRole", + // key: "customRole", + // com: [ + // { label: "", type: "TEXT", viewAttr: 1, key: "customRole" } + // ] + // } + // ]; + // const datas = [ + // { + // id: "1", + // column: "基本信息", + // isused: false, + // all: false, + // highVisible: true, + // allVisible: false, + // customRole: "角色1" + // } + // ]; return (
{ + const { columnPermission } = this.props; + columnPermission.getRight(); + }; + getTopMenuBtns = () => { return [ @@ -40,7 +50,10 @@ class ColumnPermission extends Component { render() { const { columnPermission } = this.props; - const { selectedKey } = columnPermission; + const { selectedKey, authorized } = columnPermission; + // if (!authorized) { + // return renderNoright(); + // } return (
{ - (item.isTop == '1' || item.isBatch == '1') && topMenu.push(item); + (item.isTop == "1" || item.isBatch == "1") && topMenu.push(item); !item.isBatch && rightMenu.push(item); }); return { topMenu, rightMenu - } + }; } @computed get checkedItems() { @@ -63,13 +65,13 @@ export class ColumnPermission { f.children.map(s => { if (s.value) { fArr.push( - s.id, - ) + s.id + ); s.children.map(t => { t.value && fArr.push( t.id - ) - }) + ); + }); } }); arr.push(fArr.toString()); @@ -90,21 +92,13 @@ export class ColumnPermission { @action getRight() { - this.loading = true; - Api.getRight().then(res => { - let { - api_status, - btnMenu, - hasRight - } = res; - if (api_status) { - if (hasRight) { - this.setRight(true); - btnMenu !== undefined && this.setBtnMenu(btnMenu); - } - this.loading = false; + Api.hasRight().then(res => { + let { code, data, msg } = res; + const { hasRight } = data; + if (code === 200) { + this.setRight(hasRight); } else { - message.error(res.message); + message.error(msg); } }).catch(error => { message.error(error); @@ -115,28 +109,34 @@ export class ColumnPermission { this.tabOneRelatedData.loading = true; Promise.all( [ - Api.getCardItemsData(), + Api.getTable() ] ).then(res => { - res.map((rs, index) => { - if (index == 0) { - let { - api_status, - data - } = rs; - - if (api_status) { - data !== undefined && extendObservable(this.tabOneRelatedData, { - data: data - }); - extendObservable(this.tabOneRelatedData, { - loading: false - }); - } else { - message.error(rs.message); - } - } + console.log('res', res); + extendObservable(this.tabOneRelatedData, { + datas: [], + columns: [], + loading: false }); + // res.map((rs, index) => { + // if (index == 0) { + // let { + // api_status, + // data + // } = rs; + // + // if (api_status) { + // data !== undefined && extendObservable(this.tabOneRelatedData, { + // data: data + // }); + // extendObservable(this.tabOneRelatedData, { + // loading: false + // }); + // } else { + // message.error(rs.message); + // } + // } + // }); }).catch(error => { message.error(error); }); @@ -146,7 +146,7 @@ export class ColumnPermission { this.tabTwoRelatedData.loading = true; Promise.all( [ - Api.getTableEdit(), + Api.getTableEdit() ] ).then(res => { res.map((rs, index) => { @@ -165,24 +165,28 @@ export class ColumnPermission { } this.tabTwoRelatedData.authorized = true; columns.map((c, index) => { - if (c.key === 'itemurl') { + if (c.key === "itemurl") { c.title = {c.title} - - + 即使不写占位符,默认也会收到1个固定的参数:hrmResourceID=人员id"/> - - } else if (c.key === 'itemnum') { + ; + } else if (c.key === "itemnum") { c.title = {c.title} - - + + - + ; } }); @@ -210,15 +214,15 @@ export class ColumnPermission { columnPermissionSave() { let params = { data: toJS(this.checkedItems) - } + }; Api.cardItemsSettingSave(params).then(res => { let { api_status, - sign, + sign } = res; if (api_status) { - if (sign == '1') { + if (sign == "1") { res.message && message.success(res.message); } else { res.message && message.warning(res.message); @@ -238,11 +242,11 @@ export class ColumnPermission { Api.userDefineCardItemSave(params).then(res => { let { api_status, - sign, + sign } = res; if (api_status) { - if (sign == '1') { + if (sign == "1") { res.message && message.success(res.message); } else { res.message && message.warning(res.message); @@ -261,14 +265,14 @@ export class ColumnPermission { const _rows = isEmpty(arr) ? [] : rows; _rows && _rows.map(index => { - arr[index].isused = '1'; + arr[index].isused = "1"; }); arr.map((item, index) => { - if (!item.isused) item.isused = '0'; + if (!item.isused) item.isused = "0"; for (let key in item) { - json[key + '_' + index] = item[key]; + json[key + "_" + index] = item[key]; } - }) + }); return json; } @@ -276,7 +280,7 @@ export class ColumnPermission { verify(arr) { for (let i = 0; i < arr.length; i++) { if (!arr[i].itemname || !arr[i].itemurl) { - const temp = i18n.message.requiredInfoIsNotFull().replace('{param}', i + 1); + const temp = i18n.message.requiredInfoIsNotFull().replace("{param}", i + 1); message.warning(temp); return false; } @@ -311,11 +315,11 @@ export class ColumnPermission { setTableEditDatas(e) { e.map(item => { for (let key in item) { - if (key == 'undefined') { + if (key == "undefined") { delete item[key]; } - if (!item['isused']) { - item['isused'] = ''; + if (!item["isused"]) { + item["isused"] = ""; } } }); @@ -325,7 +329,7 @@ export class ColumnPermission { } mobxDataReset() { - this.selectedKey = '0'; + this.selectedKey = "0"; extendObservable(this.tabOneRelatedData, { loading: true });