workDetail.js 6.0 KB

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