client.js 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. const _Http = getApp().globalData.http,
  2. currency = require("../../utils/currency"),
  3. CNY = (value, symbol = "¥", precision = 2) => currency(value, {
  4. symbol,
  5. precision
  6. }).format();
  7. Component({
  8. options: {
  9. addGlobalClass: true
  10. },
  11. lifetimes: {
  12. attached: function () {
  13. getApp().globalData.Language.getLanguagePackage(this)
  14. let idName = 'sa_customersid',
  15. ParamId = 20230713104204;
  16. switch (this.data.mode) {
  17. case '项目':
  18. ParamId = 20230715112304;
  19. idName = 'sa_projectid';
  20. break;
  21. case '业务员':
  22. ParamId = 20230717101304;
  23. idName = 'hrid';
  24. this.setData({
  25. dateTypes: ["全部", "本年", "本季", "本月"]
  26. })
  27. break;
  28. }
  29. this.setData({
  30. idName,
  31. ParamId,
  32. })
  33. _Http.basic({
  34. "classname": "sysmanage.develop.optiontype.optiontype",
  35. "method": "optiontypeselect",
  36. "content": {
  37. "pageNumber": 1,
  38. "pageSize": 1000,
  39. "typename": "contracttype",
  40. "parameter": {}
  41. },
  42. }).then(res => {
  43. console.log("合同类型", res)
  44. if (res.code == 1) {
  45. res.data.unshift({
  46. remarks: "全部",
  47. value: ""
  48. })
  49. this.setData({
  50. typeList: res.data
  51. })
  52. }
  53. })
  54. }
  55. },
  56. properties: {
  57. mode: {
  58. type: String,
  59. value: "客户"
  60. },
  61. },
  62. data: {
  63. dateTypes: ["全部", "本年"],
  64. dateType: "本年",
  65. showList: false,
  66. list: [],
  67. "isAll": 0, //1全部 0本年
  68. "content": {
  69. "nocache": true,
  70. "pageNumber": 1,
  71. "pageTotal": 1,
  72. "total": null,
  73. "where": {
  74. type: "",
  75. begdate: "",
  76. enddate: "",
  77. }
  78. },
  79. typeList: []
  80. },
  81. methods: {
  82. getList(id, init) {
  83. let content = this.data.content;
  84. content[this.data.idName] = id;
  85. if (this.data.mode == "业务员") {
  86. content.type = 99;
  87. switch (this.data.dateType) {
  88. case '全部':
  89. content.type = 0
  90. break;
  91. case '本年':
  92. content.type = 1
  93. break;
  94. case '本季':
  95. content.type = 2
  96. break;
  97. case '本月':
  98. content.type = 3
  99. break;
  100. }
  101. } else {
  102. content.isAll = this.data.isAll;
  103. }
  104. if (init) {
  105. content.pageNumber = 1;
  106. content.total = null;
  107. }
  108. if (!this.data.showList && content.total != null) return;
  109. if (content.pageNumber > content.pageTotal) return;
  110. _Http.basic({
  111. "id": this.data.ParamId,
  112. content
  113. }).then(res => {
  114. console.log(this.data.mode + "关联合同", res)
  115. if (res.code != '1') return wx.showToast({
  116. title: res.data,
  117. icon: "none"
  118. })
  119. content.pageNumber = res.pageNumber + 1;
  120. content.pageSize = res.pageSize;
  121. content.pageTotal = res.pageTotal;
  122. content.total = res.total;
  123. res.data = res.data.map(v => {
  124. let result = "";
  125. switch (v.type) {
  126. case "框架":
  127. result = '经销商合作协议'
  128. break;
  129. case "直销":
  130. result = '直销客户合作协议'
  131. break;
  132. case "工具借用":
  133. result = '工具使用(借用)协议'
  134. break;
  135. case "居间":
  136. result = '居间协议'
  137. break;
  138. default:
  139. result = v.type + '协议'
  140. break;
  141. };
  142. v.type = result
  143. v.sumSignAmount = CNY(v.sumSignAmount / (wx.getStorageSync('languagecode') == 'ZH' ? 10000 : 1000));
  144. v.inProgressAmount = CNY(v.inProgressAmount / (wx.getStorageSync('languagecode') == 'ZH' ? 10000 : 1000));
  145. v.expireAmount = CNY(v.expireAmount / (wx.getStorageSync('languagecode') == 'ZH' ? 10000 : 1000));
  146. v.convertOrderContractAmount = CNY(v.convertOrderContractAmount / (wx.getStorageSync('languagecode') == 'ZH' ? 10000 : 1000));
  147. v.signAmount = CNY(v.signAmount);
  148. return v
  149. })
  150. this.setData({
  151. list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
  152. content,
  153. id: id,
  154. });
  155. try {
  156. this.selectComponent("#TimeRange").onCancel()
  157. } catch (error) {
  158. }
  159. try {
  160. this.selectComponent("#Filtrate").onCancel()
  161. } catch (error) {
  162. }
  163. })
  164. },
  165. changeDate({
  166. detail
  167. }) {
  168. this.setData({
  169. dateType: detail.dateType,
  170. isAll: detail.isAll === "" ? 99 : detail.isAll,
  171. "content.where.begdate": detail.begdate || "",
  172. "content.where.enddate": detail.enddate || ""
  173. })
  174. this.getList(this.data.id, true)
  175. },
  176. changeType({
  177. detail
  178. }) {
  179. this.setData({
  180. "content.where.type": detail,
  181. })
  182. this.getList(this.data.id, true)
  183. },
  184. shrinkChange({
  185. detail
  186. }) {
  187. this.setData({
  188. showList: detail
  189. })
  190. },
  191. upDateList() {
  192. let content = JSON.parse(JSON.stringify(this.data.content));
  193. try {
  194. content[this.data.idName] = this.data.id;
  195. if (this.data.mode == "业务员") {
  196. content.type = 99;
  197. switch (this.data.dateType) {
  198. case '全部':
  199. content.type = 0
  200. break;
  201. case '本年':
  202. content.type = 1
  203. break;
  204. case '本季':
  205. content.type = 2
  206. break;
  207. case '本月':
  208. content.type = 3
  209. break;
  210. }
  211. } else {
  212. content.isAll = this.data.isAll;
  213. }
  214. content.pageSize = (content.pageNumber - 1) * content.pageSize;
  215. content.pageNumber = 1;
  216. } catch (error) {
  217. console.log("error", error)
  218. }
  219. _Http.basic({
  220. id: this.data.ParamId,
  221. content
  222. }).then(res => {
  223. console.log(this.data.mode + "更新关联合同", res);
  224. if (res.code == '1') {
  225. res.data = res.data.map(v => {
  226. v.sumSignAmount = CNY(v.sumSignAmount / (wx.getStorageSync('languagecode') == 'ZH' ? 10000 : 1000));
  227. v.inProgressAmount = CNY(v.inProgressAmount / (wx.getStorageSync('languagecode') == 'ZH' ? 10000 : 1000));
  228. v.expireAmount = CNY(v.expireAmount / (wx.getStorageSync('languagecode') == 'ZH' ? 10000 : 1000));
  229. v.convertOrderContractAmount = CNY(v.convertOrderContractAmount / (wx.getStorageSync('languagecode') == 'ZH' ? 10000 : 1000));
  230. v.signAmount = CNY(v.signAmount);
  231. return v
  232. })
  233. this.setData({
  234. list: res.data,
  235. "content.total": res.total
  236. })
  237. }
  238. })
  239. }
  240. }
  241. })