index.vue 12.2 KB
Newer Older
xinzhedeai's avatar
xinzhedeai committed
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
<template>
  <div class="name">
    <el-card class="mt10 box-card">
      <div class="lcl-title">巡检计划</div>
      <div class="mt10" style="overflow: hidden">
        <el-button
          type="primary"
          icon="el-icon-plus"
          @click="addPlan"
          style="float: left"
          >新增</el-button
        >
        <el-button
          type="primary"
          icon="el-icon-download"
          @click="exportExcl"
          style="float: left"
          >下载模板</el-button
        >
        <el-upload
          class="upload"
          ref="upload"
          action="#"
          :multiple="false"
          :on-change="onChange"
          :on-remove="onRemove"
          :on-success="successFun"
          :http-request="planExcle"
          :show-file-list="false"
          accept=".xlsx,.xls"
        >
          <el-button
            type="primary"
            icon="el-icon-upload2"
            style="margin-left: 10px"
            >导入巡检计划</el-button
          >
          <div slot="tip" class="el-upload__tip" style="color: #fff">
            提示:仅允许上传excel文件!
          </div>
        </el-upload>
      </div>
      <div class="mt20" style="clear: both; margin-top: 20px">
        <el-form
          :model="queryParams"
          ref="queryForm"
          size="small"
          :inline="true"
        >
          <el-form-item label="日期">
            <el-date-picker
              v-model="queryParams.time"
              style="width: 240px"
              value-format="yyyy-MM-dd"
              type="daterange"
              range-separator="-"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
              :clearable="false"
            ></el-date-picker>
          </el-form-item>
          <el-form-item label="类型" prop="planType">
            <el-select
              v-model="queryParams.planType"
              placeholder="巡检类型"
              :clearable="false"
              style="width: 240px"
            >
              <el-option
                v-for="dict in dict.type.slope_ins_plan"
                :key="dict.value"
                :label="dict.label"
                :value="dict.value"
              />
            </el-select>
          </el-form-item>
          <el-form-item label="责任人" prop="planName">
            <el-input
              v-model="queryParams.planName"
              placeholder="请输入责任人"
              :clearable="false"
              style="width: 240px"
            />
          </el-form-item>

          <el-form-item>
            <el-button
              type="primary"
              icon="el-icon-search"
              size="mini"
              @click="search"
              >搜索</el-button
            >
          </el-form-item>
        </el-form>
      </div>

      <div class="mt10" id=" radar-table">
        <el-table
          :data="dataList"
          border
          stripe
          style="width: 100%"
          :header-cell-style="{
            textAlign: 'center',
            height: '20px',
          }"
          :row-style="{ height: '20px' }"
        >
          <el-table-column
            prop="orderNum"
            label="排序"
            type="index"
            width="50"
          ></el-table-column>
          <el-table-column align="center" prop="planDate" label="日期">
          </el-table-column>
          <el-table-column align="center" prop="planType" label="巡检类型">
            <template slot-scope="scope">
              <span v-if="scope.row.planType == 1">巡检记录</span>
              <span v-if="scope.row.planType == 2">人工观测</span>
              <span v-if="scope.row.planType == 3">设备校准</span>
            </template>
          </el-table-column>
          <el-table-column align="center" prop="planName" label="责任人">
          </el-table-column>
          <el-table-column align="center" prop="planStatus" label="状态">
            <template slot-scope="scope">
              <el-tag
                class="subject-btn"
                type="warning"
                v-if="scope.row.planStatus == 0"
                >未开始</el-tag
              >
              <el-tag
                class="subject-btn"
                type="success"
                v-if="scope.row.planStatus == 1"
                >完成</el-tag
              >
              <el-tag
                class="subject-btn"
                type="error"
                v-if="scope.row.planStatus == 2"
                >未完成</el-tag
              >
            </template>
          </el-table-column>

          <el-table-column
            align="center"
            class-name="small-padding fixed-width"
            label="状态"
          >
            <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-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"
        />
      </div>
    </el-card>
    <!-- 新增修改 -->
    <el-dialog
      width="30%"
      :inline="true"
      title="巡检计划"
      :visible.sync="watchDialog"
    >
      <el-form ref="form" :model="form">
        <el-form-item label="巡检计划日期" label-width="120">
          <el-col :span="11">
            <el-date-picker
              v-model="form.planDate"
              type="date"
              placeholder="选择日期"
              value-format="yyyy-MM-dd"
            >
            </el-date-picker>
          </el-col>
        </el-form-item>
        <el-form-item label="巡检计划类型" label-width="120">
          <el-col :span="11">
            <el-select
              v-model="form.planType"
              placeholder="巡检类型"
              clearable
              style="width: 240px"
            >
              <el-option
                v-for="dict in dict.type.slope_ins_plan"
                :key="dict.value"
                :label="dict.label"
                :value="dict.value"
              />
            </el-select>
          </el-col>
        </el-form-item>
        <el-form-item label="负责人" label-width="120">
          <el-col :span="11">
            <el-input
              v-model="form.planName"
              placeholder="请输入负责人"
              clearable
              style="width: 240px"
            />
          </el-col>
        </el-form-item>
      </el-form>

      <div slot="footer" class="dialog-footer">
        <el-button @click="watchDialog = false">取 消</el-button>
        <el-button type="primary" @click="submitForm">提 交</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
import {
  exportModel,
  planAdd,
  planHistory,
  planEdit,
  planRemove,
} from "@/api/lclApi/lclapi";
import { planImport } from "@/api/lclApi/formData";
import ChartsForLine from "@/components/lclEcharts/ChartsForLine";
export default {
  name: "name",
  dicts: ["slope_ins_plan"],
  components: { ChartsForLine },
  props: [],
  data() {
    return {
      watchDialogTitle: "1#边坡沉降观测点",
      watchDialog: false,
      dialogView: false,
      dataList: [
        {
          id: 6,
          planDate: "2023-03-01",
          planType: "1",
          planName: "1",
          planStatus: "0",
        },
      ],
      form: {
        watchSub: null,
        val: null,
      },

      queryParams: {
        pageNum: 1,
        pageSize: 10,
        time: "",
        planName: "",
        planStatus: "",
        planType: "",
      },
      total: 0,
      baseURL: process.env.VUE_APP_BASE_API,
      fileList: [],
      formData: null,
    };
  },
  watch: {},
  created() {
    this.$nextTick(() => {});
  },
  mounted() {
    this.$nextTick(() => {
      this.getList();
    });
  },
  methods: {
    formRest() {
      this.form = {
        id: null,
        planDate: null,
        planName: null,
        planStatus: null,
        planType: null,
      };
    },
    handleAdd(row) {
      console.log(row);
    },
    handleView(row) {
      this.watchDialogTitle = row.ren;
      this.getWatchList();
      this.dialogView = true;
    },
    handleChange(e) {
      console.log(e);
    },
    search() {
      this.getList();
    },
    addPlan() {
      this.formRest();
      this.watchDialog = true;
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.formRest();
      this.form = row;
      this.watchDialog = true;
    },
    getList() {
      this.loading = true;
      planHistory(this.queryParams).then((res) => {
        if (res && res.code === 200 && res.rows) {
          this.dataList = res.rows;
          this.total = res.total;
        }
      });
    },
    submitForm() {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          if (this.form.id != undefined) {
            planEdit(this.form).then((response) => {
              this.$modal.msgSuccess("修改成功");
              this.watchDialog = false;
              this.getList();
            });
          } else {
            planAdd(this.form).then((response) => {
              if (response.code === 200) {
                this.$modal.msgSuccess("新增成功");
                this.watchDialog = false;
                this.getList();
              }
            });
          }
        }
      });
    },
    handleDelete(row) {
      const id = row.id || this.ids;
      this.$modal
        .confirm("是否确认删除?")
        .then(function () {
          return planRemove({ id }).then();
        })
        .then(() => {
          this.getList();
          this.$modal.msgSuccess("删除成功");
        })
        .catch(() => {});
    },
371
    /** 导出按钮操作 */
xinzhedeai's avatar
xinzhedeai committed
372
    exportExcl() {
373
      this.download('slope/plan/export/model', {
xinzhedeai's avatar
xinzhedeai committed
374
      }, `巡检计划导入模板.xlsx`)
xinzhedeai's avatar
xinzhedeai committed
375
    },
376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393
    // exportExcl() {
    //   exportModel().then((res) => {


    //     this.$modal
    //       .confirm("是否确认导出?")
    //       .then(function () {
    //         return window.open(
    //           `${this.$store.getters.appPicApi}/excel/${res.msg}`,
    //           "_blank"
    //         );
    //       })
    //       .then(() => {
    //         this.$modal.msgSuccess("导出成功");
    //       })
    //       .catch(() => {});
    //   });
    // },
xinzhedeai's avatar
xinzhedeai committed
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
    onChange(e) {
      this.formData = new FormData();
      this.formData.append("file", e.raw);
    },
    onRemove(file, fileList) {
      console.log(file, fileList, "onRemove");
    },
    successFun(response, file, fileList) {
      console.log(response, file, fileList, "successFun");
    },
    planExcle() {
      planImport(this.formData)
        .then((res) => {
          if (res && res.code === 200) {
            this.$modal.msgSuccess(res.msg);
            // this.$refs.upload.onSuccess(res);
            this.getList();
          }
          // this.$refs.upload.onSuccess(res);
        })
        .catch((err) => {
          this.$refs.upload.onError(err);
        });
    },
  },
};
</script>
<style lang="scss" scoped>
.name {
  width: 100%;
  min-height: 100%;
  .box-card {
    width: 100%;
    .lcl-title {
      font-size: 22px;
      font-family: Source Han Sans CN;
      font-weight: 400;
      color: #333333;
      line-height: 30px;
      position: relative;
      padding-left: 10px;
      &:before {
        content: "";
        position: absolute;
        left: 0px;
        top: 4px;
        width: 6px;
        height: 22px;
        background: #0d85f4;
      }
    }
  }
}
.el-input-number--medium {
  width: 100%;
}
.watchTable {
  width: 50%;
  min-height: 500px;
  float: left;
}

.watch-view-dialog {
  width: 100%;
  overflow: hidden;
  #charta {
    width: 50%;
    height: 500px;
    float: left;
    .nbnb {
      width: 100%;
      height: 500px !important;
    }
  }
}
.cb {
  clear: both;
}
</style>