上饶市警务平台后台管理前端
zhongrj
2024-12-13 937998f45a5c0b8772d3f9e2ed97063a4818e60f
小区管理新增默认小区设置
3 files modified
18341 ■■■■■ changed files
package-lock.json 18033 ●●●●● patch | view | raw | blame | history
src/api/villageInfo/villageInfo.js 7 ●●●●● patch | view | raw | blame | history
src/views/community/community.vue 301 ●●●● patch | view | raw | blame | history
package-lock.json
Diff too large
src/api/villageInfo/villageInfo.js
@@ -77,3 +77,10 @@
  })
}
export const setWeight = (row) => {
  return request({
    url: '/api/villageInfo/villageInfo/setWeight',
    method: 'post',
    data: row
  })
}
src/views/community/community.vue
@@ -1,6 +1,7 @@
<template>
  <basic-container>
    <avue-crud :option="option"
    <avue-crud
      :option="option"
               :table-loading="loading"
               :data="data"
               :page.sync="page"
@@ -17,21 +18,40 @@
               @current-change="currentChange"
               @size-change="sizeChange"
               @refresh-change="refreshChange"
               @on-load="onLoad">
      @on-load="onLoad"
    >
      <template slot="menuLeft">
        <el-button type="success"
        <el-button
          type="success"
                   size="small"
                   plain
                   icon="el-icon-upload2"
                   @click="handleImport">导入
          @click="handleImport"
          >导入
        </el-button>
      </template>
      <template slot-scope="{ row }" slot="weight">
        <el-switch @change="isWeightInput($event, row,1)" v-model="row.weight" :active-value="1" :inactive-value="0"
          active-color="#13ce66" inactive-color="#ccc">
        </el-switch>
      </template>
      <template slot-scope="{ row }" slot="stationWeight">
        <el-switch @change="isWeightInput($event, row,2)" v-model="row.stationWeight" :active-value="1" :inactive-value="0"
          active-color="#13ce66" inactive-color="#ccc">
        </el-switch>
      </template>
    </avue-crud>
    <el-dialog title="小区数据导入"
    <el-dialog
      title="小区数据导入"
               append-to-body
               :visible.sync="excelBox"
               width="555px">
      <avue-form :option="excelOption" v-model="excelForm" :upload-after="uploadAfter">
      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>
@@ -43,7 +63,14 @@
</template>
<script>
  import {getPage, getDetails, add, update, remove} from "@/api/villageInfo/villageInfo";
import {
  getPage,
  getDetails,
  add,
  update,
  remove,
  setWeight
} from "@/api/villageInfo/villageInfo";
  import {mapGetters} from "vuex";
  import {exportBlob} from "@/api/common";
  import {getToken} from "@/util/auth";
@@ -59,24 +86,24 @@
        page: {
          pageSize: 10,
          currentPage: 1,
          total: 0
        total: 0,
        },
        excelOption: {
          submitBtn: false,
          emptyBtn: false,
          column: [
            {
              label: '模板上传',
              prop: 'excelFile',
              type: 'upload',
            label: "模板上传",
            prop: "excelFile",
            type: "upload",
              drag: true,
              loadText: '模板上传中,请稍等',
            loadText: "模板上传中,请稍等",
              span: 24,
              propsHttp: {
                res: 'data'
              res: "data",
              },
              tip: '请上传 .xls,.xlsx 标准格式文件',
              action: "/api/villageInfo/villageInfo/import-village-info"
            tip: "请上传 .xls,.xlsx 标准格式文件",
            action: "/api/villageInfo/villageInfo/import-village-info",
            },
            {
              label: "数据覆盖",
@@ -87,12 +114,12 @@
              dicData: [
                {
                  label: "否",
                  value: 0
                value: 0,
                },
                {
                  label: "是",
                  value: 1
                }
                value: 1,
              },
              ],
              value: 0,
              slot: true,
@@ -100,21 +127,21 @@
                {
                  required: true,
                  message: "请选择是否覆盖",
                  trigger: "blur"
                }
              ]
                trigger: "blur",
              },
            ],
            },
            {
              label: '模板下载',
              prop: 'excelTemplate',
            label: "模板下载",
            prop: "excelTemplate",
              formslot: true,
              span: 24,
            }
          ]
          },
        ],
        },
        selectionList: [],
        option: {
          height:'auto',
        height: "auto",
          calcHeight: 30,
          tip: false,
          searchShow: true,
@@ -143,33 +170,58 @@
              prop: "aoiName",
              type: "input",
              search: true,
              rules: [{
            searchSpan:5,
            rules: [
              {
                required: true,
                message: "请输入小区名",
                trigger: "blur"
              }],
                trigger: "blur",
              },
            ],
            },
            {
              label: "小区范围",
              prop: "position",
              type: "input",
              rules: [{
            rules: [
              {
                required: true,
                message: "请输入小区范围",
                trigger: "blur"
              }],
                trigger: "blur",
              },
            ],
            },
            {
              label: "责任区",
              prop: "areaName",
            align:"center",
              addDisplay:false,
              editDisplay:false,
              viewDisplay:false,
              rules: [{
            rules: [
              {
                required: true,
                message: "请选择所属责任区",
                trigger: "blur"
              }]
                trigger: "blur",
              },
            ],
          },
          {
            label: "派出所",
            prop: "policeStationName",
            searchSpan:4,
            align:"center",
            addDisplay: false,
            editDisplay: false,
            viewDisplay: false,
            search:true,
            rules: [
              {
                required: true,
                message: "请输入派出所",
                trigger: "blur",
              },
            ],
            },
            {
              label: "责任区",
@@ -177,17 +229,82 @@
              type: "tree",
              emitPath:false,
              hide:true,
              dicUrl: "api/policeStationInfo/policeStationInfo/getPoliceStationTwoTrees",
            dicUrl:
              "api/policeStationInfo/policeStationInfo/getPoliceStationTwoTrees",
              parent:false,
              props:{
                label:'name',
                value:'id'
              label: "name",
              value: "id",
              },
              rules: [{
            rules: [
              {
                required: true,
                message: "请选择所属责任区",
                trigger: "blur"
              }]
                trigger: "blur",
              },
            ],
          },
          {
            label: "是否分局默认小区",
            prop: "weight",
            type: "select",
            search:true,
            slot:true,
            searchSpan:4,
            align:"center",
            searchLabelWidth:130,
            dicData: [
              {
                label: "全部",
                value: "",
              },
              {
                label: "是",
                value: "1",
              },
              {
                label: "否",
                value: "0",
              },
            ],
            rules: [
              {
                required: true,
                message: "请选择所属责任区",
                trigger: "blur",
              },
            ],
          },
          {
            label: "是否派出所默认小区",
            prop: "stationWeight",
            type: "select",
            slot:true,
            search:true,
            searchSpan:4,
            align:"center",
            searchLabelWidth:150,
            dicData: [
              {
                label: "全部",
                value: "",
              },
              {
                label: "是",
                value: "1",
              },
              {
                label: "否",
                value: "0",
              },
            ],
            rules: [
              {
                required: true,
                message: "请选择所属责任区",
                trigger: "blur",
              },
            ],
            },
            {
              label: "创建人",
@@ -210,6 +327,7 @@
            {
              label: "创建时间",
              prop: "createTime",
            align:"center",
              addDisplay: false,
              editDisplay: false,
              viewDisplay: false,
@@ -250,10 +368,9 @@
              viewDisplay: false,
              hide: true,
            },
          ]
        }
        ,
        data: []
        ],
      },
      data: [],
      };
    },
    computed: {
@@ -263,49 +380,86 @@
          addBtn: this.vaildData(this.permission.community_add, false),
          viewBtn: this.vaildData(this.permission.community_view, false),
          delBtn: this.vaildData(this.permission.community_delete, false),
          editBtn: this.vaildData(this.permission.community_edit, false)
        editBtn: this.vaildData(this.permission.community_edit, false),
        };
      },
      ids() {
        let ids = [];
        this.selectionList.forEach(ele => {
      this.selectionList.forEach((ele) => {
          ids.push(ele.id);
        });
        return ids.join(",");
      }
    },
    },
    methods: {
      rowSave(row, done, loading) {
        add(row).then(() => {
    // 是否默认小区设置 type: 1:分局权重设置  2:派出所权重设置
    isWeightInput(e,row,type){
      if(!row.policeStationId){
        this.$message({
            type: "error",
            message: "无法匹配分局派出所,无法分配!",
          });
        return
      }
      if(type===1){
        row.weight = e
      }
      if(type===2){
        row.stationWeight = e
      }
      // 更新
      setWeight(row).then(
        () => {
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!"
            message: "操作成功!",
          });
          done();
        }, error => {
        },
        (error) => {
          loading();
          window.console.log(error);
        });
        }
      );
      },
      rowUpdate(row, index, done, loading) {
        update(row).then(() => {
    rowSave(row, done, loading) {
      add(row).then(
        () => {
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!"
            message: "操作成功!",
          });
          done();
        }, error => {
        },
        (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"
        type: "warning",
        })
          .then(() => {
            return remove(row.id);
@@ -314,7 +468,7 @@
            this.onLoad(this.page);
            this.$message({
              type: "success",
              message: "操作成功!"
            message: "操作成功!",
            });
          });
      },
@@ -326,7 +480,7 @@
        this.$confirm("确定将选择数据删除?", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        type: "warning",
        })
          .then(() => {
            return remove(this.ids);
@@ -335,14 +489,14 @@
            this.onLoad(this.page);
            this.$message({
              type: "success",
              message: "操作成功!"
            message: "操作成功!",
            });
            this.$refs.crud.toggleSelection();
          });
      },
      beforeOpen(done, type) {
        if (["edit", "view"].includes(type)) {
          getDetails(this.form.id).then(res => {
        getDetails(this.form.id).then((res) => {
              this.form = res.data.data;
          });
        }
@@ -376,7 +530,11 @@
      },
      onLoad(page, params = {}) {
        this.loading = true;
        getPage(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
      getPage(
        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;
@@ -395,13 +553,16 @@
        done();
      },
      handleTemplate() {
        exportBlob(`/api/villageInfo/villageInfo/export-template?${this.website.tokenHeader}=${getToken()}`).then(res => {
      exportBlob(
        `/api/villageInfo/villageInfo/export-template?${
          this.website.tokenHeader
        }=${getToken()}`
      ).then((res) => {
          downloadXls(res.data, "小区数据模板.xlsx");
        })
      });
      },
    }
  },
  };
</script>
<style>
</style>
<style></style>