record.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. const _Http = getApp().globalData.http;
  2. Page({
  3. data: {
  4. loading: false,
  5. record: "",
  6. sa_service_improvementid: 0,
  7. sa_service_improvement_planid: 0,
  8. sa_service_improvement_recordid: 0
  9. },
  10. onLoad(options) {
  11. getApp().globalData.Language.getLanguagePackage(this, '改善记录');
  12. this.setData({
  13. sa_service_improvementid: options.sa_service_improvementid || 0,
  14. sa_service_improvement_planid: options.sa_service_improvement_planid || 0,
  15. sa_service_improvement_recordid: options.sa_service_improvement_recordid || 0,
  16. record: options.record || ""
  17. })
  18. if (_Http.basic.attinfos.length) this.selectComponent("#Yl_Files").handleFiles(_Http.basic.attinfos);
  19. },
  20. changeState({
  21. detail
  22. }) {
  23. this.setData({
  24. loading: detail
  25. })
  26. },
  27. /* 绑定媒体 */
  28. insertImgEdit({
  29. detail
  30. }) {
  31. this.handleFileLink(detail)
  32. },
  33. handleFileLink(attachmentids = []) {
  34. if (attachmentids.length) _Http.basic({
  35. "classname": "system.attachment.Attachment",
  36. "method": "createFileLink",
  37. "content": {
  38. ownertable: "sa_service_improvement_record",
  39. ownerid: this.data.sa_service_improvement_recordid || 0,
  40. usetype: 'default',
  41. attachmentids
  42. }
  43. }).then(res => {
  44. console.log('跟进记录绑定附件', res)
  45. if (res.code != '1') return wx.showToast({
  46. title: res.msg,
  47. icon: "none"
  48. })
  49. this.selectComponent("#Yl_Files").handleFiles(res.data)
  50. })
  51. },
  52. areaInput(e) {
  53. this.setData({
  54. record: e.detail.value
  55. })
  56. },
  57. submit() {
  58. let record = this.data.record;
  59. if (record == '') return wx.showToast({
  60. title: getApp().globalData.Language.getMapText("请填写改善记录"),
  61. icon: "none"
  62. })
  63. this.setData({
  64. loading: true
  65. })
  66. _Http.basic({
  67. "content": {
  68. "sa_service_improvementid": this.data.sa_service_improvementid,
  69. "sa_service_improvement_planid": this.data.sa_service_improvement_planid,
  70. "sa_service_improvement_recordid": this.data.sa_service_improvement_recordid,
  71. record
  72. },
  73. "id": 2026020210270102,
  74. }).then(res => {
  75. this.setData({
  76. loading: false
  77. })
  78. getApp().globalData.Language.showToast(res.code == '1' ? "保存成功" : res.msg)
  79. if (res.code == 1) {
  80. this.setData({
  81. sa_service_improvement_recordid: res.data.sa_service_improvement_recordid
  82. })
  83. this.handleFileLink(this.selectComponent("#Yl_Files").getFiles().attachmentids)
  84. setTimeout(() => {
  85. _Http.basic.updateExe && _Http.basic.updateExe('', true)
  86. wx.navigateBack()
  87. }, 300);
  88. }
  89. })
  90. },
  91. onUnload() {
  92. // 返回时刷新列表
  93. let pages = getCurrentPages();
  94. if (pages.length > 1) {
  95. let page = pages[pages.length - 2];
  96. if (page && page.getList) {
  97. page.getList('', true);
  98. }
  99. }
  100. }
  101. })