Просмотр исходного кода

feat: 大司空企业版详情+创建企业

outaozhen 4 лет назад
Родитель
Сommit
5e3367a83b

+ 81 - 0
src/pages/Product/Road/Enterprise/components/AddEnterprise/EnterpriseSearchSelect.jsx

@@ -0,0 +1,81 @@
+import { Select } from 'antd'
+import React, { useState } from 'react'
+import { useDebounceFn } from 'ahooks'
+import consts from '@/consts'
+import { queryRoadpricingListV2 } from '@/services/product'
+import { validateEnum } from '@/pages/Customer/Company/components/AddCompany/CompanyFormItem'
+
+const EnterpriseSearchSelect = ({ value, onChange, disabled, validateFn }) => {
+  const { Option } = Select
+  const [state, setState] = useState({
+    inputVal: value,
+    visible: false,
+    roadlist: null
+  })
+  const triggerChange = changedValue => {
+    onChange?.(changedValue)
+  }
+  const { visible, roadlist, inputVal } = state
+  const queryRoadList = async search => {
+    if (!search) return
+    const { code = -1, data } = await queryRoadpricingListV2({
+      current: 1,
+      pageSize: 10,
+      search,
+      projectType: 1
+    })
+    if (code === consts.RET_CODE.SUCCESS) {
+      const { list = [] } = data
+      setState({ ...state, roadlist: list, visible: !!list?.length })
+      if (list?.length) {
+        validateFn(validateEnum.Success)
+      } else {
+        validateFn(validateEnum.Error)
+      }
+    }
+  }
+  const { run: handleQueryList, cancel: cancelQuerying } = useDebounceFn(queryRoadList, {
+    wait: 600
+  })
+
+  const handleSearch = value => {
+    if (value) {
+      fetch(value, roadlist => setState({ ...state, roadlist }))
+    } else {
+      setState({ ...state, roadlist: [] })
+    }
+  }
+
+  const handleOnInputChange = async e => {
+    const val = e.target.value || ''
+    if (!val) {
+      cancelQuerying()
+      setState({ ...state, inputVal: val, roadlist: null, visible: false })
+      validateFn(validateEnum.Error)
+    } else {
+      setState({ ...state, inputVal: val })
+      validateFn(validateEnum.Validating)
+      handleQueryList(val)
+    }
+    triggerChange(val)
+  }
+  const options = roadlist?.map(item => <Option key={item.ID}>{{ value: item.realName }}</Option>)
+  console.log(options)
+  return (
+    <Select
+      showSearch
+      defaultActiveFirstOption={false}
+      showArrow={false}
+      filterOption={false}
+      placeholder="请输入企业名称"
+      value={inputVal}
+      disabled={disabled}
+      onSearch={handleSearch}
+      onChange={handleOnInputChange}
+      notFoundContent={null}>
+      {options}
+    </Select>
+  )
+}
+
+export default EnterpriseSearchSelect

+ 2 - 2
src/pages/Product/Road/Enterprise/components/AddEnterprise/SearchCompanyInput.jsx

@@ -5,7 +5,7 @@ import consts from '@/consts'
 import { queryRoadcompanyList } from '@/services/product'
 import { queryRoadcompanyList } from '@/services/product'
 import { validateEnum } from '@/pages/Customer/Company/components/AddCompany/CompanyFormItem'
 import { validateEnum } from '@/pages/Customer/Company/components/AddCompany/CompanyFormItem'
 
 
-const SearchCompanyInput = ({ value, onChange, disabled, validateFn }) => {
+const EnterpriseSearchSelect = ({ value, onChange, disabled, validateFn }) => {
   const [state, setState] = useState({
   const [state, setState] = useState({
     inputVal: value
     inputVal: value
   })
   })
@@ -57,4 +57,4 @@ const SearchCompanyInput = ({ value, onChange, disabled, validateFn }) => {
   )
   )
 }
 }
 
 
-export default SearchCompanyInput
+export default EnterpriseSearchSelect

+ 14 - 5
src/pages/Product/Road/Enterprise/components/AddEnterprise/index.jsx

@@ -2,8 +2,7 @@ import { ProFormText } from '@ant-design/pro-form'
 import { Button, Form, Input, InputNumber, Modal, Select, Space } from 'antd'
 import { Button, Form, Input, InputNumber, Modal, Select, Space } from 'antd'
 import React, { useState, useEffect } from 'react'
 import React, { useState, useEffect } from 'react'
 import { useDispatch, connect } from 'umi'
 import { useDispatch, connect } from 'umi'
-import EnterpriseSelect from './EnterpriseSelect'
-import EnterpriseFormItem from './EnterpriseFormItem'
+import EnterpriseSearchSelect from './EnterpriseSearchSelect'
 import { validateEnum } from '@/pages/Customer/Company/components/AddCompany/CompanyFormItem'
 import { validateEnum } from '@/pages/Customer/Company/components/AddCompany/CompanyFormItem'
 import SearchCompanyInput from './SearchCompanyInput'
 import SearchCompanyInput from './SearchCompanyInput'
 
 
@@ -94,9 +93,7 @@ const AddEnterprise = ({
         </div>
         </div>
       }
       }
       {...resetModalProps}>
       {...resetModalProps}>
-      {/* initialValues={{ licenceNum: 1 }} */}
       <Form {...layout} form={formRef} initialValues={defaultValues}>
       <Form {...layout} form={formRef} initialValues={defaultValues}>
-        {/* <ProFormText name="adminID" hidden /> */}
         <Form.Item
         <Form.Item
           name="companyName"
           name="companyName"
           label="创建企业"
           label="创建企业"
@@ -126,11 +123,23 @@ const AddEnterprise = ({
           rules={[{ required: true }]}
           rules={[{ required: true }]}
           validateStatus={validStatus.adminID}
           validateStatus={validStatus.adminID}
           help={validStatus.adminID === validateEnum.Error ? '当前账号非大司空用户,请重新输入' : null}>
           help={validStatus.adminID === validateEnum.Error ? '当前账号非大司空用户,请重新输入' : null}>
-          <EnterpriseFormItem
+          <EnterpriseSearchSelect
             validateFn={status => setValidStatus({ ...validStatus, adminID: status })}
             validateFn={status => setValidStatus({ ...validStatus, adminID: status })}
             disabled={disabled}
             disabled={disabled}
           />
           />
         </Form.Item>
         </Form.Item>
+        {/* <Form.Item
+          name="adminID"
+          label="管理员名称"
+          hasFeedback
+          rules={[{ required: true }]}
+          validateStatus={validStatus.adminID}
+          help={validStatus.adminID === validateEnum.Error ? '当前账号非大司空用户,请重新输入' : null}>
+          <EnterpriseFormItem
+            validateFn={status => setValidStatus({ ...validStatus, adminID: status })}
+            disabled={disabled}
+          />
+        </Form.Item> */}
       </Form>
       </Form>
     </Modal>
     </Modal>
   )
   )

+ 24 - 9
src/pages/Product/Road/Enterprise/components/Detail/TabList.jsx

@@ -5,9 +5,14 @@ import { renderBadge } from '@/pages/Workbench/Dashboard/components/RatioPanels'
 import { useModal } from '@/components/ModalStore'
 import { useModal } from '@/components/ModalStore'
 import { apiRoadUpdateCompany } from '@/services/product'
 import { apiRoadUpdateCompany } from '@/services/product'
 import consts from '@/consts'
 import consts from '@/consts'
+import { dayjsFormat } from '@/utils/utils'
 
 
 const EnterpriseTabList = props => {
 const EnterpriseTabList = props => {
-  const { authUsers, compilationList, company, reload } = props
+  const {
+    company,
+    reload,
+    company: { proCptList, members }
+  } = props
   const { TabPane } = Tabs
   const { TabPane } = Tabs
   const dispatchModal = useModal()
   const dispatchModal = useModal()
   const isUpgradeEnum = {
   const isUpgradeEnum = {
@@ -33,23 +38,33 @@ const EnterpriseTabList = props => {
     {
     {
       title: '限期',
       title: '限期',
       dataIndex: 'deadline',
       dataIndex: 'deadline',
-      width: '10%'
+      width: '10%',
+      renderText: text => dayjsFormat(text, 'YYYY-MM-DD')
     },
     },
     {
     {
       title: '责任人',
       title: '责任人',
       dataIndex: 'a1',
       dataIndex: 'a1',
       width: '10%'
       width: '10%'
+    },
+    {
+      title: '操作',
+      width: '15%',
+      render: (_, record) => (
+        <Button type="primary" ghost danger size="small">
+          限期
+        </Button>
+      )
     }
     }
   ]
   ]
   const columnOnline = [
   const columnOnline = [
     {
     {
       title: '姓名',
       title: '姓名',
-      dataIndex: 'name',
+      dataIndex: 'memberName',
       width: '15%'
       width: '15%'
     },
     },
     {
     {
       title: '手机',
       title: '手机',
-      dataIndex: 'phone',
+      dataIndex: 'mobile',
       width: '8%'
       width: '8%'
     },
     },
     {
     {
@@ -69,21 +84,21 @@ const EnterpriseTabList = props => {
                 columns={columns}
                 columns={columns}
                 search={false}
                 search={false}
                 toolBarRender={false}
                 toolBarRender={false}
-                rowKey={record => record._id}
-                dataSource={compilationList}
+                rowKey={record => record.compilationID}
+                dataSource={proCptList}
                 pagination={false}
                 pagination={false}
               />
               />
             </div>
             </div>
           </TabPane>
           </TabPane>
-          <TabPane tab={<span>授权用户{renderBadge(authUsers.total, true)}</span>} key="2">
+          <TabPane tab={<span>授权用户</span>} key="2">
             <div className="sheet-right-panel">
             <div className="sheet-right-panel">
               <ProTable
               <ProTable
                 size="small"
                 size="small"
                 columns={columnOnline}
                 columns={columnOnline}
                 search={false}
                 search={false}
                 toolBarRender={false}
                 toolBarRender={false}
-                rowKey={record => record.id}
-                dataSource={authUsers.users}
+                rowKey={record => record.userID}
+                dataSource={members}
                 pagination={false}
                 pagination={false}
               />
               />
             </div>
             </div>

+ 3 - 20
src/pages/Product/Road/Enterprise/components/Detail/index.jsx

@@ -16,8 +16,6 @@ const EnterpriseDetail = props => {
     loading: false,
     loading: false,
     company: {},
     company: {},
     customer: {},
     customer: {},
-    compilationList: [],
-    authUsers: {},
     client: [],
     client: [],
     serviceLog: [],
     serviceLog: [],
     log: {}
     log: {}
@@ -36,15 +34,7 @@ const EnterpriseDetail = props => {
   const initData = async id => {
   const initData = async id => {
     setState({ ...state, loading: true })
     setState({ ...state, loading: true })
     const {
     const {
-      data: {
-        company = {},
-        customer = {},
-        compilationList = [],
-        authUsers = {},
-        client = [],
-        serviceLog = [],
-        log = {}
-      },
+      data: { company = {}, customer = {}, client = [], serviceLog = [], log = {} },
       code = -1
       code = -1
     } = await apiRoadcompanyDetail({ companyId: id })
     } = await apiRoadcompanyDetail({ companyId: id })
     if (code === consts.RET_CODE.SUCCESS) {
     if (code === consts.RET_CODE.SUCCESS) {
@@ -55,8 +45,6 @@ const EnterpriseDetail = props => {
         ...state,
         ...state,
         company,
         company,
         customer,
         customer,
-        compilationList,
-        authUsers,
         client,
         client,
         serviceLog,
         serviceLog,
         log,
         log,
@@ -122,7 +110,7 @@ const EnterpriseDetail = props => {
                           type="primary"
                           type="primary"
                           ghost
                           ghost
                           size="small"
                           size="small"
-                          onClick={() => pricingUnLinkCompany(state.company.cld?.customerId)}>
+                          onClick={() => pricingUnLinkCompany(state.company.ID)}>
                           <LinkInterrupt size="14" />
                           <LinkInterrupt size="14" />
                           <span className="ml-5px">移除CLD单位信息</span>
                           <span className="ml-5px">移除CLD单位信息</span>
                         </Button>
                         </Button>
@@ -140,12 +128,7 @@ const EnterpriseDetail = props => {
               </div>
               </div>
             </Col>
             </Col>
             <Col span={15} className="sheet-box-right">
             <Col span={15} className="sheet-box-right">
-              <EnterpriseTabList
-                compilationList={state.compilationList}
-                authUsers={state.authUsers}
-                company={state.company}
-                reload={refreshDetail}
-              />
+              <EnterpriseTabList company={state.company} reload={refreshDetail} />
               <EnterpriseLowerList log={state.log} />
               <EnterpriseLowerList log={state.log} />
             </Col>
             </Col>
           </Row>
           </Row>