index.vue 9.15 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="garUserTel">
        <el-input v-model="queryParams.garUserTel" placeholder="请输入手机号" clearable size="small"
          @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="用户名" prop="garUserName">
        <el-input v-model="queryParams.garUserName" placeholder="请输入用户名" clearable size="small"
          @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="用户类型" prop="garUserType">
        <el-select v-model="queryParams.garUserType" placeholder="请选择用户类型" clearable size="small">
          <el-option label="用户" value="用户" />
          <el-option label="运输企业负责人" value="运输企业负责人" />
          <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">
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="GarUserList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="手机号" align="center" prop="garUserTel" />
      <el-table-column label="用户名" align="center" prop="garUserName" />
      <el-table-column label="用户类型" align="center" prop="garUserType" />
      <el-table-column label="创建时间" align="center" prop="garCreateTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.garCreateTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="修改时间" align="center" prop="garUpdateTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.garUpdateTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="备注" align="center" prop="garRemark" />
      <!-- <el-table-column fixed="right" label="操作" width="200px" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button size="mini" type="text" icon="el-icon-edit" @click="queryEvaluate(scope.row)"
            v-hasPermi="['garbage:order:edit']">过往评价</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="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="手机号" prop="garUserTel">
          <el-input v-model="form.garUserTel" placeholder="请输入手机号" />
        </el-form-item>
        <el-form-item label="用户名" prop="garUserName">
          <el-input v-model="form.garUserName" placeholder="请输入用户名" />
        </el-form-item>
        <el-form-item label="用户类型" prop="garUserType">
          <el-select v-model="form.garUserType" placeholder="请选择用户类型" clearable size="small">
            <el-option label="居民用户" value="居民用户" />
            <el-option label="管理负责人" value="管理负责人" />
          </el-select>
        </el-form-item>
        <el-form-item label="创建时间" prop="garCreateTime">
          <el-date-picker clearable size="small" style="width: 200px" v-model="form.garCreateTime" type="date"
            value-format="yyyy-MM-dd" placeholder="选择创建时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="修改时间" prop="garUpdateTime">
          <el-date-picker clearable size="small" style="width: 200px" v-model="form.garUpdateTime" type="date"
            value-format="yyyy-MM-dd" placeholder="选择修改时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="备注" prop="garRemark">
          <el-input v-model="form.garRemark" placeholder="请输入备注" />
        </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 { addGarUser, delGarUser, exportGarUser, getGarUser, listGarUser, updateGarUser } from "@/api/gar/user";

export default {
  name: "GarUser",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 建筑垃圾-用户表格数据
      GarUserList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        garUserTel: null,
        garUserName: null,
        garUserType: null,
        garUserCarNum: null,
        garUserDelFlag: null,
        garCreateTime: null,
        garUpdateTime: null,
        garRemark: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        garUserTel: [
          { required: true, message: "手机号不能为空", trigger: "blur" }
        ],
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {

    queryEvaluate(row) {
      this.open = true;
      console.log(row);
    },
    /** 查询建筑垃圾-用户列表 */
    getList() {
      this.loading = true;
      listGarUser(this.queryParams).then(response => {
        console.log(response);
        this.GarUserList = response.data.list;
        this.total = response.data.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        garUserId: null,
        garUserTel: null,
        garUserName: null,
        garUserType: null,
        garUserCarNum: null,
        garUserDelFlag: null,
        garCreateTime: null,
        garUpdateTime: null,
        garRemark: 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.garUserId)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加建筑垃圾-用户";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const garUserId = row.garUserId || this.ids
      getGarUser(garUserId).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改建筑垃圾-用户";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.garUserId != null) {
            updateGarUser(this.form).then(response => {
              this.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addGarUser(this.form).then(response => {
              this.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const garUserIds = row.garUserId || this.ids;
      this.$confirm('是否确认删除建筑垃圾-用户编号为"' + garUserIds + '"的数据项?', "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(function () {
        return delGarUser(garUserIds);
      }).then(() => {
        this.getList();
        this.msgSuccess("删除成功");
      })
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams;
      this.$confirm('是否确认导出所有建筑垃圾-用户数据项?', "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(function () {
        return exportGarUser(queryParams);
      }).then(response => {
        this.download(response.msg);
      })
    }
  }
};
</script>