index.js 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  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. ownertable: {
  10. type: String
  11. },
  12. ownerid: {
  13. type: String
  14. },
  15. ownerid1: {
  16. type: String
  17. },
  18. disabled: {
  19. type: Boolean,
  20. value: true
  21. },
  22. isAdmin: {
  23. type: Boolean
  24. }
  25. },
  26. options: {
  27. addGlobalClass: true
  28. },
  29. data: {
  30. content: {
  31. nocache: true,
  32. pageNumber: 1,
  33. pageSize: 10,
  34. pageTotal: 1,
  35. total: null,
  36. where: {
  37. condition: ""
  38. }
  39. },
  40. list: [],
  41. showSearch: false,
  42. focus: false,
  43. condition: ""
  44. },
  45. lifetimes: {
  46. attached: function () {
  47. this.setData({
  48. userid: wx.getStorageSync('userMsg').userid,
  49. })
  50. getApp().globalData.Language.getLanguagePackage(this)
  51. }
  52. },
  53. methods: {
  54. toSearch() {
  55. if (this.data.showSearch && this.data.content.where.condition) {
  56. this.data.content.where.condition = '';
  57. this.getList("", true);
  58. } else if (this.data.condition) {
  59. this.data.content.where.condition = this.data.condition;
  60. this.setData({
  61. condition: this.data.condition
  62. })
  63. this.getList("", true);
  64. }
  65. this.setData({
  66. showSearch: !this.data.showSearch
  67. })
  68. setTimeout(() => {
  69. this.setData({
  70. focus: this.data.showSearch
  71. })
  72. }, 300)
  73. },
  74. onChange({
  75. detail
  76. }) {
  77. this.data.condition = detail;
  78. },
  79. onSearch({
  80. detail
  81. }) {
  82. this.data.content.where.condition = detail;
  83. this.getList("", true)
  84. },
  85. getList(id, init = false) {
  86. let content = {
  87. ...this.data.content,
  88. "ownertable": this.data.ownertable,
  89. "ownerid": this.data.ownerid,
  90. };
  91. if (init) {
  92. content.pageNumber = 1
  93. content.pageTotal = 1
  94. }
  95. _Http.basic({
  96. "id": 20220930121501,
  97. content
  98. }).then(res => {
  99. console.log("跟进动态", res)
  100. if (res.code != '1') return wx.showToast({
  101. title: res.data,
  102. icon: "none"
  103. });
  104. let list = res.data.map(v => {
  105. try {
  106. v.names = v.contacts.map(n => n.name)
  107. } catch (error) {
  108. v.names = null
  109. }
  110. v.showsalesfeesamount = CNY(v.salesfeesamount || 0)
  111. return v
  112. })
  113. this.setData({
  114. "content.pageNumber": res.pageNumber + 1,
  115. "content.pageTotal": res.pageTotal,
  116. "content.total": res.total,
  117. list: res.pageNumber == 1 ? list : this.data.list.concat(list)
  118. })
  119. })
  120. },
  121. editItem(e) {
  122. let item = null;
  123. try {
  124. item = e.currentTarget.dataset.item;
  125. } catch (error) {
  126. item = e
  127. }
  128. let parems = {
  129. ownertable: this.data.ownertable,
  130. ownerid: this.data.ownerid,
  131. ownerid1: this.data.ownerid1,
  132. sys_datafollowupid: item.sys_datafollowupid,
  133. content: item.content,
  134. target: item.target,
  135. results: item.results,
  136. nextplan: item.nextplan,
  137. contactsid: item.names ? [item.names, item.dataextend.contactsid] : "",
  138. type: item.type,
  139. attinfos: item.attinfos
  140. }
  141. wx.navigateTo({
  142. url: '/pages/trace/insert?parems=' + JSON.stringify(parems),
  143. })
  144. _Http.changeItem = this.changeItem.bind(this)
  145. },
  146. changeItem(item) {
  147. let content = {
  148. ...this.data.content,
  149. "ownertable": this.data.ownertable,
  150. "ownerid": this.data.ownerid,
  151. };
  152. content.pageSize = content.pageSize * (content.pageNumber - 1);
  153. content.pageNumber = 1;
  154. _Http.basic({
  155. "id": 20220930121501,
  156. content
  157. }).then(res => {
  158. console.log("跟进动态", res)
  159. if (res.msg != '成功') return wx.showToast({
  160. title: res.data,
  161. icon: "none"
  162. });
  163. let list = res.data.map(v => {
  164. try {
  165. v.names = v.contacts.map(n => n.name)
  166. } catch (error) {
  167. v.names = null
  168. }
  169. v.showsalesfeesamount = CNY(v.salesfeesamount || 0)
  170. return v
  171. })
  172. this.setData({
  173. list
  174. })
  175. })
  176. },
  177. expenseBreakdown(e) {
  178. const {
  179. item,
  180. index
  181. } = e.currentTarget.dataset;
  182. wx.navigateTo({
  183. url: `/packageA/expenseBreakdown/index?ownertable=${item.ownertable}&ownerid=${item.sys_datafollowupid}&isAdmin=${this.data.isAdmin}&item=${
  184. JSON.stringify(item)
  185. }`,
  186. })
  187. _Http.updateEBList = function (salesfeesamount, showsalesfeesamount) {
  188. this.setData({
  189. [`list[${index}].salesfeesamount`]: salesfeesamount,
  190. [`list[${index}].showsalesfeesamount`]: showsalesfeesamount,
  191. })
  192. }.bind(this)
  193. },
  194. insetr() {
  195. let parems = {
  196. ownertable: this.data.ownertable,
  197. ownerid: this.data.ownerid,
  198. ownerid1: this.data.ownerid1,
  199. sys_datafollowupid: 0,
  200. content: ""
  201. }
  202. wx.navigateTo({
  203. url: '/pages/trace/insert?parems=' + JSON.stringify(parems),
  204. })
  205. },
  206. toDetail(e) {
  207. const {
  208. item
  209. } = e.currentTarget.dataset;
  210. wx.navigateTo({
  211. url: `/pages/trace/detail?data=` + JSON.stringify({
  212. "sys_datafollowupid": item.sys_datafollowupid,
  213. "ownertable": this.data.ownertable,
  214. "ownerid": this.data.ownerid
  215. }),
  216. });
  217. _Http.changeItem = this.changeItem.bind(this);
  218. _Http.editItem = this.editItem.bind(this);
  219. _Http.handleDelete = this.handleDelete.bind(this);
  220. },
  221. deleteItem(e) {
  222. this.handleDelete(e.currentTarget.dataset.item)
  223. },
  224. handleDelete(item) {
  225. let that = this;
  226. return new Promise((resolve) => {
  227. wx.showModal({
  228. title: getApp().globalData.Language.getMapText('提示'),
  229. content: getApp().globalData.Language.getMapText('是否确定删除该跟进动态'),
  230. complete: ({
  231. confirm
  232. }) => {
  233. if (confirm) {
  234. _Http.basic({
  235. "id": 20220930121701,
  236. "content": {
  237. "sys_datafollowupid": item.sys_datafollowupid,
  238. "ownertable": that.data.ownertable,
  239. "ownerid": that.data.ownerid,
  240. deletereason: ""
  241. }
  242. }).then(res => {
  243. console.log("删除", res);
  244. wx.showToast({
  245. title: res.code != 1 ? getApp().globalData.Language.getMapText(res.msg) : getApp().globalData.Language.getMapText("删除成功"),
  246. icon: "none"
  247. });
  248. resolve(res.code)
  249. if (res.code != 1) return;
  250. that.setData({
  251. list: that.data.list.filter(v => v.sys_datafollowupid != item.sys_datafollowupid),
  252. 'content.total': that.data.content.total - 1
  253. })
  254. })
  255. } else {
  256. resolve(0)
  257. }
  258. }
  259. })
  260. })
  261. },
  262. changeTotal() {
  263. this.setData({
  264. "content.total": this.data.content.total - 1
  265. })
  266. },
  267. comment(e) {
  268. let page = this.selectComponent('#' + e.currentTarget.id);
  269. page.changeShow()
  270. },
  271. updateCommentList({
  272. detail
  273. }) {
  274. detail.pageSize = 99999;
  275. _Http.basic({
  276. "id": 20240920092204,
  277. content: detail
  278. }).then(res => {
  279. console.log("更新评论列表", res)
  280. if (res.code == 1) {
  281. let idName = detail.ownertable + 'id';
  282. const index = this.data.list.findIndex(v => v[idName] == detail.ownerid)
  283. if (index != -1) {
  284. let item = this.data.list[index];
  285. item.commentqty = res.total == 0 ? 0 : res.data[0].totalqty;
  286. item.comment = res.data;
  287. this.setData({
  288. [`list[${index}]`]: item
  289. })
  290. }
  291. }
  292. })
  293. }
  294. }
  295. })