zCheckbox.vue 2.5 KB

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