123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167 |
- <template>
- <div
- v-loading="loading"
- class="security-check-table-wrapper"
- :style="{ height: tableWrapperHeight }"
- >
- <a-table
- ref="table"
- :data-source="tableData"
- :columns="tableCols"
- stripeed
- fited
- bordered
- height="100%"
- >
- <template v-if="withSelection">
- <a-table-column type="selection" width="35" />
- </template>
- <template v-for="col in cols">
- <NestTableColumn :key="col.prop" :col="col" />
- </template>
- <template v-if="withOperateColumn">
- <a-table-column label="操作" class-name="column-operate" :width="130">
- <template slot-scope="scope">
- <span class="cell-operate-edit" @click="editRow(scope.row)"
- >修改</span
- >
- <span class="cell-operate-delete" @click="deleteRow(scope.row)"
- >删除</span
- >
- </template>
- </a-table-column>
- </template>
- </a-table>
- </div>
- </template>
- <script>
- import NestTableColumn from "./nestTableColumn.vue";
- export default {
- name: "SecurityCheckTable",
- components: { NestTableColumn },
- props: {
- height: {
- type: [Number, String],
- default: "50vh",
- },
- tableCols: {
- type: Array,
- default: () => [],
- },
- tableData: {
- type: Array,
- default: () => [],
- },
- withSelection: {
- type: Boolean,
- default: false,
- },
- showSummary: {
- type: Boolean,
- default: false,
- },
- withOperateColumn: {
- type: Boolean,
- default: false,
- },
- },
- data() {
- return {
- loading: false,
- cols: [],
- data: [],
- };
- },
- computed: {
- tableWrapperHeight() {
- return typeof this.height === "number" ? this.height + "px" : this.height;
- },
- },
- watch: {
- tableCols: {
- handler(val) {
- this.cols = val;
- },
- deep: true,
- immediate: true,
- },
- tableData: {
- handler(val) {
- this.data = val;
- },
- deep: true,
- immediate: true,
- },
- },
- updated() {
- this.$refs["table"].doLayout();
- },
- methods: {
- editRow(row) {
- console.log("edit");
- },
- deleteRow(row) {
- console.log("delete");
- },
- },
- };
- </script>
- <style lang="scss" scoped>
- .security-check-table-wrapper {
- width: 100%;
- ::v-deep .ant-table-column-title {
- font-size: 14px;
- font-family: Helvetica, "Microsoft YaHei";
- color: #101116;
- font-weight: bold;
- }
- ::v-deep .ant-table {
- width: 100%;
- .ant-table__cell {
- .cell {
- // padding: 0 19px;
- font-size: 14px;
- font-family: Helvetica, "Microsoft YaHei";
- color: #101116;
- }
- &.ant-table-column--selection .cell {
- padding: 0;
- text-align: center;
- }
- }
- .ant-table__header {
- .ant-table__cell {
- > .cell {
- font-weight: bold;
- }
- &:not(.is-leaf) > .cell {
- text-align: center;
- }
- }
- }
- .ant-table__body {
- .cell .cell-click {
- color: #2d67e3;
- cursor: pointer;
- }
- .column-operate .cell {
- span {
- cursor: pointer;
- &:not(:last-child) {
- margin-right: 25px;
- }
- &.cell-operate-edit {
- color: #2d67e3;
- }
- &.cell-operate-delete {
- color: #ea4545;
- }
- }
- }
- }
- }
- }
- </style>
|