index.vue 3.68 KB
<template>
  <div class="dictionary-config from-clues">
    <div class="from-clues-header">
      <el-form ref="form" :model="form" label-width="125px">
        <el-row>
          <el-col :span="5">
            <el-form-item label="字典类型编码">
              <el-input v-model="form.DCODE" placeholder="字典类型编码"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="5">
            <el-form-item label="字典类型名称">
              <el-input v-model="form.DNAME" placeholder="字典类型名称"></el-input>
            </el-form-item>
          </el-col>

          <el-col :span="14" class="btnColRight">
            <el-button @click="handleUpdateDic">刷新字典缓存</el-button>
            <el-button type="primary" @click="handleSubmit">查询结果</el-button>
          </el-col>
        </el-row>
      </el-form>
    </div>
    <div class="from-clues-content">
      <lb-table :page-size="pageData.size" :current-page.sync="pageData.current" :total="pageData.total"
        @size-change="handleSizeChange" @p-current-change="handleCurrentChange" :column="tableData.columns"
        :data="tableData.data">
      </lb-table>
      <message-tips ref="msg" :message="message" />
    </div>
    <edit-dictionary ref="dictionary" :dictList="dictList" :dicData="dicRowData"></edit-dictionary>
  </div>
</template>

<script>
// 字典
import data from "./data"
import dictionaries from '@/api/dictionaries'
import tableMixin from '@/mixins/tableMixin.js'
import editDictionary from '../components/editDictionary.vue'
export default {
  name: "dictionary-config",
  mixins: [tableMixin],
  components: {
    editDictionary
  },
  data () {
    return {
      message: '',
      form: {
        DCODE: '',
        DNAME: '',
        currentPage: 1
      },
      preContent: '',
      tableData: {
        columns: data.columns().concat([
          {
            label: "操作",
            render: (h, scope) => {
              return (
                <div>
                  <el-button
                    type="text"
                    size="mini"
                    icon="el-icon-edit"
                    onClick={() => { this.handleEdit(scope.row) }}
                  >
                    编辑
                  </el-button>
                </div>
              );
            },
          }
        ]),
        data: []
      },
      pageData: {
        total: 0,
        pageSize: 15,
        current: 1,
      },
      dictList: [],
      dicRowData: null
    }
  },
  methods: {
    async featchData () {
      try {
        this.form = Object.assign(this.form, this.formData)
        let { result: { list, total, pages: pageSize, pageNum: current }
        } = await dictionaries.getSysDictParent(this.form)
        this.tableData.data = list
        this.pageData = {
          pageSize,
          current,
          total
        }
      } catch (error) {
        this.message = error
        this.$refs.msg.messageShow()
      }
    },
    async handleEdit (row) {
      this.dicRowData = row
      try {
        let { result: res } = await dictionaries.getSysDictByTypeId(row.TYPEID)
        this.dictList = res
        this.$refs.dictionary.isShow()
      } catch (error) {
        this.$alert(error, '提示', {
          confirmButtonText: '确定',
          type: 'error'
        })
      }
    },
    // 更新字典
    handleUpdateDic () {
      this.$store.dispatch('dictionaries/generateDic').then((res) => {
        if (res) {
          this.$message({
            message: '刷新成功!',
            type: 'success'
          });
        }
      })
    }
  }
}
</script>
<style scoped lang="scss">
@import "~@/styles/public.scss";
@import "./index.scss";
</style>