index.js 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  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.msg != '成功') 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. title: getApp().globalData.Language.getMapText('提示'),
  174. content: getApp().globalData.Language.joint([{
  175. v: '是否确定选择',
  176. t: 1
  177. }, {
  178. v: item.enterprisename,
  179. t: 1,
  180. r: '”',
  181. f: "“"
  182. }, {
  183. v: '创建工具借用单',
  184. t: 1,
  185. r: '?',
  186. }]),
  187. complete: (res) => {
  188. if (res.confirm) _Http.basic({
  189. "id": 20230116092702,
  190. "content": {
  191. "sa_orderid": 0,
  192. sys_enterpriseid: item.sys_enterpriseid
  193. }
  194. }).then(res => {
  195. console.log("按个", res)
  196. if (res.msg != '成功') return wx.showToast({
  197. title: res.msg,
  198. icon: "none"
  199. });
  200. wx.redirectTo({
  201. url: '/packageA/borrow/detail?id=' + res.data.sa_orderid,
  202. })
  203. })
  204. }
  205. })
  206. },
  207. handleCreated(e) {
  208. let that = this;
  209. wx.showModal({
  210. title: getApp().globalData.Language.getMapText('提示'),
  211. content: getApp().globalData.Language.joint([{
  212. v: '是否确定选择',
  213. t: 1
  214. }, {
  215. v: e.item.title,
  216. t: 1,
  217. r: '”',
  218. f: "“"
  219. }, {
  220. v: '创建借用单',
  221. t: 1,
  222. r: '?',
  223. }]),
  224. complete: ({
  225. confirm
  226. }) => {
  227. if (confirm) _Http.basic({
  228. "id": 20230116092702,
  229. "content": {
  230. "sa_contractid": e.id[0],
  231. "sa_orderid": 0,
  232. "sys_enterpriseid": e.item.sys_enterpriseid
  233. }
  234. }).then(res => {
  235. console.log("按套", res)
  236. if (res.msg != '成功') return wx.showToast({
  237. title: res.msg,
  238. icon: "none"
  239. });
  240. _Http.basic({
  241. "id": 20230116142602,
  242. "content": {
  243. "sa_orderid": res.data.sa_orderid,
  244. "sys_enterpriseid": res.data.sys_enterpriseid,
  245. "sa_contractid": e.id[0]
  246. }
  247. }, false).then(s => {
  248. console.log("复制合同商品", s)
  249. wx.redirectTo({
  250. url: '/packageA/borrow/detail?id=' + res.data.sa_orderid,
  251. })
  252. })
  253. })
  254. }
  255. })
  256. },
  257. onCancel() {
  258. this.setData({
  259. createShow: false
  260. })
  261. },
  262. /* 搜索 */
  263. onSearch({
  264. detail
  265. }) {
  266. this.setData({
  267. "content.where.condition": detail
  268. });
  269. this.getList(true)
  270. },
  271. /* 切换tabs */
  272. tabsChange(e) {
  273. let status = "";
  274. switch (e.detail.name) {
  275. case '全部':
  276. status = "";
  277. break;
  278. case '待确认':
  279. status = "交期待确认";
  280. break;
  281. default:
  282. status = e.detail.title
  283. break;
  284. }
  285. this.setData({
  286. active: status
  287. });
  288. this.getList(true);
  289. },
  290. onReady() {
  291. this.setListHeight()
  292. },
  293. /* 设置页面高度 */
  294. setListHeight() {
  295. this.selectComponent("#ListBox").setHeight(".total", this);
  296. },
  297. })