zengh
2022-02-25 6c700995c5e9bbe3a72cfc60fab863b3566e303a
任务拆分
1 files modified
2 files added
2802 ■■■■■ changed files
src/router/views/index.js 14 ●●●●● patch | view | raw | blame | history
src/views/activitys/real_px.vue 1394 ●●●●● patch | view | raw | blame | history
src/views/activitys/real_xc.vue 1394 ●●●●● patch | view | raw | blame | history
src/router/views/index.js
@@ -575,19 +575,5 @@
      import( /* webpackChunkName: "views" */ '@/views/zc/zc')
  }]
}
  , {
  path: '/activitys',
  component: Layout,
  redirect: '/activitys/index',
  children: [{
    path: 'index',
    name: '活动下发',
    meta: {
      i18n: 'real'
    },
    component: () =>
      import( /* webpackChunkName: "views" */ '@/views/activitys/real')
  }]
},
]
src/views/activitys/real_px.vue
New file
@@ -0,0 +1,1394 @@
<template>
  <basic-container class="activitys">
    <avue-crud
      :option="option"
      :table-loading="loading"
      :before-open="beforeOpen"
      :data="data"
      :page.sync="page"
      ref="crud"
      @row-del="rowDel"
      v-model="form"
      :permission="permissionList"
      @row-update="rowUpdate"
      @row-save="rowSave"
      :row-style="rowStyle"
      :search.sync="search"
      row-class-name="tabFontSize"
      @search-change="searchChange"
      @search-reset="searchReset"
      @selection-change="selectionChange"
      @current-change="currentChange"
      @size-change="sizeChange"
      @row-click="rowClick"
      @refresh-change="refreshChange"
      @on-load="onLoad"
    >
      <!-- @row-click="rowClick" -->
      <template slot="menuLeft">
        <el-button
          type="danger"
          v-show="true"
          size="mini"
          icon="el-icon-delete"
          plain
          v-if="permission.real_delete"
          @click="handleDelete"
        >删 除
        </el-button>
      </template>
      <!-- <template slot="menuLeft">
        <el-button
          v-bind:class="activeClass == 0 ? 'btn-color' : ''"
          size="mini"
          @click="getBRdata(0)"
          >本日
        </el-button>
        <el-button
          v-bind:class="activeClass == 1 ? 'btn-color' : ''"
          size="mini"
          @click="getBRdata(1)"
          >本周
        </el-button>
        <el-button
          v-bind:class="activeClass == 2 ? 'btn-color' : ''"
          size="mini"
          @click="getBRdata(2)"
          >本月
        </el-button>
        <el-button
          v-bind:class="activeClass == 3 ? 'btn-color' : ''"
          size="mini"
          @click="getQBdata(3)"
          >全部
        </el-button>
      </template> -->
      <!-- <template slot="menuLeft">
        <el-button
          type="warning"
          size="mini"
          plain
          icon="el-icon-download"
          @click="handleExport"
          >导出
        </el-button>
        <el-button
          type="warning"
          size="mini"
          plain
          icon="el-icon-pie-chart"
          @click="handleExportStatis"
          >导出报表
        </el-button>
      </template> -->
      <template slot-scope="{ row }" slot="jtype">
        <el-tag
        >{{
            row.jtype == "0" || row.jtype == ""
              ? "未派发"
              : row.jtype == "1" &&
              (row.securityId == null || row.securityId == "")
              ? "未接收"
              : row.jtype == "1" &&
              (row.securityId != null || row.securityId != "")
                ? "已接收"
                : "已处置"
          }}
        </el-tag>
      </template>
      <template slot-scope="{ row }" slot="cid">
        <el-tag
        >{{
            row.cid == "1" ? "事件发生" : row.cid == "3" ? "是" : "事件恢复"
          }}
        </el-tag>
      </template>
      <template slot-scope="{ type, size, row }" slot="menu">
        <el-button
          v-if="row.jtype == 0 || row.jtype == 0 || row.jtype == ''"
          icon="el-icon-s-order"
          :size="size"
          :type="type"
          @click.stop="PoliceTracking(row)"
        >派发
        </el-button>
      </template>
      <template slot-scope="{ type, disabled }" slot="lineForm">
        <div class="mapClassMain" style="width: 860px; height: 400px">
          <Map ref="modalForm"/>
        </div>
      </template>
    </avue-crud>
    <real-popup ref="realPopupView"></real-popup>
    <el-drawer title="电子地图" append-to-body="true" :visible.sync="showMap">
      <iframe
        id="mapDiv"
        ref="mapDiv"
        src="/map/index.html?openid=ClientManagement&ISinit=1"
        frameborder="0"
        width="100%"
        height="100%"
      ></iframe>
    </el-drawer>
  </basic-container>
</template>
<script>
import {
  getList,
  remove,
  update,
  add,
  getclient,
} from "@/api/activitys/activitys";
import {mapGetters} from "vuex";
import AvueMap from "avue-plugin-map";
export default {
  data() {
    return {
      showMap: false,
      hls: "",
      videoSource: "",
      activeClass: 3,
      form: {},
      query: {},
      search: {},
      dateTime: [],
      loading: true,
      page: {
        pageSize: 10,
        currentPage: 1,
        total: 0,
      },
      selectionList: [],
      option: {
        height: "auto",
        indexLabel: "序号",
        calcHeight: 54,
        labelWidth: "100",
        size: "mini",
        border: false,
        //stripe:true,
        menuWidth: 260,
        dialogWidth: 950,
        tip: false,
        searchShow: true,
        searchMenuSpan: 3,
        align: "center",
        index: true,
        viewBtn: true,
        selection: true,
        dialogClickModal: false,
        column: [
          {
            label: "任务标题",
            prop: "rname",
            search: true,
            searchSpan: 4,
            span: 12,
            rules: [
              {
                required: true,
                message: "请选择报警时间",
                trigger: "blur",
              },
            ],
          },
          {
            label: "下发时间",
            type: "datetime",
            prop: "time",
            width: 160,
            span: 12,
            format: "yyyy-MM-dd HH:mm:ss",
            valueFormat: "yyyy-MM-dd HH:mm:ss",
            rules: [
              {
                required: true,
                message: "请选择报警时间",
                trigger: "blur",
              },
            ],
          },
          {
            label: "任务封面",
            prop: "url",
            // align:'center',
            width: 80,
            type: "upload",
            listType: "picture-img",
            action: "/api/blade-resource/oss/endpoint/put-file",
            propsHttp: {
              res: "data",
              url: "link",
            },
            // hide: true,
            span: 24,
          },
          // {
          //   label: "报警时间",
          //   prop: "releaseTimeRange",
          //   type: "datetime",
          //   format: "yyyy-MM-dd",
          //   valueFormat: "yyyy-MM-dd",
          //   searchValue: [this.getStartTime(), this.getEndTime()],
          //   searchRange: true,
          //   searchSpan: 5,
          //   hide: true,
          //   addDisplay: false,
          //   editDisplay: false,
          //   viewDisplay: false,
          //   search: true,
          //   rules: [
          //     {
          //       required: true,
          //       message: "请输入时间",
          //       trigger: "blur",
          //     },
          //   ],
          // },
          {
            label: "任务内容",
            prop: "content",
            span: 24,
          },
          // {
          //   label: "地址",
          //   prop: "place",
          //   span: 10,
          //   rules: [
          //     {
          //       required: true,
          //       message: "请选择地址",
          //       trigger: "blur",
          //     },
          //   ],
          // },
          // {
          //   label: null,
          //   prop: "map",
          //   labelWidth: "0",
          //   searchSpan: 0,
          //   maxlength: 0,
          //   hide: true,
          //   span: 2,
          //   // display:false,
          //   component: "AvueMap",
          // },
          // {
          //   label: "经度",
          //   hide: true,
          //   prop: "jd",
          //   searchSpan: 2,
          //   width: "100",
          //   labelWidth: "120",
          //   formatter: (row, value, label, column) => {
          //     return (value = value.substring(0, 11));
          //   },
          //   span: 7,
          // },
          // {
          //   label: "纬度",
          //   labelWidth: "45",
          //   hide: true,
          //   prop: "wd",
          //   formatter: (row, value, label, column) => {
          //     return (value = value.substring(0, 10));
          //   },
          //   span: 5,
          // },
          {
            label: "所属辖区",
            prop: "jurisdiction",
            searchLabelWidth: 80,
            search: true,
            searchSpan: 4,
            overHidden: true,
            parent: false,
            type: "tree",
            dicUrl: "/api/jurisdiction/lazy-tree",
            props: {
              label: "title",
              value: "id"
            },
            checkStrictly: true,
            rules: [
              {
                required: true,
                message: "请选择所属辖区",
                trigger: "click"
              }
            ]
          },
          {
            label: "省份",
            hide: true,
            prop: "province",
            // search: true,
            width: 100,
            searchSpan: 2,
            searchLabelWidth: 45,
            placeholder: "省份",
            type: "select",
            value: "36",
            props: {
              label: "name",
              value: "code",
            },
            cascaderItem: ["city", "district"],
            dicUrl: "/api/blade-system/region/select",
            span: 6,
            className: "cityreal1",
            addDisplay: true,
            editDisplay: true,
            viewDisplay: true,
          },
          {
            label: "地市",
            hide: true,
            prop: "city",
            type: "select",
            width: 100,
            searchPlaceholder: "地市",
            placeholder: "地市",
            searchLabelWidth: 1,
            value: "3601",
            searchSpan: 2,
            // search: true,
            props: {
              label: "name",
              value: "code",
            },
            dicUrl: "/api/blade-system/region/select?code={{key}}",
            span: 3,
            labelWidth: "0",
            className: "cityreal2",
            addDisplay: true,
            editDisplay: true,
            viewDisplay: true,
          },
          {
            label: "区县",
            hide: true,
            searchSpan: 2,
            searchLabelWidth: 1,
            width: 100,
            searchPlaceholder: "区县",
            placeholder: "区县",
            // search: true,
            prop: "district",
            type: "select",
            props: {
              label: "name",
              value: "code",
            },
            dicUrl: "/api/blade-system/region/select?code={{key}}",
            span: 3,
            labelWidth: "0",
            className: "cityreal3",
            addDisplay: true,
            editDisplay: true,
            viewDisplay: true,
          },
          {
            label: "任务状态",
            prop: "rtype",
            type: "select",
            value: "2",
            dicData: [
              {
                label: "任务开始",
                value: "2",
              },
              {
                label: "任务结束",
                value: "1",
              },
              {
                label: "正在进行",
                value: "0",
              },
            ],
            // label: "任务状态",
            // searchSpan: 3,
            // width: 96,
            // search: true,
            // slot: true,
            // value: "0",
            // searchPlaceholder: "请选择",
            // prop: "rtype",
            // type: "select",
            // dicData: [
            //   {
            //     label: "任务开始",
            //     value: "0",
            //   },
            //   {
            //     label: "正在进行",
            //     value: "1",
            //   },
            //   {
            //     label: "任务结束",
            //     value: "2",
            //   },
            // ],
          },
          // {
          //   label: "派发人",
          //   prop: "alarmPeople",
          //   width: 90,
          //   addDisplay: false,
          //   editDisplay: false,
          // },
          {
            label: "积分数值",
            prop: "integral",
            type: "number",
            // multiple: true,
            // dicUrl: "/api/catalogs/catalogs/getBigTree",
            // props: {
            //   label: "title",
            // },
            width: 72,
            // hide: true,
            minRows: 1,
            value: 1,
            // leafOnly: "",
            addDisplay: true,
            editDisplay: true,
            viewDisplay: true,
          },
          {
            label: "接收人数",
            prop: "jnum",
            type: "number",
            // multiple: true,
            // dicUrl: "/api/catalogs/catalogs/getBigTree",
            // props: {
            //   label: "title",
            // },
            width: 72,
            // hide: true,
            minRows: 1,
            value: 1,
            // leafOnly: "",
            addDisplay: true,
            editDisplay: true,
            viewDisplay: true,
          },
          // {
          //   label: "巡逻路线",
          //   prop: "xllx",
          //   hide: true,
          //   display: true,
          //   type: "tree",
          //   dicUrl: "/api/routeIn/routein/tree",
          //   props: {
          //     label: "title",
          //   },
          //   addDisplay: true,
          // },
          {
            label: "请在下方地图中,建立路径!",
            labelWidth: "0",
            className: "mapClass",
            prop: "haveMap",
            hide: true,
            display: true,
            rules: [
              {
                required: true,
                message: "请在下方地图中,建立路径!",
                trigger: "blur",
              },
            ],
            addDisabled: true,
            editDisabled: true,
            // value: "", //赋值不上去,舍弃
            // type: "tree",
            // dicUrl: "/api/routeIn/routein/tree",
            // props: {
            //   label: "title",
            // },
          },
          {
            label: "路线展示",
            labelWidth: "0",
            prop: "line",
            className: "mapClass",
            hide: true,
            display: true,
            span: 24,
            formslot: true,
            addDisplay: true,
          },
        ],
      },
      data: [],
      recorder: null,
      peopleList: [],
      // rotesData: "",
    };
  },
  watch: {
    "form.map": {
      // form是表单或者表格绑定的数据集,v-model='form'
      handler(val) {
        var that = this;
        if (val) {
          //重新加载一次页面详情数据,解决新的省市区无法写入问题
          //判断是新增还是修改
          if (that.isEdit) {
            getclient(this.form.id).then((res) => {
              // that.province = res.data.data.province;
              // that.city = res.data.data.city;
              // that.district = res.data.data.district;
            });
          }
          //地址截取,从县/区开始截取,并且取从县区第一个出现的位置开始
          if (val.formattedAddress == "") {
            return;
          }
          //经纬度替换
          this.form.wd = val.latitude;
          this.form.jd = val.longitude;
          var address = val.formattedAddress.toString();
          if (address.search("县") != -1) {
            this.form.place = address.substring(
              address.indexOf("县") + 1,
              address.length
            );
          }
          if (address.search("区") != -1) {
            this.form.place = address.substring(
              address.indexOf("区") + 1,
              address.length
            );
          }
          //写入新的省市区
          that.form.province = val.addressComponent.province;
          if (val.addressComponent.city == "") {
            that.form.city = val.addressComponent.province;
          } else {
            that.form.city = val.addressComponent.city;
          }
          that.form.district = val.addressComponent.district;
        } else {
          that.form.map = {
            formattedAddress: "",
            latitude: 28.699957,
            longitude: 115.862118,
          };
        }
      },
      immediate: true,
    },
    // "form.alarmType": {
    //   handler(val) {
    //     // var xllx = this.findObject(this.option.column, "xllx");
    //     var xllxzs = this.findObject(this.option.column, "xllxzs");
    //     if (val === "巡逻任务") {
    //       // xllx.display = true;
    //       xllxzs.display = true;
    //       // xllx.rules = [
    //         // {
    //         //   required: true,
    //         //   message: "请选择巡逻路线",
    //         //   trigger: "blur",
    //         // },
    //       // ];
    //     } else {
    //       // xllx.display = false;
    //       xllxzs.display = false;
    //       // xllx.rules = [];
    //     }
    //   },
    //   immediate: true,
    // },
    "form.line": {
      handler(val) {
        if (val) {
          this.getxllx(val);
        }
      },
      immediate: true,
    },
    rotesData() {
      // console.log(this.rotesData, "rotesDatarotesDatarotesData");
      // console.log(this.rotesData, "this.rotesDatathis.rotesData");
      if (this.rotesData) {
        // var haveMap = (this.option.column[9].value = "已选择路径!");
        // haveMap.value = "已选择路径!";
        // console.log(haveMap);
        this.form["line"] = this.rotesData;
        this.form["haveMap"] = "已绘制路径!";
      } else {
        this.form["line"] = "";
        this.form["haveMap"] = "";
      }
    },
  },
  computed: {
    ...mapGetters(["permission", "flowRoutes", "rotesData", "userInfo"]),
    permissionList() {
      return {
        addBtn: this.vaildData(this.permission.real_add, false),
        viewBtn: this.vaildData(null, false),
        delBtn: this.vaildData(this.permission.real_delete, false),
        editBtn: this.vaildData(this.permission.real_edit, false),
      };
    },
    ids() {
      let ids = [];
      this.selectionList.forEach((ele) => {
        ids.push(ele.id);
      });
      return ids.join(",");
    },
  },
  created() {
    this.dateTime = this.getDate();
  },
  mounted() {
    var xb = JSON.parse(window.sessionStorage.getItem("sjsb"));
    var data = this.$route.query;
    if (xb == 1) {
      this.form = data;
      this.openAdd();
      window.sessionStorage.removeItem("sjsb");
    }
  },
  methods: {
    rowSave(row, done, loading) {
      // console.log(row);
      // return;
      var userId1 = this.userInfo.user_id;
      var username = this.userInfo.nick_name;
      let d = {
        line: row.line, //路线
        rname: row.rname, //标题
        url: row.url, //封面
        time: row.time, //下发时间
        province: row.$province, //省
        city: row.$city, //城市
        district: row.$district, //区县
        jnum: row.jnum, //接收总数
        integral: row.integral + "", //积分
        content: row.content, //内容
        rtype: row.rtype, //任务状态
        fid: userId1,//发起人id
        fname: username, //发起人id
        jurisdiction: row.jurisdiction
      };
      // console.log(d);
      // done();
      // return;
      let that = this;
      add(d).then(
        () => {
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!",
          });
          done();
        },
        (error) => {
          loading();
        }
      );
      return;
    },
    getxllx(val) {
      var that = this;
      if (this.$refs.modalForm == undefined) {
        setTimeout(function () {
          try {
            that.$refs.modalForm.addLinesDraw(val);
          } catch (error) {
          }
        }, 1500);
      } else {
        try {
          that.$refs.modalForm.addLinesDraw(val);
        } catch (error) {
        }
      }
    },
    rowUpdate(row, index, done, loading) {
      let that = this;
      update(row).then(
        () => {
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!",
          });
          done();
        },
        (error) => {
          loading();
        }
      );
    },
    rowDel(row) {
      this.$confirm("确定将选择数据删除?", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          return remove(row.id);
        })
        .then(() => {
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!",
          });
        });
    },
    searchReset() {
      this.activeClass = 3;
      //清空搜索框中的内容
      this.query = {};
      //清空this.$route.query
      this.$router.push({query: {}});
      this.onLoad(this.page);
    },
    searchChange(params, done) {
      //清空this.$route.query
      this.$router.push({query: {}});
      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();
    },
    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) {
      // console.log(type, "this.formthis.formthis.form");
      // console.log(type);
      // if (["edit", "view"].includes(type)) {
      //   getclient(this.form.id).then((res) => {
      //     this.form = res.data.data;
      //   });
      // }
      // console.log(this.form);
      if (type == "add") {
        this.$store.commit("setRotesData", false); //用vuex传最终数据 清除
        done();
        return;
      }
      if (this.form.line != "" && this.form != undefined) {
        this.form["haveMap"] = "已绘制路径!";
      } else {
        this.form["haveMap"] = "";
      }
      done();
    },
    currentChange(currentPage) {
      this.page.currentPage = currentPage;
    },
    sizeChange(pageSize) {
      this.page.pageSize = pageSize;
    },
    refreshChange() {
      this.onLoad(this.page, this.query);
    },
    onLoad(page, params = {}) {
      getList(page.currentPage, page.pageSize,params).then((res) => {
        const data = res.data.data;
        this.page.total = data.total;
        data.records.sort((a, b) => {
          return a.jtype - b.jtype;
        });
        this.data = data.records;
        this.loading = false;
        this.selectionClear();
      });
    },
    getDate() {
      // 当前时间
      var timestamp = Date.parse(new Date());
      var serverDate = new Date(timestamp);
      // 本周周一的时间
      var mondayTime =
        timestamp - (serverDate.getDay() - 1) * 24 * 60 * 60 * 1000;
      var mondayData = new Date(mondayTime);
      //年
      var mondayY = mondayData.getFullYear();
      //月
      var mondayM =
        mondayData.getMonth() + 1 < 10
          ? "0" + (mondayData.getMonth() + 1)
          : mondayData.getMonth() + 1;
      //日
      var mondayD =
        mondayData.getDate() < 10
          ? "0" + mondayData.getDate()
          : mondayData.getDate();
      // 当前时间
      var currentData = new Date(timestamp);
      //年
      var currentY = currentData.getFullYear();
      //月
      var currentM =
        currentData.getMonth() + 1 < 10
          ? "0" + (currentData.getMonth() + 1)
          : currentData.getMonth() + 1;
      //日
      var currentD =
        currentData.getDate() < 10
          ? "0" + currentData.getDate()
          : currentData.getDate();
      //时
      var currenH =
        currentData.getHours() < 10
          ? "0" + currentData.getHours()
          : currentData.getHours();
      //分
      var currenM =
        currentData.getMinutes() < 10
          ? "0" + currentData.getMinutes()
          : currentData.getMinutes();
      //秒
      var currenS =
        currentData.getSeconds() < 10
          ? "0" + currentData.getSeconds()
          : currentData.getSeconds();
      return {
        day: {
          beginTime: currentY + "-" + currentM + "-" + currentD + " 00:00:00",
          endTime:
            currentY +
            "-" +
            currentM +
            "-" +
            currentD +
            " " +
            currenH +
            ":" +
            currenM +
            ":00",
        },
        week: {
          beginTime: mondayY + "-" + mondayM + "-" + mondayD + " 00:00:00",
          endTime:
            currentY +
            "-" +
            currentM +
            "-" +
            currentD +
            " " +
            currenH +
            ":" +
            currenM +
            ":00",
        },
        month: {
          beginTime: mondayY + "-" + mondayM + "-01 00:00:00",
          endTime:
            currentY +
            "-" +
            currentM +
            "-" +
            currentD +
            " " +
            currenH +
            ":" +
            currenM +
            ":00",
        },
        current:
          currentY +
          "-" +
          currentM +
          "-" +
          currentD +
          " " +
          currenH +
          ":" +
          currenM +
          ":" +
          currenS,
      };
    },
    getBRdata(e) {
      this.activeClass = e;
      this.query = {};
      this.$router.push({query: {}});
      var today = new Date();
      var params = {};
      if (e == 0) {
        params = {
          beginTime: this.showToDay(today) + " 00:00:00",
          endTime: this.showToDay(today) + " 23:59:59",
        };
        //修改搜索框中的值
        this.search.releaseTimeRange = [
          this.showToDay(today) + " 00:00:00",
          this.showToDay(today) + " 23:59:59",
        ];
      }
      if (e == 1) {
        params = {
          beginTime: this.showWeekFirstDay(today) + " 00:00:00",
          endTime: this.showToDay(today) + " 23:59:59",
        };
        //修改搜索框中的值
        this.search.releaseTimeRange = [
          this.showWeekFirstDay(today) + " 00:00:00",
          this.showToDay(today) + " 23:59:59",
        ];
      }
      if (e == 2) {
        params = {
          beginTime: this.showMonthFirstDay(today) + " 00:00:00",
          endTime: this.showToDay(today) + " 23:59:59",
        };
        //修改搜索框中的值
        this.search.releaseTimeRange = [
          this.showMonthFirstDay(today) + " 00:00:00",
          this.showToDay(today) + " 23:59:59",
        ];
      }
      this.query = params;
      this.page.currentPage = 1;
      this.onLoad(this.page, params);
    },
    //本日
    showToDay(Nowdate) {
      var M = Number(Nowdate.getMonth()) + 1;
      if (M < 10) {
        M = "0" + M;
      }
      var day = Nowdate.getDate();
      if (day < 10) {
        day = "0" + day;
      }
      return Nowdate.getFullYear() + "-" + M + "-" + day;
    },
    //本周第一天
    showWeekFirstDay(Nowdate) {
      var WeekFirstDay = new Date(Nowdate - (Nowdate.getDay() - 1) * 86400000);
      var M = Number(WeekFirstDay.getMonth()) + 1;
      if (M < 10) {
        M = "0" + M;
      }
      var day = WeekFirstDay.getDate();
      if (day < 10) {
        day = "0" + day;
      }
      return WeekFirstDay.getFullYear() + "-" + M + "-" + day;
    },
    //本月第一天
    showMonthFirstDay(Nowdate) {
      var MonthFirstDay = new Date(
        Nowdate.getFullYear(),
        Nowdate.getMonth(),
        1
      );
      var M = Number(MonthFirstDay.getMonth()) + 1;
      if (M < 10) {
        M = "0" + M;
      }
      return (
        MonthFirstDay.getFullYear() +
        "-" +
        M +
        "-" +
        "0" +
        MonthFirstDay.getDate()
      );
    },
    getBZdata(e) {
      this.activeClass = e;
      var params = {
        beginTime: this.dateTime.week.beginTime,
        endTime: this.dateTime.week.endTime,
      };
      this.query = params;
      this.page.currentPage = 1;
      this.onLoad(this.page, params);
    },
    getBYdata(e) {
      this.activeClass = e;
      var params = {
        beginTime: this.dateTime.month.beginTime,
        endTime: this.dateTime.month.endTime,
      };
      this.query = params;
      this.page.currentPage = 1;
      this.onLoad(this.page, params);
    },
    getQBdata(e) {
      this.search.releaseTimeRange = ["", ""];
      this.activeClass = e;
      var params = {};
      this.query = params;
      this.page.currentPage = 1;
      this.onLoad(this.page, params);
    },
    rowStyle({row, column, rowIndex}) {
      if (row.jtype == "0") {
        return {
          color: "#ff2727",
        };
      } else if (row.jtype == "1") {
        return {
          color: "#15a2fe",
        };
      } else {
        return {
          color: "#000000",
        };
      }
    },
    handleStart(row) {
      var arr = [];
      this.$store.state.tags.tagList.forEach((item) => {
        if (item.label != "视频") {
          arr.push(item);
        }
      });
      this.$store.state.tags.tagList = arr;
      this.$router.push({
        path: `/real/video/`,
        query: row,
      });
    },
    handleHistory(row) {
      var arr = [];
      this.$store.state.tags.tagList.forEach((item) => {
        if (item.label != "设备历史") {
          arr.push(item);
        }
      });
      this.$store.state.tags.tagList = arr;
      this.$router.push({path: `/real/history/${row.deviceNumber}`});
    },
    handleMap(row) {
      this.showMap = true;
      this.$nextTick(() => {
        this.$refs.mapDiv.onload = () => {
          window.frames[0].init("ClientManagement", {
            x: row.jd,
            y: row.wd,
            clientID: row.deviceNumber,
          });
        };
      });
    },
    getStartTime() {
      if (
        this.$route.query.startTime != undefined &&
        this.$route.query.startTime != null &&
        this.$route.query.startTime != ""
      ) {
        return this.$route.query.startTime;
      }
      return "";
    },
    getEndTime() {
      if (
        this.$route.query.endTime != undefined &&
        this.$route.query.endTime != null &&
        this.$route.query.endTime != ""
      ) {
        return this.$route.query.endTime;
      }
      return "";
    },
    handleManage(row) {
      this.$refs.realPopupView.onItemGetParentData(row);
    },
    beginTimeOrEndTime(time) {
      var beginTime = new Date(time);
      var endTime = new Date(new Date(time).valueOf() - 1000 * 60 * 60 * 3);
      var beginY = beginTime.getFullYear();
      var beginM =
        beginTime.getMonth() + 1 < 10
          ? "0" + (beginTime.getMonth() + 1)
          : beginTime.getMonth() + 1;
      var beginD =
        beginTime.getDate() < 10
          ? "0" + beginTime.getDate()
          : beginTime.getDate();
      var beginH =
        beginTime.getHours() < 10
          ? "0" + beginTime.getHours()
          : beginTime.getHours();
      var beginm =
        beginTime.getMinutes() < 10
          ? "0" + beginTime.getMinutes()
          : beginTime.getMinutes();
      var begins =
        beginTime.getSeconds() < 10
          ? "0" + beginTime.getSeconds()
          : beginTime.getSeconds();
      var endY = endTime.getFullYear();
      var endM =
        endTime.getMonth() + 1 < 10
          ? "0" + (endTime.getMonth() + 1)
          : endTime.getMonth() + 1;
      var endD =
        endTime.getDate() < 10 ? "0" + endTime.getDate() : endTime.getDate();
      var endH =
        endTime.getHours() < 10 ? "0" + endTime.getHours() : endTime.getHours();
      var endm =
        endTime.getMinutes() < 10
          ? "0" + endTime.getMinutes()
          : endTime.getMinutes();
      var ends =
        endTime.getSeconds() < 10
          ? "0" + endTime.getSeconds()
          : endTime.getSeconds();
      return {
        begin: beginY + beginM + beginD + beginH + beginm + begins,
        end: endY + endM + endD + endH + endm + ends,
      };
    },
    PoliceTracking(row) {
      var arr = [];
      this.$store.state.tags.tagList.forEach((item) => {
        if (item.label != "任务详情") {
          arr.push(item);
        }
      });
      this.$store.state.tags.tagList = arr;
      //警情追踪
      this.$router.push({path: "/policeTracking/details", query: row});
    },
    //打开新增窗体
    openAdd() {
      this.$refs.crud.rowAdd();
    },
    //数据导出
    handleExport() {
      this.$confirm("是否导出实时警情数据?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      }).then(() => {
        window.open(
          `/api/alarm/alarm/export-alarm?beginTime=${this.$route.query.startTime}&endTime=${this.$route.query.endTime}&waringType=${this.$route.query.waringType}&timeDesc=${this.$route.query.timeDesc}`
        );
      });
    },
    //数据报表导出
    handleExportStatis() {
      let beginTime =
        this.$route.query.startTime == undefined
          ? ""
          : this.$route.query.startTime;
      let endTime =
        this.$route.query.endTime == undefined ? "" : this.$route.query.endTime;
      let waringType =
        this.$route.query.waringType == undefined
          ? ""
          : this.$route.query.waringType;
      let timeDesc =
        this.$route.query.timeDesc == undefined
          ? ""
          : this.$route.query.timeDesc;
      window.open(
        `https://web.byisf.com/api/blade-report/ureport/preview?_u=blade-alarm.statis.ureport.xml&beginTime=${beginTime}&endTime=${endTime}&waringType=${waringType}&timeDesc=${timeDesc}`
      );
      //window.open(`http://localhost:8108/ureport/excel?_u=blade-alarm.statis.ureport.xml&beginTime=${beginTime}&endTime=${endTime}&waringType=${waringType}&timeDesc=${timeDesc}`);
    },
    rowClick(val) {
      //行点击事件
      //警情追踪
      this.PoliceTracking(val);
    },
  },
};
</script>
<style>
.el-card__body .waringTypeClass {
  width: 12%;
}
.mapClass div label {
  display: none;
}
.mapClassMain {
  padding-left: 25px !important;
}
.cityreal2 div label,
.cityreal3 div label {
  display: none;
}
/*页面样式*/
.el-card__body .cityreal1 {
  width: 150px;
  padding-right: 0px !important;
}
.el-card__body .cityreal2 {
  width: 100px;
  padding-left: 10px !important;
  padding-right: 0px !important;
}
.el-card__body .cityreal3 {
  width: 100px;
  padding-left: 10px !important;
  padding-right: 0px !important;
}
/*新增窗体样式*/
.el-dialog .cityreal1 {
  width: 216px;
  padding-right: 0px !important;
}
.el-dialog .cityreal2 {
  width: 130px;
  padding-left: 10px !important;
  padding-right: 10px !important;
}
.el-dialog .cityreal3 {
  width: 105px;
  padding-left: 0px !important;
  padding-right: 0px !important;
}
.cityClassParams .avue-form__group.avue-form__group--flex {
  display: flex;
  justify-content: space-between;
}
.cityClassParams .cityClassSelect {
  flex: 1;
  margin: 0 !important;
  padding-left: 0px !important;
  padding-right: 0px !important;
}
.cityClassParams .cityClassSelect:nth-child(2) {
  margin: 0 10px !important;
}
.cityClassParams .cityClassSelect .el-form-item {
  margin-bottom: 0px !important;
}
.cityClassParams .cityClassSelect .el-form-item .el-input__inner {
  height: 28px !important;
  line-height: 28px !important;
}
.cityClass2 div label {
  display: none;
}
.cityClass3 div label {
  display: none;
}
.old-video-dialog {
  position: absolute !important;
  top: 0 !important;
  left: auto !important;
  right: 0px !important;
  bottom: 0 !important;
  margin: auto !important;
  height: 100% !important;
  width: 476px !important;
}
.old-video-dialog .el-dialog {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  margin: auto !important;
  margin-top: 15vh !important;
  height: 538px;
}
.old-video-dialog .el-dialog .el-dialog__body {
  height: calc(100% - 54px);
  box-sizing: border-box;
}
.el-button.btn-color {
  color: rgb(255, 255, 255);
  background-color: rgb(64, 158, 255);
  border-color: rgb(64, 158, 255);
}
.tabFontSize {
  font-size: 15px;
}
</style>
src/views/activitys/real_xc.vue
New file
@@ -0,0 +1,1394 @@
<template>
  <basic-container class="activitys">
    <avue-crud
      :option="option"
      :table-loading="loading"
      :before-open="beforeOpen"
      :data="data"
      :page.sync="page"
      ref="crud"
      @row-del="rowDel"
      v-model="form"
      :permission="permissionList"
      @row-update="rowUpdate"
      @row-save="rowSave"
      :row-style="rowStyle"
      :search.sync="search"
      row-class-name="tabFontSize"
      @search-change="searchChange"
      @search-reset="searchReset"
      @selection-change="selectionChange"
      @current-change="currentChange"
      @size-change="sizeChange"
      @row-click="rowClick"
      @refresh-change="refreshChange"
      @on-load="onLoad"
    >
      <!-- @row-click="rowClick" -->
      <template slot="menuLeft">
        <el-button
          type="danger"
          v-show="true"
          size="mini"
          icon="el-icon-delete"
          plain
          v-if="permission.real_delete"
          @click="handleDelete"
        >删 除
        </el-button>
      </template>
      <!-- <template slot="menuLeft">
        <el-button
          v-bind:class="activeClass == 0 ? 'btn-color' : ''"
          size="mini"
          @click="getBRdata(0)"
          >本日
        </el-button>
        <el-button
          v-bind:class="activeClass == 1 ? 'btn-color' : ''"
          size="mini"
          @click="getBRdata(1)"
          >本周
        </el-button>
        <el-button
          v-bind:class="activeClass == 2 ? 'btn-color' : ''"
          size="mini"
          @click="getBRdata(2)"
          >本月
        </el-button>
        <el-button
          v-bind:class="activeClass == 3 ? 'btn-color' : ''"
          size="mini"
          @click="getQBdata(3)"
          >全部
        </el-button>
      </template> -->
      <!-- <template slot="menuLeft">
        <el-button
          type="warning"
          size="mini"
          plain
          icon="el-icon-download"
          @click="handleExport"
          >导出
        </el-button>
        <el-button
          type="warning"
          size="mini"
          plain
          icon="el-icon-pie-chart"
          @click="handleExportStatis"
          >导出报表
        </el-button>
      </template> -->
      <template slot-scope="{ row }" slot="jtype">
        <el-tag
        >{{
            row.jtype == "0" || row.jtype == ""
              ? "未派发"
              : row.jtype == "1" &&
              (row.securityId == null || row.securityId == "")
              ? "未接收"
              : row.jtype == "1" &&
              (row.securityId != null || row.securityId != "")
                ? "已接收"
                : "已处置"
          }}
        </el-tag>
      </template>
      <template slot-scope="{ row }" slot="cid">
        <el-tag
        >{{
            row.cid == "1" ? "事件发生" : row.cid == "3" ? "是" : "事件恢复"
          }}
        </el-tag>
      </template>
      <template slot-scope="{ type, size, row }" slot="menu">
        <el-button
          v-if="row.jtype == 0 || row.jtype == 0 || row.jtype == ''"
          icon="el-icon-s-order"
          :size="size"
          :type="type"
          @click.stop="PoliceTracking(row)"
        >派发
        </el-button>
      </template>
      <template slot-scope="{ type, disabled }" slot="lineForm">
        <div class="mapClassMain" style="width: 860px; height: 400px">
          <Map ref="modalForm"/>
        </div>
      </template>
    </avue-crud>
    <real-popup ref="realPopupView"></real-popup>
    <el-drawer title="电子地图" append-to-body="true" :visible.sync="showMap">
      <iframe
        id="mapDiv"
        ref="mapDiv"
        src="/map/index.html?openid=ClientManagement&ISinit=1"
        frameborder="0"
        width="100%"
        height="100%"
      ></iframe>
    </el-drawer>
  </basic-container>
</template>
<script>
import {
  getList,
  remove,
  update,
  add,
  getclient,
} from "@/api/activitys/activitys";
import {mapGetters} from "vuex";
import AvueMap from "avue-plugin-map";
export default {
  data() {
    return {
      showMap: false,
      hls: "",
      videoSource: "",
      activeClass: 3,
      form: {},
      query: {},
      search: {},
      dateTime: [],
      loading: true,
      page: {
        pageSize: 10,
        currentPage: 1,
        total: 0,
      },
      selectionList: [],
      option: {
        height: "auto",
        indexLabel: "序号",
        calcHeight: 54,
        labelWidth: "100",
        size: "mini",
        border: false,
        //stripe:true,
        menuWidth: 260,
        dialogWidth: 950,
        tip: false,
        searchShow: true,
        searchMenuSpan: 3,
        align: "center",
        index: true,
        viewBtn: true,
        selection: true,
        dialogClickModal: false,
        column: [
          {
            label: "任务标题",
            prop: "rname",
            search: true,
            searchSpan: 4,
            span: 12,
            rules: [
              {
                required: true,
                message: "请选择报警时间",
                trigger: "blur",
              },
            ],
          },
          {
            label: "下发时间",
            type: "datetime",
            prop: "time",
            width: 160,
            span: 12,
            format: "yyyy-MM-dd HH:mm:ss",
            valueFormat: "yyyy-MM-dd HH:mm:ss",
            rules: [
              {
                required: true,
                message: "请选择报警时间",
                trigger: "blur",
              },
            ],
          },
          {
            label: "任务封面",
            prop: "url",
            // align:'center',
            width: 80,
            type: "upload",
            listType: "picture-img",
            action: "/api/blade-resource/oss/endpoint/put-file",
            propsHttp: {
              res: "data",
              url: "link",
            },
            // hide: true,
            span: 24,
          },
          // {
          //   label: "报警时间",
          //   prop: "releaseTimeRange",
          //   type: "datetime",
          //   format: "yyyy-MM-dd",
          //   valueFormat: "yyyy-MM-dd",
          //   searchValue: [this.getStartTime(), this.getEndTime()],
          //   searchRange: true,
          //   searchSpan: 5,
          //   hide: true,
          //   addDisplay: false,
          //   editDisplay: false,
          //   viewDisplay: false,
          //   search: true,
          //   rules: [
          //     {
          //       required: true,
          //       message: "请输入时间",
          //       trigger: "blur",
          //     },
          //   ],
          // },
          {
            label: "任务内容",
            prop: "content",
            span: 24,
          },
          // {
          //   label: "地址",
          //   prop: "place",
          //   span: 10,
          //   rules: [
          //     {
          //       required: true,
          //       message: "请选择地址",
          //       trigger: "blur",
          //     },
          //   ],
          // },
          // {
          //   label: null,
          //   prop: "map",
          //   labelWidth: "0",
          //   searchSpan: 0,
          //   maxlength: 0,
          //   hide: true,
          //   span: 2,
          //   // display:false,
          //   component: "AvueMap",
          // },
          // {
          //   label: "经度",
          //   hide: true,
          //   prop: "jd",
          //   searchSpan: 2,
          //   width: "100",
          //   labelWidth: "120",
          //   formatter: (row, value, label, column) => {
          //     return (value = value.substring(0, 11));
          //   },
          //   span: 7,
          // },
          // {
          //   label: "纬度",
          //   labelWidth: "45",
          //   hide: true,
          //   prop: "wd",
          //   formatter: (row, value, label, column) => {
          //     return (value = value.substring(0, 10));
          //   },
          //   span: 5,
          // },
          {
            label: "所属辖区",
            prop: "jurisdiction",
            searchLabelWidth: 80,
            search: true,
            searchSpan: 4,
            overHidden: true,
            parent: false,
            type: "tree",
            dicUrl: "/api/jurisdiction/lazy-tree",
            props: {
              label: "title",
              value: "id"
            },
            checkStrictly: true,
            rules: [
              {
                required: true,
                message: "请选择所属辖区",
                trigger: "click"
              }
            ]
          },
          {
            label: "省份",
            hide: true,
            prop: "province",
            // search: true,
            width: 100,
            searchSpan: 2,
            searchLabelWidth: 45,
            placeholder: "省份",
            type: "select",
            value: "36",
            props: {
              label: "name",
              value: "code",
            },
            cascaderItem: ["city", "district"],
            dicUrl: "/api/blade-system/region/select",
            span: 6,
            className: "cityreal1",
            addDisplay: true,
            editDisplay: true,
            viewDisplay: true,
          },
          {
            label: "地市",
            hide: true,
            prop: "city",
            type: "select",
            width: 100,
            searchPlaceholder: "地市",
            placeholder: "地市",
            searchLabelWidth: 1,
            value: "3601",
            searchSpan: 2,
            // search: true,
            props: {
              label: "name",
              value: "code",
            },
            dicUrl: "/api/blade-system/region/select?code={{key}}",
            span: 3,
            labelWidth: "0",
            className: "cityreal2",
            addDisplay: true,
            editDisplay: true,
            viewDisplay: true,
          },
          {
            label: "区县",
            hide: true,
            searchSpan: 2,
            searchLabelWidth: 1,
            width: 100,
            searchPlaceholder: "区县",
            placeholder: "区县",
            // search: true,
            prop: "district",
            type: "select",
            props: {
              label: "name",
              value: "code",
            },
            dicUrl: "/api/blade-system/region/select?code={{key}}",
            span: 3,
            labelWidth: "0",
            className: "cityreal3",
            addDisplay: true,
            editDisplay: true,
            viewDisplay: true,
          },
          {
            label: "任务状态",
            prop: "rtype",
            type: "select",
            value: "2",
            dicData: [
              {
                label: "任务开始",
                value: "2",
              },
              {
                label: "任务结束",
                value: "1",
              },
              {
                label: "正在进行",
                value: "0",
              },
            ],
            // label: "任务状态",
            // searchSpan: 3,
            // width: 96,
            // search: true,
            // slot: true,
            // value: "0",
            // searchPlaceholder: "请选择",
            // prop: "rtype",
            // type: "select",
            // dicData: [
            //   {
            //     label: "任务开始",
            //     value: "0",
            //   },
            //   {
            //     label: "正在进行",
            //     value: "1",
            //   },
            //   {
            //     label: "任务结束",
            //     value: "2",
            //   },
            // ],
          },
          // {
          //   label: "派发人",
          //   prop: "alarmPeople",
          //   width: 90,
          //   addDisplay: false,
          //   editDisplay: false,
          // },
          {
            label: "积分数值",
            prop: "integral",
            type: "number",
            // multiple: true,
            // dicUrl: "/api/catalogs/catalogs/getBigTree",
            // props: {
            //   label: "title",
            // },
            width: 72,
            // hide: true,
            minRows: 1,
            value: 1,
            // leafOnly: "",
            addDisplay: true,
            editDisplay: true,
            viewDisplay: true,
          },
          {
            label: "接收人数",
            prop: "jnum",
            type: "number",
            // multiple: true,
            // dicUrl: "/api/catalogs/catalogs/getBigTree",
            // props: {
            //   label: "title",
            // },
            width: 72,
            // hide: true,
            minRows: 1,
            value: 1,
            // leafOnly: "",
            addDisplay: true,
            editDisplay: true,
            viewDisplay: true,
          },
          // {
          //   label: "巡逻路线",
          //   prop: "xllx",
          //   hide: true,
          //   display: true,
          //   type: "tree",
          //   dicUrl: "/api/routeIn/routein/tree",
          //   props: {
          //     label: "title",
          //   },
          //   addDisplay: true,
          // },
          {
            label: "请在下方地图中,建立路径!",
            labelWidth: "0",
            className: "mapClass",
            prop: "haveMap",
            hide: true,
            display: true,
            rules: [
              {
                required: true,
                message: "请在下方地图中,建立路径!",
                trigger: "blur",
              },
            ],
            addDisabled: true,
            editDisabled: true,
            // value: "", //赋值不上去,舍弃
            // type: "tree",
            // dicUrl: "/api/routeIn/routein/tree",
            // props: {
            //   label: "title",
            // },
          },
          {
            label: "路线展示",
            labelWidth: "0",
            prop: "line",
            className: "mapClass",
            hide: true,
            display: true,
            span: 24,
            formslot: true,
            addDisplay: true,
          },
        ],
      },
      data: [],
      recorder: null,
      peopleList: [],
      // rotesData: "",
    };
  },
  watch: {
    "form.map": {
      // form是表单或者表格绑定的数据集,v-model='form'
      handler(val) {
        var that = this;
        if (val) {
          //重新加载一次页面详情数据,解决新的省市区无法写入问题
          //判断是新增还是修改
          if (that.isEdit) {
            getclient(this.form.id).then((res) => {
              // that.province = res.data.data.province;
              // that.city = res.data.data.city;
              // that.district = res.data.data.district;
            });
          }
          //地址截取,从县/区开始截取,并且取从县区第一个出现的位置开始
          if (val.formattedAddress == "") {
            return;
          }
          //经纬度替换
          this.form.wd = val.latitude;
          this.form.jd = val.longitude;
          var address = val.formattedAddress.toString();
          if (address.search("县") != -1) {
            this.form.place = address.substring(
              address.indexOf("县") + 1,
              address.length
            );
          }
          if (address.search("区") != -1) {
            this.form.place = address.substring(
              address.indexOf("区") + 1,
              address.length
            );
          }
          //写入新的省市区
          that.form.province = val.addressComponent.province;
          if (val.addressComponent.city == "") {
            that.form.city = val.addressComponent.province;
          } else {
            that.form.city = val.addressComponent.city;
          }
          that.form.district = val.addressComponent.district;
        } else {
          that.form.map = {
            formattedAddress: "",
            latitude: 28.699957,
            longitude: 115.862118,
          };
        }
      },
      immediate: true,
    },
    // "form.alarmType": {
    //   handler(val) {
    //     // var xllx = this.findObject(this.option.column, "xllx");
    //     var xllxzs = this.findObject(this.option.column, "xllxzs");
    //     if (val === "巡逻任务") {
    //       // xllx.display = true;
    //       xllxzs.display = true;
    //       // xllx.rules = [
    //         // {
    //         //   required: true,
    //         //   message: "请选择巡逻路线",
    //         //   trigger: "blur",
    //         // },
    //       // ];
    //     } else {
    //       // xllx.display = false;
    //       xllxzs.display = false;
    //       // xllx.rules = [];
    //     }
    //   },
    //   immediate: true,
    // },
    "form.line": {
      handler(val) {
        if (val) {
          this.getxllx(val);
        }
      },
      immediate: true,
    },
    rotesData() {
      // console.log(this.rotesData, "rotesDatarotesDatarotesData");
      // console.log(this.rotesData, "this.rotesDatathis.rotesData");
      if (this.rotesData) {
        // var haveMap = (this.option.column[9].value = "已选择路径!");
        // haveMap.value = "已选择路径!";
        // console.log(haveMap);
        this.form["line"] = this.rotesData;
        this.form["haveMap"] = "已绘制路径!";
      } else {
        this.form["line"] = "";
        this.form["haveMap"] = "";
      }
    },
  },
  computed: {
    ...mapGetters(["permission", "flowRoutes", "rotesData", "userInfo"]),
    permissionList() {
      return {
        addBtn: this.vaildData(this.permission.real_add, false),
        viewBtn: this.vaildData(null, false),
        delBtn: this.vaildData(this.permission.real_delete, false),
        editBtn: this.vaildData(this.permission.real_edit, false),
      };
    },
    ids() {
      let ids = [];
      this.selectionList.forEach((ele) => {
        ids.push(ele.id);
      });
      return ids.join(",");
    },
  },
  created() {
    this.dateTime = this.getDate();
  },
  mounted() {
    var xb = JSON.parse(window.sessionStorage.getItem("sjsb"));
    var data = this.$route.query;
    if (xb == 1) {
      this.form = data;
      this.openAdd();
      window.sessionStorage.removeItem("sjsb");
    }
  },
  methods: {
    rowSave(row, done, loading) {
      // console.log(row);
      // return;
      var userId1 = this.userInfo.user_id;
      var username = this.userInfo.nick_name;
      let d = {
        line: row.line, //路线
        rname: row.rname, //标题
        url: row.url, //封面
        time: row.time, //下发时间
        province: row.$province, //省
        city: row.$city, //城市
        district: row.$district, //区县
        jnum: row.jnum, //接收总数
        integral: row.integral + "", //积分
        content: row.content, //内容
        rtype: row.rtype, //任务状态
        fid: userId1,//发起人id
        fname: username, //发起人id
        jurisdiction: row.jurisdiction
      };
      // console.log(d);
      // done();
      // return;
      let that = this;
      add(d).then(
        () => {
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!",
          });
          done();
        },
        (error) => {
          loading();
        }
      );
      return;
    },
    getxllx(val) {
      var that = this;
      if (this.$refs.modalForm == undefined) {
        setTimeout(function () {
          try {
            that.$refs.modalForm.addLinesDraw(val);
          } catch (error) {
          }
        }, 1500);
      } else {
        try {
          that.$refs.modalForm.addLinesDraw(val);
        } catch (error) {
        }
      }
    },
    rowUpdate(row, index, done, loading) {
      let that = this;
      update(row).then(
        () => {
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!",
          });
          done();
        },
        (error) => {
          loading();
        }
      );
    },
    rowDel(row) {
      this.$confirm("确定将选择数据删除?", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          return remove(row.id);
        })
        .then(() => {
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!",
          });
        });
    },
    searchReset() {
      this.activeClass = 3;
      //清空搜索框中的内容
      this.query = {};
      //清空this.$route.query
      this.$router.push({query: {}});
      this.onLoad(this.page);
    },
    searchChange(params, done) {
      //清空this.$route.query
      this.$router.push({query: {}});
      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();
    },
    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) {
      // console.log(type, "this.formthis.formthis.form");
      // console.log(type);
      // if (["edit", "view"].includes(type)) {
      //   getclient(this.form.id).then((res) => {
      //     this.form = res.data.data;
      //   });
      // }
      // console.log(this.form);
      if (type == "add") {
        this.$store.commit("setRotesData", false); //用vuex传最终数据 清除
        done();
        return;
      }
      if (this.form.line != "" && this.form != undefined) {
        this.form["haveMap"] = "已绘制路径!";
      } else {
        this.form["haveMap"] = "";
      }
      done();
    },
    currentChange(currentPage) {
      this.page.currentPage = currentPage;
    },
    sizeChange(pageSize) {
      this.page.pageSize = pageSize;
    },
    refreshChange() {
      this.onLoad(this.page, this.query);
    },
    onLoad(page, params = {}) {
      getList(page.currentPage, page.pageSize,params).then((res) => {
        const data = res.data.data;
        this.page.total = data.total;
        data.records.sort((a, b) => {
          return a.jtype - b.jtype;
        });
        this.data = data.records;
        this.loading = false;
        this.selectionClear();
      });
    },
    getDate() {
      // 当前时间
      var timestamp = Date.parse(new Date());
      var serverDate = new Date(timestamp);
      // 本周周一的时间
      var mondayTime =
        timestamp - (serverDate.getDay() - 1) * 24 * 60 * 60 * 1000;
      var mondayData = new Date(mondayTime);
      //年
      var mondayY = mondayData.getFullYear();
      //月
      var mondayM =
        mondayData.getMonth() + 1 < 10
          ? "0" + (mondayData.getMonth() + 1)
          : mondayData.getMonth() + 1;
      //日
      var mondayD =
        mondayData.getDate() < 10
          ? "0" + mondayData.getDate()
          : mondayData.getDate();
      // 当前时间
      var currentData = new Date(timestamp);
      //年
      var currentY = currentData.getFullYear();
      //月
      var currentM =
        currentData.getMonth() + 1 < 10
          ? "0" + (currentData.getMonth() + 1)
          : currentData.getMonth() + 1;
      //日
      var currentD =
        currentData.getDate() < 10
          ? "0" + currentData.getDate()
          : currentData.getDate();
      //时
      var currenH =
        currentData.getHours() < 10
          ? "0" + currentData.getHours()
          : currentData.getHours();
      //分
      var currenM =
        currentData.getMinutes() < 10
          ? "0" + currentData.getMinutes()
          : currentData.getMinutes();
      //秒
      var currenS =
        currentData.getSeconds() < 10
          ? "0" + currentData.getSeconds()
          : currentData.getSeconds();
      return {
        day: {
          beginTime: currentY + "-" + currentM + "-" + currentD + " 00:00:00",
          endTime:
            currentY +
            "-" +
            currentM +
            "-" +
            currentD +
            " " +
            currenH +
            ":" +
            currenM +
            ":00",
        },
        week: {
          beginTime: mondayY + "-" + mondayM + "-" + mondayD + " 00:00:00",
          endTime:
            currentY +
            "-" +
            currentM +
            "-" +
            currentD +
            " " +
            currenH +
            ":" +
            currenM +
            ":00",
        },
        month: {
          beginTime: mondayY + "-" + mondayM + "-01 00:00:00",
          endTime:
            currentY +
            "-" +
            currentM +
            "-" +
            currentD +
            " " +
            currenH +
            ":" +
            currenM +
            ":00",
        },
        current:
          currentY +
          "-" +
          currentM +
          "-" +
          currentD +
          " " +
          currenH +
          ":" +
          currenM +
          ":" +
          currenS,
      };
    },
    getBRdata(e) {
      this.activeClass = e;
      this.query = {};
      this.$router.push({query: {}});
      var today = new Date();
      var params = {};
      if (e == 0) {
        params = {
          beginTime: this.showToDay(today) + " 00:00:00",
          endTime: this.showToDay(today) + " 23:59:59",
        };
        //修改搜索框中的值
        this.search.releaseTimeRange = [
          this.showToDay(today) + " 00:00:00",
          this.showToDay(today) + " 23:59:59",
        ];
      }
      if (e == 1) {
        params = {
          beginTime: this.showWeekFirstDay(today) + " 00:00:00",
          endTime: this.showToDay(today) + " 23:59:59",
        };
        //修改搜索框中的值
        this.search.releaseTimeRange = [
          this.showWeekFirstDay(today) + " 00:00:00",
          this.showToDay(today) + " 23:59:59",
        ];
      }
      if (e == 2) {
        params = {
          beginTime: this.showMonthFirstDay(today) + " 00:00:00",
          endTime: this.showToDay(today) + " 23:59:59",
        };
        //修改搜索框中的值
        this.search.releaseTimeRange = [
          this.showMonthFirstDay(today) + " 00:00:00",
          this.showToDay(today) + " 23:59:59",
        ];
      }
      this.query = params;
      this.page.currentPage = 1;
      this.onLoad(this.page, params);
    },
    //本日
    showToDay(Nowdate) {
      var M = Number(Nowdate.getMonth()) + 1;
      if (M < 10) {
        M = "0" + M;
      }
      var day = Nowdate.getDate();
      if (day < 10) {
        day = "0" + day;
      }
      return Nowdate.getFullYear() + "-" + M + "-" + day;
    },
    //本周第一天
    showWeekFirstDay(Nowdate) {
      var WeekFirstDay = new Date(Nowdate - (Nowdate.getDay() - 1) * 86400000);
      var M = Number(WeekFirstDay.getMonth()) + 1;
      if (M < 10) {
        M = "0" + M;
      }
      var day = WeekFirstDay.getDate();
      if (day < 10) {
        day = "0" + day;
      }
      return WeekFirstDay.getFullYear() + "-" + M + "-" + day;
    },
    //本月第一天
    showMonthFirstDay(Nowdate) {
      var MonthFirstDay = new Date(
        Nowdate.getFullYear(),
        Nowdate.getMonth(),
        1
      );
      var M = Number(MonthFirstDay.getMonth()) + 1;
      if (M < 10) {
        M = "0" + M;
      }
      return (
        MonthFirstDay.getFullYear() +
        "-" +
        M +
        "-" +
        "0" +
        MonthFirstDay.getDate()
      );
    },
    getBZdata(e) {
      this.activeClass = e;
      var params = {
        beginTime: this.dateTime.week.beginTime,
        endTime: this.dateTime.week.endTime,
      };
      this.query = params;
      this.page.currentPage = 1;
      this.onLoad(this.page, params);
    },
    getBYdata(e) {
      this.activeClass = e;
      var params = {
        beginTime: this.dateTime.month.beginTime,
        endTime: this.dateTime.month.endTime,
      };
      this.query = params;
      this.page.currentPage = 1;
      this.onLoad(this.page, params);
    },
    getQBdata(e) {
      this.search.releaseTimeRange = ["", ""];
      this.activeClass = e;
      var params = {};
      this.query = params;
      this.page.currentPage = 1;
      this.onLoad(this.page, params);
    },
    rowStyle({row, column, rowIndex}) {
      if (row.jtype == "0") {
        return {
          color: "#ff2727",
        };
      } else if (row.jtype == "1") {
        return {
          color: "#15a2fe",
        };
      } else {
        return {
          color: "#000000",
        };
      }
    },
    handleStart(row) {
      var arr = [];
      this.$store.state.tags.tagList.forEach((item) => {
        if (item.label != "视频") {
          arr.push(item);
        }
      });
      this.$store.state.tags.tagList = arr;
      this.$router.push({
        path: `/real/video/`,
        query: row,
      });
    },
    handleHistory(row) {
      var arr = [];
      this.$store.state.tags.tagList.forEach((item) => {
        if (item.label != "设备历史") {
          arr.push(item);
        }
      });
      this.$store.state.tags.tagList = arr;
      this.$router.push({path: `/real/history/${row.deviceNumber}`});
    },
    handleMap(row) {
      this.showMap = true;
      this.$nextTick(() => {
        this.$refs.mapDiv.onload = () => {
          window.frames[0].init("ClientManagement", {
            x: row.jd,
            y: row.wd,
            clientID: row.deviceNumber,
          });
        };
      });
    },
    getStartTime() {
      if (
        this.$route.query.startTime != undefined &&
        this.$route.query.startTime != null &&
        this.$route.query.startTime != ""
      ) {
        return this.$route.query.startTime;
      }
      return "";
    },
    getEndTime() {
      if (
        this.$route.query.endTime != undefined &&
        this.$route.query.endTime != null &&
        this.$route.query.endTime != ""
      ) {
        return this.$route.query.endTime;
      }
      return "";
    },
    handleManage(row) {
      this.$refs.realPopupView.onItemGetParentData(row);
    },
    beginTimeOrEndTime(time) {
      var beginTime = new Date(time);
      var endTime = new Date(new Date(time).valueOf() - 1000 * 60 * 60 * 3);
      var beginY = beginTime.getFullYear();
      var beginM =
        beginTime.getMonth() + 1 < 10
          ? "0" + (beginTime.getMonth() + 1)
          : beginTime.getMonth() + 1;
      var beginD =
        beginTime.getDate() < 10
          ? "0" + beginTime.getDate()
          : beginTime.getDate();
      var beginH =
        beginTime.getHours() < 10
          ? "0" + beginTime.getHours()
          : beginTime.getHours();
      var beginm =
        beginTime.getMinutes() < 10
          ? "0" + beginTime.getMinutes()
          : beginTime.getMinutes();
      var begins =
        beginTime.getSeconds() < 10
          ? "0" + beginTime.getSeconds()
          : beginTime.getSeconds();
      var endY = endTime.getFullYear();
      var endM =
        endTime.getMonth() + 1 < 10
          ? "0" + (endTime.getMonth() + 1)
          : endTime.getMonth() + 1;
      var endD =
        endTime.getDate() < 10 ? "0" + endTime.getDate() : endTime.getDate();
      var endH =
        endTime.getHours() < 10 ? "0" + endTime.getHours() : endTime.getHours();
      var endm =
        endTime.getMinutes() < 10
          ? "0" + endTime.getMinutes()
          : endTime.getMinutes();
      var ends =
        endTime.getSeconds() < 10
          ? "0" + endTime.getSeconds()
          : endTime.getSeconds();
      return {
        begin: beginY + beginM + beginD + beginH + beginm + begins,
        end: endY + endM + endD + endH + endm + ends,
      };
    },
    PoliceTracking(row) {
      var arr = [];
      this.$store.state.tags.tagList.forEach((item) => {
        if (item.label != "任务详情") {
          arr.push(item);
        }
      });
      this.$store.state.tags.tagList = arr;
      //警情追踪
      this.$router.push({path: "/policeTracking/details", query: row});
    },
    //打开新增窗体
    openAdd() {
      this.$refs.crud.rowAdd();
    },
    //数据导出
    handleExport() {
      this.$confirm("是否导出实时警情数据?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      }).then(() => {
        window.open(
          `/api/alarm/alarm/export-alarm?beginTime=${this.$route.query.startTime}&endTime=${this.$route.query.endTime}&waringType=${this.$route.query.waringType}&timeDesc=${this.$route.query.timeDesc}`
        );
      });
    },
    //数据报表导出
    handleExportStatis() {
      let beginTime =
        this.$route.query.startTime == undefined
          ? ""
          : this.$route.query.startTime;
      let endTime =
        this.$route.query.endTime == undefined ? "" : this.$route.query.endTime;
      let waringType =
        this.$route.query.waringType == undefined
          ? ""
          : this.$route.query.waringType;
      let timeDesc =
        this.$route.query.timeDesc == undefined
          ? ""
          : this.$route.query.timeDesc;
      window.open(
        `https://web.byisf.com/api/blade-report/ureport/preview?_u=blade-alarm.statis.ureport.xml&beginTime=${beginTime}&endTime=${endTime}&waringType=${waringType}&timeDesc=${timeDesc}`
      );
      //window.open(`http://localhost:8108/ureport/excel?_u=blade-alarm.statis.ureport.xml&beginTime=${beginTime}&endTime=${endTime}&waringType=${waringType}&timeDesc=${timeDesc}`);
    },
    rowClick(val) {
      //行点击事件
      //警情追踪
      this.PoliceTracking(val);
    },
  },
};
</script>
<style>
.el-card__body .waringTypeClass {
  width: 12%;
}
.mapClass div label {
  display: none;
}
.mapClassMain {
  padding-left: 25px !important;
}
.cityreal2 div label,
.cityreal3 div label {
  display: none;
}
/*页面样式*/
.el-card__body .cityreal1 {
  width: 150px;
  padding-right: 0px !important;
}
.el-card__body .cityreal2 {
  width: 100px;
  padding-left: 10px !important;
  padding-right: 0px !important;
}
.el-card__body .cityreal3 {
  width: 100px;
  padding-left: 10px !important;
  padding-right: 0px !important;
}
/*新增窗体样式*/
.el-dialog .cityreal1 {
  width: 216px;
  padding-right: 0px !important;
}
.el-dialog .cityreal2 {
  width: 130px;
  padding-left: 10px !important;
  padding-right: 10px !important;
}
.el-dialog .cityreal3 {
  width: 105px;
  padding-left: 0px !important;
  padding-right: 0px !important;
}
.cityClassParams .avue-form__group.avue-form__group--flex {
  display: flex;
  justify-content: space-between;
}
.cityClassParams .cityClassSelect {
  flex: 1;
  margin: 0 !important;
  padding-left: 0px !important;
  padding-right: 0px !important;
}
.cityClassParams .cityClassSelect:nth-child(2) {
  margin: 0 10px !important;
}
.cityClassParams .cityClassSelect .el-form-item {
  margin-bottom: 0px !important;
}
.cityClassParams .cityClassSelect .el-form-item .el-input__inner {
  height: 28px !important;
  line-height: 28px !important;
}
.cityClass2 div label {
  display: none;
}
.cityClass3 div label {
  display: none;
}
.old-video-dialog {
  position: absolute !important;
  top: 0 !important;
  left: auto !important;
  right: 0px !important;
  bottom: 0 !important;
  margin: auto !important;
  height: 100% !important;
  width: 476px !important;
}
.old-video-dialog .el-dialog {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  margin: auto !important;
  margin-top: 15vh !important;
  height: 538px;
}
.old-video-dialog .el-dialog .el-dialog__body {
  height: calc(100% - 54px);
  box-sizing: border-box;
}
.el-button.btn-color {
  color: rgb(255, 255, 255);
  background-color: rgb(64, 158, 255);
  border-color: rgb(64, 158, 255);
}
.tabFontSize {
  font-size: 15px;
}
</style>