SealList.jsx 6.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. import React, { useState, useEffect } from 'react';
  2. import { Input, Menu, Dropdown, Button, Icon, message, Table, Divider, Tag, Select, Form, Alert, Tabs, Row, Col, Radio, tab, Avatar, Modal, Pagination } from 'antd';
  3. import { FormattedMessage } from 'umi-plugin-react/locale';
  4. import XForm, { FieldTypes } from '../../../../components/XForm';
  5. import router from 'umi/router';
  6. import apis from '../../../../services/apis';
  7. import request from '../../../../utils/request';
  8. import Wangedit from '../../../../components/Wangedit/Wangedit'
  9. import moment from 'moment';
  10. import AddSeal from './AddSeal';
  11. import UpdateSeal from './UpdateSeal';
  12. const { TabPane } = Tabs;
  13. const header = props => {
  14. const companyId = props.companyId;
  15. const [ data, setData ] = useState({})
  16. const [sealData, setSealData] = useState({})
  17. const [sealInfo, setSealInfo] = useState({visable: false, companyId: ''})
  18. const [updateSeal, setUpdateSeal] = useState({visable: false, companyId: '', sealId: ''})
  19. useEffect(() => {
  20. getCompanyData({companyId: companyId});
  21. },[])
  22. // 查询列表
  23. function getCompanyData(params) {
  24. request({ ...apis.seal.listByCompanyId, params: { ...params } }).then((data) => {
  25. setData(data)
  26. }).catch((err) => {
  27. message.error(err.msg || err.message)
  28. })
  29. }
  30. const changePageNum = (pageNumber) => {
  31. let values = props.form.getFieldsValue()
  32. getCompanyData({ pageNum: pageNumber, pageSize: 10, ...values, companyId: companyId })
  33. }
  34. const openFddUrl = () => {
  35. window.open(data.certifiedAddress)
  36. }
  37. // 提交事件
  38. const handleSubmit = e => {
  39. e.preventDefault();
  40. props.form.validateFields((err, values) => {
  41. if (!err) {
  42. getCompanyData({ pageNumber: 1, pageSize: 10, ...values, companyId: companyId })
  43. }
  44. });
  45. }
  46. // 重置搜索
  47. function handleReset () {
  48. props.form.resetFields();
  49. getCompanyData({companyId: companyId});
  50. }
  51. function back(){
  52. router.go(-1)
  53. }
  54. function addSealInfo(){
  55. setSealInfo({visable: true, companyId: companyId})
  56. }
  57. function updateSealInfo(e){
  58. setUpdateSeal(e);
  59. }
  60. function getList(e) {
  61. setSealInfo(e)
  62. getCompanyData(e)
  63. }
  64. function updateOnSuccess(e) {
  65. setUpdateSeal(e);
  66. getCompanyData(e)
  67. }
  68. function updateOnCancel(e) {
  69. console.log(e, 'cancel')
  70. setUpdateSeal(e);
  71. getCompanyData({companyId: e.companyId})
  72. }
  73. const delSealInfo = (row) => {
  74. Modal.confirm({
  75. title: '删除后无法再使用这些章继续签章,不会影响已签署的合同',
  76. okText: '确定',
  77. cancelText: '取消',
  78. onOk() {
  79. request({ ...apis.seal.delSealById, urlData:{id: row.sealId} }).then((data) => {
  80. message.info('操作成功!')
  81. getCompanyData({ pageNum: 1, pageSize: 10, companyId: companyId })
  82. }).catch((err) => {
  83. console.log(err)
  84. message.info(err.msg || err.message)
  85. })
  86. },
  87. });
  88. }
  89. const columns = [
  90. {
  91. title: '印章编号',
  92. dataIndex: 'sealId',
  93. key: 'sealId',
  94. align: 'center',
  95. },
  96. {
  97. title: '印章名称',
  98. dataIndex: 'sealName',
  99. key: 'sealName',
  100. align: 'center',
  101. },
  102. {
  103. title: '印章图',
  104. dataIndex: 'sealImg',
  105. key: 'sealImg',
  106. align: 'center',
  107. render: (_, record) => <Avatar shape="square" style={{color: 'blue',cursor: 'pointer'}} src={record.sealImg} size={64} icon="user" />,
  108. },
  109. {
  110. title: '印章上传时间',
  111. dataIndex: 'createDate',
  112. key: 'createDate',
  113. align: 'center',
  114. render: (x, row) => <><span>{row.createDate != null ? `${moment(row.createDate).format('YYYY-MM-DD HH:mm:ss')}` : ''}</span></>,
  115. },
  116. {
  117. title: '操作',
  118. dataIndex: '',
  119. key: '',
  120. align: 'center',
  121. render: (text, record) => (
  122. <>
  123. <a style={{ color: '#66B3FF' }} onClick={() => updateSealInfo({visable:true, companyId: record.companyId, sealId: record.sealId})} ><span>修改</span></a>
  124. <a style={{ color: '#66B3FF', marginLeft:'20px' }} onClick={() => delSealInfo(record)} ><span>删除</span></a>
  125. </>
  126. ),
  127. },
  128. ]
  129. const { getFieldDecorator } = props.form
  130. return (
  131. <>
  132. <Form layout="inline" onSubmit={e => handleSubmit(e)}>
  133. <Form.Item>
  134. {getFieldDecorator('sealName')(
  135. <Input placeholder="印章名称"/>,
  136. )}
  137. </Form.Item>
  138. <Form.Item>
  139. <Button type="primary" htmlType="submit" >
  140. 搜索
  141. </Button>
  142. <Button style={{ marginLeft: 8 }} onClick={handleReset}>
  143. 重置
  144. </Button>
  145. </Form.Item>
  146. </Form>
  147. <div style={{marginTop:'20px', marginBottom:'20px'}}>
  148. <Button type="danger" onClick={() => addSealInfo({visable:true})} >新增</Button>
  149. <Button style={{marginLeft:'20px'}} onClick={() => back()} >返回</Button>
  150. </div>
  151. <AddSeal visible={sealInfo.visable} companyId={sealInfo.companyId} onCancel={e => setSealInfo(e)} onSuccess={e => getList(e)}/>
  152. <UpdateSeal visible={updateSeal.visable} sealId={updateSeal.sealId} companyId={updateSeal.companyId} onCancel={e => updateOnCancel(e)} onSuccess={e => updateOnSuccess(e)}/>
  153. <Table dataSource={data.records} columns={columns} pagination={false} rowKey="carouseFigureList"/>
  154. <div style={{ display: 'flex', justifyContent: 'flex-end', marginTop: '30px' }}>
  155. <Pagination showQuickJumper defaultCurrent={1} total={data.total} onChange={changePageNum} current={data.current}/>
  156. </div>
  157. </>
  158. )
  159. }
  160. const WrappedNormalLoginForm = Form.create({ name: 'header' })(header);
  161. export default WrappedNormalLoginForm