index.js 10 KB

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