FlowUploadPropertiesManager.vue 16.6 KB
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 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 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 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 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
<template>
  <div class="fullheight">
    <ht-table
      @load="loadData"
      :data="data"
      :pageResult="pageResult"
      :selection="true"
      quick-search-props="name,flowKey,flowName,desc"
      :show-export="false"
      :show-custom-column="false"
      ref="htTable"
      :header-cell-class-name="headerCellClassName"
      @selection-change="handleSelectionChange"
    >
      <template v-slot:toolbar>
        <!-- <el-button-group> -->
        <el-button
          size="small"
          @click="showDialog()"
          icon="el-icon-plus"
          type="primary"
          >添加</el-button
        >
        <ht-delete-button
          url="${portal}/system/flowUploadProperties/v1/remove"
          :htTable="$refs.htTable"
          style="margin-left:10px;"
          :disabled="isDisabled"
          >删除</ht-delete-button
        >
        <!-- </el-button-group> -->
      </template>
      <template>
        <ht-table-column type="index" width="50" align="center" label="序号" />
        <ht-table-column
          prop="name"
          label="名称"
          :sortable="true"
          :show-overflow-tooltip="true"
        >
          <template v-slot="{row}">
            <el-link
              type="primary"
              @click="showDialog(row.id)"
              title="查看详情"
              >{{ row.name }}</el-link
            >
          </template>
        </ht-table-column>
        <ht-table-column
          prop="flowName"
          label="流程名称"
          :sortable="false"
          :show-overflow-tooltip="true"
        >
          <template v-slot="{row}">
            {{ getShowName(row.flowName) }}
          </template>
        </ht-table-column>
        <ht-table-column
          prop="uploadType"
          label="存储类型"
          width="150"
          :render-header="renderHeaderMethod"
          :filters="[
            {text: '磁盘', value: 'folder'},
            {text: '数据库', value: 'database'},
            {text: 'FTP服务器', value: 'ftp'},
            {text: '阿里云OSS', value: 'aliyunOss'}
          ]"
        >
          <template v-slot="{row}">
            <el-tag type="info" v-if="row.uploadType == 'folder'">磁盘</el-tag>
            <el-tag type="success" v-if="row.uploadType == 'database'"
              >数据库</el-tag
            >
            <el-tag type="warning" v-if="row.uploadType == 'ftp'"
              >FTP服务器</el-tag
            >
            <el-tag type="warning" v-if="row.uploadType == 'aliyunOss'"
              >阿里云OSS</el-tag
            >
          </template>
        </ht-table-column>
        <ht-table-column
          width="120"
          prop="location"
          label="存储位置"
          :sortable="true"
          :show-overflow-tooltip="true"
        >
        </ht-table-column>
        <ht-table-column
          width="180"
          prop="ftpUrl"
          label="FTP上传地址"
          :sortable="true"
          :show-overflow-tooltip="true"
        >
        </ht-table-column>
        <ht-table-column
          prop="status"
          label="状态"
          width="120"
          :render-header="renderHeaderMethod"
          :filters="[
            {text: '启用', value: 'enable'},
            {text: '禁用', value: 'disable'}
          ]"
        >
          <template v-slot="{row}">
            <el-tag type="success" v-if="row.status == 'enable'">启用</el-tag>
            <el-tag type="danger" v-if="row.status == 'disable'">禁用</el-tag>
          </template>
        </ht-table-column>
        <ht-table-column
          width="180"
          prop="desc"
          label="描述"
          :sortable="true"
          :show-overflow-tooltip="true"
        >
        </ht-table-column>
      </template>
    </ht-table>
    <ht-sidebar-dialog
      width="37%"
      title="流程附件上传配置"
      class="sp-manager__dialog"
      :visible="dialogVisible"
      :before-close="beforeCloseDialog"
    >
      <el-form
        v-form
        label-position="left"
        data-vv-scope="flowUploadPropertiesForm"
      >
        <ht-form-item label="名称">
          <ht-input
            v-model="flowUploadProperties.name"
            validate="required"
            :maxlength="50"
            show-word-limit="true"
          />
        </ht-form-item>
        <ht-form-item label="流程名称" class="is-required">
          <el-tag
            :key="flow.key"
            v-for="flow in selectedFlows"
            closable
            type="info"
            :disable-transitions="false"
            @close="handleClose(flow)"
          >
            {{ flow.name }}
          </el-tag>
          <el-button type="primary" size="mini" @click="showFlowDialog()"
            >选择</el-button
          >
          <el-popconfirm
            title="您确定要清空嘛?"
            @onConfirm="cleanSelectedFlows()"
            @confirm="cleanSelectedFlows()"
            class="dialog-popconfirm"
          >
            <el-button
              size="mini"
              type="primary"
              plain
              slot="reference"
              class="clearButtom"
              >清空选择</el-button
            >
          </el-popconfirm>
          <!-- 流程选择对话框  -->
          <eip-flow-dialog
            ref="eipFlowDialog"
            name="eipFlowDialog"
            @onConfirm="dialogOnConfirm"
            append-to-body
          />
        </ht-form-item>
        <ht-form-item label="上传方式" stylestyle="width:120px;">
          <el-radio-group
            v-model="flowUploadProperties.uploadType"
            validate="required"
          >
            <el-radio label="folder">文件目录</el-radio>
            <el-radio label="ftp">FTP服务器</el-radio>
            <el-radio label="database">数据库</el-radio>
            <el-radio label="aliyunOss">阿里云OSS</el-radio>
          </el-radio-group>
        </ht-form-item>
        <ht-form-item
          v-if="flowUploadProperties.uploadType == 'folder'"
          label="存储位置"
          stylestyle="width:120px;"
        >
          <ht-input
            v-model="flowUploadProperties.location"
            validate="required"
            :maxlength="100"
            show-word-limit="true"
          />
        </ht-form-item>
        <ht-form-item
          v-if="flowUploadProperties.uploadType == 'ftp'"
          label="根目录"
          stylestyle="width:120px;"
        >
          <ht-input
            v-model="flowUploadProperties.location"
            validate="required"
            :maxlength="100"
            show-word-limit="true"
          />
        </ht-form-item>
        <ht-form-item
          v-if="flowUploadProperties.uploadType == 'ftp'"
          label="上传地址"
          stylestyle="width:120px;"
        >
          <ht-input
            type="textarea"
            v-model="flowUploadProperties.ftpUrl"
            placeholder="上传地址"
            validate="required"
            :rows="3"
            resize="none"
            :maxlength="80"
            :showWordLimit="true"
          />
        </ht-form-item>
        <ht-form-item
          v-if="flowUploadProperties.uploadType == 'ftp'"
          label="端口号"
          stylestyle="width:120px; "
        >
          <ht-input
            v-model="flowUploadProperties.ftpPort"
            validate="required"
            :maxlength="10"
            show-word-limit="true"
            autocomplete="on"
            :validate="{
              regex: {
                exp: '^[1-9]\\d{0,4}$',
                message: '端口号格式不正确'
              },
              required: true
            }"
          />
        </ht-form-item>
        <ht-form-item
          v-if="flowUploadProperties.uploadType == 'ftp'"
          label="用户名"
          stylestyle="width:120px;"
        >
          <ht-input
            v-model="flowUploadProperties.ftpUserName"
            validate="required"
            :maxlength="50"
            show-word-limit="true"
          />
        </ht-form-item>
        <ht-form-item
          v-if="flowUploadProperties.uploadType == 'ftp'"
          label="密码"
          stylestyle="width:120px;"
        >
          <ht-input
            v-model="flowUploadProperties.ftpPassword"
            type="password"
            validate="required"
            :maxlength="50"
            show-word-limit="true"
          />
        </ht-form-item>

        <ht-form-item
          v-if="flowUploadProperties.uploadType == 'aliyunOss'"
          label="访问域名"
          stylestyle="width:120px;"
        >
          <ht-input
            v-model="flowUploadProperties.aliyunOssEndpoint"
            placeholder="http://oss-cn-guangzhou.aliyuncs.com"
            validate="required"
            :maxlength="80"
            show-word-limit="true"
          />
        </ht-form-item>
        <ht-form-item
          v-if="flowUploadProperties.uploadType == 'aliyunOss'"
          label="密钥Id"
          stylestyle="width:120px;"
        >
          <ht-input
            type="password"
            v-model="flowUploadProperties.aliyunOssAccessKeyId"
            placeholder=""
            validate="required"
            :maxlength="80"
            show-word-limit="true"
          />
        </ht-form-item>
        <ht-form-item
          v-if="flowUploadProperties.uploadType == 'aliyunOss'"
          label="密钥Secret"
          stylestyle="width:120px;"
        >
          <ht-input
            type="password"
            v-model="flowUploadProperties.aliyunOssAccessKeySecret"
            placeholder=""
            validate="required"
           :maxlength="80"
            show-word-limit="true"
          />
        </ht-form-item>
        <ht-form-item
          v-if="flowUploadProperties.uploadType == 'aliyunOss'"
          label="主目录"
          stylestyle="width:120px;"
        >
          <ht-input
            v-model="flowUploadProperties.location"
            placeholder="hotent"
            validate="required"
            :maxlength="100"
            show-word-limit="true"
          />
        </ht-form-item>

        <ht-form-item label="状态" stylestyle="width:120px;">
          <el-radio-group
            v-model="flowUploadProperties.status"
            validate="required"
          >
            <el-radio label="enable">启用</el-radio>
            <el-radio label="disable">禁用</el-radio>
          </el-radio-group>
        </ht-form-item>
        <ht-form-item label="描述" stylestyle="width:120px;">
          <ht-input
            type="textarea"
            v-model="flowUploadProperties.desc"
            placeholder="请输入描述内容..."
            :rows="3"
            resize="none"
            :maxlength="300"
            :showWordLimit="true"
          />
        </ht-form-item>
      </el-form>
      <div slot="footer" style="text-align: right">
        <el-button @click="beforeCloseDialog">{{
          $t('eip.common.cancel')
        }}</el-button>
        <ht-submit-button
          url="${portal}/system/flowUploadProperties/v1/save"
          :model="flowUploadProperties"
          scope-name="flowUploadPropertiesForm"
          :isSubmit="isSubmit"
          @before-save-data="beforeSaveData"
          @after-save-data="afterSaveData"
          >{{ $t('eip.common.save') }}</ht-submit-button
        >
      </div>
    </ht-sidebar-dialog>
  </div>
</template>
<script>
const eipFlowDialog = () => import('@/components/dialog/EipFlowDialog.vue')
import tableHeaderFilter from '@/mixins/tableHeaderFilter.js'
export default {
  components: {
    eipFlowDialog
  },
  mixins: [tableHeaderFilter],
  data() {
    return {
      dialogVisible: false,
      data: [],
      pageResult: {
        page: 1,
        pageSize: 50,
        total: 0
      },
      selectedFlows: [],
      flowUploadProperties: {
        uploadType: 'ftp',
        status: 'enable',
        encryptName: 1
      },
      isSubmit: false,
      isDisabled: true, //按钮的禁用
      selectedList: []
    }
  },
  watch: {
    // 监听选中下
    selectedList: {
      handler(val) {
        this.isDisabled = val.length < 1 ? true : false
      },
      deep: true
    }
  },
  mounted() {
    this.$validator = this.$root.$validator
  },
  methods: {
    handleSelectionChange(selection) {
      this.selectedList = selection
    },
    showFlowDialog() {
      this.$refs.eipFlowDialog.showDialog()
    },
    showDialog(id) {
      this.selectedFlows = []
      let _this = this
      if (id) {
        this.$http
          .get('${portal}/system/flowUploadProperties/v1/getJson?id=' + `${id}`)
          .then(
            resp => {
              _this.flowUploadProperties = resp.data
              _this.flowUploadProperties.encryptName = 1
              _this.dialogVisible = true
              _this.initSelectFlow(resp.data)
            },
            error => {
              reject(error)
            }
          )
      } else {
        this.flowUploadProperties = {
          uploadType: 'ftp',
          status: 'enable',
          encryptName: 1
        }
        this.dialogVisible = true
      }
    },
    initSelectFlow(properties) {
      let _this = this
      if (properties.flowKey) {
        const flowKeys = properties.flowKey.split(',')
        const flowNames = properties.flowName.split(',')
        for (let i = 0; i < flowKeys.length; i++) {
          const key = flowKeys[i]
          if (key) {
            _this.selectedFlows.push({key: key, name: flowNames[i]})
          }
        }
      }
    },
    beforeCloseDialog() {
      this.flowUploadProperties = {}
      this.dialogVisible = false
      this.selectedFlows = []
    },
    handleClose(flow) {
      this.selectedFlows.splice(this.selectedFlows.indexOf(flow), 1)
    },
    dialogOnConfirm(data) {
      let _this = this
      data.forEach(ele => {
        let isIn = false
        _this.selectedFlows.forEach(sele => {
          if (sele.key == ele.defKey) {
            isIn = true
          }
        })
        if (!isIn) {
          _this.selectedFlows.push({key: ele.defKey, name: ele.name})
        }
      })
    },
    loadData(param, cb) {
      this.$http
        .post('${portal}/system/flowUploadProperties/v1/listJson', param)
        .then(
          resp => {
            let response = resp.data
            this.data = response.rows
            this.pageResult = {
              page: response.page,
              pageSize: response.pageSize,
              total: response.total
            }
          },
          error => {
            reject(error)
          }
        )
        .finally(() => cb())
    },
    beforeSaveData() {
      this.isSubmit = true
      if (!this.selectedFlows || this.selectedFlows.length < 1) {
        this.$message.warning('请选择流程!')
        this.isSubmit = false
        return
      }
      if (!this.flowUploadProperties.status) {
        this.$message.warning('请选择状态!')
        this.isSubmit = false
        return
      }
      let flowKeys = ''
      let flowNames = ''
      this.selectedFlows.forEach(flow => {
        if (flowKeys) {
          flowKeys += ','
          flowNames += ','
        }
        flowKeys += flow.key
        flowNames += flow.name
      })
      this.flowUploadProperties.flowKey = flowKeys
      this.flowUploadProperties.flowName = flowNames
    },
    afterSaveData() {
      setTimeout(() => {
        this.beforeCloseDialog()
        this.$refs.htTable.load()
      }, 500)
    },
    getShowName(name) {
      if (name) {
        name = name.substr(1)
        name = name.substr(0, name.length - 1)
      }
      return name
    },
    cleanSelectedFlows() {
      // 流程附件上传配置,清楚选择的流程
      this.selectedFlows = []
    }
  }
}
</script>

<style lang="scss" scoped>
::v-deep {
  .cell > .el-table__column-filter-trigger {
    display: none;
  }
}
.el-tag:first-child {
  margin-right: 5px;
}
.el-tag + .el-tag {
  margin-left: 5px;
  margin-right: 5px;
}
.el-tag--small {
  line-height: 24px;
}
.sp-manager__dialog /deep/ > .el-dialog > .el-dialog__body {
  height: calc(100% - 190px);
}

.sp-manager__dialog >>> .dialog-popconfirm {
  margin-left: 3px;
}
@media (max-width: 1024px) {
  /deep/ .el-dialog {
    width: 45% !important;
  }
}

.el-form {
  ::v-deep {
    .el-form-item__label {
      color: #888888;
    }
    .el-button {
      padding-top: 6px;
      padding-bottom: 6px;
    }
    .el-tag .el-icon-close::before {
      background: #dbdbdb;
      border-radius: 50%;
      font-weight: bold;
      display: flex;
      justify-content: center;
      align-items: center;
    }
    .inputs {
      width: 100%;
    }
    .el-input__inner{
      background: #fff !important;
    }
  }
}
.clearButtom {
  background: #fff;
}
</style>