index.vue 11.5 KB
<template xmlns:el-col="http://www.w3.org/1999/html">
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" >
      <el-form-item label="标题" prop="title">
        <el-input
          v-model="queryParams.title"
          placeholder="请输入标题"
          
          size="small"
          
        />
      </el-form-item>
      <el-form-item label="操作人" prop="operator">
        <el-input
          v-model="queryParams.operator"
          placeholder="请输入操作人"
          
          size="small"
          
        />
      </el-form-item>
      <el-form-item>
        <el-button type="cyan" size="mini" @click="handleQuery">搜索</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"
          v-hasPermi="['daily:toollist:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['daily:toollist:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['daily:toollist:remove']"
        >删除</el-button>
      </el-col>
      <!-- <el-col :span="1.5">
        <el-button
          type="warning"
          size="mini"
          @click="handleExport"
          v-hasPermi="['daily:toollist:export']"
        >导出</el-button>
      </el-col> -->
    </el-row>

    <el-table v-loading="loading" :data="toollistList" border @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="标题" align="center" prop="title" />
      <el-table-column label="区域" align="center" prop="region" />
      <el-table-column label="操作人" align="center" prop="operator" />
      <el-table-column label="详情" align="center" prop="bth" >
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            @click="handleById(scope.row)"
            v-hasPermi="['daily:toollist:query']">
            查看
          </el-button>
        </template>
      </el-table-column>
    </el-table>

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

    <el-dialog title="长沙市各区渣土管理普查情况统计表"  :visible.sync="open" width="800px" append-to-body center :close-on-click-modal='false'>

      <el-form ref="form" :model="form" :rules="rules" label-width="150px">
        <el-row type="flex" justify="center">
            <el-col :span='12'>
              <el-form-item label="操作人" prop="operator">
                <el-input v-model="form.operator" placeholder="请输入操作人" />
              </el-form-item>
            </el-col>
                <el-col :span='12'>
                   <el-form-item label="日期" prop="date">
                     <el-date-picker  size="small"
                       v-model="form.date"
                       type="date"
                       value-format="yyyy-MM-dd"
                       placeholder="选择日期">
                     </el-date-picker>
                   </el-form-item>
                </el-col>
        </el-row>

        <el-row>
          <el-col :span='12'>
            <el-form-item label="区域" prop="region">
              <el-select v-model="form.region" placeholder="请选择区域" filterable >
                <el-option
                  v-for="item in areas"
                  :key="item.code"
                  :label="item.name"
                  :value="item.name"
                ></el-option>
              </el-select>


        </el-form-item>
          </el-col>
          <el-col :span='12'>
            <el-form-item label="开工工地数" prop="numberOfConstructionSites">
              <el-input v-model="form.numberOfConstructionSites" placeholder="请输入开工工地数" type="number"/>
            </el-form-item>

          </el-col>

        </el-row>
        <el-row>
            <el-col :span='12'>
              <el-form-item label="普查结果" prop="censusStructure">
                <el-input v-model="form.censusStructure" placeholder="请输入普查结果" />
              </el-form-item>
            </el-col>
            <el-col :span='12'>

              <el-form-item label="渣土管理值班负责人" prop="managementLeader">
                <el-input v-model="form.managementLeader" placeholder="请输入渣土管理值班负责人" />
              </el-form-item>
            </el-col>
        </el-row>
        <el-row>
            <el-col :span='12'>
              <el-form-item label="执法中队负责人" prop="lawEnforcementOfficer">
                <el-input v-model="form.lawEnforcementOfficer" placeholder="请输入执法中队负责人" />
              </el-form-item></el-col>
            <el-col :span='12'></el-col>
        </el-row>
        <el-row>
        <el-form-item label="普查具体情况">
          <editor v-model="form.specificSituationOfTheCensus" :min-height="192"/>
        </el-form-item>
        </el-row>
      </el-form>

      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm" v-if="edit==true">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listToollist, getToollist, delToollist, addToollist, updateToollist, exportToollist } from "@/api/daily/toollist";
import Editor from '@/components/Editor';
import {
    earthsitesList,
    constructionsitesList,
    getDict,
    getArea
  } from "@/api/dict";

export default {
  name: "Toollist",
  components: { Editor },
  data() {
    return {
      // 遮罩层
      loading: true,
      border:true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 每日工作清单表格数据
      toollistList: [],
      // 弹出层标题
      title: "长沙市各区渣土管理普查情况统计表",
      // 是否显示弹出层
      open: false,
      // 区域字典
      regionOptions: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        title: null,
        operator: null,
        bth:null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        date: [{
          required: true,
          message: '请将信息填写完整',
          trigger: 'change'
        }, ],
        region: [{
          required: true,
          message: '请将信息填写完整',
          trigger: 'change'
        }, ],
        operator: [{
          required: true,
          message: '请将信息填写完整',
          trigger: 'change'
        }, ],
        numberOfConstructionSites: [{
          required: true,
          message: '请将信息填写完整',
          trigger: 'change'
        }, ],
        censusStructure: [{
          required: true,
          message: '请将信息填写完整',
          trigger: 'change'
        }, ],
        lawEnforcementOfficer: [{
          required: true,
          message: '请将信息填写完整',
          trigger: 'change'
        }, ],
        managementLeader: [{
          required: true,
          message: '请将信息填写完整',
          trigger: 'change'
        }, ],

      },
      edit:false,
      areas:null,
    };
  },
  created() {
    this.getList();
    getArea().then(res => {
      this.areas = res.result;
    });
  },
  methods: {
    /** 查询每日工作清单列表 */
    getList() {
      this.loading = true;
      listToollist(this.queryParams).then(response => {
        this.toollistList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 区域字典翻译
    regionFormat(row, column) {
      // return this.selectDictLabel(this.regionOptions, row.region);
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        title: null,
        region: null,
        operator: null,
        date: null,
        numberOfConstructionSites: null,
        censusStructure: null,
        managementLeader: null,
        lawEnforcementOfficer: null,
        specificSituationOfTheCensus: 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() {
      this.reset();
      this.open = true;
        this.edit = true;
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getToollist(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.edit = true;
      });
    },
    /** 查看详情按钮操作*/
    handleById(row){
      this.reset();
      const  id = row.id ||this.ids
      getToollist(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.edit = false;
        this.title = "查看详情信息";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateToollist(this.form).then(response => {
              this.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            this.form.title = this.form.date + "普查情况统计表";
            addToollist(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 delToollist(ids);
        }).then(() => {
          this.getList();
          this.msgSuccess("删除成功");
        })
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams;
      this.$confirm('是否确认导出所有每日工作清单数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return exportToollist(queryParams);
        }).then(response => {
          this.download(response.message);
        })
    }
  }
};
</script>

<!--<style scoped>-->
<!--/deep/ .el-form-item__label{-->
<!--  width: 120px !important;-->
<!--}-->
<!--</style>-->