| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267 |
- <!--
- * @Title:
- * @Description:
- * @Author: swp
- * @Date: 2022-08-24 10:49:21
- * @LastEditors:
- * @LastEditTime: 2022-08-24 10:49:21
- -->
- <template>
- <div>
- <el-row>
- <el-col :span="4">
- <div class="box">
- <el-scrollbar>
- <basic-container>
- <avue-tree :option="treeOption" :data="treeData" @node-click="nodeClick">
- <span class="el-tree-node__label" slot-scope="{ node, data }">
- <span>
- <i class="el-icon-office-building"></i>
- {{ (node || {}).label }}
- </span>
- </span>
- </avue-tree>
- </basic-container>
- </el-scrollbar>
- </div>
- </el-col>
- <el-col :span="20">
- <basic-container>
- <avue-crud :option="option" :table-loading="loading" :data="data" :page.sync="page"
- :before-open="beforeOpen" ref="crud" v-model="form" :permission="permissionList" @row-del="rowDel"
- @row-update="rowUpdate" @row-save="rowSave" @search-change="searchChange"
- @search-reset="searchReset" @selection-change="selectionChange" @current-change="currentChange"
- @size-change="sizeChange" @refresh-change="refreshChange" @on-load="onLoad"
- @select-change="selectChange">
- </avue-crud>
- </basic-container>
- </el-col>
- </el-row>
- </div>
- </template>
- <script>
- import { getPage, } from "@/api/data/dataRsvr.js";
- import { getTree } from "@/api/baseinfo/region.js";
- export default {
- components: {
- },
- data() {
- return {
- id: "",
- form: {},
- selectionList: [],
- query: {},
- sort: {},
- loading: true,
- page: {
- pageSize: 10,
- currentPage: 1,
- total: 0,
- },
- treeCode: '',
- treeParentCode: '',
- treeData: [],
- treeOption: {
- nodeKey: "id",
- defaultExpandedKeys: [],
- lazy: false,
- // treeLoad: function (node, resolve) {
- // const parentCode = (node.level === 0) ? "00" : node.data.value;
- // getLazyTree(parentCode).then(res => {
- // resolve(res.data.data.map(item => {
- // return {
- // ...item,
- // leaf: !item.hasChildren
- // }
- // }))
- // });
- // },
- addBtn: false,
- menu: true,
- size: "small",
- props: {
- labelText: "标题",
- label: "title",
- value: "value",
- children: "children",
- },
- },
- option: {
- labelWidth: 120,
- viewLabelWidth: 100,
- searchlabelWidth: 100,
- height: "auto",
- calcHeight: 80,
- align: "center",
- headerAlign: "center",
- lazy: false,
- tip: false,
- simplePage: true,
- searchShow: true,
- searchMenuSpan: 6,
- tree: true,
- border: true,
- index: true,
- selection: false,
- viewBtn: false,
- viewTitle: "测站信息",
- editBtn: false,
- delBtn: false,
- addBtn: false,
- menu: false,
- dialogType: "drawer",
- dialogClickModal: false,
- columnBtn: false,
- column: [
- {
- label: "站点编码",
- prop: "rtuCode",
- search: true,
- span: 24,
- width: 120,
- },
- {
- label: "站点名称",
- prop: "rtuName",
- search: true,
- span: 24,
- width: 160,
- },
- {
- label: "行政区",
- prop: "adCity",
- span: 12,
- editDisplay: false,
- addDisplay: false,
- html: true,
- formatter: (val) => {
- if (val.adCity && val.adDist) {
- return '<b>' + val.adCity + '</b>/' + '<b>' + val.adDist + '</b>'
- } else {
- return '<b>' + val.adCity + '</b>'
- }
- }
- },
- {
- label: "上报时间",
- prop: "tm",
- span: 8,
- },
- {
- label: "库上水位",
- prop: "rz",
- span: 8,
- formatter: (val) => {
- if (val.rz != null) {
- return val.rz;
- } else {
- return "";
- }
- }
- },
- ],
- },
- data: [],
- };
- },
- computed: {
- // ...mapGetters(["userInfo", "permission"]),
- permissionList() {
- return {
- // addBtn: this.vaildData(this.permission.docCategory_add, false),
- // viewBtn: this.vaildData(this.permission.docCategory_view, false),
- // delBtn: this.vaildData(this.permission.docCategory_delete, false),
- // editBtn: this.vaildData(this.permission.docCategory_edit, false),
- };
- },
- ids() {
- let ids = [];
- this.selectionList.forEach((ele) => {
- ids.push(ele.id);
- });
- return ids.join(",");
- },
- },
- mounted() { },
- created() {
- this.initTree();
- },
- methods: {
- initTree() {
- this.treeData = [];
- getTree().then(res => {
- this.treeData = res.data.data.map(item => {
- return {
- ...item,
- leaf: !item.hasChildren
- }
- })
- this.treeOption.defaultExpandedKeys.push(this.treeData[0].id);
- this.treeCode = this.treeData[0].id;
- });
- },
- nodeClick(data) {
- this.treeCode = data.id;
- this.treeParentCode = data.parentId;
- this.query = {};
- this.query['adCode'] = this.treeCode;
- this.page.currentPage = 1;
- var params = {};
- this.onLoad(this.page, params);
- },
- searchReset() {
- // this.query = {};
- // this.query['adCode'] = this.treeCode;
- this.page.currentPage = 1;
- this.onLoad(this.page);
- },
- searchChange(params, done) {
- // this.query = params;
- this.page.currentPage = 1;
- this.onLoad(this.page, params);
- done();
- },
- selectionChange(list) {
- this.selectionList = list;
- },
- selectChange(item) {
- this.$message.success("" + item)
- },
- selectionClear() {
- this.selectionList = [];
- this.$refs.crud.toggleSelection();
- },
- currentChange(currentPage) {
- this.page.currentPage = currentPage;
- },
- sizeChange(pageSize) {
- this.page.pageSize = pageSize;
- },
- refreshChange() {
- var params = {};
- this.onLoad(this.page, params);
- },
- onLoad(page, params = {}) {
- this.loading = true;
- getPage(
- page.currentPage,
- page.pageSize,
- Object.assign(params, this.sort, this.query)
- ).then((res) => {
- const data = res.data.data;
- this.page.total = data.total;
- this.data = data.records;
- this.loading = false;
- this.selectionClear();
- });
- },
- },
- };
- </script>
|