rt-sim-training-client/src/views/components/limits/index.vue

130 lines
4.0 KiB
Vue
Raw Normal View History

2019-07-26 13:32:43 +08:00
<template>
2019-08-13 11:10:55 +08:00
<div>
<el-table
:data="dataPostProcessor(courseModel.pmsList)"
border
:summary-method="getSummaries"
show-summary
2020-11-13 13:31:44 +08:00
style="width: 100%; margin-top: 20px;"
2019-08-13 11:10:55 +08:00
>
<el-table-column prop="index" :label="`${$t('global.index')}`" />
2019-11-11 14:08:54 +08:00
<el-table-column prop="startTime" :label="`${$t('permission.startTime')}`" />
<el-table-column prop="endTime" :label="`${$t('permission.endTime')}`">
2019-08-13 11:10:55 +08:00
<template slot-scope="scope">
2019-11-11 18:42:14 +08:00
<span>{{ scope.row.endTime? scope.row.endTime: $t('global.perpetual') }}</span>
2019-08-13 11:10:55 +08:00
</template>
</el-table-column>
<el-table-column prop="amount" :label="$t('global.permissionAllNum')" />
2019-08-13 11:15:39 +08:00
<el-table-column prop="remains" :label="$t('global.remains')" />
2019-08-13 11:10:55 +08:00
<el-table-column prop="canDistribute" :label="$t('global.status')" width="100">
<template slot-scope="scope">
2019-11-11 14:08:54 +08:00
<el-tag :type="scope.row.canDistribute == true ? 'success':'danger'" disable-transitions>
2019-08-13 11:10:55 +08:00
{{ computedName(scope.row.canDistribute, 'PermissionUseList') }}</el-tag>
</template>
</el-table-column>
</el-table>
<distribute-draft ref="distribute" @QrCodeShow="QrCodeShow" @initLoadPage="initLoadPage" />
<qr-code ref="qrCode" />
</div>
2019-07-26 13:32:43 +08:00
</template>
<script>
2019-08-13 11:10:55 +08:00
import DistributeDraft from './distribute';
import QrCode from '@/components/QrCode';
2019-07-26 13:32:43 +08:00
2019-08-13 11:10:55 +08:00
export default {
2019-11-01 13:51:00 +08:00
name: 'LimitList',
components: {
DistributeDraft,
QrCode
},
props: {
courseModel: {
type: Object,
required: true
}
},
data() {
return {
};
},
mounted() {
},
methods: {
computedName(prop, listType) {
return this.$ConstSelect.translate(prop, listType);
},
initLoadPage() {
this.$emit('initLoadPage');
},
dataPostProcessor(data) {
let index = 0;
if (data && data.length) {
data.map(elem => {
elem.index = ++index;
});
}
return data;
},
getSummaries(param) {
const { columns, data } = param;
const sums = [];
const needSumPropertys = ['remains', 'total'];
columns.forEach((column, index) => {
if (index === 0) {
sums[index] = this.$t('global.total');
return;
}
needSumPropertys.forEach(property => {
if (property === column.property) {
const values = data.map(item => Number(item[property]));
if (!values.every(value => isNaN(value))) {
let allow = 0; let notAllow = 0;
data.forEach((item) => {
if (item.canDistribute) {
allow = allow + Number(item.remains);
} else {
notAllow = notAllow + Number(item.remains);
}
});
sums[index] = this.$t('global.hasPermissionTip').replace('{0}', allow).replace('{1}', notAllow);
}
}
});
if (!sums[index]) {
sums[index] = '-';
}
});
return sums;
},
distribute(courseModel) { // 分发
if (this.$refs) {
this.$refs.distribute.doShow(courseModel);
}
},
QrCodeShow(data) {
if (this.$refs && data) {
this.$refs.qrCode.doShow(data);
}
}
}
2019-08-13 11:10:55 +08:00
};
2019-07-26 13:32:43 +08:00
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
@import "src/styles/mixin.scss";
.menu li {
border-right: solid white 1px;
}
ul {
line-height: 22px;
margin: 5px;
}
.noList {
text-align: center;
padding-top: 20px;
font-size: 20px;
}
2019-08-13 11:10:55 +08:00
</style>