project.js 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  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. import {
  8. getTypes
  9. } from "./projectQuery";
  10. Component({
  11. options: {
  12. addGlobalClass: true,
  13. },
  14. properties: {
  15. update: {
  16. type: Function
  17. }
  18. },
  19. lifetimes: {
  20. attached: function () {
  21. getApp().globalData.Language.getLanguagePackage(this)
  22. this.data.organization = this.selectComponent("#organization");
  23. this.data.organization.initDepAndUser().then(active => {
  24. let userid = active.userid || wx.getStorageSync("userMsg").userid;
  25. this.setData({
  26. "content.dataid": userid,
  27. userid,
  28. })
  29. this.triggerEvent('update', "Client")
  30. });
  31. this.setFiltratelist();
  32. }
  33. },
  34. data: {
  35. list: [],
  36. filtratelist: [],
  37. total: null,
  38. searchShow: false,
  39. searchValue: "",
  40. showFiltrate: false,
  41. "content": {
  42. "dataid": 0,
  43. "type": 0,
  44. "pageNumber": 1,
  45. "pageSize": 20,
  46. "where": {
  47. "condition": "",
  48. "tag": "",
  49. "status": "",
  50. "projecttype": "",
  51. "stagename": "",
  52. "tradefield": "",
  53. "begindate": "",
  54. "enddate": ""
  55. }
  56. }
  57. },
  58. methods: {
  59. async setFiltratelist() {
  60. let filtratelist = [{
  61. label: "项目类型",
  62. index: null,
  63. showName: "value", //显示字段
  64. valueKey: "projecttype", //返回Key
  65. selectKey: "value", //传参 代表选着字段 不传参返回整个选择对象
  66. value: "", //选中值
  67. list: await getTypes('projecttype')
  68. }, {
  69. label: "项目阶段",
  70. index: null,
  71. showName: "stagename", //显示字段
  72. valueKey: "stagename", //返回Key
  73. selectKey: "stagename", //传参 代表选着字段 不传参返回整个选择对象
  74. value: "", //选中值
  75. list: await getTypes('stagename')
  76. }, {
  77. label: "领域",
  78. index: null,
  79. showName: "value", //显示字段
  80. valueKey: "tradefield", //返回Key
  81. selectKey: "value", //传参 代表选着字段 不传参返回整个选择对象
  82. value: "", //选中值
  83. list: await getTypes('tradefield')
  84. }, {
  85. label: "标签",
  86. index: null,
  87. type: "checkbox",
  88. showName: "tag", //显示字段
  89. valueKey: "tag", //返回Key
  90. selectKey: "tag", //传参 代表选着字段 不传参返回整个选择对象
  91. value: "", //选中值
  92. list: await getTypes('tags')
  93. }, {
  94. label: "项目状态",
  95. index: null,
  96. showName: "value", //显示字段
  97. valueKey: "status", //返回Key
  98. selectKey: "value", //传参 代表选着字段 不传参返回整个选择对象
  99. value: "", //选中值
  100. list: [{
  101. value: "跟进中"
  102. }, {
  103. value: "已成交"
  104. }, {
  105. value: "已失败"
  106. }, {
  107. value: "已结案"
  108. }]
  109. }]
  110. this.setData({
  111. filtratelist
  112. })
  113. },
  114. handleFilter({
  115. detail
  116. }) {
  117. if (!detail.name) return;
  118. let content = this.data.content,
  119. organization = this.data.organization;
  120. if (detail.name == "reset") {
  121. organization.setData({
  122. isleave: 1
  123. })
  124. organization.initDepAndUser()
  125. content.type = 0;
  126. content.dataid = this.data.userid;
  127. content.where = {
  128. "condition": content.where.condition || '',
  129. "tag": "",
  130. "status": "",
  131. "projecttype": "",
  132. "stagename": "",
  133. "tradefield": "",
  134. "begindate": "",
  135. "enddate": ""
  136. }
  137. } else if (detail.name == "confirm") {
  138. const res = organization.data.result
  139. content.type = res.departmentid ? 1 : 0;
  140. content.dataid = res.departmentid || res.userid;
  141. content.where = {
  142. "condition": content.where.condition || '',
  143. "tag": detail.tag || '',
  144. "status": detail.status || '',
  145. "projecttype": detail.projecttype || '',
  146. "stagename": detail.stagename || '',
  147. "tradefield": detail.tradefield || '',
  148. "begindate": detail.startdate || '',
  149. "enddate": detail.enddate || ''
  150. }
  151. }
  152. this.setData({
  153. content
  154. });
  155. this.getList(true);
  156. },
  157. getList(init = false) {
  158. _Http.init(this.data.content, init).then(content => {
  159. _Http.basic({
  160. "id": 20230715111604,
  161. content
  162. }).then(res => {
  163. console.log("项目画像", res)
  164. this.selectComponent('#ListBox').automaticSetHei();
  165. this.selectComponent('#ListBox').RefreshToComplete();
  166. if (res.code != '1') return wx.showToast({
  167. title: res.data,
  168. icon: "none"
  169. })
  170. res.data = res.data.map(v => {
  171. v.signamount_due = CNY(v.signamount_due)
  172. return v
  173. })
  174. this.setData({
  175. list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
  176. "content.pageNumber": res.pageNumber + 1,
  177. "content.pageSize": res.pageSize,
  178. "content.pageTotal": res.pageTotal,
  179. "total": res.total,
  180. })
  181. })
  182. })
  183. },
  184. changeSearchShow() {
  185. this.setData({
  186. searchShow: !this.data.searchShow
  187. })
  188. setTimeout(() => {
  189. this.selectComponent('#ListBox').automaticSetHei();
  190. if (this.data.searchShow) {
  191. if (this.selectComponent("#Yl_Filtrate1").data.show) return
  192. this.setData({
  193. focus: true
  194. })
  195. } else {
  196. this.setData({
  197. focus: false
  198. })
  199. }
  200. }, 350)
  201. },
  202. openFiltrate() {
  203. console.log("打开筛选")
  204. },
  205. onSearch() {
  206. this.data.content.where.condition = this.data.searchValue;
  207. this.getList(true);
  208. },
  209. onChange(event) {
  210. this.setData({
  211. searchValue: event.detail
  212. })
  213. },
  214. onClear() {
  215. this.setData({
  216. searchValue: "",
  217. "content.where.condition": ""
  218. })
  219. this.getList(true);
  220. },
  221. }
  222. })