BaseView.jsx 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  1. import React, { useState, useEffect, useRef } from 'react'
  2. import { Col, message, Row, Tabs } from 'antd'
  3. import ProForm, { ProFormDatePicker, ProFormSelect, ProFormRadio, ProFormText } from '@ant-design/pro-form'
  4. import styles from './BaseView.less'
  5. import {
  6. educationOptions,
  7. householdRegistrationOptions,
  8. marriageOptions
  9. } from '@/components/EditableForm/src/useOptions'
  10. import { queryStaffOwner, updateBaseStaff, updateFinanceStaff } from '@/services/user'
  11. import consts from '@/consts'
  12. import AvatarView from './AvatarView'
  13. import { isDevMode } from '@/utils/env'
  14. import dayjs from 'dayjs'
  15. import { Button } from 'antd'
  16. import { Affix } from 'antd'
  17. const { TabPane } = Tabs
  18. // const validatorPhone = (rule, value, callback) => {
  19. // if (!value[0]) {
  20. // callback('Please input your area code!')
  21. // }
  22. // if (!value[1]) {
  23. // callback('Please input your phone number!')
  24. // }
  25. // callback()
  26. // }
  27. const BaseView = () => {
  28. const baseRef = useRef(null)
  29. const [staff, setStaff] = useState(null)
  30. const layout = {
  31. layout: 'horizontal',
  32. labelCol: { flex: '120px' }
  33. }
  34. useEffect(() => {
  35. async function initData() {
  36. const { code = -1, data = {} } = await queryStaffOwner()
  37. if (code === consts.RET_CODE.SUCCESS) {
  38. const staffData = data?.staff || {}
  39. setStaff(staffData)
  40. baseRef.current?.setFieldsValue({
  41. ...staffData,
  42. graduationTime: staffData.graduationTime ? staffData.graduationTime : dayjs(new Date()),
  43. birthday: staffData.birthday ? staffData.birthday : dayjs(new Date())
  44. })
  45. }
  46. }
  47. initData()
  48. }, [])
  49. const avatar =
  50. (isDevMode() ? 'http://cld2qa.com' : 'http://127.0.0.1') +
  51. (staff?.avatar ?? '/resource/avatar/avtra_2.jpg')
  52. return (
  53. <Tabs defaultActiveKey="1">
  54. <TabPane tab="基本信息" key="1">
  55. <div className={styles.baseView}>
  56. <div className={styles.left}>
  57. <ProForm
  58. {...layout}
  59. formRef={baseRef}
  60. onFinish={async values => {
  61. const { code = -1 } = await updateBaseStaff(values)
  62. if (code === consts.RET_CODE.SUCCESS) {
  63. message.success('更新成功')
  64. }
  65. return true
  66. }}
  67. submitter={{
  68. resetButtonProps: false,
  69. // submitButtonProps: {
  70. // className: 'ml-120px'
  71. // }
  72. render: props => {
  73. return [
  74. <Affix key="affix" offsetBottom={50}>
  75. <Button
  76. type="primary"
  77. key="submit"
  78. className="ml-120px"
  79. onClick={() => props.form?.submit?.()}>
  80. 提交
  81. </Button>
  82. </Affix>
  83. ]
  84. }
  85. }}>
  86. <ProFormText name="avatar" hidden />
  87. <Row>
  88. <Col span={24} xl={12}>
  89. <ProFormText disabled name="jobNumber" label="工号" placeholder="" />
  90. <ProFormText disabled name="departmentName" label="办事处/部门" placeholder="" />
  91. <ProFormText disabled name="birthday" label="入职日期" placeholder="" />
  92. <ProFormText name="qq" label="QQ" rules={[{ required: true, message: '请输入QQ号码' }]} />
  93. <ProFormText
  94. name="phone"
  95. label="电话"
  96. rules={[{ required: true, message: '请输入电话号码' }]}
  97. />
  98. <ProFormRadio.Group
  99. options={['男', '女']}
  100. name="gender"
  101. label="性别"
  102. rules={[{ required: true, message: '请选择性别' }]}
  103. />
  104. <ProFormText name="nation" label="民族" placeholder="" />
  105. <ProFormText name="graduateInstitutions" label="毕业院校" placeholder="" />
  106. <ProFormSelect
  107. name="education"
  108. label="毕业学历"
  109. options={educationOptions}
  110. placeholder=""
  111. />
  112. <ProFormSelect
  113. name="qualifications"
  114. label="最高学历"
  115. options={educationOptions}
  116. rules={[{ required: true, message: '请选择最高学历' }]}
  117. />
  118. </Col>
  119. <Col span={24} xl={12}>
  120. <ProFormText disabled name="username" label="姓名" />
  121. <ProFormText disabled name="position" label="岗位" />
  122. <ProFormText name="telephone" label="手机" />
  123. <ProFormText name="wecat" label="微信" placeholder="" />
  124. <ProFormText name="email" label="邮箱" placeholder="" />
  125. <ProFormDatePicker
  126. name="birthday"
  127. label="出生日期"
  128. initialValue={dayjs(new Date())}
  129. rules={[{ required: true, message: '请输入出生日期' }]}
  130. />
  131. <ProFormSelect
  132. name="marriage"
  133. options={marriageOptions}
  134. label="婚姻状况"
  135. rules={[{ required: true, message: '请选择婚姻状况' }]}
  136. />
  137. <ProFormText name="major" label="所学专业" placeholder="" />
  138. <ProFormDatePicker
  139. name="graduationTime"
  140. label="毕业时间"
  141. placeholder=""
  142. rules={[{ required: true, message: '请输入毕业时间' }]}
  143. />
  144. </Col>
  145. </Row>
  146. <Row>
  147. <Col span={24} xl={12}>
  148. <ProFormText name="registeredResidence" label="户口所在地" placeholder="" />
  149. </Col>
  150. <Col span={24} xl={12}>
  151. <ProFormSelect
  152. name="householdRegistrationType"
  153. label="户籍类型"
  154. options={householdRegistrationOptions}
  155. placeholder=""
  156. />
  157. </Col>
  158. </Row>
  159. <ProFormText
  160. name="living"
  161. label="现居住地"
  162. rules={[{ required: true, message: '请输入现居住地' }]}
  163. />
  164. <Row>
  165. <Col span={24} xl={12}>
  166. <ProFormText
  167. name="nativePlace"
  168. label="籍贯"
  169. rules={[{ required: true, message: '请输入籍贯' }]}
  170. />
  171. </Col>
  172. <Col span={24} xl={12}>
  173. <ProFormText
  174. name="emergencyContacts"
  175. label="紧急联系人"
  176. rules={[{ required: true, message: '请输入紧急联系人' }]}
  177. />
  178. </Col>
  179. </Row>
  180. </ProForm>
  181. </div>
  182. <div className={styles.right}>
  183. <AvatarView
  184. avatar={avatar}
  185. setAvatar={avatar2 => baseRef?.current.setFieldsValue({ avatar: avatar2 })}
  186. />
  187. </div>
  188. </div>
  189. </TabPane>
  190. {/* <TabPane tab="证件信息" key="2">
  191. <div className={styles.baseView}>
  192. <div className="w-1/2">
  193. <ProForm
  194. {...layout}
  195. submitter={{
  196. resetButtonProps: false
  197. }}
  198. >
  199. <ProFormText name="IDcards" label="身份证号码" required />
  200. <ProFormText
  201. name="IDcardsValidity"
  202. label="身份证有效期"
  203. rules={[{ required: true, message: '请输入身份证有效期' }]}
  204. />
  205. <ProFormUploadButton
  206. name="IDcardsImgA"
  207. label="正面(国徽)"
  208. rules={[{ required: true, message: '请上传身份证正面(国徽)' }]}
  209. />
  210. <ProFormUploadButton
  211. name="IDcardsImgB"
  212. labelCol={{ span: 24 }}
  213. label="反面(照片)"
  214. rules={[{ required: true, message: '请上传身份证反面(照片)' }]}
  215. />
  216. <ProFormUploadDragger
  217. name="certificate"
  218. labelCol={{ span: 24 }}
  219. label="毕业证书"
  220. rules={[{ required: true, message: '请上传毕业证书' }]}
  221. />
  222. <ProFormUploadDragger name="diploma" labelCol={{ span: 24 }} label="学历证书" />
  223. <ProFormUploadDragger
  224. name="professionalTitle"
  225. labelCol={{ span: 24 }}
  226. label="职称证书"
  227. />
  228. </ProForm>
  229. </div>
  230. </div>
  231. </TabPane> */}
  232. <TabPane tab="财务信息" key="3">
  233. <div className={styles.baseView}>
  234. <div className="w-3/4">
  235. <ProForm
  236. layout="horizontal"
  237. labelCol={{ flex: '150px' }}
  238. onFinish={async values => {
  239. const { code = -1 } = await updateFinanceStaff(values)
  240. if (code === consts.RET_CODE.SUCCESS) {
  241. message.success('更新成功')
  242. }
  243. return true
  244. }}
  245. submitter={{
  246. resetButtonProps: false,
  247. submitButtonProps: {
  248. className: 'ml-150px'
  249. }
  250. }}
  251. initialValues={{ ...staff }}>
  252. {/* <ProFormGroup title="报销收款帐号"> */}
  253. <h4 className="mb-4 font-bold">报销收款帐号</h4>
  254. <Row>
  255. <Col span={24} xl={12}>
  256. <ProFormText
  257. name="remittanceName"
  258. label="收款人户名"
  259. rules={[{ required: true, message: '请输入收款人户名' }]}
  260. />
  261. <ProFormText
  262. name="bankName"
  263. label="收款开户银行名称"
  264. rules={[{ required: true, message: '请输入收款开户银行名称' }]}
  265. />
  266. </Col>
  267. <Col span={24} xl={12}>
  268. <ProFormText
  269. name="coupletNumber"
  270. label="联行号"
  271. tooltip={
  272. <div>
  273. <p>1.如果不是公司广发,务必填上银行联行号</p>
  274. <p>2.如不清楚银行联行号请咨询报销查款专用 QQ:2870766094</p>
  275. </div>
  276. }
  277. />
  278. <ProFormText
  279. name="bankNumber"
  280. label="收款帐号"
  281. rules={[{ required: true, message: '请输入收款账号' }]}
  282. />
  283. </Col>
  284. </Row>
  285. {/* </ProFormGroup> */}
  286. <h4 className="mb-4 font-bold">工资卡</h4>
  287. {/* <ProFormGroup title="工资卡"> */}
  288. <Row>
  289. <Col span={24} xl={12}>
  290. <ProFormText
  291. name="salaryCard"
  292. label="银行卡号"
  293. rules={[{ required: true, message: '请输入银行卡号' }]}
  294. />
  295. </Col>
  296. <Col span={24} xl={12}>
  297. <ProFormText
  298. name="salaryBankName"
  299. label="开户行"
  300. rules={[{ required: true, message: '请输入开户行' }]}
  301. />
  302. </Col>
  303. </Row>
  304. {/* </ProFormGroup> */}
  305. </ProForm>
  306. </div>
  307. </div>
  308. </TabPane>
  309. </Tabs>
  310. )
  311. }
  312. export default BaseView