index.js 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. const _Http = getApp().globalData.http;
  2. Component({
  3. options: {
  4. addGlobalClass: true
  5. },
  6. properties: {
  7. sc_workorderid: {
  8. type: String,
  9. value: ''
  10. }
  11. },
  12. data: {
  13. hasApplicationPerm: false,
  14. delShow: false,
  15. reason: {
  16. voidreason: ""
  17. },
  18. id: 2026052911075602,
  19. content: {
  20. nocache: true,
  21. pageNumber: 1,
  22. pageSize: 20,
  23. where: {
  24. condition: "",
  25. }
  26. },
  27. list: [],
  28. showSearch: false,
  29. focus: false,
  30. condition: ""
  31. },
  32. lifetimes: {
  33. attached: function () {
  34. getApp().globalData.Language.getLanguagePackage(this)
  35. const auth = wx.getStorageSync('auth').wWorkOrder;
  36. const hasApplicationPerm = auth.options.some(v => v == 'application');
  37. this.setData({ hasApplicationPerm });
  38. },
  39. },
  40. methods: {
  41. getList(sc_workorderid, init = false) {
  42. let content = {
  43. ...this.data.content,
  44. sc_workorderid: sc_workorderid || this.properties.sc_workorderid
  45. };
  46. _Http.init(content, init).then(content => {
  47. _Http.basic({
  48. id: this.data.id,
  49. content
  50. }).then(res => {
  51. if (res.code != '1') return wx.showToast({
  52. title: res.msg,
  53. icon: "none"
  54. });
  55. this.setData({
  56. content: _Http.paging(content, res),
  57. list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
  58. })
  59. })
  60. })
  61. },
  62. handleRefuse(e) {
  63. const sc_warrantycard_applyid = e.currentTarget.dataset.id;
  64. this.setData({
  65. delShow: true,
  66. currentApplyId: sc_warrantycard_applyid
  67. })
  68. },
  69. onCancel() {
  70. this.setData({
  71. delShow: false,
  72. reason: {
  73. voidreason: ""
  74. }
  75. })
  76. },
  77. areaInput(e) {
  78. this.data.reason[e.currentTarget.dataset.name] = e.detail.value;
  79. },
  80. // 拒绝
  81. onSuspend() {
  82. let voidreason = this.data.reason.voidreason;
  83. if (voidreason == '') return wx.showToast({
  84. title: getApp().globalData.Language.getMapText("请填写拒绝原因"),
  85. icon: "none"
  86. })
  87. _Http.basic({
  88. "content": {
  89. "sc_workorderid": this.properties.sc_workorderid,
  90. "sc_warrantycard_applyid": this.data.currentApplyId,
  91. "isAgreed": 0,
  92. "reject_reason": voidreason
  93. },
  94. "id": 2026052910290102,
  95. }).then(res => {
  96. if (res.code != '1') return wx.showToast({
  97. title: res.msg,
  98. icon: "none"
  99. });
  100. getApp().globalData.Language.showToast("拒绝成功");
  101. this.setData({
  102. delShow: false,
  103. reason: { voidreason: "" }
  104. });
  105. this.getList(this.properties.sc_workorderid, true);
  106. this.triggerEvent('refreshdetail');
  107. }).catch(err => {
  108. wx.showToast({
  109. title: getApp().globalData.Language.getMapText("操作失败"),
  110. icon: "none"
  111. });
  112. })
  113. },
  114. handleAgree(e) {
  115. const sc_warrantycard_applyid = e.currentTarget.dataset.id;
  116. wx.showModal({
  117. title: getApp().globalData.Language.getMapText('提示'),
  118. content: getApp().globalData.Language.getMapText(`是否同意该工单的质保卡申请`) + '?',
  119. confirmText: getApp().globalData.Language.getMapText('确定同意'),
  120. cancelText: getApp().globalData.Language.getMapText('取消'),
  121. success: ({
  122. confirm
  123. }) => {
  124. if (!confirm) return;
  125. _Http.basic({
  126. "content": {
  127. "sc_workorderid": this.properties.sc_workorderid,
  128. "sc_warrantycard_applyid": sc_warrantycard_applyid,
  129. "isAgreed": 1
  130. },
  131. "id": 2026052910290102,
  132. }).then(res => {
  133. if (res.code != '1') return wx.showToast({
  134. title: res.msg,
  135. icon: "none"
  136. });
  137. getApp().globalData.Language.showToast("同意成功");
  138. this.getList(this.properties.sc_workorderid, true);
  139. this.triggerEvent('refreshdetail');
  140. }).catch(err => {
  141. wx.showToast({
  142. title: getApp().globalData.Language.getMapText("操作失败"),
  143. icon: "none"
  144. });
  145. })
  146. }
  147. })
  148. },
  149. toSearch() {
  150. if (this.data.showSearch && this.data.content.where.condition) {
  151. // 点击关闭搜索框 清空搜索条件,刷新列表
  152. this.data.content.where.condition = '';
  153. this.getList("", true); // init=true 重置分页
  154. } else if (this.data.condition) {
  155. // 输入了关键词,搜索
  156. this.data.content.where.condition = this.data.condition;
  157. this.getList("", true);
  158. }
  159. this.setData({
  160. showSearch: !this.data.showSearch
  161. })
  162. setTimeout(() => {
  163. this.setData({
  164. focus: this.data.showSearch
  165. })
  166. }, 300)
  167. },
  168. onChange({
  169. detail
  170. }) {
  171. this.data.condition = detail;
  172. },
  173. onSearch({
  174. detail
  175. }) {
  176. this.data.content.where.condition = detail;
  177. this.getList("", true)
  178. },
  179. }
  180. });