dk-save-button.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /*******************************************************************************
  2. * Copyright(c) 2022 dongke All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:
  5. * 编辑履历:
  6. * 作者 日期 版本 修改内容
  7. * 周兴 2024-3-12 1.00 底部工具栏-保存
  8. *******************************************************************************/
  9. const util = require('@/utils/util.js')
  10. Component({
  11. /**
  12. * 组件的属性列表
  13. */
  14. properties: {
  15. // 按钮
  16. buttonList: {
  17. type: Array,
  18. },
  19. // 内容
  20. contentList: {
  21. type: Array,
  22. },
  23. // 内容是否一行显示
  24. contentLineFlag: {
  25. type: Boolean,
  26. },
  27. // 按钮自动宽度
  28. btnAutoWidthFlag: {
  29. type: Boolean,
  30. },
  31. checkFlag: {
  32. type: Boolean,
  33. value: false,
  34. },
  35. // 按钮是居右
  36. btnRightFlag: {
  37. type: Boolean,
  38. },
  39. cssType: { //css 样式
  40. type: String,
  41. value: 'default'
  42. },
  43. countName: {
  44. type: String,
  45. value: '数量'
  46. },
  47. countEnd: {
  48. type: String,
  49. value: '件'
  50. },
  51. // loading:{
  52. // type:Boolean,
  53. // value:false
  54. // },
  55. // 结果集
  56. value: {
  57. type: String,
  58. observer: function (newVal) {
  59. if (newVal) {
  60. this.setData({
  61. form: JSON.parse(newVal) || {}
  62. })
  63. } else {
  64. this.setData({
  65. form: {}
  66. })
  67. }
  68. }
  69. },
  70. },
  71. /**
  72. * 组件的初始数据
  73. */
  74. data: {
  75. form: {},
  76. },
  77. /**
  78. * 组件生命周期
  79. */
  80. lifetimes: {
  81. attached: function () {
  82. // 防抖
  83. this.submit = util.debounce(this.submit, this);
  84. },
  85. detached: function () {
  86. // 在组件实例被从页面节点树移除时执行
  87. },
  88. },
  89. /**
  90. * 组件的方法列表
  91. */
  92. methods: {
  93. /**
  94. * @desc : 修改复选框的值
  95. * @author : 周兴
  96. * @date : 2024/2/2 11:46
  97. */
  98. change(e) {
  99. if (this.data.checkFlag) {
  100. return
  101. }
  102. let code = e.currentTarget.dataset.code
  103. let form = this.data.form
  104. form[code] = e.detail
  105. this.setData({
  106. form: form,
  107. value: JSON.stringify(form)
  108. })
  109. this.triggerEvent("change", { code: code })
  110. },
  111. /**
  112. * @desc : 点击按钮
  113. * @author : 周兴
  114. * @date : 2024/2/2 11:46
  115. */
  116. submit(e) {
  117. let item = e.currentTarget.dataset.item
  118. this.triggerEvent("open", { name: item.code, customUrl: item.customUrl })
  119. },
  120. }
  121. })