edit.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681
  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. let reason = v.reason?v.reason:'';
  291. let time = v.endTime?v.endTime:v.createTime;
  292. tasks.push({
  293. title:'任务:' + v.assigneeUser.nickname + v.name,
  294. desc: reason + " " + this.parseTime(time),
  295. })
  296. })
  297. this.tasks = tasks;
  298. }
  299. });
  300. },
  301. // 关闭标签
  302. handleClose(index) {
  303. this.nikeNamelist.splice(index, 1);
  304. let peopleList = this.form.peopleList.split(',');
  305. peopleList.splice(index, 1);
  306. this.form.peopleList = peopleList.join(',');
  307. },
  308. getEmployee() {
  309. getEmployeeInfo(this.form.employeeId).then(response => {
  310. let employeeInfo = response.data;
  311. this.form.deptName = employeeInfo.deptName;
  312. this.form.position = employeeInfo.position;
  313. this.form.employeePhone = employeeInfo.phone;
  314. this.form.oldContractStartDate = employeeInfo.oldContractStartDate;
  315. this.form.oldContractEndDate = employeeInfo.oldContractEndDate;
  316. });
  317. },
  318. submitPeople(userList, nikeNamelist, userIdList) {
  319. console.log(userList);
  320. console.log(userIdList);
  321. if (this.popleSelectType == 'multiple') {
  322. this.nikeNamelist = nikeNamelist;
  323. this.form.peopleList = userIdList.join(',');
  324. this.$refs.popup.close();
  325. } else {
  326. this.form.employeeName = nikeNamelist.join();
  327. this.form.employeeId = userIdList.join();
  328. this.getEmployee();
  329. this.$refs.popup.close();
  330. }
  331. },
  332. popupClose() {
  333. this.$refs.popup.close();
  334. },
  335. gotochooseUser(type) {
  336. this.popleSelectType = type;
  337. this.$refs.popup.open('bottom');
  338. setTimeout(() => {
  339. this.$refs.popleSelect.getInfoData();
  340. })
  341. },
  342. handleUploadClick() {
  343. this.$refs.XeUpload.upload('file');
  344. },
  345. handleUploadCallback(e) {
  346. console.log('UploadCallback', e);
  347. let data = {
  348. filePath: e.data[0].tempFilePath
  349. }
  350. uploadFile(data).then(response => {
  351. const tmpFiles = ([response.data] || []).map(({
  352. id,
  353. url,
  354. name,
  355. type
  356. }) => {
  357. return {
  358. id,
  359. url,
  360. name,
  361. type,
  362. };
  363. });
  364. this.fileList.push(...tmpFiles);
  365. })
  366. },
  367. // 预览
  368. handlePreview(val) {
  369. console.log('PreviewFile', val);
  370. const fileType = this.getFileType(val.name);
  371. if (fileType === 'image') {
  372. uni.previewImage({
  373. current: 0,
  374. urls: [val.url],
  375. });
  376. } else if (fileType === 'office') {
  377. return uni.downloadFile({
  378. url: val.url,
  379. success: function (res) {
  380. let filePath = res.filePath || res.tempFilePath;
  381. uni.openDocument({
  382. filePath: filePath,
  383. showMenu: true,
  384. success: function (res) {
  385. console.log('打开文档成功');
  386. }
  387. });
  388. }
  389. });
  390. } else {
  391. uni.showModal({
  392. title: '该类型文件无法预览',
  393. content: val.name,
  394. showCancel: false,
  395. });
  396. }
  397. },
  398. handleDeleteFile(index) {
  399. this.fileList.splice(index, 1);
  400. },
  401. submit(ref) {
  402. this.$refs[ref].validate().then(res => {
  403. this.form.startUserSelectAssignees = this.form.peopleList.split(',');
  404. this.form.auditPass = true;
  405. let fileIds = [];
  406. this.fileList.forEach(v => {
  407. fileIds.push(v.id)
  408. })
  409. this.form.fileIdList = fileIds;
  410. create(this.form).then(response => {
  411. uni.showToast({
  412. title: `提交成功`
  413. })
  414. if (this.id) {
  415. this.$emit('popupClose');
  416. } else {
  417. setTimeout(() => {
  418. this.$router.go(0)
  419. }, 500)
  420. }
  421. }).catch(() => {
  422. });
  423. }).catch(err => {
  424. console.log('err', err);
  425. })
  426. },
  427. //暂存
  428. onSave() {
  429. if (this.form.peopleList) {
  430. this.form.startUserSelectAssignees = this.form.peopleList.split(',');
  431. }
  432. this.form.auditPass = false;
  433. let fileIds = [];
  434. this.fileList.forEach(v => {
  435. fileIds.push(v.id)
  436. })
  437. this.form.fileIdList = fileIds;
  438. save(this.form).then(response => {
  439. uni.showToast({
  440. title: `暂存成功`
  441. })
  442. if (this.id) {
  443. this.$emit('popupClose');
  444. } else {
  445. setTimeout(() => {
  446. this.$router.go(0)
  447. }, 500)
  448. }
  449. }).catch(() => {
  450. });
  451. },
  452. //驳回或撤回后再次提交
  453. onReCommit(ref) {
  454. this.$refs[ref].validate().then(res => {
  455. this.form.startUserSelectAssignees = this.form.peopleList.split(',');
  456. this.form.auditPass = true;
  457. let fileIds = [];
  458. this.fileList.forEach(v => {
  459. fileIds.push(v.id)
  460. })
  461. this.form.fileIdList = fileIds;
  462. reCommit(this.form).then(response => {
  463. uni.showToast({
  464. title: `提交成功`
  465. })
  466. this.$emit('popupClose');
  467. }).catch(() => {
  468. });
  469. }).catch(err => {
  470. console.log('err', err);
  471. })
  472. },
  473. //暂存删除
  474. async onDelete() {
  475. let that = this;
  476. uni.showModal({
  477. title: '提示',
  478. content: '是否确认删除?',
  479. success: function (res) {
  480. if (res.confirm) {
  481. console.log('用户点击确定');
  482. deleteById(that.id).then(response => {
  483. uni.showToast({
  484. title: "删除成功!"
  485. })
  486. that.$emit('popupClose');
  487. })
  488. } else if (res.cancel) {
  489. console.log('用户点击取消');
  490. }
  491. }
  492. });
  493. },
  494. //暂存关闭
  495. async onClose() {
  496. let that = this;
  497. uni.showModal({
  498. title: '提示',
  499. content: '是否确认关闭?',
  500. success: function (res) {
  501. if (res.confirm) {
  502. console.log('用户点击确定');
  503. closeById(that.id).then(response => {
  504. uni.showToast({
  505. title: "流程已关闭!"
  506. })
  507. that.$emit('popupClose');
  508. })
  509. } else if (res.cancel) {
  510. console.log('用户点击取消');
  511. }
  512. }
  513. });
  514. },
  515. }
  516. }
  517. </script>
  518. <style lang="scss">
  519. .container {
  520. padding: 15px;
  521. background-color: #fff;
  522. }
  523. .segmented-control {
  524. margin-bottom: 15px;
  525. }
  526. .button-group {
  527. margin-top: 15px;
  528. display: flex;
  529. }
  530. .form-item {
  531. display: flex;
  532. align-items: center;
  533. flex: 1;
  534. }
  535. .button {
  536. display: flex;
  537. align-items: center;
  538. height: 35px;
  539. line-height: 35px;
  540. margin-left: 10px;
  541. }
  542. </style>
  543. <style lang="scss" scoped>
  544. .user-avatar {
  545. width: 22px;
  546. height: 22px;
  547. line-height: 19px;
  548. font-size: 12px;
  549. background: #46c26f;
  550. border: 1px solid transparent;
  551. border-radius: 5px;
  552. color: #fff;
  553. display: inline-block;
  554. overflow: hidden;
  555. text-align: center;
  556. line-height: 22px;
  557. margin-bottom: 2px;
  558. }
  559. .popup-body {
  560. z-index: 99;
  561. margin-bottom: 30px;
  562. }
  563. .popup-close {
  564. cursor: pointer;
  565. height: 40px;
  566. line-height: 40px;
  567. padding-left: 10px;
  568. border-bottom: 1px solid #eaecef;
  569. }
  570. .popup-content {
  571. height: 450px;
  572. overflow-x: auto;
  573. margin: 20px;
  574. }
  575. .btn-click {
  576. transition: all 0.3s;
  577. opacity: 1;
  578. }
  579. .btn-click:active {
  580. opacity: 0.5;
  581. }
  582. .mgb-16 {
  583. margin-bottom: 16rpx;
  584. &:last-child {
  585. margin-bottom: 0;
  586. }
  587. }
  588. .upload-wrap {
  589. width: 100%;
  590. border-radius: 16rpx;
  591. background: white;
  592. // padding: 32rpx;
  593. .upload-btn {
  594. width: 100%;
  595. height: 176rpx;
  596. border: 2rpx dashed #AAAAAA;
  597. background: #FAFAFA;
  598. border-radius: 16rpx;
  599. display: flex;
  600. align-items: center;
  601. justify-content: center;
  602. flex-direction: column;
  603. .upload-icon {
  604. width: 48rpx;
  605. height: 48rpx;
  606. margin-bottom: 8rpx;
  607. }
  608. .upload-text {
  609. font-size: 26rpx;
  610. color: #9E9E9E;
  611. line-height: 40rpx;
  612. }
  613. }
  614. .file-wrap {
  615. .file-line {
  616. width: 100%;
  617. background: #F5F5F5;
  618. border-radius: 8rpx;
  619. padding: 16rpx;
  620. font-size: 26rpx;
  621. color: #1A1A1A;
  622. line-height: 40rpx;
  623. display: flex;
  624. align-items: center;
  625. justify-content: space-between;
  626. .file-info {
  627. width: 90%;
  628. display: flex;
  629. align-items: center;
  630. .file-name {
  631. max-width: 80%;
  632. padding-left: 16rpx;
  633. overflow: hidden;
  634. text-overflow: ellipsis;
  635. white-space: nowrap;
  636. }
  637. }
  638. .file-icon {
  639. width: 40rpx;
  640. height: 40rpx;
  641. flex-shrink: 0;
  642. }
  643. .file-empty {
  644. color: #999999;
  645. }
  646. }
  647. }
  648. }
  649. </style>