index.vue 6.34 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
          ></el-cascader>
        </el-form-item>
24 25 26 27 28 29 30 31 32 33 34
        <el-form-item>
          <el-date-picker
            v-model="form.date"
            type="daterange"
            value-format="yyyy-MM-dd"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
          >
          </el-date-picker>
        </el-form-item>
35 36 37 38 39 40 41 42 43
        <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
44
        <span class="page-tips"
45
          >机顶盒账号为机顶盒所属单位名称,新建后生成6位数字及字母的随机密码,作为机顶盒的登录密码。</span
乐宝呗666's avatar
乐宝呗666 committed
46
        >
47
      </div>
48 49 50 51
    </div>
    <div class="table-content">
      <div class="btn-group">
        <el-button type="primary" @click="addBox">新建机顶盒账号</el-button>
52 53 54
        <el-button class="export" type="primary" @click="handleExport"
          >导出</el-button
        >
55
      </div>
56 57 58 59 60 61
      <stb-table
        :currentPage="page._index"
        :feildList="feildList"
        :list="tableData"
        @action="handleAction"
      />
62
      <party-pagination :page="page" @changePage="handleCurrentChange" />
63
    </div>
64 65
    <add-dialog ref="formItem" @refreshFn="onSearch" />
    <edit-dialog ref="editform" @refreshFn="onSearch" />
66 67 68
  </div>
</template>
<script>
69 70
import { partyPagination } from "@/components/index";
import { addDialog, editDialog, stbTable } from "./components/index";
71
import { getAreas } from "@/config/area.js";
qzhxx's avatar
qzhxx committed
72
import { getOrgListWithOutPage } from "@/config/organ.js";
73
export default {
74
  components: { partyPagination, addDialog, editDialog, stbTable },
75 76
  data() {
    return {
77 78 79 80
      page: {
        _index: 1,
        _size: 10,
        total: 0,
乐宝呗666's avatar
乐宝呗666 committed
81
      },
乐宝呗666's avatar
乐宝呗666 committed
82 83
      feildList: [
        { prop: "mac", label: "MAC地址" },
84
        { prop: "organName", label: "所属单位" },
85
        { prop: "num", label: "展板播放次数" },
86 87
        { prop: "exiredDate", label: "到期时间" },
        { prop: "", label: "操作", isEdit: true, width: 180 },
乐宝呗666's avatar
乐宝呗666 committed
88
      ],
乐宝呗666's avatar
乐宝呗666 committed
89 90
      orgOptions: [], // 单位信息
      areaOptions: [], //区域信息
91 92 93
      defaultProps: {
        label: "name",
        value: "id",
乐宝呗666's avatar
乐宝呗666 committed
94
        checkStrictly: true,
95 96
      },
      form: {
qzhxx's avatar
qzhxx committed
97
        orgId: "",
乐宝呗666's avatar
乐宝呗666 committed
98
        areaId: [],
99
      },
乐宝呗666's avatar
乐宝呗666 committed
100
      tableData: [], // 表格信息
101 102 103 104 105
    };
  },

  mounted() {
    this.getAreas();
qzhxx's avatar
qzhxx committed
106 107
    this.onSearch();
    this.getOrgList();
108 109
  },
  methods: {
乐宝呗666's avatar
乐宝呗666 committed
110 111
    // 获取单位信息
    async getOrgList() {
112
      this.orgOptions = await getOrgListWithOutPage();
qzhxx's avatar
qzhxx committed
113
    },
乐宝呗666's avatar
乐宝呗666 committed
114 115
    // 获取区域信息
    async getAreas() {
116
      this.areaOptions = await getAreas();
117 118 119
    },
    // 查询
    onSearch() {
120 121 122
      this.page._index = 1;
      this.requestForm = JSON.parse(JSON.stringify(this.form));
      this.getTableData();
123 124 125 126
    },
    // 获得数据接口
    getTableData() {
      let vm = this;
127 128 129 130 131
      let dates = {};
      if (this.form.date) {
        dates.startDate = this.form.date[0];
        dates.endDate = this.form.date[1];
      }
132
      let param = {
133 134
        _index: this.page._index,
        _size: this.page._size,
135 136 137 138 139
        areaId: this.requestForm.areaId.length
          ? this.requestForm.areaId[this.requestForm.areaId.length - 1]
          : "",
        organId: this.requestForm.orgId,
        ...dates,
140 141 142
      };
      vm.$https(
        {
qzhxx's avatar
qzhxx committed
143
          url: "boxOperation/selectPageList",
144
          method: "post",
乐宝呗666's avatar
乐宝呗666 committed
145
          authType: this.backToken,
146 147 148
        },
        vm.$qs.stringify(param)
      )
乐宝呗666's avatar
乐宝呗666 committed
149 150
        .then((res) => {
          if (res.data.resultCode === "200") {
151 152 153
            let data = res.data.data;
            vm.page.total = data.total;
            vm.tableData = data.records;
乐宝呗666's avatar
乐宝呗666 committed
154
          } else {
155
            this.$message.error(res.data.message);
乐宝呗666's avatar
乐宝呗666 committed
156
          }
157
        })
乐宝呗666's avatar
乐宝呗666 committed
158
        .catch(function (err) {
159
          console.log(err);
160 161 162 163
        });
    },
    // 新增弹框打开
    addBox() {
qzhxx's avatar
qzhxx committed
164
      this.$refs.formItem.backFn(this.orgOptions);
165
    },
乐宝呗666's avatar
乐宝呗666 committed
166
    // 重置
167
    handleReset() {
qzhxx's avatar
qzhxx committed
168 169
      this.form = {
        orgId: "",
乐宝呗666's avatar
乐宝呗666 committed
170
        areaId: [],
qzhxx's avatar
qzhxx committed
171
      };
乐宝呗666's avatar
乐宝呗666 committed
172
      this.onSearch();
173 174 175
    },
    // 分页
    handleCurrentChange(val) {
176
      this.page._index = val;
177
      this.getTableData();
乐宝呗666's avatar
乐宝呗666 committed
178
    },
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195
    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);
    },
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226
    // 导出
    handleExport() {
      let dates = {};
      if (this.form.date) {
        dates.startDate = this.requestForm.date[0];
        dates.endDate = this.requestForm.date[1];
      }
      let param = {
        areaId: this.requestForm.areaId.length
          ? this.requestForm.areaId[this.requestForm.areaId.length - 1]
          : "",
        organId: this.requestForm.orgId,
        ...dates,
      };
      this.$https(
        {
          url: "/boxOperation/export",
          method: "post",
          authType: this.backToken,
          responseType: "blob",
        },
        this.$qs.stringify(param)
      ).then((res) => {
        let blobUrl = window.URL.createObjectURL(res.data);
        const aElement = document.createElement("a");
        aElement.href = blobUrl;
        aElement.download = "机顶盒基础信息.xls";
        aElement.click();
        window.URL.revokeObjectURL(blobUrl);
      });
    },
乐宝呗666's avatar
乐宝呗666 committed
227
  },
228
};
229 230 231
</script>
<style lang="less">
</style>