detail.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506
  1. <template>
  2. <div class="app-container">
  3. <div class="title-container">
  4. <breadcrumb id="breadcrumb-container" class="breadcrumb-container"/>
  5. </div>
  6. <y-detail-page-layout @save="handleCreate" :edit-status="true" v-loading="vLoading" element-loading-text="处理中。。。" :list-query="listQuery">
  7. <div style="padding-top: 30px;">
  8. <el-tabs v-model="activeName">
  9. <el-tab-pane label="员工信息" name="first">
  10. <el-form ref="postForm" :model="postForm" class="form-container">
  11. <div class="createPost-main-container">
  12. <div class="postInfo-container">
  13. <div style="margin-bottom: 30px">
  14. <h3 class="title">
  15. <div class="avatar-wrapper icon-title">基</div>
  16. <div class="icon-info">基本信息</div>
  17. </h3>
  18. </div>
  19. <el-row>
  20. <el-col :xs="24" :sm="12" :lg="6" :span="6">
  21. <el-form-item
  22. label="员工姓名:"
  23. prop="name"
  24. :rules="{required: true, message: '请输入员工姓名', trigger: 'blur'}"
  25. label-width="120px"
  26. class="postInfo-container-item"
  27. >
  28. <el-input v-model="postForm.name" class="filter-item"/>
  29. </el-form-item>
  30. </el-col>
  31. <el-col :xs="24" :sm="12" :lg="6" :span="6">
  32. <el-form-item
  33. label="性别:"
  34. prop="sex"
  35. :rules="{required: true, message: '请选择性别', trigger: 'blur'}"
  36. label-width="120px"
  37. class="postInfo-container-item"
  38. >
  39. <el-select
  40. v-model="postForm.sex"
  41. placeholder=""
  42. clearable
  43. filterable
  44. class="filter-item"
  45. style="width: 100%"
  46. >
  47. <el-option key="1" label="男" value="男"/>
  48. <el-option key="2" label="女" value="女"/>
  49. </el-select>
  50. </el-form-item>
  51. </el-col>
  52. <el-col :xs="24" :sm="12" :lg="6" :span="6">
  53. <el-form-item
  54. label="身份证号:"
  55. prop="idNo"
  56. :rules="[{required: true, message: '请选择身份证号', trigger: 'blur'},
  57. {
  58. pattern: /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/,
  59. message: '证件号码格式有误!',
  60. trigger: 'blur'}]"
  61. label-width="120px"
  62. class="postInfo-container-item"
  63. >
  64. <el-input v-model="postForm.idNo" class="filter-item"/>
  65. </el-form-item>
  66. </el-col>
  67. <el-col :xs="24" :sm="12" :lg="6" :span="6">
  68. <el-form-item label="出生日期:" label-width="120px" class="postInfo-container-item">
  69. <el-date-picker
  70. v-model="postForm.birthday"
  71. type="date"
  72. value-format="yyyy-MM-dd"
  73. style="width: 100%"
  74. placeholder="选择日期"
  75. />
  76. </el-form-item>
  77. </el-col>
  78. <el-col :xs="24" :sm="12" :lg="6" :span="6">
  79. <el-form-item label="民族:" label-width="120px" class="postInfo-container-item">
  80. <el-select
  81. v-model="postForm.nation"
  82. placeholder=""
  83. clearable
  84. filterable
  85. class="filter-item"
  86. style="width: 100%"
  87. >
  88. <el-option v-for="(item, index) in AllEnum['民族']" :key="index" :label="item" :value="item"/>
  89. </el-select>
  90. </el-form-item>
  91. </el-col>
  92. <el-col :xs="24" :sm="12" :lg="6" :span="6">
  93. <el-form-item label="联系电话:"
  94. prop="mobile"
  95. :rules="[{required: true, message: '请输入联系电话', trigger: 'blur'},
  96. {
  97. pattern: /^1\d{10}$/,
  98. message: '联系电话格式有误!',
  99. trigger: 'blur'}]"
  100. label-width="120px" class="postInfo-container-item">
  101. <el-input v-model="postForm.mobile" class="filter-item"/>
  102. </el-form-item>
  103. </el-col>
  104. <el-col :xs="24" :sm="12" :lg="6" :span="6">
  105. <el-form-item label="政治面貌:" label-width="120px" class="postInfo-container-item">
  106. <el-select
  107. v-model="postForm.politics"
  108. placeholder=""
  109. clearable
  110. filterable
  111. class="filter-item"
  112. style="width: 100%"
  113. >
  114. <el-option v-for="(item, index) in AllEnum['政治面貌']" :key="index" :label="item" :value="item"/>
  115. </el-select>
  116. </el-form-item>
  117. </el-col>
  118. <el-col :xs="24" :sm="12" :lg="6" :span="6">
  119. <el-form-item
  120. label="籍贯:"
  121. prop="nativePlace"
  122. label-width="120px"
  123. class="postInfo-container-item"
  124. >
  125. <el-input v-model="postForm.nativePlace" class="filter-item"/>
  126. </el-form-item>
  127. </el-col>
  128. <el-col :xs="24" :sm="12" :lg="6" :span="6">
  129. <el-form-item
  130. label="家庭住址:"
  131. prop="homeAddress"
  132. label-width="120px"
  133. class="postInfo-container-item"
  134. >
  135. <el-input v-model="postForm.homeAddress" class="filter-item" style="width: 480px"/>
  136. </el-form-item>
  137. </el-col>
  138. <el-button type="danger" style="margin-left: 300px" @click="initPassword">重置密码</el-button>
  139. <el-button type="danger" @click="initSettlePassword">重置提成查询密码</el-button>
  140. </el-row>
  141. <div style="margin-top:20px;width:100%;height:1px;background:rgba(242,242,242,1);"/>
  142. <div style="margin-bottom: 30px">
  143. <h3 class="title">
  144. <div class="avatar-wrapper icon-title" style="background:rgba(255,175,41,1)">工</div>
  145. <div class="icon-info">工作信息</div>
  146. </h3>
  147. </div>
  148. <el-row>
  149. <el-col :xs="24" :sm="12" :lg="6" :span="6">
  150. <el-form-item
  151. label="员工类型:"
  152. prop="userType"
  153. :rules="{required: true, message: '请选择员工类型', trigger: 'blur'}"
  154. label-width="120px"
  155. class="postInfo-container-item"
  156. >
  157. <el-select
  158. v-model="postForm.userType"
  159. clearable
  160. filterable
  161. placeholder=""
  162. style="width: 100%"
  163. >
  164. <el-option v-for="(item, index) in AllEnum['员工类型']" :key="index" :label="item" :value="item"/>
  165. </el-select>
  166. </el-form-item>
  167. </el-col>
  168. <el-col :xs="24" :sm="12" :lg="6" :span="6">
  169. <el-form-item
  170. label="员工工号:"
  171. prop="staffNo"
  172. label-width="120px"
  173. class="postInfo-container-item"
  174. >
  175. <el-input :value="postForm.staffNo" class="filter-item" placeholder="系统自动生成" :disabled="true" readonly/>
  176. </el-form-item>
  177. </el-col>
  178. <el-col :xs="24" :sm="24" :lg="12" :span="12">
  179. <el-form-item
  180. label="岗-部门名:"
  181. prop="userPosts"
  182. :rules="{required: true, message: '请选择岗-部门', trigger: 'blur'}"
  183. label-width="120px"
  184. class="postInfo-container-item"
  185. >
  186. <el-select
  187. v-model="userPosts"
  188. placeholder=""
  189. clearable
  190. multiple
  191. filterable
  192. class="filter-item"
  193. style=" width: 100%"
  194. >
  195. <el-option
  196. v-for="item in postOptions"
  197. :key="item.id"
  198. :label="item.name"
  199. :value="item.id"
  200. />
  201. </el-select>
  202. </el-form-item>
  203. </el-col>
  204. </el-row>
  205. <el-row>
  206. <el-col :xs="24" :sm="12" :lg="6" :span="6">
  207. <el-form-item
  208. label="在职状态:"
  209. prop="resignState"
  210. :rules="{required: true, message: '请选择在职状态', trigger: 'blur'}"
  211. label-width="120px"
  212. class="postInfo-container-item"
  213. >
  214. <el-select
  215. v-model="postForm.resignState"
  216. placeholder=""
  217. clearable
  218. filterable
  219. class="filter-item"
  220. style="width: 100%"
  221. >
  222. <el-option key="0" label="离职" :value="true" />
  223. <el-option key="1" label="在职" :value="false"/>
  224. </el-select>
  225. </el-form-item>
  226. </el-col>
  227. <el-col :xs="24" :sm="12" :lg="6" :span="6">
  228. <el-form-item label="入职日期:" :rules="{required: true, message: '请选择入职日期', trigger: 'blur'}" label-width="120px" class="postInfo-container-item">
  229. <el-date-picker
  230. v-model="postForm.hireDate"
  231. type="date"
  232. value-format="yyyy-MM-dd"
  233. style="width: 100%"
  234. placeholder="选择日期"
  235. :disabled="ifAble"
  236. />
  237. </el-form-item>
  238. </el-col>
  239. <el-col :xs="24" :sm="12" :lg="6" :span="6">
  240. <el-form-item label="离职日期:" label-width="120px" class="postInfo-container-item">
  241. <el-date-picker
  242. v-model="postForm.resignDate"
  243. type="date"
  244. value-format="yyyy-MM-dd"
  245. style="width: 100%"
  246. placeholder="选择日期"
  247. />
  248. </el-form-item>
  249. </el-col>
  250. </el-row>
  251. <div style="margin-top:20px;width:100%;height:1px;background:rgba(242,242,242,1);"/>
  252. <div style="margin-bottom: 30px">
  253. <h3 class="title">
  254. <div class="avatar-wrapper icon-title" style="background:#9E9CF4">信</div>
  255. <div class="icon-info">信息备注</div>
  256. </h3>
  257. </div>
  258. <el-row>
  259. <el-col :span="24">
  260. <el-form-item label="备注:" label-width="120px" class="postInfo-container-item">
  261. <el-input v-model="postForm.remark" type="textarea" class="filter-item" placeholder="200字符"/>
  262. </el-form-item>
  263. </el-col>
  264. </el-row>
  265. </div>
  266. </div>
  267. </el-form>
  268. </el-tab-pane>
  269. </el-tabs>
  270. </div>
  271. </y-detail-page-layout>
  272. </div>
  273. </template>
  274. <script>
  275. import Breadcrumb from '@/components/Breadcrumb'
  276. import YDetailPageLayout from '@/components/YDetailPageLayout'
  277. export default {
  278. name: 'StaffDetail',
  279. components: {
  280. Breadcrumb,
  281. YDetailPageLayout
  282. },
  283. data() {
  284. return {
  285. type: 'detail',
  286. postForm: {
  287. userPosts: [],
  288. resignState:false,
  289. userType: '正式员工',
  290. },
  291. dataId: this.$route.query.id,
  292. activeName: 'first',
  293. vLoading: false,
  294. AllEnum:[],
  295. listQuery:null,
  296. postOptions:[],
  297. userPosts:[],
  298. disable: false,
  299. }
  300. },
  301. created() {
  302. this.listQuery = this.$route.query.listQuery;
  303. this.getAllEnum();
  304. this.getOptions();
  305. this.getDetail();
  306. },
  307. computed:{
  308. ifAble(){
  309. if (this.dataId){
  310. return true;
  311. }else {
  312. return false;
  313. }
  314. }
  315. },
  316. methods: {
  317. initSettlePassword(){
  318. this.$confirm('确认重置提成查询密码, 是否继续?', '提示', {
  319. confirmButtonText: '确定',
  320. cancelButtonText: '取消',
  321. type: 'warning'
  322. }).then(() => {
  323. this.$api.user.resetSettlePwd(this.postForm.id).then(res => {
  324. if (res.code === 200) {
  325. this.$notify({
  326. title: '成功',
  327. message: '重置提成查询密码成功。',
  328. type: 'success',
  329. duration: 2000
  330. })
  331. }
  332. })
  333. }).catch(() => {
  334. })
  335. },
  336. initPassword() {
  337. this.$confirm('确认初始密码, 是否继续?', '提示', {
  338. confirmButtonText: '确定',
  339. cancelButtonText: '取消',
  340. type: 'warning'
  341. }).then(() => {
  342. this.$api.user.resetPwd(this.postForm.id).then(res => {
  343. if (res.code === 200) {
  344. this.$notify({
  345. title: '成功',
  346. message: '密码初始成功',
  347. type: 'success',
  348. duration: 2000
  349. })
  350. }
  351. })
  352. }).catch(() => {
  353. })
  354. },
  355. getOptions(){
  356. this.$api.post.xSimpleAll().then(res => {
  357. this.postOptions = res.data
  358. })
  359. },
  360. getAllEnum() {
  361. const that = this;
  362. that.$api.globalConfig.getAllEnum().then(data => {
  363. if (data.code === 200) {
  364. that.AllEnum = data.data
  365. } else {
  366. this.$message({
  367. type: 'error',
  368. message: data.msg
  369. })
  370. }
  371. })
  372. },
  373. getDetail() {
  374. if (this.dataId) {
  375. this.$api.user.detail(this.dataId).then(res => {
  376. this.postForm = res.data;
  377. this.userPosts = res.data.userPosts.map(item => {
  378. return item.id
  379. })
  380. });
  381. }
  382. },
  383. handleCreate() {
  384. if (!this.postForm.userType) {
  385. this.$notify({
  386. title: '错误',
  387. message: '请选择员工类型',
  388. type: 'error',
  389. duration: 2000
  390. });
  391. return
  392. }
  393. if (!this.postForm.name) {
  394. this.$notify({
  395. title: '错误',
  396. message: '请输入姓名',
  397. type: 'error',
  398. duration: 2000
  399. });
  400. return
  401. }
  402. if (!this.postForm.sex) {
  403. this.$notify({
  404. title: '错误',
  405. message: '请选择性别',
  406. type: 'error',
  407. duration: 2000
  408. });
  409. return
  410. }
  411. if (!this.postForm.idNo) {
  412. this.$notify({
  413. title: '错误',
  414. message: '请输入身份证号',
  415. type: 'error',
  416. duration: 2000
  417. });
  418. return
  419. }
  420. if (this.postForm.remark && this.postForm.remark.length>200) {
  421. this.$notify({
  422. title: '错误',
  423. message: '备注信息长度应不超过200字符',
  424. type: 'error',
  425. duration: 2000
  426. });
  427. return
  428. }
  429. this.postForm.userPosts = this.userPosts;
  430. if (!this.postForm.userPosts || !this.postForm.userPosts.length) {
  431. this.$notify({
  432. title: '错误',
  433. message: '请选择岗-部门',
  434. type: 'error',
  435. duration: 2000
  436. });
  437. return
  438. }
  439. if (!this.postForm.hireDate) {
  440. this.$notify({
  441. title: '错误',
  442. message: '请选择入职日期',
  443. type: 'error',
  444. duration: 2000
  445. });
  446. return
  447. }
  448. this.vLoading = true;
  449. this.$refs.postForm.validate(valid => {
  450. if (valid) {
  451. if (this.dataId) {
  452. this.$api.user.edit(Object.assign({}, this.postForm, {
  453. userPosts: this.userPosts.map(item => { return { id: item } }),
  454. })).then(res => {
  455. if (res.code === 200) {
  456. this.$notify({
  457. title: '成功',
  458. message: '保存成功',
  459. type: 'success',
  460. duration: 2000
  461. });
  462. const back = this.$route.query.back;
  463. if (back) {
  464. this.$router.push(back)
  465. }
  466. this.initData();
  467. this.vLoading = false
  468. }
  469. }).catch(() => {
  470. this.vLoading = false
  471. })
  472. } else {
  473. this.$api.user.add(Object.assign({}, this.postForm, {
  474. userPosts: this.userPosts.map(item => { return { id: item } }),
  475. })).then(res => {
  476. if (res.code === 200) {
  477. this.$notify({
  478. title: '成功',
  479. message: '新增成功',
  480. type: 'success',
  481. duration: 2000
  482. });
  483. const back = this.$route.query.back;
  484. if (back) {
  485. this.$router.push(back)
  486. }
  487. this.initData();
  488. this.vLoading = false
  489. }
  490. }).catch(() => {
  491. this.vLoading = false
  492. })
  493. }
  494. }
  495. })
  496. },
  497. }
  498. }
  499. </script>
  500. <style lang="scss" scoped>
  501. </style>