dictionaries.vue 4 KB
<!--
 * @Description:
 * @Autor: renchao
 * @LastEditTime: 2023-07-24 14:09:53
-->
<template>
  <div class="from-clues">
    <!-- 表单部分 -->
    <div class="from-clues-header">
      <el-form @submit.native.prevent :model="ruleForm">
        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item label="字典类型编码">
              <el-input v-model="ruleForm.dcode" clearable placeholder="字典类型编码"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="字典类型名称">
              <el-input v-model="ruleForm.dname" clearable placeholder="字典类型名称"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12" class="btnColRight">
            <el-form-item>
              <el-button type="primary" native-type="submit" icon="el-icon-search" @click="handleSearch">查询</el-button>
              <el-button icon="el-icon-refresh" @click="handleRefresh">刷新缓存</el-button>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </div>
    <!-- 表格 -->
    <div class="from-clues-content">
      <lb-table :page-size="pageData.pageSize" class="loadingtext" :current-page.sync="pageData.currentPage"
        :total="tableData.total" @size-change="handleSizeChange" @p-current-change="handleCurrentChange"
        :column="tableData.columns" :data="tableData.data">
      </lb-table>
    </div>
  </div>
</template>
<script>
  import table from "@/utils/mixin/table"
  import { getQlxxDictList, getChildDictList, refreshDictCache } from "@/api/dict.js"
  import { datas, sendThis } from "./dictionaries"
  import editDialog from "./components/editDialog.vue"
  export default {
    name: "dictionaries",
    components: {
      editDialog
    },
    mixins: [table],
    mounted () {
      sendThis(this);
    },
    data () {
      return {
        details: {
          bsmDict: '',
          isenable: 1,
          rowData: {}
        },
        ruleForm: {
          dcode: '',
          dname: ''
        },
        tableData: {
          total: 0,
          columns: datas.columns(),
          data: []
        }
      }
    },
    activated () {
      this.queryClick()
    },
    methods: {
      // 初始化数据
      /**
       * @description: 初始化数据
       * @author: renchao
       */
      queryClick () {
        this.$startLoading();
        getQlxxDictList({ ...this.ruleForm, ...this.pageData }).then(res => {
          this.$endLoading();
          let { records, total } = res.result
          this.tableData.data = records ? records : []
          this.tableData.total = total ? total : 0
        })
      },
      /**
       * @description: handleRefresh
       * @author: renchao
       */
      handleRefresh () {
        this.$confirm('是否确认刷新', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.$startLoading()
          refreshDictCache().then(res => {
            if (res.code == 200) {
              let refech = this.$store.dispatch('dict/generateDic')
              this.$endLoading()
              refech && this.$message({
                message: '刷新成功',
                type: 'success'
              });
            } else {
              this.$message.error(res.message)
            }
          })
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '取消刷新'
          });
        });
      },
      // 修改
      /**
       * @description: 修改
       * @param {*} row
       * @param {*} val
       * @author: renchao
       */
      editClick (row, val) {
        this.details.rowData = row
        this.details.isenable = val
        this.details.bsmDict = row.bsmDict
        this.$popupDialog("字典信息", "system/dictionaries/components/editDialog", this.details)
      }
    }
  }
</script>
<style scoped lang="scss">
  @import "~@/styles/public.scss";
</style>