index.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  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. detail: {
  13. item: {},
  14. list: [],
  15. show: false
  16. },
  17. tabbarList: [{
  18. icon: "icon-bodadianhua",
  19. label: "呼叫",
  20. alias: "call"
  21. }, {
  22. icon: "icon-a-yingxiaowuliaofuzhi",
  23. label: "复制",
  24. alias: "copy"
  25. }, {
  26. icon: "icon-bianji",
  27. label: "编辑",
  28. alias: "edit"
  29. }, {
  30. icon: "icon-shanchu",
  31. label: "删除",
  32. alias: "delete"
  33. }]
  34. },
  35. methods: {
  36. //详情单元格单击复制
  37. clickItem({
  38. detail
  39. }) {
  40. wx.setClipboardData({
  41. data: detail.value,
  42. success: () => {
  43. wx.hideToast();
  44. wx.showToast({
  45. title: `已复制${detail.label}`,
  46. icon: "none"
  47. })
  48. }
  49. })
  50. },
  51. //打开详情
  52. onClick(e) {
  53. const {
  54. item
  55. } = e.currentTarget.dataset;
  56. this.setData({
  57. "detail.show": true,
  58. "detail.list": [{
  59. label: "名称",
  60. value: item.enterprisename
  61. }, {
  62. label: "纳税人识别号",
  63. value: item.taxno
  64. }, {
  65. label: "地址",
  66. value: item.address
  67. }, {
  68. label: "开户行",
  69. value: item.bank
  70. }, {
  71. label: "账号",
  72. value: item.bankcardno
  73. }, {
  74. label: "联系人号码",
  75. value: item.phonenumber
  76. }],
  77. "detail.item": item
  78. })
  79. },
  80. //关闭详情弹窗
  81. onClose() {
  82. this.setData({
  83. detail: {
  84. item: {},
  85. list: [],
  86. show: false
  87. }
  88. })
  89. },
  90. /* 处理快捷小按钮 */
  91. handleItem(e) {
  92. const {
  93. name,
  94. item
  95. } = e.target.dataset,
  96. that = this;
  97. if (!name) return;
  98. switch (name) {
  99. case "call":
  100. wx.makePhoneCall({
  101. phoneNumber: item.phonenumber,
  102. })
  103. break;
  104. case "copy":
  105. wx.setClipboardData({
  106. data: `名称:${item.enterprisename}\n纳税人识别号:${item.taxno}\n地址:${item.address}\n开户行:${item.bank}\n账号:${item.bankcardno}`,
  107. })
  108. break;
  109. case "delete":
  110. wx.showModal({
  111. title: '提示',
  112. content: '是否确认删除',
  113. complete: (res) => {
  114. if (res.confirm) {
  115. _Http.basic({
  116. "id": 20221013160502,
  117. "content": {
  118. "sys_enterprise_financeids": [item.sys_enterprise_financeid]
  119. },
  120. }).then(res => {
  121. if (res.msg != '成功') return wx.showToast({
  122. title: res.data,
  123. icon: "none"
  124. });
  125. that.setData({
  126. list: that.data.list.filter(v => v.sys_enterprise_financeid != item.sys_enterprise_financeid)
  127. });
  128. that.triggerEvent("changeTotal");
  129. that.onClose();
  130. wx.showToast({
  131. title: '删除成功',
  132. icon: "none"
  133. });
  134. })
  135. }
  136. }
  137. })
  138. break;
  139. case "edit":
  140. wx.navigateTo({
  141. url: '/packageA/setclient/modules/financing/add/index?data=' + JSON.stringify(item),
  142. });
  143. that.onClose();
  144. break;
  145. }
  146. },
  147. /* 查询默认项目 */
  148. queryDefault() {
  149. const item = this.data.list.find(v => v.isdefault == 1);
  150. this.setData({
  151. radio: item.sys_enterprise_financeid
  152. })
  153. },
  154. /* 修改默认项 */
  155. onChange({
  156. detail
  157. }) {
  158. _Http.basic({
  159. "id": 20221013160702,
  160. "content": {
  161. "sys_enterprise_financeid": detail
  162. },
  163. }).then(res => {
  164. if (res.msg != '成功') return wx.showToast({
  165. title: res.data,
  166. icon: "none"
  167. });
  168. this.setData({
  169. list: this.data.list.map(v => {
  170. v.isdefault = v.sys_enterprise_financeid == detail ? 1 : 0
  171. return v
  172. }),
  173. radio: detail
  174. })
  175. })
  176. },
  177. //详情按钮回调
  178. tabbarOnClick({
  179. detail
  180. }) {
  181. this.handleItem({
  182. target: {
  183. dataset: {
  184. name: detail.alias,
  185. item: this.data.detail.item
  186. }
  187. }
  188. })
  189. }
  190. }
  191. })