detail.js 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896
  1. const _Http = getApp().globalData.http,
  2. currency = require("../../utils/currency"),
  3. CNY = value => currency(value, {
  4. symbol: "¥",
  5. precision: 2
  6. }).format(),
  7. {
  8. formatTime
  9. } = require("../../utils/getTime");
  10. Page({
  11. data: {
  12. isLeader: false, //是否为负责人
  13. tabsActive: 0, //tabs 选中项
  14. sa_contractid: "",
  15. tabsList: [{
  16. label: "详细信息",
  17. icon: "icon-tabxiangxixinxi1"
  18. }],
  19. tabbarList: [],
  20. loading: true
  21. },
  22. onLoad(options) {
  23. const appAuth = wx.getStorageSync('auth').wcontract;
  24. this.setData({
  25. sa_contractid: options.id,
  26. isAdmin: appAuth.options.some(v => v == "admin"), //是否具有管理权限
  27. options: appAuth.options, //权限列表
  28. appAuth
  29. })
  30. this.getDetail(true);
  31. getApp().globalData.Language.getLanguagePackage(this, '合同详情');
  32. },
  33. getDetail() {
  34. _Http.basic({
  35. "id": 20221121195102,
  36. "content": {
  37. nocache: true,
  38. "sa_contractid": this.data.sa_contractid
  39. },
  40. }).then(res => {
  41. console.log("合同详情", res)
  42. if (res.code != '1') return wx.showToast({
  43. title: res.msg,
  44. icon: "none"
  45. });
  46. let data = res.data,
  47. tabsList = this.data.tabsList,
  48. tabsActive = 0;
  49. if (this.data.appAuth.isdatatag) this.getTags();
  50. if (this.data.appAuth.isdatateam) this.getGroup();
  51. switch (data.type) {
  52. case "框架":
  53. data.type = '经销商合作协议'
  54. tabsList = tabsList.concat([{
  55. label: "产品明细折扣",
  56. icon: "icon-tabchanpin",
  57. model: '#PiscountProduct'
  58. }, {
  59. label: "产品类别折扣",
  60. icon: "icon-tabchanpinleibie",
  61. model: '#PiscountType'
  62. }, {
  63. label: "业绩目标",
  64. icon: "icon-tabrenwu",
  65. model: '#Objective'
  66. }]);
  67. tabsActive = 1;
  68. break;
  69. case "直销":
  70. data.type = '直销客户合作协议'
  71. tabsList = tabsList.concat([{
  72. label: "产品明细折扣",
  73. icon: "icon-tabchanpin",
  74. model: '#PiscountProduct'
  75. }, {
  76. label: "产品类别折扣",
  77. icon: "icon-tabchanpinleibie",
  78. model: '#PiscountType'
  79. }, {
  80. label: "业绩目标",
  81. icon: "icon-tabrenwu",
  82. model: '#Objective'
  83. }]);
  84. tabsActive = 1;
  85. break;
  86. case "工具借用":
  87. data.type = '工具使用(借用)协议'
  88. tabsList = tabsList.concat([{
  89. label: "工具清单",
  90. icon: "icon-tabgongjuqingdan",
  91. model: '#Product'
  92. }])
  93. tabsActive = 1;
  94. break;
  95. case "居间":
  96. data.type = '居间协议'
  97. if (wx.getStorageSync('siteP').siteid != 'HY') tabsList = tabsList.concat([{
  98. label: "产品明细折扣",
  99. icon: "icon-tabchanpin",
  100. model: '#PiscountProduct'
  101. }, {
  102. label: "产品类别折扣",
  103. icon: "icon-tabchanpinleibie",
  104. model: '#PiscountType'
  105. }]);
  106. if (this.data.appAuth.options.some(v => v == 'IntermediaryContact')) tabsList.push({
  107. label: "联系人",
  108. icon: "icon-tablianxiren",
  109. model: "#Contacts"
  110. })
  111. break;
  112. case "项目":
  113. data.type = data.typemx + '项目协议'
  114. tabsList = tabsList.concat([{
  115. label: "产品明细折扣",
  116. icon: "icon-tabchanpin",
  117. model: '#Product'
  118. }, {
  119. label: "产品类别折扣",
  120. icon: "icon-tabchanpinleibie",
  121. model: '#PiscountType'
  122. }]);
  123. tabsActive = 1;
  124. break;
  125. };
  126. if (this.data.appAuth.isdatafollowup) tabsList.push({
  127. label: "跟进动态",
  128. icon: "icon-tabgenjindongtai1",
  129. model: "#Trace"
  130. })
  131. if (this.data.appAuth.istask) tabsList.push({
  132. label: "任务",
  133. icon: "icon-tabrenwu",
  134. model: "#Work"
  135. })
  136. tabsList.push({
  137. label: "操作记录",
  138. icon: "icon-tabcaozuojilu1",
  139. model: "#Record"
  140. })
  141. this.setData({
  142. detail: data,
  143. loading: false,
  144. list2: [{
  145. label: "创建人",
  146. value: data.createby
  147. }, {
  148. label: "创建时间",
  149. value: data.createdate
  150. }, {
  151. label: "最近编辑人",
  152. value: data.changeby
  153. }, {
  154. label: "最近编辑时间",
  155. value: data.changedate
  156. }, {
  157. label: "提交人",
  158. value: data.submitby
  159. }, {
  160. label: "提交时间",
  161. value: data.submitdate
  162. }, {
  163. label: "审核人",
  164. value: data.checkby
  165. }, {
  166. label: "审核时间",
  167. value: data.checkdate
  168. }, {
  169. label: "作废原因",
  170. value: data.leader.deletereason
  171. }, {
  172. label: "转手次数",
  173. value: data.leader[0].leadernum
  174. }],
  175. tabsList,
  176. tabsActive: this.data.tabsActive != 0 ? this.data.tabsActive : tabsActive,
  177. });
  178. this.setTabbarList();
  179. this.setDetail(data);
  180. this.partialRenewal();
  181. })
  182. },
  183. /* 设置tabbar */
  184. async setTabbarList() {
  185. let detail = this.data.detail,
  186. status = detail.status,
  187. isLeader = detail.leader.some(some => some.userid == wx.getStorageSync('userMsg').userid),
  188. isAdmin = this.data.isAdmin,
  189. editdataleader = isLeader,
  190. tabbarList = [];
  191. if (this.data.appAuth.isdatafollowup) tabbarList.push({
  192. icon: "icon-genjin",
  193. label: "跟进"
  194. })
  195. if (!isLeader) {
  196. let res = await getApp().agentOrNot("sa_contract", this.data.sa_contractid),
  197. data = res.code == '1' ? res.data : {
  198. editable: 0,
  199. editdataleader: 0
  200. }
  201. if (this.data.appAuth.isdatateam) isLeader = this.selectComponent("#Group").data.editable == 1;
  202. if (!isLeader) isLeader = data.editable == 1;
  203. editdataleader = data.editdataleader;
  204. }
  205. if (isAdmin) {
  206. if (status == '已提交') tabbarList.unshift({
  207. icon: "icon-genjin",
  208. label: "审核"
  209. })
  210. if (status == '审核') tabbarList.unshift({
  211. icon: "icon-genjin",
  212. label: "反审核"
  213. })
  214. }
  215. /* {
  216. icon: "icon-shanchu",
  217. label: "作废"
  218. } */
  219. if (status != '已终止' && status != '已过期') {
  220. if (isLeader || isAdmin) {
  221. if (editdataleader) tabbarList.unshift({
  222. icon: "icon-zhuanyi",
  223. label: "更换负责人"
  224. });
  225. if (status == '新建') {
  226. tabbarList.push({
  227. icon: "icon-bianji",
  228. label: "编辑"
  229. })
  230. tabbarList.unshift({
  231. icon: "icon-genjin",
  232. label: '提交'
  233. })
  234. } else if (status == '已提交') {
  235. tabbarList.unshift({
  236. icon: "icon-genjin",
  237. label: '撤回'
  238. })
  239. } else if (status == '审核') {
  240. tabbarList.unshift({
  241. icon: "icon-genjin",
  242. label: "终止"
  243. })
  244. }
  245. };
  246. }
  247. if (isLeader && status != '已提交' && status != '审核') tabbarList.push({
  248. icon: "icon-shanchu",
  249. label: "作废"
  250. })
  251. this.setData({
  252. isLeader,
  253. tabbarList,
  254. editdataleader
  255. });
  256. if (detail.typemx && (isLeader || this.data.appAuth.options.includes("app")) && status != '审核') {
  257. setTimeout(() => {
  258. this.selectComponent("#Product").setData({
  259. directAddition: true
  260. })
  261. });
  262. }
  263. },
  264. /* 设置详情信息 */
  265. setDetail(data) {
  266. let briefs = [{
  267. label: "合同编号",
  268. value: data.billno
  269. }, {
  270. label: "合同类型",
  271. value: data.type
  272. }, {
  273. label: "经销商",
  274. value: data.enterprisename
  275. }, {
  276. label: "整体折扣",
  277. value: data.discountrate * 100 + "%"
  278. }, {
  279. label: "签约日期",
  280. value: data.signdate
  281. }, {
  282. label: "状态",
  283. value: getApp().globalData.Language.getMapText(data.status),
  284. style:`color:${this.data.sColors[data.status]}`
  285. }],
  286. list1 = [{
  287. label: "合同标题",
  288. value: data.title
  289. }, {
  290. label: "合同编号",
  291. value: data.billno
  292. }, {
  293. label: "合同类型",
  294. value: data.type
  295. }, {
  296. label: "签约日期",
  297. value: data.signdate
  298. }, {
  299. label: "合同有效期",
  300. value: data.begdate + ' ' + getApp().globalData.Language.getMapText('至') + ' ' + data.enddate
  301. }, {
  302. label: "合同模板",
  303. value: data.type
  304. }, {
  305. label: "合同描述",
  306. value: data.remarks
  307. }, {
  308. label: "负责人",
  309. value: data.leader[0].name
  310. }, {
  311. label: "状态",
  312. value: getApp().globalData.Language.getMapText(data.status),
  313. style:`color:${this.data.sColors[data.status]}`
  314. }];
  315. if (data.typemx) {
  316. briefs.splice(3, 0, {
  317. label: "项目",
  318. value: data.projectname
  319. })
  320. briefs.splice(4, 0, {
  321. label: "项目编号",
  322. value: data.projectnum
  323. })
  324. briefs.splice(5, 0, {
  325. label: "有效期",
  326. value: data.begdate + ' ' + getApp().globalData.Language.getMapText('至') + ' ' + data.enddate
  327. })
  328. briefs.splice(6, 1)
  329. briefs.splice(7, 0, {
  330. label: "签约金额(元)",
  331. value: CNY(data.signamount)
  332. })
  333. briefs.splice(7, 0, {
  334. label: "折扣(%)",
  335. value: data.discountrate * 100 + "%"
  336. })
  337. list1.splice(3, 0, {
  338. label: data.typemx == '直销' ? '客户' : "经销商",
  339. value: data.enterprisename
  340. })
  341. list1.splice(4, 0, {
  342. label: "项目",
  343. value: data.projectname
  344. })
  345. list1.splice(5, 0, {
  346. label: "品牌",
  347. value: data.brandname
  348. })
  349. list1.splice(6, 0, {
  350. label: "领域",
  351. value: data.tradefields
  352. })
  353. list1.splice(7, 0, {
  354. label: "项目编号",
  355. value: data.projectnum
  356. })
  357. list1.splice(8, 0, {
  358. label: "项目地址",
  359. value: data.address
  360. })
  361. list1.splice(9, 0, {
  362. label: "收货人",
  363. value: data.name
  364. })
  365. list1.splice(10, 0, {
  366. label: "收货人电话",
  367. value: data.phonenumber
  368. })
  369. list1.splice(11, 0, {
  370. label: "业务员",
  371. value: data.salername
  372. })
  373. list1.splice(12, 0, {
  374. label: "签约金额",
  375. value: CNY(data.signamount)
  376. })
  377. list1.splice(13, 0, {
  378. label: "折扣(%)",
  379. value: data.discountrate * 100 + "%"
  380. })
  381. if (data.typemx == '直销') briefs[2].label = '客户';
  382. } else {
  383. switch (data.type) {
  384. case "居间协议":
  385. briefs.splice(2, 1, {
  386. label: "居间商",
  387. value: data.enterprisename
  388. })
  389. briefs.splice(3, 0, {
  390. label: "项目",
  391. value: data.projectname
  392. })
  393. briefs.splice(4, 0, {
  394. label: "客户名称",
  395. value: data.ascription_enterprisename
  396. })
  397. /* briefs.splice(4, 0, {
  398. label: "项目编号",
  399. value: data.projectnum
  400. }) */
  401. briefs.splice(5, 1, {
  402. label: data.calculatemodel == 1 ? '订单金额比例' : '居间产品折扣',
  403. value: data.calculatemodel == 1 ? data.orderratio * 100 + '%' : data.productdiscount * 100 + '%'
  404. })
  405. briefs.splice(3, 0, {
  406. label: "合同",
  407. value: data.ascription_title
  408. })
  409. briefs.splice(7, 0, {
  410. label: "合同有效期",
  411. value: data.begdate + "-" + data.enddate
  412. })
  413. list1.splice(3, 0, {
  414. label: "居间商",
  415. value: data.enterprisename
  416. })
  417. list1.splice(4, 0, {
  418. label: "合同",
  419. value: data.ascription_title
  420. })
  421. list1.splice(5, 0, {
  422. label: "项目",
  423. value: data.projectname
  424. })
  425. list1.splice(6, 0, {
  426. label: "客户名称",
  427. value: data.ascription_enterprisename
  428. })
  429. list1.splice(6, 0, {
  430. label: "项目编号",
  431. value: data.projectnum
  432. })
  433. list1.splice(8, 0, {
  434. label: data.calculatemodel == 1 ? '订单金额比例' : '居间产品折扣',
  435. value: data.calculatemodel == 1 ? data.orderratio * 100 + '%' : data.productdiscount * 100 + '%'
  436. })
  437. break;
  438. case "工具使用(借用)协议":
  439. briefs.splice(2, 1, {
  440. label: "客户",
  441. value: data.enterprisename
  442. })
  443. briefs.splice(3, 1, {
  444. label: "单套价格",
  445. value: data.signamount
  446. })
  447. briefs.splice(5, 0, {
  448. label: "合同有效期",
  449. value: data.begdate + ' ' + getApp().globalData.Language.getMapText('至') + ' ' + data.enddate
  450. })
  451. list1.splice(3, 0, {
  452. label: "客户",
  453. value: data.enterprisename
  454. })
  455. list1.splice(4, 0, {
  456. label: "单套价格",
  457. value: data.signamount
  458. })
  459. break;
  460. case "经销商合作协议":
  461. briefs[3].label = '折扣(%)';
  462. briefs.splice(3, 0, {
  463. label: "签约金额(元)",
  464. value: CNY(data.signamount)
  465. })
  466. list1.splice(3, 0, {
  467. label: "经销商",
  468. value: data.enterprisename
  469. })
  470. list1.splice(4, 0, {
  471. label: "签约金额(元)",
  472. value: CNY(data.signamount)
  473. })
  474. list1.splice(5, 0, {
  475. label: "折扣(%)",
  476. value: data.discountrate * 100 + "%"
  477. })
  478. list1.splice(6, 0, {
  479. label: "品牌",
  480. value: data.brandname
  481. })
  482. list1.splice(7, 0, {
  483. label: "领域",
  484. value: data.tradefields
  485. })
  486. break;
  487. case "直销客户合作协议":
  488. briefs[3].label = '折扣(%)';
  489. briefs[2].label = '客户';
  490. /* briefs.splice(3, 0, {
  491. label: "签约金额(元)",
  492. value: CNY(data.signamount)
  493. }) */
  494. briefs.splice(4, 0, {
  495. label: "合同有效期",
  496. value: data.begdate + ' ' + getApp().globalData.Language.getMapText('至') + ' ' + data.enddate
  497. })
  498. briefs.splice(6, 0, {
  499. label: "业务员",
  500. value: data.salername
  501. })
  502. list1.splice(3, 0, {
  503. label: "客户",
  504. value: data.enterprisename
  505. })
  506. list1.splice(4, 0, {
  507. label: "签约金额(元)",
  508. value: CNY(data.signamount)
  509. })
  510. list1.splice(5, 0, {
  511. label: "折扣(%)",
  512. value: data.discountrate * 100 + "%"
  513. })
  514. list1.splice(6, 0, {
  515. label: "品牌",
  516. value: data.brandname
  517. })
  518. list1.splice(7, 0, {
  519. label: "领域",
  520. value: data.tradefields
  521. })
  522. break;
  523. }
  524. }
  525. if (data.typemx || ['经销商合作协议', '直销客户合作协议'].includes(data.type)) {
  526. list1.splice(list1.findIndex(v => v.label == '签约日期'), 0, {
  527. label: "付款条件",
  528. value: data.paytype
  529. })
  530. list1.splice(list1.findIndex(v => v.label == '合同有效期')+1, 0, {
  531. label: "发货日期提醒(天)",
  532. value: data.reminddays
  533. })
  534. }
  535. this.setData({
  536. briefs,
  537. list1
  538. })
  539. },
  540. //tabs 切换
  541. tabsChange({
  542. detail
  543. }) {
  544. this.setData({
  545. tabsActive: detail
  546. });
  547. this.partialRenewal();
  548. },
  549. //更新标签
  550. getTags() {
  551. this.selectComponent("#Tags").getTags();
  552. },
  553. //更新团队成员
  554. getGroup() {
  555. this.selectComponent("#Group").getList().then(this.setTabbarList)
  556. },
  557. //局部数据更新 tabs
  558. partialRenewal(init = false) {
  559. let model = this.data.tabsList[this.data.tabsActive].model;
  560. if (model) {
  561. let Component = this.selectComponent(model),
  562. {
  563. total,
  564. pageNumber,
  565. pageTotal
  566. } = Component.data.content,
  567. id = this.data.sa_contractid;
  568. if (total == null || init) {
  569. Component.getList(id, init);
  570. } else if (pageNumber <= pageTotal) {
  571. Component.getList(id, false);
  572. }
  573. }
  574. },
  575. onReachBottom() {
  576. this.partialRenewal();
  577. },
  578. //详情按钮回调
  579. tabbarOnClick({
  580. detail
  581. }) {
  582. let data = this.data.detail,
  583. that = this;
  584. switch (detail.label) {
  585. case "终止":
  586. wx.showModal({
  587. title: getApp().globalData.Language.getMapText('提示'),
  588. content: getApp().globalData.Language.getMapText('是否确定终止当前协议'),
  589. cancelText: getApp().globalData.Language.getMapText('取消'),
  590. confirmText: getApp().globalData.Language.getMapText('确定'),
  591. complete: (res) => {
  592. if (res.confirm) _Http.basic({
  593. "id": 20221212102802,
  594. "content": {
  595. "sa_contractid": that.data.sa_contractid
  596. }
  597. }).then(res => {
  598. console.log("提交报价单", res)
  599. wx.showToast({
  600. title: res.code == '1' ? getApp().globalData.Language.getMapText("已终止") : res.msg,
  601. icon: "none"
  602. })
  603. if (res.code == '1') setTimeout(() => {
  604. that.getDetail();
  605. }, 300)
  606. })
  607. }
  608. })
  609. break;
  610. case "提交":
  611. wx.showModal({
  612. title: getApp().globalData.Language.getMapText('提示'),
  613. content: getApp().globalData.Language.getMapText('是否确定提交当前协议,提交后禁止使用部分功能'),
  614. complete: ({
  615. confirm
  616. }) => {
  617. if (confirm) {
  618. _Http.basic({
  619. "id": "2024091910001802",
  620. "content": {
  621. "ownertable": "sa_contract", //sa_project,,sa_quotedprice
  622. "ownerid": that.data.sa_contractid
  623. },
  624. }).then(s => {
  625. console.log("是否可以提交", s)
  626. if (s.code == 1) {
  627. _Http.basic({
  628. "id": 20221121202802,
  629. "content": {
  630. "sa_contractids": [that.data.sa_contractid]
  631. }
  632. }).then(res => {
  633. console.log("提交合同", res)
  634. getApp().globalData.Language.showToast(res.code == '1' ? "提交成功" : res.msg)
  635. if (res.code == '1') setTimeout(() => {
  636. that.getDetail();
  637. }, 300)
  638. })
  639. } else {
  640. wx.showModal({
  641. title: '提示',
  642. content: s.msg,
  643. complete: ({
  644. confirm
  645. }) => {
  646. if (confirm) _Http.basic({
  647. "id": "2024091910214302",
  648. "content": {
  649. "ownertable": "sa_contract", //sa_project,,sa_quotedprice
  650. "ownerid": that.data.sa_contractid
  651. },
  652. }).then(v => {
  653. console.log("发送提醒", v)
  654. getApp().globalData.Language.showToast(v.code == '1' ? "已发送提醒" : res.msg)
  655. })
  656. }
  657. })
  658. }
  659. })
  660. }
  661. }
  662. })
  663. break;
  664. case "审核":
  665. // enddate
  666. if (formatTime().split(" ")[0] <= that.data.detail.enddate) {
  667. wx.showModal({
  668. title: getApp().globalData.Language.getMapText('提示'),
  669. content: getApp().globalData.Language.getMapText('是否通过当前协议'),
  670. cancelText: getApp().globalData.Language.getMapText('取消'),
  671. confirmText: getApp().globalData.Language.getMapText('确定'),
  672. complete: (res) => {
  673. if (res.confirm) handle()
  674. }
  675. })
  676. } else {
  677. wx.showModal({
  678. title: getApp().globalData.Language.getMapText('提示'),
  679. content: getApp().globalData.Language.getMapText('当前合同已过期,是否确认继续审核'),
  680. cancelText: getApp().globalData.Language.getMapText('取消'),
  681. confirmText: getApp().globalData.Language.getMapText('确定'),
  682. complete: (res) => {
  683. if (res.confirm) handle()
  684. }
  685. })
  686. }
  687. function handle() {
  688. _Http.basic({
  689. "id": 20221121203102,
  690. "version": 1,
  691. "content": {
  692. "type": 1, //0:不通过,1:通过
  693. "sa_contractid": that.data.sa_contractid
  694. }
  695. }).then(res => {
  696. console.log("审核合同", res)
  697. wx.showToast({
  698. title: res.code == '1' ? getApp().globalData.Language.getMapText('审核成功') : res.msg,
  699. icon: "none"
  700. })
  701. if (res.code == '1') setTimeout(() => {
  702. that.getDetail();
  703. }, 300)
  704. })
  705. }
  706. break;
  707. case "撤回":
  708. wx.showModal({
  709. title: getApp().globalData.Language.getMapText('提示'),
  710. content: getApp().globalData.Language.getMapText('是否撤回审核当前协议'),
  711. cancelText: getApp().globalData.Language.getMapText('取消'),
  712. confirmText: getApp().globalData.Language.getMapText('确定'),
  713. complete: (res) => {
  714. if (res.confirm) _Http.basic({
  715. "id": 20230130091502,
  716. "content": {
  717. "sa_contractid": that.data.sa_contractid,
  718. }
  719. }).then(res => {
  720. console.log("撤回审核合同", res)
  721. wx.showToast({
  722. title: res.code == '1' ? getApp().globalData.Language.getMapText('撤回审核成功') : res.msg,
  723. icon: "none"
  724. })
  725. if (res.code == '1') setTimeout(() => {
  726. that.getDetail();
  727. }, 300)
  728. })
  729. }
  730. })
  731. break;
  732. case "反审核":
  733. wx.showModal({
  734. title: getApp().globalData.Language.getMapText('提示'),
  735. content: getApp().globalData.Language.getMapText('是否反审核当前协议'),
  736. cancelText: getApp().globalData.Language.getMapText('取消'),
  737. confirmText: getApp().globalData.Language.getMapText('确定'),
  738. complete: (res) => {
  739. if (res.confirm) _Http.basic({
  740. "id": 20221212135402,
  741. "content": {
  742. "sa_contractid": that.data.sa_contractid,
  743. }
  744. }).then(res => {
  745. console.log("反审核合同", res)
  746. wx.showToast({
  747. title: res.code == '1' ? getApp().globalData.Language.getMapText('反审核成功') : res.msg,
  748. icon: "none"
  749. })
  750. if (res.code == '1') setTimeout(() => {
  751. that.getDetail();
  752. }, 300)
  753. })
  754. }
  755. })
  756. break;
  757. case "跟进":
  758. wx.navigateTo({
  759. url: `/packageA/setclient/modules/trace/add/index?ownertable=sa_contract&ownerid=${data.sa_contractid}`,
  760. })
  761. break;
  762. case "作废":
  763. wx.navigateTo({
  764. url: '/packageA/contract/delete?id=' + this.data.detail.sa_contractid,
  765. })
  766. break;
  767. case "编辑":
  768. this.toEdit();
  769. break;
  770. case "更换负责人":
  771. wx.navigateTo({
  772. url: `/pages/group/select?data=${JSON.stringify({
  773. ownertable:"sa_contract",
  774. ownerid:data.sa_contractid,
  775. })}&radio=true&principal=true`,
  776. })
  777. break;
  778. }
  779. },
  780. toEdit() {
  781. let data = this.data.detail,
  782. type = null;
  783. data.invaliddate = [data.begdate, data.enddate]
  784. data.sys_enterpriseid = [data.enterprisename, [data.sys_enterpriseid]];
  785. data.sa_projectid = [data.projectname, [data.sa_projectid]];
  786. switch (data.type) {
  787. case "经销商合作协议":
  788. type = "type1"
  789. break;
  790. case "经销项目协议":
  791. type = "type2"
  792. break;
  793. case "直销项目协议":
  794. type = "type3"
  795. break;
  796. case "居间协议":
  797. if (data.ascription_title) {
  798. //客户合同
  799. data.ascription_contractid = [data.title, [data.ascription_contractid]]
  800. data.sys_enterpriseid1 = [data.ascription_enterprisename, [data.ascription_enterpriseid]]
  801. console.log(data.sys_enterpriseid)
  802. } else {
  803. }
  804. data.radios = data.calculatemodel + "";
  805. type = "type4"
  806. break;
  807. case "工具使用(借用)协议":
  808. type = "type5"
  809. break;
  810. case "直销客户合作协议":
  811. data.saler_hrid = [data.salername, [data.saler_hrid]];
  812. type = "type6"
  813. break;
  814. };
  815. if (type) wx.navigateTo({
  816. url: `/packageA/contract/add/${type}/index?data=${JSON.stringify(data)}`,
  817. })
  818. },
  819. /* 更换负责人 */
  820. handelSubmit(arr) {
  821. const that = this;
  822. wx.showModal({
  823. title: getApp().globalData.Language.getMapText('提示'),
  824. content: getApp().globalData.Language.getMapText('是否确认更换负责人'),
  825. cancelText: getApp().globalData.Language.getMapText('取消'),
  826. confirmText: getApp().globalData.Language.getMapText('确定'),
  827. complete: ({
  828. confirm
  829. }) => {
  830. if (confirm) wx.showModal({
  831. title: getApp().globalData.Language.getMapText('提示'),
  832. content: getApp().globalData.Language.getMapText('是否参与该数据的后续工作'),
  833. cancelText: getApp().globalData.Language.getMapText('不参与'),
  834. confirmText: getApp().globalData.Language.getMapText('参与'),
  835. complete: (s) => {
  836. _Http.basic({
  837. "id": 20220930103701,
  838. "content": {
  839. ownertable: "sa_contract",
  840. ownerid: that.data.detail.sa_contractid,
  841. userid: arr[0],
  842. isaddoldleader: s.confirm ? 1 : 0
  843. }
  844. }).then(res => {
  845. console.log("更换负责人", res)
  846. if (res.code != '1') return wx.showToast({
  847. title: res.data,
  848. icon: "none"
  849. });
  850. wx.showToast({
  851. title: getApp().globalData.Language.getMapText('更换成功'),
  852. icon: "none",
  853. mask: true
  854. });
  855. setTimeout(() => {
  856. wx.navigateBack({
  857. delta: 2
  858. });
  859. }, 300)
  860. })
  861. }
  862. })
  863. }
  864. })
  865. },
  866. onUnload() {
  867. let page = getCurrentPages().find(v => v.__route__ == 'packageA/contract/index');
  868. if (!page) return;
  869. let content = JSON.parse(JSON.stringify(page.data.content));
  870. content.pageSize = (content.pageNumber - 1) * content.pageSize;
  871. content.pageNumber = 1;
  872. _Http.basic({
  873. id: 20221121201502,
  874. content
  875. }).then(res => {
  876. console.log("更新合同列表", res);
  877. if (res.code == '1') page.setData({
  878. list: res.data,
  879. "content.total": res.total
  880. })
  881. })
  882. }
  883. })