workDetail.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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. if (this.data.array[e.detail.value] == '删除任务') {
  42. dd.confirm({
  43. title: '删除任务',
  44. content: '删除此任务将会删除其相关记录和积分数据,确认删除吗?',
  45. confirmButtonText: '确定',
  46. cancelButtonText: '取消',
  47. success: (result) => {
  48. if (result.confirm) {
  49. app.$get("api/integral/work/delete", { work_id: this.data.id }).then((res) => {
  50. app.globalData.showToast(res.data.msg);
  51. setTimeout(() => {
  52. dd.navigateBack({ delta: 1 })
  53. }, 1000);
  54. })
  55. }
  56. },
  57. });
  58. } else if (this.data.array[e.detail.value] == '编辑任务') {//编辑任务
  59. dd.navigateTo({
  60. url: '../assaign_set/assaign_set?item=' + JSON.stringify(this.data.dataDetail)
  61. })
  62. }
  63. },
  64. //显示图片
  65. showImg(e) {
  66. var index = e.target.dataset.index;
  67. var item = e.target.dataset.item
  68. dd.previewImage({
  69. current: index,
  70. urls: item
  71. });
  72. },
  73. activeItem(e) {
  74. var index = e.target.dataset.index;
  75. this.setData({ activeIndex: index })
  76. },
  77. openJyt() {
  78. dd.navigateTo({
  79. url: '../workpoints/workpoints?item=' + JSON.stringify(this.data.process) + '&id=' + this.data.dataDetail.id + '&isJf=' + false
  80. })
  81. },
  82. openJf(e) {
  83. dd.navigateTo({
  84. url: '../workpoints/workpoints?item=' + JSON.stringify(this.data.process) + '&id=' + this.data.dataDetail.id + '&isJf=' + true
  85. })
  86. },
  87. deleteItem(e) {
  88. dd.confirm({
  89. title: '提示',
  90. content: '确定永久删除此项?',
  91. confirmButtonText: '确定',
  92. cancelButtonText: '取消',
  93. success: (result) => {
  94. if (result.confirm) {
  95. var index = e.target.dataset.index;
  96. var data = {
  97. work_id: this.data.id,
  98. process: this.data.process
  99. }
  100. data.process.splice(index, 1)
  101. if(data.process.length==0){
  102. data.process="[1]"
  103. }else{
  104. data.process = JSON.stringify(data.process);
  105. }
  106. app.$post("api/integral/work",data).then((res) => {
  107. app.globalData.showToast(res.data.msg);
  108. this.getDetail(this.data.id);
  109. })
  110. }
  111. },
  112. });
  113. },
  114. getDetail(id, fun = function () { }) {
  115. this.setData({
  116. total:0
  117. })
  118. app.$get("api/integral/work", { work_id: id }).then((res) => {
  119. fun();
  120. this.current_none(res.data.data)
  121. var process = res.data.data.process.list || [];
  122. var data = res.data.data;
  123. data.jf = [];
  124. data.gc = [];
  125. process.forEach(item => {
  126. if (item.recorder_id == data.publisher_id) {
  127. data.jf.push(item)
  128. } else {
  129. data.gc.push(item)
  130. }
  131. })
  132. this.setData({
  133. dataDetail: data,
  134. total: res.data.data.process.total,
  135. process: process,
  136. isPublisher: data.publisher_id == this.data.userId ? true : false
  137. })
  138. })
  139. },
  140. openWc(){
  141. console.log("asdas")
  142. dd.navigateTo({
  143. url: '../../workbench/approve/approve?id=' + this.data.dataDetail.review_id
  144. })
  145. },
  146. // 完成任务
  147. openPerform() {
  148. dd.navigateTo({
  149. url: '../openPerform/openPerform?id=' + this.data.dataDetail.id + '&is=detail'
  150. })
  151. },
  152. openSchedule() {
  153. dd.navigateTo({
  154. url: '../schedule/schedule?id=' + this.data.dataDetail.id + "&progress=" + this.data.dataDetail.progress
  155. })
  156. },
  157. });