detail.js 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806
  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.joint([{
  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.joint([{
  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. console.log(res)
  288. if (res.confirm) {
  289. let rec_contactsid = that.data.detail.rec_contactsid;
  290. that.setData({
  291. "detail.rec_contactsid": item.contactsid
  292. });
  293. that.changeDetail().then(s => {
  294. if (s.code == '1') {
  295. wx.showToast({
  296. title: getApp().globalData.Language.getMapText('设置成功'),
  297. icon: "none"
  298. });
  299. setTimeout(() => {
  300. wx.navigateBack();
  301. that.getDetail();
  302. }, 500)
  303. } else {
  304. that.setData({
  305. "detail.rec_contactsid": rec_contactsid
  306. });
  307. }
  308. })
  309. }
  310. }
  311. })
  312. },
  313. /* 选择财务信息 */
  314. selectFinance() {
  315. if (this.isEdit()) return;
  316. wx.navigateTo({
  317. url: `/select/finance/index?params=${JSON.stringify({
  318. "id":20221013160602,
  319. "content": {
  320. nocache:true,
  321. sys_enterpriseid:this.data.detail.sys_enterpriseid,
  322. "pageNumber": 1,
  323. "pageTotal": 1,
  324. "pageSize": 20,
  325. "where": {
  326. "condition": "",
  327. },
  328. }
  329. })}&radio=true`,
  330. });
  331. getApp().globalData.handleSelect = this.setFinance.bind(this);
  332. },
  333. /* 设置财务信息 */
  334. setFinance({
  335. item
  336. }) {
  337. let that = this;
  338. console.log("设置财务信息", item)
  339. wx.showModal({
  340. cancelText: getApp().globalData.Language.getMapText('取消'),
  341. confirmText: getApp().globalData.Language.getMapText('确定'),
  342. title: getApp().globalData.Language.getMapText('提示'),
  343. content: getApp().globalData.Language.joint([{
  344. t: 1,
  345. v: '是否确认设置',
  346. r: " "
  347. }, {
  348. v: item.enterprisename,
  349. f: "“",
  350. r: "”"
  351. }, {
  352. t: 1,
  353. v: '为开票单位',
  354. r: "?"
  355. }]),
  356. complete: (res) => {
  357. if (res.confirm) {
  358. let sys_enterprise_financeid = that.data.detail.sys_enterprise_financeid;
  359. that.setData({
  360. "detail.sys_enterprise_financeid": item.sys_enterprise_financeid
  361. });
  362. that.changeDetail().then(s => {
  363. if (s.code == '1') {
  364. wx.showToast({
  365. title: getApp().globalData.Language.getMapText('设置成功'),
  366. icon: "none"
  367. });
  368. setTimeout(() => {
  369. wx.navigateBack();
  370. that.getDetail();
  371. }, 500)
  372. } else {
  373. that.setData({
  374. "detail.sys_enterprise_financeid": sys_enterprise_financeid
  375. });
  376. }
  377. })
  378. }
  379. }
  380. })
  381. },
  382. //tabs 切换
  383. tabsChange({
  384. detail
  385. }) {
  386. this.setData({
  387. tabsActive: detail
  388. });
  389. this.partialRenewal();
  390. },
  391. //局部数据更新 tabs
  392. partialRenewal(init = false) {
  393. let model = this.data.tabsList[this.data.tabsActive].model;
  394. if (model) {
  395. let Component = this.selectComponent(model),
  396. {
  397. total,
  398. pageNumber,
  399. pageTotal
  400. } = Component.data.content,
  401. id = this.data.detail.sa_orderid;
  402. if (total == null || init) {
  403. Component.getList(id, init);
  404. } else if (pageNumber <= pageTotal) {
  405. Component.getList(id, false);
  406. }
  407. }
  408. },
  409. onReachBottom() {
  410. this.partialRenewal();
  411. },
  412. /* 更新数据 */
  413. changeDetail() {
  414. let data = this.data.detail,
  415. content = {
  416. "sa_orderid": data.sa_orderid,
  417. "sys_enterpriseid": data.sys_enterpriseid, //订货企业id
  418. "sa_accountclassid": data.accountclass.sa_accountclassid || 0, //营销账户类型ID
  419. projectnote: data.projectnote || "", //项目备注
  420. "sa_brandid": data.sa_brandid, //品牌ID
  421. "sys_enterprise_financeid": data.sys_enterprise_financeid || 0, //合作企业财务信息ID(开票信息)
  422. //"sa_logiscompid": data.logiscomp.sa_logiscompid || 0, 物流公司档案ID
  423. "rec_contactsid": data.rec_contactsid || 0, //合作企业联系人表ID(收货信息)
  424. "type": data.type, //订单类型
  425. "typemx": data.typemx, // 明细分类,可选
  426. "remarks": data.remarks,
  427. "saler_hrid": data.saler_hrid, //销售人员hrid,业务员hrid
  428. "tradefield": data.tradefield, //必选
  429. "pay_enterpriseid": data.pay_enterpriseid, //结算单位
  430. "rebate_userate": data.accountclass.rebate_userate, //返利金使用比例
  431. signbackstatus: data.signbackstatus,
  432. saletype: data.saletype
  433. };
  434. if (content.type = '项目订单') {
  435. content.sa_contractid = data.sa_contractid,
  436. content.sa_projectid = data.sa_projectid;
  437. }
  438. return new Promise((resolve, reject) => {
  439. _Http.basic({
  440. "id": 20221108111402,
  441. content
  442. }).then(res => {
  443. console.log("修改订单数据", res);
  444. if (res.code != '1') wx.showToast({
  445. title: res.msg,
  446. icon: "none"
  447. });
  448. resolve(res)
  449. })
  450. })
  451. },
  452. /* 修改订单备注 */
  453. changeRemarks(e) {
  454. let name = e.currentTarget.dataset.name,
  455. value = e.detail.value,
  456. remarks = this.data.detail[name],
  457. that = this;
  458. if (value == remarks) return;
  459. wx.showModal({
  460. cancelText: getApp().globalData.Language.getMapText('取消'),
  461. confirmText: getApp().globalData.Language.getMapText('确定'),
  462. title: getApp().globalData.Language.getMapText('提示'),
  463. content: getApp().globalData.Language.joint([{
  464. t: 1,
  465. v: '是否确定修改',
  466. r: " "
  467. }, {
  468. t: 1,
  469. v: name == 'remarks' ? '订单' : '项目',
  470. f: "“",
  471. r: "”"
  472. }, {
  473. t: 1,
  474. v: '备注',
  475. r: "?"
  476. }]),
  477. complete: async (res) => {
  478. if (res.cancel) that.setData({
  479. [`detail[${name}]`]: remarks
  480. })
  481. if (res.confirm) {
  482. this.data.detail[name] = value;
  483. let res = await that.changeDetail();
  484. that.setData({
  485. [`detail${name}`]: res.code == '1' ? value : remarks
  486. })
  487. }
  488. }
  489. })
  490. },
  491. /* 设置是否使用返利金 */
  492. changeRebateUsed() {
  493. if (this.isEdit()) return this.setData({
  494. detail: this.data.detail
  495. })
  496. let amount = (this.data.detail.order_rebate_userate * this.data.detail.defaultamount).toFixed(2); //最大可用金额
  497. let rebatebalance = this.data.detail.rebatebalance; //返利金账户余额
  498. _Http.basic({
  499. "id": 20230218225002,
  500. "content": {
  501. "sa_orderid": this.data.sa_orderid, //订单金额
  502. "isused": this.data.detail.rebate_used == 1 ? 0 : 1, //是否使用
  503. "rebateamount": rebatebalance > amount ? amount : rebatebalance //返利金使用金额
  504. }
  505. }, false).then(res => {
  506. console.log('设置启用返利金', res)
  507. if (res.code != '1') {
  508. wx.showToast({
  509. title: res.msg,
  510. icon: "none"
  511. });
  512. this.setData({
  513. "detail.rebate_used": this.data.detail.rebate_used
  514. })
  515. return;
  516. }
  517. this.getDetail(true, false)
  518. })
  519. },
  520. /* 修改返利金 */
  521. setRebate_amount(e = 0) {
  522. let value = e.detail.value;
  523. let rebatebalance = this.data.detail.rebatebalance; //返利金账户余额
  524. value = value > rebatebalance ? rebatebalance : value;
  525. let amount = (this.data.detail.order_rebate_userate * this.data.detail.defaultamount).toFixed(2); //最大可用金额
  526. _Http.basic({
  527. "id": 20230218225002,
  528. "content": {
  529. "sa_orderid": this.data.sa_orderid, //订单金额
  530. "isused": 1, //是否使用
  531. "rebateamount": value > amount ? amount : value
  532. }
  533. }, false).then(res => {
  534. console.log('设置返利金', res)
  535. if (res.code != '1') {
  536. wx.showToast({
  537. title: res.msg,
  538. icon: "none",
  539. mask: true
  540. });
  541. this.setData({
  542. "detail.accountclass.rebate_amount": this.data.detail.accountclass.rebate_amount
  543. })
  544. } else {
  545. this.setData({
  546. "detail.accountclass.rebate_amount": value
  547. })
  548. if (value > amount || amount == 0) getApp().globalData.Language.showToast(
  549. [{
  550. t: 1,
  551. v: '返利金最大可使用',
  552. r: " "
  553. }, {
  554. v: amount,
  555. f: "“",
  556. r: "”"
  557. }, {
  558. t: 1,
  559. v: '元'
  560. }])
  561. this.getDetail(true, false)
  562. }
  563. })
  564. },
  565. /* 删除订单 */
  566. deleteItem() {
  567. let that = this;
  568. wx.showModal({
  569. cancelText: getApp().globalData.Language.getMapText('取消'),
  570. confirmText: getApp().globalData.Language.getMapText('确定'),
  571. title: getApp().globalData.Language.getMapText('提示'),
  572. content: getApp().globalData.Language.getMapText('是否确认删除订单') + '?',
  573. complete: (res) => {
  574. if (res.confirm) _Http.basic({
  575. "id": 20221108152102,
  576. "content": {
  577. "sa_orderids": [
  578. that.data.sa_orderid
  579. ]
  580. }
  581. }).then(s => {
  582. console.log("删除订单", s)
  583. if (s.code != '1') return wx.showToast({
  584. title: s.msg,
  585. icon: "none"
  586. });
  587. getApp().globalData.Language.showToast('删除成功')
  588. setTimeout(() => {
  589. /* let page = getCurrentPages().find(v => v.__route__ == 'packageA/orderForm/index');
  590. if (page) page.setData({
  591. list: page.data.list.filter(v => v.sa_orderid != that.data.sa_orderid),
  592. "content.total": page.data.content.total - 1,
  593. amount: (page.data.amount - that.data.detail.amount).toFixed(2)
  594. }); */
  595. wx.navigateBack()
  596. }, 500)
  597. })
  598. }
  599. })
  600. },
  601. /* 提交订单 */
  602. submit() {
  603. let that = this;
  604. if (['HY', 'YOSTEST1'].includes(wx.getStorageSync('userMsg').siteid)) {
  605. this.setData({
  606. showMYModel: true
  607. })
  608. } else {
  609. wx.showModal({
  610. cancelText: getApp().globalData.Language.getMapText('取消'),
  611. confirmText: getApp().globalData.Language.getMapText('确定'),
  612. title: getApp().globalData.Language.getMapText('提示'),
  613. content: getApp().globalData.Language.getMapText('是否确认提交订单') + '?',
  614. complete: (res) => {
  615. if (res.confirm) that.handleSubmit();
  616. }
  617. })
  618. }
  619. },
  620. handleSubmit(reminddays = 0) {
  621. _Http.basic({
  622. "id": 20221108153402,
  623. "content": {
  624. sa_orderid: this.data.sa_orderid,
  625. reminddays
  626. },
  627. }).then(s => {
  628. console.log("提交订单", s)
  629. wx.showToast({
  630. title: s.code != '1' ? s.msg : getApp().globalData.Language.getMapText('提交成功'),
  631. icon: "none"
  632. });
  633. if (s.code == '1') this.getDetail(true, false)
  634. })
  635. },
  636. confirmSubmit() {
  637. let that = this;
  638. wx.showModal({
  639. cancelText: getApp().globalData.Language.getMapText('取消'),
  640. confirmText: getApp().globalData.Language.getMapText('确定'),
  641. title: getApp().globalData.Language.getMapText('提示'),
  642. content: getApp().globalData.Language.getMapText('是否确认提交订单') + '?',
  643. complete: (res) => {
  644. if (res.confirm) _Http.basic({
  645. "id": 2025011514120303,
  646. "content": {
  647. sa_orderid: that.data.sa_orderid,
  648. reminddays: that.data.reminddays
  649. },
  650. }).then(s => {
  651. console.log("确定提交订单", s)
  652. wx.showToast({
  653. title: s.code != '1' ? s.msg : getApp().globalData.Language.getMapText('提交成功'),
  654. icon: "none"
  655. });
  656. if (s.code == '1') that.getDetail(true, false)
  657. })
  658. }
  659. })
  660. },
  661. recall() {
  662. let that = this;
  663. wx.showModal({
  664. cancelText: getApp().globalData.Language.getMapText('取消'),
  665. confirmText: getApp().globalData.Language.getMapText('确定'),
  666. title: getApp().globalData.Language.getMapText('提示'),
  667. content: getApp().globalData.Language.getMapText('是否确认撤回订单') + '?',
  668. complete: (res) => {
  669. if (res.confirm) _Http.basic({
  670. "id": 20230301190202,
  671. "content": {
  672. sa_orderid: that.data.sa_orderid
  673. },
  674. }).then(s => {
  675. console.log("确定提交订单", s)
  676. wx.showToast({
  677. title: s.code != '1' ? s.msg : getApp().globalData.Language.getMapText('撤回成功'),
  678. icon: "none"
  679. });
  680. if (s.code == '1') that.getDetail(true, false)
  681. })
  682. }
  683. })
  684. },
  685. stepperSubmit() {
  686. this.handleSubmit(this.data.reminddays)
  687. },
  688. dialogOnClose() {
  689. this.setData({
  690. showMYModel: false
  691. })
  692. },
  693. stepperChange({
  694. detail
  695. }) {
  696. this.setData({
  697. reminddays: detail
  698. })
  699. },
  700. /* 确认订单交期 */
  701. notarize() {
  702. let that = this;
  703. wx.showModal({
  704. cancelText: getApp().globalData.Language.getMapText('取消'),
  705. confirmText: getApp().globalData.Language.getMapText('确定'),
  706. title: getApp().globalData.Language.getMapText('提示'),
  707. content: getApp().globalData.Language.getMapText('是否确认交期') + '?',
  708. complete: (res) => {
  709. if (res.confirm) _Http.basic({
  710. "id": 20221230094802,
  711. "content": {
  712. sa_orderid: that.data.sa_orderid
  713. },
  714. }).then(s => {
  715. console.log("确认交期", s)
  716. wx.showToast({
  717. title: s.code != '1' ? s.msg : getApp().globalData.Language.getMapText('确认成功'),
  718. icon: "none"
  719. });
  720. if (s.code == '1') {
  721. that.setData({
  722. "detail.status": "交期确认"
  723. })
  724. }
  725. })
  726. }
  727. })
  728. },
  729. /* 判断是否可以编辑 */
  730. isEdit() {
  731. if (this.data.detail.status != '新建') getApp().globalData.Language.showToast('当前订单状态不可设置!')
  732. if (this.data.detail.type == '特殊订单') getApp().globalData.Language.showToast('特殊订单不可设置!')
  733. return this.data.detail.status != '新建' || this.data.detail.type == '特殊订单';
  734. },
  735. /* 拷贝订单 */
  736. copyItem() {
  737. let item = this.data.detail;
  738. wx.showModal({
  739. cancelText: getApp().globalData.Language.getMapText('取消'),
  740. confirmText: getApp().globalData.Language.getMapText('确定'),
  741. title: getApp().globalData.Language.getMapText('提示'),
  742. content: getApp().globalData.Language.getMapText('是否确认复制') + `${getApp().globalData.Language.showToast(item.type)}“${item.sonum}”`,
  743. complete: (res) => {
  744. if (res.confirm) _Http.basic({
  745. "id": 20230102144502,
  746. "content": {
  747. "sa_orderid": item.sa_orderid
  748. }
  749. }).then(res => {
  750. console.log("复制订单", res)
  751. if (res.code != '1') return wx.showToast({
  752. title: res.msg,
  753. icon: "none"
  754. });
  755. wx.showModal({
  756. cancelText: getApp().globalData.Language.getMapText('取消'),
  757. confirmText: getApp().globalData.Language.getMapText('确定'),
  758. title: getApp().globalData.Language.getMapText('提示'),
  759. content: getApp().globalData.Language.showToast(item.type) + ' ' + getApp().globalData.Language.showToast('复制成功 是否立即前往'),
  760. complete: (s) => {
  761. if (s.confirm) wx.redirectTo({
  762. url: '/packageA/orderForm/detail?id=' + res.data.sa_orderid,
  763. })
  764. }
  765. })
  766. })
  767. }
  768. })
  769. },
  770. /* 设置项目订单品牌领域 */
  771. setBraned() {
  772. wx.navigateTo({
  773. url: './modules/setBrand/index?id=' + this.data.sa_orderid,
  774. })
  775. },
  776. onUnload() {
  777. let page = getCurrentPages().find(v => v.__route__ == 'packageA/orderForm/index');
  778. let content = JSON.parse(JSON.stringify(page.data.content));
  779. content.pageNumber = 1;
  780. content.pageSize = (page.data.content.pageNumber - 1) * page.data.content.pageSize;
  781. _Http.basic({
  782. "id": this.data.userrole == '业务员' ? 20221111145202 : 20221224180302,
  783. content
  784. }).then(res => {
  785. console.log("订单列表", res)
  786. if (res.code != '1') return;
  787. /* 格式化价格 */
  788. if (res.data.length != 0) res.data = res.data.map(v => {
  789. v.defaultamount = currency(v.defaultamount, {
  790. symbol: "¥",
  791. precision: 2
  792. }).format();
  793. return v
  794. })
  795. page.setData({
  796. list: res.data,
  797. "content.total": res.total,
  798. amount: currency(res.tips.amount, {
  799. symbol: "¥",
  800. precision: 2
  801. }).format()
  802. })
  803. })
  804. },
  805. })