detail.js 30 KB

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