zCheckbox.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <template>
  2. <div class="zSelect">
  3. <div>
  4. <div class="checkbox">
  5. <van-checkbox-group v-model="zSelectValuec" @change="checkboxclick">
  6. <van-checkbox :name="item.collectionOptionId+''" v-for="(item,index) in zCheckboxcolumns" :key="index"
  7. shape="square">{{ item.collectionOption }}
  8. </van-checkbox>
  9. </van-checkbox-group>
  10. </div>
  11. </div>
  12. </div>
  13. </template>
  14. <script>
  15. export default {
  16. name: "zSelect",
  17. props: {
  18. zCheckboxcolumns: [],
  19. checkboxval: "",
  20. textc: "",
  21. rules: false,
  22. answerType: "",
  23. collectionType: "",
  24. childindex:"",
  25. childindex1:"",
  26. childindex2:"",
  27. childindex4:"",
  28. childindex3:"",
  29. level:""
  30. },
  31. data() {
  32. return {
  33. zSelect: false,
  34. zSelectValuec: ""
  35. }
  36. },
  37. created() {
  38. this.checkboxvalFn()
  39. },
  40. methods: {
  41. checkboxvalFn() {
  42. if (this.checkboxval == "" || this.checkboxval == undefined) {
  43. this.zSelectValuec = []
  44. } else {
  45. this.zSelectValuec = this.checkboxval.split(",")
  46. }
  47. },
  48. checkboxclick(value) {
  49. var typeval = []
  50. var index=""
  51. for (let k = 0; k < this.zCheckboxcolumns.length; k++) {
  52. for (let kk = 0; kk < value.length; kk++) {
  53. if (this.zCheckboxcolumns[k].collectionOptionId == value[kk]) {
  54. typeval.push(this.zCheckboxcolumns[k])
  55. }
  56. }
  57. }
  58. let datalist = {
  59. type: this.textc,
  60. answerType: this.answerType,
  61. collectionType: this.collectionType,
  62. childindex:this.childindex,
  63. childindex1:this.childindex1,
  64. childindex2:this.childindex2,
  65. childindex3:this.childindex3,
  66. childindex4:this.childindex4,
  67. level:this.level,
  68. value: typeval
  69. }
  70. this.zSelectValuec = value
  71. this.$emit('zSelectVal', datalist)
  72. this.zSelect = false
  73. }
  74. }
  75. }
  76. </script>
  77. <style scoped>
  78. .van-f-red {
  79. color: red;
  80. width: 4px;
  81. display: inline-block
  82. }
  83. .zSelect .z-cell {
  84. padding: 10px 16px 0 16px;
  85. font-size: 16px;
  86. }
  87. /*.checkbox{padding: 10px 16px 0 16px;background-color: white;}*/
  88. .checkbox .van-checkbox {
  89. padding-bottom: 10px
  90. }
  91. </style>
  92. <style>
  93. .checkbox .van-checkbox__icon .van-icon {
  94. border: 1px solid #333 !important;
  95. }
  96. .checkbox .van-checkbox__icon--checked .van-icon {
  97. border: 1px solid #1989fa !important;
  98. color: #1989fa;
  99. background-color: #fff;
  100. }
  101. </style>