fields.vue 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <template>
  2. <div>
  3. <el-dialog
  4. title="提示"
  5. :visible.sync="dialogVisible"
  6. width="50%"
  7. :before-close="handleClose">
  8. <div>
  9. <el-checkbox :indeterminate="isIndeterminate" v-model="checkAll" @change="handleCheckAllChange">全选</el-checkbox>
  10. <div style="margin: 15px 0;"></div>
  11. <el-checkbox-group v-model="checked" @change="handleCheckedChange">
  12. <el-checkbox v-for="field in filedList" :label="field.value" :key="field.value">{{field.name}}</el-checkbox>
  13. </el-checkbox-group>
  14. </div>
  15. <span slot="footer" class="dialog-footer">
  16. <el-button @click="handleClose">取 消</el-button>
  17. <el-button type="primary" @click="submit">确 定</el-button>
  18. </span>
  19. </el-dialog>
  20. </div>
  21. </template>
  22. <script>
  23. export default {
  24. components: {},
  25. props: {
  26. filedList:{
  27. type:Array,
  28. default:[]
  29. }
  30. },
  31. data() {
  32. return {
  33. //控制显示弹窗
  34. dialogVisible:false,
  35. //是否全选
  36. isIndeterminate:false,
  37. //全选
  38. checkAll:false,
  39. //选择
  40. checked:[],
  41. };
  42. },
  43. watch: {},
  44. computed: {},
  45. created() {},
  46. mounted() {},
  47. methods: {
  48. //打开栏位
  49. open(data){
  50. this.dialogVisible = true
  51. },
  52. //关闭弹窗
  53. handleClose(){
  54. this.dialogVisible = false
  55. },
  56. //提交更改
  57. submit(){
  58. },
  59. //全选
  60. handleCheckAllChange(val) {
  61. this.checked = val ? this.filedList : [];
  62. this.isIndeterminate = false;
  63. },
  64. //勾选
  65. handleCheckedChange(value){
  66. let checkedCount = value.length;
  67. this.checkAll = checkedCount === this.filedList.length;
  68. this.isIndeterminate = checkedCount > 0 && checkedCount < this.cities.length;
  69. },
  70. },
  71. };
  72. </script>
  73. <style lang="scss" scoped>
  74. </style>