index.js 7.7 KB

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