index.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. const _Http = getApp().globalData.http;
  2. Component({
  3. options: {
  4. addGlobalClass: true
  5. },
  6. properties: {
  7. list: Array,
  8. changeTotal: Function
  9. },
  10. data: {
  11. radio: 0
  12. },
  13. methods: {
  14. //打开详情
  15. onClick(e) {
  16. const {
  17. item
  18. } = e.currentTarget.dataset;
  19. wx.navigateTo({
  20. url: '/packageA/setclient/modules/financing/detail/index?sys_enterprise_financeid=' + item.sys_enterprise_financeid,
  21. })
  22. },
  23. /* 处理快捷小按钮 */
  24. handleItem(e) {
  25. const {
  26. name,
  27. item
  28. } = e.target.dataset,
  29. that = this;
  30. if (!name) return;
  31. switch (name) {
  32. case "call":
  33. wx.makePhoneCall({
  34. phoneNumber: item.phonenumber,
  35. })
  36. break;
  37. case "copy":
  38. wx.setClipboardData({
  39. data: `名称:${item.enterprisename}\n纳税人识别号:${item.taxno}\n地址:${item.address}\n开户行:${item.bank}\n账号:${item.bankcardno}`,
  40. })
  41. break;
  42. case "delete":
  43. wx.showModal({
  44. title: '提示',
  45. content: '是否确认作废',
  46. complete: (res) => {
  47. if (res.confirm) {
  48. _Http.basic({
  49. "id": 20221013160502,
  50. "content": {
  51. "sys_enterprise_financeids": [item.sys_enterprise_financeid]
  52. },
  53. }).then(res => {
  54. if (res.msg != '成功') return wx.showToast({
  55. title: res.msg,
  56. icon: "none"
  57. });
  58. that.triggerEvent("changeTotal");
  59. getCurrentPages().forEach(v => {
  60. switch (v.__route__) {
  61. //退出详情界面
  62. case 'packageA/setclient/modules/financing/detail/index':
  63. wx.navigateBack()
  64. break;
  65. //列表页更新数据
  66. case 'packageA/setclient/detail':
  67. that.setData({
  68. list: that.data.list.filter(v => v.sys_enterprise_financeid != item.sys_enterprise_financeid)
  69. });
  70. break;
  71. }
  72. });
  73. wx.showToast({
  74. title: '作废成功',
  75. icon: "none"
  76. });
  77. });
  78. }
  79. }
  80. })
  81. break;
  82. case "edit":
  83. wx.navigateTo({
  84. url: '/packageA/setclient/modules/financing/add/index?data=' + JSON.stringify(item),
  85. });
  86. break;
  87. }
  88. },
  89. /* 查询默认项目 */
  90. queryDefault() {
  91. const item = this.data.list.find(v => v.isdefault == 1);
  92. if (!item) return;
  93. this.setData({
  94. radio: item.sys_enterprise_financeid
  95. })
  96. },
  97. /* 修改默认项 */
  98. onChange({
  99. detail
  100. }) {
  101. _Http.basic({
  102. "id": 20221013160702,
  103. "content": {
  104. "sys_enterprise_financeid": detail
  105. },
  106. }).then(res => {
  107. if (res.msg != '成功') return wx.showToast({
  108. title: res.data,
  109. icon: "none"
  110. });
  111. this.setData({
  112. list: this.data.list.map(v => {
  113. v.isdefault = v.sys_enterprise_financeid == detail ? 1 : 0
  114. return v
  115. }),
  116. radio: detail
  117. })
  118. })
  119. },
  120. }
  121. })