index.vue 16 KB
Newer Older
王晓倩's avatar
王晓倩 committed
1 2
<template>
  <div class="app-container">
3
    <el-form :model="queryParams" ref="queryParams" :inline="true" v-show="showSearch" label-width="80px">
王晓倩's avatar
王晓倩 committed
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
      <el-form-item label="用户名称" prop="userName">
        <el-input
          v-model="queryParams.userName"
          placeholder="请输入用户名称"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <!--<el-form-item label="身份证号" prop="idCard">
        <el-input
          v-model="queryParams.idCard"
          placeholder="请输入身份证号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>-->
      <el-form-item label="联系电话" prop="linkMobile">
        <el-input
          v-model="queryParams.linkMobile"
          placeholder="请输入联系电话"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="安装时间" prop="installTime">
        <el-date-picker clearable size="small"
                        v-model="queryParams.installTimeStart"
34 35
                        type="date"
                        value-format="yyyy-MM-dd"
王晓倩's avatar
王晓倩 committed
36 37 38 39
                        placeholder="请选择起始时间">
        </el-date-picker><span style="color: #bebfc3"> - </span>
        <el-date-picker clearable size="small"
                        v-model="queryParams.installTimeEnd"
40 41
                        type="date"
                        value-format="yyyy-MM-dd"
王晓倩's avatar
王晓倩 committed
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
                        placeholder="请选择截止时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" 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"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
		  :loading="exportLoading"
          @click="handleExport"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="equipmentList" >
75 76
      <el-table-column label="用户名称" align="center" prop="userName" width="200px"/>
      <el-table-column label="身份证号" align="center" prop="idCard" width="180px"/>
王晓倩's avatar
王晓倩 committed
77 78 79
      <el-table-column label="联系电话" align="center" prop="linkMobile"/>
      <el-table-column label="详细地址" align="center" prop="userAddress" width="380px"/>
      <el-table-column label="安装时间" align="center" prop="installTime"/>
80 81
      <el-table-column label="品牌名称" align="center" prop="brandName"/>
      <el-table-column label="操作" align="center" width="180px">
王晓倩's avatar
王晓倩 committed
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
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="showDetail(scope.row)"
          >详情</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
          >删除</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"
    />

    <!-- 添加或修改用户加装安全装置台账对话框 -->
114
    <el-dialog :title="title1" :visible.sync="open1" width="800px" append-to-body @cancel="cancel1">
王晓倩's avatar
王晓倩 committed
115
      <el-form ref="form" :model="form" :rules="rules" label-width="120px">
116 117 118 119
        <el-row>
          <el-col :span="11">
            <el-form-item label="用户名称" prop="userName">
              <el-input v-model="form.userName" placeholder="请输入用户名称"/>
王晓倩's avatar
王晓倩 committed
120
            </el-form-item>
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
          </el-col>
          <el-col :span="12">
            <el-form-item label="用户编号" prop="userNo">
              <el-input v-model="form.userNo" placeholder="请输入用户编号"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="11">
            <el-form-item label="身份证号" prop="idCard">
              <el-input v-model="form.idCard" placeholder="请输入身份证号" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="联系电话" prop="linkMobile">
              <el-input v-model="form.linkMobile" placeholder="请输入联系电话" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="23">
            <el-form-item label="详细地址" prop="userAddress">
              <el-input type="textarea" v-model="form.userAddress" placeholder="请输入详细地址"/>
王晓倩's avatar
王晓倩 committed
144
            </el-form-item>
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="11">
            <el-form-item label="品牌名称" prop="brandName">
              <el-input v-model="form.brandName" placeholder="请输入品牌名称" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="安装时间" prop="installTime">
              <el-date-picker clearable size="small"
                              v-model="form.installTime"
                              type="date"
                              value-format="yyyy-MM-dd"
                              placeholder="请选择安装时间"
                              style="width: 100%">
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
王晓倩's avatar
王晓倩 committed
165 166 167 168 169 170 171 172 173 174 175 176 177 178
        <el-row>
          <el-col :span="23">
            <el-form-item label="装置类型" prop="equipments">
              <el-select placeholder="请选择装置类型" v-model="form.equipments" multiple filterable clearable style="width: 100%" onchange="change()">
                <el-option
                  v-for="dict in options"
                  :key="dict.dictValue"
                  :label="dict.dictLabel"
                  :value="dict.dictValue"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
179 180 181 182 183 184 185
        <el-row>
          <el-col :span="23">
            <el-form-item label="备注信息" prop="remarks">
              <el-input type="textarea" v-model="form.remarks" placeholder="请输入备注信息" />
            </el-form-item>
          </el-col>
        </el-row>
王晓倩's avatar
王晓倩 committed
186
      </el-form>
187

王晓倩's avatar
王晓倩 committed
188
      <div slot="footer" class="dialog-footer">
189 190
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel1">取 消</el-button>
王晓倩's avatar
王晓倩 committed
191 192
      </div>
    </el-dialog>
193 194

    <el-dialog :title="title2" :visible.sync="open2" width="800px" append-to-body @cancel="cancel2">
195
      <el-form ref="detailForm" :model="detailForm" label-width="100px">
196 197 198
        <el-row>
          <el-col :span="11">
            <el-form-item label="用户名称:">
199
              <el-input v-model="detailForm.userName" disabled/>
200 201
            </el-form-item>
            <el-form-item label="身份证号:">
202
              <el-input v-model="detailForm.idCard" disabled/>
203 204
            </el-form-item>
            <el-form-item label="品牌名称:">
205
              <el-input v-model="detailForm.brandName" disabled/>
206 207 208 209
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="用户编号:">
210
              <el-input v-model="detailForm.userNo" disabled style="width: 100%"/>
211 212
            </el-form-item>
            <el-form-item label="联系电话:">
213
              <el-input v-model="detailForm.linkMobile" disabled/>
214 215
            </el-form-item>
            <el-form-item label="安装时间:">
216
              <el-input v-model="detailForm.installTime" disabled/>
217 218 219
            </el-form-item>
          </el-col>
        </el-row>
王晓倩's avatar
王晓倩 committed
220 221 222 223 224 225 226 227 228 229 230 231 232 233
        <el-row>
          <el-col :span="23">
            <el-form-item label="装置类型" prop="equipments">
              <el-select placeholder="请选择装置类型" v-model="detailForm.equipments" multiple filterable style="width: 100%" disabled>
                <el-option
                  v-for="dict in options"
                  :key="dict.dictValue"
                  :label="dict.dictLabel"
                  :value="dict.dictValue"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
234
        <el-row>
235 236 237 238 239
          <el-col :span="23">
            <el-form-item label="详细地址:">
              <el-input type="textarea" v-model="detailForm.userAddress" disabled/>
            </el-form-item>
          </el-col>
240 241
        </el-row>
        <el-row>
242 243 244 245 246
          <el-col :span="23">
            <el-form-item label="备注信息:">
              <el-input type="textarea" v-model="detailForm.remarks" disabled/>
            </el-form-item>
          </el-col>
247 248 249
        </el-row>
      </el-form>
    </el-dialog>
王晓倩's avatar
王晓倩 committed
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
  </div>
</template>

<script>
import { listEquipment, getEquipment, delEquipment, addEquipment, updateEquipment, exportEquipment } from "@/api/standingBook/equipment";

export default {
  name: "Equipment",
  components: {
  },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 导出遮罩层
      exportLoading: false,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 用户加装安全装置台账表格数据
      equipmentList: [],
王晓倩's avatar
王晓倩 committed
276 277
      // 装置类型字典
      options: [],
王晓倩's avatar
王晓倩 committed
278
      // 弹出层标题
279 280
      title1: "",
      title2: "",
王晓倩's avatar
王晓倩 committed
281
      // 是否显示弹出层
282 283
      open1: false,
      open2: false,
王晓倩's avatar
王晓倩 committed
284 285 286 287 288 289 290 291 292 293 294 295
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        userName: null,
        idCard: null,
        linkMobile: null,
        installTimeStart: null,
        installTimeEnd: null
      },
      // 表单参数
      form: {},
296
      detailForm: {},
王晓倩's avatar
王晓倩 committed
297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312
      // 表单校验
      rules: {
        userName: [
          { required: true, message: "请输入用户名称", trigger: "blur" },
        ],
        userAddress: [
          { required: true, message: "请输入详细地址", trigger: "blur" },
        ],
        linkMobile: [
          { required: true, message: "请输入联系电话", trigger: "blur" },
          { min: 11, max: 11, message: "长度11位", trigger: "blur" },
        ],
        idCard: [
          { required: true, message: "请输入身份证号", trigger: "blur" },
          { min: 18, max: 18, message: "长度18位", trigger: "blur" },
        ],
王晓倩's avatar
王晓倩 committed
313 314 315
        equipments: [
          { required: true, message: "请选择装置类型", trigger: "blur" }
        ],
王晓倩's avatar
王晓倩 committed
316 317 318 319 320 321 322 323
        installTime: [
          { required: true, message: "选择安装时间", trigger: "change" },
        ],
      }
    };
  },
  created() {
    this.getList();
324 325 326
    this.getDicts("t_equipment_type").then(response => {
      this.options = response.data;
    });
王晓倩's avatar
王晓倩 committed
327 328
  },
  methods: {
王晓倩's avatar
王晓倩 committed
329 330 331
    change(){

    },
王晓倩's avatar
王晓倩 committed
332 333 334 335 336 337 338 339 340 341
    /** 查询用户加装安全装置台账列表 */
    getList() {
      this.loading = true;
      listEquipment(this.queryParams).then(response => {
        this.equipmentList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
342 343 344 345 346 347 348
    cancel1() {
      this.open1 = false;
      this.reset1();
    },
    cancel2() {
      this.open2 = false;
      this.reset2();
王晓倩's avatar
王晓倩 committed
349 350
    },
    // 表单重置
351
    reset1() {
王晓倩's avatar
王晓倩 committed
352 353 354 355 356 357 358 359
      this.form = {
        safeEquipmentId: null,
        userName: null,
        userNo: null,
        userAddress: null,
        idCard: null,
        linkMobile: null,
        installTime: null,
王晓倩's avatar
王晓倩 committed
360 361
        equipmentType: null,
        equipments: [],
王晓倩's avatar
王晓倩 committed
362 363 364 365 366 367 368 369 370 371
        brandName: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        isDel: null,
        remarks: null
      };
      this.resetForm("form");
    },
372 373 374 375 376 377 378 379 380
    reset2() {
      this.detailForm = {
        safeEquipmentId: null,
        userName: null,
        userNo: null,
        userAddress: null,
        idCard: null,
        linkMobile: null,
        installTime: null,
王晓倩's avatar
王晓倩 committed
381 382
        equipmentType: null,
        equipments: [],
383 384 385 386 387 388 389 390 391 392
        brandName: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        isDel: null,
        remarks: null
      };
      this.resetForm("detailForm");
    },
王晓倩's avatar
王晓倩 committed
393 394 395 396 397 398 399
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
400 401 402 403 404 405 406 407 408 409
      this.queryParams = {
        pageNum: 1,
        pageSize: 10,
        userName: null,
        idCard: null,
        linkMobile: null,
        installTimeStart: null,
        installTimeEnd: null
      },
      this.resetForm("queryParams");
王晓倩's avatar
王晓倩 committed
410 411 412 413
      this.handleQuery();
    },
    /** 新增按钮操作 */
    handleAdd() {
414 415 416
      this.reset1();
      this.open1 = true;
      this.title1 = "添加用户加装安全装置台账";
王晓倩's avatar
王晓倩 committed
417 418 419
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
420
      this.reset1();
王晓倩's avatar
王晓倩 committed
421
      getEquipment(row.safeEquipmentId).then(response => {
422 423 424
        let data = response.data;
        data.equipments = [];
        this.form = data;
王晓倩's avatar
王晓倩 committed
425 426 427
        if(this.form.equipmentType){
          this.form.equipments = this.form.equipmentType.split(",");
        }
428 429
        this.open1 = true;
        this.title1 = "修改用户加装安全装置台账";
王晓倩's avatar
王晓倩 committed
430 431 432 433 434 435
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
王晓倩's avatar
王晓倩 committed
436 437
          var str = this.form.equipments.toString();
          this.form.equipmentType = str;
王晓倩's avatar
王晓倩 committed
438 439 440
          if (this.form.safeEquipmentId != null) {
            updateEquipment(this.form).then(response => {
              this.msgSuccess("修改成功");
441
              this.open1 = false;
王晓倩's avatar
王晓倩 committed
442 443 444 445 446
              this.getList();
            });
          } else {
            addEquipment(this.form).then(response => {
              this.msgSuccess("新增成功");
447
              this.open1 = false;
王晓倩's avatar
王晓倩 committed
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 484 485
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      // const safeEquipmentIds = row.safeEquipmentId || this.ids;
      row.isDel = "1";
      this.$confirm('是否确认删除"' + row.userName + '"的台账?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return updateEquipment(row);
        }).then(() => {
          this.getList();
          this.msgSuccess("删除成功");
        }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams;
      this.$confirm('是否确认导出所有用户加装安全装置台账数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(() => {
          this.exportLoading = true;
          return exportEquipment(queryParams);
        }).then(response => {
          this.download(response.msg);
          this.exportLoading = false;
        }).catch(() => {});
    },
    /** 详细信息跳转 */
    showDetail(row) {
486
      this.reset2();
487
      getEquipment(row.safeEquipmentId).then(response => {
488
        this.detailForm = response.data;
王晓倩's avatar
王晓倩 committed
489
        this.detailForm.equipments = this.detailForm.equipmentType.split(",");
490 491
        this.open2 = true;
        this.title2 = "用户加装安全装置台账详情";
492
      });
王晓倩's avatar
王晓倩 committed
493 494 495 496
    },
  }
};
</script>