常用组件例子

var _= require("lodash");
//lodash 需要找资源引入
window._ = _;

Vue.component('expandRow', {
    props: {
        modifyData: Array,
        columns: Array
    },
    template: '<i-table :columns="columns" :data="modifyData"> </i-table>'
});
Vue.component('editCell', {
    props: {
        data: Object,
        name: String
    },
    watch: {
        data: function (newValue) {
            this.$emit('change', newValue, this.name)
        }
    },
    template: '<i-input placeholder="请输入..." v-model="data"></i-input>'
});
Vue.component('inputCell', {
    props: {
        data: Object,
        name: String,
        maxlength: Number,
    },
    watch: {
        data: function (newValue) {
            this.$emit('change', newValue, this.name)
        }
    },
    template: '<i-input placeholder="请输入..." v-model="data" :maxlength="maxlength"></i-input>'
});
Vue.component('textAreaCell', {
    props: {
        data: Object,
        name: String,
        maxlength: Number
    },
    watch: {
        data: function (newValue) {
            this.$emit('change', newValue, this.name)
        }
    },
    template: '<i-input type="textarea" placeholder="请输入..." :autosize="{minRows: 5,maxRows: 8}" v-model="data" :maxlength="maxlength"></i-input>'
});

Vue.component('textAreaCellMkII', {
    props: {
        data: Object,
        name: String,
        maxlength: Number,
        text:{
            type: String,
            default: "请输入..."
        }
    },
    watch: {
        data: function (newValue) {
            this.$emit('change', newValue, this.name)
        }
    },
    template: '<i-input type="textarea" :placeholder="text" :autosize="{minRows: 2,maxRows: 8}" v-model="data" :maxlength="maxlength"></i-input>'
});

Vue.component('selectCell', {
    props: {
        dataList: Array,
        data: Object,
        name: String,
        field: {value: "code", label: "name"}
    },
    computed: {
        list: function () {
            var _this = this;
            return _.map(this.dataList, function (o) {
                o.name = o[_this.field.label];
                o.code = o[_this.field.value];
                return o;
            });
        }
    },
    watch: {
        data: function (newValue) {
            this.$emit('change', newValue, this.name, this)
        }
    },
    methods: {
        clear: function () {
            var _this = this;
            Vue.nextTick(function () {
                _this.data = "";
            });
        }
    },
    template: '<i-select  v-model="data" placeholder="请选择" clearable filterable >'
        + '<i-option v-for="item in list" :value="item.code" :label="item.name"></i-option>'
        + '</i-select>'
});

Vue.component('datepickerCell', {
    props: {
        data: Object
    },
    watch: {
        data: function (newValue) {
            this.$emit('change', newValue)
        }
    },
    template: '<Date-picker type="date"  placeholder="请选择" v-model="data"></Date-picker>'
});

Vue.component('rateCell', {
    props: {
        data: Object,
        disabled: false
    },
    //props:['data','disabled'],
    watch: {
        data: function (newValue) {
            this.$emit('change', newValue)
        }
    },
    template: '<div><Rate v-model="data" v-if="!disabled"></Rate><Rate v-model="data" v-if="disabled" disabled></Rate></div>'
});

Vue.component('radioGroupCell', {
    props: {
        data: Object,
        dataList: Array
    },
    mounted: function () {
        var dataDictionary = {};
        for (var i = 0; i < this.dataList.length; i++) {
            var entity = this.dataList[i];
            dataDictionary[entity.name] = entity.code;
        }
        ;
        this.dataDictionary = dataDictionary;
    },
    watch: {
        data: function (newValue) {
            this.$emit('change', newValue);
        }
    },
    template: '<RadioGroup v-model="data"><Radio v-for="item in dataList" :label="item.code">{{item.name}}</Radio></RadioGroup>'
});

Vue.component('radioCell', {
    props: {
        data: false,
        name: ""
    },
    watch: {
        data: function (newValue) {
            this.$emit('change', newValue);
        }
    },
    template: '<Radio v-model="data">{{name}}</Radio>'
});

Vue.component('checkboxGroupCell', {
    props: {
        data: Object,
        dataList: Array
    },
    mounted: function () {
        var dataDictionary = {};
        for (var i = 0; i < this.dataList.length; i++) {
            var entity = this.dataList[i];
            dataDictionary[entity.name] = entity.code;
        }
        ;
        this.dataDictionary = dataDictionary;
    },
    watch: {
        data: function (newValue) {
            if(typeof(newValue) == "boolean"){
                if(newValue){
                    newValue = [ this.$props.dataList[0].code ]
                }else{
                    newValue = []
                }
            }
            this.$emit('change', newValue);
        }
    },
    template: '<CheckboxGroup v-model="data"><Checkbox v-for="item in dataList" :label="item.code">{{item.name}}</Checkbox></CheckboxGroup>'
});

  • 8
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

*阿漓*

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值