detail.js 34 KB

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