edit.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663
  1. <template>
  2. <view class="container">
  3. <uni-forms ref="form" :rules="rules" :model="form" labelWidth="120px" :label-position="alignment">
  4. <uni-forms-item label="续签人" required name="employeeName">
  5. <uni-easyinput v-model="form.employeeName" placeholder="点击选择" :clearable="false" @click.native="gotochooseUser('single')"/>
  6. </uni-forms-item>
  7. <uni-forms-item label="部门">
  8. <uni-easyinput v-model="form.deptName" disabled/>
  9. </uni-forms-item>
  10. <uni-forms-item label="职位">
  11. <uni-easyinput v-model="form.position" disabled/>
  12. </uni-forms-item>
  13. <uni-forms-item label="手机号">
  14. <uni-easyinput v-model="form.employeePhone" disabled/>
  15. </uni-forms-item>
  16. <uni-forms-item label="原合同开始日期">
  17. <uni-easyinput v-model="form.oldContractStartDate" disabled/>
  18. </uni-forms-item>
  19. <uni-forms-item label="原合同结束日期">
  20. <uni-easyinput v-model="form.oldContractEndDate" disabled/>
  21. </uni-forms-item>
  22. <uni-forms-item label="续签合同期限(月)" required name="renewPeriod">
  23. <uni-easyinput v-model="form.renewPeriod" placeholder="请输入"/>
  24. </uni-forms-item>
  25. <uni-forms-item label="续签开始日期" required name="renewContractStartDate">
  26. <uni-datetime-picker type="date" v-model="form.renewContractStartDate"/>
  27. </uni-forms-item>
  28. <uni-forms-item label="续签结束日期" required name="renewContractEndDate">
  29. <uni-datetime-picker type="date" v-model="form.renewContractEndDate"/>
  30. </uni-forms-item>
  31. <uni-forms-item label="续签申请理由" required name="renewReason">
  32. <uni-easyinput maxlength="200" type="textarea" v-model="form.renewReason" placeholder="请输入" />
  33. </uni-forms-item>
  34. <uni-forms-item label="工作总结">
  35. <uni-easyinput maxlength="200" type="textarea" v-model="form.workPerformance" placeholder="请输入" />
  36. </uni-forms-item>
  37. <uni-forms-item label="附件">
  38. <view class="upload-wrap">
  39. <button type="primary" size="mini" @click="handleUploadClick">点击上传</button>
  40. <xe-upload ref="XeUpload" :options="uploadOptions" @callback="handleUploadCallback"></xe-upload>
  41. <view class="mgb-16 file-wrap" v-for="(item, index) in fileList" :key="index">
  42. <view class="btn-click file-line" @click="handlePreview(item)">
  43. <view class="file-info">
  44. <image :src="icons.file" mode="aspectFill" class="file-icon" />
  45. <text class="file-name">{{ item.name || title[type] }}</text>
  46. </view>
  47. <image :src="icons.close" mode="aspectFill" class="file-icon"
  48. @click.stop="handleDeleteFile(index)" />
  49. </view>
  50. </view>
  51. </view>
  52. </uni-forms-item>
  53. <uni-forms-item label="备注">
  54. <uni-easyinput maxlength="200" type="textarea" v-model="form.remarks" placeholder="请输入备注" />
  55. </uni-forms-item>
  56. <uni-forms-item label="审批人" required name="peopleList">
  57. <uni-easyinput v-model="form.peopleList" style="display: none;" />
  58. <view style="display: flex;justify-content: flex-start;align-items: center;">
  59. <uni-icons type="folder-add" size="40" @click="gotochooseUser('multiple')"></uni-icons>
  60. <view style="display: flex;justify-content: flex-start;align-items: center;"
  61. v-for="(tag, index) in nikeNamelist" :key="index">
  62. <uni-icons type="right" size="20"></uni-icons>
  63. <view style="display: flex;flex-direction: column;justify-content: center;align-items: center;"
  64. @click="handleClose(index)">
  65. <span class="user-avatar">{{ tag.substring(0, 1) || 'U' }}</span>
  66. <text style="font-size: 12px;">{{tag}}</text>
  67. </view>
  68. </view>
  69. </view>
  70. </uni-forms-item>
  71. <uni-forms-item label="流程动态" v-if="tasks.length > 0">
  72. <uni-steps active-icon="medal" :options="tasks" active-color="#007AFF" :active="tasks.length"
  73. direction="column" />
  74. </uni-forms-item>
  75. </uni-forms>
  76. <view class="button-group" v-if="name == '0'">
  77. <button type="default" size="mini" @click="onReCommit('form')">提交</button>
  78. <button type="primary" size="mini" @click="onClose()">关闭</button>
  79. </view>
  80. <view class="button-group" v-else>
  81. <button type="primary" size="mini" @click="submit('form')">提交</button>
  82. <button type="default" size="mini" @click="onSave()">暂存</button>
  83. <button type="warn" size="mini" @click="onDelete()" v-if="form.auditStatus == 0">删除</button>
  84. </view>
  85. <view>
  86. <!-- 普通弹窗 -->
  87. <uni-popup ref="popup" background-color="#fff" border-radius="10px 10px 0 0">
  88. <view class="popup-body">
  89. <view class="popup-close">
  90. <uni-icons type="closeempty" size="20" @click="popupClose"></uni-icons>
  91. </view>
  92. <view class="popup-content">
  93. <pople-Select :type="popleSelectType" @submit="submitPeople" ref="popleSelect"></pople-Select>
  94. </view>
  95. </view>
  96. </uni-popup>
  97. </view>
  98. </view>
  99. </template>
  100. <script>
  101. import {
  102. getDetail,
  103. create,
  104. save,
  105. deleteById,
  106. closeById,
  107. reCommit
  108. } from "@/api/oa/renew.js"
  109. import {getDicts,getOpenDicts,listSimplePosts,listSimpleDepts } from "@/api/system/dict.js";
  110. import {
  111. uploadFile,
  112. getEmployeeInfo
  113. } from "@/api/system/user"
  114. import popleSelect from '../../popleSelect/choose.vue'
  115. export default {
  116. components: {
  117. popleSelect
  118. },
  119. props: {
  120. id: {
  121. type: [String, Number],
  122. default: undefined
  123. },
  124. name: {
  125. type: String,
  126. default: undefined
  127. },
  128. },
  129. data() {
  130. return {
  131. popleSelectType: 'single',
  132. deptOptions:[],
  133. postOptions:[],
  134. employeeTypeListOpen:[],
  135. userSexList:[],
  136. tasks: [],
  137. alignment: 'top',
  138. uploadOptions: {},
  139. fileList: [],
  140. icons: {
  141. close: '/static/icon_close.png',
  142. file: '/static/icon_file.png',
  143. },
  144. nikeNamelist: [],
  145. // 表单数据
  146. form: {
  147. employeeName: undefined,
  148. employeeId: undefined,
  149. deptName: undefined,
  150. position: undefined,
  151. employeePhone: undefined,
  152. oldContractStartDate: undefined,
  153. oldContractEndDate: undefined,
  154. renewPeriod: undefined,
  155. renewContractStartDate: undefined,
  156. renewContractEndDate: undefined,
  157. renewReason: undefined,
  158. workPerformance: undefined,
  159. fileIdList: undefined,
  160. remarks: undefined,
  161. peopleList: '',
  162. },
  163. // 校验规则
  164. rules: {
  165. employeeName: {
  166. rules: [{
  167. required: true,
  168. errorMessage: '请选择'
  169. }, ]
  170. },
  171. renewPeriod: {
  172. rules: [
  173. {
  174. required: true,
  175. errorMessage: '请输入'
  176. },
  177. {
  178. validateFunction: function(rule, value, data, callback) {
  179. let reg = /^[0-9]*$/
  180. if (!reg.test(value)) {
  181. callback("请输入数字")
  182. }
  183. return true
  184. }
  185. }
  186. ]
  187. },
  188. renewContractStartDate: {
  189. rules: [{
  190. required: true,
  191. errorMessage: '请选择'
  192. }, ]
  193. },
  194. renewContractEndDate: {
  195. rules: [{
  196. required: true,
  197. errorMessage: '请选择'
  198. }, ]
  199. },
  200. renewReason: {
  201. rules: [{
  202. required: true,
  203. errorMessage: '请输入'
  204. }, ]
  205. },
  206. peopleList: {
  207. rules: [{
  208. required: true,
  209. errorMessage: '请选择审批人'
  210. }, ]
  211. },
  212. },
  213. }
  214. },
  215. watch: {
  216. id: {
  217. immediate: true,
  218. handler(val) {
  219. this.getInfoDataList();
  220. if (val) {
  221. this.getDetail(val);
  222. }
  223. }
  224. }
  225. },
  226. methods: {
  227. maskClick(e) {
  228. console.log('----maskClick事件:', e);
  229. },
  230. /** 查询部门列表 */
  231. getInfoDataList() {
  232. listSimpleDepts().then(response => {
  233. response.data.forEach(v => {
  234. this.deptOptions.push({
  235. text: v.name,
  236. value: v.id,
  237. })
  238. })
  239. });
  240. getDicts('system_user_sex').then(response => {
  241. response.data.forEach(v => {
  242. this.userSexList.push({
  243. text: v.label,
  244. value: v.value,
  245. })
  246. })
  247. });
  248. getOpenDicts('tenant_employee_type').then(response => {
  249. response.data.forEach(v => {
  250. this.employeeTypeListOpen.push({
  251. text: v.label,
  252. value: v.value,
  253. })
  254. })
  255. });
  256. listSimplePosts().then(response => {
  257. response.data.forEach(v => {
  258. this.postOptions.push({
  259. text: v.name,
  260. value: v.id,
  261. })
  262. })
  263. });
  264. },
  265. /** 获得详情信息 */
  266. getDetail(val) {
  267. getDetail(val).then(response => {
  268. this.form = response.data;
  269. console.log(this.form);
  270. this.fileList = response.data.fileList ? response.data.fileList : [];
  271. let auditUserList = response.data.auditUserList;
  272. if (auditUserList) {
  273. let peopleList = [];
  274. let nikeNamelist = [];
  275. auditUserList.map(item => {
  276. peopleList.push(item.id);
  277. nikeNamelist.push(item.nickname)
  278. });
  279. this.$set(this.form, 'peopleList', peopleList.join(','));
  280. this.nikeNamelist = nikeNamelist;
  281. } else {
  282. this.$set(this.form, 'peopleList', '');
  283. this.nikeNamelist = [];
  284. }
  285. let auditRecordList = response.data.auditRecordList;
  286. if (auditRecordList) {
  287. let tasks = [];
  288. auditRecordList.forEach(v => {
  289. tasks.push({
  290. title: '任务:' + v.assigneeUser.nickname + v.name,
  291. desc: this.parseTime(v.endTime),
  292. })
  293. })
  294. this.tasks = tasks;
  295. }
  296. });
  297. },
  298. // 关闭标签
  299. handleClose(index) {
  300. this.nikeNamelist.splice(index, 1);
  301. let peopleList = this.form.peopleList.split(',');
  302. peopleList.splice(index, 1);
  303. this.form.peopleList = peopleList.join(',');
  304. },
  305. getEmployee() {
  306. getEmployeeInfo(this.form.employeeId).then(response => {
  307. let employeeInfo = response.data;
  308. this.form.deptName = employeeInfo.deptName;
  309. this.form.position = employeeInfo.position;
  310. this.form.employeePhone = employeeInfo.phone;
  311. this.form.oldContractStartDate = employeeInfo.oldContractStartDate;
  312. this.form.oldContractEndDate = employeeInfo.oldContractEndDate;
  313. });
  314. },
  315. submitPeople(userList, nikeNamelist, userIdList) {
  316. console.log(userList);
  317. console.log(userIdList);
  318. if(this.popleSelectType=='multiple'){
  319. this.nikeNamelist = nikeNamelist;
  320. this.form.peopleList = userIdList.join(',');
  321. this.$refs.popup.close();
  322. }else{
  323. this.form.employeeName = nikeNamelist.join();
  324. this.form.employeeId = userIdList.join();
  325. this.getEmployee();
  326. this.$refs.popup.close();
  327. }
  328. },
  329. popupClose() {
  330. this.$refs.popup.close();
  331. },
  332. gotochooseUser(type) {
  333. this.popleSelectType = type;
  334. this.$refs.popup.open('bottom');
  335. setTimeout(() => {
  336. this.$refs.popleSelect.getInfoData();
  337. })
  338. },
  339. handleUploadClick() {
  340. this.$refs.XeUpload.upload('file');
  341. },
  342. handleUploadCallback(e) {
  343. console.log('UploadCallback', e);
  344. let data = {
  345. filePath: e.data[0].tempFilePath
  346. }
  347. uploadFile(data).then(response => {
  348. const tmpFiles = ([response.data] || []).map(({
  349. id,
  350. url,
  351. name,
  352. type
  353. }) => {
  354. return {
  355. id,
  356. url,
  357. name,
  358. type,
  359. };
  360. });
  361. this.fileList.push(...tmpFiles);
  362. })
  363. },
  364. // 预览
  365. handlePreview(val) {
  366. console.log('PreviewFile', val);
  367. const fileType = this.getFileType(val.name);
  368. if (fileType === 'image') {
  369. uni.previewImage({
  370. current: 0,
  371. urls: [val.url],
  372. });
  373. } else if (fileType === 'office') {
  374. return uni.downloadFile({
  375. url: val.url,
  376. success: function(res) {
  377. let filePath = res.filePath || res.tempFilePath;
  378. uni.openDocument({
  379. filePath: filePath,
  380. showMenu: true,
  381. success: function(res) {
  382. console.log('打开文档成功');
  383. }
  384. });
  385. }
  386. });
  387. } else {
  388. uni.showModal({
  389. title: '该类型文件无法预览',
  390. content: val.name,
  391. showCancel: false,
  392. });
  393. }
  394. },
  395. handleDeleteFile(index) {
  396. this.fileList.splice(index, 1);
  397. },
  398. submit(ref) {
  399. this.$refs[ref].validate().then(res => {
  400. this.form.startUserSelectAssignees = this.form.peopleList.split(',');
  401. this.form.auditPass = true;
  402. create(this.form).then(response => {
  403. uni.showToast({
  404. title: `提交成功`
  405. })
  406. if(this.id){
  407. this.$emit('popupClose');
  408. }else{
  409. setTimeout(() => {
  410. this.$router.go(0)
  411. }, 500)
  412. }
  413. }).catch(() => {
  414. });
  415. }).catch(err => {
  416. console.log('err', err);
  417. })
  418. },
  419. //暂存
  420. onSave() {
  421. if (this.form.peopleList) {
  422. this.form.startUserSelectAssignees = this.form.peopleList.split(',');
  423. }
  424. this.form.auditPass = false;
  425. save(this.form).then(response => {
  426. uni.showToast({
  427. title: `暂存成功`
  428. })
  429. if(this.id){
  430. this.$emit('popupClose');
  431. }else{
  432. setTimeout(() => {
  433. this.$router.go(0)
  434. }, 500)
  435. }
  436. }).catch(() => {
  437. });
  438. },
  439. //驳回或撤回后再次提交
  440. onReCommit(ref) {
  441. this.$refs[ref].validate().then(res => {
  442. this.form.startUserSelectAssignees = this.form.peopleList.split(',');
  443. this.form.auditPass = true;
  444. reCommit(this.form).then(response => {
  445. uni.showToast({
  446. title: `提交成功`
  447. })
  448. this.$emit('popupClose');
  449. }).catch(() => {
  450. });
  451. }).catch(err => {
  452. console.log('err', err);
  453. })
  454. },
  455. //暂存删除
  456. async onDelete() {
  457. let that = this;
  458. uni.showModal({
  459. title: '提示',
  460. content: '是否确认删除?',
  461. success: function(res) {
  462. if (res.confirm) {
  463. console.log('用户点击确定');
  464. deleteById(that.id).then(response => {
  465. uni.showToast({
  466. title: "删除成功!"
  467. })
  468. that.$emit('popupClose');
  469. })
  470. } else if (res.cancel) {
  471. console.log('用户点击取消');
  472. }
  473. }
  474. });
  475. },
  476. //暂存关闭
  477. async onClose() {
  478. let that = this;
  479. uni.showModal({
  480. title: '提示',
  481. content: '是否确认关闭?',
  482. success: function(res) {
  483. if (res.confirm) {
  484. console.log('用户点击确定');
  485. closeById(that.id).then(response => {
  486. uni.showToast({
  487. title: "流程已关闭!"
  488. })
  489. that.$emit('popupClose');
  490. })
  491. } else if (res.cancel) {
  492. console.log('用户点击取消');
  493. }
  494. }
  495. });
  496. },
  497. }
  498. }
  499. </script>
  500. <style lang="scss">
  501. .container {
  502. padding: 15px;
  503. background-color: #fff;
  504. }
  505. .segmented-control {
  506. margin-bottom: 15px;
  507. }
  508. .button-group {
  509. margin-top: 15px;
  510. display: flex;
  511. }
  512. .form-item {
  513. display: flex;
  514. align-items: center;
  515. flex: 1;
  516. }
  517. .button {
  518. display: flex;
  519. align-items: center;
  520. height: 35px;
  521. line-height: 35px;
  522. margin-left: 10px;
  523. }
  524. </style>
  525. <style lang="scss" scoped>
  526. .user-avatar {
  527. width: 22px;
  528. height: 22px;
  529. line-height: 19px;
  530. font-size: 12px;
  531. background: #46c26f;
  532. border: 1px solid transparent;
  533. border-radius: 5px;
  534. color: #fff;
  535. display: inline-block;
  536. overflow: hidden;
  537. text-align: center;
  538. line-height: 22px;
  539. margin-bottom: 2px;
  540. }
  541. .popup-body {
  542. z-index: 99;
  543. margin-bottom: 30px;
  544. }
  545. .popup-close {
  546. cursor: pointer;
  547. height: 40px;
  548. line-height: 40px;
  549. padding-left: 10px;
  550. border-bottom: 1px solid #eaecef;
  551. }
  552. .popup-content {
  553. height: 450px;
  554. overflow-x: auto;
  555. margin: 20px;
  556. }
  557. .btn-click {
  558. transition: all 0.3s;
  559. opacity: 1;
  560. }
  561. .btn-click:active {
  562. opacity: 0.5;
  563. }
  564. .mgb-16 {
  565. margin-bottom: 16rpx;
  566. &:last-child {
  567. margin-bottom: 0;
  568. }
  569. }
  570. .upload-wrap {
  571. width: 100%;
  572. border-radius: 16rpx;
  573. background: white;
  574. // padding: 32rpx;
  575. .upload-btn {
  576. width: 100%;
  577. height: 176rpx;
  578. border: 2rpx dashed #AAAAAA;
  579. background: #FAFAFA;
  580. border-radius: 16rpx;
  581. display: flex;
  582. align-items: center;
  583. justify-content: center;
  584. flex-direction: column;
  585. .upload-icon {
  586. width: 48rpx;
  587. height: 48rpx;
  588. margin-bottom: 8rpx;
  589. }
  590. .upload-text {
  591. font-size: 26rpx;
  592. color: #9E9E9E;
  593. line-height: 40rpx;
  594. }
  595. }
  596. .file-wrap {
  597. .file-line {
  598. width: 100%;
  599. background: #F5F5F5;
  600. border-radius: 8rpx;
  601. padding: 16rpx;
  602. font-size: 26rpx;
  603. color: #1A1A1A;
  604. line-height: 40rpx;
  605. display: flex;
  606. align-items: center;
  607. justify-content: space-between;
  608. .file-info {
  609. width: 90%;
  610. display: flex;
  611. align-items: center;
  612. .file-name {
  613. max-width: 80%;
  614. padding-left: 16rpx;
  615. overflow: hidden;
  616. text-overflow: ellipsis;
  617. white-space: nowrap;
  618. }
  619. }
  620. .file-icon {
  621. width: 40rpx;
  622. height: 40rpx;
  623. flex-shrink: 0;
  624. }
  625. .file-empty {
  626. color: #999999;
  627. }
  628. }
  629. }
  630. }
  631. </style>