workDetail.js 5.4 KB

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