|  | @@ -2,19 +2,23 @@ import AnimateContent from '@/components/AnimateContent'
 | 
	
		
			
				|  |  |  import consts from '@/utils/consts'
 | 
	
		
			
				|  |  |  import { PageContainer } from '@ant-design/pro-layout'
 | 
	
		
			
				|  |  |  import ProTable from '@ant-design/pro-table'
 | 
	
		
			
				|  |  | -import { Button, message } from 'antd'
 | 
	
		
			
				|  |  | +import { Button, message, Popconfirm } from 'antd'
 | 
	
		
			
				|  |  |  import { useRef, useState } from 'react'
 | 
	
		
			
				|  |  |  import { useRequest } from 'umi'
 | 
	
		
			
				|  |  | -import { addApproval, getApprovalList, publishApproval, saveApproval } from '@/services/api/project'
 | 
	
		
			
				|  |  | -import type { ActionType } from '@ant-design/pro-table'
 | 
	
		
			
				|  |  | +import { addApproval, delApproval, getApprovalList, saveApproval } from '@/services/api/project'
 | 
	
		
			
				|  |  | +import type { ActionType, ProColumnType } from '@ant-design/pro-table'
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  import ApprovalDetail from './Detail'
 | 
	
		
			
				|  |  |  import { ModalForm, ProFormText } from '@ant-design/pro-form'
 | 
	
		
			
				|  |  |  import type { ProFormInstance } from '@ant-design/pro-form'
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -export enum PublishType {
 | 
	
		
			
				|  |  | -  FAIL = '0',
 | 
	
		
			
				|  |  | -  SUCCESS = '1'
 | 
	
		
			
				|  |  | +// export enum PublishType {
 | 
	
		
			
				|  |  | +//   FAIL = '0',
 | 
	
		
			
				|  |  | +//   SUCCESS = '1'
 | 
	
		
			
				|  |  | +// }
 | 
	
		
			
				|  |  | +export enum ApprovalModalType {
 | 
	
		
			
				|  |  | +  ADD,
 | 
	
		
			
				|  |  | +  UPDATE
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  const FlowList = () => {
 | 
	
	
		
			
				|  | @@ -32,12 +36,12 @@ const FlowList = () => {
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |    })
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -  // const { run: tryDel } = useRequest(delApproval, {
 | 
	
		
			
				|  |  | -  //   manual: true,
 | 
	
		
			
				|  |  | -  //   onSuccess: () => {
 | 
	
		
			
				|  |  | -  //     tRef.current?.reload()
 | 
	
		
			
				|  |  | -  //   }
 | 
	
		
			
				|  |  | -  // })
 | 
	
		
			
				|  |  | +  const { run: tryDel } = useRequest(delApproval, {
 | 
	
		
			
				|  |  | +    manual: true,
 | 
	
		
			
				|  |  | +    onSuccess: () => {
 | 
	
		
			
				|  |  | +      tRef.current?.reload()
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +  })
 | 
	
		
			
				|  |  |    const { run: tryAdd } = useRequest(addApproval, {
 | 
	
		
			
				|  |  |      manual: true,
 | 
	
		
			
				|  |  |      onSuccess: () => {
 | 
	
	
		
			
				|  | @@ -58,17 +62,12 @@ const FlowList = () => {
 | 
	
		
			
				|  |  |        tRef.current?.reload()
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |    })
 | 
	
		
			
				|  |  | -  const columns = [
 | 
	
		
			
				|  |  | -    // {
 | 
	
		
			
				|  |  | -    //   dataIndex: 'name',
 | 
	
		
			
				|  |  | -    //   title: '项目名称',
 | 
	
		
			
				|  |  | -    //   onHeaderCell: () => ({ style: { textAlign: 'center' } })
 | 
	
		
			
				|  |  | -    // },
 | 
	
		
			
				|  |  | +  const columns: ProColumnType = [
 | 
	
		
			
				|  |  |      {
 | 
	
		
			
				|  |  |        dataIndex: 'name',
 | 
	
		
			
				|  |  |        title: '模板名称',
 | 
	
		
			
				|  |  |        onHeaderCell: () => ({ style: { textAlign: 'center' } }),
 | 
	
		
			
				|  |  | -      renderText: (_, record) => (
 | 
	
		
			
				|  |  | +      render: (_, record) => (
 | 
	
		
			
				|  |  |          <span
 | 
	
		
			
				|  |  |            className="text-primary hover:cursor-pointer hover:text-blue-600"
 | 
	
		
			
				|  |  |            onClick={() => {
 | 
	
	
		
			
				|  | @@ -78,7 +77,12 @@ const FlowList = () => {
 | 
	
		
			
				|  |  |                current: { dataID: record.ID, name: record.name, readPretty: true }
 | 
	
		
			
				|  |  |              })
 | 
	
		
			
				|  |  |            }}>
 | 
	
		
			
				|  |  | -          {record.name}
 | 
	
		
			
				|  |  | +          {record.stickyTop ? (
 | 
	
		
			
				|  |  | +            <span className="w-30px text-center rounded-lg text-primary border border-hex-0089ff bg-hex-e9f5ff">
 | 
	
		
			
				|  |  | +              默
 | 
	
		
			
				|  |  | +            </span>
 | 
	
		
			
				|  |  | +          ) : null}
 | 
	
		
			
				|  |  | +          <span className="ml-2">{record.name}</span>
 | 
	
		
			
				|  |  |          </span>
 | 
	
		
			
				|  |  |        )
 | 
	
		
			
				|  |  |      },
 | 
	
	
		
			
				|  | @@ -103,29 +107,30 @@ const FlowList = () => {
 | 
	
		
			
				|  |  |        onHeaderCell: () => ({ style: { textAlign: 'center' } }),
 | 
	
		
			
				|  |  |        align: 'center',
 | 
	
		
			
				|  |  |        render: (_, record) => (
 | 
	
		
			
				|  |  | -        <div className="divide-x divide-bg-gray-400 ">
 | 
	
		
			
				|  |  | +        <div className="divide-x divide-bg-gray-400">
 | 
	
		
			
				|  |  |            <span
 | 
	
		
			
				|  |  |              className="pr-2 text-primary cursor-pointer hover:text-hex-967bbd"
 | 
	
		
			
				|  |  |              onClick={() => {
 | 
	
		
			
				|  |  |                setState({
 | 
	
		
			
				|  |  |                  ...state,
 | 
	
		
			
				|  |  | -                visible: true,
 | 
	
		
			
				|  |  | +                modalType: ApprovalModalType.UPDATE,
 | 
	
		
			
				|  |  | +                modalVisible: true,
 | 
	
		
			
				|  |  |                  current: { dataID: record.ID, name: record.name }
 | 
	
		
			
				|  |  |                })
 | 
	
		
			
				|  |  |              }}>
 | 
	
		
			
				|  |  | -            编辑流程
 | 
	
		
			
				|  |  | +            编辑名称
 | 
	
		
			
				|  |  |            </span>
 | 
	
		
			
				|  |  | -          {/* <span
 | 
	
		
			
				|  |  | -            className="px-2 text-primary hover:cursor-pointer hover:text-blue-600"
 | 
	
		
			
				|  |  | -            onClick={() =>
 | 
	
		
			
				|  |  | +          <span
 | 
	
		
			
				|  |  | +            className="px-2 text-primary cursor-pointer hover:text-hex-967bbd"
 | 
	
		
			
				|  |  | +            onClick={() => {
 | 
	
		
			
				|  |  |                setState({
 | 
	
		
			
				|  |  |                  ...state,
 | 
	
		
			
				|  |  |                  visible: true,
 | 
	
		
			
				|  |  | -                current: { ...record.approval, readPretty: true }
 | 
	
		
			
				|  |  | +                current: { dataID: record.ID, name: record.name }
 | 
	
		
			
				|  |  |                })
 | 
	
		
			
				|  |  | -            }>
 | 
	
		
			
				|  |  | -            查看流程图
 | 
	
		
			
				|  |  | -          </span> */}
 | 
	
		
			
				|  |  | +            }}>
 | 
	
		
			
				|  |  | +            配置流程
 | 
	
		
			
				|  |  | +          </span>
 | 
	
		
			
				|  |  |            {/* <span
 | 
	
		
			
				|  |  |              className={[
 | 
	
		
			
				|  |  |                'pl-2',
 | 
	
	
		
			
				|  | @@ -134,13 +139,14 @@ const FlowList = () => {
 | 
	
		
			
				|  |  |              onClick={() => !record.publish && tryPublish({ ID: record.approval.ID })}>
 | 
	
		
			
				|  |  |              发布
 | 
	
		
			
				|  |  |            </span> */}
 | 
	
		
			
				|  |  | -          {/* <Popconfirm
 | 
	
		
			
				|  |  | -            title={`确认删除${record.name}吗?`}
 | 
	
		
			
				|  |  | -            okText="确认"
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +          <Popconfirm
 | 
	
		
			
				|  |  | +            title="是否删除此流程模板?"
 | 
	
		
			
				|  |  | +            okText="确定"
 | 
	
		
			
				|  |  |              cancelText="取消"
 | 
	
		
			
				|  |  |              onConfirm={() => tryDel({ ID: record.ID })}>
 | 
	
		
			
				|  |  |              <span className="text-red-500 pl-2 cursor-pointer hover:text-red-600">删除</span>
 | 
	
		
			
				|  |  | -          </Popconfirm> */}
 | 
	
		
			
				|  |  | +          </Popconfirm>
 | 
	
		
			
				|  |  |          </div>
 | 
	
		
			
				|  |  |        )
 | 
	
		
			
				|  |  |      }
 | 
	
	
		
			
				|  | @@ -172,7 +178,9 @@ const FlowList = () => {
 | 
	
		
			
				|  |  |            actions: [
 | 
	
		
			
				|  |  |              <Button
 | 
	
		
			
				|  |  |                type="primary"
 | 
	
		
			
				|  |  | -              onClick={() => setState({ ...state, modalType: 'add', modalVisible: true })}
 | 
	
		
			
				|  |  | +              onClick={() =>
 | 
	
		
			
				|  |  | +                setState({ ...state, modalType: ApprovalModalType.ADD, modalVisible: true })
 | 
	
		
			
				|  |  | +              }
 | 
	
		
			
				|  |  |                key="add_flow_btn">
 | 
	
		
			
				|  |  |                新建流程
 | 
	
		
			
				|  |  |              </Button>
 | 
	
	
		
			
				|  | @@ -191,20 +199,21 @@ const FlowList = () => {
 | 
	
		
			
				|  |  |        <ModalForm
 | 
	
		
			
				|  |  |          visible={state.modalVisible}
 | 
	
		
			
				|  |  |          isKeyPressSubmit
 | 
	
		
			
				|  |  | +        layout="horizontal"
 | 
	
		
			
				|  |  |          modalProps={{
 | 
	
		
			
				|  |  |            width: '30%'
 | 
	
		
			
				|  |  |          }}
 | 
	
		
			
				|  |  |          onVisibleChange={visible => setState({ ...state, modalVisible: visible })}
 | 
	
		
			
				|  |  | -        title={`${state.modalType === 'add' ? '新建' : '编辑'}审批流程`}
 | 
	
		
			
				|  |  | +        title={`${state.modalType === ApprovalModalType.ADD ? '新建' : '编辑'}审批流程`}
 | 
	
		
			
				|  |  |          formRef={formRef}
 | 
	
		
			
				|  |  |          onFinish={async values => {
 | 
	
		
			
				|  |  |            try {
 | 
	
		
			
				|  |  | -            if (state.modalType === 'add') {
 | 
	
		
			
				|  |  | +            if (state.modalType === ApprovalModalType.ADD) {
 | 
	
		
			
				|  |  |                await tryAdd(values)
 | 
	
		
			
				|  |  |              } else {
 | 
	
		
			
				|  |  | -              await tryUpdate(values)
 | 
	
		
			
				|  |  | +              await tryUpdate({ ...values, ID: state.current.dataID })
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | -            message.success(`${state.modalType === 'add' ? '新增' : '编辑'}成功`)
 | 
	
		
			
				|  |  | +            message.success(`${state.modalType === ApprovalModalType.ADD ? '新增' : '编辑'}成功`)
 | 
	
		
			
				|  |  |              tRef.current?.reload()
 | 
	
		
			
				|  |  |              return true
 | 
	
		
			
				|  |  |            } catch (error) {
 | 
	
	
		
			
				|  | @@ -212,7 +221,6 @@ const FlowList = () => {
 | 
	
		
			
				|  |  |              return false
 | 
	
		
			
				|  |  |            }
 | 
	
		
			
				|  |  |          }}>
 | 
	
		
			
				|  |  | -        <ProFormText name="ID" hidden />
 | 
	
		
			
				|  |  |          <ProFormText name="name" label="名称" rules={[{ required: true }]} />
 | 
	
		
			
				|  |  |        </ModalForm>
 | 
	
		
			
				|  |  |      </PageContainer>
 |