上饶市警务平台后台管理前端
zhongrj
2023-03-09 8bb17a1e1291c4de28e79b8b47c9ad508c47c4d9
新增手台管理
1 files modified
2 files added
427 ■■■■■ changed files
src/api/talkbackequipmentinfo/talkbackequipmentinfo.js 50 ●●●●● patch | view | raw | blame | history
src/router/views/index.js 14 ●●●●● patch | view | raw | blame | history
src/views/talkbackequipmentinfo/talkbackequipmentinfo.vue 363 ●●●●● patch | view | raw | blame | history
src/api/talkbackequipmentinfo/talkbackequipmentinfo.js
New file
@@ -0,0 +1,50 @@
import request from '@/router/axios';
export const getList = (current, size, params) => {
  return request({
    url: '/api/talkBackEquipmentInfo/talkBackEquipmentInfo/page',
    method: 'get',
    params: {
      ...params,
      current,
      size,
    }
  })
}
export const getDetail = (id) => {
  return request({
    url: '/api/talkBackEquipmentInfo/talkBackEquipmentInfo/details',
    method: 'get',
    params: {
      id
    }
  })
}
export const remove = (ids) => {
  return request({
    url: '/api/talkBackEquipmentInfo/talkBackEquipmentInfo/removes',
    method: 'post',
    params: {
      ids,
    }
  })
}
export const add = (row) => {
  return request({
    url: '/api/talkBackEquipmentInfo/talkBackEquipmentInfo/saves',
    method: 'post',
    data: row
  })
}
export const update = (row) => {
  return request({
    url: '/api/talkBackEquipmentInfo/talkBackEquipmentInfo/updates',
    method: 'post',
    data: row
  })
}
src/router/views/index.js
@@ -103,6 +103,20 @@
  }]
}
, {
  path: '/talkbackequipmentinfo',
  component: Layout,
  redirect: 'talkbackequipmentinfo/index',
  children: [{
    path: 'index',
    name: '手台管理',
    meta: {
      i18n: 'info'
    },
    component: () =>
      import( /* webpackChunkName: "views" */ '@/views/talkbackequipmentinfo/talkbackequipmentinfo')
  }]
}
, {
  path: '/range',
  component: Layout,
  redirect: 'range/index',
src/views/talkbackequipmentinfo/talkbackequipmentinfo.vue
New file
@@ -0,0 +1,363 @@
<template>
  <basic-container>
    <avue-crud :option="option" :table-loading="loading" :data="data" :page.sync="page" :permission="permissionList"
      :before-open="beforeOpen" v-model="form" ref="crud" @row-update="rowUpdate" @row-save="rowSave" @row-del="rowDel"
      @search-change="searchChange" @search-reset="searchReset" @selection-change="selectionChange"
      @current-change="currentChange" @size-change="sizeChange" @refresh-change="refreshChange" @on-load="onLoad">
      <template slot="menuLeft">
        <el-button size="small" icon="el-icon-delete" plain v-if="permission.talkBackEquipmentInfo_delete" @click="handleDelete">删 除
        </el-button>
        <el-button type="success" size="small" plain icon="el-icon-upload2" @click="handleImport">导入
        </el-button>
      </template>
    </avue-crud>
    <el-dialog title="数据导入" append-to-body :visible.sync="excelBox" width="555px">
      <avue-form :option="excelOption" v-model="excelForm" :upload-after="uploadAfter">
        <template slot="excelTemplate">
          <el-button type="primary" @click="handleTemplate">
            点击下载<i class="el-icon-download el-icon--right"></i>
          </el-button>
        </template>
      </avue-form>
    </el-dialog>
  </basic-container>
</template>
<script>
import { getList, getDetail, add, update, remove } from "@/api/talkbackequipmentinfo/talkbackequipmentinfo";
import { mapGetters } from "vuex";
import { exportBlob } from "@/api/common";
import { downloadXls } from "@/util/util";
import { getToken } from "@/util/auth";
export default {
  data() {
    return {
      form: {},
      query: {},
      loading: true,
      page: {
        pageSize: 10,
        currentPage: 1,
        total: 0
      },
      selectionList: [],
      excelBox: false,
      excelForm: {},
      excelOption: {
        submitBtn: false,
        emptyBtn: false,
        column: [
          {
            label: '模板上传',
            prop: 'excelFile',
            type: 'upload',
            drag: true,
            loadText: '模板上传中,请稍等',
            span: 24,
            propsHttp: {
              res: 'data'
            },
            tip: '请上传 .xls,.xlsx 标准格式文件',
            action: "/api/talkBackEquipmentInfo/talkBackEquipmentInfo/import-talk-back-equipment-info"
          },
          {
            label: "数据覆盖",
            prop: "isCovered",
            type: "switch",
            align: "center",
            width: 80,
            dicData: [
              {
                label: "否",
                value: 0
              },
              {
                label: "是",
                value: 1
              }
            ],
            value: 0,
            slot: true,
            rules: [
              {
                required: true,
                message: "请选择是否覆盖",
                trigger: "blur"
              }
            ]
          },
          {
            label: '模板下载',
            prop: 'excelTemplate',
            formslot: true,
            span: 24,
          }
        ]
      },
      option: {
        height: 'auto',
        calcHeight: 30,
        dialogWidth: 950,
        tip: false,
        searchShow: true,
        searchMenuSpan: 6,
        border: true,
        index: true,
        viewBtn: true,
        addBtn:true,
        selection: true,
        excelBtn: true,
        menuWidth:280,
        dialogClickModal: false,
        column: [
          {
            label: "终端编号",
            prop: "terminalNumber",
            editDisabled:true,
            search: true,
            searchSpan: 4,
            rules: [{
              required: true,
              message: "请输入终端编号",
              trigger: "blur"
            }]
          },
          {
            label: "设备名称",
            prop: "name",
          },
          {
            label: "类型",
            prop: "type",
            type:"select",
            search: true,
            searchSpan: 4,
            dicData:[
              {
                label:"公网",
                value: 1
              },
              {
                label:"专网",
                value: 2
              }
            ]
          },
          {
            label: "所属辖区",
            prop: "deptId",
            type: "tree",
            dicUrl: "api/blade-system/dept/getPoliceStationTree",
            props: {
              label: 'name',
              value: 'id',
              children: 'children'
            },
            search: true,
            searchSpan: 4,
            defaultExpandAll:"true",
            width: 110,
            rules: [{
              required: true,
              message: "请选择所属辖区",
              trigger: "blur"
            }]
          },
          {
            label: "单位名称",
            prop: "unitName",
            search: true,
            searchSpan: 5,
            rules: [{
              required: true,
              message: "请输入单位名称",
              trigger: "blur"
            }],
          },
          {
            label: "单位编号",
            prop: "unitCode",
            rules: [{
              required: true,
              message: "请输入单位编号",
              trigger: "blur"
            }],
          },
          {
            label: "民警姓名",
            prop: "policeName",
            // search: true,
          },
          {
            label: "民警编号",
            prop: "policeCode",
          },
          {
            label: "联系方式",
            prop: "phone",
          },
        ]
      },
      data: [],
      policemanList: []
    };
  },
  computed: {
    ...mapGetters(["permission"]),
    permissionList() {
      return {
        addBtn: this.vaildData(this.permission.talkBackEquipmentInfo_add, true),
        viewBtn: this.vaildData(this.permission.talkBackEquipmentInfo_view, true),
        delBtn: this.vaildData(this.permission.talkBackEquipmentInfo_delete, true),
        editBtn: this.vaildData(this.permission.talkBackEquipmentInfo_edit, true)
      };
    },
    ids() {
      let ids = [];
      this.selectionList.forEach(ele => {
        ids.push(ele.id);
      });
      return ids.join(",");
    }
  },
  watch: {
    'excelForm.isCovered'() {
      if (this.excelForm.isCovered !== '') {
        const column = this.findObject(this.excelOption.column, "excelFile");
        column.action = `/api/talkBackEquipmentInfo/talkBackEquipmentInfo/import-talk-back-equipment-info?isCovered=${this.excelForm.isCovered}`;
      }
    },
  },
  created() {
  },
  methods: {
    rowSave(row, done, loading) {
      add(row).then(() => {
        this.onLoad(this.page);
        this.$message({
          type: "success",
          message: "操作成功!"
        });
        done();
      }, error => {
        loading();
        window.console.log(error);
      });
    },
    rowUpdate(row, index, done, loading) {
      update(row).then(() => {
        this.onLoad(this.page);
        this.$message({
          type: "success",
          message: "操作成功!"
        });
        done();
      }, error => {
        loading();
        console.log(error);
      });
    },
    rowDel(row) {
      this.$confirm("确定将选择数据删除?", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          return remove(row.id);
        })
        .then(() => {
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!"
          });
        });
    },
    handleDelete() {
      if (this.selectionList.length === 0) {
        this.$message.warning("请选择至少一条数据");
        return;
      }
      this.$confirm("确定将选择数据删除?", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          return remove(this.ids);
        })
        .then(() => {
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!"
          });
          this.$refs.crud.toggleSelection();
        });
    },
    beforeOpen(done, type) {
      if (["edit", "view"].includes(type)) {
        getDetail(this.form.id).then(res => {
          this.form = res.data.data;
        });
      }
      done();
    },
    searchReset() {
      this.query = {};
      this.onLoad(this.page);
    },
    searchChange(params, done) {
      this.query = params;
      this.page.currentPage = 1;
      this.onLoad(this.page, params);
      done();
    },
    selectionChange(list) {
      this.selectionList = list;
    },
    selectionClear() {
      this.selectionList = [];
      this.$refs.crud.toggleSelection();
    },
    currentChange(currentPage) {
      this.page.currentPage = currentPage;
    },
    sizeChange(pageSize) {
      this.page.pageSize = pageSize;
    },
    refreshChange() {
      this.onLoad(this.page, this.query);
    },
    onLoad(page, params = {}) {
      this.loading = true;
      getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
        const data = res.data.data;
        this.page.total = data.total;
        this.data = data.records;
        this.loading = false;
        this.selectionClear();
      });
    },
    //下面为导入操作
    handleImport() {
      this.excelBox = true;
    },
    uploadAfter(res, done, loading, column) {
      window.console.log(column);
      this.excelBox = false;
      this.refreshChange();
      done();
    },
    handleTemplate() {
      exportBlob(`/api/talkBackEquipmentInfo/talkBackEquipmentInfo/export-template?${this.website.tokenHeader}=${getToken()}`).then(res => {
        downloadXls(res.data, "手台数据模板.xlsx");
      })
    },
  }
};
</script>
<style></style>