index.js 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  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. wx.navigateTo({
  146. url: '/pages/trace/insert?parems=' + JSON.stringify(parems),
  147. })
  148. _Http.changeItem = this.changeItem.bind(this)
  149. },
  150. changeItem(item) {
  151. let content = {
  152. ...this.data.content,
  153. "ownertable": this.data.ownertable,
  154. "ownerid": this.data.ownerid,
  155. };
  156. content.pageSize = content.pageSize * (content.pageNumber - 1);
  157. content.pageNumber = 1;
  158. _Http.basic({
  159. "id": 20220930121501,
  160. content
  161. }).then(res => {
  162. console.log("跟进动态", res)
  163. if (res.msg != '成功') return wx.showToast({
  164. title: res.data,
  165. icon: "none"
  166. });
  167. let list = res.data.map(v => {
  168. try {
  169. v.names = v.contacts.map(n => n.name)
  170. } catch (error) {
  171. v.names = null
  172. }
  173. v.showsalesfeesamount = CNY(v.salesfeesamount || 0)
  174. return v
  175. })
  176. this.setData({
  177. list
  178. })
  179. })
  180. },
  181. expenseBreakdown(e) {
  182. const {
  183. item,
  184. index
  185. } = e.currentTarget.dataset;
  186. wx.navigateTo({
  187. url: `/packageA/expenseBreakdown/index?ownertable=${item.ownertable}&ownerid=${item.sys_datafollowupid}&isAdmin=${this.data.isAdmin}&item=${
  188. JSON.stringify(item)
  189. }`,
  190. })
  191. _Http.updateEBList = function (salesfeesamount, showsalesfeesamount) {
  192. this.setData({
  193. [`list[${index}].salesfeesamount`]: salesfeesamount,
  194. [`list[${index}].showsalesfeesamount`]: showsalesfeesamount,
  195. })
  196. }.bind(this)
  197. },
  198. insetr() {
  199. let parems = {
  200. ownertable: this.data.ownertable,
  201. ownerid: this.data.ownerid,
  202. ownerid1: this.data.ownerid1,
  203. resource: this.data.resource,
  204. sys_datafollowupid: 0,
  205. content: ""
  206. }
  207. wx.navigateTo({
  208. url: '/pages/trace/insert?parems=' + JSON.stringify(parems),
  209. })
  210. },
  211. toDetail(e) {
  212. const {
  213. item
  214. } = e.currentTarget.dataset;
  215. wx.navigateTo({
  216. url: `/pages/trace/detail?data=` + JSON.stringify({
  217. "sys_datafollowupid": item.sys_datafollowupid,
  218. "ownertable": this.data.ownertable,
  219. "ownerid": this.data.ownerid
  220. }),
  221. });
  222. _Http.changeItem = this.changeItem.bind(this);
  223. _Http.editItem = this.editItem.bind(this);
  224. _Http.handleDelete = this.handleDelete.bind(this);
  225. },
  226. deleteItem(e) {
  227. this.handleDelete(e.currentTarget.dataset.item)
  228. },
  229. handleDelete(item) {
  230. let that = this;
  231. return new Promise((resolve) => {
  232. wx.showModal({
  233. title: getApp().globalData.Language.getMapText('提示'),
  234. content: getApp().globalData.Language.getMapText('是否确定删除该跟进动态'),
  235. complete: ({
  236. confirm
  237. }) => {
  238. if (confirm) {
  239. _Http.basic({
  240. "id": 20220930121701,
  241. "content": {
  242. "sys_datafollowupid": item.sys_datafollowupid,
  243. "ownertable": that.data.ownertable,
  244. "ownerid": that.data.ownerid,
  245. deletereason: ""
  246. }
  247. }).then(res => {
  248. console.log("删除", res);
  249. wx.showToast({
  250. title: res.code != 1 ? getApp().globalData.Language.getMapText(res.msg) : getApp().globalData.Language.getMapText("删除成功"),
  251. icon: "none"
  252. });
  253. resolve(res.code)
  254. if (res.code != 1) return;
  255. that.setData({
  256. list: that.data.list.filter(v => v.sys_datafollowupid != item.sys_datafollowupid),
  257. 'content.total': that.data.content.total - 1
  258. })
  259. })
  260. } else {
  261. resolve(0)
  262. }
  263. }
  264. })
  265. })
  266. },
  267. changeTotal() {
  268. this.setData({
  269. "content.total": this.data.content.total - 1
  270. })
  271. },
  272. comment(e) {
  273. let page = this.selectComponent('#' + e.currentTarget.id);
  274. page.changeShow()
  275. },
  276. updateCommentList({
  277. detail
  278. }) {
  279. detail.pageSize = 99999;
  280. _Http.basic({
  281. "id": 20240920092204,
  282. content: detail
  283. }).then(res => {
  284. console.log("更新评论列表", res)
  285. if (res.code == 1) {
  286. let idName = detail.ownertable + 'id';
  287. const index = this.data.list.findIndex(v => v[idName] == detail.ownerid)
  288. if (index != -1) {
  289. let item = this.data.list[index];
  290. item.commentqty = res.total == 0 ? 0 : res.data[0].totalqty;
  291. item.comment = res.data;
  292. this.setData({
  293. [`list[${index}]`]: item
  294. })
  295. }
  296. }
  297. })
  298. }
  299. }
  300. })