index.vue 4.71 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
乐宝呗666's avatar
乐宝呗666 committed
17
            placeholder="请选择区域"
qzhxx's avatar
qzhxx committed
18
            v-model="form.areaId"
19 20
            :options="areaOptions"
            :props="defaultProps"
21
            change-on-select
22 23 24 25 26 27 28 29 30 31 32
          ></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
33
        <span class="page-tips"
34
          >机顶盒账号为机顶盒所属单位名称,新建后生成6位数字及字母的随机密码,作为机顶盒的登录密码。</span
乐宝呗666's avatar
乐宝呗666 committed
35
        >
36
      </div>
37 38 39 40
    </div>
    <div class="table-content">
      <div class="btn-group">
        <el-button type="primary" @click="addBox">新建机顶盒账号</el-button>
41
      </div>
42 43
      <stb-table :currentPage="page._index" :feildList="feildList" :list="tableData" @action="handleAction"/>
      <party-pagination :page="page" @changePage="handleCurrentChange" />
44
    </div>
45 46
    <add-dialog ref="formItem" @refreshFn="onSearch" />
    <edit-dialog ref="editform" @refreshFn="onSearch" />
47 48 49
  </div>
</template>
<script>
50 51
import { partyPagination} from "@/components/index";
import { addDialog, editDialog ,stbTable } from "./components/index";
52
import { getAreas } from "@/config/area.js";
qzhxx's avatar
qzhxx committed
53
import { getOrgListWithOutPage } from "@/config/organ.js";
54
export default {
55
  components: { partyPagination, addDialog,editDialog,stbTable },
56 57
  data() {
    return {
乐宝呗666's avatar
乐宝呗666 committed
58
      page: { 
59 60
        _index: 1, 
        _size: 10, 
乐宝呗666's avatar
乐宝呗666 committed
61 62
        total: 0 
      },
乐宝呗666's avatar
乐宝呗666 committed
63 64
      feildList: [
        { prop: "mac", label: "MAC地址" },
65 66 67
        { prop: "organName", label: "所属单位" },
        { prop: "exiredDate", label: "到期时间" },
        { prop: "", label: "操作", isEdit: true, width: 180 },
乐宝呗666's avatar
乐宝呗666 committed
68
      ],
乐宝呗666's avatar
乐宝呗666 committed
69 70
      orgOptions: [], // 单位信息
      areaOptions: [], //区域信息
71 72 73
      defaultProps: {
        label: "name",
        value: "id",
乐宝呗666's avatar
乐宝呗666 committed
74
        checkStrictly: true,
75 76
      },
      form: {
qzhxx's avatar
qzhxx committed
77
        orgId: "",
乐宝呗666's avatar
乐宝呗666 committed
78
        areaId: [],
79
      },
乐宝呗666's avatar
乐宝呗666 committed
80
      tableData: [], // 表格信息
81 82 83 84 85
    };
  },

  mounted() {
    this.getAreas();
qzhxx's avatar
qzhxx committed
86 87
    this.onSearch();
    this.getOrgList();
88 89
  },
  methods: {
乐宝呗666's avatar
乐宝呗666 committed
90 91 92
    // 获取单位信息
    async getOrgList() {
      this.orgOptions = await getOrgListWithOutPage()
qzhxx's avatar
qzhxx committed
93
    },
乐宝呗666's avatar
乐宝呗666 committed
94 95 96
    // 获取区域信息
    async getAreas() {
      this.areaOptions = await getAreas()
97 98 99
    },
    // 查询
    onSearch() {
100
      this.page._index = 1
乐宝呗666's avatar
乐宝呗666 committed
101
      this.requestForm = JSON.parse(JSON.stringify(this.form))
乐宝呗666's avatar
乐宝呗666 committed
102
      this.getTableData()
103 104 105 106 107
    },
    // 获得数据接口
    getTableData() {
      let vm = this;
      let param = {
108 109
        _index: this.page._index,
        _size: this.page._size,
乐宝呗666's avatar
乐宝呗666 committed
110 111
        areaId: this.requestForm.areaId.length ? this.requestForm.areaId[this.requestForm.areaId.length - 1] : '',
        organId: this.requestForm.orgId
112 113 114
      };
      vm.$https(
        {
qzhxx's avatar
qzhxx committed
115
          url: "boxOperation/selectPageList",
116
          method: "post",
乐宝呗666's avatar
乐宝呗666 committed
117
          authType: this.backToken,
118 119 120
        },
        vm.$qs.stringify(param)
      )
乐宝呗666's avatar
乐宝呗666 committed
121 122 123 124 125 126 127 128
        .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)
          }
129
        })
乐宝呗666's avatar
乐宝呗666 committed
130 131
        .catch(function (err) {
          console.log(err)
132 133 134 135
        });
    },
    // 新增弹框打开
    addBox() {
qzhxx's avatar
qzhxx committed
136
      this.$refs.formItem.backFn(this.orgOptions);
137
    },
乐宝呗666's avatar
乐宝呗666 committed
138
    // 重置
139
    handleReset() {
qzhxx's avatar
qzhxx committed
140 141
      this.form = {
        orgId: "",
乐宝呗666's avatar
乐宝呗666 committed
142
        areaId: [],
qzhxx's avatar
qzhxx committed
143
      };
乐宝呗666's avatar
乐宝呗666 committed
144
      this.onSearch();
145 146 147
    },
    // 分页
    handleCurrentChange(val) {
148
      this.page._index = val;
149
      this.getTableData();
乐宝呗666's avatar
乐宝呗666 committed
150
    },
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167
    handleAction(params) {
      this.activeRow = params.row;
      switch (params.type) {
        case "detail":
          this.handleDetail();
          break;
        case "edit":
          this.handleEdit();
          break;
        default:
          break;
      }
    },
    // 编辑
    handleEdit() {
      this.$refs.editform.backFn(this.activeRow);
    },
乐宝呗666's avatar
乐宝呗666 committed
168
  },
169
};
170 171 172
</script>
<style lang="less">
</style>