|
@@ -1,13 +1,21 @@
|
|
|
<script setup lang="ts">
|
|
|
import type { PropsParams, TablePaginationSetting, QueryInfo } from '@/types/table'
|
|
|
-import { FilterType } from '@/types/table'
|
|
|
+import { FilterType, FieldSpecialEffectType, ColorType } from '@/types/table'
|
|
|
|
|
|
import { computed, onMounted, reactive, ref, watch } from 'vue'
|
|
|
import { useTable } from '@/hooks/useTable'
|
|
|
|
|
|
+import FilterPopover from './toolsBtn/FilterPopover.vue'
|
|
|
+import RegreshBtn from './toolsBtn/RegreshBtn.vue'
|
|
|
+
|
|
|
+import type { FormInstance } from 'element-plus'
|
|
|
+
|
|
|
// 表格工具图标大小
|
|
|
const toolsIconSize = ref(25)
|
|
|
|
|
|
+// 查询表单
|
|
|
+const queryFormRef = ref<FormInstance>()
|
|
|
+
|
|
|
// 传过来的配置
|
|
|
const props = defineProps<PropsParams>()
|
|
|
|
|
@@ -96,6 +104,12 @@ const queryTableData = () => {
|
|
|
getData()
|
|
|
}
|
|
|
|
|
|
+// 重置查询的条件
|
|
|
+const resetQueryForm = (formEl: FormInstance | undefined) => {
|
|
|
+ if (!formEl) return
|
|
|
+ formEl?.resetFields()
|
|
|
+}
|
|
|
+
|
|
|
// 没有开启分页查询就关闭掉这个监听
|
|
|
if (!props.openPageQuery) changePageLimit()
|
|
|
|
|
@@ -107,7 +121,6 @@ defineExpose({
|
|
|
|
|
|
onMounted(() => {
|
|
|
getData()
|
|
|
- console.log(selectFieldsList)
|
|
|
})
|
|
|
</script>
|
|
|
|
|
@@ -119,8 +132,13 @@ onMounted(() => {
|
|
|
<span>查询条件</span>
|
|
|
</div>
|
|
|
<div class="filterBody">
|
|
|
- <!-- <slot name="filterBody"></slot> -->
|
|
|
- <el-form :inline="true" :model="queryFormData" class="queryForm" :label-position="'left'">
|
|
|
+ <el-form
|
|
|
+ :inline="true"
|
|
|
+ ref="queryFormRef"
|
|
|
+ :model="queryFormData"
|
|
|
+ class="queryForm"
|
|
|
+ :label-position="'left'"
|
|
|
+ >
|
|
|
<!-- 所有的input查询框 -->
|
|
|
<el-form-item :label="item.label" v-for="item in inputFieldsList" class="filterItem">
|
|
|
<el-input
|
|
@@ -156,7 +174,7 @@ onMounted(() => {
|
|
|
<el-button class="queryBtn" color="#165dff" @click="queryTableData">
|
|
|
<el-icon><Search /></el-icon>查询
|
|
|
</el-button>
|
|
|
- <el-button class="refreshBtn" color="#f2f3f5">
|
|
|
+ <el-button class="refreshBtn" color="#f2f3f5" @click="resetQueryForm(queryFormRef)">
|
|
|
<el-icon><RefreshRight /></el-icon>重置
|
|
|
</el-button>
|
|
|
</div>
|
|
@@ -175,8 +193,15 @@ onMounted(() => {
|
|
|
<el-button color="#f0f1f3" size="default" class="rightToolsItem">
|
|
|
<el-icon><Download /></el-icon>下载
|
|
|
</el-button>
|
|
|
- <el-icon :size="toolsIconSize" class="rightToolsItem"><RefreshRight /></el-icon>
|
|
|
- <el-icon :size="toolsIconSize" class="rightToolsItem"><Setting /></el-icon>
|
|
|
+
|
|
|
+ <RegreshBtn @refresh-table="getData" :icon-size="toolsIconSize"></RegreshBtn>
|
|
|
+ <!-- <el-icon :size="toolsIconSize" class="rightToolsItem"><RefreshRight /></el-icon> -->
|
|
|
+
|
|
|
+ <FilterPopover
|
|
|
+ :table-fields-info="tableFieldsInfo"
|
|
|
+ :icon-size="toolsIconSize"
|
|
|
+ ></FilterPopover>
|
|
|
+ <!-- <el-icon :size="toolsIconSize" class="rightToolsItem"><Setting /></el-icon> -->
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
@@ -187,15 +212,65 @@ onMounted(() => {
|
|
|
class="tableBody"
|
|
|
>
|
|
|
<el-table-column align="center" label="#" type="index" :index="1" />
|
|
|
- <el-table-column
|
|
|
- v-for="item in tableFieldsInfo"
|
|
|
- :prop="item.name"
|
|
|
- :label="item.cnName"
|
|
|
- width="auto"
|
|
|
- align="center"
|
|
|
- show-overflow-tooltip
|
|
|
- >
|
|
|
- </el-table-column>
|
|
|
+ <template v-for="item in tableFieldsInfo">
|
|
|
+ <el-table-column
|
|
|
+ :prop="item.name"
|
|
|
+ :label="item.cnName"
|
|
|
+ width="auto"
|
|
|
+ align="center"
|
|
|
+ show-overflow-tooltip
|
|
|
+ v-if="item.isShow"
|
|
|
+ >
|
|
|
+ <template v-slot="scope">
|
|
|
+ <!-- tag类 -->
|
|
|
+ <el-tag
|
|
|
+ v-if="item.specialEffect?.type === FieldSpecialEffectType.TAG"
|
|
|
+ :type="scope.row[item.name] ? 'danger' : 'success'"
|
|
|
+ >
|
|
|
+ {{
|
|
|
+ scope.row[item.name]
|
|
|
+ ? item.specialEffect.othnerInfo[0]
|
|
|
+ : item.specialEffect.othnerInfo[1]
|
|
|
+ }}
|
|
|
+ </el-tag>
|
|
|
+
|
|
|
+ <!-- 头像类 -->
|
|
|
+ <el-image
|
|
|
+ v-else-if="item.specialEffect?.type === FieldSpecialEffectType.IMG"
|
|
|
+ :preview-teleported="true"
|
|
|
+ :src="scope.row[item.name]"
|
|
|
+ :preview-src-list="[scope.row[item.name]]"
|
|
|
+ style="width: 35px; height: 35px"
|
|
|
+ :fit="'fill'"
|
|
|
+ :hide-on-click-modal="true"
|
|
|
+ >
|
|
|
+ <template #error>
|
|
|
+ <!-- -->
|
|
|
+ <img style="width: 35px; height: 35px" src="../assets/default/defaultHead.png" />
|
|
|
+ </template>
|
|
|
+ </el-image>
|
|
|
+
|
|
|
+ <!-- 文字类 -->
|
|
|
+ <el-text
|
|
|
+ v-else-if="item.specialEffect?.type === FieldSpecialEffectType.TEXT"
|
|
|
+ :type="scope.row[item.name] ? 'danger' : 'success'"
|
|
|
+ >
|
|
|
+ {{ scope.row[item.name] }}
|
|
|
+ </el-text>
|
|
|
+
|
|
|
+ <!-- 翻译类 -->
|
|
|
+ <el-text v-else-if="item.specialEffect?.type === FieldSpecialEffectType.TRANSLATE">
|
|
|
+ {{ item.specialEffect.othnerInfo[scope.row[item.name]] }}
|
|
|
+ </el-text>
|
|
|
+
|
|
|
+ <el-text v-else>
|
|
|
+ <!-- 其他列按默认方式显示 -->
|
|
|
+ {{ scope.row[item.name] }}
|
|
|
+ </el-text>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </template>
|
|
|
+
|
|
|
<slot name="tableOperation"></slot>
|
|
|
</el-table>
|
|
|
<div class="userTablePaginationBox">
|