edit.vue 14 KB

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