edit.vue 16 KB

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