UserModal.vue 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997
  1. <template>
  2. <a-modal :width="1000" title="员工信息" :visible="visible" @ok="handleSubmit()" @cancel="handleCancel" cancelText="关闭">
  3. <template slot="title">
  4. <div style="width: 100%;">
  5. <span>{{ title }}</span>
  6. <span style="display:inline-block;width:calc(100% - 51px);padding-right:10px;text-align: right">
  7. <a-button @click="toggleScreen" icon="appstore" style="height:20px;width:20px;border:0px"></a-button>
  8. </span>
  9. </div>
  10. </template>
  11. <a-spin :spinning="confirmLoading">
  12. <a-form :form="form">
  13. <a-row>
  14. <a-col :md="6" :sm="8" :lg="12">
  15. <a-form-item label="员工姓名" :labelCol="labelCol" :wrapperCol="wrapperCol">
  16. <a-input placeholder="请输入员工姓名" v-decorator="[ 'realname', validatorRules.realname]" />
  17. </a-form-item>
  18. </a-col>
  19. <a-col :md="6" :sm="8" :lg="12">
  20. <a-form-item label="英文名" :labelCol="labelCol" :wrapperCol="wrapperCol">
  21. <a-input placeholder="请输入英文名" v-decorator="[ 'egName', validatorRules.egName]" />
  22. </a-form-item>
  23. </a-col>
  24. </a-row>
  25. <a-row>
  26. <a-col :md="6" :sm="8" :lg="12">
  27. <a-form-item label="邮箱" :labelCol="labelCol" :wrapperCol="wrapperCol">
  28. <a-input placeholder="请输入邮箱" v-decorator="[ 'email', validatorRules.email]" />
  29. </a-form-item>
  30. </a-col>
  31. <a-col :md="6" :sm="8" :lg="12">
  32. <a-form-item label="身份证号码" :labelCol="labelCol" :wrapperCol="wrapperCol">
  33. <a-input maxLength="18" placeholder="请输入身份证号码" v-decorator="[ 'sfzCode', validatorRules.sfzCode]" />
  34. </a-form-item>
  35. </a-col>
  36. </a-row>
  37. <a-row>
  38. <a-col :md="6" :sm="8" :lg="12">
  39. <a-form-item label="性别" :labelCol="labelCol" :wrapperCol="wrapperCol">
  40. <a-select v-decorator="[ 'sex',validatorRules.sex]" placeholder="请选择性别"
  41. :getPopupContainer="(target) => target.parentNode">
  42. <a-select-option :value="1">男</a-select-option>
  43. <a-select-option :value="2">女</a-select-option>
  44. </a-select>
  45. </a-form-item>
  46. </a-col>
  47. <a-col :md="6" :sm="8" :lg="12">
  48. <a-form-item label="生日" :labelCol="labelCol" :wrapperCol="wrapperCol">
  49. <a-date-picker style="width: 100%" placeholder="请选择生日"
  50. v-decorator="['birthday', {initialValue:!model.birthday?null:moment(model.birthday,dateFormat)}]"
  51. :getCalendarContainer="node => node.parentNode" />
  52. </a-form-item>
  53. </a-col>
  54. </a-row>
  55. <a-row>
  56. <a-col :md="6" :sm="8" :lg="12">
  57. <a-form-item label="手机号码" :labelCol="labelCol" :wrapperCol="wrapperCol">
  58. <a-input placeholder="请输入手机号码" v-decorator="[ 'phone', validatorRules.phone]" />
  59. </a-form-item>
  60. </a-col>
  61. <a-col :md="6" :sm="8" :lg="12">
  62. <a-form-item label="公积金账号" :labelCol="labelCol" :wrapperCol="wrapperCol">
  63. <a-input-number placeholder="请输入公积金账号" style="width: 320px;" v-decorator="['syFund', {}]" />
  64. </a-form-item>
  65. </a-col>
  66. </a-row>
  67. <a-row>
  68. <a-col :md="6" :sm="8" :lg="12">
  69. <a-form-item label="银行账号" :labelCol="labelCol" :wrapperCol="wrapperCol">
  70. <a-input-number placeholder="请输入银行账号" style="width: 320px;" v-decorator="['bankCard', validatorRules.bankCard]" />
  71. </a-form-item>
  72. </a-col>
  73. <a-col :md="6" :sm="8" :lg="12">
  74. <a-form-item label="开户行" :labelCol="labelCol" :wrapperCol="wrapperCol">
  75. <a-input placeholder="请输入开户行" v-decorator="['bankAddr', {}]" />
  76. </a-form-item>
  77. </a-col>
  78. </a-row>
  79. <a-row>
  80. <a-col :md="6" :sm="8" :lg="12">
  81. <a-form-item label="入职日期" :labelCol="labelCol" :wrapperCol="wrapperCol">
  82. <a-date-picker style="width: 100%" placeholder="请选择入职日期"
  83. v-decorator="['entryDate', {initialValue:!model.entryDate?moment(new Date(),dateFormat):moment(model.entryDate,dateFormat)}]"
  84. :getCalendarContainer="node => node.parentNode" />
  85. </a-form-item>
  86. </a-col>
  87. <a-col :md="6" :sm="8" :lg="12">
  88. <a-form-item label="*部门分配" :labelCol="labelCol" :wrapperCol="wrapperCol" v-show="!departDisabled">
  89. <a-input-search placeholder="点击选择部门" v-model="checkedDepartNameString" readOnly @search="onSearch">
  90. <a-button slot="enterButton" icon="search">选择</a-button>
  91. </a-input-search>
  92. </a-form-item>
  93. </a-col>
  94. </a-row>
  95. <a-row>
  96. <a-col :md="6" :sm="8" :lg="12">
  97. <a-form-item label="基本工资一" :labelCol="labelCol" :wrapperCol="wrapperCol" >
  98. <a-input-number id="inputNumber" placeholder="请输入基本工资" style="width: 320px;" v-decorator="['wagesOne', {}]" />
  99. </a-form-item>
  100. </a-col>
  101. <a-col :md="6" :sm="8" :lg="12">
  102. <a-form-item label="基本工资二" :labelCol="labelCol" :wrapperCol="wrapperCol">
  103. <a-input-number placeholder="请输入基本工资" style="width: 320px;" v-decorator="['wagesTwo', {}]" />
  104. </a-form-item>
  105. </a-col>
  106. </a-row>
  107. <a-row>
  108. <a-col :md="6" :sm="8" :lg="12">
  109. <a-form-item label="社保基数" :labelCol="labelCol" :wrapperCol="wrapperCol">
  110. <a-input-number placeholder="请输入社保基数" style="width: 320px;" v-decorator="['security', {}]" />
  111. </a-form-item>
  112. </a-col>
  113. <a-col :md="6" :sm="8" :lg="12">
  114. <a-form-item label="缴交基数" :labelCol="labelCol" :wrapperCol="wrapperCol">
  115. <a-input-number controls="false" placeholder="请输入缴交基数" style="width: 320px;" v-decorator="['wagesBase', {}]" />
  116. </a-form-item>
  117. </a-col>
  118. </a-row>
  119. <a-row>
  120. <a-col :md="6" :sm="8" :lg="12">
  121. <a-form-item label="证件类型" :labelCol="labelCol" :wrapperCol="wrapperCol">
  122. <a-select v-model="sfzType" placeholder="请选择证件类型">
  123. <a-select-option value="0">中国身份证</a-select-option>
  124. <a-select-option value="1">其他身份证</a-select-option>
  125. </a-select>
  126. </a-form-item>
  127. </a-col>
  128. <a-col :md="6" :sm="8" :lg="12">
  129. <a-form-item label="身份类型" :labelCol="labelCol" :wrapperCol="wrapperCol">
  130. <a-radio-group v-model="identity" @change="identityChange">
  131. <a-radio value="1">普通员工</a-radio>
  132. <a-radio value="2">上级</a-radio>
  133. </a-radio-group>
  134. </a-form-item>
  135. </a-col>
  136. </a-row>
  137. <a-row>
  138. <a-col :md="6" :sm="8" :lg="12">
  139. <a-form-item label="紧急联系人" :labelCol="labelCol" :wrapperCol="wrapperCol">
  140. <a-input placeholder="请输入紧急联系人" v-decorator="[ 'urgentName',{}]" />
  141. </a-form-item>
  142. </a-col>
  143. <a-col :md="6" :sm="8" :lg="12">
  144. <a-form-item label="联系人电话" :labelCol="labelCol" :wrapperCol="wrapperCol">
  145. <a-input placeholder="请输入紧急联系人电话" v-decorator="[ 'urgentPhone', {}]" />
  146. </a-form-item>
  147. </a-col>
  148. </a-row>
  149. <a-row>
  150. <a-col :md="6" :sm="8" :lg="12">
  151. <a-form-item label="人员类别" :labelCol="labelCol" :wrapperCol="wrapperCol">
  152. <a-select v-decorator="[ 'category', {initialValue:101}]" placeholder="请选择人员类别"
  153. :getPopupContainer="(target) => target.parentNode">
  154. <a-select-option :value="101">正式工</a-select-option>
  155. <a-select-option :value="103">实习生</a-select-option>
  156. <a-select-option :value="104">劳务工</a-select-option>
  157. <a-select-option :value="105">劳务外包5+2</a-select-option>
  158. <a-select-option :value="106">劳务外包6+1</a-select-option>
  159. <a-select-option :value="102">顾问</a-select-option>
  160. </a-select>
  161. </a-form-item>
  162. </a-col>
  163. <a-col :md="6" :sm="8" :lg="12">
  164. <a-form-item label="雇佣状态" :labelCol="labelCol" :wrapperCol="wrapperCol">
  165. <a-select v-decorator="[ 'employmentStatus', {initialValue:10}]" placeholder="请选择雇佣状态"
  166. :getPopupContainer="(target) => target.parentNode">
  167. <a-select-option :value="10">在职</a-select-option>
  168. <a-select-option :value="20">离退</a-select-option>
  169. <a-select-option :value="30">离职</a-select-option>
  170. </a-select>
  171. </a-form-item>
  172. </a-col>
  173. </a-row>
  174. <a-row>
  175. <a-col :md="6" :sm="8" :lg="12">
  176. <a-form-item label="是否免打卡" :labelCol="labelCol" :wrapperCol="wrapperCol">
  177. <a-select v-decorator="[ 'isAttendance', {initialValue:'0'}]" placeholder="请选择"
  178. :getPopupContainer="(target) => target.parentNode">
  179. <a-select-option value="0">否</a-select-option>
  180. <a-select-option value="1">是</a-select-option>
  181. </a-select>
  182. </a-form-item>
  183. </a-col>
  184. <a-col :md="6" :sm="8" :lg="12">
  185. <a-form-item label="职务" :labelCol="labelCol" :wrapperCol="wrapperCol">
  186. <j-select-position placeholder="请选择职务" :multiple="false" v-decorator="['post', {}]" />
  187. </a-form-item>
  188. </a-col>
  189. </a-row>
  190. <a-row>
  191. <a-col :lg="12">
  192. <a-form-item label="同步信息" :labelCol="labelCol" :wrapperCol="wrapperCol">
  193. <j-dict-select-tag v-decorator="['infoSy', {initialValue:3}]" placeholder="请选择同步" :type="'radio'"
  194. :triggerChange="true" dictCode="info_sy" />
  195. </a-form-item>
  196. </a-col>
  197. <a-col :md="6" :sm="8" :lg="12">
  198. <a-form-item label="附件上传" :labelCol="labelCol" :wrapperCol="wrapperCol">
  199. <a-button icon="search" @click="uploads()">选择</a-button>
  200. </a-form-item>
  201. </a-col>
  202. </a-row>
  203. <a-row>
  204. </a-row>
  205. </a-form>
  206. </a-spin>
  207. <depart-window ref="departWindow" @ok="modalFormOk"></depart-window>
  208. <a-modal title="附件" :visible="visiblet" @ok="saveUpload()" @cancel="handleCancelts()" footer="">
  209. <a-upload action="http://58.34.141.138:8085/jeecg-boot/sys/common/upload" list-type="picture" :file-list="fileList"
  210. @change="t" method="post" @download="handleDownload" :showUploadList="{
  211. showRemoveIcon: true,
  212. showDownloadIcon: true
  213. }"
  214. :remove="handleRemove"
  215. >
  216. <a-button>
  217. <a-icon type="upload" />上传
  218. </a-button>
  219. </a-upload>
  220. </a-modal>
  221. </a-modal>
  222. </template>
  223. <script>
  224. import pick from 'lodash.pick'
  225. import moment from 'moment'
  226. import Vue from 'vue'
  227. // 引入搜索部门弹出框的组件
  228. import departWindow from './DepartWindow'
  229. import JSelectPosition from '@/components/jeecgbiz/JSelectPosition'
  230. import {
  231. ACCESS_TOKEN
  232. } from "@/store/mutation-types"
  233. import {
  234. getAction,
  235. httpAction,
  236. deleteAction
  237. } from '@/api/manage'
  238. import {
  239. addUser,
  240. editUser,
  241. queryUserRole,
  242. queryall
  243. } from '@/api/api'
  244. import {
  245. disabledAuthFilter
  246. } from "@/utils/authFilter"
  247. import {
  248. duplicateCheck
  249. } from '@/api/api'
  250. import JImageUpload from '../../../components/jeecg/JImageUpload'
  251. import py from '../../../mixins/vue-py.js'
  252. export default {
  253. name: "UserModal",
  254. components: {
  255. JImageUpload,
  256. departWindow,
  257. JSelectPosition
  258. },
  259. data() {
  260. return {
  261. departDisabled: false, //是否是我的部门调用该页面
  262. roleDisabled: false, //是否是角色维护调用该页面
  263. modalWidth: 800,
  264. drawerWidth: 700,
  265. titles: "新增员工",
  266. modaltoggleFlag: true,
  267. sfzCode: "",
  268. bankCard: "",
  269. bankAddr: "",
  270. syFund: "",
  271. visiblet: false,
  272. phone: "",
  273. isSalary: "0",
  274. email: "",
  275. isAttendance: "0",
  276. sfzType: "0",
  277. fileList: [],
  278. confirmDirty: false,
  279. files: [],
  280. selectedDepartKeys: [], //保存用户选择部门id
  281. checkedDepartKeys: [],
  282. checkedDepartNames: [], // 保存部门的名称 =>title
  283. checkedDepartNameString: "", // 保存部门的名称 =>title
  284. resultDepartOptions: [],
  285. userId: "", //保存用户id
  286. disableSubmit: false,
  287. userDepartModel: {
  288. userId: '',
  289. departIdList: []
  290. }, // 保存SysUserDepart的用户部门中间表数据需要的对象
  291. dateFormat: "YYYY-MM-DD",
  292. validatorRules: {
  293. phone: {
  294. rules: [{
  295. required: true,
  296. message: '请输入手机号!'
  297. }, {
  298. validator: this.validatePhone
  299. }]
  300. },
  301. email: {
  302. rules: [{
  303. required: true,
  304. message: '请输入邮箱'
  305. }, {
  306. validator: this.validateEmail
  307. }]
  308. },
  309. realname: {
  310. rules: [{
  311. required: true,
  312. message: '请输入姓名'
  313. }, {
  314. validator: this.validateRealname
  315. }]
  316. },
  317. egName: {
  318. rules: [{
  319. required: true,
  320. message: '请输入英文名'
  321. }, {
  322. validator: this.validateEgname
  323. }]
  324. },
  325. sfzCode: {
  326. rules: [{
  327. required: true,
  328. message: '请输入身份证号'
  329. }, {
  330. validator: this.validateSfzCode
  331. }]
  332. },
  333. sex: {
  334. rules: [{
  335. required: true,
  336. message: '请选择性别'
  337. }]
  338. },
  339. bankCard: {
  340. rules: [{
  341. required: true,
  342. message: '请输入银行账号'
  343. }]
  344. },
  345. },
  346. departIdShow: false,
  347. departIds: [], //负责部门id
  348. title: "操作",
  349. visible: false,
  350. model: {},
  351. roleList: [],
  352. selectedRole: [],
  353. realname: "",
  354. egName: "",
  355. labelCol: {
  356. xs: {
  357. span: 24
  358. },
  359. sm: {
  360. span: 5
  361. },
  362. },
  363. wrapperCol: {
  364. xs: {
  365. span: 24
  366. },
  367. sm: {
  368. span: 16
  369. },
  370. },
  371. uploadLoading: false,
  372. confirmLoading: false,
  373. headers: {},
  374. form: this.$form.createForm(this),
  375. picUrl: "",
  376. url: {
  377. fileUpload: window._CONFIG['domianURL'] + "/sys/common/upload",
  378. userWithDepart: "/sys/user/userDepartList", // 引入为指定用户查看部门信息需要的url
  379. userId: "/sys/user/generateUserId", // 引入生成添加用户情况下的url
  380. syncUserByUserName: "/act/process/extActProcess/doSyncUserByUserName", //同步用户到工作流
  381. queryTenantList: '/sys/tenant/queryList',
  382. xzupload: '/sys/common/static',
  383. sysFile: '/sysFile/sysFile/queryByUserId',
  384. delSysFile:'/sysFile/sysFile/deleteById'
  385. },
  386. identity: "1",
  387. fileList: [],
  388. tenantList: [],
  389. currentTenant: []
  390. }
  391. },
  392. created() {
  393. const token = Vue.ls.get(ACCESS_TOKEN);
  394. this.headers = {
  395. "X-Access-Token": token
  396. }
  397. this.initTenantList()
  398. },
  399. computed: {
  400. uploadAction: function() {
  401. return this.url.fileUpload;
  402. }
  403. },
  404. methods: {
  405. handleRemove(file){
  406. if(this.userId!=null&&this.userId!=""){
  407. deleteAction(this.url.delSysFile, {userid:this.userId,name:file.name}).then((res) => {
  408. if (res.success) {
  409. }
  410. }).finally(() => {
  411. });
  412. }
  413. },
  414. handleCancelts() {
  415. // this.fileList = [];
  416. this.visiblet = false;
  417. },
  418. // 文件下载
  419. handleDownload(file) {
  420. console.log(file.response.message)
  421. window.location.href = "http://58.34.141.138:8085/jeecg-boot/sys/common/static/" + file.response.message;
  422. },
  423. t(info) {
  424. // this.files = [];
  425. // let {
  426. // fileList
  427. // } = info
  428. // const status = info.file.status
  429. // if (status !== 'uploading') {}
  430. // if (status === 'done') {
  431. // var list = fileList.fileList;
  432. // for (var i = 0; i < list.length; i++) {
  433. // this.files.push(list[i].response.message);
  434. // }
  435. // }
  436. this.fileList = info.fileList //重点
  437. //console.log(info)
  438. },
  439. saveUpload() {
  440. this.visiblet = false;
  441. console.log(this.defaultFileList)
  442. },
  443. uploads() {
  444. this.visiblet = true;
  445. },
  446. isDisabledAuth(code) {
  447. return disabledAuthFilter(code);
  448. },
  449. getBirth(idCard) {
  450. var birthday = "";
  451. if (idCard != null && idCard != "") {
  452. if (idCard.length == 15) {
  453. birthday = "19" + idCard.slice(6, 12);
  454. } else if (idCard.length == 18) {
  455. birthday = idCard.slice(6, 14);
  456. }
  457. //通过正则表达式来指定输出格式为:1990-01-01
  458. }
  459. if (birthday != "" && birthday != null) {
  460. this.form.setFieldsValue({
  461. birthday: birthday.replace(/(.{4})(.{2})/, "$1-$2-")
  462. })
  463. if (parseInt(idCard.slice(-2, -1)) % 2 == 1) {
  464. this.form.setFieldsValue({
  465. sex: 1
  466. })
  467. } else {
  468. this.form.setFieldsValue({
  469. sex: 2
  470. })
  471. }
  472. }
  473. },
  474. queryFiles(e) {
  475. getAction(this.url.sysFile, {
  476. userid: e
  477. }).then(res => {
  478. if (res.success) {
  479. if (res.result.length > 0) {
  480. this.fileList = [];
  481. for (var i = 0; i < res.result.length; i++) {
  482. const rs = {
  483. message: res.result[i].txtName
  484. };
  485. const fileInfo = {
  486. uid: res.result[i].id,
  487. name: res.result[i].txtName,
  488. status: "done",
  489. response: rs,
  490. url: "http://58.34.141.138:8085/jeecg-boot/" + res.result[i].txtName,
  491. };
  492. this.fileList.push(fileInfo)
  493. }
  494. }
  495. }
  496. })
  497. },
  498. initTenantList() {
  499. getAction(this.url.queryTenantList).then(res => {
  500. if (res.success) {
  501. this.tenantList = res.result
  502. }
  503. })
  504. },
  505. //窗口最大化切换
  506. toggleScreen() {
  507. if (this.modaltoggleFlag) {
  508. this.modalWidth = window.innerWidth;
  509. } else {
  510. this.modalWidth = 800;
  511. }
  512. this.modaltoggleFlag = !this.modaltoggleFlag;
  513. },
  514. initialRoleList() {
  515. queryall().then((res) => {
  516. if (res.success) {
  517. this.roleList = res.result;
  518. } else {
  519. console.log(res.message);
  520. }
  521. });
  522. },
  523. loadUserRoles(userid) {
  524. queryUserRole({
  525. userid: userid
  526. }).then((res) => {
  527. if (res.success) {
  528. this.selectedRole = res.result;
  529. } else {
  530. console.log(res.message);
  531. }
  532. });
  533. },
  534. refresh() {
  535. this.selectedDepartKeys = [];
  536. this.checkedDepartKeys = [];
  537. this.checkedDepartNames = [];
  538. this.checkedDepartNameString = "";
  539. this.userId = ""
  540. this.resultDepartOptions = [];
  541. this.departId = [];
  542. this.departIdShow = false;
  543. this.currentTenant = []
  544. this.sfzCode = "";
  545. this.realname = "";
  546. this.egName = "";
  547. this.syFund = "";
  548. this.isAttendance = 0;
  549. this.isSalary = 0;
  550. this.bankAddr = "";
  551. this.bankCard = "";
  552. this.phone = "";
  553. this.email = "";
  554. },
  555. add() {
  556. this.picUrl = "";
  557. this.refresh();
  558. this.edit({
  559. activitiSync: '1'
  560. });
  561. },
  562. edit(record) {
  563. this.realname = record.realname;
  564. this.egName = record.egName;
  565. this.resetScreenSize(); // 调用此方法,根据屏幕宽度自适应调整抽屉的宽度
  566. let that = this;
  567. //that.initialRoleList();
  568. that.checkedDepartNameString = "";
  569. that.form.resetFields();
  570. if (record.hasOwnProperty("id")) {
  571. that.loadUserRoles(record.id);
  572. setTimeout(() => {
  573. this.fileList = record.avatar;
  574. }, 5)
  575. }
  576. if (record.sfzType != null && record.sfzType != "") {
  577. this.sfzType = record.sfzType;
  578. }
  579. that.visible = true;
  580. that.model = Object.assign({}, record);
  581. that.$nextTick(() => {
  582. that.form.setFieldsValue(pick(this.model, 'sex', 'email', 'phone', 'post', 'urgentName', 'urgentPhone',
  583. 'bankAddr', 'bankCard', 'realname', 'egName', 'sfzCode','isAttendance',
  584. 'infoSy', 'syFund', 'category', 'employmentStatus', 'wagesOne', 'wagesTwo', 'security','wagesBase'))
  585. });
  586. //身份为上级显示负责部门,否则不显示
  587. if (this.model.userIdentity == "2") {
  588. this.identity = "2";
  589. this.departIdShow = true;
  590. } else {
  591. this.identity = "1";
  592. this.departIdShow = false;
  593. }
  594. //update-begin-author:taoyan date:2020710 for:多租户配置
  595. if (!record.relTenantIds || record.relTenantIds.length == 0) {
  596. this.currentTenant = []
  597. } else {
  598. this.currentTenant = record.relTenantIds.split(',').map(Number);
  599. }
  600. if (record.id != null && record.id != "") {
  601. this.userId = record.id;
  602. this.queryFiles(record.id)
  603. }
  604. // 调用查询用户对应的部门信息的方法
  605. that.checkedDepartKeys = [];
  606. that.loadCheckedDeparts();
  607. if (this.userId != null && this.userId != "") {
  608. this.queryFiles(this.userId)
  609. }
  610. },
  611. //
  612. loadCheckedDeparts() {
  613. var id= this.userId
  614. let that = this;
  615. if (!that.userId) {
  616. return
  617. }
  618. getAction(that.url.userWithDepart, {
  619. userId: that.userId
  620. }).then((res) => {
  621. that.checkedDepartNames = [];
  622. if (res.success) {
  623. var depart = [];
  624. var departId = [];
  625. for (let i = 0; i < res.result.length; i++) {
  626. that.checkedDepartNames.push(res.result[i].title);
  627. this.checkedDepartNameString = this.checkedDepartNames.join(",");
  628. that.checkedDepartKeys.push(res.result[i].key);
  629. //新增负责部门选择下拉框
  630. depart.push({
  631. key: res.result[i].key,
  632. title: res.result[i].title
  633. })
  634. departId.push(res.result[i].key)
  635. }
  636. that.resultDepartOptions = depart;
  637. //判断部门id是否存在,不存在择直接默认当前所在部门
  638. if (this.model.departIds) {
  639. this.departIds = this.model.departIds.split(",");
  640. } else {
  641. this.departIds = departId;
  642. }
  643. that.userDepartModel.departIdList = that.checkedDepartKeys
  644. } else {
  645. console.log(res.message);
  646. }
  647. })
  648. },
  649. close() {
  650. this.$emit('close');
  651. this.visible = false;
  652. this.disableSubmit = false;
  653. this.selectedRole = [];
  654. this.userDepartModel = {
  655. userId: '',
  656. departIdList: []
  657. };
  658. this.checkedDepartNames = [];
  659. this.checkedDepartNameString = '';
  660. this.checkedDepartKeys = [];
  661. this.selectedDepartKeys = [];
  662. this.resultDepartOptions = [];
  663. this.departIds = [];
  664. this.departIdShow = false;
  665. this.fileList=[];
  666. this.identity = "1";
  667. this.bankAddr = "";
  668. this.bankCard = "";
  669. this.syFund = "";
  670. },
  671. moment,
  672. handleSubmit() {
  673. if (this.userDepartModel.departIdList.join(",") == "" || this.userDepartModel.departIdList.join(",") == null) {
  674. this.$message.warning('请选择部门!');
  675. return;
  676. }
  677. const that = this;
  678. // 触发表单验证
  679. this.form.validateFields((err, values) => {
  680. if (!err) {
  681. that.confirmLoading = true;
  682. if (!values.birthday) {
  683. values.birthday = '';
  684. } else {
  685. values.birthday = values.birthday;
  686. }
  687. let formData = Object.assign(this.model, values);
  688. // if (that.fileList != '') {
  689. // formData.avatar = that.fileList;
  690. // } else {
  691. // formData.avatar = null;
  692. // }
  693. formData.sfzType = this.sfzType;
  694. var a = this.fileList;
  695. var txt = [];
  696. if (this.fileList != null && this.fileList.length > 0) {
  697. for (var i = 0; i < this.fileList.length; i++) {
  698. txt.push(this.fileList[i].response.message)
  699. }
  700. formData.txt = txt.join(",");
  701. }
  702. //formData.selectedroles = this.selectedRole.length>0?this.selectedRole.join(","):'';
  703. formData.selecteddeparts = this.userDepartModel.departIdList.length > 0 ? this.userDepartModel
  704. .departIdList.join(",") : '';
  705. formData.userIdentity = this.identity;
  706. formData.departIds = this.userDepartModel.departIdList.join(",");
  707. //如果是上级择传入departIds,否则为空
  708. if (this.identity === "2") {
  709. formData.departIds = this.departIds.join(",");
  710. } else {
  711. formData.departIds = "";
  712. }
  713. // that.addDepartsToUser(that,formData); // 调用根据当前用户添加部门信息的方法
  714. let obj;
  715. if (!this.model.id) {
  716. formData.id = this.userId;
  717. obj = addUser(formData);
  718. } else {
  719. obj = editUser(formData);
  720. }
  721. obj.then((res) => {
  722. if (res.success) {
  723. that.$message.success(res.message);
  724. that.$emit('ok');
  725. } else {
  726. that.$message.warning(res.message);
  727. }
  728. }).finally(() => {
  729. that.confirmLoading = false;
  730. that.checkedDepartNames = [];
  731. that.userDepartModel.departIdList = {
  732. userId: '',
  733. departIdList: []
  734. };
  735. that.close();
  736. })
  737. } else {
  738. console.log("1")
  739. }
  740. })
  741. },
  742. handleCancel() {
  743. this.close()
  744. },
  745. validateRealname(rule, value, callback) {
  746. if (!value) {
  747. callback()
  748. } else {
  749. this.realname = value;
  750. if (this.egName != null && this.egName != "") {
  751. var emil = "@gksports.com.cn";
  752. var name = py.chineseToPinYin(value.substr(0, 1))
  753. this.form.setFieldsValue({
  754. email: this.egName + "." + name + emil
  755. })
  756. }
  757. callback()
  758. }
  759. },
  760. validateSfzCode(rule, value, callback) {
  761. if (!value) {
  762. callback()
  763. } else {
  764. if (this.sfzType == "0") {
  765. this.getBirth(value)
  766. }
  767. callback()
  768. }
  769. },
  770. validateEgname(rule, value, callback) {
  771. if (!value) {
  772. callback()
  773. } else {
  774. this.egName = value;
  775. if (this.realname != null && this.realname != "") {
  776. var emil = "@gksports.com.cn";
  777. var name = py.chineseToPinYin(this.realname.substr(0, 1))
  778. this.form.setFieldsValue({
  779. email: value + "." + name + emil
  780. })
  781. }
  782. callback()
  783. }
  784. },
  785. validatePhone(rule, value, callback) {
  786. if (!value) {
  787. callback()
  788. } else {
  789. //update-begin--Author:kangxiaolin Date:20190826 for:[05] 手机号不支持199号码段--------------------
  790. if (new RegExp(/^1[3|4|5|7|8|9][0-9]\d{8}$/).test(value)) {
  791. //update-end--Author:kangxiaolin Date:20190826 for:[05] 手机号不支持199号码段--------------------
  792. var params = {
  793. tableName: 'sys_user',
  794. fieldName: 'phone',
  795. fieldVal: value,
  796. dataId: this.userId
  797. };
  798. duplicateCheck(params).then((res) => {
  799. if (res.success) {
  800. callback()
  801. } else {
  802. callback("手机号已存在!")
  803. }
  804. })
  805. } else {
  806. callback("请输入正确格式的手机号码!");
  807. }
  808. }
  809. },
  810. validateEmail(rule, value, callback) {
  811. if (!value) {
  812. callback()
  813. } else {
  814. if (new RegExp(
  815. /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
  816. ).test(value)) {
  817. var params = {
  818. tableName: 'sys_user',
  819. fieldName: 'email',
  820. fieldVal: value,
  821. dataId: this.userId
  822. };
  823. duplicateCheck(params).then((res) => {
  824. if (res.success) {
  825. callback()
  826. } else {
  827. callback("邮箱已存在!")
  828. }
  829. })
  830. } else {
  831. callback("请输入正确格式的邮箱!")
  832. }
  833. }
  834. },
  835. handleConfirmBlur(e) {
  836. const value = e.target.value;
  837. this.confirmDirty = this.confirmDirty || !!value
  838. },
  839. normFile(e) {
  840. console.log('Upload event:', e);
  841. if (Array.isArray(e)) {
  842. return e
  843. }
  844. return e && e.fileList
  845. },
  846. beforeUpload: function(file) {
  847. var fileType = file.type;
  848. if (fileType.indexOf('image') < 0) {
  849. this.$message.warning('请上传图片');
  850. return false;
  851. }
  852. //TODO 验证文件大小
  853. },
  854. handleChange(info) {
  855. this.picUrl = "";
  856. if (info.file.status === 'uploading') {
  857. this.uploadLoading = true;
  858. return
  859. }
  860. if (info.file.status === 'done') {
  861. var response = info.file.response;
  862. this.uploadLoading = false;
  863. console.log(response);
  864. if (response.success) {
  865. this.model.avatar = response.message;
  866. this.picUrl = "Has no pic url yet";
  867. } else {
  868. this.$message.warning(response.message);
  869. }
  870. }
  871. },
  872. // 搜索用户对应的部门API
  873. onSearch() {
  874. console.log(this.$refs.departWindow)
  875. this.$refs.departWindow.add(this.checkedDepartKeys, this.userId);
  876. },
  877. // 获取用户对应部门弹出框提交给返回的数据
  878. modalFormOk(formData) {
  879. this.checkedDepartNames = [];
  880. this.selectedDepartKeys = [];
  881. this.checkedDepartNameString = '';
  882. this.userId = formData.userId;
  883. this.userDepartModel.userId = formData.userId;
  884. this.departIds = [];
  885. this.resultDepartOptions = [];
  886. var depart = [];
  887. for (let i = 0; i < formData.departIdList.length; i++) {
  888. this.selectedDepartKeys.push(formData.departIdList[i].key);
  889. this.checkedDepartNames.push(formData.departIdList[i].title);
  890. this.checkedDepartNameString = this.checkedDepartNames.join(",");
  891. //新增部门选择,如果上面部门选择后不为空直接付给负责部门
  892. depart.push({
  893. key: formData.departIdList[i].key,
  894. title: formData.departIdList[i].title
  895. })
  896. this.departIds.push(formData.departIdList[i].key)
  897. }
  898. this.resultDepartOptions = depart;
  899. this.userDepartModel.departIdList = this.selectedDepartKeys;
  900. this.checkedDepartKeys = this.selectedDepartKeys //更新当前的选择keys
  901. },
  902. // 根据屏幕变化,设置抽屉尺寸
  903. resetScreenSize() {
  904. let screenWidth = document.body.clientWidth;
  905. if (screenWidth < 500) {
  906. this.drawerWidth = screenWidth;
  907. } else {
  908. this.drawerWidth = 700;
  909. }
  910. },
  911. identityChange(e) {
  912. if (e.target.value === "1") {
  913. this.departIdShow = false;
  914. } else {
  915. this.departIdShow = true;
  916. }
  917. }
  918. }
  919. }
  920. </script>
  921. <style scoped>
  922. .avatar-uploader>.ant-upload {
  923. width: 104px;
  924. height: 104px;
  925. }
  926. .ant-upload-select-picture-card i {
  927. font-size: 49px;
  928. color: #999;
  929. }
  930. .ant-upload-select-picture-card .ant-upload-text {
  931. margin-top: 8px;
  932. color: #666;
  933. }
  934. .ant-table-tbody .ant-table-row td {
  935. padding-top: 10px;
  936. padding-bottom: 10px;
  937. }
  938. .drawer-bootom-button {
  939. position: absolute;
  940. bottom: -8px;
  941. width: 100%;
  942. border-top: 1px solid #e8e8e8;
  943. padding: 10px 16px;
  944. text-align: right;
  945. left: 0;
  946. background: #fff;
  947. border-radius: 0 0 2px 2px;
  948. }
  949. </style>