detail.js 16 KB

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