|
@@ -2,7 +2,7 @@
|
|
|
* @Author: fxs bjnsfxs@163.com
|
|
|
* @Date: 2024-08-20 18:16:18
|
|
|
* @LastEditors: fxs bjnsfxs@163.com
|
|
|
- * @LastEditTime: 2024-09-02 15:57:42
|
|
|
+ * @LastEditTime: 2024-09-18 12:00:45
|
|
|
* @FilePath: \Game-Backstage-Management-System\src\components\Table.vue
|
|
|
* @Description:
|
|
|
*
|
|
@@ -11,14 +11,20 @@
|
|
|
import type { PropsParams, TablePaginationSetting } from '@/types/table'
|
|
|
import type { ReqConfig } from '@/types/dataAnalysis'
|
|
|
import { FilterType, FieldSpecialEffectType } from '@/types/table'
|
|
|
+import { initLoadResouce } from '@/utils/resource'
|
|
|
+import { fuzzySearch } from '@/utils/common'
|
|
|
|
|
|
-import { computed, onMounted, reactive, ref, watch } from 'vue'
|
|
|
+import { computed, onMounted, reactive, ref, toRaw, watch } from 'vue'
|
|
|
import { useTable } from '@/hooks/useTable'
|
|
|
|
|
|
import FilterPopover from './toolsBtn/FilterPopover.vue'
|
|
|
import RegreshBtn from './toolsBtn/RegreshBtn.vue'
|
|
|
+import { useRequest } from '@/hooks/useRequest'
|
|
|
|
|
|
import type { FormInstance } from 'element-plus'
|
|
|
+import axiosInstance from '@/utils/axios/axiosInstance'
|
|
|
+
|
|
|
+const { analysisResCode } = useRequest()
|
|
|
|
|
|
// 表格工具图标大小
|
|
|
const toolsIconSize = ref(25)
|
|
@@ -33,11 +39,14 @@ const props = withDefaults(defineProps<PropsParams>(), {
|
|
|
needLeftTools: false,
|
|
|
needRightTools: false,
|
|
|
openFilterQuery: false,
|
|
|
- openPageQuery: false
|
|
|
+ openPageQuery: false,
|
|
|
+ needUpload: false,
|
|
|
+ needDownLoad: false
|
|
|
})
|
|
|
|
|
|
// 父组件触发的方法
|
|
|
-const emits = defineEmits(['addNewItem'])
|
|
|
+// 删除了一个事件触发,loadSuccess
|
|
|
+const emits = defineEmits(['addNewItem', 'upload', 'downLoad'])
|
|
|
|
|
|
// 加载动画
|
|
|
const loading = ref(false)
|
|
@@ -45,16 +54,20 @@ const loading = ref(false)
|
|
|
// 表格数据
|
|
|
const tableData: Array<any> = reactive([])
|
|
|
|
|
|
+// 备份表格数据,用于在不分页查询的时候,恢复数据
|
|
|
+const backupTableData: Array<any> = []
|
|
|
+
|
|
|
// 查询表单的数据
|
|
|
-const queryFormData = reactive<any>({})
|
|
|
+const queryFormData = reactive<{ [key: string]: any }>({})
|
|
|
+
|
|
|
+const backupQueryFormData = reactive<{ [key: string]: any }>({})
|
|
|
|
|
|
// 分页数据
|
|
|
const paginationConfig2 = reactive<TablePaginationSetting>({
|
|
|
currentPage: 0,
|
|
|
limit: 0,
|
|
|
total: 0,
|
|
|
- pagesizeList: [],
|
|
|
- hasLodingData: 0
|
|
|
+ pagesizeList: []
|
|
|
})
|
|
|
|
|
|
// 请求配置
|
|
@@ -63,6 +76,14 @@ const reqconfig = reactive<ReqConfig>({
|
|
|
otherOptions: {}
|
|
|
})
|
|
|
|
|
|
+// 资源的加载路径
|
|
|
+const resourceInfo: Record<string, string> = {
|
|
|
+ defaultHead: `/img/default/defaultHead.png`
|
|
|
+}
|
|
|
+
|
|
|
+// 使用blob的资源路径信息
|
|
|
+const blobUrlInfo = reactive<Record<string, string>>({})
|
|
|
+
|
|
|
// 一些公用方法
|
|
|
const { getTableData } = useTable(tableData, paginationConfig2)
|
|
|
|
|
@@ -84,9 +105,6 @@ const inputFieldsList = computed(() => {
|
|
|
// 所有类型为select的表单控件信息
|
|
|
const selectFieldsList = computed(() => {
|
|
|
return props.queryInfo?.filter((item) => {
|
|
|
- if (item.default) {
|
|
|
- queryFormData[item.name] = item.default
|
|
|
- }
|
|
|
return item.type === FilterType.SELECT
|
|
|
})
|
|
|
})
|
|
@@ -116,91 +134,139 @@ const handleSizeChange = (val: number) => {
|
|
|
* @return {*}
|
|
|
*/
|
|
|
const getData = () => {
|
|
|
- return new Promise((resolve, reject) => {
|
|
|
- if (props.dataList) {
|
|
|
- tableData.splice(0, tableData.length, ...props.dataList)
|
|
|
- paginationConfig2.total = props.paginationConfig.total
|
|
|
- loading.value = false
|
|
|
- resolve(true)
|
|
|
- } else {
|
|
|
- loading.value = true
|
|
|
- if (props.requestConfig) {
|
|
|
- if (props.openPageQuery) {
|
|
|
- // 如果开启了分页查询,那么要计算出需要展示的页码位置所对应的偏移量
|
|
|
- // 同时要将查询的条数改为对应的用户选择的展示条数
|
|
|
- reqconfig.otherOptions.offset =
|
|
|
- (paginationConfig2.currentPage - 1) * paginationConfig2.limit
|
|
|
- reqconfig.otherOptions.limit = paginationConfig2.limit
|
|
|
- }
|
|
|
-
|
|
|
- // 查询时要根据是否开启分页查询传入对应参数
|
|
|
- getTableData(reqconfig.url, reqconfig.otherOptions, props.openPageQuery)
|
|
|
- .then(() => {
|
|
|
- resolve(true)
|
|
|
- })
|
|
|
- .catch((err) => {
|
|
|
- console.log(err)
|
|
|
- reject(err)
|
|
|
- })
|
|
|
- .finally(() => {
|
|
|
+ return new Promise(async (resolve, reject) => {
|
|
|
+ try {
|
|
|
+ Object.assign(queryFormData, JSON.parse(JSON.stringify(backupQueryFormData)))
|
|
|
+ const loadTableData = async () => {
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
+ if (props.dataList) {
|
|
|
+ tableData.splice(0, tableData.length, ...props.dataList)
|
|
|
+
|
|
|
+ paginationConfig2.total = props.paginationConfig.total
|
|
|
loading.value = false
|
|
|
- })
|
|
|
- } else {
|
|
|
- loading.value = false
|
|
|
- throw new Error('no match requestConfig')
|
|
|
- }
|
|
|
- }
|
|
|
+ // emits('loadSuccess', tableData)
|
|
|
|
|
|
- if (tableData.length) {
|
|
|
- if (props.needAverage) {
|
|
|
- let rowData: any = {}
|
|
|
- let oldList: Array<any> = JSON.parse(JSON.stringify(tableData))
|
|
|
- Object.values(props.tableFieldsInfo).map((item, index) => {
|
|
|
- let sum = oldList
|
|
|
- .map((item) => item.count)
|
|
|
- .reduce((accumulator, currentValue) => accumulator + currentValue, 0)
|
|
|
- let averageList = oldList
|
|
|
- .map((val) => val[item.name])
|
|
|
- .filter((item) => item !== undefined)
|
|
|
- if (index === 0) rowData[item.name] = '均值'
|
|
|
- else if (item.name === 'count') rowData[item.name] = sum
|
|
|
- else {
|
|
|
- let num =
|
|
|
- averageList.reduce((accumulator, currentValue) => accumulator + currentValue, 0) /
|
|
|
- averageList.length
|
|
|
-
|
|
|
- rowData[item.name] = isNaN(num) ? 0 : num.toFixed(2)
|
|
|
+ resolve(true)
|
|
|
+ } else {
|
|
|
+ loading.value = true
|
|
|
+ if (props.requestConfig) {
|
|
|
+ if (props.openPageQuery) {
|
|
|
+ // 如果开启了分页查询,那么要计算出需要展示的页码位置所对应的偏移量
|
|
|
+ // 同时要将查询的条数改为对应的用户选择的展示条数
|
|
|
+ reqconfig.otherOptions.offset =
|
|
|
+ (paginationConfig2.currentPage - 1) * paginationConfig2.limit
|
|
|
+ reqconfig.otherOptions.limit = paginationConfig2.limit
|
|
|
+ }
|
|
|
+
|
|
|
+ // 查询时要根据是否开启分页查询传入对应参数
|
|
|
+ getTableData(reqconfig.url, reqconfig.otherOptions, props.openPageQuery)
|
|
|
+ .then(() => {
|
|
|
+ // emits('loadSuccess', tableData)
|
|
|
+ backupTableData.splice(0, backupTableData.length, ...tableData)
|
|
|
+
|
|
|
+ resolve(true)
|
|
|
+ })
|
|
|
+ .catch((err) => {
|
|
|
+ console.log(err)
|
|
|
+
|
|
|
+ reject(err)
|
|
|
+ })
|
|
|
+ .finally(() => {
|
|
|
+ loading.value = false
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ loading.value = false
|
|
|
+
|
|
|
+ throw new Error('no match requestConfig')
|
|
|
+ }
|
|
|
}
|
|
|
})
|
|
|
- insertRow(0, rowData)
|
|
|
}
|
|
|
+ // 等待数据加载完成
|
|
|
+ await loadTableData()
|
|
|
+ .then(async () => {
|
|
|
+ if (props.needAverage) {
|
|
|
+ let rowData: any = {}
|
|
|
+ let oldList: Array<any> = JSON.parse(JSON.stringify(tableData))
|
|
|
+ Object.values(props.tableFieldsInfo).map((item, index) => {
|
|
|
+ let sum = oldList
|
|
|
+ .map((item) => item.count)
|
|
|
+ .reduce((accumulator, currentValue) => accumulator + currentValue, 0)
|
|
|
+ let averageList = oldList
|
|
|
+ .map((val) => val[item.name])
|
|
|
+ .filter((item) => item !== undefined)
|
|
|
+ if (index === 0) rowData[item.name] = '均值'
|
|
|
+ else if (item.name === 'count') rowData[item.name] = sum
|
|
|
+ else {
|
|
|
+ let num =
|
|
|
+ averageList.reduce((accumulator, currentValue) => accumulator + currentValue, 0) /
|
|
|
+ averageList.length
|
|
|
+
|
|
|
+ rowData[item.name] = isNaN(num) ? 0 : num.toFixed(2)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ insertRow(0, rowData)
|
|
|
+ }
|
|
|
+ resolve(true)
|
|
|
+ })
|
|
|
+ .catch((err) => {
|
|
|
+ console.log(err)
|
|
|
+ reject(err)
|
|
|
+ })
|
|
|
+ } catch (err) {
|
|
|
+ console.log(err)
|
|
|
+ reject(err)
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
|
|
|
-// 清空表格数据
|
|
|
+/**
|
|
|
+ * @description: 清空表格数据
|
|
|
+ * @return {*}
|
|
|
+ */
|
|
|
const resetTableData = () => {
|
|
|
tableData.splice(0, tableData.length)
|
|
|
}
|
|
|
|
|
|
-// 按条件查询
|
|
|
+/**
|
|
|
+ * @description: 按条件查询,如果开启了分页查询,那么会直接重新查询数据,否则,会根据现有数据进行查询
|
|
|
+ * @return {*}
|
|
|
+ */
|
|
|
const queryTableData = () => {
|
|
|
if (props.requestConfig) {
|
|
|
- reqconfig.otherOptions = { ...reqconfig.otherOptions, ...queryFormData }
|
|
|
- getData()
|
|
|
- } else {
|
|
|
- throw new Error('no match requestConfig')
|
|
|
+ reqconfig.otherOptions = { ...props.requestConfig.otherOptions, ...queryFormData }
|
|
|
+ }
|
|
|
+ if (props.openPageQuery) getData()
|
|
|
+ else {
|
|
|
+ let filteredTable = []
|
|
|
+ // 过滤出来所有符合formData数据的条件
|
|
|
+ filteredTable = backupTableData.filter((item) => {
|
|
|
+ let state = true
|
|
|
+ for (let [k, v] of Object.entries(queryFormData)) {
|
|
|
+ // 模糊查询,看值是否跟表格中的数据匹配
|
|
|
+ if (!fuzzySearch(v, item[k])) {
|
|
|
+ state = false
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return state
|
|
|
+ })
|
|
|
+
|
|
|
+ tableData.splice(0, tableData.length, ...filteredTable)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @description: 重置整个查询表单(无效目前)
|
|
|
- * @param {*} formEl
|
|
|
+ * @description: 重置整个查询表单,重置后,再请求一次全部表格
|
|
|
+ * @param {*} formEl 表单对象
|
|
|
* @return {*}
|
|
|
*/
|
|
|
const resetQueryForm = (formEl: FormInstance | undefined) => {
|
|
|
if (!formEl) return
|
|
|
- formEl?.resetFields()
|
|
|
+ // clearReactiveData(queryFormData)
|
|
|
+ // queryFormData
|
|
|
+ Object.assign(queryFormData, JSON.parse(JSON.stringify(backupQueryFormData)))
|
|
|
+ queryTableData()
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -248,37 +314,49 @@ const tableCellStyle = (info: any) => {
|
|
|
} else return {}
|
|
|
}
|
|
|
|
|
|
-// 根据分页大小的切换来更新数据
|
|
|
-// 这里将他赋值,用于根据传入的配置来选择是否开启该监听
|
|
|
/**
|
|
|
- * @description: 监听litmit,currentpage,gid的变化,改变后去重新请求数据
|
|
|
+ * @description: 监听litmit,currentpage的变化,改变后去重新请求数据
|
|
|
* 如果是limit的变化,则需要把当前页置为1
|
|
|
*
|
|
|
* 对于Gid需要去监听props的,而不是本地的,因为是外部的改变
|
|
|
* @return {*}
|
|
|
*/
|
|
|
const changePageLimit = watch(
|
|
|
- () => [
|
|
|
- paginationConfig2.limit,
|
|
|
- props.requestConfig?.otherOptions.gid,
|
|
|
- paginationConfig2.currentPage
|
|
|
- ],
|
|
|
- ([newLimit, newGid], [oldLimit, oldGid]) => {
|
|
|
+ () => [paginationConfig2.limit, paginationConfig2.currentPage],
|
|
|
+ ([newLimit, newCurPage], [oldLimit, oldCruPage]) => {
|
|
|
if (newLimit != oldLimit) {
|
|
|
// 需要给分页按钮加上:current-page.sync="current_page" 配置,不然不生效
|
|
|
// 当改变每页大小时把之前的缓存全部清除,重新开始
|
|
|
paginationConfig2.currentPage = 1
|
|
|
// resetTableData()
|
|
|
}
|
|
|
- if (newGid != oldGid) reqconfig.otherOptions.gid = newGid
|
|
|
|
|
|
- if (newLimit != oldLimit || !tableData[paginationConfig2.currentPage] || newGid != oldGid) {
|
|
|
+ if (newCurPage != oldCruPage) paginationConfig2.currentPage = newCurPage
|
|
|
+
|
|
|
+ // if (newGid != oldGid) reqconfig.otherOptions.gid = newGid
|
|
|
+ // || newGid != oldGid
|
|
|
+
|
|
|
+ if (newLimit != oldLimit || !tableData[paginationConfig2.currentPage]) {
|
|
|
getData()
|
|
|
}
|
|
|
},
|
|
|
{ deep: true }
|
|
|
)
|
|
|
|
|
|
+/**
|
|
|
+ * @description: 监听gid的变化,重新请求数据,这里很奇怪,跟上面的limit和page放到一起不起作用
|
|
|
+ * @return {*}
|
|
|
+ */
|
|
|
+watch(
|
|
|
+ () => props.requestConfig?.otherOptions.gid,
|
|
|
+ (newGid, oldGid) => {
|
|
|
+ if (newGid != oldGid) {
|
|
|
+ reqconfig.otherOptions.gid = newGid
|
|
|
+ getData()
|
|
|
+ }
|
|
|
+ }
|
|
|
+)
|
|
|
+
|
|
|
// 监听传入的datalist的变化,然后去更新数据
|
|
|
const changeDataList = watch(
|
|
|
() => [props.dataList],
|
|
@@ -290,6 +368,15 @@ const changeDataList = watch(
|
|
|
}
|
|
|
)
|
|
|
|
|
|
+// 监听日期的变化,
|
|
|
+const watchDateChange = watch(
|
|
|
+ () => [props.requestConfig?.otherOptions.startTime, props.requestConfig?.otherOptions.endTime],
|
|
|
+ () => {
|
|
|
+ getData()
|
|
|
+ },
|
|
|
+ { deep: true }
|
|
|
+)
|
|
|
+
|
|
|
/**
|
|
|
* @description: 创建row-key优化表格性能
|
|
|
* @return {*}
|
|
@@ -298,6 +385,11 @@ const createRowKey = () => {
|
|
|
return `${Date.now()}-${Math.random().toString(36).substr(2, 9)}`
|
|
|
}
|
|
|
|
|
|
+//如果没有日期就取消掉
|
|
|
+if (!props.requestConfig?.otherOptions.startTime && !props.requestConfig?.otherOptions.endTime) {
|
|
|
+ watchDateChange()
|
|
|
+}
|
|
|
+
|
|
|
// 没传入datalist则取消该监听
|
|
|
if (!props.dataList) {
|
|
|
changeDataList()
|
|
@@ -308,29 +400,106 @@ if (!props.openPageQuery) {
|
|
|
changePageLimit()
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ * @description: 拷贝一份配置文件
|
|
|
+ * @return {*}
|
|
|
+ */
|
|
|
const initpageConfig = () => {
|
|
|
Object.assign(paginationConfig2, props.paginationConfig)
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ * @description: 初始化请求配置,用于把拷贝一份新的数据
|
|
|
+ * @return {*}
|
|
|
+ */
|
|
|
const initReqConfig = () => {
|
|
|
Object.assign(reqconfig, props.requestConfig)
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ * @description: 初始化查询框的数据
|
|
|
+ * @return {*}
|
|
|
+ */
|
|
|
+const initFormData = () => {
|
|
|
+ props.queryInfo?.map((item: any) => {
|
|
|
+ queryFormData[item.name] = item.default
|
|
|
+ })
|
|
|
+ // backupQueryFormData = JSON.parse(JSON.stringify(queryFormData))
|
|
|
+ Object.assign(backupQueryFormData, JSON.parse(JSON.stringify(queryFormData)))
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * @description: 表格排序
|
|
|
+ * @param {*} data 获取到的数据
|
|
|
+ * @return {*}
|
|
|
+ */
|
|
|
+const tableSortChange = (data: { column: any; prop: string; order: any }) => {
|
|
|
+ let { order } = { ...data }
|
|
|
+ if (order === 'ascending') order = 'asc'
|
|
|
+ else if (order === 'descending') order = 'desc'
|
|
|
+ else order = ''
|
|
|
+ reqconfig.otherOptions.order = order
|
|
|
+ getData()
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * @description: 删除行
|
|
|
+ * @param {*} url 请求地址
|
|
|
+ * @param {*} row 行数据
|
|
|
+ * @return {*}
|
|
|
+ */
|
|
|
+const deleteRow = (url: string, filedsInfo: any) => {
|
|
|
+ axiosInstance
|
|
|
+ .post(url, { ...filedsInfo })
|
|
|
+ .then((data) => {
|
|
|
+ analysisResCode(data).then(() => {
|
|
|
+ getData()
|
|
|
+ })
|
|
|
+ })
|
|
|
+ .catch((err) => {
|
|
|
+ console.log(err)
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * @description: 下载表格数据
|
|
|
+ * @return {*}
|
|
|
+ */
|
|
|
+const downLoadTable = () => {
|
|
|
+ emits('downLoad', JSON.parse(JSON.stringify(tableData)))
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * @description: 外部获取数据
|
|
|
+ * @return {*}
|
|
|
+ */
|
|
|
+const outGetTableData = () => {
|
|
|
+ return toRaw(tableData).flat()
|
|
|
+}
|
|
|
+
|
|
|
// 定义暴露出去的方法
|
|
|
defineExpose({
|
|
|
getData,
|
|
|
- resetTableData
|
|
|
+ resetTableData,
|
|
|
+ deleteRow,
|
|
|
+ downLoadTable,
|
|
|
+ outGetTableData
|
|
|
})
|
|
|
|
|
|
onMounted(() => {
|
|
|
initpageConfig()
|
|
|
initReqConfig()
|
|
|
+ initFormData()
|
|
|
if (props.loadingState !== undefined) {
|
|
|
loading.value = props.loadingState
|
|
|
}
|
|
|
- if (!props.openPageQuery) {
|
|
|
- getData()
|
|
|
- }
|
|
|
+ // if (!props.openPageQuery) {
|
|
|
+ // getData()
|
|
|
+ // }
|
|
|
+ // 去加载所有需要的资源
|
|
|
+ initLoadResouce(resourceInfo).then((data) => {
|
|
|
+ Object.assign(blobUrlInfo, data)
|
|
|
+ })
|
|
|
})
|
|
|
</script>
|
|
|
|
|
@@ -359,11 +528,18 @@ onMounted(() => {
|
|
|
</el-form-item>
|
|
|
|
|
|
<!-- 所有选择框 -->
|
|
|
+ <!-- <el-config-provider :value-on-clear="null" :empty-values="[undefined, null]"> -->
|
|
|
<el-form-item :label="item.label" v-for="item in selectFieldsList" class="filterItem">
|
|
|
- <el-select v-model="queryFormData[item.name]" :placeholder="item.placeholder">
|
|
|
+ <el-select
|
|
|
+ :empty-values="[undefined, null]"
|
|
|
+ v-model="queryFormData[item.name]"
|
|
|
+ :placeholder="item.placeholder"
|
|
|
+ :value-key="item.name"
|
|
|
+ >
|
|
|
<el-option v-for="val in item.otherOption" :label="val.cnName" :value="val.value" />
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
+ <!-- </el-config-provider> -->
|
|
|
|
|
|
<!-- 所有日期选择框 -->
|
|
|
<el-form-item :label="item.label" v-for="item in dateFieldsList" class="filterItem">
|
|
@@ -391,15 +567,31 @@ onMounted(() => {
|
|
|
</div>
|
|
|
</div>
|
|
|
<!-- 分割线 -->
|
|
|
- <el-divider class="partition" content-position="center" />
|
|
|
+ <!-- <el-divider class="partition" content-position="center" /> -->
|
|
|
<div class="tableTools">
|
|
|
<div class="leftTools">
|
|
|
- <el-button v-if="needLeftTools" type="primary" color="#165dff" @click="emits('addNewItem')">
|
|
|
- <el-icon><Plus /></el-icon>新增
|
|
|
- </el-button>
|
|
|
+ <div class="leftToolsGroup" v-if="needLeftTools" style="display: flex">
|
|
|
+ <el-button class="leftToolBtn" color="#165dff" @click="emits('addNewItem')">
|
|
|
+ <el-icon><Plus /></el-icon>新增
|
|
|
+ </el-button>
|
|
|
+ <el-button
|
|
|
+ class="leftToolBtn"
|
|
|
+ color="#626aef"
|
|
|
+ @click="emits('upload', outGetTableData())"
|
|
|
+ v-if="needUpload"
|
|
|
+ >
|
|
|
+ <el-icon><Upload /></el-icon>上传
|
|
|
+ </el-button>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
<div class="rightTools" v-if="needRightTools">
|
|
|
- <el-button color="#f0f1f3" size="default" class="rightToolsItem">
|
|
|
+ <el-button
|
|
|
+ v-if="needDownload"
|
|
|
+ color="#f0f1f3"
|
|
|
+ size="default"
|
|
|
+ class="rightToolsItem"
|
|
|
+ @click="downLoadTable"
|
|
|
+ >
|
|
|
<el-icon><Download /></el-icon>下载
|
|
|
</el-button>
|
|
|
|
|
@@ -421,6 +613,7 @@ onMounted(() => {
|
|
|
:cell-style="tableCellStyle"
|
|
|
v-loading="loading"
|
|
|
:row-key="createRowKey()"
|
|
|
+ @sort-change="tableSortChange"
|
|
|
>
|
|
|
<el-table-column
|
|
|
v-if="props.needRowindex"
|
|
@@ -433,10 +626,11 @@ onMounted(() => {
|
|
|
<el-table-column
|
|
|
:prop="item.name"
|
|
|
:label="item.cnName"
|
|
|
- width="auto"
|
|
|
+ :min-width="item.specialEffect?.type === FieldSpecialEffectType.DROPDOWN ? '170px' : ''"
|
|
|
align="center"
|
|
|
show-overflow-tooltip
|
|
|
v-if="item.isShow"
|
|
|
+ :sortable="item.needSort === true ? 'custorm' : false"
|
|
|
>
|
|
|
<template v-slot="scope">
|
|
|
<!-- tag类 -->
|
|
@@ -450,7 +644,8 @@ onMounted(() => {
|
|
|
: 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"
|
|
@@ -463,7 +658,7 @@ onMounted(() => {
|
|
|
>
|
|
|
<template #error>
|
|
|
<!-- -->
|
|
|
- <img style="width: 35px; height: 35px" src="../assets/default/defaultHead.png" />
|
|
|
+ <img style="width: 35px; height: 35px" :src="blobUrlInfo.defaultHead" />
|
|
|
</template>
|
|
|
</el-image>
|
|
|
|
|
@@ -481,9 +676,77 @@ onMounted(() => {
|
|
|
|
|
|
<!-- 翻译类 -->
|
|
|
<el-text v-else-if="item.specialEffect?.type === FieldSpecialEffectType.TRANSLATE">
|
|
|
- {{ item.specialEffect.othnerInfo.translateText[scope.row[item.name]] }}
|
|
|
+ <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>
|
|
|
|
|
|
+ <!-- 开关类 -->
|
|
|
+
|
|
|
+ <el-switch
|
|
|
+ :active-value="1"
|
|
|
+ :inactive-value="0"
|
|
|
+ v-else-if="item.specialEffect?.type === FieldSpecialEffectType.SWITCH"
|
|
|
+ v-model="scope.row[item.name]"
|
|
|
+ :data="scope.row[item.name]"
|
|
|
+ size="default"
|
|
|
+ >
|
|
|
+ </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>
|
|
|
<!-- 其他列按默认方式显示 -->
|
|
|
|
|
@@ -522,10 +785,13 @@ onMounted(() => {
|
|
|
|
|
|
<style scoped>
|
|
|
.tableContent {
|
|
|
- margin: 0 auto;
|
|
|
- width: 98%;
|
|
|
+ margin: 10px auto 20px;
|
|
|
+ width: 100%;
|
|
|
|
|
|
/* height: 100%; */
|
|
|
+ box-shadow:
|
|
|
+ 0 4px 8px 0 rgba(0, 0, 0, 0.02),
|
|
|
+ 0 1px 3px 0 rgba(0, 0, 0, 0.02);
|
|
|
}
|
|
|
.filterBox,
|
|
|
.tableBox {
|
|
@@ -549,7 +815,7 @@ onMounted(() => {
|
|
|
display: flex;
|
|
|
align-items: center;
|
|
|
color: black;
|
|
|
- font-size: 20px;
|
|
|
+ font-size: 16px;
|
|
|
font-weight: bold;
|
|
|
/* background-color: lightblue; */
|
|
|
/* margin-bottom: 1%; */
|
|
@@ -617,20 +883,32 @@ onMounted(() => {
|
|
|
}
|
|
|
|
|
|
.rightTools {
|
|
|
- width: 10%;
|
|
|
+ width: 5%;
|
|
|
}
|
|
|
|
|
|
.tableBox {
|
|
|
width: 98%;
|
|
|
/* height: 98%; */
|
|
|
- margin: 0 auto;
|
|
|
+ margin: 5px auto;
|
|
|
+ box-shadow:
|
|
|
+ 0 4px 8px 0 rgba(0, 0, 0, 0.02),
|
|
|
+ 0 1px 3px 0 rgba(0, 0, 0, 0.02);
|
|
|
/* margin-top: 0.5%;
|
|
|
margin-bottom: 2%; */
|
|
|
}
|
|
|
|
|
|
+.tableBody {
|
|
|
+ box-shadow: 0 0 3px 0px 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); */
|
|
|
+}
|
|
|
+
|
|
|
.userTablePaginationBox {
|
|
|
+ box-sizing: border-box;
|
|
|
width: 98%;
|
|
|
- margin: 0.5% auto;
|
|
|
+ margin: 0% auto;
|
|
|
+ padding: 1% 0;
|
|
|
display: flex;
|
|
|
justify-content: center;
|
|
|
}
|
|
@@ -645,4 +923,8 @@ onMounted(() => {
|
|
|
color: #515b6f;
|
|
|
font-weight: 400;
|
|
|
}
|
|
|
+
|
|
|
+.leftToolBtn {
|
|
|
+ margin-right: 5px;
|
|
|
+}
|
|
|
</style>
|