index.js 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  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. Page({
  8. data: {
  9. loading: true,
  10. typeList: [{
  11. name: getApp().globalData.Language.getMapText('客户报价'),
  12. index: 0
  13. }, {
  14. name: getApp().globalData.Language.getMapText('项目报价'),
  15. index: 1
  16. }],
  17. typeShow: false,
  18. navList: [{
  19. label: "我负责的",
  20. icon: "icon-webxialaxuanxiangjiantou",
  21. color: "",
  22. width: "",
  23. id: "1"
  24. }, {
  25. label: "排序",
  26. icon: "icon-jiangxu1",
  27. color: "",
  28. width: "",
  29. id: "sort"
  30. }, {
  31. label: "筛选",
  32. icon: "icon-shaixuan",
  33. color: "",
  34. width: "",
  35. id: "2"
  36. }],
  37. classShow: false,
  38. content: {
  39. "nocache": true,
  40. deleted: 0,
  41. "type": 1,
  42. "version": 1,
  43. "pageNumber": 1,
  44. "pageSize": 20,
  45. "where": {
  46. "condition": "",
  47. "startdate": "",
  48. "enddate": "",
  49. "status": "",
  50. },
  51. "sort": []
  52. },
  53. filter: {
  54. show: false,
  55. type: ['客户报价', '项目报价'], //状态项
  56. typeActive: "",
  57. status: ['新建', '提交', '审核', "复核"], //状态项
  58. statusActive: "",
  59. startdate: "",
  60. enddate: ""
  61. }
  62. },
  63. onLoad(options) {
  64. getApp().globalData.Language.getLanguagePackage(this, '报价单');
  65. this.setData({
  66. insert: wx.getStorageSync('auth').woffer.options.some(v => v == 'insert'), //查询新增权限
  67. classActions: wx.getStorageSync('templetList').map((v, i) => {
  68. return {
  69. name: v.templetname,
  70. index: v.templetid,
  71. color: i == 0 ? '#3874F6' : '',
  72. i: i,
  73. }
  74. }),
  75. 'navList[0].label': wx.getStorageSync('templetList')[0].templetname,
  76. "content.type": wx.getStorageSync('templetList')[0].templetid,
  77. });
  78. this.getList();
  79. },
  80. /* 获取列表 */
  81. getList(init = false, data) {
  82. if (init.detail != undefined) init = init.detail;
  83. let content = this.data.content;
  84. if (init) content.pageNumber = 1;
  85. if (content.pageNumber > content.pageTotal) return;
  86. if (data) {
  87. content.where.status = data.statusActive;
  88. content.where.startdate = data.startdate;
  89. content.where.enddate = data.enddate;
  90. content.where.isproject = data.typeActive;
  91. }
  92. _Http.basic({
  93. "id": 20221020165103,
  94. content
  95. }).then(res => {
  96. console.log("报价单列表", res)
  97. this.selectComponent('#ListBox').RefreshToComplete();
  98. if (res.code != '1') return wx.showToast({
  99. title: res.msg,
  100. icon: "none"
  101. })
  102. res.data = res.data.map(v => {
  103. v.progress = v.stage / v.totalstage * 100;
  104. v.quotedpriceamount = CNY(v.quotedpriceamount)
  105. return v
  106. })
  107. this.setData({
  108. loading: false,
  109. 'content.pageNumber': res.pageNumber + 1,
  110. 'content.pageTotal': res.pageTotal,
  111. 'content.total': res.total,
  112. 'content.sort': res.sort,
  113. list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data)
  114. });
  115. this.getTags();
  116. })
  117. },
  118. /* 处理搜索 */
  119. onSearch({
  120. detail
  121. }) {
  122. this.setData({
  123. "content.where.condition": detail
  124. });
  125. this.getList(true);
  126. },
  127. /* 获取列表标签 */
  128. getTags() {
  129. let list = this.data.list,
  130. ownerids = list.map(v => v.sa_quotedpriceid);
  131. _Http.basic({
  132. "id": 20221018102001,
  133. "content": {
  134. nocache: true,
  135. "ownertable": "sa_quotedprice",
  136. ownerids
  137. }
  138. }).then(res => {
  139. console.log("标签", res)
  140. for (let key in res.data) {
  141. let index = list.findIndex(v => v.sa_quotedpriceid == key);
  142. list[index].tags = res.data[key]
  143. };
  144. this.setData({
  145. list
  146. })
  147. })
  148. },
  149. /* 去添加 */
  150. openType() {
  151. this.setData({
  152. typeShow: true
  153. })
  154. },
  155. typeCancel() {
  156. this.setData({
  157. typeShow: false
  158. })
  159. },
  160. /* 选择添加报价形式 */
  161. typeSelect({
  162. detail
  163. }) {
  164. wx.navigateTo({
  165. url: detail.index == 1 ? '/packageA/offers/addProjectOffer' : '/packageA/offers/addSetclientOffer',
  166. });
  167. this.typeCancel();
  168. },
  169. /* 顶部条件导航回调 */
  170. navClick({
  171. detail
  172. }) {
  173. switch (detail.id) {
  174. case '1':
  175. this.setData({
  176. classShow: true
  177. })
  178. break;
  179. case '2':
  180. this.setData({
  181. 'filter.show': true
  182. })
  183. break;
  184. }
  185. },
  186. classClose() {
  187. this.setData({
  188. classShow: false
  189. })
  190. },
  191. classSelect({
  192. detail
  193. }) {
  194. if (this.data.content.type == detail.index) return this.classClose();
  195. this.setData({
  196. "content.type": detail.index,
  197. 'navList[0].label': detail.name,
  198. classActions: this.data.classActions.map(v => {
  199. v.color = detail.i == v.i ? '#3874F6' : ''
  200. return v
  201. })
  202. })
  203. this.classClose();
  204. this.getList(true)
  205. },
  206. /* 筛选状态选择 */
  207. selectStatus(e) {
  208. const {
  209. item
  210. } = e.currentTarget.dataset;
  211. this.setData({
  212. "filter.statusActive": this.data.filter.statusActive == item ? "" : item
  213. })
  214. },
  215. /* 筛选状态选择 */
  216. typeStatus(e) {
  217. const {
  218. item
  219. } = e.currentTarget.dataset;
  220. this.setData({
  221. "filter.typeActive": this.data.filter.typeActive == item ? "" : item
  222. })
  223. },
  224. /* 处理筛选 */
  225. handleFilter({
  226. detail
  227. }) {
  228. const data = this.data.filter;
  229. if (data.typeActive) data.typeActive = data.typeActive == '客户报价' ? 0 : 1;
  230. switch (detail) {
  231. case 'confirm':
  232. this.setData({
  233. 'filter.show': false
  234. });
  235. this.getList(true, data);
  236. break;
  237. case 'reset':
  238. this.setData({
  239. 'filter.statusActive': "",
  240. 'filter.typeActive': "",
  241. 'filter.startdate': "",
  242. 'filter.enddate': "",
  243. });
  244. this.getList(true, this.data.filter)
  245. break;
  246. case 'close':
  247. this.setData({
  248. 'filter.show': false
  249. });
  250. break;
  251. }
  252. }
  253. })