NewUserModal.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558
  1. <template>
  2. <a-modal
  3. :title="title"
  4. :width="1600"
  5. :visible="visible"
  6. :maskClosable="false"
  7. :confirmLoading="confirmLoading"
  8. @ok="handleOk"
  9. @cancel="handleCancel">
  10. <a-spin :spinning="confirmLoading">
  11. <!-- 主表单区域 -->
  12. <a-form :form="form">
  13. <a-row>
  14. <a-col :span="8 ">
  15. <a-form-item label="姓名" :labelCol="labelCol" :wrapperCol="wrapperCol">
  16. <a-input v-decorator="[ 'realname', validatorRules.realname]" placeholder="请输入姓名"></a-input>
  17. </a-form-item>
  18. </a-col>
  19. <a-col :span="8 ">
  20. <a-form-item label="用户账号" :labelCol="labelCol" :wrapperCol="wrapperCol">
  21. <a-input v-decorator="[ 'username', validatorRules.username]" placeholder="请输入用户账号" disabled></a-input>
  22. </a-form-item>
  23. </a-col>
  24. <a-col :span="8 ">
  25. <a-form-item label="性别" :labelCol="labelCol" :wrapperCol="wrapperCol">
  26. <a-select v-decorator="['sex', validatorRules.sex]" placeholder="请选择性别" :getPopupContainer="trigger => trigger.parentNode || document.body">
  27. <a-select-option :value="1">男</a-select-option>
  28. <a-select-option :value="2">女</a-select-option>
  29. </a-select>
  30. </a-form-item>
  31. </a-col>
  32. </a-row>
  33. <a-row>
  34. <a-col :span="8 ">
  35. <a-form-item label="证件类型" :labelCol="labelCol" :wrapperCol="wrapperCol">
  36. <a-select v-decorator="['idType', validatorRules.idType]" placeholder="请选择证件类型" :getPopupContainer="trigger => trigger.parentNode || document.body">
  37. <a-select-option value="身份证">身份证</a-select-option>
  38. <a-select-option value="其他">其他</a-select-option>
  39. </a-select>
  40. </a-form-item>
  41. </a-col>
  42. <a-col :span="8 ">
  43. <a-form-item label="证件号码" :labelCol="labelCol" :wrapperCol="wrapperCol">
  44. <a-input v-decorator="[ 'idNo', validatorRules.idNo]" placeholder="请输入证件号码"></a-input>
  45. </a-form-item>
  46. </a-col>
  47. <a-col :span="8 ">
  48. <a-form-item label="生日" :labelCol="labelCol" :wrapperCol="wrapperCol">
  49. <j-date placeholder="请选择生日" v-decorator="[ 'birthday', validatorRules.birthday]" :trigger-change="true" style="width: 100%"/>
  50. </a-form-item>
  51. </a-col>
  52. </a-row>
  53. <a-row>
  54. <a-col :span="8 ">
  55. <a-form-item label="入职日期" :labelCol="labelCol" :wrapperCol="wrapperCol">
  56. <j-date placeholder="请选择入职日期" v-decorator="[ 'joinDate', validatorRules.joinDate]" :trigger-change="true" style="width: 100%"/>
  57. </a-form-item>
  58. </a-col>
  59. <a-col :span="8 ">
  60. <a-form-item label="职务" :labelCol="labelCol" :wrapperCol="wrapperCol">
  61. <j-select-position placeholder="请选择职务" :multiple="false" v-decorator="['post', validatorRules.post]" />
  62. </a-form-item>
  63. </a-col>
  64. <a-col :span="8 ">
  65. <a-form-item label="职级" :labelCol="labelCol" :wrapperCol="wrapperCol">
  66. <a-input v-decorator="[ 'postLevel', validatorRules.postLevel]" placeholder="请输入职级"></a-input>
  67. </a-form-item>
  68. </a-col>
  69. </a-row>
  70. <a-row>
  71. <a-col :span="8 ">
  72. <a-form-item label="学历" :labelCol="labelCol" :wrapperCol="wrapperCol">
  73. <a-select v-decorator="['education', validatorRules.education]" placeholder="请选择学历" :getPopupContainer="trigger => trigger.parentNode || document.body">
  74. <a-select-option value="大专">大专</a-select-option>
  75. <a-select-option value="本科">本科</a-select-option>
  76. <a-select-option value="硕士">硕士</a-select-option>
  77. <a-select-option value="博士">博士</a-select-option>
  78. </a-select>
  79. </a-form-item>
  80. </a-col>
  81. <a-col :span="8 ">
  82. <a-form-item label="岗位类型" :labelCol="labelCol" :wrapperCol="wrapperCol">
  83. <a-select v-decorator="['positionType', validatorRules.positionType]" placeholder="请选择岗位类型" :getPopupContainer="trigger => trigger.parentNode || document.body">
  84. <a-select-option value="管理类">管理类</a-select-option>
  85. <a-select-option value="专技类">专技类</a-select-option>
  86. </a-select>
  87. </a-form-item>
  88. </a-col>
  89. <a-col :span="8 ">
  90. <a-form-item label="部门" :labelCol="labelCol" :wrapperCol="wrapperCol">
  91. <j-select-depart v-decorator="['departIds', validatorRules.departIds]" :trigger-change="true"/>
  92. </a-form-item>
  93. </a-col>
  94. </a-row>
  95. <a-row>
  96. <a-col :span="8 ">
  97. <a-form-item label="手机号码" :labelCol="labelCol" :wrapperCol="wrapperCol">
  98. <a-input v-decorator="[ 'mobile', validatorRules.mobile]" placeholder="请输入手机号码"></a-input>
  99. </a-form-item>
  100. </a-col>
  101. <a-col :span="8 ">
  102. <a-form-item label="座机" :labelCol="labelCol" :wrapperCol="wrapperCol">
  103. <a-input v-decorator="[ 'phone', validatorRules.phone]" placeholder="请输入座机"></a-input>
  104. </a-form-item>
  105. </a-col>
  106. <a-col :span="8 ">
  107. <a-form-item label="联系地址" :labelCol="labelCol" :wrapperCol="wrapperCol">
  108. <a-input v-decorator="[ 'address', validatorRules.address]" placeholder="请输入联系地址"></a-input>
  109. </a-form-item>
  110. </a-col>
  111. </a-row>
  112. <a-row>
  113. <a-col :span="8 ">
  114. <a-form-item label="试用结束日期" :labelCol="labelCol" :wrapperCol="wrapperCol">
  115. <j-date placeholder="请选择试用结束日期" v-decorator="[ 'probationEnd', validatorRules.probationEnd]" :trigger-change="true" style="width: 100%"/>
  116. </a-form-item>
  117. </a-col>
  118. <a-col :span="8 ">
  119. <a-form-item label="合同起始日期" :labelCol="labelCol" :wrapperCol="wrapperCol">
  120. <j-date placeholder="请选择合同起始日期" @change="changeStartTime" v-decorator="[ 'contractStart', validatorRules.contractStart]" :trigger-change="true" style="width: 100%"/>
  121. </a-form-item>
  122. </a-col>
  123. <a-col :span="8 ">
  124. <a-form-item label="合同结束日期" :labelCol="labelCol" :wrapperCol="wrapperCol">
  125. <j-date placeholder="请选择合同结束日期" @change="changeEndTime" v-decorator="[ 'contractEnd', validatorRules.contractEnd]" :trigger-change="true" style="width: 100%"/>
  126. </a-form-item>
  127. </a-col>
  128. </a-row>
  129. <a-row>
  130. <a-col :span="8 ">
  131. <a-form-item label="身份" :labelCol="labelCol" :wrapperCol="wrapperCol">
  132. <a-radio-group v-decorator="[ 'identity', validatorRules.identity]">
  133. <a-radio :value="1">普通用户</a-radio>
  134. <a-radio :value="2">上级</a-radio>
  135. </a-radio-group>
  136. </a-form-item>
  137. </a-col>
  138. <a-col :span="8 ">
  139. <a-form-item label="备注" :labelCol="labelCol" :wrapperCol="wrapperCol">
  140. <a-input v-decorator="[ 'remark', validatorRules.remark]" placeholder="请输入备注"></a-input>
  141. </a-form-item>
  142. </a-col>
  143. <a-col :span="8 ">
  144. <a-form-item label="签字图片" :labelCol="labelCol" :wrapperCol="wrapperCol">
  145. <j-upload v-decorator="['signature', validatorRules.signature]" fileType="image" :trigger-change="true"></j-upload>
  146. </a-form-item>
  147. </a-col>
  148. </a-row>
  149. <a-row>
  150. <a-col :span="8 ">
  151. <a-form-item label="附件" :labelCol="labelCol" :wrapperCol="wrapperCol">
  152. <j-upload v-decorator="['attachment', validatorRules.attachment]" fileType="file" :trigger-change="true"></j-upload>
  153. </a-form-item>
  154. </a-col>
  155. </a-row>
  156. </a-form>
  157. <!-- 子表单区域 -->
  158. <a-tabs v-model="activeKey" @change="handleChangeTabs">
  159. <a-tab-pane tab="联系人" :key="refKeys[0]" :forceRender="true">
  160. <j-editable-table
  161. :ref="refKeys[0]"
  162. :loading="sysUserContactTable.loading"
  163. :columns="sysUserContactTable.columns"
  164. :dataSource="sysUserContactTable.dataSource"
  165. :maxHeight="300"
  166. :rowNumber="true"
  167. :rowSelection="true"
  168. :actionButton="true"/>
  169. </a-tab-pane>
  170. <a-tab-pane tab="工作经历" :key="refKeys[1]" :forceRender="true">
  171. <j-editable-table
  172. :ref="refKeys[1]"
  173. :loading="sysUserJobTable.loading"
  174. :columns="sysUserJobTable.columns"
  175. :dataSource="sysUserJobTable.dataSource"
  176. :maxHeight="300"
  177. :rowNumber="true"
  178. :rowSelection="true"
  179. :actionButton="true"/>
  180. </a-tab-pane>
  181. <a-tab-pane tab="学习经历" :key="refKeys[2]" :forceRender="true">
  182. <j-editable-table
  183. :ref="refKeys[2]"
  184. :loading="sysUserEduTable.loading"
  185. :columns="sysUserEduTable.columns"
  186. :dataSource="sysUserEduTable.dataSource"
  187. :maxHeight="300"
  188. :rowNumber="true"
  189. :rowSelection="true"
  190. :actionButton="true"/>
  191. </a-tab-pane>
  192. </a-tabs>
  193. </a-spin>
  194. </a-modal>
  195. </template>
  196. <script>
  197. import pick from 'lodash.pick'
  198. import { FormTypes,getRefPromise } from '@/utils/JEditableTableUtil'
  199. import { JEditableTableMixin } from '@/mixins/JEditableTableMixin'
  200. import { validateDuplicateValue } from '@/utils/util'
  201. import JDate from '@/components/jeecg/JDate'
  202. import JUpload from '@/components/jeecg/JUpload'
  203. import JSelectDepart from '@/components/jeecgbiz/JSelectDepart'
  204. import JDictSelectTag from "@/components/dict/JDictSelectTag"
  205. import JSelectPosition from '@/components/jeecgbiz/JSelectPosition'
  206. export default {
  207. name: 'SysUserModal',
  208. mixins: [JEditableTableMixin],
  209. components: {
  210. JDate,
  211. JUpload,
  212. JSelectDepart,
  213. JDictSelectTag,
  214. JSelectPosition
  215. },
  216. data() {
  217. return {
  218. labelCol: {
  219. span: 6
  220. },
  221. wrapperCol: {
  222. span: 16
  223. },
  224. labelCol2: {
  225. span: 3
  226. },
  227. wrapperCol2: {
  228. span: 20
  229. },
  230. // 新增时子表默认添加几行空数据
  231. addDefaultRowNum: 1,
  232. validatorRules: {
  233. operator: {rules: [
  234. {required: true, message: '请输入登记人 !'},
  235. ]},
  236. operatorDept: {rules: [
  237. ]},
  238. operateDate: {rules: [
  239. {required: true, message: '请输入登记日期!'},
  240. ]},
  241. realname: {rules: [
  242. ]},
  243. username: {rules: [
  244. ]},
  245. sex: {rules: [
  246. {required: true, message: '请输入性别!'},
  247. ]},
  248. idType: {rules: [
  249. {required: true, message: '请输入证件类型!'},
  250. ]},
  251. idNo: {rules: [
  252. {required: true, message: '请输入证件号码!'},{validator: this.validateIdCard}
  253. ]},
  254. birthday: {rules: [
  255. {required: true, message: '请输入生日!'},
  256. ]},
  257. joinDate: {rules: [
  258. {required: true, message: '请输入入职日期!'},
  259. ]},
  260. post: {rules: [
  261. {required: true, message: '请输入职务!'},
  262. ]},
  263. postLevel: {rules: [
  264. {required: true, message: '请输入职级!'},
  265. ]},
  266. education: {rules: [
  267. {required: true, message: '请选择学历!'},
  268. ]},
  269. positionType: {rules: [
  270. {required: true, message: '请输入岗位类型!'},
  271. ]},
  272. departIds: {rules: [
  273. {required: true, message: '请输入部门!'},
  274. ]},
  275. mobile: {rules: [
  276. { validator: this.validatePhone }
  277. ]},
  278. phone: {rules: [
  279. { pattern: /^0\d{2,3}-[1-9]\d{6,7}$/, message: '请输入正确的座机号码' }
  280. ]},
  281. address: {rules: [
  282. ]},
  283. probationEnd: {rules: [
  284. {required: true, message: '请输入试用结束日期!'},
  285. ]},
  286. contractStart: {rules: [
  287. {required: true, message: '请输入合同起始日期!'},
  288. ]},
  289. contractEnd: {rules: [
  290. {required: true, message: '请输入合同结束日期!'},
  291. ]},
  292. remark: {rules: [
  293. ]},
  294. identity: {rules: [
  295. ]},
  296. signature: {rules: [
  297. ]},
  298. attachment: {rules: [
  299. ]},
  300. },
  301. refKeys: ['sysUserContact','sysUserJob', 'sysUserEdu', ],
  302. tableKeys:['sysUserContact', 'sysUserJob', 'sysUserEdu', ],
  303. activeKey: 'sysUserJob',
  304. // 人员管理工作经历
  305. sysUserJobTable: {
  306. loading: false,
  307. dataSource: [],
  308. columns: [
  309. {
  310. title: '单位',
  311. key: 'company',
  312. type: FormTypes.input,
  313. width:"200px",
  314. placeholder: '请输入${title}',
  315. defaultValue: '',
  316. },
  317. {
  318. title: '职位',
  319. key: 'position',
  320. type: FormTypes.input,
  321. width:"200px",
  322. placeholder: '请输入${title}',
  323. defaultValue: '',
  324. },
  325. {
  326. title: '起始日期',
  327. key: 'startDate',
  328. type: FormTypes.date,
  329. width:"200px",
  330. placeholder: '请输入${title}',
  331. defaultValue: '',
  332. },
  333. {
  334. title: '截止日期',
  335. key: 'endDate',
  336. type: FormTypes.date,
  337. width:"200px",
  338. placeholder: '请输入${title}',
  339. defaultValue: '',
  340. },
  341. ]
  342. },
  343. // 人员管理联系人
  344. sysUserContactTable: {
  345. loading: false,
  346. dataSource: [],
  347. columns: [
  348. {
  349. title: '姓名',
  350. key: 'name',
  351. type: FormTypes.input,
  352. width:"200px",
  353. placeholder: '请输入${title}',
  354. defaultValue: '',
  355. },
  356. {
  357. title: '关系',
  358. key: 'relation',
  359. type: FormTypes.input,
  360. width:"200px",
  361. placeholder: '请输入${title}',
  362. defaultValue: '',
  363. },
  364. {
  365. title: '性别',
  366. key: 'sex',
  367. width:"200px",
  368. placeholder: '请输入${title}',
  369. defaultValue: '',
  370. type: FormTypes.select,
  371. options: [ // 下拉选项
  372. { title: '男', value: '1' },
  373. { title: '女', value: '2' },
  374. ],
  375. },
  376. {
  377. title: '联系方式',
  378. key: 'phone',
  379. type: FormTypes.input,
  380. width:"200px",
  381. placeholder: '请输入${title}',
  382. defaultValue: '',
  383. },
  384. {
  385. title: '职业',
  386. key: 'career',
  387. type: FormTypes.input,
  388. width:"200px",
  389. placeholder: '请输入${title}',
  390. defaultValue: '',
  391. },
  392. ]
  393. },
  394. // 人员管理学习经历
  395. sysUserEduTable: {
  396. loading: false,
  397. dataSource: [],
  398. columns: [
  399. {
  400. title: '学校',
  401. key: 'school',
  402. type: FormTypes.input,
  403. width:"200px",
  404. placeholder: '请输入${title}',
  405. defaultValue: '',
  406. },
  407. {
  408. title: '起始日期',
  409. key: 'startDate',
  410. type: FormTypes.date,
  411. width:"200px",
  412. placeholder: '请输入${title}',
  413. defaultValue: '',
  414. },
  415. {
  416. title: '截止日期',
  417. key: 'endDate',
  418. type: FormTypes.date,
  419. width:"200px",
  420. placeholder: '请输入${title}',
  421. defaultValue: '',
  422. },
  423. ]
  424. },
  425. url: {
  426. add: "/sys/user/add",
  427. edit: "/sys/user/editNew",
  428. sysUserJob: {
  429. list: '/sys/user/querySysUserJobByMainId'
  430. },
  431. sysUserContact: {
  432. list: '/sys/user/querySysUserContactByMainId'
  433. },
  434. sysUserEdu: {
  435. list: '/sys/user/querySysUserEduByMainId'
  436. },
  437. }
  438. }
  439. },
  440. methods: {
  441. getAllTable() {
  442. let values = this.tableKeys.map(key => getRefPromise(this, key))
  443. return Promise.all(values)
  444. },
  445. validateIdCard(rule, value, callback) {
  446. if (!value || new RegExp(/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/).test(value)) {
  447. callback();
  448. } else {
  449. callback("您的身份证号码格式不正确!");
  450. }
  451. },
  452. validatePhone (rule, value, callback) {
  453. if (!value) {
  454. callback()
  455. } else {
  456. // update-begin--Author:kangxiaolin Date:20190826 for:[05] 手机号不支持199号码段--------------------
  457. if (new RegExp(/^1[3|4|5|7|8|9][0-9]\d{8}$/).test(value)) {
  458. // update-end--Author:kangxiaolin Date:20190826 for:[05] 手机号不支持199号码段--------------------
  459. // var params = {
  460. // tableName: 'sys_user',
  461. // fieldName: 'phone',
  462. // fieldVal: value,
  463. // dataId: this.userId
  464. // }
  465. // duplicateCheck(params).then(res => {
  466. // if (res.success) {
  467. // callback()
  468. // } else {
  469. // callback('手机号已存在!')
  470. // }
  471. // })
  472. } else {
  473. callback('请输入正确格式的手机号码!')
  474. }
  475. }
  476. },
  477. /** 调用完edit()方法之后会自动调用此方法 */
  478. editAfter() {
  479. let fieldval = pick(this.model,'operator','operatorDept','operateDate','realname','username','sex','idType','idNo','birthday','joinDate','post','postLevel','education','positionType','departIds','mobile','phone','address','probationEnd','contractStart','contractEnd','remark','identity','signature','attachment')
  480. this.$nextTick(() => {
  481. this.form.setFieldsValue(fieldval)
  482. })
  483. // 加载子表数据
  484. if (this.model.id) {
  485. let params = { id: this.model.id }
  486. this.requestSubTableData(this.url.sysUserJob.list, params, this.sysUserJobTable)
  487. this.requestSubTableData(this.url.sysUserContact.list, params, this.sysUserContactTable)
  488. this.requestSubTableData(this.url.sysUserEdu.list, params, this.sysUserEduTable)
  489. }
  490. },
  491. /** 整理成formData */
  492. classifyIntoFormData(allValues) {
  493. let main = Object.assign(this.model, allValues.formValue)
  494. return {
  495. ...main, // 展开
  496. sysUserContactList: allValues.tablesValue[0].values,
  497. sysUserJobList: allValues.tablesValue[1].values,
  498. sysUserEduList: allValues.tablesValue[2].values,
  499. }
  500. },
  501. validateError(msg){
  502. this.$message.error(msg)
  503. },
  504. popupCallback(row){
  505. this.form.setFieldsValue(pick(row,'operator','operatorDept','operateDate','realname','username','sex','idType','idNo','birthday','joinDate','post','postLevel','education','positionType','departIds','mobile','phone','address','probationEnd','contractStart','contractEnd','remark','identity','signature','attachment'))
  506. },
  507. changeStartTime(data){
  508. var end = new Date((this.form.getFieldValue('contractEnd')).replace(/\-/g, "\/"));
  509. var start = new Date(data.replace(/\-/g, "\/"));
  510. if(this.form.getFieldValue('contractEnd')!=""&&data!=""&&start >=end)
  511. {
  512. this.$nextTick(() => {
  513. this.form.setFieldsValue({contractStart: '' })
  514. this.$forceUpdate()
  515. })
  516. this.$message.error("合同开始时间不能大于合同结束时间!")
  517. return false;
  518. }
  519. },
  520. changeEndTime(data){
  521. var start = new Date((this.form.getFieldValue('contractStart')).replace(/\-/g, "\/"));
  522. var end = new Date(data.replace(/\-/g, "\/"));
  523. if(this.form.getFieldValue('contractStart')!=""&&data!=""&&start >=end)
  524. {
  525. this.$nextTick(() => {
  526. this.form.setFieldsValue({contractEnd: '' })
  527. this.$forceUpdate()
  528. })
  529. this.$message.error("合同开始时间不能大于合同结束时间!")
  530. return false;
  531. }
  532. }
  533. }
  534. }
  535. </script>
  536. <style scoped lang="less">
  537. /deep/ .ant-form-item-control {
  538. height: 40px;
  539. display: contents;
  540. }
  541. </style>