index.js 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. const _Http = getApp().globalData.http;
  2. import currency from "../../utils/currency";
  3. Page({
  4. data: {
  5. loading: true,
  6. active: "新建",
  7. "content": {
  8. nocache: true,
  9. "pageNumber": 1,
  10. "pageTotal": 1,
  11. "pageSize": 20,
  12. "isManage": 0, //默认是1,表示管理端,0表示非管理端,根据用户类型自动区分业务员还是经销商
  13. "isExport": 0,
  14. total: 0,
  15. "where": {
  16. "condition": "",
  17. },
  18. sort: []
  19. },
  20. filter: [{
  21. label: "品牌",
  22. index: null,
  23. showName: "brandname", //显示字段
  24. valueKey: "brandname", //返回Key
  25. selectKey: "brandname", //传参 代表选着字段 不传参返回整个选择对象
  26. value: "", //选中值
  27. list: []
  28. }, {
  29. label: "领域",
  30. index: null,
  31. showName: "tradefield", //显示字段
  32. valueKey: "tradefield", //返回Key
  33. selectKey: "tradefield", //传参 代表选着字段 不传参返回整个选择对象
  34. value: "", //选中值
  35. list: []
  36. }],
  37. createShow: false,
  38. types: [{
  39. name: "按借用合同借用"
  40. }, {
  41. name: "单个借用"
  42. }]
  43. },
  44. onLoad(options) {
  45. this.getList(true)
  46. this.setData({
  47. userrole: wx.getStorageSync('userrole')
  48. })
  49. },
  50. /* 处理筛选 */
  51. handleFilter({
  52. detail
  53. }) {
  54. console.log(detail)
  55. },
  56. getList(init = false) {
  57. if (init.detail != undefined) init = init.detail;
  58. let content = this.data.content;
  59. if (init) content.pageNumber = 1;
  60. if (content.pageNumber > content.pageTotal) return;
  61. content.where.status = this.data.active;
  62. _Http.basic({
  63. "id": 20230114105002,
  64. "version": 1,
  65. content
  66. }).then(res => {
  67. console.log("工具借用列表", res)
  68. this.selectComponent('#ListBox').RefreshToComplete();
  69. res.data = res.data.map(v => {
  70. v.amount = currency(v.amount, {
  71. symbol: "¥",
  72. precision: 2
  73. }).format()
  74. return v
  75. })
  76. this.setData({
  77. list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
  78. "content.pageNumber": res.pageNumber + 1,
  79. "content.pageTotal": res.pageTotal,
  80. "content.sort": res.sort,
  81. "content.total": res.total,
  82. loading: false
  83. })
  84. })
  85. },
  86. /* 去新增 */
  87. openAction() {
  88. this.setData({
  89. createShow: true
  90. })
  91. },
  92. createBor({
  93. detail
  94. }) {
  95. this.onCancel();
  96. if (detail.name == '按借用合同借用') {
  97. wx.navigateTo({
  98. url: `/select/contract/index?params=${JSON.stringify({
  99. "id": 20230114092502,
  100. "content": {
  101. nocache: true,
  102. "pageNumber": 1,
  103. "pageTotal": 1,
  104. "total": null,
  105. "pageSize": 20,
  106. "where": {
  107. "condition": ""
  108. }
  109. }
  110. })}&radio=false`
  111. })
  112. getApp().globalData.handleSelect = this.handleCreated.bind(this);
  113. } else {
  114. if (this.data.userrole == '业务员') {
  115. wx.navigateTo({
  116. url: `/select/agent/index?params=${JSON.stringify({
  117. "id": 20220920083901,
  118. "content": {
  119. nocache:true,
  120. "where": {
  121. "condition": "",
  122. "type":9,
  123. }
  124. }
  125. })}&radio=true`,
  126. })
  127. getApp().globalData.handleSelect = this.handleSingle.bind(this);
  128. } else {
  129. _Http.basic({
  130. "id": 20230116092702,
  131. "content": {
  132. "sa_orderid": 0
  133. }
  134. }).then(res => {
  135. console.log("按个", res)
  136. if (res.msg != '成功') return wx.showToast({
  137. title: res.msg,
  138. icon: "none"
  139. });
  140. wx.navigateTo({
  141. url: '/packageA/borrow/detail?id=' + res.data.sa_orderid,
  142. })
  143. })
  144. }
  145. }
  146. },
  147. handleSingle({
  148. item
  149. }) {
  150. wx.showModal({
  151. title: '提示',
  152. content: `是否确定选择"${item.enterprisename}"创建工具借用单?`,
  153. complete: (res) => {
  154. if (res.confirm) _Http.basic({
  155. "id": 20230116092702,
  156. "content": {
  157. "sa_orderid": 0,
  158. sys_enterpriseid: item.sys_enterpriseid
  159. }
  160. }).then(res => {
  161. console.log("按个", res)
  162. if (res.msg != '成功') return wx.showToast({
  163. title: res.msg,
  164. icon: "none"
  165. });
  166. wx.redirectTo({
  167. url: '/packageA/borrow/detail?id=' + res.data.sa_orderid,
  168. })
  169. })
  170. }
  171. })
  172. },
  173. handleCreated(e) {
  174. wx.showModal({
  175. title: '提示',
  176. content: `是否确认选择“${e.item.title}”创建借用单`,
  177. complete: ({
  178. confirm
  179. }) => {
  180. if (confirm) _Http.basic({
  181. "id": 20230116092702,
  182. "content": {
  183. "sa_contractid": e.id[0],
  184. "sa_orderid": 0
  185. }
  186. }).then(res => {
  187. console.log("按套", res)
  188. if (res.msg != '成功') return wx.showToast({
  189. title: res.msg,
  190. icon: "none"
  191. });
  192. _Http.basic({
  193. "id": 20230116142602,
  194. "content": {
  195. "sa_orderid": res.data.sa_orderid,
  196. "sys_enterpriseid": res.data.sys_enterpriseid,
  197. "sa_contractid": e.id[0]
  198. }
  199. }, false).then(s => {
  200. console.log("复制合同商品", s)
  201. wx.redirectTo({
  202. url: '/packageA/borrow/detail?id=' + res.data.sa_orderid,
  203. })
  204. })
  205. })
  206. }
  207. })
  208. },
  209. onCancel() {
  210. this.setData({
  211. createShow: false
  212. })
  213. },
  214. /* 搜索 */
  215. onSearch({
  216. detail
  217. }) {
  218. this.setData({
  219. "content.where.condition": detail
  220. });
  221. this.getList(true)
  222. },
  223. /* 切换tabs */
  224. tabsChange(e) {
  225. let status = "";
  226. switch (e.detail.title) {
  227. case '全部':
  228. status = "";
  229. break;
  230. case '待确认':
  231. status = "交期待确认";
  232. break;
  233. default:
  234. status = e.detail.title
  235. break;
  236. }
  237. this.setData({
  238. active: status
  239. });
  240. this.getList(true);
  241. },
  242. onReady() {
  243. this.setListHeight()
  244. },
  245. /* 设置页面高度 */
  246. setListHeight() {
  247. this.selectComponent("#ListBox").setHeight(".total", this);
  248. },
  249. })