index.vue 4.64 KB
Newer Older
1 2
<template>
  <div class="STBbase-wrapper height100">
3 4 5
    <div class="search-container">
      <el-form :inline="true" :model="form">
        <el-form-item>
qzhxx's avatar
qzhxx committed
6
          <el-select v-model="form.orgId" placeholder="请选择所属单位">
7
            <el-option
qzhxx's avatar
qzhxx committed
8 9 10 11
              v-for="item in orgOptions"
              :key="item.id"
              :label="item.name"
              :value="item.id"
12 13 14 15 16
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-cascader
qzhxx's avatar
qzhxx committed
17
            v-model="form.areaId"
18 19 20 21 22 23 24 25 26 27 28 29 30 31
            :options="areaOptions"
            :props="defaultProps"
            :show-all-levels="false"
          ></el-cascader>
        </el-form-item>
        <el-form-item>
          <div class="btn-group">
            <el-button type="primary" @click="onSearch">查询</el-button>
            <el-button @click="handleReset">重置</el-button>
          </div>
        </el-form-item>
      </el-form>
      <div class="page-tip">
        <span class="page-tip-title">页面说明:</span>
乐宝呗666's avatar
乐宝呗666 committed
32
        <span class="page-tips"
33
          >机顶盒账号为机顶盒所属单位名称,新建后生成6位数字及字母的随机密码,作为机顶盒的登录密码。</span
乐宝呗666's avatar
乐宝呗666 committed
34
        >
35
      </div>
36 37 38 39
    </div>
    <div class="table-content">
      <div class="btn-group">
        <el-button type="primary" @click="addBox">新建机顶盒账号</el-button>
40
      </div>
41
      <div class="party-table">
乐宝呗666's avatar
乐宝呗666 committed
42 43 44 45 46 47 48 49 50 51 52
        <el-table
          border
          style="width: 100%; height: 100%"
          height="100%"
          :data="tableData"
        >
          <el-table-column
            type="index"
            width="120"
            label="序号"
          ></el-table-column>
qzhxx's avatar
qzhxx committed
53 54
          <el-table-column label="MAC地址" prop="mac"></el-table-column>
          <el-table-column label="所属单位" prop="organName"></el-table-column>
55 56
        </el-table>
      </div>
乐宝呗666's avatar
乐宝呗666 committed
57
      <div class="partyt-pagination" style="margin: 0 20px">
qzhxx's avatar
qzhxx committed
58 59 60 61 62 63 64 65 66
        <el-pagination
          background
          @current-change="handleCurrentChange"
          :current-page="page.currentPage"
          :page-size="page.pageSize"
          layout="prev, pager, next, jumper"
          :total="page.total"
        ></el-pagination>
      </div>
67 68
    </div>
    <custom-dialog ref="formItem" @refreshFn="onSearch" />
69 70 71
  </div>
</template>
<script>
72 73 74
import { partyPagination } from "@/components/index";
import customDialog from "./components/dialog.vue";
import { getAreas } from "@/config/area.js";
qzhxx's avatar
qzhxx committed
75
import { getOrgListWithOutPage } from "@/config/organ.js";
76
export default {
77 78 79
  components: { partyPagination, customDialog },
  data() {
    return {
乐宝呗666's avatar
乐宝呗666 committed
80 81 82 83 84 85 86
      page: { 
        currentPage: 1, 
        pageSize: 10, 
        total: 0 
      },
      orgOptions: [], // 单位信息
      areaOptions: [], //区域信息
87 88 89
      defaultProps: {
        label: "name",
        value: "id",
乐宝呗666's avatar
乐宝呗666 committed
90
        checkStrictly: true,
91 92
      },
      form: {
qzhxx's avatar
qzhxx committed
93
        orgId: "",
乐宝呗666's avatar
乐宝呗666 committed
94
        areaId: [],
95
      },
乐宝呗666's avatar
乐宝呗666 committed
96
      tableData: [], // 表格信息
97 98 99 100 101
    };
  },

  mounted() {
    this.getAreas();
qzhxx's avatar
qzhxx committed
102 103
    this.onSearch();
    this.getOrgList();
104 105
  },
  methods: {
乐宝呗666's avatar
乐宝呗666 committed
106 107 108
    // 获取单位信息
    async getOrgList() {
      this.orgOptions = await getOrgListWithOutPage()
qzhxx's avatar
qzhxx committed
109
    },
乐宝呗666's avatar
乐宝呗666 committed
110 111 112
    // 获取区域信息
    async getAreas() {
      this.areaOptions = await getAreas()
113 114 115
    },
    // 查询
    onSearch() {
乐宝呗666's avatar
乐宝呗666 committed
116 117
      this.page.currentPage = 1
      this.getTableData()
118 119 120 121 122 123 124
    },
    // 获得数据接口
    getTableData() {
      let vm = this;
      let param = {
        _index: this.page.currentPage,
        _size: this.page.pageSize,
乐宝呗666's avatar
乐宝呗666 committed
125 126
        areaId: this.form.areaId.length ? this.form.areaId[this.form.areaId.length - 1] : '',
        organId: this.form.orgId
127 128 129
      };
      vm.$https(
        {
qzhxx's avatar
qzhxx committed
130
          url: "boxOperation/selectPageList",
131
          method: "post",
乐宝呗666's avatar
乐宝呗666 committed
132
          authType: this.backToken,
133 134 135
        },
        vm.$qs.stringify(param)
      )
乐宝呗666's avatar
乐宝呗666 committed
136 137 138 139 140 141 142 143
        .then((res) => {
          if (res.data.resultCode === "200") {
            let data = res.data.data
            vm.page.total = data.total
            vm.tableData = data.records
          } else {
            this.$message.error(res.data.message)
          }
144
        })
乐宝呗666's avatar
乐宝呗666 committed
145 146
        .catch(function (err) {
          console.log(err)
147 148 149 150
        });
    },
    // 新增弹框打开
    addBox() {
qzhxx's avatar
qzhxx committed
151
      this.$refs.formItem.backFn(this.orgOptions);
152
    },
乐宝呗666's avatar
乐宝呗666 committed
153
    // 重置
154
    handleReset() {
qzhxx's avatar
qzhxx committed
155 156
      this.form = {
        orgId: "",
乐宝呗666's avatar
乐宝呗666 committed
157
        areaId: [],
qzhxx's avatar
qzhxx committed
158
      };
乐宝呗666's avatar
乐宝呗666 committed
159
      this.onSearch();
160 161 162 163 164
    },
    // 分页
    handleCurrentChange(val) {
      this.page.currentPage = val;
      this.getTableData();
乐宝呗666's avatar
乐宝呗666 committed
165 166
    },
  },
167
};
168 169
</script>
<style lang="less">
乐宝呗666's avatar
乐宝呗666 committed
170 171
@import "~@/style/table.less";
@import "~@/style/pagination.less";
172
</style>