上饶市警务平台后台管理前端
zhongrj
2023-02-20 f02caef2e782b578b2a29b84b59b15e2f43648f2
警员,值班新增导入
3 files modified
320 ■■■■ changed files
src/views/policeman/policeman.vue 150 ●●●● patch | view | raw | blame | history
src/views/scheduling/scheduling.vue 168 ●●●● patch | view | raw | blame | history
src/views/villagePersonInfo/villagePersonInfo.vue 2 ●●● patch | view | raw | blame | history
src/views/policeman/policeman.vue
@@ -1,39 +1,34 @@
<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">
    <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.policeman_delete"
                   @click="handleDelete">删 除
        <el-button size="small" icon="el-icon-delete" plain v-if="permission.policeman_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 {getPage, getDetail, add, update, remove} from "@/api/policeman/policeman";
  import {mapGetters} from "vuex";
import { exportBlob } from "@/api/common";
import { downloadXls } from "@/util/util";
import { getToken } from "@/util/auth";
  export default {
    data() {
@@ -47,6 +42,59 @@
          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/policeman/policeman/import-policeman"
          },
          {
            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,
@@ -56,6 +104,8 @@
          border: true,
          index: true,
          viewBtn: true,
        addBtn: false,
        editBtn: false,
          selection: true,
          dialogClickModal: false,
          column: [
@@ -63,6 +113,7 @@
              label: "警员名称",
              prop: "name",
              search: true,
            searchSpan: 4,
              rules: [{
                required: true,
                message: "请输入警员名称",
@@ -78,22 +129,16 @@
              prop: "contact",
            },
            {
              label: "所属单位",
              prop: "deptId",
              type: "tree",
              dicUrl: "api/blade-system/dept/lazy-list",
              props:{
                label:'deptName',
                value:'id',
                children:'children'
              },
            label: "单位编号",
            prop: "deptCode",
              search: true,
              searchSpan:4,
              rules: [{
                required: true,
                message: "请选择所属单位",
                trigger: "blur"
              }]
          },
          {
            label: "单位名称",
            prop: "deptName",
            search: true,
            searchSpan: 4,
            },
          ]
        },
@@ -117,6 +162,14 @@
        });
        return ids.join(",");
      }
  },
  watch: {
    'excelForm.isCovered'() {
      if (this.excelForm.isCovered !== '') {
        const column = this.findObject(this.excelOption.column, "excelFile");
        column.action = `/api/policeman/policeman/import-policeman?isCovered=${this.excelForm.isCovered}`;
      }
    },
    },
    methods: {
      rowSave(row, done, loading) {
@@ -232,10 +285,25 @@
          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/policeman/policeman/export-template?${this.website.tokenHeader}=${getToken()}`).then(res => {
        downloadXls(res.data, "警员信息数据模板.xlsx");
      })
    },
      }
    }
  };
</script>
<style>
</style>
<style></style>
src/views/scheduling/scheduling.vue
@@ -1,39 +1,34 @@
<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">
    <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.scheduling_delete"
                   @click="handleDelete">删 除
        <el-button size="small" icon="el-icon-delete" plain v-if="permission.scheduling_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, getPliceman} from "@/api/scheduling/scheduling";
  import {mapGetters} from "vuex";
import { exportBlob } from "@/api/common";
import { downloadXls } from "@/util/util";
import { getToken } from "@/util/auth";
  export default {
    data() {
@@ -47,6 +42,59 @@
          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/scheduling/scheduling/import-scheduling"
          },
          {
            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,
@@ -57,43 +105,42 @@
          border: true,
          index: true,
          viewBtn: true,
        addBtn: false,
        editBtn: false,
          selection: true,
          excelBtn: true,
          dialogClickModal: false,
          column: [
            {
            label: "值班单位",
            prop: "dept",
            row: true,
            span: 24
          },
          {
            label: "值班日期",
            prop: "day",
            type: "date",
            format: "yyyy-MM-dd",
            valueFormat: "yyyy-MM-dd",
            rules: [{
              required: true,
              message: "请选择值班日期",
              trigger: "blur"
            }],
          },
          {
              label: "值班员",
              prop: "person",
              search:true,
              type: "select",
              dicUrl: "/api/policeman/policeman/all",
              props: {
                label: "name",
                value: "id"
              }
            },
            {
              label: "联系方式",
              prop: "contact",
            },
            {
              label: "值班岗位",
              prop: "station",
              row: true,
              span: 24
            },
            {
              label: "值班时间",
              prop: "startTime",
              type: "datetime",
              defaultTime: '00:00:00',
              format: "yyyy-MM-dd",
              valueFormat: "yyyy-MM-dd HH:mm:ss",
              rules: [{
                required: true,
                message: "请选择值班时间",
                trigger: "blur"
              }],
            label: "值班类型",
            prop: "type",
            },
            {
              label: "带班领导",
@@ -109,6 +156,7 @@
              label: "联系方式",
              prop: "leadContact",
            },
          ]
        },
        data: [],
@@ -150,6 +198,12 @@
              this.form.leadContact = e.contact
            }
          })
      }
    },
    'excelForm.isCovered'() {
      if (this.excelForm.isCovered !== '') {
        const column = this.findObject(this.excelOption.column, "excelFile");
        column.action = `/api/scheduling/scheduling/import-scheduling?isCovered=${this.excelForm.isCovered}`;
        }
      },
    },
@@ -274,10 +328,24 @@
          const securityIdColumns = this.findObject(this.option.column, "leads")
          securityIdColumns.dicData = this.policemanList
        })
      }
    },
    //下面为导入操作
    handleImport() {
      this.excelBox = true;
    },
    uploadAfter(res, done, loading, column) {
      window.console.log(column);
      this.excelBox = false;
      this.refreshChange();
      done();
    },
    handleTemplate() {
      exportBlob(`/api/scheduling/scheduling/export-template?${this.website.tokenHeader}=${getToken()}`).then(res => {
        downloadXls(res.data, "值班信息数据模板.xlsx");
      })
    },
    }
  };
</script>
<style>
</style>
<style></style>
src/views/villagePersonInfo/villagePersonInfo.vue
@@ -34,7 +34,7 @@
        </el-button>
      </template>
    </avue-crud>
    <el-dialog title="用户数据导入"
    <el-dialog title="数据导入"
               append-to-body
               :visible.sync="excelBox"
               width="555px">