geNewsApproval.vue 15 KB

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