edit.vue 15 KB

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