geContract.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604
  1. <template>
  2. <view class="geHeight">
  3. <view style="height: 100%;">
  4. <u-gap height="10" bgColor="#f5f5f5"></u-gap>
  5. <view class="desc">
  6. <uni-row>
  7. <uni-col :span="5">
  8. <view class="desc">
  9. 标题
  10. </view>
  11. </uni-col>
  12. <uni-col :span="18">
  13. <view class="desc">
  14. {{data.formData.title}}
  15. </view>
  16. </uni-col>
  17. </uni-row>
  18. </view>
  19. <u-gap height="10" bgColor="#f5f5f5"></u-gap>
  20. <view class="desc">
  21. <uni-row>
  22. <uni-col :span="5">
  23. <view class="desc">
  24. 文件
  25. </view>
  26. </uni-col>
  27. <uni-col :span="18">
  28. <view class="u-demo-block">
  29. <text class="u-demo-block__title">点击下方文件名查看</text>
  30. <view class="u-demo-block__content">
  31. <view v-for="item in fileList" class="yyButton" style="border: 1rpx solid rgb(10, 185, 156);color: rgb(10, 185, 156);font-size: 22rpx; padding: 5rpx 15rpx;
  32. border-radius: 10rpx;" @click="previewFile(item.url)">
  33. {{item.name?item.name : "无名称"}}
  34. </view>
  35. </view>
  36. </view>
  37. </uni-col>
  38. </uni-row>
  39. </view>
  40. <u-gap height="10" bgColor="#f5f5f5"></u-gap>
  41. <view class="desc">
  42. <view class="desc">
  43. 图片
  44. </view>
  45. <view style="width: 100%;overflow-x: scroll;white-space: nowrap">
  46. <u-upload v-if="data.pageType >= 1 && data.pageType <= 2" :fileList="imgList" multiple width="120"
  47. height="120" useBeforeRead="true" disabled="true" uploadIcon="clock">
  48. </u-upload>
  49. <u-upload v-if="data.pageType >= 3" :fileList="data.formData.img_list" multiple width="120"
  50. height="120" useBeforeRead="true" disabled="true" uploadIcon="clock">
  51. </u-upload>
  52. </view>
  53. </view>
  54. <u-gap height="10" bgColor="#f5f5f5"></u-gap>
  55. <view class="desc">
  56. <uni-row>
  57. <uni-col :span="5">
  58. <view class="desc">
  59. 申请人
  60. </view>
  61. </uni-col>
  62. <uni-col :span="18">
  63. <view class="desc">
  64. {{data.formData.apply_user_name}}
  65. </view>
  66. </uni-col>
  67. </uni-row>
  68. </view>
  69. <u-gap height="10" bgColor="#f5f5f5"></u-gap>
  70. <view class="desc">
  71. <view>
  72. <uni-steps :options="list1" :active="active" direction="column" active-color="rgb(55,186,189)" />
  73. </view>
  74. </view>
  75. <u-gap height="10" bgColor="#f5f5f5"></u-gap>
  76. <view v-if="data.pageType === 1" class="desc">
  77. <view class="desc" style="color: #bababa;">
  78. 批注:
  79. </view>
  80. <view class="desc">
  81. <u--textarea v-model="pz" border="bottom"></u--textarea>
  82. </view>
  83. </view>
  84. <u-gap height="10" bgColor="#f5f5f5"></u-gap>
  85. </view>
  86. <view v-if="data.pageType == 3" class="bomButtonBody" style="height: 10%;">
  87. <uni-row v-if="list1 && list1.length === 1">
  88. <uni-col>
  89. <view class="desc">
  90. <u-button :disabled="isDisabled" color="rgb(55,186,189)" shape="circle" size="large"
  91. @click="revoke">撤销
  92. </u-button>
  93. </view>
  94. </uni-col>
  95. </uni-row>
  96. <uni-row>
  97. <uni-col>
  98. <view class="desc">
  99. <!-- <u-button :disabled="isDisabled" color="rgb(55,186,189)" shape="circle" size="large"
  100. @click="againLaunch">再次发起
  101. </u-button> -->
  102. </view>
  103. </uni-col>
  104. </uni-row>
  105. </view>
  106. <u-gap height="110" bgColor="#f5f5f5"></u-gap>
  107. <view v-if="data.pageType === 1 && zindeButtion === 1 && data.isEnd === '0'" class="bomButtonBody"
  108. style="position: fixed;bottom: 0">
  109. <uni-row>
  110. <uni-col :span="10">
  111. <view class="desc">
  112. <u-button color="rgb(55,186,189)" shape="circle" size="large"
  113. @click="passTrue('同意','RESULT_TRUE','bottom')">同意,下一步
  114. </u-button>
  115. </view>
  116. </uni-col>
  117. <uni-col :span="7.5">
  118. <view class="desc">
  119. <u-button color="rgb(188, 188, 188)" shape="circle" size="large"
  120. @click="passTrue('驳回','RESULT_FALSE','bottom')">驳回</u-button>
  121. </view>
  122. </uni-col>
  123. <uni-col :span="7.5">
  124. <view class="desc">
  125. <u-button color="rgb(136, 188, 160)" shape="circle" size="large"
  126. @click="passTrue('驳回','RESULT_CASE_OF','bottom')">转交</u-button>
  127. </view>
  128. </uni-col>
  129. </uni-row>
  130. </view>
  131. <view>
  132. <!-- 普通弹窗 -->
  133. <uni-popup ref="popup" background-color="#fff" @change="propChange">
  134. <view class="popup-content" :class="{ 'popup-height': type === 'left' || type === 'right' }">
  135. <view class="desc">
  136. <uni-row>
  137. <uni-col :span="8">
  138. <view style="font-size: 40rpx;color: rgb(145, 145, 145);">
  139. </view>
  140. </uni-col>
  141. <uni-col :span="13">
  142. <view style="font-size: 40rpx;color: rgb(98, 98, 98);">
  143. {{nextTitle}}
  144. </view>
  145. </uni-col>
  146. <uni-col :span="3">
  147. <view @click="submitPass" style="font-size: 40rpx;color: rgb(55,186,189);">
  148. 确认
  149. </view>
  150. </uni-col>
  151. </uni-row>
  152. </view>
  153. <view class="desc">
  154. <uni-row>
  155. <uni-col>
  156. <view class="desc">
  157. <uni-data-picker ref="picker" placeholder="请选择" :popup-title="selectTitle"
  158. :localdata="dataTree" v-model="nextUserName" @change="nextApprovalChange">
  159. </uni-data-picker>
  160. </view>
  161. </uni-col>
  162. </uni-row>
  163. </view>
  164. </view>
  165. </uni-popup>
  166. </view>
  167. <view>
  168. <!-- 驳回选择弹窗 -->
  169. <uni-popup ref="popup2" background-color="#fff" @change="propChange">
  170. <view style="height: 800rpx;">
  171. <view class="desc">
  172. <view style="text-align: center;font-size: 30rpx;color: rgb(98, 98, 98);">
  173. 驳回至以下任意流程
  174. </view>
  175. </view>
  176. <view style="padding: 20rpx 10rpx;">
  177. <uni-list v-for="item in rejectHistoryData">
  178. <uni-list-item :clickable="true" @click="rejectSubmit(item)" :title="item.comment" />
  179. </uni-list>
  180. </view>
  181. </view>
  182. </uni-popup>
  183. </view>
  184. </view>
  185. </template>
  186. <script>
  187. export default {
  188. data() {
  189. return {
  190. pz: '',
  191. nextApproval: '',
  192. nextUserName: '',
  193. app_vacate_type: uni.getStorageSync('app_vacate_type'),
  194. data: uni.getStorageSync("approval"),
  195. form: {},
  196. dataTree: [],
  197. queryParams: {},
  198. historyData: [],
  199. nextTitle: '',
  200. selectTitle: '',
  201. active: 0,
  202. list1: [],
  203. isDisabled: false,
  204. actions: [],
  205. type: 'center',
  206. zindeButtion: 1,
  207. rejectHistoryData: [],
  208. fileList: [],
  209. imgList: []
  210. }
  211. },
  212. onLoad() {
  213. uni.showLoading({
  214. title: '正在加载'
  215. })
  216. setTimeout(() => {
  217. let start = new Date().getTime()
  218. this.fileList = JSON.parse(this.data.formData.file_list)
  219. this.imgList = JSON.parse(this.data.formData.img_list)
  220. }, 10)
  221. this.getHouXuanZu()
  222. this.getListHistory()
  223. this.readTask()
  224. if (this.data.baseName && this.data.pageType === 1) {
  225. uni.setNavigationBarTitle({
  226. title: this.data.baseName
  227. })
  228. }
  229. },
  230. methods: {
  231. rejectSubmit(item) {
  232. this.form.rejectBaseId = item.baseId
  233. this.nextApproval = item.operator
  234. this.submitPass()
  235. },
  236. nextApprovalChange(e) {
  237. console.log('onchange:', e.detail.value[1]);
  238. this.nextUserName = e.detail.value[1].text
  239. this.nextApproval = e.detail.value[1].value
  240. },
  241. propChange(e) {
  242. if (e.show) {
  243. this.zindeButtion = 0
  244. } else {
  245. this.zindeButtion = 1
  246. }
  247. },
  248. againLaunch() {
  249. this.$goto('../hr/leave')
  250. },
  251. async revoke() {
  252. const {
  253. data: res
  254. } = await this.$httpRequest({
  255. url: '/app/revoke?taskId=' + this.data.taskId,
  256. method: 'get'
  257. });
  258. if (res.code === 200) {
  259. uni.showModal({
  260. title: "撤销成功",
  261. icon: "OK",
  262. showCancel: false,
  263. success() {
  264. uni.navigateBack()
  265. }
  266. })
  267. } else {
  268. uni.showModal({
  269. title: "撤销失败",
  270. content: res.msg,
  271. showCancel: false,
  272. success() {
  273. uni.navigateBack()
  274. }
  275. })
  276. }
  277. },
  278. previewFile(fileUrl) {
  279. uni.showLoading({
  280. title: '加载中'
  281. })
  282. uni.downloadFile({
  283. url: fileUrl, //后端返回的文件地址
  284. // filePath: wx.env.USER_DATA_PATH + '/' + item.name + '.' + item.value.split('.')[item.value.split('.').length - 1],
  285. success: function(res) {
  286. if (res.statusCode === 200) {
  287. uni.openDocument({
  288. showMenu: true,
  289. filePath: res.tempFilePath,
  290. success: function(res) {
  291. console.log(res, '打开文件成功')
  292. },
  293. fail: (err) => {
  294. uni.showToast({
  295. title: '打开文件失败请重试',
  296. icon: 'none'
  297. })
  298. }
  299. })
  300. } else {
  301. uni.showToast({
  302. title: '打开文件失败请重试',
  303. icon: 'none'
  304. })
  305. }
  306. uni.hideLoading()
  307. },
  308. fail: (err) => {
  309. uni.hideLoading()
  310. uni.showToast({
  311. title: '加载失败请重试',
  312. icon: "none"
  313. })
  314. }
  315. })
  316. },
  317. async readTask() {
  318. if (this.data.msgIsRead === '0') {
  319. const {
  320. data: res
  321. } = await this.$httpRequest({
  322. url: '/app/rt?taskId=' + this.data.id,
  323. method: 'get'
  324. });
  325. if (res.code === 200) {
  326. let msgData = uni.getStorageSync("msgData")
  327. if (this.pageType === 1) {
  328. --msgData.m1
  329. } else if (this.pageType === 3) {
  330. --msgData.m4
  331. } else if (this.pageType === 4) {
  332. --msgData.m7
  333. }
  334. uni.setStorageSync("msgData", msgData)
  335. }
  336. }
  337. },
  338. async getHouXuanZu() {
  339. const {
  340. data: res
  341. } = await this.$httpRequest({
  342. url: '/app/pL?taskId=' + this.data.id + '&groupId=' + this.data.baseGroupId + '&baseId=' +
  343. this.data.baseId,
  344. method: 'get'
  345. });
  346. if (res.code === 200) {
  347. this.dataTree = res.data
  348. }
  349. uni.hideLoading()
  350. },
  351. async getListHistory() {
  352. let id = this.data.taskId ? this.data.taskId : this.data.id
  353. const {
  354. data: res
  355. } = await this.$httpRequest({
  356. url: '/app/ctr?taskId=' + id,
  357. method: 'get',
  358. data: this.queryParams
  359. });
  360. if (res.code === 200) {
  361. uni.hideLoading()
  362. this.historyData = res.data
  363. this.list1
  364. if (0 != this.historyData.length) {
  365. for (var i = 0; i < this.historyData.length; i++) {
  366. if (this.historyData[i].comment && this.historyData[i].comment === "自动结束" ||
  367. this.historyData[i].comment === "流程结束") {
  368. this.list1.push({
  369. title: this.historyData[i].comment,
  370. desc: this.historyData[i].createTime
  371. })
  372. } else {
  373. this.list1.push({
  374. title: this.historyData[i].operator + ' ' + this.historyData[i].comment,
  375. desc: this.historyData[i].createTime
  376. })
  377. }
  378. }
  379. } else {
  380. this.list1.push({
  381. title: "待审批"
  382. })
  383. }
  384. if (this.historyData[this.historyData.length - 1]) {
  385. if (!(this.historyData[this.historyData.length - 1].comment === "同意并结束") &&
  386. !(this.historyData[this.historyData.length - 1].comment === "自动结束") &&
  387. !(this.historyData[this.historyData.length - 1].comment === "流程结束")) {
  388. this.list1.push({
  389. title: "待审批"
  390. })
  391. }
  392. }
  393. this.active = this.list1.length - 1
  394. }
  395. },
  396. dataForm(comment, pass) {
  397. this.form = {
  398. comment: this.pz ? this.pz : comment,
  399. result: pass,
  400. baseId: this.data.baseId,
  401. taskId: this.data.id,
  402. nextApproval: this.nextApproval,
  403. nextUserName: this.nextUserName,
  404. formData: this.data.formData
  405. }
  406. },
  407. passTrue(comment, pass, type) {
  408. this.dataForm(comment, pass)
  409. if (pass === 'RESULT_TRUE' && this.data.isCandidate == "1") {
  410. this.submitPass()
  411. return
  412. }
  413. if (pass === 'RESULT_FALSE') {
  414. this.getRejectListHistory()
  415. return
  416. }
  417. if (pass === 'RESULT_CASE_OF') {
  418. this.getCurrentHouXuanZu()
  419. this.selectTitle = '请选择转交人'
  420. this.nextTitle = '请选择转交人'
  421. this.$refs.popup.open(type)
  422. return
  423. }
  424. this.getHouXuanZu()
  425. this.nextTitle = '下一步审批人'
  426. this.type = type
  427. // open 方法传入参数 等同在 uni-popup 组件上绑定 type属性
  428. this.$refs.popup.open(type)
  429. },
  430. async getRejectListHistory() {
  431. uni.showLoading({
  432. title: '加载中',
  433. mask: true
  434. })
  435. let id = this.data.taskId ? this.data.taskId : this.data.id
  436. const {
  437. data: res
  438. } = await this.$httpRequest({
  439. url: '/app/reject/ctr?taskId=' + id,
  440. method: 'get',
  441. data: this.queryParams
  442. });
  443. if (res.code === 200) {
  444. if (res.data.length == 0) {
  445. this.submitPass()
  446. return
  447. }
  448. this.$refs.popup2.open('bottom')
  449. this.rejectHistoryData = res.data
  450. uni.hideLoading()
  451. }
  452. },
  453. async getCurrentHouXuanZu() {
  454. uni.showLoading({
  455. title: '加载中',
  456. mask: true
  457. })
  458. const {
  459. data: res
  460. } = await this.$httpRequest({
  461. url: '/app/currentPL?taskId=' + this.data.id + '&groupId=' + this.data.baseGroupId +
  462. '&baseId=' + this.data.baseId,
  463. method: 'get'
  464. });
  465. if (res.code === 200) {
  466. this.dataTree = res.data
  467. uni.hideLoading()
  468. }
  469. },
  470. async submitPass() {
  471. uni.showLoading({
  472. mask: true,
  473. title: '正在提交'
  474. })
  475. if (this.form.result !== 'RESULT_FALSE' && this.data.isCandidate == "0" && 2.0 < parseFloat(this.data
  476. .formData.total_time)) {
  477. if (!this.nextApproval) {
  478. uni.showModal({
  479. content: '请选择批准人',
  480. title: '提交失败',
  481. showCancel: false
  482. })
  483. this.isDisabled = false
  484. return
  485. }
  486. }
  487. this.form.nextApproval = this.nextApproval
  488. this.form.nextUserName = this.nextUserName
  489. const {
  490. data: res
  491. } = await this.$httpRequest({
  492. url: '/app/nextStep',
  493. method: 'post',
  494. data: this.form
  495. });
  496. if (res.code === 200) {
  497. uni.hideLoading()
  498. uni.showModal({
  499. title: "提交成功",
  500. icon: "OK",
  501. showCancel: false,
  502. success() {
  503. setTimeout(() => {
  504. this.isDisabled = false
  505. }, 1000)
  506. uni.navigateBack()
  507. }
  508. })
  509. } else {
  510. uni.showModal({
  511. title: "提交失败",
  512. icon: "ERROR",
  513. showCancel: false,
  514. content: res.msg
  515. })
  516. }
  517. setTimeout(() => {
  518. this.isDisabled = false
  519. }, 1000)
  520. setTimeout(() => {
  521. this.isDisabled = false
  522. uni.hideLoading()
  523. }, 1000)
  524. },
  525. dateFormat(time) {
  526. let date = new Date(time);
  527. let year = date.getFullYear();
  528. // 在日期格式中,月份是从0开始的,因此要加0,使用三元表达式在小于10的前面加0,以达到格式统一 如 09:11:05
  529. let month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
  530. let day = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
  531. let hours = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
  532. let minutes = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
  533. let seconds = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
  534. // 拼接
  535. // return year + "-" + month + "-" + day + " " + hours + ":" + minutes + ":" + seconds;
  536. return year + "/" + month + "/" + day;
  537. }
  538. }
  539. }
  540. </script>
  541. <style lang="scss" scoped>
  542. .desc {
  543. padding: 10rpx;
  544. }
  545. .u-page {
  546. &__button-item {
  547. margin: 0 15px 5px 0;
  548. }
  549. }
  550. .u-demo-block__content {
  551. flex-direction: row;
  552. flex-wrap: wrap;
  553. align-items: center;
  554. }
  555. .popup-content {
  556. height: 800rpx;
  557. }
  558. .geHeight {
  559. height: 100%;
  560. position: relative;
  561. }
  562. .bomButtonBody {
  563. border-top: 5rpx #f5f5f5 solid;
  564. padding: 30rpx 0 50rpx 0;
  565. width: 100%;
  566. background-color: #ffffff;
  567. }
  568. .status-btn {
  569. /* #ifndef APP-NVUE */
  570. display: flex;
  571. /* #endif */
  572. flex-direction: row;
  573. align-items: center;
  574. justify-content: center;
  575. height: 92rpx;
  576. margin: 30rpx;
  577. background-color: #007AFF;
  578. }
  579. .example-body {
  580. /* #ifndef APP-NVUE */
  581. display: block;
  582. /* #endif */
  583. padding: 15px;
  584. flex-direction: row;
  585. }
  586. .check-btn {
  587. display: flex;
  588. justify-content: space-between;
  589. margin-bottom: 10px;
  590. }
  591. </style>