detail.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  1. const _Http = getApp().globalData.http;
  2. Page({
  3. data: {
  4. loading: true,
  5. sa_orderid: null,
  6. tabsActive: 0,
  7. tabsList: [{
  8. label: "借用工具明细",
  9. icon: "icon-tabchanpin",
  10. model: "#Product"
  11. }, {
  12. label: "附件",
  13. icon: "icon-tabfujian1",
  14. model: "#Yl_Attachment"
  15. }, {
  16. label: "订单进度",
  17. icon: "icon-tabcaozuojilu1",
  18. model: "#Progress"
  19. }],
  20. },
  21. onLoad(options) {
  22. this.setData({
  23. sa_orderid: options.id
  24. });
  25. this.getDetail(true);
  26. },
  27. /* 获取详情 */
  28. getDetail(init = false, show = true) {
  29. _Http.basic({
  30. "id": 20230114140402,
  31. "content": {
  32. nocache: true,
  33. "sa_orderid": this.data.sa_orderid
  34. }
  35. }, show).then(res => {
  36. console.log("订单详情", res)
  37. if (res.msg != '成功') return wx.showToast({
  38. title: res.msg,
  39. icon: "none"
  40. });
  41. this.setData({
  42. detail: res.data,
  43. loading: false
  44. });
  45. if (init) this.partialRenewal(true)
  46. })
  47. },
  48. /* 选择收货人 */
  49. selectConsignee() {
  50. if (this.isEdit()) return;
  51. wx.navigateTo({
  52. url: `/select/address/index?params=${JSON.stringify({
  53. "id":20221009155803,
  54. "content": {
  55. nocache:true,
  56. sys_enterpriseid:this.data.detail.sys_enterpriseid,
  57. "pageNumber": 1,
  58. "pageTotal": 1,
  59. "pageSize": 20,
  60. "where": {
  61. "condition": "",
  62. workaddress:1
  63. },
  64. }
  65. })}&radio=true`,
  66. });
  67. getApp().globalData.handleSelect = this.setConsignee.bind(this);
  68. },
  69. /* 设置收货人 */
  70. setConsignee({
  71. item
  72. }) {
  73. let that = this;
  74. console.log("设置收货人", item)
  75. wx.showModal({
  76. title: '提示',
  77. content: `是否确认设置"${item.name}"为收货人?`,
  78. complete: (res) => {
  79. if (res.confirm) {
  80. let rec_contactsid = that.data.detail.rec_contactsid;
  81. that.setData({
  82. "detail.rec_contactsid": item.contactsid
  83. });
  84. that.changeDetail().then(s => {
  85. if (s.msg == '成功') {
  86. wx.showToast({
  87. title: '设置成功',
  88. icon: "none"
  89. });
  90. setTimeout(() => {
  91. wx.navigateBack();
  92. that.getDetail();
  93. }, 500)
  94. } else {
  95. that.setData({
  96. "detail.rec_contactsid": rec_contactsid
  97. });
  98. }
  99. })
  100. }
  101. }
  102. })
  103. },
  104. /* 选择财务信息 */
  105. selectFinance() {
  106. if (this.isEdit()) return;
  107. wx.navigateTo({
  108. url: `/select/finance/index?params=${JSON.stringify({
  109. "id":20221013160602,
  110. "content": {
  111. nocache:true,
  112. sys_enterpriseid:this.data.detail.sys_enterpriseid,
  113. "pageNumber": 1,
  114. "pageTotal": 1,
  115. "pageSize": 20,
  116. "where": {
  117. "condition": "",
  118. },
  119. }
  120. })}&radio=true`,
  121. });
  122. getApp().globalData.handleSelect = this.setFinance.bind(this);
  123. },
  124. /* 设置财务信息 */
  125. setFinance({
  126. item
  127. }) {
  128. let that = this;
  129. console.log("设置财务信息", item)
  130. wx.showModal({
  131. title: '提示',
  132. content: `是否确认设置"${item.enterprisename}"为开票单位?`,
  133. complete: (res) => {
  134. if (res.confirm) {
  135. let sys_enterprise_financeid = that.data.detail.sys_enterprise_financeid;
  136. that.setData({
  137. "detail.sys_enterprise_financeid": item.sys_enterprise_financeid
  138. });
  139. that.changeDetail().then(s => {
  140. if (s.msg == '成功') {
  141. wx.showToast({
  142. title: '设置成功',
  143. icon: "none"
  144. });
  145. setTimeout(() => {
  146. wx.navigateBack();
  147. that.getDetail();
  148. }, 500)
  149. } else {
  150. that.setData({
  151. "detail.sys_enterprise_financeid": sys_enterprise_financeid
  152. });
  153. }
  154. })
  155. }
  156. }
  157. })
  158. },
  159. //tabs 切换
  160. tabsChange({
  161. detail
  162. }) {
  163. this.setData({
  164. tabsActive: detail
  165. });
  166. this.partialRenewal();
  167. },
  168. //局部数据更新 tabs
  169. partialRenewal(init = false) {
  170. let model = this.data.tabsList[this.data.tabsActive].model;
  171. if (model) {
  172. let Component = this.selectComponent(model),
  173. {
  174. total,
  175. pageNumber,
  176. pageTotal
  177. } = Component.data.content,
  178. id = this.data.detail.sa_orderid;
  179. if (model == '#Product') id = {
  180. id: this.data.detail.sa_orderid,
  181. toolcount: this.data.detail.toolcount || ""
  182. };
  183. if (total == null || init) {
  184. Component.getList(id, init);
  185. } else if (pageNumber < pageTotal) {
  186. Component.getList(id, false);
  187. }
  188. }
  189. },
  190. onReachBottom() {
  191. this.partialRenewal();
  192. },
  193. /* 更新数据 */
  194. changeDetail() {
  195. let data = this.data.detail,
  196. content = {
  197. "sa_orderid": data.sa_orderid,
  198. "sys_enterpriseid": data.sys_enterpriseid, //订货企业id
  199. "sa_accountclassid": data.accountclass.sa_accountclassid || 0, //营销账户类型ID
  200. "sa_brandid": data.sa_brandid, //品牌ID
  201. "sys_enterprise_financeid": data.sys_enterprise_financeid || 0, //合作企业财务信息ID(开票信息)
  202. "sa_logiscompid": data.logiscomp.sa_logiscompid, //物流公司档案ID
  203. "rec_contactsid": data.rec_contactsid || 0, //合作企业联系人表ID(收货信息)
  204. "type": data.type, //订单类型
  205. "typemx": data.typemx, // 明细分类,可选
  206. "remarks": data.remarks,
  207. "saler_hrid": data.saler_hrid, //销售人员hrid,业务员hrid
  208. "tradefield": data.tradefield, //必选
  209. "pay_enterpriseid": data.pay_enterpriseid, //结算单位
  210. "rebate_userate": data.accountclass.rebate_userate, //返利金使用比例
  211. "rebate_used": data.rebate_used, //默认0,是否使用返利金
  212. "billdate": data.billdate, //单据日期,默认创建日期
  213. };
  214. return new Promise((resolve, reject) => {
  215. _Http.basic({
  216. "id": 20230116092702,
  217. content
  218. }).then(res => {
  219. console.log("修改订单数据", res);
  220. if (res.msg != '成功') wx.showToast({
  221. title: res.msg,
  222. icon: "none"
  223. });
  224. resolve(res)
  225. })
  226. })
  227. },
  228. /* 修改订单备注 */
  229. changeRemarks(e) {
  230. let value = e.detail.value,
  231. remarks = this.data.detail.remarks,
  232. that = this;
  233. if (value == this.data.detail.remarks) return;
  234. wx.showModal({
  235. title: '提示',
  236. content: '是否确定修改订单备注?',
  237. complete: async (res) => {
  238. if (res.cancel) that.setData({
  239. "detail.remarks": remarks
  240. })
  241. if (res.confirm) {
  242. this.data.detail.remarks = value;
  243. let res = await that.changeDetail();
  244. that.setData({
  245. "detail.remarks": res.msg == '成功' ? value : remarks
  246. })
  247. }
  248. }
  249. })
  250. },
  251. /* 删除订单 */
  252. deleteItem() {
  253. let that = this;
  254. wx.showModal({
  255. title: '提示',
  256. content: '是否确认删除订单?',
  257. complete: (res) => {
  258. if (res.confirm) _Http.basic({
  259. "id": 20230116100002,
  260. "content": {
  261. "sa_orderids": [
  262. that.data.sa_orderid
  263. ]
  264. }
  265. }).then(s => {
  266. console.log("删除订单", s)
  267. if (s.msg != '成功') return wx.showToast({
  268. title: s.msg,
  269. icon: "none"
  270. });
  271. wx.showToast({
  272. title: `成功删除${that.data.detail.sonum}订单`,
  273. icon: "none"
  274. });
  275. setTimeout(() => {
  276. /* let page = getCurrentPages().find(v => v.__route__ == 'packageA/orderForm/index');
  277. if (page) page.setData({
  278. list: page.data.list.filter(v => v.sa_orderid != that.data.sa_orderid),
  279. "content.total": page.data.content.total - 1,
  280. amount: (page.data.amount - that.data.detail.amount).toFixed(2)
  281. }); */
  282. wx.navigateBack()
  283. }, 500)
  284. })
  285. }
  286. })
  287. },
  288. /* 提交订单 */
  289. submit() {
  290. let that = this;
  291. wx.showModal({
  292. title: '提示',
  293. content: '是否确认提交订单?',
  294. complete: (res) => {
  295. if (res.confirm) _Http.basic({
  296. "id": 20230114160002,
  297. "content": {
  298. sa_orderid: that.data.sa_orderid
  299. },
  300. }).then(s => {
  301. console.log("提交订单", s)
  302. wx.showToast({
  303. title: s.msg != '成功' ? s.msg : '提交成功',
  304. icon: "none"
  305. });
  306. if (s.msg == '成功') that.setData({
  307. "detail.status": "提交"
  308. })
  309. })
  310. }
  311. })
  312. },
  313. /* 确认订单交期 */
  314. notarize() {
  315. let that = this;
  316. wx.showModal({
  317. title: '提示',
  318. content: '是否确认交期?',
  319. complete: (res) => {
  320. if (res.confirm) _Http.basic({
  321. "id": 20230129154102,
  322. "content": {
  323. sa_orderid: that.data.sa_orderid
  324. },
  325. }).then(s => {
  326. console.log("确认交期", s)
  327. wx.showToast({
  328. title: s.msg != '成功' ? s.msg : '确认成功',
  329. icon: "none"
  330. });
  331. if (s.msg == '成功') {
  332. that.setData({
  333. "detail.status": "交期确认"
  334. })
  335. }
  336. })
  337. }
  338. })
  339. },
  340. /* 判断是否可以编辑 */
  341. isEdit() {
  342. if (this.data.detail.status != '新建') wx.showToast({
  343. title: '当前订单状态不可设置!',
  344. icon: "none"
  345. });
  346. return this.data.detail.status != '新建';
  347. },
  348. /* 设置项目订单品牌领域 */
  349. setBraned() {
  350. wx.navigateTo({
  351. url: './modules/setBrand/index?id=' + this.data.sa_orderid,
  352. })
  353. },
  354. onUnload() {
  355. let page = getCurrentPages().find(v => v.__route__ == 'packageA/borrow/index');
  356. let content = JSON.parse(JSON.stringify(page.data.content));
  357. content.pageNumber = 1;
  358. content.pageSize = page.data.list.length <= 20 ? page.data.list.length + 3 : page.data.list.length;
  359. _Http.basic({
  360. "id": 20230114105002,
  361. content
  362. }).then(res => {
  363. console.log("更新借用单", res)
  364. page.setData({
  365. list: res.data,
  366. "content.total": res.total,
  367. })
  368. /* amount: res.tips.amount || 0 */
  369. })
  370. },
  371. })