detail.js 31 KB

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