edit.vue 14 KB

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