fsuTable.vue 7.82 KB
Newer Older
neogcg's avatar
neogcg committed
1 2 3 4 5 6
<template>
  <div>
    <div class="leakage-top">
      <div style="color: #666666"></div>

      <div class="operate-btn">
yanzhongrong's avatar
yanzhongrong committed
7
        <delids :multipleSelection2="multipleSelection" @del="del()">删除</delids>
neogcg's avatar
neogcg committed
8
        <el-button type="primary" @click="refresh">刷新</el-button>
neogcg's avatar
neogcg committed
9
        <el-button type="primary" @click="block = !block">查询</el-button>
neogcg's avatar
neogcg committed
10 11
        <el-button type="primary" @click="exportData">导出</el-button>
      </div>
neogcg's avatar
neogcg committed
12
    </div>
neogcg's avatar
neogcg committed
13 14 15 16 17 18 19 20
    <el-form
      class="search-div"
      v-if="block"
      :model="FSUForm"
      :inline="true"
      size="mini"
    >
      <el-form-item label="设备名称:">
neogcg's avatar
neogcg committed
21 22 23 24 25 26
        <el-input
          placeholder="请输入设备名称"
          v-model="FSUForm.equipName"
          clearable
        >
        </el-input>
neogcg's avatar
neogcg committed
27 28
      </el-form-item>
      <el-form-item label="FSU身份编号:">
neogcg's avatar
neogcg committed
29 30 31 32 33 34
        <el-input
          placeholder="请输入FSU身份编号"
          v-model="FSUForm.fsuCode"
          clearable
        >
        </el-input>
neogcg's avatar
neogcg committed
35 36 37
      </el-form-item>
      <el-form-item label="IP地址:">
        <el-input placeholder="请输入IP地址" v-model="FSUForm.ip" clearable>
neogcg's avatar
neogcg committed
38
        </el-input>
neogcg's avatar
neogcg committed
39 40
      </el-form-item>
      <el-form-item label="所在铁路线:">
neogcg's avatar
neogcg committed
41 42
        <el-select
          placeholder="请选择所在铁路线"
neogcg's avatar
neogcg committed
43
          v-model="FSUForm.wayId"
neogcg's avatar
neogcg committed
44 45 46
          clearable
          @change="changerailWay()"
        >
neogcg's avatar
neogcg committed
47
          <el-option
neogcg's avatar
neogcg committed
48 49 50 51 52 53
            v-for="item in railWaySelect"
            :key="item.id"
            :label="item.name"
            :value="item.id"
          ></el-option>
        </el-select>
neogcg's avatar
neogcg committed
54 55
      </el-form-item>
      <el-form-item label="所在站点:">
neogcg's avatar
neogcg committed
56 57 58 59 60
        <el-select
          placeholder="请选择所在站点"
          v-model="FSUForm.siteId"
          clearable
        >
neogcg's avatar
neogcg committed
61
          <el-option
neogcg's avatar
neogcg committed
62 63 64 65 66 67
            v-for="item in stationSelect2"
            :key="item.id"
            :label="item.siteName"
            :value="item.id"
          ></el-option>
        </el-select>
neogcg's avatar
neogcg committed
68 69
      </el-form-item>
      <el-form-item>
neogcg's avatar
neogcg committed
70 71
        <el-button type="success" @click="searchQuery()">查询</el-button>
        <el-button type="primary" @click="reset">重置</el-button>
neogcg's avatar
neogcg committed
72 73
      </el-form-item>
    </el-form>
neogcg's avatar
neogcg committed
74 75 76 77 78 79
    <el-table
      ref="multipleTable"
      class="statistics-table"
      :data="tableData"
      tooltip-effect="dark"
      style="width: 100%"
yanzhongrong's avatar
yanzhongrong committed
80
      height="100%"
neogcg's avatar
neogcg committed
81 82 83 84 85 86 87 88 89 90 91
      :row-class-name="tableRowClassName"
      :row-style="{ height: '50px' }"
      :header-cell-style="{
        background: '#eaf1fe',
        color: '#000',
        fontWeight: 700,
        height: '50px',
      }"
      @selection-change="handleSelectionChange"
    >
      <el-table-column type="selection" width="55" align="center" />
neogcg's avatar
neogcg committed
92
      <el-table-column prop="equipName" label="设备名称" align="center" />
neogcg's avatar
neogcg committed
93 94 95 96 97 98
      <el-table-column
        prop="fsuCode"
        label="FSU身份编号"
        show-overflow-tooltip
        align="center"
      />
neogcg's avatar
neogcg committed
99
      <el-table-column
neogcg's avatar
neogcg committed
100 101 102 103
        prop="ip"
        label="IP地址"
        show-overflow-tooltip
        align="center"
neogcg's avatar
neogcg committed
104
      />
neogcg's avatar
neogcg committed
105
      <el-table-column prop="railWayName" label="所在铁路线" align="center" />
neogcg's avatar
neogcg committed
106
      <el-table-column
neogcg's avatar
neogcg committed
107
        prop="siteName"
neogcg's avatar
neogcg committed
108
        label="所在站点"
neogcg's avatar
neogcg committed
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
        show-overflow-tooltip
        align="center"
      />
      <el-table-column
        prop="action"
        label="详细信息"
        show-overflow-tooltip
        align="center"
      >
        <template slot-scope="{ row }">
          <el-link type="primary" :underline="false" @click="handleView(row)"
            >查看</el-link
          >
        </template>
      </el-table-column>
    </el-table>
neogcg's avatar
neogcg committed
125

yanzhongrong's avatar
yanzhongrong committed
126 127
    <Pagination
      :limit="FSUForm.size"
neogcg's avatar
neogcg committed
128
      :page="FSUForm.current"
neogcg's avatar
neogcg committed
129 130 131 132 133 134 135
      :total="total"
      class="pagination"
      @pagination="handlePageChange"
    />
  </div>
</template>
<script>
neogcg's avatar
neogcg committed
136 137 138 139 140 141 142
import {
  fsulist,
  fsubatchDelete,
  fsudetail,
  railWaylist,
  selectForSite,
} from "../../api";
neogcg's avatar
neogcg committed
143
import { successAlert, warningAlert } from "@/utils/alert";
neogcg's avatar
neogcg committed
144 145
import download from "@/utils/download";
import { exportFsu } from "@/api/export";
neogcg's avatar
neogcg committed
146 147
export default {
  props: [],
yanzhongrong's avatar
yanzhongrong committed
148
  components: {},
neogcg's avatar
neogcg committed
149 150
  data() {
    return {
neogcg's avatar
neogcg committed
151
      railWaySelect: [],
neogcg's avatar
neogcg committed
152 153
      stationSelect: [],
      stationSelect2: [],
neogcg's avatar
neogcg committed
154 155
      FSUForm: formInit(),

neogcg's avatar
neogcg committed
156
      visible: false,
neogcg's avatar
neogcg committed
157 158
      tableData: [],
      params: {
neogcg's avatar
neogcg committed
159 160
        current: 1,
        size: 10,
neogcg's avatar
neogcg committed
161 162 163 164
      },
      total: 10,
      multipleSelection: [],
      ids: [],
neogcg's avatar
neogcg committed
165
      block: 0,
neogcg's avatar
neogcg committed
166
      istrue: 0,
neogcg's avatar
neogcg committed
167
      exids: [],
neogcg's avatar
neogcg committed
168 169
    };
  },
neogcg's avatar
neogcg committed
170
  computed: {},
neogcg's avatar
neogcg committed
171
  methods: {
neogcg's avatar
neogcg committed
172
    changerailWay() {
neogcg's avatar
neogcg committed
173 174 175
      selectForSite({ wayId: this.FSUForm.wayId }).then((res) => {
        this.stationSelect2 = res;
      });
neogcg's avatar
neogcg committed
176
    },
neogcg's avatar
neogcg committed
177 178 179 180 181 182
    tableRowClassName({ row, rowIndex }) {
      return rowIndex % 2 === 0 ? "" : "single-row";
    },
    changeType(item) {
      this.activeName = item.key;
    },
neogcg's avatar
neogcg committed
183
    del() {
neogcg's avatar
neogcg committed
184
      let ids = this.ids;
neogcg's avatar
neogcg committed
185
      fsubatchDelete({ ids }).then((res) => {
neogcg's avatar
neogcg committed
186
        if (res.code == 200) {
neogcg's avatar
neogcg committed
187
          successAlert("删除成功");
neogcg's avatar
neogcg committed
188

neogcg's avatar
neogcg committed
189
          this.getTableData();
neogcg's avatar
neogcg committed
190 191
        } else {
          warningAlert("删除失败");
neogcg's avatar
neogcg committed
192 193
        }
      });
neogcg's avatar
neogcg committed
194 195
    },
    refresh() {
neogcg's avatar
neogcg committed
196
      this.reset();     
neogcg's avatar
neogcg committed
197
    },
neogcg's avatar
neogcg committed
198
    searchQuery() {
neogcg's avatar
neogcg committed
199
      this.istrue = 1;
neogcg's avatar
neogcg committed
200 201 202
      this.getTableData();
    },
    reset() {
neogcg's avatar
neogcg committed
203
      this.FSUForm = formInit();
neogcg's avatar
neogcg committed
204
      this.searchQuery();
neogcg's avatar
neogcg committed
205
    },
neogcg's avatar
neogcg committed
206
    exportData() {
neogcg's avatar
neogcg committed
207 208
      // let ids = [];
      // this.ids.length != 0 ? (ids = this.ids) : (ids = this.exids);
neogcg's avatar
neogcg committed
209 210 211 212
       if (this.exids.length == 0) {
        this.$message.warning("暂无数据");
        return false;
      } else {
neogcg's avatar
neogcg committed
213 214 215
      exportFsu({ ids: this.exids }).then((res) => {
        download(res, "vnd.ms-excel", `FSU表.xls`);
      });
neogcg's avatar
neogcg committed
216
      }
neogcg's avatar
neogcg committed
217
    },
neogcg's avatar
neogcg committed
218 219 220 221 222 223
    handleSelectionChange(val) {
      this.multipleSelection = val;

      this.ids = this.multipleSelection.map((i) => i.id);
    },
    handleView(row) {
neogcg's avatar
neogcg committed
224 225 226 227 228 229 230
      this.$router.push({
        path: "/detail",
        query: {
          id: row.id,
          type: 3,
        },
      });
neogcg's avatar
neogcg committed
231 232
    },
    handlePageChange(pageData) {
yanzhongrong's avatar
yanzhongrong committed
233
      this.FSUForm.size = pageData.size;
neogcg's avatar
neogcg committed
234
      this.FSUForm.current = pageData.page;
neogcg's avatar
neogcg committed
235 236 237
      this.getTableData();
    },
    getTableData() {
neogcg's avatar
neogcg committed
238
      fsulist(this.FSUForm).then((res) => {
neogcg's avatar
neogcg committed
239 240 241
        let list = res.records || [];
        this.tableData = list;
        this.total = res.total;
neogcg's avatar
neogcg committed
242
        this.exids = list.map((i) => i.id);
yanzhongrong's avatar
yanzhongrong committed
243 244 245

        if (this.istrue == 1) {
          if (this.tableData.length != 0) {
yanzhongrong's avatar
yanzhongrong committed
246
            successAlert("操作成功");
neogcg's avatar
neogcg committed
247 248 249 250 251
          } else {
            warningAlert("查询结果为空");
          }
          this.istrue = 0;
        }
neogcg's avatar
neogcg committed
252 253
      });
    },
neogcg's avatar
neogcg committed
254 255 256 257 258 259 260 261 262
    getAllWay() {
      railWaylist(this.params).then((res) => {
        this.railWaySelect = res.records;
        if (res.total > this.params.size) {
          this.params.size = res.total;
          this.getAllWay();
        }
      });
    },
neogcg's avatar
neogcg committed
263
  },
yanzhongrong's avatar
yanzhongrong committed
264
  created() {
neogcg's avatar
neogcg committed
265 266 267
    var that = this;
    document.onkeydown = function (e) {
      var key = window.event.keyCode;
neogcg's avatar
neogcg committed
268
      if (key == 13) {
neogcg's avatar
neogcg committed
269 270 271
        that.searchQuery();
      }
    };
neogcg's avatar
neogcg committed
272 273 274
  },
  mounted() {
    this.getTableData();
neogcg's avatar
neogcg committed
275
    this.getAllWay();
neogcg's avatar
neogcg committed
276 277
  },
};
neogcg's avatar
neogcg committed
278 279 280 281 282 283 284 285 286 287 288 289 290 291 292
function formInit(data = {}) {
  return {
    fsuCode: "",
    equipName: "",
    equipSerialNumber: "",
    ip: "",
    parentId: "",
    siteId: "",
    siteName: "",
    wayId: "",
    current: 1,
    size: 10,
    ...data,
  };
}
neogcg's avatar
neogcg committed
293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334
</script>
<style lang="scss" scoped>
.leakage-cable {
  .leakage-top {
    margin-bottom: 20px;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
  }
  & ::v-deep .cell {
    color: #333333;
  }
  & ::v-deep .stripe {
    background-color: #eaf1fe;
  }
  & ::v-deep .red {
    background-color: #f00;
  }
  & ::v-deep .green {
    background-color: green;
  }
  .page {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 20px 0;
    .pageNum {
      margin: 0 20px;
    }
  }
}
</style>
<style lang="scss">
.statistics-table {
  .single-row {
    background: #f1f6ff;
  }
  td {
    padding: 5px !important;
  }
}
</style>