edit.vue 15 KB

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