detail.js 32 KB

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