edit.vue 15 KB

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