123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244 |
- <template>
-
- -<el-table-column align='center' v-if="$slots.default || $scopedSlots.default" :label="name" :width="width" :min-width="minWidth">
- <template slot-scope="s">
- <slot :row="s.row" :index="s.index"></slot>
- </template>
- </el-table-column>
-
- -<el-table-column align='center' v-else-if="type == 'selection'" type="selection" width="45px" :min-width="minWidth"></el-table-column>
-
- -<el-table-column align='center' v-else-if="type == 'text'" :label="name" :width="width" :min-width="minWidth">
- <template slot-scope="s">
- <span v-if="s.row[prop]">{{s.row[prop]}}</span>
- <span v-else>{{not}}</span>
- </template>
- </el-table-column>
- -<el-table-column align='center' v-else-if="type == 'index'" type="index" :label="name" :width="width || '60px'" :min-width="minWidth"></el-table-column>
-
- -<el-table-column align='center' v-else-if="type == 'num'" :label="name" :width="width" :min-width="minWidth" class-name="tc-num">
- <template slot-scope="s">
- <span v-if="s.row[prop]">{{s.row[prop]}}</span>
- <span v-else>{{not}}</span>
- </template>
- </el-table-column>
-
- -<el-table-column align='center' v-else-if="type == 'icon'" :label="name" :width="width" :min-width="minWidth">
- <template slot-scope="s">
- <i v-if="s.row[prop]" :class="s.row[prop]" style="font-size: 1.3em;"></i>
- <span v-else>{{not}}</span>
- </template>
- </el-table-column>
-
- -<el-table-column align='center' v-else-if="type == 'img'" :label="name" :width="width" :min-width="minWidth">
- <template slot-scope="s">
- <img v-if="s.row[prop]" :src="s.row[prop]" class="td-img" @click="sa.showImage(s.row[prop], '400px', '400px')" />
- <span v-else>{{not}}</span>
- </template>
- </el-table-column>
-
- -<el-table-column align='center' v-else-if="type == 'audio' || type == 'video' || type == 'file'" :label="name" :width="width" :min-width="minWidth">
- <template slot-scope="s">
- <el-link type="info" :href="s.row[prop]" target="_blank" v-if="!sa.isNull(s.row[prop])">预览</el-link>
- <span v-else>{{not}}</span>
- </template>
- </el-table-column>
-
- -<el-table-column align='center' v-else-if="type == 'img-list'" :label="name" :width="width" :min-width="minWidth || '120px'" show-overflow-tooltip>
- <template slot-scope="s">
- <div @click="sa.showImageList(value_to_arr(s.row[prop]))" style="cursor: pointer;" v-if="s.row[prop]">
- <img :src="value_to_arr(s.row[prop])[0]" class="td-img" />
- </div>
- <div v-else>{{not}}</div>
- </template>
- </el-table-column>
-
- -<el-table-column align='center' v-else-if="type == 'audio-list' || type == 'video-list' || type == 'file-list' || type == 'img-video-list'" :label="name" :width="width" :min-width="minWidth">
- <template slot-scope="s">
- <span v-if="s.row[prop]" style="color: #666;">共 {{value_to_arr(s.row[prop]).length}} 个</span>
- <span v-else>{{not}}</span>
- </template>
- </el-table-column>
-
-
- -<el-table-column align='center' v-else-if="type == 'textarea'" :label="name" :width="width" :min-width="minWidth" show-overflow-tooltip>
- <template slot-scope="s">
- <span v-if="s.row[prop]">{{sa.maxLength(s.row[prop], 100)}}</span>
- <span v-else>{{not}}</span>
- </template>
- </el-table-column>
-
- -<el-table-column align='center' v-else-if="type == 'richtext' || type == 'f'" :label="name" :width="width" :min-width="minWidth" show-overflow-tooltip>
- <template slot-scope="s">
- <span>{{sa.maxLength(sa.text(s.row[prop]), 100)}}</span>
- </template>
- </el-table-column>
-
- -<el-table-column align='center' v-else-if="type == 'link'" :label="name" :width="width" :min-width="minWidth">
- <template slot-scope="s">
- <el-link type="primary" :href="s.row[prop]" target="_blank" v-if="!sa.isNull(s.row[prop])">{{s.row[prop]}}</el-link>
- <div v-else>-</div>
- </template>
- </el-table-column>
-
- -<el-table-column align='center' v-else-if="type == 'link-btn'" :label="name" :width="width" :min-width="minWidth">
- <template slot-scope="s">
- <el-link type="primary" @click="$emit('click', s)" v-if="!sa.isNull(s.row[prop])">{{s.row[prop]}}</el-link>
- <div v-else>-</div>
- </template>
- </el-table-column>
-
-
- -<el-table-column align='center' v-else-if="type == 'money'" :label="name" :width="width" :min-width="minWidth">
- <template slot-scope="s">
- <b class="c-price" v-if="!sa.isNull(s.row[prop])">¥{{s.row[prop]}}</b>
- <div v-else>-</div>
- </template>
- </el-table-column>
-
- -<el-table-column align='center' v-else-if="type == 'money-f'" :label="name" :width="width" :min-width="minWidth">
- <template slot-scope="s">
- <b class="c-price" v-if="!sa.isNull(s.row[prop])">¥{{s.row[prop] / 100}}</b>
- <div v-else>-</div>
- </template>
- </el-table-column>
-
- -<el-table-column align='center' v-else-if="type == 'enum' || type == 'j'" :label="name" :width="width" :min-width="minWidth">
- <template slot-scope="s">
- <b v-for="j in jvList" :key="j.key" :style="{color: j.color || '#606266'}" v-if="s.row[prop] == j.key">{{j.value}}</b>
- </template>
- </el-table-column>
-
- -<el-table-column align='center' v-else-if="type == 'switch'" :label="name" :width="width" :min-width="minWidth">
- <template slot-scope="s">
- <el-switch
- v-model="s.row[prop]" v-if='jvList.length >= 2'
- :active-value="jvList[0].key" :inactive-value="jvList[1].key"
- :active-color="jvList[0].color || '#409EFF'" :inactive-color="jvList[1].color || '#ccc'"
- @change="$emit('change', s)">
- </el-switch>
- <span v-for="j in jvList" :key="j.key" :style="{color: '#999'}" v-if="s.row[prop] == j.key">{{j.value}}</span>
- </template>
- </el-table-column>
-
- -<el-table-column align='center' v-else-if="type == 'rate'" :label="name" :width="width" :min-width="minWidth">
- <template slot-scope="s">
- <el-rate :value="s.row[prop] <= 5 ? s.row[prop] : 5" show-text disabled v-if="!sa.isNull(s.row[prop])"></el-rate>
- <div v-else>-</div>
- </template>
- </el-table-column>
-
- -<el-table-column align='center' v-else-if="type == 'date'" :label="name" :width="width" :min-width="minWidth" class-name="tc-date">
- <template slot-scope="s"><span>{{sa.forDate(s.row[prop]) || not}}</span></template>
- </el-table-column>
-
- -<el-table-column align='center' v-else-if="type == 'datetime'" :label="name" :width="width" :min-width="minWidth" class-name="tc-date">
- <template slot-scope="s"><span>{{sa.forDate(s.row[prop], 2) || not}}</span></template>
- </el-table-column>
-
- -<el-table-column align='center' v-else-if="type == 'time'" :label="name" :width="width" :min-width="minWidth" class-name="tc-date">
- <template slot-scope="s"><span>{{s.row[prop] || not}}</span></template>
- </el-table-column>
-
- -<el-table-column align='center' v-else-if="type == 'user-avatar'" :label="name" :width="width" :min-width="minWidth">
- <template slot-scope="s">
- <img :src="s.row[prop.split(',')[1]]" class="td-img"
- style="vertical-align: middle; margin-right: 5px;"
- @click="sa.showImage(s.row[prop.split(',')[1]], '400px', '400px')" />
- <b>{{s.row[prop.split(',')[0]]}}</b>
- </template>
- </el-table-column>
- </template>
- <script>
- module.exports = {
-
- props: {
-
- type: {
- default: 'text'
- },
-
- name: {},
- label: {},
-
- prop: {},
-
- width: {},
-
- minWidth: {},
-
- jv: {default: ''},
-
- not: {default: '-'}
- },
- data() {
- return {
-
- jvList: [],
-
-
- value_arr: [],
-
- }
- },
- methods: {
-
- parseJv: function() {
- for(let key in this.jv) {
- let value = this.jv[key];
- let color = '';
-
- if(value.indexOf('[') != -1 && value.endsWith(']')) {
- let index = value.indexOf('[');
- color = value.substring(index + 1, value.length - 1);
- value = value.substring(0, index);
-
- }
-
- if(isNaN(key) == false) {
- key = parseInt(key);
- }
-
- this.jvList.push({
- key: key,
- value: value,
- color: color
- })
- }
- },
-
- value_to_arr: function(value) {
- var value_arr = sa.isNull(value) ? [] : value.split(',');
- for (var i = 0; i < value_arr.length; i++) {
- if(value_arr[i] == '' || value_arr[i].trim() == '') {
- sa.arrayDelete(value_arr, value_arr[i]);
- i--;
- }
- }
-
-
-
-
- return value_arr;
- },
- },
- mounted() {
-
-
-
- this.name = this.name || this.label;
-
- if(this.type == 'enum' || this.type == 'j' || this.type == 'switch') {
- this.parseJv();
- }
-
-
-
-
- }
- }
- </script>
- <style scoped>
- </style>
|