detail.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  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. "rec_contactsid": data.rec_contactsid || 0, //合作企业联系人表ID(收货信息)
  203. "type": data.type, //订单类型
  204. "typemx": data.typemx, // 明细分类,可选
  205. "remarks": data.remarks,
  206. sa_contractid: data.sa_contractid,
  207. "saler_hrid": data.saler_hrid, //销售人员hrid,业务员hrid
  208. "tradefield": data.tradefield, //必选
  209. "pay_enterpriseid": data.pay_enterpriseid, //结算单位
  210. };
  211. return new Promise((resolve, reject) => {
  212. _Http.basic({
  213. "id": 20230116092702,
  214. content
  215. }).then(res => {
  216. console.log("修改订单数据", res);
  217. if (res.msg != '成功') wx.showToast({
  218. title: res.msg,
  219. icon: "none"
  220. });
  221. resolve(res)
  222. })
  223. })
  224. },
  225. /* 修改订单备注 */
  226. changeRemarks(e) {
  227. let value = e.detail.value,
  228. remarks = this.data.detail.remarks,
  229. that = this;
  230. if (value == this.data.detail.remarks) return;
  231. wx.showModal({
  232. title: '提示',
  233. content: '是否确定修改订单备注?',
  234. complete: async (res) => {
  235. if (res.cancel) that.setData({
  236. "detail.remarks": remarks
  237. })
  238. if (res.confirm) {
  239. this.data.detail.remarks = value;
  240. let res = await that.changeDetail();
  241. that.setData({
  242. "detail.remarks": res.msg == '成功' ? value : remarks
  243. })
  244. }
  245. }
  246. })
  247. },
  248. /* 删除订单 */
  249. deleteItem() {
  250. let that = this;
  251. wx.showModal({
  252. title: '提示',
  253. content: '是否确认删除订单?',
  254. complete: (res) => {
  255. if (res.confirm) _Http.basic({
  256. "id": 20230116100002,
  257. "content": {
  258. "sa_orderids": [
  259. that.data.sa_orderid
  260. ]
  261. }
  262. }).then(s => {
  263. console.log("删除订单", s)
  264. if (s.msg != '成功') return wx.showToast({
  265. title: s.msg,
  266. icon: "none"
  267. });
  268. wx.showToast({
  269. title: `成功删除${that.data.detail.sonum}订单`,
  270. icon: "none"
  271. });
  272. setTimeout(() => {
  273. /* let page = getCurrentPages().find(v => v.__route__ == 'packageA/orderForm/index');
  274. if (page) page.setData({
  275. list: page.data.list.filter(v => v.sa_orderid != that.data.sa_orderid),
  276. "content.total": page.data.content.total - 1,
  277. amount: (page.data.amount - that.data.detail.amount).toFixed(2)
  278. }); */
  279. wx.navigateBack()
  280. }, 500)
  281. })
  282. }
  283. })
  284. },
  285. /* 提交订单 */
  286. submit() {
  287. let that = this;
  288. wx.showModal({
  289. title: '提示',
  290. content: '是否确认提交订单?',
  291. complete: (res) => {
  292. if (res.confirm) _Http.basic({
  293. "id": 20230114160002,
  294. "content": {
  295. sa_orderid: that.data.sa_orderid
  296. },
  297. }).then(s => {
  298. console.log("提交订单", s)
  299. wx.showToast({
  300. title: s.msg != '成功' ? s.msg : '提交成功',
  301. icon: "none"
  302. });
  303. if (s.msg == '成功') that.setData({
  304. "detail.status": "提交"
  305. })
  306. })
  307. }
  308. })
  309. },
  310. /* 确认订单交期 */
  311. notarize() {
  312. let that = this;
  313. wx.showModal({
  314. title: '提示',
  315. content: '是否确认交期?',
  316. complete: (res) => {
  317. if (res.confirm) _Http.basic({
  318. "id": 20230129154102,
  319. "content": {
  320. sa_orderid: that.data.sa_orderid
  321. },
  322. }).then(s => {
  323. console.log("确认交期", s)
  324. wx.showToast({
  325. title: s.msg != '成功' ? s.msg : '确认成功',
  326. icon: "none"
  327. });
  328. if (s.msg == '成功') {
  329. that.setData({
  330. "detail.status": "交期确认"
  331. })
  332. }
  333. })
  334. }
  335. })
  336. },
  337. /* 判断是否可以编辑 */
  338. isEdit() {
  339. if (this.data.detail.status != '新建') wx.showToast({
  340. title: '当前订单状态不可设置!',
  341. icon: "none"
  342. });
  343. return this.data.detail.status != '新建';
  344. },
  345. /* 设置项目订单品牌领域 */
  346. setBraned() {
  347. wx.navigateTo({
  348. url: './modules/setBrand/index?id=' + this.data.sa_orderid,
  349. })
  350. },
  351. onUnload() {
  352. let page = getCurrentPages().find(v => v.__route__ == 'packageA/borrow/index');
  353. let content = JSON.parse(JSON.stringify(page.data.content));
  354. content.pageNumber = 1;
  355. content.pageSize = (page.data.content.pageNumber - 1) * page.data.content.pageSize;
  356. _Http.basic({
  357. "id": 20230114105002,
  358. content
  359. }).then(res => {
  360. console.log("更新借用单", res)
  361. page.setData({
  362. list: res.data,
  363. "content.total": res.total,
  364. })
  365. /* amount: res.tips.amount || 0 */
  366. })
  367. },
  368. })