Checkbox.vue 1.43 KB
Newer Older
fukai committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
<template>
  <el-checkbox
		v-model="model"
		:style="{'border-bottom': isShowRed ? `1px solid ${isShowRed}` : ''}"
		v-bind="$attrs"
		v-on="$listeners"
		:disabled="isDisable"
		@change="handleChange"
	>
    <slot></slot>
  </el-checkbox>
</template>
<script>
import commonDepend from '~/mixin/commonDepend.js'
import markSetShowRed from '~/components/business/componentMixins/markSetShowRed.js'
export default {
	inject: {
		root: {
			default: () => null
		}
	},
	mixins: [commonDepend, markSetShowRed],
  props: {
    value: {
      type: String | Boolean,
      default: ''
    },
    disabled: {
      type: Boolean,
      default: false
    },
    // 此对象为markset或者modifySet所在的对象,如果传了此对象可以标记当前对象下的字段为红色下划线
    markSetData: {
      type: Object,
      default: () => null
    },
		customModifykey: {
			type: String,
      default: null
		}
  },
  computed: {
    model: {
      get () {
        return this.value
      },
      set (newVal) {
        this.$emit('input', newVal)
      }
    },
    mode () {
      return this.$store.state.Status.mode
    },
    isDisable() {
			return this.mode === 'display' || this.disabled
		},
  },
  watch: {
    disabled(newVal) {
      if (newVal) {
        this.resetValidate()
      }
    }
  },
	methods: {
		handleChange () {
			if (!this.customModifykey) {
				// 添加isModify属性
				this.changeModify()
			}
		},
	}
}
</script>