12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- <template>
- <dg-table
- style="width: 100%"
- row-key="id"
- lazy
- border
- :data="table"
- :tree-props="treeProp"
- :load="load"
- :pagination="false"
- v-bind="$attrs"
- v-on="$listeners"
- >
- <template v-for="(item, indexs) in headerData">
- <dg-table-column :key="indexs" v-bind="item">
- <!-- <template v-if="item.state" slot-scope="scope">
- <span>{{ converterText(scope.row, item) }}</span>
- </template> -->
- </dg-table-column>
- </template>
- <slot />
- </dg-table>
- </template>
- <script>
- import * as api from "@/api/statistics-manage";
- export default {
- name: "lTreeTable",
- props: {
- url: {
- tpye: String,
- require: true
- },
- treeProp: {
- type: Object,
- default: () => ({
- hasChildren: "isParent",
- children: "children",
- isLeaf(data) {
- return data.isParent !== true;
- }
- })
- },
- headerData: {
- type: Array,
- default: () => []
- },
- searchForm: {
- type: Object,
- default: () => {}
- }
- },
- data() {
- return {
- table: []
- };
- },
- computed: {
- searchFormComputed() {
- return this.searchForm;
- }
- },
- methods: {
- load({ id, isParent, parent }, treeNode, resolve) {
- const { url } = this;
- this.searchFormComputed.isInit = false;
- this.searchFormComputed.orgId = id;
- if (isParent === true || parent === true) {
- api[url](this.searchFormComputed)
- .then(res => {
- resolve(res);
- })
- .catch(err => {
- resolve([]);
- });
- }
- }
- },
- created() {
- const that = this;
- const { url } = that;
- const { searchForm } = that;
- console.log(searchForm);
- api[url](searchForm || {})
- .then(res => {
- that.table = res;
- })
- .catch(err => {
- that.table = [];
- });
- }
- };
- </script>
|