index.vue 7.1 KB
<template>
  <div class="entrySreach">
    <el-form
      class="fedexFormStyle fedexformSreach fedexformSreachBottomBorder"
      ref="sreachForm"
      :model="sreachFormData"
      label-position="top"
      size="small"
    >
      <el-row class="row-border">
        <!-- 角色名称 -->
        <el-col :span="5">
          <Formitem label="密码机编号" prop="cipherMachineNumber">
            <el-input
              type="text"
              class="inputShadow"
              id="inputInner--cipherMachineNumber"
              resize="none"
              v-model="sreachFormData.cipherMachineNumber"
              clearable
              placeholder=""
            ></el-input>
          </Formitem>
        </el-col>
        <el-col :span="5">
          <Formitem label="创建日期" prop="creationTime" :activeType="true">
            <el-date-picker
              class="inputInner--creationTime"
              id="inputInner--creationTime"
              v-model="sreachFormData.creationTime"
              type="daterange"
              format="yyyy-MM-dd"
              prefix-icon="none"
              value-format="yyyy-MM-dd"
              range-separator="至"
              @change="dateChange"
            />
          </Formitem>
        </el-col>
        <el-col :span="2">
          <el-form-item class="textCenter">
            <el-button
              class="entrySreachButton"
              type="text"
              icon="el-icon-search"
              :loading="loadings.searchLoading"
              @click="search(0)"
            ></el-button>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <div class="optionButton">
      <el-button
        class="entrySaveButton"
        icon="el-icon-plus"
        size="small"
        @click="addcipherMachine"
      >
        新 增
      </el-button>
    </div>
    <Table
      class="fedexDetialTable fedexSreachTable"
      ref="entryTable"
      :data="tableData"
      :headerData="headerData"
      :maxHeight="tableMaxheight"
      :border="true"
      :pagination="true"
      :order="true"
      noLabel="序号"
      :loading="loadings.searchLoading"
      :page="page.pageIndex"
      :pageSizes="[20, 30, 50, 100]"
      :totalCount="page.total"
      @sizeChange="sizeChange"
      @currentChange="currentChange"
      :selection="false"
      :selectFixed="false"
      :rowSelectDataType="false"
    >
      <template slot="optionColumn">
        <el-table-column align="left" label="操作" width="100">
          <template slot-scope="scope">
            <el-button type="text" @click="update(scope.row)"> 修改 </el-button>
          </template>
        </el-table-column>
      </template>
    </Table>
    <DialogVue
      :outerVisible="outerVisible"
      :title="dialogTitle"
      :type="editType"
      :active="activeData"
      @close="dialogClose"
    />
  </div>
</template>

<script>
import { getCipherMachineList } from "@/api/system/cipherMachine-api.js";
import DialogVue from "./dialog.vue";
export default {
  name: "RoleConfig",
  components: {
    DialogVue,
  },
  data() {
    return {
      sreachFormData: {
        cipherMachineNumber: "",
        creationTime: [],
      },
      page: {
        pageIndex: 1,
        pageSize: 20,
        total: 0,
      },
      activeData: null,
      tableData: [],
      headerData: [
        {
          name: "密码机编号",
          value: "cipherMachineNumber",
          width: "",
          align: "left",
        },
        {
          name: "密码机IP地址",
          value: "ipAddress",
          width: "",
          align: "left",
        },
        {
          name: "密码机可使用用户数量",
          value: "availableUserCount",
          width: "",
          align: "left",
        },
        {
          name: "创建时间",
          value: "creationTime",
          width: "",
          align: "left",
        },
        {
          name: "创建人",
          value: "creator",
          width: "",
          align: "left",
        },
        {
          name: "修改时间",
          value: "modificationTime",
          width: "",
          align: "left",
        },
        {
          name: "修改人",
          value: "modifier",
          width: "",
          align: "left",
        },
      ],
      loadings: {
        searchLoading: false,
      },
      tableMaxheight: null,
      outerVisible: false,
      dialogTitle: "",
      editType: "",
    };
  },
  created() {
    this.search(0);
  },
  mounted() {
    this.tableMaxheight = window.innerHeight - 300;
  },
  methods: {
    //查询
    search(val) {
      this.loadings.searchLoading = true;
      if (val == 0) {
        this.page.pageIndex = 1;
      }
      let obj = this.sreachFormData;
      obj.pageIndex = this.page.pageIndex;
      obj.pageSize = this.page.pageSize;
      obj.endCreationTime = "";
      obj.startCreationTime = "";
      if (obj.creationTime.length > 0) {
        obj.endCreationTime = obj.creationTime[0];
        obj.startCreationTime = obj.creationTime[1];
      }
      getCipherMachineList(obj)
        .then((res) => {
          if (res.code === "200") {
            this.tableData = res.data.value;
            this.page.total = res.data.totalItems;
            this.tableData.forEach((item, idx) => {
              item.index = idx;
            });
          } else {
            this.alertWarningMsg(res.message);
          }
          this.loadings.searchLoading = false;
        })
        .catch((err) => {
          console.log(err);
          this.loadings.searchLoading = false;
        });
    },
    addcipherMachine() {
      this.dialogTitle = "新增密码机";
      this.editType = "add";
      this.outerVisible = true;
    },
    update(val) {
      this.dialogTitle = "修改密码机";
      this.editType = "update";
      this.outerVisible = true;
      this.activeData = val;
    },
    dialogClose() {
      this.outerVisible = false;
      this.activeData = null;
      this.search(1);
    },
    //分页
    currentChange(val) {
      this.page.pageIndex = val.page;
      this.search(1);
    },
    sizeChange(val) {
      this.page.pageSize = val;
      this.search(1);
    },
    input() {
      this.$forceUpdate();
    },
    dateChange(val) {
      if (val == "" || val == null) {
        this.$nextTick(() => {
          this.sreachFormData.creationTime = [];
        });
      }
    },
  },
};
</script>

<style scoped lang="scss">
@import "@/assets/styles/variables.scss";
.entrySreach {
  height: 100%;
  background-color: $menuLightBg;

  .entrySreachButton {
    display: inline-block;
    font-size: 20px;
    color: $fedexButton !important;
  }

  .optionButton {
    padding: 10px;
    text-align: left;

    .el-button {
      color: $fedexButton;
      border-color: $fedexButton !important;

      svg {
        display: inline-block;
        margin-right: 5px;
        fill: $fedexButton;
      }
    }

    .entrySaveButton:hover,
    .entrySaveButton:focus {
      color: $menuLightBg !important;
      background-color: $fedexButton !important;
    }
  }
}

.texttareaTip {
  position: absolute;
  top: 52%;
  right: 20px;
  transform: translate(0, -50%);
  z-index: 10;
}
</style>