fsuTable.vue 8.3 KB
Newer Older
neogcg's avatar
neogcg committed
1 2 3 4 5
<template>
  <div>
    <div class="leakage-top">
      <div style="color: #666666"></div>
      <div class="operate-btn">
yanzhongrong's avatar
yanzhongrong committed
6 7 8
        <delids :multipleSelection2="multipleSelection" @del="del()"
          >删除</delids
        >
neogcg's avatar
neogcg committed
9
        <el-button type="primary" @click="refresh">刷新</el-button>
neogcg's avatar
neogcg committed
10
        <el-button type="primary" @click="block = !block">查询</el-button>
neogcg's avatar
neogcg committed
11 12
        <el-button type="primary" @click="exportData">导出</el-button>
      </div>
neogcg's avatar
neogcg committed
13
    </div>
neogcg's avatar
neogcg committed
14 15 16 17 18 19 20 21
    <el-form
      class="search-div"
      v-if="block"
      :model="FSUForm"
      :inline="true"
      size="mini"
    >
      <el-form-item label="设备名称:">
neogcg's avatar
neogcg committed
22 23 24 25 26 27
        <el-input
          placeholder="请输入设备名称"
          v-model="FSUForm.equipName"
          clearable
        >
        </el-input>
neogcg's avatar
neogcg committed
28 29
      </el-form-item>
      <el-form-item label="FSU身份编号:">
neogcg's avatar
neogcg committed
30 31 32 33 34 35
        <el-input
          placeholder="请输入FSU身份编号"
          v-model="FSUForm.fsuCode"
          clearable
        >
        </el-input>
neogcg's avatar
neogcg committed
36 37 38
      </el-form-item>
      <el-form-item label="IP地址:">
        <el-input placeholder="请输入IP地址" v-model="FSUForm.ip" clearable>
neogcg's avatar
neogcg committed
39
        </el-input>
neogcg's avatar
neogcg committed
40 41
      </el-form-item>
      <el-form-item label="所在铁路线:">
neogcg's avatar
neogcg committed
42 43
        <el-select
          placeholder="请选择所在铁路线"
neogcg's avatar
neogcg committed
44
          v-model="FSUForm.wayId"
neogcg's avatar
neogcg committed
45 46 47
          clearable
          @change="changerailWay()"
        >
neogcg's avatar
neogcg committed
48
          <el-option
neogcg's avatar
neogcg committed
49 50 51 52 53 54
            v-for="item in railWaySelect"
            :key="item.id"
            :label="item.name"
            :value="item.id"
          ></el-option>
        </el-select>
neogcg's avatar
neogcg committed
55 56
      </el-form-item>
      <el-form-item label="所在站点:">
neogcg's avatar
neogcg committed
57 58 59 60 61
        <el-select
          placeholder="请选择所在站点"
          v-model="FSUForm.siteId"
          clearable
        >
neogcg's avatar
neogcg committed
62
          <el-option
neogcg's avatar
neogcg committed
63 64 65 66 67 68
            v-for="item in stationSelect2"
            :key="item.id"
            :label="item.siteName"
            :value="item.id"
          ></el-option>
        </el-select>
neogcg's avatar
neogcg committed
69 70
      </el-form-item>
      <el-form-item>
neogcg's avatar
neogcg committed
71 72
        <el-button type="success" @click="searchQuery()">查询</el-button>
        <el-button type="primary" @click="reset">重置</el-button>
neogcg's avatar
neogcg committed
73 74
      </el-form-item>
    </el-form>
neogcg's avatar
neogcg committed
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
    <el-table
      ref="multipleTable"
      class="statistics-table"
      :data="tableData"
      tooltip-effect="dark"
      style="width: 100%"
      :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
        show-overflow-tooltip
        align="center"
      />
      <el-table-column
        prop="action"
yanzhongrong's avatar
yanzhongrong committed
114
        label="操作"
neogcg's avatar
neogcg committed
115 116 117 118
        show-overflow-tooltip
        align="center"
      >
        <template slot-scope="{ row }">
yanzhongrong's avatar
yanzhongrong committed
119 120 121 122 123 124
          <el-link type="primary" :underline="false" @click="handleView(row)"
            >查看</el-link
          >
          <el-link type="primary" :underline="false" @click="toEdit(row)"
            >编辑</el-link
          >
neogcg's avatar
neogcg committed
125 126 127
        </template>
      </el-table-column>
    </el-table>
yanzhongrong's avatar
yanzhongrong committed
128 129
    <Pagination
      :limit="FSUForm.size"
neogcg's avatar
neogcg committed
130
      :page="FSUForm.current"
neogcg's avatar
neogcg committed
131 132 133 134
      :total="total"
      class="pagination"
      @pagination="handlePageChange"
    />
yanzhongrong's avatar
yanzhongrong committed
135
    <el-dialog
yanzhongrong's avatar
yanzhongrong committed
136 137
      title="编辑-FSU"
      :visible.sync="visible"
dupengyu's avatar
dupengyu committed
138
      width="760px"
yanzhongrong's avatar
yanzhongrong committed
139
      :close-on-click-modal="false"
yanzhongrong's avatar
yanzhongrong committed
140 141 142
    >
      <fsu :curInfo="curInfo" :isEdit="1" @update="update" />
    </el-dialog>
neogcg's avatar
neogcg committed
143 144 145
  </div>
</template>
<script>
146 147
import fsu from "@/views/setting/add/comp/FSU.vue";
import { fsulist, fsubatchDelete, railWaylist, selectForSite } from "../../api";
neogcg's avatar
neogcg committed
148
import { successAlert, warningAlert } from "@/utils/alert";
neogcg's avatar
neogcg committed
149 150
import download from "@/utils/download";
import { exportFsu } from "@/api/export";
yanzhongrong's avatar
yanzhongrong committed
151

neogcg's avatar
neogcg committed
152
export default {
yanzhongrong's avatar
yanzhongrong committed
153
  components: { fsu },
neogcg's avatar
neogcg committed
154 155
  data() {
    return {
neogcg's avatar
neogcg committed
156
      railWaySelect: [],
neogcg's avatar
neogcg committed
157 158
      stationSelect: [],
      stationSelect2: [],
neogcg's avatar
neogcg committed
159
      FSUForm: formInit(),
neogcg's avatar
neogcg committed
160
      visible: false,
neogcg's avatar
neogcg committed
161 162
      tableData: [],
      params: {
neogcg's avatar
neogcg committed
163 164
        current: 1,
        size: 10,
neogcg's avatar
neogcg committed
165 166 167 168
      },
      total: 10,
      multipleSelection: [],
      ids: [],
neogcg's avatar
neogcg committed
169
      block: 0,
neogcg's avatar
neogcg committed
170
      istrue: 0,
neogcg's avatar
neogcg committed
171
      exids: [],
172
      curInfo: {},
neogcg's avatar
neogcg committed
173 174
    };
  },
yanzhongrong's avatar
yanzhongrong committed
175 176 177 178 179 180 181 182 183 184 185 186 187
  created() {
    var that = this;
    document.onkeydown = function (e) {
      var key = window.event.keyCode;
      if (key == 13) {
        that.searchQuery();
      }
    };
  },
  mounted() {
    this.getTableData();
    this.getAllWay();
  },
neogcg's avatar
neogcg committed
188
  methods: {
yanzhongrong's avatar
yanzhongrong committed
189
    toEdit(row) {
190 191
      this.visible = true;
      this.curInfo = row;
yanzhongrong's avatar
yanzhongrong committed
192 193
    },
    update(data) {
194
      this.visible = false;
yanzhongrong's avatar
yanzhongrong committed
195
      if (data) {
196
        this.getTableData();
yanzhongrong's avatar
yanzhongrong committed
197 198
      }
    },
neogcg's avatar
neogcg committed
199
    changerailWay() {
neogcg's avatar
neogcg committed
200 201 202
      selectForSite({ wayId: this.FSUForm.wayId }).then((res) => {
        this.stationSelect2 = res;
      });
neogcg's avatar
neogcg committed
203
    },
neogcg's avatar
neogcg committed
204 205 206 207 208 209
    tableRowClassName({ row, rowIndex }) {
      return rowIndex % 2 === 0 ? "" : "single-row";
    },
    changeType(item) {
      this.activeName = item.key;
    },
neogcg's avatar
neogcg committed
210
    del() {
neogcg's avatar
neogcg committed
211
      let ids = this.ids;
neogcg's avatar
neogcg committed
212
      fsubatchDelete({ ids }).then((res) => {
neogcg's avatar
neogcg committed
213
        if (res.code == 200) {
neogcg's avatar
neogcg committed
214
          successAlert("删除成功");
neogcg's avatar
neogcg committed
215

neogcg's avatar
neogcg committed
216
          this.getTableData();
neogcg's avatar
neogcg committed
217 218
        } else {
          warningAlert("删除失败");
neogcg's avatar
neogcg committed
219 220
        }
      });
neogcg's avatar
neogcg committed
221 222
    },
    refresh() {
yanzhongrong's avatar
yanzhongrong committed
223
      this.reset();
neogcg's avatar
neogcg committed
224
    },
neogcg's avatar
neogcg committed
225
    searchQuery() {
neogcg's avatar
neogcg committed
226
      this.istrue = 1;
neogcg's avatar
neogcg committed
227 228 229
      this.getTableData();
    },
    reset() {
neogcg's avatar
neogcg committed
230
      this.FSUForm = formInit();
neogcg's avatar
neogcg committed
231
      this.searchQuery();
neogcg's avatar
neogcg committed
232
    },
neogcg's avatar
neogcg committed
233
    exportData() {
yanzhongrong's avatar
yanzhongrong committed
234
      if (this.exids.length == 0) {
neogcg's avatar
neogcg committed
235 236 237
        this.$message.warning("暂无数据");
        return false;
      } else {
yanzhongrong's avatar
yanzhongrong committed
238 239 240
        exportFsu({ ids: this.exids }).then((res) => {
          download(res, "vnd.ms-excel", `FSU表.xls`);
        });
neogcg's avatar
neogcg committed
241
      }
neogcg's avatar
neogcg committed
242
    },
neogcg's avatar
neogcg committed
243 244 245 246 247
    handleSelectionChange(val) {
      this.multipleSelection = val;
      this.ids = this.multipleSelection.map((i) => i.id);
    },
    handleView(row) {
neogcg's avatar
neogcg committed
248
      this.$router.push({
dupengyu's avatar
dupengyu committed
249
        path: "/setting/statistics/detail",
neogcg's avatar
neogcg committed
250 251 252 253 254
        query: {
          id: row.id,
          type: 3,
        },
      });
neogcg's avatar
neogcg committed
255 256
    },
    handlePageChange(pageData) {
yanzhongrong's avatar
yanzhongrong committed
257
      this.FSUForm.size = pageData.size;
neogcg's avatar
neogcg committed
258
      this.FSUForm.current = pageData.page;
neogcg's avatar
neogcg committed
259 260 261
      this.getTableData();
    },
    getTableData() {
neogcg's avatar
neogcg committed
262
      fsulist(this.FSUForm).then((res) => {
neogcg's avatar
neogcg committed
263 264 265
        let list = res.records || [];
        this.tableData = list;
        this.total = res.total;
neogcg's avatar
neogcg committed
266
        this.exids = list.map((i) => i.id);
yanzhongrong's avatar
yanzhongrong committed
267 268
        if (this.istrue == 1) {
          if (this.tableData.length != 0) {
yanzhongrong's avatar
yanzhongrong committed
269
            successAlert("操作成功");
neogcg's avatar
neogcg committed
270 271 272 273 274
          } else {
            warningAlert("查询结果为空");
          }
          this.istrue = 0;
        }
neogcg's avatar
neogcg committed
275 276
      });
    },
neogcg's avatar
neogcg committed
277 278 279 280 281 282 283 284 285
    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
286
  },
neogcg's avatar
neogcg committed
287
};
yanzhongrong's avatar
yanzhongrong committed
288

neogcg's avatar
neogcg committed
289 290 291 292 293 294 295 296 297 298 299 300 301 302 303
function formInit(data = {}) {
  return {
    fsuCode: "",
    equipName: "",
    equipSerialNumber: "",
    ip: "",
    parentId: "",
    siteId: "",
    siteName: "",
    wayId: "",
    current: 1,
    size: 10,
    ...data,
  };
}
neogcg's avatar
neogcg committed
304 305
</script>
<style lang="scss" scoped>
yanzhongrong's avatar
yanzhongrong committed
306 307 308
.el-link {
  margin-right: 20px;
}
neogcg's avatar
neogcg committed
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 335 336 337 338 339 340 341 342 343 344 345 346 347 348
.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>