edit.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645
  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. reCommit(this.form).then(response => {
  427. uni.showToast({
  428. title: `提交成功`
  429. })
  430. this.$emit('popupClose');
  431. }).catch(() => {
  432. });
  433. }).catch(err => {
  434. console.log('err', err);
  435. })
  436. },
  437. //暂存删除
  438. async onDelete() {
  439. let that = this;
  440. uni.showModal({
  441. title: '提示',
  442. content: '是否确认删除?',
  443. success: function (res) {
  444. if (res.confirm) {
  445. console.log('用户点击确定');
  446. deleteById(that.id).then(response => {
  447. uni.showToast({
  448. title: "删除成功!"
  449. })
  450. that.$emit('popupClose');
  451. })
  452. } else if (res.cancel) {
  453. console.log('用户点击取消');
  454. }
  455. }
  456. });
  457. },
  458. //暂存关闭
  459. async onClose() {
  460. let that = this;
  461. uni.showModal({
  462. title: '提示',
  463. content: '是否确认关闭?',
  464. success: function (res) {
  465. if (res.confirm) {
  466. console.log('用户点击确定');
  467. closeById(that.id).then(response => {
  468. uni.showToast({
  469. title: "流程已关闭!"
  470. })
  471. that.$emit('popupClose');
  472. })
  473. } else if (res.cancel) {
  474. console.log('用户点击取消');
  475. }
  476. }
  477. });
  478. },
  479. }
  480. }
  481. </script>
  482. <style lang="scss">
  483. .container {
  484. padding: 15px;
  485. background-color: #fff;
  486. }
  487. .segmented-control {
  488. margin-bottom: 15px;
  489. }
  490. .button-group {
  491. margin-top: 15px;
  492. display: flex;
  493. }
  494. .form-item {
  495. display: flex;
  496. align-items: center;
  497. flex: 1;
  498. }
  499. .button {
  500. display: flex;
  501. align-items: center;
  502. height: 35px;
  503. line-height: 35px;
  504. margin-left: 10px;
  505. }
  506. </style>
  507. <style lang="scss" scoped>
  508. .user-avatar {
  509. width: 22px;
  510. height: 22px;
  511. line-height: 19px;
  512. font-size: 12px;
  513. background: #46c26f;
  514. border: 1px solid transparent;
  515. border-radius: 5px;
  516. color: #fff;
  517. display: inline-block;
  518. overflow: hidden;
  519. text-align: center;
  520. line-height: 22px;
  521. margin-bottom: 2px;
  522. }
  523. .popup-body {
  524. z-index: 99;
  525. margin-bottom: 30px;
  526. }
  527. .popup-close {
  528. cursor: pointer;
  529. height: 40px;
  530. line-height: 40px;
  531. padding-left: 10px;
  532. border-bottom: 1px solid #eaecef;
  533. }
  534. .popup-content {
  535. height: 450px;
  536. overflow-x: auto;
  537. margin: 20px;
  538. }
  539. .btn-click {
  540. transition: all 0.3s;
  541. opacity: 1;
  542. }
  543. .btn-click:active {
  544. opacity: 0.5;
  545. }
  546. .mgb-16 {
  547. margin-bottom: 16rpx;
  548. &:last-child {
  549. margin-bottom: 0;
  550. }
  551. }
  552. .upload-wrap {
  553. width: 100%;
  554. border-radius: 16rpx;
  555. background: white;
  556. // padding: 32rpx;
  557. .upload-btn {
  558. width: 100%;
  559. height: 176rpx;
  560. border: 2rpx dashed #AAAAAA;
  561. background: #FAFAFA;
  562. border-radius: 16rpx;
  563. display: flex;
  564. align-items: center;
  565. justify-content: center;
  566. flex-direction: column;
  567. .upload-icon {
  568. width: 48rpx;
  569. height: 48rpx;
  570. margin-bottom: 8rpx;
  571. }
  572. .upload-text {
  573. font-size: 26rpx;
  574. color: #9E9E9E;
  575. line-height: 40rpx;
  576. }
  577. }
  578. .file-wrap {
  579. .file-line {
  580. width: 100%;
  581. background: #F5F5F5;
  582. border-radius: 8rpx;
  583. padding: 16rpx;
  584. font-size: 26rpx;
  585. color: #1A1A1A;
  586. line-height: 40rpx;
  587. display: flex;
  588. align-items: center;
  589. justify-content: space-between;
  590. .file-info {
  591. width: 90%;
  592. display: flex;
  593. align-items: center;
  594. .file-name {
  595. max-width: 80%;
  596. padding-left: 16rpx;
  597. overflow: hidden;
  598. text-overflow: ellipsis;
  599. white-space: nowrap;
  600. }
  601. }
  602. .file-icon {
  603. width: 40rpx;
  604. height: 40rpx;
  605. flex-shrink: 0;
  606. }
  607. .file-empty {
  608. color: #999999;
  609. }
  610. }
  611. }
  612. }
  613. </style>