follow.js 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. const _Http = getApp().globalData.http,
  2. currency = require("../../../../utils/currency"),
  3. CNY = value => currency(value, {
  4. symbol: "¥",
  5. precision: 2
  6. }).format();
  7. Component({
  8. properties: {
  9. disabled: {
  10. type: Boolean,
  11. value: false
  12. },
  13. isshowsalesfeesamount: {
  14. type: Boolean,
  15. value: false
  16. },
  17. isAdmin: {
  18. type: Boolean,
  19. value: false
  20. },
  21. expenseBreakdown: {
  22. type: Boolean,
  23. }
  24. },
  25. lifetimes: {
  26. attached() {
  27. getApp().globalData.Language.getLanguagePackage(this)
  28. }
  29. },
  30. options: {
  31. addGlobalClass: true
  32. },
  33. data: {
  34. sat_orderclueid: null,
  35. content: {
  36. nocache: true,
  37. pageNumber: 1,
  38. pageTotal: 1,
  39. pageSize: 20,
  40. total: null,
  41. where: {
  42. condition: ""
  43. }
  44. },
  45. showSearch: false,
  46. focus: false,
  47. condition: "",
  48. poputShow: false,
  49. followList: []
  50. },
  51. lifetimes: {
  52. attached: function () {
  53. this.setData({
  54. userid: wx.getStorageSync('userMsg').userid,
  55. })
  56. getApp().globalData.Language.getLanguagePackage(this)
  57. }
  58. },
  59. methods: {
  60. toSearch() {
  61. if (this.data.showSearch && this.data.content.where.condition) {
  62. this.data.content.where.condition = '';
  63. this.getList(this.data.sat_orderclueid, true);
  64. } else if (this.data.condition) {
  65. this.data.content.where.condition = this.data.condition;
  66. this.setData({
  67. condition: this.data.condition
  68. })
  69. this.getList(this.data.sat_orderclueid, true);
  70. }
  71. this.setData({
  72. showSearch: !this.data.showSearch
  73. })
  74. setTimeout(() => {
  75. this.setData({
  76. focus: this.data.showSearch
  77. })
  78. }, 300)
  79. },
  80. onChange({
  81. detail
  82. }) {
  83. this.data.condition = detail;
  84. },
  85. onSearch({
  86. detail
  87. }) {
  88. this.data.content.where.condition = detail;
  89. this.getList(this.data.sat_orderclueid, true)
  90. },
  91. getList(id, init = false) {
  92. let content = this.data.content;
  93. if (init) content.pageNumber = 1;
  94. content.sat_orderclueid = id;
  95. _Http.basic({
  96. id: 20221101094602,
  97. content
  98. }).then(res => {
  99. console.log('线索跟进', res);
  100. if (this.data.isshowsalesfeesamount) res.data = res.data.map(v => {
  101. v.showsalesfeesamount = CNY(v.salesfeesamount || 0)
  102. return v
  103. })
  104. this.setData({
  105. followList: res.pageNumber == 1 ? res.data : this.data.followList.concat(res.data),
  106. "content.pageNumber": res.pageNumber + 1,
  107. "content.pageTotal": res.pageTotal,
  108. "content.total": res.total,
  109. sat_orderclueid: id,
  110. userid: wx.getStorageSync('userMsg').userid
  111. })
  112. })
  113. },
  114. viewFiles(e) {
  115. const {
  116. item
  117. } = e.currentTarget.dataset;
  118. this.setData({
  119. poputShow: true
  120. })
  121. this.selectComponent("#Yl_Files").handleFiles(item.attinfo, true)
  122. },
  123. onClosePoput() {
  124. this.setData({
  125. poputShow: false
  126. })
  127. this.selectComponent("#Yl_Files").initData()
  128. },
  129. deleteItem(e) {
  130. const {
  131. item
  132. } = e.currentTarget.dataset,
  133. that = this;
  134. console.log(that.data)
  135. wx.showModal({
  136. title: getApp().globalData.Language.getMapText('提示'),
  137. content: getApp().globalData.Language.getMapText('是否确定删除该跟进记录'),
  138. cancelText: getApp().globalData.Language.getMapText('取消'),
  139. confirmText: getApp().globalData.Language.getMapText('确定'),
  140. complete: (res) => {
  141. if (res.confirm) _Http.basic({
  142. "id": 20221208112002,
  143. "content": {
  144. "sat_ordercluefollowuplogid": item.sat_ordercluefollowuplogid
  145. }
  146. }).then(res => {
  147. console.log("删除跟进记录", res)
  148. wx.showToast({
  149. title: res.code != '1' ? res.msg : getApp().globalData.Language.getMapText('删除成功'),
  150. icon: "none"
  151. });
  152. that.getReadList();
  153. })
  154. }
  155. })
  156. },
  157. getReadList() {
  158. let content = JSON.parse(JSON.stringify(this.data.content))
  159. content.pageSize = (content.pageNumber - 1) * content.pageSize;
  160. content.pageNumber = 1;
  161. _Http.basic({
  162. id: 20221101094602,
  163. content
  164. }).then(res => {
  165. console.log('线索跟进记录', res);
  166. this.setData({
  167. followList: res.data,
  168. "content.total": res.total
  169. });
  170. delete(_Http.changeItem)
  171. })
  172. },
  173. editItem(e) {
  174. const {
  175. item
  176. } = e.currentTarget.dataset;
  177. wx.navigateTo({
  178. url: '/packageA/publicClue/modules/follow/insert?data=' + JSON.stringify(item),
  179. })
  180. _Http.changeItem = this.getReadList.bind(this);
  181. },
  182. expenseBreakdown(e) {
  183. const {
  184. item,
  185. index
  186. } = e.currentTarget.dataset;
  187. wx.navigateTo({
  188. url: `/packageA/expenseBreakdown/index?ownertable=sat_orderclue&ownerid=${item.sat_ordercluefollowuplogid}&isAdmin=${this.data.isAdmin}&item=${
  189. JSON.stringify(item)
  190. }`,
  191. })
  192. _Http.updateEBList = function (salesfeesamount, showsalesfeesamount) {
  193. this.setData({
  194. [`followList[${index}].salesfeesamount`]: salesfeesamount,
  195. [`followList[${index}].showsalesfeesamount`]: showsalesfeesamount,
  196. })
  197. }.bind(this)
  198. },
  199. comment(e) {
  200. let page = this.selectComponent('#' + e.currentTarget.id);
  201. page.changeShow()
  202. },
  203. toAdd() {
  204. wx.navigateTo({
  205. url: `/packageA/publicClue/modules/follow/insert?sat_orderclueid=` + this.data.sat_orderclueid
  206. })
  207. _Http.changeItem = function () {
  208. this.getList(this.data.sat_orderclueid, true);
  209. }.bind(this)
  210. },
  211. updateCommentList({
  212. detail
  213. }) {
  214. console.log("detail", detail)
  215. detail.pageSize = 99999;
  216. _Http.basic({
  217. "id": 20240920092204,
  218. content: detail
  219. }).then(res => {
  220. console.log("更新评论列表", res)
  221. if (res.code == 1) {
  222. let idName = detail.ownertable + 'id';
  223. const index = this.data.followList.findIndex(v => v[idName] == detail.ownerid)
  224. if (index != -1) {
  225. let item = this.data.followList[index];
  226. item.commentqty = res.total == 0 ? 0 : res.data[0].totalqty;
  227. item.comment = res.data;
  228. this.setData({
  229. [`followList[${index}]`]: item
  230. })
  231. }
  232. }
  233. })
  234. }
  235. }
  236. })