|
|
@@ -2,24 +2,58 @@
|
|
|
<div id="tableList">
|
|
|
<div class="headerNavTool">
|
|
|
<div class="leftIndexText">
|
|
|
- {{navText.title}} <strong>{{navText.index}}</strong> 项
|
|
|
+ {{ navText.title }} <strong>{{ navText.index }}</strong> {{navText.ch}}
|
|
|
</div>
|
|
|
<div class="rightBtnBox">
|
|
|
- <el-button size="medium" type="primary" @click="addClick">新增</el-button>
|
|
|
+ <el-button size="medium" type="primary" @click="addClick"
|
|
|
+ >新增</el-button
|
|
|
+ >
|
|
|
<el-button size="medium" type="warning" @click="backFather"
|
|
|
>未定义</el-button
|
|
|
>
|
|
|
- <el-popover placement="bottom" trigger="click" title="勾选隐藏">
|
|
|
+ <el-popover
|
|
|
+ popper-class="slotPopper"
|
|
|
+ placement="bottom-end"
|
|
|
+ trigger="click"
|
|
|
+ >
|
|
|
<div class="popoverDis">
|
|
|
- <!-- <el-checkbox-group v-model="checkList"> -->
|
|
|
- <el-checkbox
|
|
|
- v-for="(item, index) in tableSet"
|
|
|
- :key="index"
|
|
|
- :checked="item.hidden"
|
|
|
- @change="getNewStatus(item, $event)"
|
|
|
- >{{ item.label }}</el-checkbox
|
|
|
+ <div class="checkboxHeader">
|
|
|
+ <el-checkbox
|
|
|
+ :indeterminate="isIndeterminate"
|
|
|
+ v-model="checkAll"
|
|
|
+ @change="handleCheckAllChange"
|
|
|
+ >列展示</el-checkbox
|
|
|
+ >
|
|
|
+ <div class="initbtns" @click="initVue">重置</div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div
|
|
|
+ style="height: 1px; width: 100%; background-color: #eaeefb"
|
|
|
+ ></div>
|
|
|
+ <el-checkbox-group
|
|
|
+ class="checkboxGroup"
|
|
|
+ v-model="checkedCities"
|
|
|
+ @change="handleCheckedCitiesChange"
|
|
|
>
|
|
|
- <!-- </el-checkbox-group> -->
|
|
|
+ <div
|
|
|
+ class="checkboxchild"
|
|
|
+ v-for="(item, index) in cities"
|
|
|
+ :key="index"
|
|
|
+ >
|
|
|
+ <el-checkbox
|
|
|
+ :label="item"
|
|
|
+ @change="checkboxChange(item, $event)"
|
|
|
+ >{{ item }}</el-checkbox
|
|
|
+ >
|
|
|
+ <div class="icon-right">
|
|
|
+ <i class="el-icon-upload2" @click="upMove(item, index)"></i>
|
|
|
+ <i
|
|
|
+ class="el-icon-download"
|
|
|
+ @click="downMove(item, index)"
|
|
|
+ ></i>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </el-checkbox-group>
|
|
|
</div>
|
|
|
<el-button style="margin-left: 10px" size="medium" slot="reference"
|
|
|
>自定义列</el-button
|
|
|
@@ -40,14 +74,24 @@
|
|
|
</el-table-column>
|
|
|
<template v-for="(item, index) in tableSet">
|
|
|
<el-table-column
|
|
|
- v-if="!item.hidden"
|
|
|
+ v-if="item.hidden"
|
|
|
:width="item.width"
|
|
|
:key="index"
|
|
|
:label="item.label"
|
|
|
align="center"
|
|
|
>
|
|
|
<template slot-scope="scope">
|
|
|
- <span>{{ scope.row[item.prop] }}</span>
|
|
|
+ <div class="imgboxsq" v-if="item.socpe === 'img'">
|
|
|
+ <!-- <img :src="scope.row[item.prop]" alt="" /> -->
|
|
|
+ <el-image
|
|
|
+ class="el_images"
|
|
|
+ style="width: 100%; height: 100%"
|
|
|
+ :src="scope.row[item.prop][0]"
|
|
|
+ :preview-src-list="scope.row[item.prop]"
|
|
|
+ >
|
|
|
+ </el-image>
|
|
|
+ </div>
|
|
|
+ <span v-else>{{ scope.row[item.prop] }}</span>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
</template>
|
|
|
@@ -62,25 +106,111 @@
|
|
|
|
|
|
<script>
|
|
|
export default {
|
|
|
- props: ["tableSet", "tableData","navText"],
|
|
|
+ props: ["tableSets", "tableData", "navText"],
|
|
|
data() {
|
|
|
return {
|
|
|
- allCheckData: [],
|
|
|
+ tableSet: this.tableSets,
|
|
|
+ allCheckData: [], //表格多选
|
|
|
+ checkAll: true,
|
|
|
+ checkedCities: [], //自定义列 选中数组
|
|
|
+ cities: [], //自定义列 总数组
|
|
|
+ isIndeterminate: false,
|
|
|
};
|
|
|
},
|
|
|
+ created() {
|
|
|
+ this.inittableSet = JSON.stringify(this.tableSet);
|
|
|
+ this.initTR();
|
|
|
+ },
|
|
|
methods: {
|
|
|
+ initTR() {
|
|
|
+ this.cities = [];
|
|
|
+ this.checkedCities = [];
|
|
|
+ this.checkAll = true;
|
|
|
+ this.isIndeterminate = false;
|
|
|
+ this.tableSet.forEach((item, index) => {
|
|
|
+ this.cities.push(item.label);
|
|
|
+ if (item.hidden) {
|
|
|
+ this.checkedCities.push(item.label);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if (this.checkedCities.length === 0) {
|
|
|
+ this.isIndeterminate = false;
|
|
|
+ } else if (this.checkedCities.length === this.cities.length) {
|
|
|
+ this.isIndeterminate = false;
|
|
|
+ this.checkAll = true;
|
|
|
+ } else {
|
|
|
+ this.isIndeterminate = true;
|
|
|
+ this.checkAll = false;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ handleCheckAllChange(val) {
|
|
|
+ this.checkedCities = val ? this.cities : [];
|
|
|
+ this.isIndeterminate = false;
|
|
|
+ if (val) {
|
|
|
+ this.tableSet.forEach((item, index) => {
|
|
|
+ item.hidden = true;
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ this.tableSet.forEach((item, index) => {
|
|
|
+ item.hidden = false;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
+ handleCheckedCitiesChange(value) {
|
|
|
+ let checkedCount = value.length;
|
|
|
+ this.checkAll = checkedCount === this.cities.length;
|
|
|
+ this.isIndeterminate =
|
|
|
+ checkedCount > 0 && checkedCount < this.cities.length;
|
|
|
+ },
|
|
|
+ checkboxChange(v, e) {
|
|
|
+ this.tableSet.forEach((item) => {
|
|
|
+ if (item.label === v) {
|
|
|
+ item.hidden = e;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ downMove(option, index) {
|
|
|
+ if (index !== this.tableSet.length - 1) {
|
|
|
+ this.tableSet[index] = this.tableSet.splice(
|
|
|
+ index + 1,
|
|
|
+ 1,
|
|
|
+ this.tableSet[index]
|
|
|
+ )[0];
|
|
|
+ this.cities[index] = this.cities.splice(
|
|
|
+ index + 1,
|
|
|
+ 1,
|
|
|
+ this.cities[index]
|
|
|
+ )[0];
|
|
|
+ } else {
|
|
|
+ this.tableSet.unshift(this.tableSet.splice(index, 1)[0]);
|
|
|
+ this.cities.unshift(this.cities.splice(index, 1)[0]);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ upMove(option, index) {
|
|
|
+ if (index != 0) {
|
|
|
+ this.tableSet[index] = this.tableSet.splice(
|
|
|
+ index - 1,
|
|
|
+ 1,
|
|
|
+ this.tableSet[index]
|
|
|
+ )[0];
|
|
|
+ this.cities[index] = this.cities.splice(
|
|
|
+ index - 1,
|
|
|
+ 1,
|
|
|
+ this.cities[index]
|
|
|
+ )[0];
|
|
|
+ } else {
|
|
|
+ this.tableSet.push(this.tableSet.shift());
|
|
|
+ this.cities.push(this.cities.shift());
|
|
|
+ }
|
|
|
+ },
|
|
|
//新增按钮
|
|
|
- addClick(){
|
|
|
- this.$emit('addClick')
|
|
|
+ addClick() {
|
|
|
+ this.$emit("addClick");
|
|
|
},
|
|
|
//将选中值传回调用组件
|
|
|
backFather() {
|
|
|
this.$emit("emitData", this.allCheckData);
|
|
|
},
|
|
|
- //自定义列 选中触发
|
|
|
- getNewStatus(options, e) {
|
|
|
- options.hidden = e;
|
|
|
- },
|
|
|
edit() {},
|
|
|
selectAll(value) {
|
|
|
this.allCheckData = value;
|
|
|
@@ -88,10 +218,20 @@ export default {
|
|
|
select(value) {
|
|
|
this.allCheckData = value;
|
|
|
},
|
|
|
+ //重置
|
|
|
+ initVue() {
|
|
|
+ this.$emit("initTableset");
|
|
|
+ this.tableSet = JSON.parse(this.inittableSet);
|
|
|
+ this.initTR();
|
|
|
+ },
|
|
|
},
|
|
|
};
|
|
|
</script>
|
|
|
-
|
|
|
+<style lang="less">
|
|
|
+.slotPopper {
|
|
|
+ padding: 0px!important;
|
|
|
+}
|
|
|
+</style>
|
|
|
<style lang="less" scoped>
|
|
|
#tableList {
|
|
|
padding: 0px 16px 16px;
|
|
|
@@ -113,5 +253,62 @@ export default {
|
|
|
display: flex;
|
|
|
flex-direction: column;
|
|
|
align-items: flex-start;
|
|
|
+ font-size: 14px;
|
|
|
+ .checkboxHeader {
|
|
|
+ height: 40px;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: space-between;
|
|
|
+ padding-left: 13px;
|
|
|
+ padding-right: 15px;
|
|
|
+ width: 100%;
|
|
|
+ .initbtns {
|
|
|
+ color: #47a6ff;
|
|
|
+ cursor: pointer;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .checkboxGroup {
|
|
|
+ display: flex;
|
|
|
+ flex-direction: column;
|
|
|
+ width: 100%;
|
|
|
+ .checkboxchild {
|
|
|
+ width: 100%;
|
|
|
+ justify-content: space-between;
|
|
|
+ height: 40px;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ padding: 0px 15px 0px 13px;
|
|
|
+ transition: all 0.4s;
|
|
|
+ &:hover {
|
|
|
+ background-color: #ecf5ff;
|
|
|
+ }
|
|
|
+ &:hover .icon-right {
|
|
|
+ display: flex;
|
|
|
+ }
|
|
|
+ .icon-right {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ width: 30px;
|
|
|
+ height: 30px;
|
|
|
+ color: #666;
|
|
|
+ font-size: 14px;
|
|
|
+ display: none;
|
|
|
+ i {
|
|
|
+ cursor: pointer;
|
|
|
+ margin: 0px 3px;
|
|
|
+ &:hover {
|
|
|
+ color: #47a6ff;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+/deep/.el-checkbox__input.is-checked + .el-checkbox__label {
|
|
|
+ color: #666;
|
|
|
+}
|
|
|
+.imgboxsq {
|
|
|
+ max-height: 100px;
|
|
|
}
|
|
|
</style>
|
|
|
+
|