index.vue 11 KB
<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="名称" prop="name">
        <el-input
          v-model="queryParams.name"
          placeholder="请输入名称"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="所属区域" prop="place">
        <el-select v-model="queryParams.place" placeholder="请选择所属区域 "  size="small">
         <el-option v-for="item in areas" :label="item.name" :value="item.name" />
        </el-select>
      </el-form-item>
      <el-form-item label="作业区域" v-if="this.type==0">
        <el-select v-model="queryParams.workAreaCodeName" placeholder="工地所属区域 "  size="small">
           <el-option label="中心区域" value="中心区域" />
           <el-option label="外环区域" value="外环区域" />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          size="mini"
          @click="handleAdd(3)"
          v-hasPermi="['threehistory:threeHistory:add']"
        >申请开工</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="primary"
          size="mini"
          @click="handleAdd(1)"
          v-hasPermi="['threehistory:threeHistory:add']"
        >申请停工</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          size="mini"
          @click="handleExport"
          v-hasPermi="['threehistory:threeHistory:export']"
        >导出</el-button>
      </el-col>
	  <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="threeHistoryList" @selection-change="handleSelectionChange">
      <el-table-column label="序号" align="center" type="index" />
      <el-table-column :label="pageLabel" align="center" prop="name" />
      <el-table-column :label="pageType" align="center" prop="projectType" />
      <el-table-column label="所属区域" align="center" prop="place"  />
      <el-table-column label="作业区域" align="center" prop="workAreaCodeName" v-if="this.type==0"/>
      <el-table-column label="操作时间" align="center" prop="createTime" />
      <el-table-column label="操作人" align="center" prop="createBy" />
      <el-table-column label="状态" align="center" prop="status">
          <template slot-scope="scope">
            <span>{{ scope.row.status == 3 ? "申请停工" : "申请开工"}}</span>
          </template>
      </el-table-column>
      <el-table-column label="开停工原因" align="center" prop="reason" />
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改开停工对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="1000px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="150px">
        <el-form-item :label="pageLabel" prop="objectId">
          <el-select v-model="form.objectId" filterable  reserve-keyword @change="getObjId" :filter-method="getObjId">
            <el-option v-for="item in threestepList" :label="item.name"
              :value="item.objectId">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="执法部门负责人" prop="person">
          <el-input v-model="form.person" placeholder="请输入执法部门负责人" :maxlength="40" show-word-limit />
        </el-form-item>
        <el-form-item label="联系方式" prop="personNumber">
          <el-input v-model="form.personNumber" placeholder="请输入联系方式" :maxlength="11" show-word-limit/>
        </el-form-item>
        <el-form-item label="管理部门负责人" prop="person1">
          <el-input v-model="form.person1" placeholder="请输入管理部门负责人"  :maxlength="40" show-word-limit />
        </el-form-item>
        <el-form-item label="联系方式" prop="person1Number">
          <el-input v-model="form.person1Number" placeholder="请输入联系方式" :maxlength="11" show-word-limit/>
        </el-form-item>
        <el-form-item label="开停工原因" prop="reason">
          <el-input v-model="form.reason" placeholder="请输入开停工原因" :maxlength="200" show-word-limit type="textarea" rows="3"/>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>

import { listThreeHistory, getThreeHistory,
delThreeHistory, addThreeHistory,
updateThreeHistory, exportThreeHistory } from "@/api/business/threeHistory";

import {
  listThreestep,
  getThreestep,
  delThreestep,
  addThreestep,
  updateThreestep,
  exportThreestep,
  getNames
} from "@/api/business/threestep";

import {
  getArea,
  constructionLicenseById,
  earthsitesById
} from "@/api/dict";

export default {
  name: "ThreeHistory",
  props: {
    type: {
      type: Number
    },
  },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 开停工表格数据
      threeHistoryList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        type:0,
        name: null,
        place: null,
      },
      workQuery : {
       pageNum: 1,
       pageSize: 500,
      },
      pageLabel:"名称",
      pageType:"类型",
      threestepList:null,
      areas: [],
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        objectId: [{
          required: true,
          message: '请填写完整',
          trigger: 'change'
        },],
      }
    };
  },
  created() {
    if(!this.type){
      this.type = 0;
    }
    if(this.type == 0){
      this.pageLabel = "工地名称";
      this.pageType = "工地类型";
    }else{
      this.pageLabel = "处理场所名称";
      this.pageType = "处理场所类型";
    }

    this.workQuery.type = this.type;
    this.queryParams.type = this.type;
    getArea().then(res => {
      this.areas = res.result;
    });

    this.getList();
  },
  methods: {
    getList() {
      this.loading = true;
      listThreeHistory(this.queryParams).then(response => {
        this.threeHistoryList = response.rows;
        this.total = response.total;
        this.loading = false;
        this.$forceUpdate();
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        name: null,
        type: null,
        place: null,
        reason: null,
        status: 0,
        objectId: null,
        createBy: null,
        createTime: null,
        person: null,
        personNumber: null,
        person1: null,
        person1Number: 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
    },
    /** 新增按钮操作 */
    handleAdd(status) {
      this.reset();

      let date = new Date();
      let d = date.getDate();
      if(date.getHours() < 8){
          d -= 1;
      }
      let start = date.getFullYear() + "-" +  (date.getMonth()+1) + "-" + d + " 06:00:00"
      let end = date.getFullYear() + "-" +  (date.getMonth()+1) + "-" + (d+1) + " 06:00:00"

      this.workQuery.name = null;
      this.workQuery.workStartTime = start;
      this.workQuery.workEndTime = end;
      this.workQuery.status = status;

      this.form.workStartTime = start;
      this.form.workEndTime = end;
      this.form.type = this.type;


      if(status == 3){
        this.form.status = 1;
      }else{
        this.form.status = 3;
      }

      listThreestep(this.workQuery).then(response => {
        this.open = true;
        this.title = "添加开停工";
        this.threestepList = response.rows;
      });

    },
    getObjId(value) {
      this.workQuery.name = value;

      listThreestep(this.workQuery).then(response => {

        this.open = true;
        this.title = "添加开停工";
        this.threestepList = response.rows;
      });
    },

    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getThreeHistory(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改开停工";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateThreeHistory(this.form).then(response => {
              this.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addThreeHistory(this.form).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 delThreeHistory(ids);
        }).then(() => {
          this.getList();
          this.msgSuccess("删除成功");
        })
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams;
      queryParams.pageNum = 1;
      queryParams.pageSize = 99999;
      this.$confirm('是否确认导出所有开停工数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return exportThreeHistory(queryParams);
        }).then(response => {
          this.download(response.message);
        })
    }
  }
};
</script>