vio_casefile.js 14.9 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483

import { listViolationCaseFile, getViolationCaseFile,
        delViolationCaseFile, addViolationCaseFile,
        updateViolationCaseFile, exportViolationCaseFile } from "@/api/casefile/violationCaseFile";
import violationCaseFileInfo from "@/views/casefile/violationCaseFile/violationCaseFileInfo";

import h5Info from "@/views/h5/task/violationCaseFileInfo";
import h5Page from "@/views/h5/Pagination";

  import {
    earthsitesList,
    constructionsitesList,
    getDict,
    getArea,
    companyList,
    truckList,
  } from "@/api/dict";


export default {
  name: "ViolationCaseFile",
  components: { violationCaseFileInfo,
   h5Page,
   h5Info},
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 平台违规案卷表格数据
      violationCaseFileList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        number: null,
        violationObjectType: null,
        owningRegion: null,
        violationType: null,
        violationGrade: null,
        projectName: null,
        companyName: null,
        describe: null,
        sendObject: null,
        status: null,
        receive: null,
        receiveStatus: null,
        readBy: null,
        readTime: null
      },
      // 表单参数
      form: {

      },
      place:null,
      // 表单校验
      rules: {
        number :[
          { required: true, message: "必填", trigger: "blur" }
        ],
        violationObjectType :[
          { required: true, message: "必填", trigger: "blur" }
        ],
        owningRegion :[
          { required: true, message: "必填", trigger: "blur" }
        ],
        violationType :[
          { required: true, message: "必填", trigger: "blur" }
        ],
      },
      caseType:[{code:0,name:"进入非专用车辆"},
      {code:1,name:"无许可手续(工)"},
      {code:2,name:"无许可手续(消)"},
      {code:3,name:"黄土覆盖情况"},
      {code:4,name:"出入口路面污染"},
      {code:5,name:"出入口道路硬化"},
      {code:6,name:"车辆冲洗是否到位"},
      {code:7,name:"雾炮机是否正常开启"},
      {code:8,name:"使用费专用车运输"},
      {code:9,name:"监控点位未对准"},
      {code:10,name:"未报开工作业"},
      {code:11,name:"视频设备离线超时报警"},
      {code:12,name:"三无车辆进入工地"},
      {code:13,name:"未按时间作业"},
      {code:14,name:"未报开工作业"},
      {code:15,name:"视频设备离线超时报警"},
      {code:16,name:"三无车辆进入消纳场"},
      {code:17,name:"未到指定的消纳场作业"},
      {code:18,name:"离线运输报警(工)"},
      {code:19,name:"离线运输报警(消)"},
      {code:20,name:"未激活车辆作业"},
      {code:21,name:"未核准作业车辆作业"},
      {code:22,name:"未按线路行驶"},
      {code:23,name:"闯禁行驶"},
      {code:24,name:"失信车辆作业"},
      {code:25,name:"其他1"},
      {code:26,name:"其他2"},
      {code:27,name:"其他3"},
      {code:28,name:"其他4"},
      {code:29,name:"其他5"}],

      projectNameList:[
      ],
      isLoading: false,
      fileEntityList:[],
      companyList:[
      ],
      remoteQueryData: {
        "page": 1,
        "size": 9999
      },
      areas:[],
      data:{},
      isLoadingCompany: false,
      idInfo:null,
      openInfo:false,
      slide1: []
    };
  },
  watch: {
    fileEntityList(value) {
      this.slide1 = []
      if (this.fileEntityList.length != 0) {
        this.fileEntityList.map(item => {
          if (item.name.indexOf(".jpg") > -1 || item.name.indexOf(".png") > -1 || item.name.indexOf(".jpeg") > -1 || item.name.indexOf(".jpg") > -1) {
            if(item.raw!=null){
              this.slide1.push({
                src: URL.createObjectURL(item.raw),
                msrc: URL.createObjectURL(item.raw),
                alt: item.uid,
                w: 1920,
                h: 1080
              });
            }else{
              this.slide1.push({
                src: process.env.VUE_APP_BASE_API + item.url,
                msrc: process.env.VUE_APP_BASE_API + item.url,
                w: 1920,
                h: 1080
              });
            }
          }
        })
      }

    }
  },
  created() {
    getArea().then(res=>{

      this.areas = res.result;
    });


    constructionsitesList(this.remoteQueryData).then(res => {
      this.projectNameList = res.result.list;
      earthsitesList(this.remoteQueryData).then(res => {
         for(var i in res.result.list){
           this.projectNameList.push(res.result.list[i]);
         }
      });
    });


    companyList(this.remoteQueryData).then(res => {
       this.companyList = res.result.list;
    });



    this.getList();
  },
  methods: {
    selectArea(item){

      this.form.owningRegion = item.name;
      this.form.projectName = null;

    },
    /** 查询平台违规案卷列表 */
    getList() {
      this.loading = true;
      listViolationCaseFile(this.queryParams).then(response => {
        this.violationCaseFileList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.openInfo = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.fileEntityList = [];
      this.form = {
        id: null,
        number: null,
        violationObjectType: null,
        owningRegion: null,
        violationType: null,
        violationGrade: null,
        projectName: null,
        companyName: null,
        describe: null,
        sendObject: null,
        createTime: null,
        createBy: null,
        updateTime: null,
        updateBy: null,
        status: 0,
        receive: null,
        receiveStatus: 0,
        readBy: null,
        readTime: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    handleInfo(row){
      this.idInfo = row.id + "";
      this.openInfo = true;
      this.title = "平台违规案卷详情";
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.form.number = this.getNumber();
      this.form.violationGrade = "一般类";
      this.form.sendObject = "区管理部门(治)";
      this.title = "添加平台违规案卷";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getViolationCaseFile(id).then(response => {
        this.form = response.data.violationCaseFile;
        let files = JSON.stringify(response.data.uploadFiles);
        this.fileEntityList = JSON.parse(files.replaceAll("filePath", "url").replaceAll("fileName", "name"))
        this.open = true;
        this.title = "修改平台违规案卷";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {

          if(this.form.sendObject == "运输企业" && this.form.companyName == null){

            this.$message("请选择相关企业");

            return;
          }


          let formData = new FormData();
          let form = this.form;
          //去掉params属性
          delete form.params;
          formData.append('fileList', null);
          //将新增的文件放入formData
          this.fileEntityList.forEach(item => {
            if(item.id==null){
              formData.append('fileList', item.raw)
            }
          })
          if (this.form.id != null) {
            formData.append("violationCaseFile", JSON.stringify(form));
            formData.append("uploadFilesList", null);
            this.fileEntityList.forEach(item => {
              delete item.params;
              if(item != "null" && item != null){
                formData.append('uploadFilesList', JSON.stringify(item).replaceAll("url", "filePath").replaceAll("name", "fileName"));
              }
            })
            updateViolationCaseFile(formData).then(response => {
              this.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            for (let key in form) {
              formData.append(key, form[key] == null ? "" : form[key])
            }
            addViolationCaseFile(formData).then(response => {
              this.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$confirm('是否确认删除平台违规案卷编号为"' + ids + '"的数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return delViolationCaseFile(ids);
        }).then(() => {
          this.getList();
          this.msgSuccess("删除成功");
        })
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams;
      this.$confirm('是否确认导出所有平台违规案卷数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return exportViolationCaseFile(queryParams);
        }).then(response => {
          this.download(response.message);
        })
    },
    /** 生成案卷编号 */
    getNumber(){
      const now = new Date();
      const year = now.getFullYear().toString().slice(-2); // 提取后两位数
      const month = now.getMonth() + 1 < 10 ? `0${now.getMonth() + 1}` : now.getMonth() + 1;
      const day = now.getDate() < 10 ? `0${now.getDate()}` : now.getDate();
      const hour = now.getHours() < 10 ? `0${now.getHours()}` : now.getHours();
      const minute = now.getMinutes() < 10 ? `0${now.getMinutes()}` : now.getMinutes();
      const second = now.getSeconds() < 10 ? `0${now.getSeconds()}` : now.getSeconds();
      const millisecond = now.getMilliseconds();
      const code = `${year}${month}${day}${hour}${minute}${second}${millisecond}`;
      return code;
    },
    projectNameLoadOptions(query) {
      // 根据输入的关键字query异步加载选项数据
      this.isLoading = true
      setTimeout(() => {
        // 模拟异步加载数据
        const data = [
          { name:'项目1' },
          { name:'项目2' },
          { name:'项目3' }
        ].filter(item => item.name.includes(query))
        this.projectNameList = data
        this.isLoading = false
      }, 200)
    },
    companyLoadOptions(query) {
      // 根据输入的关键字query异步加载选项数据
      this.isLoadingCompany = true
      setTimeout(() => {
        // 模拟异步加载数据
        const data = [
          { name:'公司1' },
          { name:'公司2' },
          { name:'公司3' }
        ].filter(item => item.name.includes(query))
        this.companyList = data
        this.isLoadingCompany = false
      }, 200)
    },
    /**
     * 文件改变时,限制文件上传格式和大小
     * 文件格式只能为docx/doc/pdf/png/jpeg/png/jpg
     * 大小不超过20M
     * */
    fileChange(file, fileList) {
      let count = 0;
      for (let i = 0; i < fileList.length; i++) {
        // console.log(fileList.length)
        // console.log(this.fileEntityList[i].name+"111"+file.name)
        if (fileList[i].name == file.name) {
          count++;
          if (count == 2) {
            this.$message({
              message: '已存在此文件!',
              type: 'warning'
            });
            for (let j = fileList.length; j > 0; j--) {
              //如果存在此文件,去除新选择的重复文件
              if (fileList[j - 1].name == file.name) {
                fileList.splice(j - 1, 1);
                i--;
                return false;
              }
            }
          }
        }
      }
      let fileType = file.name.substring(file.name.lastIndexOf('.') + 1).toLowerCase();
      //格式符合后判断大小
      if ("docx,doc,pdf,png,jpeg,png,jpg".indexOf(fileType) != -1) {
        let max5M = file.size / 1024 / 1024 < 20;
        if (!max5M) {
          this.$message({
            message: '上传文件大小不得超过20M!',
            type: 'warning'
          });
          fileList = fileList.splice(fileList.length - 1, 1);
        } else {
          //符合条件后进行添加
          this.fileEntityList = fileList
        }
      } else {
        this.$message({
          message: '上传文件只能是 docx、doc、pdf、png、jpeg、png、jpg格式!',
          type: 'warning'
        });
        fileList = fileList.splice(fileList.length - 1, 1);
      }
    },
    // 删除文件
    handleDeleteFile(index) {
      this.fileEntityList.splice(index, 1);
      this.slide1.splice(index, 1);
    },
    /** 文件下载 */
    downloadFA(row) {
      let name = row.name;
      let url = row.url;
      const a = document.createElement('a')
      a.setAttribute('download', name)
      a.setAttribute('target', '_blank')
      a.setAttribute('href', process.env.VUE_APP_BASE_API + url);
      a.click()
    },
    /** 生成违规描述 */
    createDescribe(){
      this.rules.companyName = [{ required: true, message: "必填", trigger: "blur" }]
      this.rules.projectName = [{ required: true, message: "必填", trigger: "blur" }]
      this.$refs["form"].validate(valid => {
        if (valid) {
          let formData = this.form;
          const now = new Date();
          const year = now.getFullYear();
          const month = now.getMonth() + 1 < 10 ? `0${now.getMonth() + 1}` : now.getMonth() + 1;
          const day = now.getDate() < 10 ? `0${now.getDate()}` : now.getDate();
          const hour = now.getHours() < 10 ? `0${now.getHours()}` : now.getHours();
          const minute = now.getMinutes() < 10 ? `0${now.getMinutes()}` : now.getMinutes();
          const second = now.getSeconds() < 10 ? `0${now.getSeconds()}` : now.getSeconds();
          const code = `${year}/${month}/${day} ${hour}:${minute}:${second}`;
          this.form.describe =code + formData.companyName + "在" + formData.projectName + "出现" + formData.violationType;
          this.rules.companyName = null;
          this.rules.projectName = null;
        }
      });

    }
  }
};