detail.js 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805
  1. const _Http = getApp().globalData.http;
  2. let figure = null; //免运费额度
  3. import currency from "../../utils/currency";
  4. Page({
  5. data: {
  6. loading: true,
  7. sa_orderid: null,
  8. tabsActive: 0,
  9. tabsList: [{
  10. label: "产品明细",
  11. icon: "icon-tabchanpin",
  12. model: "#Product"
  13. }, {
  14. label: "附件",
  15. icon: "icon-tabfujian1",
  16. model: "#Yl_Attachment"
  17. }, {
  18. label: "订单进度",
  19. icon: "icon-tabcaozuojilu1",
  20. model: "#Progress"
  21. }, {
  22. label: "发票",
  23. icon: "icon-tabkaipiaoxinxi",
  24. model: "#Invoice"
  25. }],
  26. saletypeList: null,
  27. showMYModel: false,
  28. reminddays: 0,
  29. },
  30. onLoad(options) {
  31. const authOptions = wx.getStorageSync('auth').worderform.options;
  32. const checkPermission = (permission) => authOptions.includes(permission);
  33. this.setData({
  34. sa_orderid: options.id,
  35. order_rebate_used: wx.getStorageSync('siteP').order_rebate_used,
  36. userrole: wx.getStorageSync('userrole'),
  37. isSubmit: checkPermission('submit'),
  38. isDelete: checkPermission("delete"),
  39. fixATime: checkPermission("fixATime"),
  40. isRecall: checkPermission("recall"),
  41. isSure: checkPermission("sure"),
  42. });
  43. this.getDetail(true);
  44. //销售分类
  45. _Http.basic({
  46. "classname": "sysmanage.develop.optiontype.optiontype",
  47. "method": "optiontypeselect",
  48. "content": {
  49. pageSize: "999",
  50. "typename": "saletype",
  51. "parameter": {
  52. "siteid": wx.getStorageSync('siteP').siteid
  53. }
  54. }
  55. }, false).then(res => {
  56. console.log("销售分类", res)
  57. if (res.code != '1') return wx.showToast({
  58. title: res.msg,
  59. icon: "none"
  60. })
  61. this.setData({
  62. saletypeList: res.data.map(v => {
  63. v.show = v.value + '-' + v.remarks
  64. return v
  65. })
  66. })
  67. })
  68. getApp().globalData.Language.getLanguagePackage(this, 'E-订单');
  69. },
  70. /* 设置回签单 */
  71. changeSignbackstatus(e) {
  72. if (this.isEdit()) return this.setData({
  73. "detail.signbackstatus": this.data.detail.signbackstatus
  74. })
  75. this.data.detail.signbackstatus = e.detail;
  76. this.changeDetail();
  77. },
  78. /* 获取详情 */
  79. getDetail(init = false, show = true) {
  80. _Http.basic({
  81. "id": 20221108151302,
  82. "content": {
  83. nocache: true,
  84. "sa_orderid": this.data.sa_orderid
  85. }
  86. }, show).then(res => {
  87. console.log("订单详情", res)
  88. if (res.code != '1') return wx.showToast({
  89. title: res.msg,
  90. icon: "none"
  91. });
  92. let CNY = value => currency(value, {
  93. symbol: "¥",
  94. precision: 2
  95. }).format();
  96. let account = {
  97. name: "",
  98. text: ""
  99. };
  100. let accountclass = res.data.accountclass;
  101. if (accountclass.accountname) {
  102. account.name = accountclass.accountname
  103. account.text = `\n(${getApp().globalData.Language.getMapText('余额')}:${CNY(accountclass.balance)},${getApp().globalData.Language.getMapText('信用额度')}:${CNY(accountclass.creditquota)})`
  104. }
  105. this.setData({
  106. detail: res.data,
  107. loading: false,
  108. defaultamount: CNY(res.data.defaultamount),
  109. account,
  110. reminddays: res.data.contract_reminddays || 7
  111. });
  112. if (init) {
  113. this.partialRenewal(true)
  114. let content = wx.getStorageSync('userrole') == '业务员' ? {
  115. sys_enterpriseid: this.data.detail.sys_enterpriseid
  116. } : {};
  117. //业务员根据指定经销商的免运费
  118. _Http.basic({
  119. "id": 20220920084001,
  120. content
  121. }, false).then(res => {
  122. console.log("查询企业档案获取企业免邮额度", res)
  123. if (res.code != '1') return wx.showToast({
  124. title: res.msg,
  125. icon: "none"
  126. })
  127. figure = res.data.freefreightamount;
  128. this.setLogisticsMsg();
  129. })
  130. } else {
  131. this.setLogisticsMsg();
  132. }
  133. })
  134. },
  135. /* 免运费信息 */
  136. setLogisticsMsg() {
  137. let logistics = null;
  138. if (figure == -1) {
  139. logistics = '到付'
  140. } else if (figure == 0) {
  141. logistics = '预付'
  142. } else {
  143. let defaultamount = this.data.detail.defaultamount;
  144. logistics = defaultamount >= figure ? '免运费' : (getApp().globalData.Language.getMapText('差') + currency(figure).subtract(defaultamount).value + getApp().globalData.Language.getMapText('元免运费'));
  145. }
  146. this.setData({
  147. logistics
  148. })
  149. },
  150. /* 选择销售分类 */
  151. selectSaletype(e) {
  152. if (this.isEdit()) return;
  153. if (this.data.detail.type == '项目订单') return;
  154. },
  155. /* 设置销售分类 */
  156. setSaletype(e) {
  157. let {
  158. value,
  159. remarks
  160. } = this.data.saletypeList[e.detail.value];
  161. if (value == this.data.detail.saletype) return;
  162. this.setData({
  163. "detail.saletype": value,
  164. "detail.saletyperemarks": remarks
  165. })
  166. this.changeDetail();
  167. },
  168. /* 选择结算人 */
  169. selectAgent() {
  170. if (this.isEdit()) return;
  171. if (this.data.detail.type == '项目订单') return;
  172. wx.navigateTo({
  173. url: `/select/agent/index?params=${JSON.stringify({
  174. "id":20230104103702,
  175. "content": {
  176. "pageNumber": 1,
  177. "pageTotal": 1,
  178. "pageSize": 20,
  179. "where": {
  180. "condition": "",
  181. },
  182. }
  183. })}&radio=true`,
  184. });
  185. getApp().globalData.handleSelect = this.setAgeant.bind(this);
  186. },
  187. /* 设置结算人 */
  188. setAgeant({
  189. item
  190. }) {
  191. let that = this;
  192. console.log("选择经销商", item)
  193. wx.showModal({
  194. cancelText: getApp().globalData.Language.getMapText('取消'),
  195. confirmText: getApp().globalData.Language.getMapText('确定'),
  196. title: getApp().globalData.Language.getMapText('提示'),
  197. content: getApp().globalData.Language.modeBoxPrompts([{
  198. t: 1,
  199. v: '是否确认设置',
  200. r: " "
  201. }, {
  202. v: item.enterprisename,
  203. f: "“",
  204. r: "”"
  205. }, {
  206. t: 1,
  207. v: '为结算人',
  208. r: "?"
  209. }]),
  210. complete: (res) => {
  211. if (res.confirm) {
  212. let pay_enterpriseid = that.data.detail.pay_enterpriseid,
  213. sys_enterprise_financeid = that.data.detail.sys_enterprise_financeid,
  214. sa_accountclassid = that.data.detail.accountclass.sa_accountclassid;
  215. that.setData({
  216. "detail.pay_enterpriseid": item.sys_enterpriseid,
  217. "detail.sys_enterprise_financeid": item.finance[0] ? item.finance[0].sys_enterprise_financeid : 0,
  218. "detail.accountclass.sa_accountclassid": item.accounts[0] ? item.accounts[0].sa_accountclassid : 0,
  219. });
  220. that.changeDetail().then(s => {
  221. if (s.code == '1') {
  222. wx.showToast({
  223. title: getApp().globalData.Language.getMapText('设置成功'),
  224. icon: "none"
  225. });
  226. setTimeout(() => {
  227. wx.navigateBack();
  228. that.getDetail();
  229. }, 500)
  230. } else {
  231. that.setData({
  232. "detail.pay_enterpriseid": pay_enterpriseid,
  233. "detail.sys_enterprise_financeid": sys_enterprise_financeid,
  234. "detail.sa_accountclassid": sa_accountclassid
  235. });
  236. }
  237. })
  238. }
  239. }
  240. })
  241. },
  242. /* 选择收货人 */
  243. selectConsignee() {
  244. if (this.isEdit()) return;
  245. wx.navigateTo({
  246. url: `/select/address/index?params=${JSON.stringify({
  247. "id":20221009155803,
  248. "content": {
  249. nocache:true,
  250. sys_enterpriseid:this.data.detail.sys_enterpriseid,
  251. "pageNumber": 1,
  252. "pageTotal": 1,
  253. "pageSize": 20,
  254. "where": {
  255. "condition": "",
  256. workaddress:1
  257. },
  258. }
  259. })}&radio=true`,
  260. });
  261. getApp().globalData.handleSelect = this.setConsignee.bind(this);
  262. },
  263. /* 设置收货人 */
  264. setConsignee({
  265. item
  266. }) {
  267. let that = this;
  268. console.log("设置收货人", item)
  269. wx.showModal({
  270. cancelText: getApp().globalData.Language.getMapText('取消'),
  271. confirmText: getApp().globalData.Language.getMapText('确定'),
  272. title: getApp().globalData.Language.getMapText('提示'),
  273. content: getApp().globalData.Language.modeBoxPrompts([{
  274. t: 1,
  275. v: '是否确认设置',
  276. r: " "
  277. }, {
  278. v: item.name,
  279. f: "“",
  280. r: "”"
  281. }, {
  282. t: 1,
  283. v: '为收货人',
  284. r: "?"
  285. }]),
  286. complete: (res) => {
  287. if (res.confirm) {
  288. let rec_contactsid = that.data.detail.rec_contactsid;
  289. that.setData({
  290. "detail.rec_contactsid": item.contactsid
  291. });
  292. that.changeDetail().then(s => {
  293. if (s.code == '1') {
  294. wx.showToast({
  295. title: getApp().globalData.Language.getMapText('设置成功'),
  296. icon: "none"
  297. });
  298. setTimeout(() => {
  299. wx.navigateBack();
  300. that.getDetail();
  301. }, 500)
  302. } else {
  303. that.setData({
  304. "detail.rec_contactsid": rec_contactsid
  305. });
  306. }
  307. })
  308. }
  309. }
  310. })
  311. },
  312. /* 选择财务信息 */
  313. selectFinance() {
  314. if (this.isEdit()) return;
  315. wx.navigateTo({
  316. url: `/select/finance/index?params=${JSON.stringify({
  317. "id":20221013160602,
  318. "content": {
  319. nocache:true,
  320. sys_enterpriseid:this.data.detail.sys_enterpriseid,
  321. "pageNumber": 1,
  322. "pageTotal": 1,
  323. "pageSize": 20,
  324. "where": {
  325. "condition": "",
  326. },
  327. }
  328. })}&radio=true`,
  329. });
  330. getApp().globalData.handleSelect = this.setFinance.bind(this);
  331. },
  332. /* 设置财务信息 */
  333. setFinance({
  334. item
  335. }) {
  336. let that = this;
  337. console.log("设置财务信息", item)
  338. wx.showModal({
  339. cancelText: getApp().globalData.Language.getMapText('取消'),
  340. confirmText: getApp().globalData.Language.getMapText('确定'),
  341. title: getApp().globalData.Language.getMapText('提示'),
  342. content: getApp().globalData.Language.modeBoxPrompts([{
  343. t: 1,
  344. v: '是否确认设置',
  345. r: " "
  346. }, {
  347. v: item.enterprisename,
  348. f: "“",
  349. r: "”"
  350. }, {
  351. t: 1,
  352. v: '为开票单位',
  353. r: "?"
  354. }]),
  355. complete: (res) => {
  356. if (res.confirm) {
  357. let sys_enterprise_financeid = that.data.detail.sys_enterprise_financeid;
  358. that.setData({
  359. "detail.sys_enterprise_financeid": item.sys_enterprise_financeid
  360. });
  361. that.changeDetail().then(s => {
  362. if (s.code == '1') {
  363. wx.showToast({
  364. title: getApp().globalData.Language.getMapText('设置成功'),
  365. icon: "none"
  366. });
  367. setTimeout(() => {
  368. wx.navigateBack();
  369. that.getDetail();
  370. }, 500)
  371. } else {
  372. that.setData({
  373. "detail.sys_enterprise_financeid": sys_enterprise_financeid
  374. });
  375. }
  376. })
  377. }
  378. }
  379. })
  380. },
  381. //tabs 切换
  382. tabsChange({
  383. detail
  384. }) {
  385. this.setData({
  386. tabsActive: detail
  387. });
  388. this.partialRenewal();
  389. },
  390. //局部数据更新 tabs
  391. partialRenewal(init = false) {
  392. let model = this.data.tabsList[this.data.tabsActive].model;
  393. if (model) {
  394. let Component = this.selectComponent(model),
  395. {
  396. total,
  397. pageNumber,
  398. pageTotal
  399. } = Component.data.content,
  400. id = this.data.detail.sa_orderid;
  401. if (total == null || init) {
  402. Component.getList(id, init);
  403. } else if (pageNumber <= pageTotal) {
  404. Component.getList(id, false);
  405. }
  406. }
  407. },
  408. onReachBottom() {
  409. this.partialRenewal();
  410. },
  411. /* 更新数据 */
  412. changeDetail() {
  413. let data = this.data.detail,
  414. content = {
  415. "sa_orderid": data.sa_orderid,
  416. "sys_enterpriseid": data.sys_enterpriseid, //订货企业id
  417. "sa_accountclassid": data.accountclass.sa_accountclassid || 0, //营销账户类型ID
  418. projectnote: data.projectnote || "", //项目备注
  419. "sa_brandid": data.sa_brandid, //品牌ID
  420. "sys_enterprise_financeid": data.sys_enterprise_financeid || 0, //合作企业财务信息ID(开票信息)
  421. //"sa_logiscompid": data.logiscomp.sa_logiscompid || 0, 物流公司档案ID
  422. "rec_contactsid": data.rec_contactsid || 0, //合作企业联系人表ID(收货信息)
  423. "type": data.type, //订单类型
  424. "typemx": data.typemx, // 明细分类,可选
  425. "remarks": data.remarks,
  426. "saler_hrid": data.saler_hrid, //销售人员hrid,业务员hrid
  427. "tradefield": data.tradefield, //必选
  428. "pay_enterpriseid": data.pay_enterpriseid, //结算单位
  429. "rebate_userate": data.accountclass.rebate_userate, //返利金使用比例
  430. signbackstatus: data.signbackstatus,
  431. saletype: data.saletype
  432. };
  433. if (content.type = '项目订单') {
  434. content.sa_contractid = data.sa_contractid,
  435. content.sa_projectid = data.sa_projectid;
  436. }
  437. return new Promise((resolve, reject) => {
  438. _Http.basic({
  439. "id": 20221108111402,
  440. content
  441. }).then(res => {
  442. console.log("修改订单数据", res);
  443. if (res.code != '1') wx.showToast({
  444. title: res.msg,
  445. icon: "none"
  446. });
  447. resolve(res)
  448. })
  449. })
  450. },
  451. /* 修改订单备注 */
  452. changeRemarks(e) {
  453. let name = e.currentTarget.dataset.name,
  454. value = e.detail.value,
  455. remarks = this.data.detail[name],
  456. that = this;
  457. if (value == remarks) return;
  458. wx.showModal({
  459. cancelText: getApp().globalData.Language.getMapText('取消'),
  460. confirmText: getApp().globalData.Language.getMapText('确定'),
  461. title: getApp().globalData.Language.getMapText('提示'),
  462. content: getApp().globalData.Language.modeBoxPrompts([{
  463. t: 1,
  464. v: '是否确定修改',
  465. r: " "
  466. }, {
  467. t: 1,
  468. v: name == 'remarks' ? '订单' : '项目',
  469. f: "“",
  470. r: "”"
  471. }, {
  472. t: 1,
  473. v: '备注',
  474. r: "?"
  475. }]),
  476. complete: async (res) => {
  477. if (res.cancel) that.setData({
  478. [`detail[${name}]`]: remarks
  479. })
  480. if (res.confirm) {
  481. this.data.detail[name] = value;
  482. let res = await that.changeDetail();
  483. that.setData({
  484. [`detail${name}`]: res.code == '1' ? value : remarks
  485. })
  486. }
  487. }
  488. })
  489. },
  490. /* 设置是否使用返利金 */
  491. changeRebateUsed() {
  492. if (this.isEdit()) return this.setData({
  493. detail: this.data.detail
  494. })
  495. let amount = (this.data.detail.order_rebate_userate * this.data.detail.defaultamount).toFixed(2); //最大可用金额
  496. let rebatebalance = this.data.detail.rebatebalance; //返利金账户余额
  497. _Http.basic({
  498. "id": 20230218225002,
  499. "content": {
  500. "sa_orderid": this.data.sa_orderid, //订单金额
  501. "isused": this.data.detail.rebate_used == 1 ? 0 : 1, //是否使用
  502. "rebateamount": rebatebalance > amount ? amount : rebatebalance //返利金使用金额
  503. }
  504. }, false).then(res => {
  505. console.log('设置启用返利金', res)
  506. if (res.code != '1') {
  507. wx.showToast({
  508. title: res.msg,
  509. icon: "none"
  510. });
  511. this.setData({
  512. "detail.rebate_used": this.data.detail.rebate_used
  513. })
  514. return;
  515. }
  516. this.getDetail(true, false)
  517. })
  518. },
  519. /* 修改返利金 */
  520. setRebate_amount(e = 0) {
  521. let value = e.detail.value;
  522. let rebatebalance = this.data.detail.rebatebalance; //返利金账户余额
  523. value = value > rebatebalance ? rebatebalance : value;
  524. let amount = (this.data.detail.order_rebate_userate * this.data.detail.defaultamount).toFixed(2); //最大可用金额
  525. _Http.basic({
  526. "id": 20230218225002,
  527. "content": {
  528. "sa_orderid": this.data.sa_orderid, //订单金额
  529. "isused": 1, //是否使用
  530. "rebateamount": value > amount ? amount : value
  531. }
  532. }, false).then(res => {
  533. console.log('设置返利金', res)
  534. if (res.code != '1') {
  535. wx.showToast({
  536. title: res.msg,
  537. icon: "none",
  538. mask: true
  539. });
  540. this.setData({
  541. "detail.accountclass.rebate_amount": this.data.detail.accountclass.rebate_amount
  542. })
  543. } else {
  544. this.setData({
  545. "detail.accountclass.rebate_amount": value
  546. })
  547. if (value > amount || amount == 0) getApp().globalData.Language.showToast(
  548. [{
  549. t: 1,
  550. v: '返利金最大可使用',
  551. r: " "
  552. }, {
  553. v: amount,
  554. f: "“",
  555. r: "”"
  556. }, {
  557. t: 1,
  558. v: '元'
  559. }])
  560. this.getDetail(true, false)
  561. }
  562. })
  563. },
  564. /* 删除订单 */
  565. deleteItem() {
  566. let that = this;
  567. wx.showModal({
  568. cancelText: getApp().globalData.Language.getMapText('取消'),
  569. confirmText: getApp().globalData.Language.getMapText('确定'),
  570. title: getApp().globalData.Language.getMapText('提示'),
  571. content: getApp().globalData.Language.getMapText('是否确认删除订单') + '?',
  572. complete: (res) => {
  573. if (res.confirm) _Http.basic({
  574. "id": 20221108152102,
  575. "content": {
  576. "sa_orderids": [
  577. that.data.sa_orderid
  578. ]
  579. }
  580. }).then(s => {
  581. console.log("删除订单", s)
  582. if (s.code != '1') return wx.showToast({
  583. title: s.msg,
  584. icon: "none"
  585. });
  586. getApp().globalData.Language.showToast('删除成功')
  587. setTimeout(() => {
  588. /* let page = getCurrentPages().find(v => v.__route__ == 'packageA/orderForm/index');
  589. if (page) page.setData({
  590. list: page.data.list.filter(v => v.sa_orderid != that.data.sa_orderid),
  591. "content.total": page.data.content.total - 1,
  592. amount: (page.data.amount - that.data.detail.amount).toFixed(2)
  593. }); */
  594. wx.navigateBack()
  595. }, 500)
  596. })
  597. }
  598. })
  599. },
  600. /* 提交订单 */
  601. submit() {
  602. let that = this;
  603. if (['HY', 'YOSTEST1'].includes(wx.getStorageSync('userMsg').siteid)) {
  604. this.setData({
  605. showMYModel: true
  606. })
  607. } else {
  608. wx.showModal({
  609. cancelText: getApp().globalData.Language.getMapText('取消'),
  610. confirmText: getApp().globalData.Language.getMapText('确定'),
  611. title: getApp().globalData.Language.getMapText('提示'),
  612. content: getApp().globalData.Language.getMapText('是否确认提交订单') + '?',
  613. complete: (res) => {
  614. if (res.confirm) that.handleSubmit();
  615. }
  616. })
  617. }
  618. },
  619. handleSubmit(reminddays = 0) {
  620. _Http.basic({
  621. "id": 20221108153402,
  622. "content": {
  623. sa_orderid: this.data.sa_orderid,
  624. reminddays
  625. },
  626. }).then(s => {
  627. console.log("提交订单", s)
  628. wx.showToast({
  629. title: s.code != '1' ? s.msg : getApp().globalData.Language.getMapText('提交成功'),
  630. icon: "none"
  631. });
  632. if (s.code == '1') this.getDetail(true, false)
  633. })
  634. },
  635. confirmSubmit() {
  636. let that = this;
  637. wx.showModal({
  638. cancelText: getApp().globalData.Language.getMapText('取消'),
  639. confirmText: getApp().globalData.Language.getMapText('确定'),
  640. title: getApp().globalData.Language.getMapText('提示'),
  641. content: getApp().globalData.Language.getMapText('是否确认提交订单') + '?',
  642. complete: (res) => {
  643. if (res.confirm) _Http.basic({
  644. "id": 2025011514120303,
  645. "content": {
  646. sa_orderid: that.data.sa_orderid,
  647. reminddays: that.data.reminddays
  648. },
  649. }).then(s => {
  650. console.log("确定提交订单", s)
  651. wx.showToast({
  652. title: s.code != '1' ? s.msg : getApp().globalData.Language.getMapText('提交成功'),
  653. icon: "none"
  654. });
  655. if (s.code == '1') that.getDetail(true, false)
  656. })
  657. }
  658. })
  659. },
  660. recall() {
  661. let that = this;
  662. wx.showModal({
  663. cancelText: getApp().globalData.Language.getMapText('取消'),
  664. confirmText: getApp().globalData.Language.getMapText('确定'),
  665. title: getApp().globalData.Language.getMapText('提示'),
  666. content: getApp().globalData.Language.getMapText('是否确认撤回订单') + '?',
  667. complete: (res) => {
  668. if (res.confirm) _Http.basic({
  669. "id": 20230301190202,
  670. "content": {
  671. sa_orderid: that.data.sa_orderid
  672. },
  673. }).then(s => {
  674. console.log("确定提交订单", s)
  675. wx.showToast({
  676. title: s.code != '1' ? s.msg : getApp().globalData.Language.getMapText('撤回成功'),
  677. icon: "none"
  678. });
  679. if (s.code == '1') that.getDetail(true, false)
  680. })
  681. }
  682. })
  683. },
  684. stepperSubmit() {
  685. this.handleSubmit(this.data.reminddays)
  686. },
  687. dialogOnClose() {
  688. this.setData({
  689. showMYModel: false
  690. })
  691. },
  692. stepperChange({
  693. detail
  694. }) {
  695. this.setData({
  696. reminddays: detail
  697. })
  698. },
  699. /* 确认订单交期 */
  700. notarize() {
  701. let that = this;
  702. wx.showModal({
  703. cancelText: getApp().globalData.Language.getMapText('取消'),
  704. confirmText: getApp().globalData.Language.getMapText('确定'),
  705. title: getApp().globalData.Language.getMapText('提示'),
  706. content: getApp().globalData.Language.getMapText('是否确认交期') + '?',
  707. complete: (res) => {
  708. if (res.confirm) _Http.basic({
  709. "id": 20221230094802,
  710. "content": {
  711. sa_orderid: that.data.sa_orderid
  712. },
  713. }).then(s => {
  714. console.log("确认交期", s)
  715. wx.showToast({
  716. title: s.code != '1' ? s.msg : getApp().globalData.Language.getMapText('确认成功'),
  717. icon: "none"
  718. });
  719. if (s.code == '1') {
  720. that.setData({
  721. "detail.status": "交期确认"
  722. })
  723. }
  724. })
  725. }
  726. })
  727. },
  728. /* 判断是否可以编辑 */
  729. isEdit() {
  730. if (this.data.detail.status != '新建') getApp().globalData.Language.showToast('当前订单状态不可设置!')
  731. if (this.data.detail.type == '特殊订单') getApp().globalData.Language.showToast('特殊订单不可设置!')
  732. return this.data.detail.status != '新建' || this.data.detail.type == '特殊订单';
  733. },
  734. /* 拷贝订单 */
  735. copyItem() {
  736. let item = this.data.detail;
  737. wx.showModal({
  738. cancelText: getApp().globalData.Language.getMapText('取消'),
  739. confirmText: getApp().globalData.Language.getMapText('确定'),
  740. title: getApp().globalData.Language.getMapText('提示'),
  741. content: getApp().globalData.Language.getMapText('是否确认复制') + `${getApp().globalData.Language.showToast(item.type)}“${item.sonum}”`,
  742. complete: (res) => {
  743. if (res.confirm) _Http.basic({
  744. "id": 20230102144502,
  745. "content": {
  746. "sa_orderid": item.sa_orderid
  747. }
  748. }).then(res => {
  749. console.log("复制订单", res)
  750. if (res.code != '1') return wx.showToast({
  751. title: res.msg,
  752. icon: "none"
  753. });
  754. wx.showModal({
  755. cancelText: getApp().globalData.Language.getMapText('取消'),
  756. confirmText: getApp().globalData.Language.getMapText('确定'),
  757. title: getApp().globalData.Language.getMapText('提示'),
  758. content: getApp().globalData.Language.showToast(item.type) + ' ' + getApp().globalData.Language.showToast('复制成功 是否立即前往'),
  759. complete: (s) => {
  760. if (s.confirm) wx.redirectTo({
  761. url: '/packageA/orderForm/detail?id=' + res.data.sa_orderid,
  762. })
  763. }
  764. })
  765. })
  766. }
  767. })
  768. },
  769. /* 设置项目订单品牌领域 */
  770. setBraned() {
  771. wx.navigateTo({
  772. url: './modules/setBrand/index?id=' + this.data.sa_orderid,
  773. })
  774. },
  775. onUnload() {
  776. let page = getCurrentPages().find(v => v.__route__ == 'packageA/orderForm/index');
  777. let content = JSON.parse(JSON.stringify(page.data.content));
  778. content.pageNumber = 1;
  779. content.pageSize = (page.data.content.pageNumber - 1) * page.data.content.pageSize;
  780. _Http.basic({
  781. "id": this.data.userrole == '业务员' ? 20221111145202 : 20221224180302,
  782. content
  783. }).then(res => {
  784. console.log("订单列表", res)
  785. if (res.code != '1') return;
  786. /* 格式化价格 */
  787. if (res.data.length != 0) res.data = res.data.map(v => {
  788. v.defaultamount = currency(v.defaultamount, {
  789. symbol: "¥",
  790. precision: 2
  791. }).format();
  792. return v
  793. })
  794. page.setData({
  795. list: res.data,
  796. "content.total": res.total,
  797. amount: currency(res.tips.amount, {
  798. symbol: "¥",
  799. precision: 2
  800. }).format()
  801. })
  802. })
  803. },
  804. })