Blame view

src/views/system/dictionaries/dictionaries.vue 3.58 KB
任超 committed
1 2 3 4
<template>
  <div class="from-clues">
    <!-- 表单部分 -->
    <div class="from-clues-header">
任超 committed
5
      <el-form @submit.native.prevent :model="ruleForm">
任超 committed
6
        <el-row :gutter="20">
任超 committed
7 8
          <el-col :span="6">
            <el-form-item label="字典类型编码">
任超 committed
9
              <el-input v-model="ruleForm.dcode" @clear="queryClick" clearable placeholder="字典类型编码"></el-input>
任超 committed
10 11 12 13
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="字典类型名称">
任超 committed
14
              <el-input v-model="ruleForm.dname" @clear="queryClick" clearable placeholder="字典类型名称"></el-input>
任超 committed
15 16
            </el-form-item>
          </el-col>
17
          <el-col :span="12" class="btnColRight">
任超 committed
18
            <el-form-item>
任超 committed
19
              <el-button type="primary" native-type="submit" icon="el-icon-search" @click="queryClick">查询</el-button>
任超 committed
20
              <el-button icon="el-icon-refresh" @click="handleRefresh">刷新缓存</el-button>
任超 committed
21 22 23 24 25 26 27
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </div>
    <!-- 表格 -->
    <div class="from-clues-content">
任超 committed
28 29 30
      <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">
任超 committed
31 32
      </lb-table>
    </div>
任超 committed
33
    <editDialog v-model="isDialog" :details="details" />
任超 committed
34 35 36 37
  </div>
</template>
<script>
import table from "@/utils/mixin/table"
任超 committed
38
import { getQlxxDictList, getChildDictList, refreshDictCache } from "@/api/user.js"
任超 committed
39 40 41 42 43 44 45 46 47 48
import { datas, sendThis } from "./dictionaries"
import editDialog from "./components/editDialog.vue"
export default {
  name: "djbcx",
  components: {
    editDialog
  },
  mixins: [table],
  mounted () {
    sendThis(this);
任超 committed
49
    this.queryClick()
任超 committed
50 51 52 53
  },
  data () {
    return {
      isDialog: false,
任超 committed
54 55
      details: {
        dataList: [],
任超 committed
56 57
        isenable: 1,
        rowData: {}
任超 committed
58
      },
任超 committed
59
      ruleForm: {
任超 committed
60 61
        dcode: '',
        dname: ''
任超 committed
62 63 64 65
      },
      tableData: {
        total: 0,
        columns: datas.columns(),
任超 committed
66
        data: []
任超 committed
67 68 69 70 71
      }
    }
  },
  methods: {
    // 初始化数据
任超 committed
72 73
    queryClick () {
      this.$startLoading();
任超 committed
74
      getQlxxDictList({ ...this.ruleForm, ...this.pageData }).then(res => {
任超 committed
75
        this.$endLoading();
任超 committed
76
        let { records, total } = res.result
任超 committed
77 78
        this.tableData.data = records ? records : []
        this.tableData.total = total ? total : 0
任超 committed
79
      })
任超 committed
80
    },
蔡俊立 committed
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
    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: '取消刷新'
        });
任超 committed
105
      });
任超 committed
106
    },
任超 committed
107
    editClick (row, val) {
任超 committed
108
      this.details.rowData = row
任超 committed
109 110 111 112
      this.details.isenable = val
      getChildDictList(row.bsmDict).then(res => {
        this.isDialog = true
        let { result } = res
任超 committed
113
        this.details.dataList = result ? result : []
任超 committed
114
      })
任超 committed
115
    }
任超 committed
116
  }
任超 committed
117 118 119 120 121
};
</script>
<style scoped lang="scss">
@import "~@/styles/public.scss";
</style>