فهرست منبع

Merge branch 'master' of http://192.168.1.41:3000/outaozhen/cldV2react

outaozhen 5 سال پیش
والد
کامیت
9c221f9e59

+ 6 - 6
config/config.js

@@ -115,11 +115,11 @@ export default defineConfig({
       )
     }
     //过滤掉momnet的那些不使用的国际化文件
-    config
-      .plugin('replace')
-      .use(require('webpack').ContextReplacementPlugin)
-      .tap(() => {
-        return [/moment[/\\]locale$/, /zh-cn/]
-      })
+    // config
+    //   .plugin('replace')
+    //   .use(require('webpack').ContextReplacementPlugin)
+    //   .tap(() => {
+    //     return [/moment[/\\]locale$/, /zh-cn/]
+    //   })
   }
 })

+ 19 - 6
src/app.tsx

@@ -1,11 +1,24 @@
-import { apiGetRoles } from './services/user'
+import { apiGetRoles, getDataPerm } from './services/user'
+import { setAuthCache } from './utils/auth'
 import { setAuthority } from './utils/auth/authority'
+import { PERM_LIST_KEY } from './utils/cache/cacheEnum'
 
-export function render(oldRender) {
-  if (window.location.pathname !== '/user/login') {
-    apiGetRoles().then(value => {
-      setAuthority(value?.data || [])
-    })
+const PermDataList = [
+  {
+    key: '/customer',
+    value: 2
+  }
+]
+export async function render(oldRender) {
+  const path = window.location.pathname
+  if (path !== '/user/login') {
+    const { data = [] } = await apiGetRoles()
+    const permVal = PermDataList.find(item => path.startsWith(item.key))?.value
+    if (permVal) {
+      const prem = await getDataPerm()
+      setAuthCache(PERM_LIST_KEY, prem?.data || [])
+    }
+    setAuthority(data)
   }
   oldRender()
 }

+ 2 - 2
src/global.less

@@ -101,6 +101,6 @@ input:-webkit-autofill:active {
   -webkit-transition-delay: 111111s;
 }
 
-.card-group {
-  box-shadow: 0 0 13px 0 rgba(74, 53, 107, 8%);
+.ant-picker {
+  width: 100%;
 }

+ 28 - 25
src/pages/Customer/Company/components/PersonLabel/index.jsx

@@ -1,7 +1,7 @@
 import { Button, Checkbox, Popover, Input, message, Spin } from 'antd'
 import React, { useState, useRef, useEffect, useMemo } from 'react'
 import { connect } from 'dva'
-import styles from './index.scss'
+import styles from './index.less'
 import { apiConnOrDelTag, apiUpdateTag } from '@/services/customer'
 import consts from '@/basic/consts'
 import {
@@ -192,30 +192,33 @@ const DropDownMenu = props => {
   return (
     <ul className={styles.labelContent}>
       {menuType === DropdownTypeEnum.check
-        ? tags.map((item, idx) => (
-            <li
-              key={item.id}
-              className={[styles.menuItem, checkedIds.includes(item.id) && styles.select].join(
-                ' '
-              )}>
-              <div className={styles.labelText}>
-                <div
-                  className={[
-                    styles.statusIcon,
-                    tagType === TagTypeEnum.PERSONTAG ? styles.suqare : ''
-                  ].join(' ')}
-                  style={{ backgroundColor: LabelStatusColorMap[tagType][idx] }}
-                />
-                <span>{item.name}</span>
-              </div>
-              <div className={styles.checkSpan}>
-                <Checkbox
-                  checked={checkedIds.includes(item.id)}
-                  onChange={e => handleOnchange(e, item.id)}
-                />
-              </div>
-            </li>
-          ))
+        ? tags.map((item, idx) => {
+            console.log('LabelStatusColorMap', LabelStatusColorMap[tagType][idx])
+            return (
+              <li
+                key={item.id}
+                className={[styles.menuItem, checkedIds.includes(item.id) && styles.select].join(
+                  ' '
+                )}>
+                <div className={styles.labelText}>
+                  <div
+                    className={[
+                      styles.statusIcon,
+                      tagType === TagTypeEnum.PERSONTAG ? styles.suqare : ''
+                    ].join(' ')}
+                    style={{ backgroundColor: LabelStatusColorMap[tagType][idx] }}
+                  />
+                  <span>{item.name}</span>
+                </div>
+                <div className={styles.checkSpan}>
+                  <Checkbox
+                    checked={checkedIds.includes(item.id)}
+                    onChange={e => handleOnchange(e, item.id)}
+                  />
+                </div>
+              </li>
+            )
+          })
         : null}
       {menuType === DropdownTypeEnum.edit
         ? tags.map((item, idx) => (

+ 2 - 3
src/pages/Customer/Company/components/PersonLabel/index.scss

@@ -18,7 +18,7 @@
   .menuItemWithBorder {
     margin-bottom: 0.25rem;
     border: 1px solid #e5e5e5;
-    box-shadow: 0 0.2rem 0.325rem rgba(0,0,0,0.04);
+    box-shadow: 0 0.2rem 0.325rem rgba(0, 0, 0, 0.04);
     &:last-of-type {
       margin: 0;
     }
@@ -37,8 +37,7 @@
     &:hover {
       background-color: #f5f5f5;
     }
-    &
-    .labelText {
+    & .labelText {
       display: flex;
       align-items: center;
       width: 80%;

+ 24 - 7
src/pages/Customer/Company/index.jsx

@@ -1,7 +1,7 @@
 import React, { useState, useEffect, useRef, useMemo } from 'react'
 import ProTable from '@ant-design/pro-table'
 import { useTableScroll } from '@/hooks/useAutoTable'
-import { Button, message, Tooltip } from 'antd'
+import { Input, Button, message, Select, Space, Tooltip } from 'antd'
 import { connect } from 'dva'
 import consts from '@/consts'
 import { queryCompany, apiAddCompany } from '@/services/customer'
@@ -14,6 +14,7 @@ import PersonLabel from './components/PersonLabel'
 import { TagTypeEnum, TagDataTypeEnum, LabelModeType } from './components/PersonLabel/const'
 import { Add, Down, Check } from '@icon-park/react'
 import { apiBatchLink } from '@/services/customer'
+import { getPermDataList } from '@/utils/auth'
 
 const Company = props => {
   const {
@@ -439,15 +440,17 @@ const Company = props => {
           total
         }
       }}
-      headerTitle="客户"
       bordered
       search={{ filterType: 'light' }}
       toolbar={{
-        search: {
-          allowClear: true,
-          onSearch: handleSearch,
-          placeholder: '输入客户名称、公司性质等'
-        },
+        search: (
+          <Input.Search
+            style={{ width: '300px' }}
+            allowClear={true}
+            placeholder="输入客户名称、公司性质等"
+            onSearch={handleSearch}
+          />
+        ),
         actions: [
           <LazyCascader
             onChange={onDistrictChange}
@@ -459,6 +462,20 @@ const Company = props => {
           <AddCompany onConfirm={handleAddCompany} key="addCompanyBtn" />
         ]
       }}
+      headerTitle={
+        <Space>
+          <span className="text-lg font-medium">客户</span>
+          <Select
+            defaultValue="oneself"
+            dropdownMatchSelectWidth={false}
+            bordered={false}
+            onChange={e => {
+              setState({ ...state, params: { ...state.params, dataPermission: e } })
+            }}
+            options={getPermDataList()?.customer || []}
+          />
+        </Space>
+      }
       rowSelection={{
         onChange: hanleRowSelectChange,
         type: 'checkbox',

+ 32 - 10
src/pages/Customer/Contact/index.jsx

@@ -1,8 +1,8 @@
 import ContactDetail from '@/pages/customer/Contact/components/ContactDetail'
 import CompanyDetail from '@/pages/customer/Company/components/CompanyDetail'
-import Addcontact from '@/pages/customer/Contact/components/AddContact'
+import AddContact from '@/pages/customer/Contact/components/AddContact'
 import ProTable from '@ant-design/pro-table'
-import { Button, message, Tooltip } from 'antd'
+import { Input, Button, message, Tooltip, Space, Select } from 'antd'
 import { connect } from 'dva'
 import React, { useEffect, useState, useRef, useMemo } from 'react'
 import consts from '@/consts'
@@ -20,6 +20,7 @@ import { useTableScroll } from '@/hooks/useAutoTable'
 import { apiAddClient, queryContact } from '@/services/customer'
 import { apiBatchLink } from '@/services/customer'
 import styles from './index.less'
+import { getPermDataList } from '@/utils/auth'
 
 const Contact = props => {
   const { toggleDrawer, setDrawerProps } = useModal()
@@ -87,7 +88,7 @@ const Contact = props => {
   }
 
   const [state, setState] = useState({
-    params: {},
+    params: { dataPermission: 'oneself' },
     id: '',
     orderIds: []
   })
@@ -568,11 +569,19 @@ const Contact = props => {
         // search={false}
         search={{ filterType: 'light' }}
         toolbar={{
-          search: {
-            allowClear: true,
-            onSearch: handleSearch,
-            placeholder: '输入联系人、客户名称、电话邮箱等'
-          },
+          search: (
+            <Input.Search
+              style={{ width: '300px' }}
+              allowClear={true}
+              placeholder="输入联系人、客户名称、电话邮箱等"
+              onSearch={handleSearch}
+            />
+          ),
+          // search: {
+          //   allowClear: true,
+          //   onSearch: handleSearch,
+          //   placeholder: '输入联系人、客户名称、电话邮箱等'
+          // },
           actions: [
             <LazyCascader
               key="lazyCascader"
@@ -581,16 +590,29 @@ const Contact = props => {
               bordered={false}
               className="hover:bg-[rgba(0,0,0,0.1)]"
             />,
-            <Addcontact onConfirm={handleAddClient} key="addContactBtn" />
+            <AddContact onConfirm={handleAddClient} key="addContactBtn" />
           ]
         }}
+        headerTitle={
+          <Space>
+            <span className="text-lg font-medium">联系人</span>
+            <Select
+              defaultValue="oneself"
+              dropdownMatchSelectWidth={false}
+              bordered={false}
+              onChange={e => {
+                setState({ ...state, params: { ...state.params, dataPermission: e } })
+              }}
+              options={getPermDataList()?.customer || []}
+            />
+          </Space>
+        }
         onLoadingChange={loadingStatus => {
           loadingStatus && redoHeight()
         }}
         scroll={getScrollRef}
         columnsStateMap={columnsStateMap}
         onColumnsStateChange={map => setColumnsStateMap(map)}
-        headerTitle="联系人"
       />
     </div>
   )

+ 7 - 0
src/services/user.js

@@ -15,3 +15,10 @@ export async function apiCurrent() {
 export async function apiGetRoles() {
   return request.get('/login/roles')
 }
+
+/** 获取数据权限下拉菜单 */
+export async function getDataPerm(params) {
+  return request.get('/DataPermission/list', {
+    params
+  })
+}

+ 5 - 1
src/utils/auth/index.ts

@@ -2,7 +2,7 @@
 
 import { Persistent, BasicKeys } from '@/utils/cache/persistent'
 import projectSetting from '@/settings/projectSetting'
-import { TOKEN_KEY, CacheTypeEnum } from '@/utils/cache/cacheEnum'
+import { TOKEN_KEY, CacheTypeEnum, PERM_LIST_KEY } from '@/utils/cache/cacheEnum'
 
 const { permissionCacheType } = projectSetting
 const isLocal = permissionCacheType === CacheTypeEnum.LOCAL
@@ -11,6 +11,10 @@ export function getToken() {
   return getAuthCache(TOKEN_KEY)
 }
 
+export function getPermDataList() {
+  return getAuthCache(PERM_LIST_KEY)
+}
+
 export function getAuthCache<T>(key: BasicKeys) {
   const fn = isLocal ? Persistent.getLocal : Persistent.getSession
   return fn(key) as T

+ 2 - 0
src/utils/cache/cacheEnum.ts

@@ -5,6 +5,8 @@ export const TOKEN_KEY = 'TOKEN__'
 // role role key
 export const ROLES_KEY = 'ROLES__KEY__'
 
+export const PERM_LIST_KEY = 'PERM_LIST_KEY'
+
 // base global local key
 export const APP_LOCAL_CACHE_KEY = 'COMMON__LOCAL__KEY__'