|
@@ -2,21 +2,20 @@
|
|
|
* @Author: fxs bjnsfxs@163.com
|
|
|
* @Date: 2024-08-20 18:16:18
|
|
|
* @LastEditors: fxs bjnsfxs@163.com
|
|
|
- * @LastEditTime: 2024-11-06 17:55:04
|
|
|
- * @FilePath: \Quantity-Creation-Management-Systemc:\Users\NINGMEI\Desktop\Game-Backstage-Management-System\src\components\Table.vue
|
|
|
+ * @LastEditTime: 2024-11-14
|
|
|
+ * @FilePath: \Game-Backstage-Management-System\src\components\Table.vue
|
|
|
* @Description:
|
|
|
*
|
|
|
-->
|
|
|
<script setup lang="ts">
|
|
|
-import type { PropsParams, TablePaginationSetting } from '@/types/table'
|
|
|
+import type { PropsParams, TableFieldInfo, TablePaginationSetting } from '@/types/table'
|
|
|
import type { ReqConfig } from '@/types/dataAnalysis'
|
|
|
-import type { TableFieldInfo } from '@/types/table'
|
|
|
import type { FormInstance } from 'element-plus'
|
|
|
+import { FilterType } from '@/types/table'
|
|
|
+import { FieldSpecialEffectType } from '@/types/tableText'
|
|
|
|
|
|
-import { FilterType, FieldSpecialEffectType } from '@/types/table'
|
|
|
import { initLoadResouce } from '@/utils/resource'
|
|
|
-import { fuzzySearch } from '@/utils/common'
|
|
|
-import { throttleFunc } from '@/utils/common'
|
|
|
+import { fuzzySearch, throttleFunc } from '@/utils/common'
|
|
|
import { computed, onMounted, reactive, ref, toRaw, watch } from 'vue'
|
|
|
import { useTable } from '@/hooks/useTable'
|
|
|
import { useRequest } from '@/hooks/useRequest'
|
|
@@ -24,6 +23,7 @@ import { useRequest } from '@/hooks/useRequest'
|
|
|
import FilterPopover from './toolsBtn/FilterPopover.vue'
|
|
|
import RegreshBtn from './toolsBtn/RegreshBtn.vue'
|
|
|
import axiosInstance from '@/utils/axios/axiosInstance'
|
|
|
+import TableFieldText from './table/TableFieldText.vue'
|
|
|
|
|
|
const { analysisResCode } = useRequest()
|
|
|
|
|
@@ -127,21 +127,26 @@ const computedRowIndex = (index: number) => {
|
|
|
return (paginationConfig.currentPage - 1) * paginationConfig.limit + index + 1
|
|
|
}
|
|
|
|
|
|
-// 改变页码
|
|
|
+/**
|
|
|
+ * @description: 改变页码
|
|
|
+ * @param val
|
|
|
+ */
|
|
|
const handleCurrentChange = (val: number) => {
|
|
|
paginationConfig.currentPage = val
|
|
|
}
|
|
|
|
|
|
-// 改变每页大小
|
|
|
+/**
|
|
|
+ * @description 改变每页大小
|
|
|
+ * @param val
|
|
|
+ */
|
|
|
const handleSizeChange = (val: number) => {
|
|
|
paginationConfig.limit = val
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @description: 加载表格数据
|
|
|
- * @return {*}
|
|
|
+ * @description 加载表格数据
|
|
|
*/
|
|
|
-const loadTableData = async () => {
|
|
|
+const loadTableData = async (): Promise<boolean> => {
|
|
|
return new Promise(async (resolve, reject) => {
|
|
|
loading.value = true
|
|
|
if (props.dataList) {
|
|
@@ -181,7 +186,7 @@ const loadTableData = async () => {
|
|
|
|
|
|
/**
|
|
|
* @description: 获取数据,如果没有直接传入数据,则去请求数据,有则直接用
|
|
|
- * @return {*}
|
|
|
+ * @return Promise
|
|
|
*/
|
|
|
const getData = () => {
|
|
|
return new Promise(async (resolve, reject) => {
|
|
@@ -231,14 +236,13 @@ const resetTableData = () => {
|
|
|
|
|
|
/**
|
|
|
* @description: 按条件查询,如果开启了分页查询,那么会直接重新查询数据,否则,会根据现有数据进行查询
|
|
|
- * @return {*}
|
|
|
*/
|
|
|
const queryTableData = () => {
|
|
|
if (props.openRemoteinquiry && props.requestConfig) {
|
|
|
reqconfig.otherOptions = { ...props.requestConfig.otherOptions, ...queryFormData }
|
|
|
getData()
|
|
|
} else {
|
|
|
- let filteredTable = []
|
|
|
+ let filteredTable: any[]
|
|
|
// 过滤出来所有符合formData数据的条件
|
|
|
filteredTable = backupTableData.filter((item) => {
|
|
|
let state = true
|
|
@@ -261,22 +265,20 @@ const throttleQueryTableData = throttleFunc(queryTableData, throttleTime)
|
|
|
|
|
|
/**
|
|
|
* @description: 重置整个查询表单,重置后,再请求一次全部表格
|
|
|
- * @param {*} formEl 表单对象
|
|
|
- * @return {*}
|
|
|
+ * @param needQuery 是否需要重新查询,默认为true,如果为false,则不重新查询
|
|
|
*/
|
|
|
-const resetQueryForm = (neewQuery: boolean = true) => {
|
|
|
+const resetQueryForm = (needQuery: boolean = true) => {
|
|
|
// 使用函数返回保存的备份信息,这样可以正确的给queryformdata赋值
|
|
|
// JSON.stringify()第二个参数可以用来处理undefined的情况,第一个参数设置为_可以避免ts检查
|
|
|
function resetFormData() {
|
|
|
- let data = JSON.parse(
|
|
|
+ return JSON.parse(
|
|
|
JSON.stringify(backupQueryFormData, (_, v) => (typeof v === 'undefined' ? '' : v))
|
|
|
)
|
|
|
- return data
|
|
|
}
|
|
|
Object.assign(queryFormData, resetFormData())
|
|
|
reqconfig.otherOptions = backupReqOtherOptions // 要把请求的参数也重置一次,不然切换平台等操作,会带着原来的查询参数请求
|
|
|
|
|
|
- if (neewQuery) queryTableData()
|
|
|
+ if (needQuery) queryTableData()
|
|
|
}
|
|
|
|
|
|
// 把重置方法包装一下,节流
|
|
@@ -472,14 +474,13 @@ const tableSortChange = (data: { column: any; prop: string; order: any }) => {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @description: 删除行
|
|
|
- * @param {*} url 请求地址
|
|
|
- * @param {*} row 行数据
|
|
|
- * @return {*}
|
|
|
+ * 删除行
|
|
|
+ * @param url 请求地址
|
|
|
+ * @param fieldsInfo 行数据
|
|
|
*/
|
|
|
-const deleteRow = (url: string, filedsInfo: any) => {
|
|
|
+const deleteRow = (url: string, fieldsInfo: any) => {
|
|
|
axiosInstance
|
|
|
- .post(url, { ...filedsInfo })
|
|
|
+ .post(url, { ...fieldsInfo })
|
|
|
.then((data) => {
|
|
|
analysisResCode(data).then(() => {
|
|
|
resetQueryForm(false)
|
|
@@ -565,10 +566,14 @@ onMounted(() => {
|
|
|
<el-form-item
|
|
|
@keyup.enter.native="throttleQueryTableData"
|
|
|
:label="item.label"
|
|
|
- v-if="item.valueType === 'string' || item.valueType === 'float'"
|
|
|
+ v-if="item.valueType !== 'int'"
|
|
|
class="filterItem"
|
|
|
>
|
|
|
- <el-input clearable v-model="queryFormData[item.name]" />
|
|
|
+ <el-input
|
|
|
+ :placeholder="item.placeholder"
|
|
|
+ clearable
|
|
|
+ v-model="queryFormData[item.name]"
|
|
|
+ />
|
|
|
</el-form-item>
|
|
|
<el-form-item
|
|
|
@keyup.enter.native="throttleQueryTableData"
|
|
@@ -578,6 +583,7 @@ onMounted(() => {
|
|
|
>
|
|
|
<el-input
|
|
|
clearable
|
|
|
+ :placeholder="item.placeholder"
|
|
|
v-model="queryFormData[item.name]"
|
|
|
@input="numberInput(item.name)"
|
|
|
/>
|
|
@@ -687,25 +693,12 @@ onMounted(() => {
|
|
|
align="center"
|
|
|
show-overflow-tooltip
|
|
|
v-if="item.isShow"
|
|
|
- :sortable="item.needSort === true ? 'custorm' : false"
|
|
|
+ :sortable="item.needSort ? 'custorm' : false"
|
|
|
>
|
|
|
<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.text[0]
|
|
|
- : item.specialEffect.othnerInfo.text[1]
|
|
|
- }}
|
|
|
- </el-tag>
|
|
|
- <!-- :src="loadResource(scope.row[item.name])" -->
|
|
|
- <!-- :src="scope.row[item.name]" -->
|
|
|
<!-- 头像类 -->
|
|
|
<el-image
|
|
|
- v-else-if="item.specialEffect?.type === FieldSpecialEffectType.IMG"
|
|
|
+ v-if="item.specialEffect?.type === FieldSpecialEffectType.IMG"
|
|
|
:preview-teleported="true"
|
|
|
:src="scope.row[item.name]"
|
|
|
:preview-src-list="[scope.row[item.name]]"
|
|
@@ -715,52 +708,20 @@ onMounted(() => {
|
|
|
>
|
|
|
<template #error>
|
|
|
<!-- -->
|
|
|
- <img style="width: 35px; height: 35px" :src="blobUrlInfo.defaultHead" />
|
|
|
+ <img
|
|
|
+ alt="头像"
|
|
|
+ style="width: 35px; height: 35px"
|
|
|
+ :src="blobUrlInfo.defaultHead"
|
|
|
+ />
|
|
|
</template>
|
|
|
</el-image>
|
|
|
|
|
|
<!-- 文字类 -->
|
|
|
- <el-text
|
|
|
- v-else-if="item.specialEffect?.type === FieldSpecialEffectType.TEXT"
|
|
|
- :type="
|
|
|
- scope.row[item.name]
|
|
|
- ? item.specialEffect.othnerInfo.color[0]
|
|
|
- : item.specialEffect.othnerInfo.color[1]
|
|
|
- "
|
|
|
- >
|
|
|
- {{ scope.row[item.name] }}
|
|
|
- </el-text>
|
|
|
-
|
|
|
- <!-- 翻译类 -->
|
|
|
- <el-text v-else-if="item.specialEffect?.type === FieldSpecialEffectType.TRANSLATE">
|
|
|
- <el-icon
|
|
|
- v-if="item.specialEffect.othnerInfo.icon"
|
|
|
- style="padding-right: 8px"
|
|
|
- :color="scope.row[item.name] ? '#409EFF' : '#F56C6C'"
|
|
|
- ><icon-tabler-point-filled></icon-tabler-point-filled
|
|
|
- ></el-icon>
|
|
|
- {{
|
|
|
- item.specialEffect.othnerInfo.translateText[scope.row[item.name]]
|
|
|
- ? item.specialEffect.othnerInfo.translateText[scope.row[item.name]]
|
|
|
- : '未知'
|
|
|
- }}
|
|
|
- </el-text>
|
|
|
-
|
|
|
- <!-- 状态类 -->
|
|
|
- <el-text v-else-if="item.specialEffect?.type === FieldSpecialEffectType.STATE">
|
|
|
- <span>
|
|
|
- <el-icon
|
|
|
- style="padding-right: 8px"
|
|
|
- :color="scope.row[item.name] ? '#409EFF' : '#F56C6C'"
|
|
|
- ><icon-tabler-point-filled></icon-tabler-point-filled
|
|
|
- ></el-icon>
|
|
|
- {{
|
|
|
- scope.row[item.name]
|
|
|
- ? item.specialEffect.othnerInfo.text[0]
|
|
|
- : item.specialEffect.othnerInfo.text[1]
|
|
|
- }}</span
|
|
|
- >
|
|
|
- </el-text>
|
|
|
+ <!-- :value="tableTextFieldVal(item, scope)" -->
|
|
|
+ <span v-else-if="item.specialEffect?.type === FieldSpecialEffectType.TEXT">
|
|
|
+ <TableFieldText :special-effect="item.specialEffect" :value="scope.row[item.name]">
|
|
|
+ </TableFieldText>
|
|
|
+ </span>
|
|
|
|
|
|
<!-- 开关类 -->
|
|
|
|
|
@@ -774,36 +735,6 @@ onMounted(() => {
|
|
|
>
|
|
|
</el-switch>
|
|
|
|
|
|
- <!-- 下拉菜单类 -->
|
|
|
- <el-dropdown
|
|
|
- trigger="click"
|
|
|
- v-else-if="item.specialEffect?.type === FieldSpecialEffectType.DROPDOWN"
|
|
|
- >
|
|
|
- <span
|
|
|
- class="el-dropdown-link"
|
|
|
- style="display: flex; align-items: center; cursor: pointer"
|
|
|
- >
|
|
|
- <el-icon
|
|
|
- style="padding-right: 8px"
|
|
|
- :color="scope.row[item.name] ? '#409EFF' : '#F56C6C'"
|
|
|
- ><icon-tabler-point-filled></icon-tabler-point-filled
|
|
|
- ></el-icon>
|
|
|
- {{
|
|
|
- scope.row[item.name]
|
|
|
- ? item.specialEffect.othnerInfo.text[0]
|
|
|
- : item.specialEffect.othnerInfo.text[1]
|
|
|
- }}
|
|
|
-
|
|
|
- <el-icon class="el-icon--right"><arrow-down /></el-icon>
|
|
|
- </span>
|
|
|
- <template #dropdown>
|
|
|
- <el-dropdown-menu>
|
|
|
- <el-dropdown-item :command="{ value: true }">使用中</el-dropdown-item>
|
|
|
- <el-dropdown-item :command="{ value: false }">已弃用</el-dropdown-item>
|
|
|
- </el-dropdown-menu>
|
|
|
- </template>
|
|
|
- </el-dropdown>
|
|
|
-
|
|
|
<el-text v-else>
|
|
|
<!-- 其他列按默认方式显示 -->
|
|
|
|
|
@@ -921,11 +852,6 @@ onMounted(() => {
|
|
|
align-items: center;
|
|
|
}
|
|
|
|
|
|
-.partition {
|
|
|
- width: 98%;
|
|
|
- margin: 0 auto;
|
|
|
-}
|
|
|
-
|
|
|
.tableTools {
|
|
|
width: 98%;
|
|
|
margin: 0 auto;
|
|
@@ -958,7 +884,7 @@ onMounted(() => {
|
|
|
}
|
|
|
|
|
|
.tableBody {
|
|
|
- box-shadow: 0 0 3px 0px rgba(0, 0, 0, 0.1);
|
|
|
+ box-shadow: 0 0 3px 0 rgba(0, 0, 0, 0.1);
|
|
|
/* box-shadow:
|
|
|
-4px -4px 8px 1px rgba(0, 0, 0, 0.02),
|
|
|
-4px -4px 3px 1px rgba(0, 0, 0, 0.02); */
|
|
@@ -967,23 +893,12 @@ onMounted(() => {
|
|
|
.userTablePaginationBox {
|
|
|
box-sizing: border-box;
|
|
|
width: 98%;
|
|
|
- margin: 0% auto;
|
|
|
+ margin: 0 auto;
|
|
|
padding: 1% 0;
|
|
|
display: flex;
|
|
|
justify-content: center;
|
|
|
}
|
|
|
|
|
|
-.averageItem {
|
|
|
- font-size: 14px;
|
|
|
- color: #515b6f;
|
|
|
-}
|
|
|
-
|
|
|
-.normalItem {
|
|
|
- font-size: 14px;
|
|
|
- color: #515b6f;
|
|
|
- font-weight: 400;
|
|
|
-}
|
|
|
-
|
|
|
.leftToolBtn {
|
|
|
margin-right: 5px;
|
|
|
}
|