workDetail.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. var app = getApp()
  2. var that;
  3. Page({
  4. data: {
  5. date: app.globalData.month,
  6. activeIndex: 1,
  7. id: '',
  8. userId: '',
  9. process: [],
  10. array: ['编辑任务', '删除任务'],
  11. isPublisher: true,//是不是发布者
  12. },
  13. onLoad(e) {
  14. that = this;
  15. dd.setNavigationBar({ title: "工作详情" });
  16. if (e.id) {
  17. this.setData({
  18. id: e.id,
  19. userId: app.globalData.userData.id
  20. })
  21. that.getDetail(e.id);
  22. }
  23. },
  24. // 判断当前账号与发布工作者是否同一人;
  25. current_none(data) {
  26. var actions = []
  27. // 这里比较复杂,因为团队绩效的工作详情跟我的发布的工作详情都调用这个页面
  28. if (data.status == 1) {
  29. if (data.pt_id != 1) {
  30. actions.push('编辑任务')
  31. actions.push('删除任务')
  32. } else {
  33. actions.push('删除任务')
  34. }
  35. } else {
  36. actions.push('删除任务')
  37. }
  38. this.setData({ array: actions })
  39. },
  40. bindPickerChange(e) {
  41. var page = getCurrentPages()[getCurrentPages().length - 2]//上一个页面的数据
  42. if (this.data.array[e.detail.value] == '删除任务') {
  43. dd.confirm({
  44. title: '删除任务',
  45. content: '删除此任务将会删除其相关记录和积分数据,确认删除吗?',
  46. confirmButtonText: '确定',
  47. cancelButtonText: '取消',
  48. success: (result) => {
  49. if (result.confirm) {
  50. app.$get("api/integral/work/delete", { work_id: this.data.id }).then((res) => {
  51. app.globalData.showToast(res.data.msg);
  52. page.filtrationList(2, this.data.id);
  53. setTimeout(() => {
  54. dd.navigateBack({ delta: 1 })
  55. }, 1000);
  56. })
  57. }
  58. },
  59. });
  60. } else if (this.data.array[e.detail.value] == '编辑任务') {//编辑任务
  61. dd.navigateTo({
  62. url: '../assaign_set/assaign_set?item=' + JSON.stringify(this.data.dataDetail)
  63. })
  64. }
  65. },
  66. //显示图片
  67. showImg(e) {
  68. var index = e.target.dataset.index;
  69. var item = e.target.dataset.item
  70. dd.previewImage({
  71. current: index,
  72. urls: item
  73. });
  74. },
  75. activeItem(e) {
  76. var index = e.target.dataset.index;
  77. this.setData({ activeIndex: index })
  78. },
  79. openJyt() {
  80. dd.navigateTo({
  81. url: '../workpoints/workpoints?item=' + JSON.stringify(this.data.process) + '&id=' + this.data.dataDetail.id + '&isJf=' + false
  82. })
  83. },
  84. openJf(e) {
  85. dd.navigateTo({
  86. url: '../workpoints/workpoints?item=' + JSON.stringify(this.data.process) + '&id=' + this.data.dataDetail.id + '&isJf=' + true
  87. })
  88. },
  89. deleteItem(e) {
  90. dd.confirm({
  91. title: '提示',
  92. content: '确定永久删除此项?',
  93. confirmButtonText: '确定',
  94. cancelButtonText: '取消',
  95. success: (result) => {
  96. if (result.confirm) {
  97. var index = e.target.dataset.index;
  98. var data = {
  99. work_id: this.data.id,
  100. process: this.data.process
  101. }
  102. data.process.splice(index, 1)
  103. if(data.process.length==0){
  104. data.process="[1]"
  105. }else{
  106. data.process = JSON.stringify(data.process);
  107. }
  108. app.$post("api/integral/work",data).then((res) => {
  109. app.globalData.showToast(res.data.msg);
  110. this.getDetail(this.data.id);
  111. })
  112. }
  113. },
  114. });
  115. },
  116. getDetail(id, fun = function () { }) {
  117. this.setData({
  118. total:0
  119. })
  120. app.$get("api/integral/work", { work_id: id }).then((res) => {
  121. fun();
  122. this.current_none(res.data.data)
  123. var process = res.data.data.process.list || [];
  124. var data = res.data.data;
  125. data.jf = [];
  126. data.gc = [];
  127. process.forEach(item => {
  128. if (item.recorder_id == data.publisher_id) {
  129. data.jf.push(item)
  130. } else {
  131. data.gc.push(item)
  132. }
  133. })
  134. this.setData({
  135. dataDetail: data,
  136. total: res.data.data.process.total,
  137. process: process,
  138. isPublisher: data.publisher_id == this.data.userId ? true : false
  139. })
  140. })
  141. },
  142. openWc(){
  143. dd.navigateTo({
  144. url: '../../workbench/approve/approve?id=' + this.data.dataDetail.review_id
  145. })
  146. },
  147. // 完成任务
  148. openPerform() {
  149. dd.navigateTo({
  150. url: '../openPerform/openPerform?id=' + this.data.dataDetail.id + '&is=detail'
  151. })
  152. },
  153. openSchedule() {
  154. dd.navigateTo({
  155. url: '../schedule/schedule?id=' + this.data.dataDetail.id + "&progress=" + this.data.dataDetail.progress
  156. })
  157. },
  158. });