Explorar el Código

Merge branch 'dev' of http://192.168.1.41:3000/outaozhen/cldV2react into dev

outaozhen hace 4 años
padre
commit
d6611321b8

+ 1 - 1
src/components/ModalStore/index.tsx

@@ -38,7 +38,7 @@ const modalMap = {
   M_RATIO_PANELS: RatioPanels, // 仪表盘环比数据弹窗
   D_LOCK_DETAIL: LockDetail, // 锁库详情抽屉
   D_SOFTWARE_DETAIL: SoftwareDetail, // 软件锁详情抽屉
-  M_ADD_RECORD: AddRecord, // 添加服务记录
+  M_RECORD_ADD: AddRecord, // 添加服务记录
   M_OPREATE_LOCK: OpreateLock, // 操作锁库弹窗
   M_RECEIVE_LOCK: ReceiveLock, // 接受锁库弹窗
   M_CUSTOM_PERM: CustomPerm, // 自定义数据权限弹窗

+ 36 - 23
src/components/ModalStore/src/CreateProvider.tsx

@@ -28,6 +28,8 @@ export interface ModalStoreState {
   currentModal: ModalItem[]
 }
 
+const indent = 8
+
 const ModalStore: React.FC<ModalStoreProps> = props => {
   const dispatch = useDispatch()
   const [state, setState] = useState<ModalStoreState>({
@@ -80,8 +82,11 @@ const ModalStore: React.FC<ModalStoreProps> = props => {
   }
 
   function push(key: string, compState: any) {
+    console.log(key)
+
+    const isDrawer = key.startsWith('D')
     // eslint-disable-next-line no-param-reassign
-    key = compState?.dataId ? `${key}@${compState?.dataId}` : key
+    key = isDrawer && compState?.dataId ? `${key}@${compState?.dataId}` : key
     const { visiblePropName, onClosePropName, destroyOnClose } = getModalConfig(key)
 
     setModalState(prevModals => {
@@ -89,11 +94,7 @@ const ModalStore: React.FC<ModalStoreProps> = props => {
         [visiblePropName]: key.startsWith('D') ? false : true,
         [onClosePropName]: getCloseFunction(key, compState?.[onClosePropName])
       }
-      compState?.dataId &&
-        dispatch({
-          type: 'refresh/commitAction',
-          payload: compState.dataId
-        })
+
       if (destroyOnClose) {
         const prop = typeof destroyOnClose === 'string' ? destroyOnClose : onClosePropName
 
@@ -113,17 +114,23 @@ const ModalStore: React.FC<ModalStoreProps> = props => {
       const index = nextModals.findIndex(item => item.key === key)
 
       if (index !== -1) {
-        if (key.startsWith('D')) {
+        if (isDrawer) {
           message.warning('当前窗口正在运行中,请勿重复打开')
           return prevModals
         }
         nextModals.splice(index, 1)
+        compState?.dataId &&
+          dispatch({
+            type: 'refresh/commitAction',
+            payload: compState.dataId
+          })
       }
       nextModals.push(newModal)
 
       return nextModals
     })
-    if (key.startsWith('D')) {
+    if (isDrawer) {
+      if (state.currentModal.find(item => item.key === key)) return
       // 利用事件循环,先让dom元素渲染出来再使其展示动画(否则可能导致抽屉无动画直接出现)
       setTimeout(() => {
         setModalState(prevModals =>
@@ -153,24 +160,30 @@ const ModalStore: React.FC<ModalStoreProps> = props => {
   }
 
   function renderMaskProps(item: ModalItem) {
-    // 没有dataId 不是抽屉
-    if (!item.dataId) return item
-    const drawerStore = state.currentModal.filter(modal => modal.dataId).map(modal => modal.dataId)
+    const newItem = { ...item }
+    const isModal = item.key.startsWith('M')
+    const maskStyle: CSSProperties = {}
+    if (state.currentModal.findIndex(modal => modal.key === item.key) > 0) {
+      maskStyle.opacity = 0
+      maskStyle.animation = 'none'
+      newItem.maskStyle = maskStyle
+    }
+    if (isModal && !item.dataId) return newItem
+    const drawerStore = state.currentModal
+      .filter(modal => modal.key.startsWith('D'))
+      .map(modal => modal.dataId)
     const len = drawerStore.length
-    if (len === 1) return item
-    // 抽屉至少2个
     const currentIdx = drawerStore.findIndex(modal => modal === item.dataId)
-    if (currentIdx === 0) return item
-    if (currentIdx > 0) {
-      // 大于0说明是第二或以上的抽屉了
-      // console.log(len, currentIdx)
-
-      return {
-        ...item,
-        maskStyle: { opacity: 0, animation: 'none' } as CSSProperties
-      }
+    if (len - 1 === currentIdx) return newItem
+    // 抽屉大于2个
+
+    return {
+      ...item,
+      style: {
+        transform: `translateX(-${indent * (len - currentIdx - 1)}px)`
+      },
+      maskStyle
     }
-    return item
   }
   const { currentModal } = state
   const { children } = props

+ 0 - 1
src/pages/Customer/Client/components/AddClient/TelephoneFormItem.jsx

@@ -56,7 +56,6 @@ const TelephoneFormItem = ({ value, onChange, validateFn }) => {
   const { visible, list, inputVal } = state
   return (
     <Popover
-      zIndex={1003}
       placement="bottom"
       visible={list && list?.length && visible}
       onVisibleChange={e => setState({ ...state, visible: e })}

+ 1 - 1
src/pages/Customer/Client/components/AddClient/index.jsx

@@ -68,8 +68,8 @@ const AddClient = props => {
             formRef?.resetFields()
             setTimeout(() => {
               setValidStatusFtl('')
-              onCancel()
             }, 80)
+            onCancel()
           }
         } catch (error) {}
       })

+ 1 - 1
src/pages/Customer/Client/components/ClientDetail/TabList.jsx

@@ -166,7 +166,7 @@ const ClientTabList = ({ clientId, software, updatePayload }) => {
           ghost
           size="small"
           className="mr-1"
-          onClick={() => dispatchModal('M_ADD_RECORD', { onConfirm: handleAddService })}
+          onClick={() => dispatchModal('M_RECORD_ADD', { onConfirm: handleAddService })}
         >
           <Plus className="mr-1" /> 添加服务记录
         </Button>

+ 17 - 11
src/pages/Customer/Client/components/ConnectClient/index.jsx

@@ -114,6 +114,23 @@ const ConnectClient = ({
           onChange={handleInputChange}
         />
       }
+      footer={
+        showFooter && (
+          <Button
+            type="primary"
+            ghost
+            onClick={() =>
+              dispatchModal('M_CLIENT_ADD', {
+                onConfirm: addConfirm,
+                dataId,
+                dataType: preUrl
+              })
+            }
+          >
+            添加并关联到新客户
+          </Button>
+        )
+      }
     >
       <div
         className={styles.modalContent}
@@ -145,17 +162,6 @@ const ConnectClient = ({
         </Spin>
         {state.noMore && <div className="text-center text-gray-400 my-4">已到底部</div>}
       </div>
-      {showFooter ? (
-        <div className={styles.modalFooter}>
-          <AddClient
-            onConfirm={addConfirm}
-            dataId={dataId}
-            dataType={preUrl}
-            buttonProps={{ ghost: true }}
-            btnTitle={'添加并关联到新客户'}
-          />
-        </div>
-      ) : null}
     </Modal>
   )
 }

+ 15 - 2
src/pages/Customer/Client/index.jsx

@@ -28,7 +28,8 @@ const Client = props => {
     teamTags,
     dispatch,
     shouldUpdate,
-    loading
+    loading,
+    sourceList
   } = props
 
   const { initialState: { permData } = { permData: {} } } = useModel('@@initialState')
@@ -83,6 +84,11 @@ const Client = props => {
 
   // 默认刷新一次列表请求数据
   useEffect(() => {
+    if (!sourceList?.length) {
+      dispatch({
+        type: 'client/fetchSourceList'
+      })
+    }
     if (!personTags.length) {
       dispatch({
         type: 'client/fetchPersonTags',
@@ -351,7 +357,13 @@ const Client = props => {
       dataIndex: 'sourceName',
       key: 'sourceName',
       width: 80,
-      search: false
+      search: false,
+      filters: true,
+      filterMultiple: false,
+      valueEnum: sourceList.reduce((prev, curr) => {
+        prev[curr.value] = { text: curr.label }
+        return prev
+      }, {})
     },
     {
       title: '备注',
@@ -600,6 +612,7 @@ const Client = props => {
 export default connect(({ client, refresh, loading }) => ({
   personTagColorMap: client.personTagColorMap,
   personTags: client.personTags,
+  sourceList: client.sourceList,
   teamTagColorMap: client.teamTagColorMap,
   teamTags: client.teamTags,
   loading: loading.models.client,

+ 0 - 1
src/pages/Customer/Company/components/AddCompany/CompanyFormItem.jsx

@@ -60,7 +60,6 @@ const CompanyFormItem = ({ value, onChange, validateFn }) => {
   const { visible, list, inputVal } = state
   return (
     <Popover
-      zIndex={1003}
       placement="bottom"
       visible={list && list.length && visible}
       onVisibleChange={e => setState({ ...state, visible: e })}

+ 3 - 4
src/pages/Customer/Company/components/AddCompany/index.jsx

@@ -58,8 +58,8 @@ const AddCompanyModal = ({
             formRef?.resetFields()
             setTimeout(() => {
               setValidStatusFcn('')
-              onCancel()
             }, 80)
+            onCancel()
           }
         } catch (error) {}
       })
@@ -89,7 +89,6 @@ const AddCompanyModal = ({
               type="primary"
               className="ml-2"
               onClick={() => {
-                setShowDataItem(true)
                 const values = {}
                 if (dataType === ChangeCompMap.CLIENT.key) {
                   values.clientId = dataId
@@ -97,7 +96,7 @@ const AddCompanyModal = ({
                 if (dataType === ChangeCompMap.BUSINESS.key) {
                   values.businessId = dataId
                 }
-                formRef && formRef.setFieldsValue(values)
+                formRef?.setFieldsValue(values)
                 handleOnOk()
               }}
             >
@@ -117,7 +116,7 @@ const AddCompanyModal = ({
         >
           <CompanyFormItem validateFn={status => setValidStatusFcn(status)} />
         </Form.Item>
-        {showDataItem ? <ProFormText name={`${dataType}Id`} hidden /> : null}
+        <ProFormText name={`${dataType}Id`} hidden />
         <Form.Item
           name="districtIds"
           label="单位地区"

+ 1 - 1
src/pages/Customer/Company/components/ChangeCompany/index.jsx

@@ -65,7 +65,7 @@ const ChangeCompanyInput = props => {
         </p>
       ),
       onOk: async () => {
-        await apiDelCustomer(actionPayload, { id: dataId, customerId })
+        await apiDelCustomer(actionPayload.main, { id: dataId, customerId })
         refreshClient()
       }
     })

+ 1 - 0
src/pages/Customer/Company/components/ChangeCompany/index.less

@@ -1,5 +1,6 @@
 .companyInput {
   padding: 8px 12px 6px;
+  min-height: 38px;
   color: @primary-color;
   background: #f7f7f7;
   border: 1px solid #f7f7f7;

+ 1 - 0
src/pages/Customer/Company/components/CompanyDetail/TabList.jsx

@@ -321,6 +321,7 @@ const CompanyTabList = ({
       })
       initData()
     }
+    return code === consts.RET_CODE.SUCCESS
   }
   return (
     <div>

+ 20 - 11
src/pages/Customer/Company/components/ConnectCompany/index.jsx

@@ -9,6 +9,7 @@ import { createCustomer, queryCustomers } from '@/services/customer'
 import consts from '@/basic/consts'
 import { formatValues } from '@/components/LazyCascader'
 import { apiChangeCustomer } from '@/services/customer'
+import { useModal } from '@/components/ModalStore'
 
 const ConnectCompany = ({
   onCancel,
@@ -19,6 +20,7 @@ const ConnectCompany = ({
   ...resetModalProps
 }) => {
   const hasAddPerm = useAccess()?.validatePermByType('company_add')
+  const dispatchModal = useModal()
   const scrollRef = useRef()
   const [state, setState] = useState({
     laoding: true,
@@ -73,6 +75,7 @@ const ConnectCompany = ({
         initData()
       }
     }
+    return code === consts.RET_CODE.SUCCESS
   }
 
   // 客户/商机关联单位
@@ -114,7 +117,23 @@ const ConnectCompany = ({
           onChange={handleInputChange}
         />
       }
-      footer={false}
+      footer={
+        hasAddPerm && (
+          <Button
+            type="primary"
+            onClick={() =>
+              dispatchModal('M_COMPANY_ADD', {
+                onConfirm: addConfirm,
+                dataId,
+                dataType: preUrl,
+                defaultValue: defaultAddibleValue
+              })
+            }
+          >
+            添加单位
+          </Button>
+        )
+      }
     >
       <div
         className={styles.modalContent}
@@ -144,16 +163,6 @@ const ConnectCompany = ({
         </Spin>
         {state.noMore && <div className="text-center text-gray-400 my-4">已到底部</div>}
       </div>
-      {hasAddPerm && (
-        <div className={styles.modalFooter}>
-          <AddCompany
-            onConfirm={addConfirm}
-            dataId={dataId}
-            dataType={preUrl}
-            defaultValue={defaultAddibleValue}
-          />
-        </div>
-      )}
     </Modal>
   )
 }

+ 1 - 1
src/pages/Customer/Company/index.jsx

@@ -177,7 +177,7 @@ const Company = props => {
       key: 'phone',
       search: false,
       sorter: true,
-      width: 100
+      width: 110
     },
     {
       title: '个人标签',

+ 1 - 1
src/pages/Hr/Employee/components/ChangeSupervisor/index.jsx

@@ -30,7 +30,7 @@ const ChangeSupervisor = props => {
     })
   }
   const handleConnectStaff = () => {
-    dispatchModal('M_CONNECT_CLIENT', {
+    dispatchModal('M_CONNECT_STAFF', {
       onSelect: refreshStaff,
       id: clientId,
       preUrl: actionPayload.main

+ 3 - 2
src/pages/Hr/Employee/components/StaffModal/index.jsx

@@ -6,7 +6,7 @@ import { SearchOutlined } from '@ant-design/icons'
 import { queryStaff, apiChangeSupervisor } from '@/services/staff'
 import styles from '@/pages/Customer/Company/components/ConnectCompany/index.less'
 
-const StaffModal = ({ visible, onCancel, id, onSelect, postUrl }) => {
+const StaffModal = ({ visible, onCancel, id, onSelect, preUrl }) => {
   const scrollRef = useRef()
   const [state, setState] = useState({
     loading: true,
@@ -51,7 +51,7 @@ const StaffModal = ({ visible, onCancel, id, onSelect, postUrl }) => {
 
   // 关联上司
   const connectStaff = async dataId => {
-    const { code = -1 } = await apiChangeSupervisor(postUrl, { id, dataId })
+    const { code = -1 } = await apiChangeSupervisor(preUrl, { id, dataId })
     if (code === consts.RET_CODE.SUCCESS) {
       onSelect()
       setTimeout(() => {
@@ -88,6 +88,7 @@ const StaffModal = ({ visible, onCancel, id, onSelect, postUrl }) => {
           onChange={handleInputChange}
         />
       }
+      footer={false}
     >
       <div
         className={styles.modalContent}

+ 3 - 1
src/pages/Product/Lock/LockStore/components/CopyAuthorizeStr/index.jsx

@@ -4,11 +4,13 @@ import { Copy } from '@icon-park/react'
 import { CopyToClipboard } from 'react-copy-to-clipboard'
 import styles from '@/pages/Product/Lock/LockStore/components/ChangeClient/index.less'
 import { isEmpty, isNullOrUnDef } from '@/utils/is'
+import classNames from 'classnames'
 
 const CopyAuthorizeStr = ({ authorizeStr }) => {
   if (isNullOrUnDef(authorizeStr) || isEmpty(authorizeStr)) return null
+  const className = classNames(styles.companyInput, 'mb-2')
   return (
-    <div className={styles.companyInput}>
+    <div className={className}>
       <Card size="small">
         <div className="flex justify-between">
           <div className={`${styles.nameContent} ${styles.nameContentWidth}`}>{authorizeStr}</div>

+ 3 - 1
src/pages/Product/Lock/LockStore/components/DownUpdateFile/index.jsx

@@ -3,6 +3,7 @@ import { Card, Tooltip } from 'antd'
 import { Download } from '@icon-park/react'
 import styles from '@/pages/Product/Lock/LockStore/components/ChangeClient/index.less'
 import { isEmpty, isNullOrUnDef } from '@/utils/is'
+import classNames from 'classnames'
 
 const DownUpdateFile = ({ updateFile }) => {
   const NewupdateFile = updateFile?.replace('/upload/longle/', '')
@@ -14,8 +15,9 @@ const DownUpdateFile = ({ updateFile }) => {
     document.body.appendChild(oa)
     oa.click()
   }
+  const className = classNames(styles.companyInput, 'mb-2')
   return (
-    <div className={styles.companyInput}>
+    <div className={className}>
       <Card size="small">
         <div className="flex justify-between">
           <div className={`${styles.nameContent} ${styles.nameContentWidth}`}>{NewupdateFile}</div>

+ 3 - 8
src/pages/Product/Lock/LockStore/components/LockDetail/Form.jsx

@@ -122,8 +122,8 @@ const LockForm = props => {
           <ChangeCompanyInput
             actionPayload={actionPayload}
             dataSource={changeCompanyInputData}
-            showRemoveIcon={false}
-            showConnectIcon={false}
+            // showRemoveIcon={false}
+            // showConnectIcon={false}
           />
         </Col>
         <Divider style={{ margin: '12px 0' }} />
@@ -135,20 +135,15 @@ const LockForm = props => {
         <Col span={6}>注册码</Col>
         <Col span={18}>
           <CopyAuthorizeStr authorizeStr={longle.authorizeStr} />
-        </Col>
-        <Col span={6} />
-        <Col span={18}>
           <small>
             使用方法:复制以上注册码,打开软件帮助菜单/产品注册/下一步/下一步/选择&quot;手工输入注册码&quot;。将注册码不分段不空格复制粘贴到&quot;注册码&quot;栏内确定即可。
           </small>
         </Col>
+
         <Divider style={{ margin: '12px 0' }} />
         <Col span={6}>升级文件</Col>
         <Col span={18}>
           <DownUpdateFile updateFile={longle.updateFile} />
-        </Col>
-        <Col span={6} />
-        <Col span={18}>
           <small>
             使用方法:下载以上升级文件,打开软件帮助菜单/升级加密锁/下一步/下一步/选择“使用升级文件升级”,再点击下一步完成即可。
           </small>

+ 2 - 2
src/pages/Workbench/Dashboard/components/RatioPanels.jsx

@@ -67,7 +67,7 @@ const ServiceRatioPanels = ({ dispatchModal, staffIds, cyclical, dataPermission
       render: (text, record) => (
         <span
           onClick={() => showDrawer(record[activeKeyMap[state.activeKey].id])}
-          className="text-primary cursor-pointer hover:text-[#967bbd]"
+          className="text-primary cursor-pointer hover:text-hex-967bbd"
         >
           {text}
         </span>
@@ -186,7 +186,7 @@ const RatioPanels = ({ dataType, staffIds, retioCyclical, dataPermission, ...res
         render: (companyName, record) => (
           <span
             className="text-primary cursor-pointer hover:text-[#967bbd]"
-            onClick={() => dispatchModal('D_CLIENT_DETAIL', { dataId: record.companyId })}
+            onClick={() => dispatchModal('D_COMPANY_DETAIL', { dataId: record.companyId })}
           >
             {companyName}
           </span>

+ 7 - 11
src/pages/Workbench/Dashboard/index.jsx

@@ -187,7 +187,7 @@ const Dashboard = ({ dispatch, departments = [] }) => {
       render: (name, record) => (
         <span
           onClick={() => handleReminderList(record.type, '7day')}
-          className="text-primary cursor-pointer hover:text-[#967bbd]"
+          className="text-primary cursor-pointer hover:text-hex-967bbd"
         >
           {name}
         </span>
@@ -199,7 +199,7 @@ const Dashboard = ({ dispatch, departments = [] }) => {
       render: (name, record) => (
         <span
           onClick={() => handleReminderList(record.type, '15day')}
-          className="text-primary cursor-pointer hover:text-[#967bbd]"
+          className="text-primary cursor-pointer hover:text-hex-967bbd"
         >
           {name}
         </span>
@@ -211,7 +211,7 @@ const Dashboard = ({ dispatch, departments = [] }) => {
       render: (name, record) => (
         <span
           onClick={() => handleReminderList(record.type, '30day')}
-          className="text-primary cursor-pointer hover:text-[#967bbd]"
+          className="text-primary cursor-pointer hover:text-hex-967bbd"
         >
           {name}
         </span>
@@ -223,7 +223,7 @@ const Dashboard = ({ dispatch, departments = [] }) => {
       render: (name, record) => (
         <span
           onClick={() => handleReminderList(record.type, '3month')}
-          className="text-primary cursor-pointer hover:text-[#967bbd]"
+          className="text-primary cursor-pointer hover:text-hex-967bbd"
         >
           {name}
         </span>
@@ -235,7 +235,7 @@ const Dashboard = ({ dispatch, departments = [] }) => {
       render: (name, record) => (
         <span
           onClick={() => handleReminderList(record.type, '6month')}
-          className="text-primary cursor-pointer hover:text-[#967bbd]"
+          className="text-primary cursor-pointer hover:text-hex-967bbd"
         >
           {name}
         </span>
@@ -247,7 +247,7 @@ const Dashboard = ({ dispatch, departments = [] }) => {
       render: (name, record) => (
         <span
           onClick={() => handleReminderList(record.type, 'reminder')}
-          className="text-primary cursor-pointer hover:text-[#967bbd]"
+          className="text-primary cursor-pointer hover:text-hex-967bbd"
         >
           {name}
         </span>
@@ -255,9 +255,6 @@ const Dashboard = ({ dispatch, departments = [] }) => {
     }
   ]
 
-  // const handleChangeGroupId = e =>
-  //   setState({ ...state, immediate: true, params: { ...state.params, businessGroupId: e } })
-
   // 处理权限Select下拉组件OnChange事件
   const handlePermChange = ({ staffIds = [], dataPermission }) => {
     if (staffIds?.length) {
@@ -346,8 +343,7 @@ const Dashboard = ({ dispatch, departments = [] }) => {
         </span>
 
         <div className="flex items-center flex-row ml-2">
-          {!isMobile() &&
-            ['all', 'department'].includes(state.params.dataPermission) &&
+          {['all', 'department'].includes(state.params.dataPermission) &&
             state.staffList.map(item => (
               <div key={item.id} onClick={() => handleStaffClick(item.id)}>
                 <div