index.vue 5.26 KB
<template>
  <div class="system-container">
    <div class="user-container">
      <search-form
        class="searchTop border-shadow"
        :formModel="searchForm"
        :formList="worklogFormList"
      >
        <slot name="form-slot">
          <el-button
            type="primary"
            :size="btn_size"
            icon="el-icon-search"
            :id="tableParams.btnId"
          >搜索</el-button>
          <el-button
            type="primary"
            :size="btn_size"
            icon="el-icon-refresh"
            @click="refresh"
          >重置</el-button>
        </slot>
      </search-form>
      <div class="table-btn">
        <el-button
          type="primary"
          :size="btn_size"
          @click="exportTable"
        >导出</el-button>
      </div>
      <basic-table
        :tableParams="tableParams"
        :getListApi="getListApi"
        :beforeSearchFn="beforeSearchFn"
        :searchForm="searchDataForm"
        :hasNum="false"
      >
        <span
          slot="status"
          slot-scope="scope"
        >
          <span
            class="statusText"
            :class="scope.scope.operStatus ? WORKLOGSTATUS[scope.scope.operStatus].split(',')[1] : ''"
          >
            {{scope.scope.operStatus ? WORKLOGSTATUS[scope.scope.operStatus].split(',')[0] : '--'}}
          </span>
        </span>
      </basic-table>
      <basic-dialog
        :title="worklogDialogTitle"
        :isVisible="worklogVisible"
        @confirmDialog="handleConfirm"
        @closeDialog="handleClose"
      >
        <slot>
          <rule-form
            :ruleForm="worklogForm"
            :rules="worklogRules"
            :ruleData="worklogData"
            ref='worklogForm'
          ></rule-form>
        </slot>
      </basic-dialog>
    </div>
  </div>
</template>

<script>
import { getWorkLogList, exportWorkLog } from 'services/worklog';
export default {
  data() {
    return {
      WORKLOGSTATUS: this.$Constants.WORKLOG_STATUS,
      searchForm: {},
      searchDataForm: {},
      worklogFormList: [
        {
          type: 'daterange',
          prop: 'daterange',
          placeholder: '请输入字典名称'
        }
      ],
      tableParams: {
        mutiSelectName: 'worklog',
        mutiSelectUniqueKey: 'id',
        btnId: new Date().getTime() + parseInt(Math.random() * 1000),
        listName: 'list',
        tableColumns: [
          {
            label: '日志编号',
            prop: 'id'
          }, {
            label: '系统菜单',
            prop: 'module'
          }, {
            label: '操作类型',
            prop: 'action'
          }, {
            label: '操作账号',
            prop: 'operatorName'
          }, {
            label: '所属组织',
            prop: 'belongOrg'
          }, {
            label: '主机IP',
            prop: 'ip',
          }, {
            label: '操作状态',
            prop: 'operStatus',
            addHtml: 'status'
          }, {
            label: '创建时间',
            prop: 'createdDate'
          }
        ]
      },
      getListApi: getWorkLogList,
      // 弹窗
      worklogDialogTitle: '新增字典',
      worklogVisible: false,
      worklogForm: {},
      worklogData: [
        { label: '字典名称:', prop: 'dictName', type: 'input' },
        { label: '字典类型', prop: 'dictType', type: 'input' },
        { label: '状态', prop: 'enableStatus', type: 'switch' },
        { label: '备注', prop: 'remark', type: 'input', inputText: 'textarea' }
      ],
      worklogRules: {}
    }
  },
  methods: {
    refresh() {
      this.searchForm = {}
      this.searchDataForm = {}
    },
    // 按钮事件
    btnClick(pType, scope) {
      console.log(pType, scope)
      switch (pType) {
        case 'edit':
          this.handleClose(scope)
          break
        case 'delete':
          this.deleteEvent(scope.id)
          break
        case 'list':
          console.log('list')
          break
      }
    },
    beforeSearchFn() {
      return new Promise((resolve, reject) => {
        console.log(this.searchForm)
        if (this.searchForm.daterange) this.searchDataForm.sDate = this.searchForm.daterange[0]
        if (this.searchForm.daterange) this.searchDataForm.eDate = this.searchForm.daterange[1]

        resolve()
      })
    },
    // 确定
    handleConfirm() {
      console.log(this.$refs.worklogForm)
      this.$refs.worklogForm.$children[0].validate((valid) => {
        if (valid) {
          this.handleClose()
        } else {
          console.log('error')
        }
      })
    },
    // 取消
    handleClose(row) {
      console.log(row)
      if (!this.worklogVisible && this.$refs.worklogForm) {
        this.$refs.worklogForm.$children[0].resetFields()
      }
      this.worklogVisible = !this.worklogVisible
    },
    // 删除触发事件
    deleteEvent(id) {
      const that = this
      const tipData = {
        that: that,
        tipText: '是否删除当前记录',
        tipTitle: '提示',
        type: 'error',
        callBack: () => {
          this.$message({
            type: 'success',
            message: '删除成功!'
          })
        }
      }
      this.$Common.confirmDialog(tipData)
    },
    // 导出列表
    exportTable() {
      exportWorkLog().then(res => {

      })
    }
  }
}
</script>