index.vue 18.7 KB
Newer Older
lxyang committed
1 2 3 4 5
<template>
  <div class="app-container">
    <!--    功能项-->
    <div class="seachData" ref="seachDatas">
        <div class="seachData-left">
lxyang committed
6 7 8
          跟踪文档列表
        </div>
        <div class="seachData-right">
lxyang committed
9
         <el-input v-model="queryParams.name"
lxyang committed
10
                      placeholder="请输入任务名称"
lxyang committed
11
                      suffix-icon="el-icon-search"
lxyang committed
12 13 14 15 16 17 18
                      clearable
                      size="small"
                      @keyup.enter.native="handleQuery" />
          <div class="seachData-next-div left-div">
            <el-button type="primary"
                      icon="el-icon-plus"
                      size="mini"
lxyang committed
19
                      @click="handleAdd">创建任务
lxyang committed
20 21 22 23
            </el-button>
          </div>
        </div>
    </div>
lxyang committed
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
    <div class="table-center">
      <el-table class="seachTable" v-loading="loading"
                :data="customerList"
                :height="tableHeightCount"
                ref="customerListHeight"
                border>
        <el-table-column label="订阅状态"
                       fixed="left"
                       width="90"
                       align="subscriptionStatus">
          <template slot-scope="scope">
            <el-switch v-model="scope.row.subscriptionStatus"
                      active-value="0"
                      inactive-value="1"
                      @change="handleStatusChange(scope.row)"></el-switch>
          </template>
        </el-table-column>
        <el-table-column fixed="left"
                        min-width="240" 
                        label="任务名称"
                        prop="taskName"
                        :show-overflow-tooltip="true"
                        >
          <template slot-scope="scope">
            <div class="ellipsis-hidden"><span class="blue" @click="routerTaskListDetails(scope.row)">{{ isEmpty(scope.row, 'taskName') }}</span></div>
          </template>
        </el-table-column>
        <el-table-column min-width="160" 
                        fixed="left" 
                        label="任务ID"
                        prop="id"
                        >
          <template slot-scope="scope">
            <span>{{ isEmpty(scope.row, 'id') }}</span>
          </template>
        </el-table-column>
        <el-table-column label="任务说明"
                        min-width="280"
                        prop="explain"
                        :show-overflow-tooltip="true"
                        >
          <template slot-scope="scope">
            <div class="ellipsis-hidden">{{ isEmpty(scope.row, 'explain') }}</div>
          </template>
        </el-table-column>
lxyang committed
69

lxyang committed
70 71 72 73 74 75 76
        <el-table-column label="最后修改时间"
                        prop="createTime"
                        width="200">
          <template slot-scope="scope">
            <span>{{ isEmpty(scope.row, 'createTime')  }}</span>
          </template>
        </el-table-column>
lxyang committed
77

lxyang committed
78 79 80 81 82 83 84
        <el-table-column label="状态"
                        prop="status"
                        width="120">
          <template slot-scope="scope">
            <span :class="statusTable(scope.row).class">{{ statusTable(scope.row).text }}</span>
          </template>
        </el-table-column>
lxyang committed
85

lxyang committed
86 87 88 89 90 91 92 93 94 95 96 97 98
        <el-table-column fixed="right"
                        label="操作"
                        width="160">
          <template slot-scope="scope">
            <el-button @click="handleUpdate(scope.row)"
                      type="text"
                      size="small">修改订阅</el-button>
            <el-button @click="handleDelete(scope.row)"
                      type="text"
                      size="small">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
lxyang committed
99

lxyang committed
100 101
      <pagination v-show="total>0"
                  :total="total"
lxyang committed
102 103
                  :page.sync="queryParams.pageindex"
                  :limit.sync="queryParams.pagesize"
lxyang committed
104 105 106 107 108 109 110 111 112 113
                  layout="total, prev, pager, next"
                  @pagination="searchCustomer" />
    </div>
    <el-drawer
      class="from-pop-up"
      :title="title"
      :visible.sync="open"
      :direction="'rtl'"
      :wrapperClosable="false"
      :before-close="cancel">
lxyang committed
114 115
      <el-form ref="form"
               :model="form"
lxyang committed
116
               :rules="rules">
lxyang committed
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
        <el-form-item label="任务名称"
                      prop="taskName">
          <el-input v-model.trim="form.taskName"
                    placeholder="请输入任务名称"
                    :disabled="editFlag" />
        </el-form-item>
        <el-form-item label="选择文档"
                      prop="document">
          <el-select v-model="form.document"
                     clearable
                     placeholder="请选择文档">
            <el-option v-for="item in documentOptions"
                       :key="item.value"
                       :label="item.label"
                       :value="item.value">
            </el-option>
          </el-select>
lxyang committed
134 135 136 137 138
        </el-form-item>
         <el-form-item class="second-level" v-if="form.document === '1'" label="文档链接"
                      prop="link">
          <el-input v-model.trim="form.link"
                    placeholder="请输入文档链接" />
lxyang committed
139 140 141 142 143 144 145 146 147 148 149 150 151
        </el-form-item>
        <el-form-item label="邮箱通知"
                      prop="email">
          <el-input v-model.trim="form.email"
                    placeholder="请输入要订阅和通知的邮箱"
                    :disabled="editFlag" />
        </el-form-item>
        <el-form-item label="任务说明">
          <el-input v-model.trim="form.explain"
                    type="textarea"
                    placeholder="请输入任务说明" />
        </el-form-item>
      </el-form>
lxyang committed
152 153 154 155 156 157 158 159 160 161 162 163
      <div class="dialog-footer">
        <el-button type="primary"
                   @click="submitForm"
                   :loading="submitLoading">确 定</el-button>
        <el-button class="cancel" @click="cancel">取 消</el-button>
      </div>
    </el-drawer>
    <!-- 添加或修改角色配置对话框 -->
    <!-- <el-dialog class="from-pop-up" 
               :title="title"
               :visible.sync="open"
               width="640px">
lxyang committed
164 165 166 167 168 169 170
      <div slot="footer"
           class="dialog-footer">
        <el-button @click="cancel">取 消</el-button>
        <el-button type="primary"
                   @click="submitForm"
                   :loading="submitLoading">确 定</el-button>
      </div>
lxyang committed
171
    </el-dialog> -->
lxyang committed
172 173 174 175 176
  </div>
</template>

<script>
import {
lxyang committed
177
  doctaskList,
lxyang committed
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
} from "@/api/system/customer";
export default {
  data() {
    return {
      // 遮罩层
      loading: true,
      submitLoading: false,
      // 总条数
      total: 0,
      // 角色表格数据
      customerList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 是否显示弹出层(数据权限)
      openDataScope: false,
      // 日期范围
      searchDateRange: [],
      customerStatusOptions: [
        {
          dictValue: "ENABLE",
          dictLabel: "正常"
        },
        {
          dictValue: "DISABLE",
          dictLabel: "失效"
        }
      ],
      // 查询参数
      queryParams: {
lxyang committed
209 210 211
        pageindex: 1,
        pagesize: 10,
        name: ""
lxyang committed
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
      },
      queryParamsStatus: true,
      // 表单参数
      form: {
        id: undefined,
        taskName: "",
        document: "",
        link: "",
        email: "",
        explain: ""
      },
      // 选择文档
      documentOptions: [
        {
          label: "巨量",
          value: "0"
        },
        {
          label: "其他",
          value: "1"
        }
      ],
      editFlag: false,
      defaultProps: {
        children: "children",
        label: "label"
      },
      // 表单校验
      rules: {
        taskName: [
          { required: true, message: "任务名称不能为空", trigger: "blur" }
        ],
        email: [
          { required: true, message: "邮箱不能为空", trigger: "blur" },
          {
            validator: function (rule, value, callback) {
              let verificationLink = /^[A-Za-z0-9]+([_\.][A-Za-z0-9]+)*@([A-Za-z0-9\-]+\.)+[A-Za-z]{2,6}$/
              if (verificationLink.test(value) === false) {
                callback(new Error('请输入正确的邮箱地址'))
              } else {
                callback()
              }
            },
            trigger: 'blur'
          }
        ],
        document: [
          { required: true, message: "请选择文档", trigger: "blur" }
        ],
        link: [
          { required: true, message: "文档链接不能为空", trigger: "blur" },
          {
            validator: function (rule, value, callback) {
              let verificationLink = /(http|https):\/\/([\w.]+\/?)\S*/
              if (verificationLink.test(value) === false) {
                callback(new Error('请输入正确的url'))
              } else {
                callback()
              }
            },
            trigger: 'blur'
          }
        ]
      },
      tableHeights: 0, // table高度
      customerListHeights: 0 // table真实高度
    };
  },
  created() {
    this.searchCustomer();
    this.$nextTick(() => {
      this.tableHeight();
    })
  },
  computed: {
    // 计算过的height
    tableHeightCount() {
lxyang committed
289
      return this.tableHeights - 112
lxyang committed
290 291 292 293
    }
  },
  methods: {
    tableHeight() {
lxyang committed
294
      let height = document.documentElement.clientHeight - 128
lxyang committed
295 296
      this.tableHeights = height < 580 ? 580 : height
    },
lxyang committed
297 298 299 300 301 302 303 304 305 306
    // 跳转跟踪文档详情界面
    routerTaskListDetails(row) {
      this.$router.push({
         path: '/documentManagement/taskListDetails',
         query: {
           id: row.id,
           name: row.taskName
         }
      })
    },
lxyang committed
307 308 309 310 311 312 313
    // table显示内容
    isEmpty(row, name) {
      return !row[name] ? '-' : row[name]
    },
    // table显示状态
    statusTable(row) {
      let status = {
lxyang committed
314 315 316 317 318 319 320 321 322 323 324 325
        0: {
          text: "已失效",
          class: "span-table span-red"
        },
        1: {
          text: "运行中",
          class: "span-table span-blue"
        },
        2: {
          text: "已完成",
          class: "span-table span-green"
        }
lxyang committed
326
      }
lxyang committed
327 328 329 330 331 332 333 334 335 336 337 338
      return status[row.status] ? status[row.status] : {
        text: "",
        class: ""
      }
    },
    handleStatusChange(row) {
      // editStatus(row.id, row.subscriptionStatus)
      //   .then(() => {
          this.searchCustomer();
          this.msgSuccess("修改状态成功");
        // })
        // .catch(() => this.msgError("修改状态失败"));
lxyang committed
339 340 341
    },
    searchCustomer() {
      this.loading = true;
lxyang committed
342 343 344
      doctaskList(this.queryParams)
        .then(response => {
          console.log(response, 'response')
lxyang committed
345 346 347 348 349
          let data = [
            {
              id: 1,
              taskName: '任务1',
              explain: '这是一个任务1',
lxyang committed
350
              subscriptionStatus: '1',
lxyang committed
351 352 353 354 355 356 357 358 359
              createTime: '2020-10-22 20:16:01',
              status: 0,
              document: '1',
              link: 'https://element.eleme.io/#/zh-CN/component/form#form-item-methods',
              email: '111111111@.qq.com'
            },
            {
              id: 2,
              taskName: '任务2',
lxyang committed
360
              subscriptionStatus: '1',
lxyang committed
361 362 363 364 365 366 367 368 369 370 371
              explain: '这是一个任务2',
              createTime: '2020-10-22 20:16:01',
              status: 1,
              document: '0',
              link: '',
              email: '111111111@qq.com'
            },
            {
              id: 3,
              taskName: '任务3',
              explain: '',
lxyang committed
372
              subscriptionStatus: '0',
lxyang committed
373
              createTime: '2020-10-22 20:16:01',
lxyang committed
374
              status: 2,
lxyang committed
375 376 377 378 379 380 381 382 383
              document: '0',
              link: '',
              email: '111111111@.qq.com'
            }
          ]
          // this.customerList = response.data.records;
          this.customerList = data
          // data
          // this.total = response.data.total;
lxyang committed
384
          this.total = 0;
lxyang committed
385 386 387 388
          // 10;
          setTimeout(() => {
            this.loading = false;
          }, 2000)
lxyang committed
389 390 391
          this.$nextTick(() => {
            this.customerListHeights = this.$refs.customerListHeight.offsetHeight
          })
lxyang committed
392 393 394 395
        })
        .catch(error => {
          this.loading = false;
        });
lxyang committed
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 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529
        this.$nextTick(() => {
          this.customerListHeights = this.$refs.customerListHeight.offsetHeight
        })
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 取消按钮(数据权限)
    cancelDataScope() {
      this.openDataScope = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: undefined,
        taskName: "",
        document: "",
        link: "",
        email: "",
        explain: ""
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.current = 1;
      this.searchCustomer();
    },
    /** 重置筛选 */
    resetHandleQuery() {
      this.queryParams = {
        current: 1,
        size: 10,
        taskName: ""
      };
      this.searchCustomer();
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      // this.editFlag = false;
      this.title = "创建跟踪任务";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      // getCustomer(row.id).then(response => {
        // this.form = response.data;
        this.handleUpdateFrom(row)
        this.open = true;
        this.title = "修改跟踪任务";
      // });
    },
    // 修改from赋值
    handleUpdateFrom(row) {
      this.form.id = row.id ? row.id : undefined
      this.form.taskName = row.taskName ? row.taskName : ""
      this.form.document = row.document ? row.document : ""
      this.form.link = row.link ? row.link : ""
      this.form.email = row.email ? row.email : ""
      this.form.explain = row.explain ? row.explain : ""
    },
    /** 提交按钮 */
    submitForm: function() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id) {
            this.submitLoading = true;
            // editCustomer(this.form)
            //   .then(response => {
            //     if (response.code === 200) {
                  this.msgSuccess("修改成功");
                  this.open = false;
                  this.searchCustomer();
              //   } else {
              //     this.msgError(response.msg);
              //   }
              //   // this.editFlag = false;
              //   this.submitLoading = false;
              // })
              // .catch(() => {
              //   this.submitLoading = false;
              // });
          }
          // 否则新建
          else {
            this.submitLoading = true;
            // addCustomer(this.form)
            //   .then(response => {
            //     if (response.code === 200) {
                  this.msgSuccess("新增成功");
                  this.open = false;
                  this.searchCustomer();
              //   } else {
              //     this.msgError(response.msg);
              //   }
              //   this.submitLoading = false;
              // })
              // .catch(() => {
              //   this.submitLoading = false;
              // });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      this.$confirm(
        '是否确认删除名称为"' + row.taskName + '"的跟踪任务?',
        "警告",
        {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }
      )
        .then(() => {
          // return deleteCustomer(row.id);
        })
        .then(() => {
          this.searchCustomer();
          this.msgSuccess("删除成功");
        })
        .catch(() => this.msgError("删除失败"));
    }
  }
};
</script>
<style scoped lang="scss">
@import '@/views/main.scss';
lxyang committed
530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666
.table-center {
  width: calc(100% - 32px);
  height: calc(100% - 96px);
  display: inline-block;
  margin: 16px;
  background: #fff;
}
/deep/.seachTable {
  margin: 16px;
  width: calc(100% - 32px);
  &.el-table {
    th {
      background: #fff;
      color: #a8a8a8;
    }
    .el-table__header-wrapper th {
      color: #a8a8a8;
    }
    .el-button--small {
      font-size: 14px;
      color: #0052d9;
    }
    .el-button + .el-button {
      margin-left: 16px;
    }
    .span-table {
      padding-left: 16px;
      position: relative;
      &::before {
        content: '';
        position: absolute;
        left: 0;
        top: 50%;
        transform: translate(0, -50%);
        width: 8px;
        height: 8px;
        border-radius: 50%;
      }
    }
    .span-red {
      &::before {
        background: rgba(227, 77, 89, 1);
      }
    }
    .span-blue {
      &::before {
        background: rgba(0, 82, 217, 1);
      }
    }
    .span-green {
      &::before {
        background: rgba(5, 168, 112, 1);
      }
    }
  }
}
/deep/.pagination-container {
  height: 32px;
  margin: 0 16px 16px 16px;
  padding: 0 !important;
  width: calc(100% - 32px);
}
/deep/.el-pagination.is-background {
      .el-pager li {
          background-color: #fff;
          border-radius: 3px;
          color: rgba(0, 0, 0, 0.6000);
          border: 1px solid rgba(220, 220, 220, 1);
          border-radius: 3px;
          &:not(.disabled).active {
              color: #fff;
              background: rgba(0, 82, 217, 1);
          }
      }
      .btn-prev, .btn-next {
          border: 0;
          background: #fff;
          color: rgba(0, 0, 0, 0.6000);
      }
  }
  /deep/.el-drawer__header {
    height: 64px;
    font-size: 16px;
    padding: 0;
    line-height: 64px;
    color: rgba(0, 0, 0, 0.9000);
    font-weight: 500;
    margin-bottom: 26px;
    padding: 0 24px;
    box-shadow: inset 0px -1px 0px 0px #dcdcdc;
  }
  .el-form {
    padding: 0 24px;
    /deep/.el-form-item__label {
      width: 100% !important;
      text-align: left;
    }
    /deep/.el-form-item__content {
      margin-left: 0 !important;
    }
    /deep/.el-select, /deep/.el-select > .el-input {
      width: 100%;
    }
  }
  .dialog-footer {
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    line-height: 64px;
    height: 64px;
    padding: 0 24px;
    border-top: 1px solid rgba(231, 231, 231, 1);
    /deep/.el-button--medium {
      width: 60px;
      height: 32px;
      border-radius: 3px;
      padding: 0;
      text-align: center;
      line-height: 32px;
      font-size: 14px;
    }
    /deep/.el-button--primary {
      background: #0052D9;
      border-color: #0052D9;
    }
    .el-button--medium {
      &.cancel {
        background: #E7E7E7;
        border-color: #E7E7E7;
        color: rgba(0, 0, 0, 0.9000);
      }
    }
    .el-button + .el-button {
      margin-left: 8px;
    }
  }
lxyang committed
667 668 669
  .second-level {
    margin-left: 20px;
  }
lxyang committed
670
</style>