workpoints.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. var app = getApp();
  2. var that;
  3. var animation;
  4. Page({
  5. data: {
  6. defaultVal: '',
  7. process: {
  8. recorder_id: app.globalData.userData.id,
  9. recorder: app.globalData.userData.name,
  10. remark: '',
  11. point: 0,
  12. img_url: app.globalData.userData.img_url,
  13. time: app.globalData.allDate
  14. },
  15. items: [],
  16. id: '',
  17. isArrindex: true,//正还是负
  18. isJf: false,
  19. },
  20. onLoad(e) {
  21. that = this;
  22. dd.setNavigationBar({ title: "任务过程" });
  23. if (e.id) {
  24. this.setData({
  25. isJf: JSON.parse(e.isJf),
  26. id: e.id,
  27. items: JSON.parse(e.item),
  28. process: {
  29. recorder_id: app.globalData.userData.id,
  30. recorder: app.globalData.userData.name,
  31. remark: '',
  32. point: 0,
  33. img_url: app.globalData.userData.img_url,
  34. time: app.globalData.allDate
  35. },
  36. })
  37. }
  38. },
  39. //备注输入
  40. bindTextAreaBlur: function (e) {
  41. this.setData({
  42. [`process.remark`]: e.detail.value,
  43. });
  44. },
  45. bindKeyInput(e) {
  46. this.setData({
  47. [`process.point`]: e.detail.value,
  48. });
  49. },
  50. formSubmit() {
  51. var page1 = getCurrentPages()[getCurrentPages().length - 2]//上一个页面的数据
  52. if (!this.data.process.remark) {
  53. app.globalData.showToast("请输入记录过程");
  54. return;
  55. }
  56. if (this.data.isJf) {
  57. if (this.data.process.point == 0 || !this.data.process.point) {
  58. app.globalData.showToast("请输入记分");
  59. return;
  60. }
  61. }
  62. var data = {
  63. work_id: this.data.id,
  64. process: []
  65. }
  66. var items = this.data.items;
  67. var process = this.data.process;
  68. this.data.isArrindex === false ? process.point = process.point * -1 : process.point = process.point * 1
  69. items.unshift(process)
  70. data.process = JSON.stringify(items);
  71. this.setData({ disabled: true })
  72. app.$post("api/integral/work", data).then((res) => {
  73. page1.getDetail(this.data.id, function () {
  74. app.globalData.showToast(res.data.msg);
  75. setTimeout(() => {
  76. dd.navigateBack({ delta: 1 })
  77. }, 1000);
  78. })
  79. }).finally(e => {
  80. this.setData({ disabled: false })
  81. })
  82. },
  83. //选择奖还是扣(细则)
  84. bindPickerChange() {
  85. this.setData({
  86. isArrindex: !this.data.isArrindex,
  87. });
  88. },
  89. });