index.js 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  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. createShow: false,
  21. sys_enterpriseid: 0,
  22. types: [{
  23. name: "按借用合同借用"
  24. }, {
  25. name: "单个借用"
  26. }]
  27. },
  28. onLoad(options) {
  29. this.getList(true)
  30. this.setData({
  31. userrole: wx.getStorageSync('userrole')
  32. })
  33. },
  34. getList(init = false) {
  35. if (init.detail != undefined) init = init.detail;
  36. let content = this.data.content;
  37. if (init) content.pageNumber = 1;
  38. if (content.pageNumber > content.pageTotal) return;
  39. content.where.status = this.data.active;
  40. _Http.basic({
  41. "id": 20230114105002,
  42. "version": 1,
  43. content
  44. }).then(res => {
  45. console.log("工具借用列表", res)
  46. this.selectComponent('#ListBox').RefreshToComplete();
  47. res.data = res.data.map(v => {
  48. v.amount = currency(v.amount, {
  49. symbol: "¥",
  50. precision: 2
  51. }).format()
  52. return v
  53. })
  54. this.setData({
  55. list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
  56. "content.pageNumber": res.pageNumber + 1,
  57. "content.pageTotal": res.pageTotal,
  58. "content.sort": res.sort,
  59. "content.total": res.total,
  60. loading: false
  61. })
  62. })
  63. },
  64. /* 去新增 */
  65. openAction() {
  66. this.setData({
  67. createShow: true
  68. })
  69. },
  70. createBor({
  71. detail
  72. }) {
  73. this.onCancel();
  74. if (detail.name == '按借用合同借用') {
  75. let usertype = wx.getStorageSync('userMsg').usertype,
  76. that = this;
  77. if (usertype == 1) {
  78. wx.navigateTo({
  79. url: `/select/agent/index?params=${JSON.stringify({
  80. "id": 20220920083901,
  81. "content": {
  82. nocache:true,
  83. "where": {
  84. "condition": "",
  85. "type":9,
  86. }
  87. }
  88. })}&radio=true`,
  89. })
  90. getApp().globalData.handleSelect = function ({
  91. item
  92. }) {
  93. wx.redirectTo({
  94. url: `/select/contract/index?params=${JSON.stringify({
  95. "id": 20230114092502,
  96. "content": {
  97. nocache: true,
  98. "pageNumber": 1,
  99. "sys_enterpriseid":item.sys_enterpriseid,
  100. "pageTotal": 1,
  101. "total": null,
  102. "pageSize": 20,
  103. "where": {
  104. "condition": ""
  105. }
  106. }
  107. })}&radio=false`,
  108. success() {
  109. getApp().globalData.handleSelect = that.handleCreated.bind(this);
  110. }
  111. })
  112. }
  113. } else {
  114. wx.navigateTo({
  115. url: `/select/contract/index?params=${JSON.stringify({
  116. "id": 20230114092502,
  117. "content": {
  118. nocache: true,
  119. "pageNumber": 1,
  120. "pageTotal": 1,
  121. "total": null,
  122. "pageSize": 20,
  123. typemx:"合同借用",
  124. "where": {
  125. "condition": ""
  126. }
  127. }
  128. })}&radio=false`
  129. })
  130. getApp().globalData.handleSelect = this.handleCreated.bind(this);
  131. }
  132. } else {
  133. if (this.data.userrole == '业务员') {
  134. wx.navigateTo({
  135. url: `/select/agent/index?params=${JSON.stringify({
  136. "id": 20220920083901,
  137. "content": {
  138. nocache:true,
  139. "where": {
  140. "condition": "",
  141. "type":9,
  142. }
  143. }
  144. })}&radio=true`,
  145. })
  146. getApp().globalData.handleSelect = this.handleSingle.bind(this);
  147. } else {
  148. _Http.basic({
  149. "id": 20230116092702,
  150. "content": {
  151. "sa_orderid": 0
  152. }
  153. }).then(res => {
  154. console.log("按个", res)
  155. if (res.msg != '成功') return wx.showToast({
  156. title: res.msg,
  157. icon: "none"
  158. });
  159. wx.navigateTo({
  160. url: '/packageA/borrow/detail?id=' + res.data.sa_orderid,
  161. })
  162. })
  163. }
  164. }
  165. },
  166. handleSingle({
  167. item
  168. }) {
  169. wx.showModal({
  170. title: '提示',
  171. content: `是否确定选择"${item.enterprisename}"创建工具借用单?`,
  172. complete: (res) => {
  173. if (res.confirm) _Http.basic({
  174. "id": 20230116092702,
  175. "content": {
  176. "sa_orderid": 0,
  177. sys_enterpriseid: item.sys_enterpriseid
  178. }
  179. }).then(res => {
  180. console.log("按个", res)
  181. if (res.msg != '成功') return wx.showToast({
  182. title: res.msg,
  183. icon: "none"
  184. });
  185. wx.redirectTo({
  186. url: '/packageA/borrow/detail?id=' + res.data.sa_orderid,
  187. })
  188. })
  189. }
  190. })
  191. },
  192. handleCreated(e) {
  193. let that = this;
  194. wx.showModal({
  195. title: '提示',
  196. content: `是否确认选择“${e.item.title}”创建借用单`,
  197. complete: ({
  198. confirm
  199. }) => {
  200. if (confirm) _Http.basic({
  201. "id": 20230116092702,
  202. "content": {
  203. "sa_contractid": e.id[0],
  204. "sa_orderid": 0,
  205. "sys_enterpriseid": e.item.sys_enterpriseid
  206. }
  207. }).then(res => {
  208. console.log("按套", res)
  209. if (res.msg != '成功') return wx.showToast({
  210. title: res.msg,
  211. icon: "none"
  212. });
  213. _Http.basic({
  214. "id": 20230116142602,
  215. "content": {
  216. "sa_orderid": res.data.sa_orderid,
  217. "sys_enterpriseid": res.data.sys_enterpriseid,
  218. "sa_contractid": e.id[0]
  219. }
  220. }, false).then(s => {
  221. console.log("复制合同商品", s)
  222. wx.redirectTo({
  223. url: '/packageA/borrow/detail?id=' + res.data.sa_orderid,
  224. })
  225. })
  226. })
  227. }
  228. })
  229. },
  230. onCancel() {
  231. this.setData({
  232. createShow: false
  233. })
  234. },
  235. /* 搜索 */
  236. onSearch({
  237. detail
  238. }) {
  239. this.setData({
  240. "content.where.condition": detail
  241. });
  242. this.getList(true)
  243. },
  244. /* 切换tabs */
  245. tabsChange(e) {
  246. let status = "";
  247. switch (e.detail.title) {
  248. case '全部':
  249. status = "";
  250. break;
  251. case '待确认':
  252. status = "交期待确认";
  253. break;
  254. default:
  255. status = e.detail.title
  256. break;
  257. }
  258. this.setData({
  259. active: status
  260. });
  261. this.getList(true);
  262. },
  263. onReady() {
  264. this.setListHeight()
  265. },
  266. /* 设置页面高度 */
  267. setListHeight() {
  268. this.selectComponent("#ListBox").setHeight(".total", this);
  269. },
  270. })