Merge remote-tracking branch 'origin/hui_dev' into leng_dev

This commit is contained in:
lbw 2023-03-07 13:43:34 +08:00
commit 71b5086840

View File

@ -1,157 +1,178 @@
<template> <template>
<div class="layout-padding"> <div class="layout-padding">
<div class="layout-padding-auto layout-padding-view"> <div class="layout-padding-auto layout-padding-view">
<el-row v-show="showSearch" class="mb8"> <el-row class="mb8" v-show="showSearch">
<el-form :model="state.queryForm" ref="queryRef" :inline="true" @keyup.enter="getDataList"> <el-form :inline="true" :model="state.queryForm" @keyup.enter="getDataList" ref="queryRef">
<el-form-item :label="$t('sysdict.dictType')" prop="dictType"> <el-form-item :label="$t('sysdict.dictType')" prop="dictType">
<el-input :placeholder="$t('sysdict.inputDictTypeTip')" v-model="state.queryForm.dictType" style="max-width: 180px" /> <el-input :placeholder="$t('sysdict.inputDictTypeTip')" style="max-width: 180px"
</el-form-item> v-model="state.queryForm.dictType"/>
<el-form-item :label="$t('sysdict.systemFlag')" prop="systemFlag"> </el-form-item>
<el-select v-model="state.queryForm.systemFlag" clearable> <el-form-item :label="$t('sysdict.systemFlag')" prop="systemFlag">
<el-option v-for="(item, index) in dict_type" :label="item.label" :value="item.value" :key="index"></el-option> <el-select clearable v-model="state.queryForm.systemFlag">
</el-select> <el-option :key="index" :label="item.label" :value="item.value"
</el-form-item> v-for="(item, index) in dict_type"></el-option>
<el-form-item class="ml2"> </el-select>
<el-button icon="search" type="primary" @click="getDataList"> </el-form-item>
{{ $t('common.queryBtn') }} <el-form-item class="ml2">
</el-button> <el-button @click="getDataList" icon="search" type="primary">
<el-button icon="Refresh" @click="resetQuery">{{ $t('common.resetBtn') }}</el-button> {{ $t('common.queryBtn') }}
</el-form-item> </el-button>
</el-form> <el-button @click="resetQuery" icon="Refresh">{{ $t('common.resetBtn') }}</el-button>
</el-row> </el-form-item>
<el-row> </el-form>
<div class="mb8" style="width: 100%"> </el-row>
<el-button icon="folder-add" type="primary" class="ml10" @click="dicDialogRef.openDialog()"> <el-row>
{{ $t('common.addBtn') }} <div class="mb8" style="width: 100%">
</el-button> <el-button @click="dicDialogRef.openDialog()" class="ml10" icon="folder-add" type="primary">
<el-button :disabled="multiple" icon="Delete" type="primary" class="ml10" v-auth="'sys_dict_del'" @click="handleDelete(selectObjs)"> {{ $t('common.addBtn') }}
{{ $t('common.delBtn') }} </el-button>
</el-button> <el-button :disabled="multiple" @click="handleDelete(selectObjs)" class="ml10" icon="Delete" type="primary"
<el-button class="ml10" icon="refresh-left" type="primary" @click="handleRefreshCache()"> v-auth="'sys_dict_del'">
{{ $t('common.refreshCacheBtn') }} {{ $t('common.delBtn') }}
</el-button> </el-button>
<right-toolbar <el-button @click="handleRefreshCache()" class="ml10" icon="refresh-left" type="primary">
v-model:showSearch="showSearch" {{ $t('common.refreshCacheBtn') }}
class="ml10" </el-button>
style="float: right; margin-right: 20px" <el-button @click="exportExcel" class="ml10" icon="Download" type="primary">
@queryTable="getDataList" {{ $t('common.exportBtn') }}
></right-toolbar> </el-button>
</div> <right-toolbar
</el-row> @queryTable="getDataList"
<el-table :data="state.dataList" v-loading="state.loading" style="width: 100%" @selection-change="handleSelectionChange"> class="ml10"
<el-table-column align="center" type="selection" :selectable="handleSelectable" width="50"> </el-table-column> style="float: right; margin-right: 20px"
<el-table-column type="index" :label="$t('sysdict.index')" width="80" /> v-model:showSearch="showSearch"
<el-table-column :label="$t('sysdict.dictType')" show-overflow-tooltip> ></right-toolbar>
<template #default="scope"> </div>
<el-button text type="primary" @click="showDictITem(scope.row)">{{ scope.row.dictType }}</el-button> </el-row>
</template> <el-table :data="state.dataList" @selection-change="handleSelectionChange" style="width: 100%"
</el-table-column> v-loading="state.loading">
<el-table-column prop="description" :label="$t('sysdict.description')" show-overflow-tooltip sortable></el-table-column> <el-table-column :selectable="handleSelectable" align="center" type="selection"
<el-table-column prop="systemFlag" :label="$t('sysdict.systemFlag')" show-overflow-tooltip> width="50"></el-table-column>
<template #default="scope"> <el-table-column :label="$t('sysdict.index')" type="index" width="80"/>
<dict-tag :options="dict_type" :value="scope.row.systemFlag"></dict-tag> <el-table-column :label="$t('sysdict.dictType')" show-overflow-tooltip>
</template> <template #default="scope">
</el-table-column> <el-button @click="showDictITem(scope.row)" text type="primary">{{ scope.row.dictType }}
<el-table-column prop="remarks" :label="$t('sysdict.remarks')" show-overflow-tooltip></el-table-column> </el-button>
<el-table-column prop="createTime" :label="$t('sysdict.createTime')" show-overflow-tooltip sortable></el-table-column> </template>
<el-table-column :label="$t('common.action')" width="200"> </el-table-column>
<template #default="scope"> <el-table-column :label="$t('sysdict.description')" prop="description" show-overflow-tooltip
<el-button text type="primary" @click="showDictITem(scope.row)">{{ $t('sysdict.dictItem') }}</el-button> sortable></el-table-column>
<el-button text type="primary" @click="onOpenEditDic('edit', scope.row)">{{ $t('common.editBtn') }} </el-button> <el-table-column :label="$t('sysdict.systemFlag')" prop="systemFlag" show-overflow-tooltip>
<el-tooltip :content="$t('sysdict.deleteDisabledTip')" :disabled="scope.row.systemFlag === 1" placement="top"> <template #default="scope">
<dict-tag :options="dict_type" :value="scope.row.systemFlag"></dict-tag>
</template>
</el-table-column>
<el-table-column :label="$t('sysdict.remarks')" prop="remarks" show-overflow-tooltip></el-table-column>
<el-table-column :label="$t('sysdict.createTime')" prop="createTime" show-overflow-tooltip
sortable></el-table-column>
<el-table-column :label="$t('common.action')" width="200">
<template #default="scope">
<el-button @click="showDictITem(scope.row)" text type="primary">{{ $t('sysdict.dictItem') }}
</el-button>
<el-button @click="onOpenEditDic('edit', scope.row)" text type="primary">{{ $t('common.editBtn')
}}
</el-button>
<el-tooltip :content="$t('sysdict.deleteDisabledTip')" :disabled="scope.row.systemFlag === 1"
placement="top">
<span style="margin-left: 12px"> <span style="margin-left: 12px">
<el-button text type="primary" :disabled="scope.row.systemFlag !== 1" @click="handleDelete([scope.row.id])"> <el-button :disabled="scope.row.systemFlag !== 1" @click="handleDelete([scope.row.id])" text
type="primary">
{{ $t('common.delBtn') }} {{ $t('common.delBtn') }}
</el-button> </el-button>
</span> </span>
</el-tooltip> </el-tooltip>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" v-bind="state.pagination" /> <pagination @current-change="currentChangeHandle" @size-change="sizeChangeHandle"
</div> v-bind="state.pagination"/>
<DicDialog ref="dicDialogRef" @refresh="getDataList()" /> </div>
<dict-item-dialog ref="dictItemDialogRef"></dict-item-dialog> <DicDialog @refresh="getDataList()" ref="dicDialogRef"/>
</div> <dict-item-dialog ref="dictItemDialogRef"></dict-item-dialog>
</div>
</template> </template>
<script setup lang="ts" name="systemDic"> <script lang="ts" name="systemDic" setup>
import { BasicTableProps, useTable } from '/@/hooks/table'; import {BasicTableProps, useTable} from '/@/hooks/table';
import { delObj, fetchList, refreshCache } from '/@/api/admin/dict'; import {delObj, fetchList, refreshCache} from '/@/api/admin/dict';
import { useMessage, useMessageBox } from '/@/hooks/message'; import {useMessage, useMessageBox} from '/@/hooks/message';
import { useDict } from '/@/hooks/dict'; import {useDict} from '/@/hooks/dict';
import { useI18n } from 'vue-i18n'; import {useI18n} from 'vue-i18n';
import {downBlobFile} from "/@/utils/other";
const { dict_type } = useDict('dict_type'); const {dict_type} = useDict('dict_type');
// //
const DicDialog = defineAsyncComponent(() => import('./form.vue')); const DicDialog = defineAsyncComponent(() => import('./form.vue'));
const DictItemDialog = defineAsyncComponent(() => import('./dictItem/index.vue')); const DictItemDialog = defineAsyncComponent(() => import('./dictItem/index.vue'));
const { t } = useI18n(); const {t} = useI18n();
// //
const dicDialogRef = ref(); const dicDialogRef = ref();
const dictItemDialogRef = ref(); const dictItemDialogRef = ref();
const queryRef = ref(); const queryRef = ref();
const showSearch = ref(true); const showSearch = ref(true);
// //
const selectObjs = ref([]) as any; const selectObjs = ref([]) as any;
const multiple = ref(true); const multiple = ref(true);
const state: BasicTableProps = reactive<BasicTableProps>({ const state: BasicTableProps = reactive<BasicTableProps>({
queryForm: {}, queryForm: {},
pageList: fetchList, pageList: fetchList,
descs: ['create_time'], descs: ['create_time'],
}); });
const { getDataList, currentChangeHandle, sizeChangeHandle } = useTable(state); const {getDataList, currentChangeHandle, sizeChangeHandle} = useTable(state);
// //
const onOpenEditDic = (type: string, row: any) => { const onOpenEditDic = (type: string, row: any) => {
dicDialogRef.value.openDialog(type, row); dicDialogRef.value.openDialog(type, row);
}; };
const showDictITem = (row: any) => { const showDictITem = (row: any) => {
dictItemDialogRef.value.open(row); dictItemDialogRef.value.open(row);
}; };
// //
const resetQuery = () => { const resetQuery = () => {
queryRef.value.resetFields(); queryRef.value.resetFields();
state.queryForm = {}; state.queryForm = {};
getDataList(); getDataList();
}; };
const exportExcel = () => {
downBlobFile("/admin/dict/export", state.queryForm, "dict.xlsx")
}
// //
const handleSelectable = (row: any) => { const handleSelectable = (row: any) => {
// //
return row.systemFlag !== '1'; return row.systemFlag !== '1';
}; };
// //
const handleSelectionChange = (objs: any) => { const handleSelectionChange = (objs: any) => {
objs.forEach((val: any) => { objs.forEach((val: any) => {
selectObjs.value.push(val.id); selectObjs.value.push(val.id);
}); });
multiple.value = !objs.length; multiple.value = !objs.length;
}; };
// //
const handleRefreshCache = () => { const handleRefreshCache = () => {
refreshCache().then(() => { refreshCache().then(() => {
useMessage().success('同步成功'); useMessage().success('同步成功');
}); });
}; };
// //
const handleDelete = (ids: string[]) => { const handleDelete = (ids: string[]) => {
useMessageBox() useMessageBox()
.confirm(t('common.delConfirmText')) .confirm(t('common.delConfirmText'))
.then(() => { .then(() => {
delObj(ids) delObj(ids)
.then(() => { .then(() => {
getDataList(); getDataList();
useMessage().success(t('common.delSuccessText')); useMessage().success(t('common.delSuccessText'));
}) })
.catch((err: any) => { .catch((err: any) => {
useMessage().error(err.msg); useMessage().error(err.msg);
}); });
}); });
}; };
</script> </script>