geNewsApproval.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599
  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"
  47. multiple width="120" 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=' + this.data.baseId,
  343. method: 'get'
  344. });
  345. if (res.code === 200) {
  346. this.dataTree = res.data
  347. }
  348. uni.hideLoading()
  349. },
  350. async getListHistory() {
  351. let id = this.data.taskId ? this.data.taskId : this.data.id
  352. const {
  353. data: res
  354. } = await this.$httpRequest({
  355. url: '/app/ctr?taskId=' + id,
  356. method: 'get',
  357. data: this.queryParams
  358. });
  359. if (res.code === 200) {
  360. uni.hideLoading()
  361. this.historyData = res.data
  362. this.list1
  363. if (0 != this.historyData.length) {
  364. for (var i = 0; i < this.historyData.length; i++) {
  365. if (this.historyData[i].comment && this.historyData[i].comment === "自动结束") {
  366. this.list1.push({
  367. title: this.historyData[i].comment,
  368. desc: this.historyData[i].createTime
  369. })
  370. } else {
  371. this.list1.push({
  372. title: this.historyData[i].operator + ' ' + this.historyData[i].comment,
  373. desc: this.historyData[i].createTime
  374. })
  375. }
  376. }
  377. } else {
  378. this.list1.push({
  379. title: "待审批"
  380. })
  381. }
  382. if (this.historyData[this.historyData.length - 1]) {
  383. if (!(this.historyData[this.historyData.length - 1].comment === "同意并结束") &&
  384. !(this.historyData[this.historyData.length - 1].comment === "自动结束")) {
  385. this.list1.push({
  386. title: "待审批"
  387. })
  388. }
  389. }
  390. this.active = this.list1.length - 1
  391. }
  392. },
  393. dataForm(comment, pass) {
  394. this.form = {
  395. comment: this.pz ? this.pz : comment,
  396. result: pass,
  397. baseId: this.data.baseId,
  398. taskId: this.data.id,
  399. nextApproval: this.nextApproval,
  400. nextUserName: this.nextUserName,
  401. formData: this.data.formData
  402. }
  403. },
  404. passTrue(comment, pass, type) {
  405. this.dataForm(comment, pass)
  406. if (pass === 'RESULT_TRUE' && this.data.isCandidate == "1") {
  407. this.submitPass()
  408. return
  409. }
  410. if (pass === 'RESULT_FALSE') {
  411. this.getRejectListHistory()
  412. return
  413. }
  414. if (pass === 'RESULT_CASE_OF') {
  415. this.getCurrentHouXuanZu()
  416. this.selectTitle = '请选择转交人'
  417. this.nextTitle = '请选择转交人'
  418. this.$refs.popup.open(type)
  419. return
  420. }
  421. this.nextTitle = '下一步审批人'
  422. this.type = type
  423. // open 方法传入参数 等同在 uni-popup 组件上绑定 type属性
  424. this.$refs.popup.open(type)
  425. },
  426. async getRejectListHistory() {
  427. uni.showLoading({
  428. title: '加载中',
  429. mask: true
  430. })
  431. let id = this.data.taskId ? this.data.taskId : this.data.id
  432. const {
  433. data: res
  434. } = await this.$httpRequest({
  435. url: '/app/reject/ctr?taskId=' + id,
  436. method: 'get',
  437. data: this.queryParams
  438. });
  439. if (res.code === 200) {
  440. if (res.data.length == 0) {
  441. this.submitPass()
  442. return
  443. }
  444. this.$refs.popup2.open('bottom')
  445. this.rejectHistoryData = res.data
  446. uni.hideLoading()
  447. }
  448. },
  449. async getCurrentHouXuanZu() {
  450. uni.showLoading({
  451. title: '加载中',
  452. mask: true
  453. })
  454. const {
  455. data: res
  456. } = await this.$httpRequest({
  457. url: '/app/currentPL?taskId='+ this.data.id +'&groupId=' + this.data.baseGroupId + '&baseId=' + this.data.baseId,
  458. method: 'get'
  459. });
  460. if (res.code === 200) {
  461. this.dataTree = res.data
  462. uni.hideLoading()
  463. }
  464. },
  465. async submitPass() {
  466. uni.showLoading({
  467. mask: true,
  468. title: '正在提交'
  469. })
  470. if (this.form.result !== 'RESULT_FALSE' && this.data.isCandidate == "0" && 2.0 < parseFloat(this.data
  471. .formData.total_time)) {
  472. if (!this.nextApproval) {
  473. uni.showModal({
  474. content: '请选择批准人',
  475. title: '提交失败',
  476. showCancel: false
  477. })
  478. this.isDisabled = false
  479. return
  480. }
  481. }
  482. this.form.nextApproval = this.nextApproval
  483. this.form.nextUserName = this.nextUserName
  484. const {
  485. data: res
  486. } = await this.$httpRequest({
  487. url: '/app/nextStep',
  488. method: 'post',
  489. data: this.form
  490. });
  491. if (res.code === 200) {
  492. uni.hideLoading()
  493. uni.showModal({
  494. title: "提交成功",
  495. icon: "OK",
  496. showCancel: false,
  497. success() {
  498. setTimeout(() => {
  499. this.isDisabled = false
  500. }, 1000)
  501. uni.navigateBack()
  502. }
  503. })
  504. } else {
  505. uni.showModal({
  506. title: "提交失败",
  507. icon: "ERROR",
  508. showCancel: false,
  509. content: res.msg
  510. })
  511. }
  512. setTimeout(() => {
  513. this.isDisabled = false
  514. }, 1000)
  515. setTimeout(() => {
  516. this.isDisabled = false
  517. uni.hideLoading()
  518. }, 1000)
  519. },
  520. dateFormat(time) {
  521. let date = new Date(time);
  522. let year = date.getFullYear();
  523. // 在日期格式中,月份是从0开始的,因此要加0,使用三元表达式在小于10的前面加0,以达到格式统一 如 09:11:05
  524. let month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
  525. let day = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
  526. let hours = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
  527. let minutes = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
  528. let seconds = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
  529. // 拼接
  530. // return year + "-" + month + "-" + day + " " + hours + ":" + minutes + ":" + seconds;
  531. return year + "/" + month + "/" + day;
  532. }
  533. }
  534. }
  535. </script>
  536. <style lang="scss" scoped>
  537. .desc {
  538. padding: 10rpx;
  539. }
  540. .u-page {
  541. &__button-item {
  542. margin: 0 15px 5px 0;
  543. }
  544. }
  545. .u-demo-block__content {
  546. flex-direction: row;
  547. flex-wrap: wrap;
  548. align-items: center;
  549. }
  550. .popup-content {
  551. height: 800rpx;
  552. }
  553. .geHeight {
  554. height: 100%;
  555. position: relative;
  556. }
  557. .bomButtonBody {
  558. border-top: 5rpx #f5f5f5 solid;
  559. padding: 30rpx 0 50rpx 0;
  560. width: 100%;
  561. background-color: #ffffff;
  562. }
  563. .status-btn {
  564. /* #ifndef APP-NVUE */
  565. display: flex;
  566. /* #endif */
  567. flex-direction: row;
  568. align-items: center;
  569. justify-content: center;
  570. height: 92rpx;
  571. margin: 30rpx;
  572. background-color: #007AFF;
  573. }
  574. .example-body {
  575. /* #ifndef APP-NVUE */
  576. display: block;
  577. /* #endif */
  578. padding: 15px;
  579. flex-direction: row;
  580. }
  581. .check-btn {
  582. display: flex;
  583. justify-content: space-between;
  584. margin-bottom: 10px;
  585. }
  586. </style>