index.js 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  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. that.data.sys_enterpriseid = item.sys_enterpriseid;
  110. getApp().globalData.handleSelect = that.handleCreated.bind(this);
  111. }
  112. })
  113. }
  114. } else {
  115. wx.navigateTo({
  116. url: `/select/contract/index?params=${JSON.stringify({
  117. "id": 20230114092502,
  118. "content": {
  119. nocache: true,
  120. "pageNumber": 1,
  121. "pageTotal": 1,
  122. "total": null,
  123. "pageSize": 20,
  124. typemx:"合同借用",
  125. "where": {
  126. "condition": ""
  127. }
  128. }
  129. })}&radio=false`
  130. })
  131. getApp().globalData.handleSelect = this.handleCreated.bind(this);
  132. }
  133. } else {
  134. if (this.data.userrole == '业务员') {
  135. wx.navigateTo({
  136. url: `/select/agent/index?params=${JSON.stringify({
  137. "id": 20220920083901,
  138. "content": {
  139. nocache:true,
  140. "where": {
  141. "condition": "",
  142. "type":9,
  143. }
  144. }
  145. })}&radio=true`,
  146. })
  147. getApp().globalData.handleSelect = this.handleSingle.bind(this);
  148. } else {
  149. _Http.basic({
  150. "id": 20230116092702,
  151. "content": {
  152. "sa_orderid": 0
  153. }
  154. }).then(res => {
  155. console.log("按个", res)
  156. if (res.msg != '成功') return wx.showToast({
  157. title: res.msg,
  158. icon: "none"
  159. });
  160. wx.navigateTo({
  161. url: '/packageA/borrow/detail?id=' + res.data.sa_orderid,
  162. })
  163. })
  164. }
  165. }
  166. },
  167. handleSingle({
  168. item
  169. }) {
  170. wx.showModal({
  171. title: '提示',
  172. content: `是否确定选择"${item.enterprisename}"创建工具借用单?`,
  173. complete: (res) => {
  174. if (res.confirm) _Http.basic({
  175. "id": 20230116092702,
  176. "content": {
  177. "sa_orderid": 0,
  178. sys_enterpriseid: item.sys_enterpriseid
  179. }
  180. }).then(res => {
  181. console.log("按个", res)
  182. if (res.msg != '成功') return wx.showToast({
  183. title: res.msg,
  184. icon: "none"
  185. });
  186. wx.redirectTo({
  187. url: '/packageA/borrow/detail?id=' + res.data.sa_orderid,
  188. })
  189. })
  190. }
  191. })
  192. },
  193. handleCreated(e) {
  194. let that = this;
  195. wx.showModal({
  196. title: '提示',
  197. content: `是否确认选择“${e.item.title}”创建借用单`,
  198. complete: ({
  199. confirm
  200. }) => {
  201. if (confirm) _Http.basic({
  202. "id": 20230116092702,
  203. "content": {
  204. "sa_contractid": e.id[0],
  205. "sa_orderid": 0,
  206. "sys_enterpriseid": that.data.sys_enterpriseid
  207. }
  208. }).then(res => {
  209. console.log("按套", res)
  210. if (res.msg != '成功') return wx.showToast({
  211. title: res.msg,
  212. icon: "none"
  213. });
  214. _Http.basic({
  215. "id": 20230116142602,
  216. "content": {
  217. "sa_orderid": res.data.sa_orderid,
  218. "sys_enterpriseid": res.data.sys_enterpriseid,
  219. "sa_contractid": e.id[0]
  220. }
  221. }, false).then(s => {
  222. console.log("复制合同商品", s)
  223. wx.redirectTo({
  224. url: '/packageA/borrow/detail?id=' + res.data.sa_orderid,
  225. })
  226. })
  227. })
  228. }
  229. })
  230. },
  231. onCancel() {
  232. this.setData({
  233. createShow: false
  234. })
  235. },
  236. /* 搜索 */
  237. onSearch({
  238. detail
  239. }) {
  240. this.setData({
  241. "content.where.condition": detail
  242. });
  243. this.getList(true)
  244. },
  245. /* 切换tabs */
  246. tabsChange(e) {
  247. let status = "";
  248. switch (e.detail.title) {
  249. case '全部':
  250. status = "";
  251. break;
  252. case '待确认':
  253. status = "交期待确认";
  254. break;
  255. default:
  256. status = e.detail.title
  257. break;
  258. }
  259. this.setData({
  260. active: status
  261. });
  262. this.getList(true);
  263. },
  264. onReady() {
  265. this.setListHeight()
  266. },
  267. /* 设置页面高度 */
  268. setListHeight() {
  269. this.selectComponent("#ListBox").setHeight(".total", this);
  270. },
  271. })