index.js 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. const _Http = getApp().globalData.http;
  2. Component({
  3. properties: {
  4. disabled: {
  5. type: Boolean,
  6. value: true
  7. }
  8. },
  9. options: {
  10. addGlobalClass: true
  11. },
  12. data: {
  13. sat_campaignid: 0,
  14. content: {
  15. nocache: true,
  16. pageNumber: 1,
  17. pageSize: 10,
  18. pageTotal: 1,
  19. total: null,
  20. where: {
  21. condition: ""
  22. }
  23. },
  24. list: [],
  25. showSearch: false,
  26. focus: false,
  27. condition: ""
  28. },
  29. lifetimes: {
  30. attached: function () {
  31. getApp().globalData.Language.getLanguagePackage(this)
  32. }
  33. },
  34. methods: {
  35. getList(id, init = false) {
  36. let content = {
  37. ...this.data.content,
  38. sat_campaignid: id || this.data.sat_campaignid
  39. };
  40. if (init) {
  41. content.pageNumber = 1
  42. content.pageTotal = 1
  43. }
  44. _Http.basic({
  45. "id": 2025103013521502,
  46. content
  47. }).then(res => {
  48. console.log("科室医生", res)
  49. if (res.code != '1') return wx.showToast({
  50. title: res.data,
  51. icon: "none"
  52. });
  53. let list = res.data
  54. this.setData({
  55. "content.pageNumber": res.pageNumber + 1,
  56. "content.pageTotal": res.pageTotal,
  57. "content.total": res.total,
  58. list: res.pageNumber == 1 ? list : this.data.list.concat(list),
  59. sat_campaignid: content.sat_campaignid
  60. })
  61. })
  62. },
  63. insetr() {
  64. let params = {
  65. "id": 2025103013523102,
  66. "content": {
  67. "sat_campaignid": this.data.sat_campaignid,
  68. pageNumber: 1,
  69. pageSize: 20,
  70. "where": {
  71. "condition": ""
  72. }
  73. }
  74. };
  75. wx.navigateTo({
  76. url: '/prsx/select/docter/index?params=' + JSON.stringify(params) + '&radio=true',
  77. })
  78. let that = this;
  79. getApp().globalData.handleSelect = function ({
  80. item
  81. }) {
  82. wx.showModal({
  83. content: `是否确定添加“${item.doctorname}”`,
  84. complete: ({
  85. confirm
  86. }) => {
  87. if (confirm) _Http.basic({
  88. "id": 2025103013511502,
  89. "content": {
  90. "sat_campaignid": that.data.sat_campaignid,
  91. "doctors": [{
  92. "sat_campaign_doctorid": 0,
  93. "sa_doctorid": item.sa_doctorid,
  94. "amount": 0
  95. }]
  96. },
  97. }).then(res => {
  98. console.log("添加医生", res)
  99. wx.showToast({
  100. title: res.code == 1 ? '添加成功' : res.data,
  101. icon: 'none',
  102. mask:res.code == 1
  103. })
  104. if (res.code == 1) {
  105. that.getList("", true)
  106. getCurrentPages().find(v => v.__route__ == 'prsx/select/docter/index').uploadList()
  107. wx.navigateBack()
  108. }
  109. })
  110. }
  111. })
  112. console.log(item)
  113. }.bind(this)
  114. },
  115. toSearch() {
  116. if (this.data.showSearch && this.data.content.where.condition) {
  117. this.data.content.where.condition = '';
  118. this.getList("", true);
  119. } else if (this.data.condition) {
  120. this.data.content.where.condition = this.data.condition;
  121. this.setData({
  122. condition: this.data.condition
  123. })
  124. this.getList("", true);
  125. }
  126. this.setData({
  127. showSearch: !this.data.showSearch
  128. })
  129. setTimeout(() => {
  130. this.setData({
  131. focus: this.data.showSearch
  132. })
  133. }, 300)
  134. },
  135. onChange({
  136. detail
  137. }) {
  138. this.data.condition = detail;
  139. },
  140. onSearch({
  141. detail
  142. }) {
  143. this.data.content.where.condition = detail;
  144. this.getList("", true)
  145. },
  146. deleteItem(e) {
  147. const {
  148. item
  149. } = e.currentTarget.dataset,
  150. that = this;
  151. wx.showModal({
  152. content: `是否确定删除“${item.doctorname}”`,
  153. complete: ({
  154. confirm
  155. }) => {
  156. if (confirm) _Http.basic({
  157. "id": 2025103013514902,
  158. "content": {
  159. "sat_campaignid": that.data.sat_campaignid,
  160. "sa_doctorid": [item.sa_doctorid]
  161. },
  162. }).then(res => {
  163. console.log("添加医生", res)
  164. wx.showToast({
  165. title: res.code == 1 ? '删除成功' : res.data,
  166. icon: 'none'
  167. })
  168. if (res.code == 1) {
  169. that.getList("", true)
  170. getCurrentPages().find(v => v.__route__ == 'prsx/activity/detail').getDetail()
  171. }
  172. })
  173. }
  174. })
  175. },
  176. changeAmount(e) {
  177. let value = e.detail.value,
  178. index = e.currentTarget.dataset.index;
  179. this.data.list[index].amount = value;
  180. _Http.basic({
  181. "id": 2025103013511502,
  182. "content": {
  183. "sat_campaignid": this.data.sat_campaignid,
  184. doctors: this.data.list
  185. }
  186. }).then(res => {
  187. console.log("修改金额", res)
  188. wx.showToast({
  189. title: res.code == 1 ? '修改成功' : res.msg,
  190. icon: "none"
  191. })
  192. if (res.code == 1) getCurrentPages().find(v => v.__route__ == 'prsx/activity/detail').getDetail()
  193. })
  194. }
  195. }
  196. })