detail.js 30 KB

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