index.js 8.1 KB

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