|
@@ -0,0 +1,65 @@
|
|
|
+<template>
|
|
|
+ <div id="es-dict">
|
|
|
+ <el-row justify="space-between" style="margin-bottom:10px">
|
|
|
+ <el-col :span="6" style="text-align: left">
|
|
|
+ <el-button type="success" @click="toSave">保存</el-button>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="6" style="text-align: right">
|
|
|
+ <el-button type="primary" @click="toAdd">添加字典</el-button>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ <el-row>
|
|
|
+ <el-col :span="24">
|
|
|
+ <el-table :data="data" height="70vh" border stripe>
|
|
|
+ <el-table-column align="center" label="字典项">
|
|
|
+ <template #default="{ row }">{{ row }}</template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column align="center" label="操作" width="150px">
|
|
|
+ <template #default="{ $index }">
|
|
|
+ <el-button text type="danger" @click="toDelete($index)">删除</el-button>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script setup>
|
|
|
+const $checkRes = inject('$checkRes')
|
|
|
+import { get, cloneDeep } from 'lodash-es'
|
|
|
+import { EsDictStore } from '@/store/api/esDict'
|
|
|
+const store = EsDictStore()
|
|
|
+const data = ref([])
|
|
|
+const search = async () => {
|
|
|
+ const result = await store.getDict()
|
|
|
+ if ($checkRes(result)) {
|
|
|
+ data.value = get(result, 'data', [])
|
|
|
+ }
|
|
|
+}
|
|
|
+const toAdd = () =>{
|
|
|
+ ElMessageBox.prompt('请填写字典项', '添加字典项', {
|
|
|
+ confirmButtonText: '确认',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ })
|
|
|
+ .then(({ value }) => {
|
|
|
+ data.value.push(value)
|
|
|
+ })
|
|
|
+ .catch(() => {
|
|
|
+ })
|
|
|
+}
|
|
|
+const toDelete = (index) => {
|
|
|
+ data.value.splice(index, 1)
|
|
|
+}
|
|
|
+const toSave = async () => {
|
|
|
+ const updateData = cloneDeep(data.value)
|
|
|
+ const result = store.updateDict(updateData)
|
|
|
+ if ($checkRes(result, true, result.errmsg)) {
|
|
|
+ search()
|
|
|
+ }
|
|
|
+}
|
|
|
+onMounted(() => {
|
|
|
+ search()
|
|
|
+})
|
|
|
+</script>
|
|
|
+<style scoped></style>
|