From af5847927931d3f491d7be5e0178cff3c37ac6f9 Mon Sep 17 00:00:00 2001
From: huangxiaoqiang <huangxiaoqiang@hnkhzn.com>
Date: 星期四, 06 十一月 2025 17:20:44 +0800
Subject: [PATCH] 1
---
项目代码/WMS/WIDESEA_WMSClient/src/components/basic/VolTable.vue | 1426 +++++++++++++++++++++++++++++++++--------------------------
1 files changed, 799 insertions(+), 627 deletions(-)
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSClient/src/components/basic/VolTable.vue" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSClient/src/components/basic/VolTable.vue"
index ec01ee7..5618bf6 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSClient/src/components/basic/VolTable.vue"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSClient/src/components/basic/VolTable.vue"
@@ -1,58 +1,114 @@
<template>
<!-- 2021.11.18绉婚櫎voltable鏂规硶@cell-mouse-leave="rowEndEdit" -->
- <div class="vol-table" :class="[
- textInline ? 'text-inline' : '',
- fxRight ? 'fx-right' : '',
- isChrome ? 'chrome' : '',
- smallCell ? 'small-table' : ''
- ]">
+ <div
+ class="vol-table"
+ :class="[
+ textInline ? 'text-inline' : '',
+ fxRight ? 'fx-right' : '',
+ isChrome ? 'chrome' : '',
+ smallCell ? 'small-table' : ''
+ ]"
+ >
<div class="mask" v-show="loading"></div>
<div class="message" v-show="loading">鍔犺浇涓�.....</div>
- <el-table :show-summary="summary" :summary-method="getSummaryData" :row-key="rowKey" :key="randomTableKey"
- :lazy="lazy" :defaultExpandAll="defaultExpandAll" :expand-row-keys="rowKey ? expandRowKeys : undefined" stripe
- :load="loadTreeChildren" @select="userSelect" @select-all="userSelect" @selection-change="selectionChange"
- @row-dblclick="rowDbClick" @row-click="rowClick" @header-click="headerClick"
- :highlight-current-row="highlightCurrentRow" ref="table" class="v-table" @sort-change="sortChange"
- tooltip-effect="dark" :height="realHeight" :max-height="realMaxHeight" :data="url ? rowData : tableData" border
- :row-class-name="initIndex" :cell-style="getCellStyle" style="width: 100%" :scrollbar-always-on="true"
- :span-method="cellSpanMethod" @expand-change="expandChange">
+ <el-table
+ :show-summary="summary"
+ :summary-method="getSummaryData"
+ :row-key="rowKey"
+ :key="randomTableKey"
+ :lazy="lazy"
+ :defaultExpandAll="defaultExpandAll"
+ :expand-row-keys="rowKey ? expandRowKeys : undefined"
+ stripe
+ :load="loadTreeChildren"
+ @select="userSelect"
+ @select-all="userSelect"
+ @selection-change="selectionChange"
+ @row-dblclick="rowDbClick"
+ @row-click="rowClick"
+ @header-click="headerClick"
+ :highlight-current-row="highlightCurrentRow"
+ ref="table"
+ class="v-table"
+ @sort-change="sortChange"
+ tooltip-effect="dark"
+ :height="realHeight"
+ :max-height="realMaxHeight"
+ :data="url ? rowData : tableData"
+ border
+ :row-class-name="initIndex"
+ :cell-style="getCellStyle"
+ style="width: 100%"
+ :scrollbar-always-on="true"
+ :span-method="cellSpanMethod"
+ @expand-change="expandChange"
+ >
<el-table-column v-if="columnIndex" type="index" :fixed="fixed" width="55"></el-table-column>
- <el-table-column v-if="ck" type="selection" :fixed="fixed" :selectable="selectable" width="55"></el-table-column>
+ <el-table-column
+ v-if="ck"
+ type="selection"
+ :fixed="fixed"
+ :selectable="selectable"
+ width="55"
+ ></el-table-column>
<!-- 2020.10.10绉婚櫎table绗竴琛屽己鍒舵帓搴� -->
- <el-table-column v-for="(column, cindex) in filterColumns" :prop="column.field" :label="column.title"
- :min-width="column.width" :formatter="formatter" :fixed="column.fixed" :key="column.field + cindex"
- :align="column.align" :sortable="column.sort ? 'custom' : false" :show-overflow-tooltip=true>
+ <el-table-column
+ v-for="(column, cindex) in filterColumns"
+ :prop="column.field"
+ :label="column.title"
+ :min-width="column.width"
+ :formatter="formatter"
+ :fixed="column.fixed"
+ :key="column.field + cindex"
+ :align="column.align"
+ :sortable="column.sort ? 'custom' : false"
+ :show-overflow-tooltip="true"
+ >
<template #header>
- <span v-if="(column.require || column.required) && column.edit" class="column-required">*</span>{{
- column.title }}
+ <span v-if="(column.require || column.required) && column.edit" class="column-required"
+ >*</span
+ >{{ column.title }}
</template>
<template #default="scope">
<!-- 2022.01.08澧炲姞澶氳〃澶达紝鐜板湪鍙敮鎸佸父鐢ㄥ姛鑳芥覆鏌擄紝涓嶆敮鎸佺紪杈戝姛鑳�(娑夊強鍒扮粍浠堕噸鍐�) -->
- <el-table-column style="border: none" v-for="columnChildren in filterChildrenColumn(column.children)"
- :key="columnChildren.field" :min-width="columnChildren.width" :class-name="columnChildren.class"
- :prop="columnChildren.field" :align="columnChildren.align" :label="columnChildren.title">
+ <el-table-column
+ style="border: none"
+ v-for="columnChildren in filterChildrenColumn(column.children)"
+ :key="columnChildren.field"
+ :min-width="columnChildren.width"
+ :class-name="columnChildren.class"
+ :prop="columnChildren.field"
+ :align="columnChildren.align"
+ :label="columnChildren.title"
+ >
<template #default="scopeChildren">
- <a href="javascript:void(0);" style="text-decoration: none"
- @click="link(scopeChildren.row, columnChildren, $event)" v-if="columnChildren.link"
- v-text="scopeChildren.row[columnChildren.field]"></a>
- <table-render v-else-if="columnChildren.render && typeof columnChildren.render == 'function'"
- :row="scopeChildren.row" key="rd-01" :index="scope.$index" :column="columnChildren"
- :render="columnChildren.render"></table-render>
- <div v-else-if="columnChildren.formatter" @click="
- columnChildren.click &&
- columnChildren.click(
- scopeChildren.row,
- columnChildren,
- scopeChildren.$index
- )
- " v-html="columnChildren.formatter(
- scopeChildren.row,
- columnChildren,
- scopeChildren.$index
- )
- "></div>
+ <a
+ href="javascript:void(0);"
+ style="text-decoration: none"
+ @click="link(scopeChildren.row, columnChildren, $event)"
+ v-if="columnChildren.link"
+ v-text="scopeChildren.row[columnChildren.field]"
+ ></a>
+ <table-render
+ v-else-if="columnChildren.render && typeof columnChildren.render == 'function'"
+ :row="scopeChildren.row"
+ key="rd-01"
+ :index="scope.$index"
+ :column="columnChildren"
+ :render="columnChildren.render"
+ ></table-render>
+ <div
+ v-else-if="columnChildren.formatter"
+ @click="
+ columnChildren.click &&
+ columnChildren.click(scopeChildren.row, columnChildren, scopeChildren.$index)
+ "
+ v-html="
+ columnChildren.formatter(scopeChildren.row, columnChildren, scopeChildren.$index)
+ "
+ ></div>
<div v-else-if="columnChildren.bind">
{{ formatter(scopeChildren.row, columnChildren, true) }}
</div>
@@ -65,108 +121,184 @@
</template>
</el-table-column>
<!-- 2020.06.18澧炲姞render娓叉煋鑷畾涔夊唴瀹� -->
- <table-render v-if="column.render && typeof column.render == 'function'" :row="scope.row" key="rd-01"
- :index="scope.$index" :column="column" :render="column.render"></table-render>
+ <table-render
+ v-if="column.render && typeof column.render == 'function'"
+ :row="scope.row"
+ key="rd-01"
+ :index="scope.$index"
+ :column="column"
+ :render="column.render"
+ ></table-render>
<!-- 鍚敤鍙屽嚮缂栬緫鍔熻兘锛屽甫缂栬緫鍔熻兘鐨勪笉浼氭覆鏌撲笅鎷夋鏂囨湰鑳屾櫙棰滆壊 -->
<!-- @click="rowBeginEdit(scope.$index,cindex)" -->
<!-- 2021.09.21澧炲姞缂栬緫鏃跺readonly灞炴�у垽鏂� -->
<template
- v-else-if="column.edit && !column.readonly && ['file', 'img', 'excel'].indexOf(column.edit.type) != -1">
- <div style="display:flex;align-items: center;" @click.stop>
- <i v-if="!column.showUpload || column.showUpload(scope.row, column)"
- style="padding: 3px;margin-right: 10px;color:#8f9293;cursor: pointer;"
- @click="showUpload(scope.row, column)" class="el-icon-upload"></i>
+ v-else-if="
+ column.edit &&
+ !column.readonly &&
+ ['file', 'img', 'excel'].indexOf(column.edit.type) != -1
+ "
+ >
+ <div style="display: flex; align-items: center" @click.stop>
+ <i
+ v-if="!column.showUpload || column.showUpload(scope.row, column)"
+ style="padding: 3px; margin-right: 10px; color: #8f9293; cursor: pointer"
+ @click="showUpload(scope.row, column)"
+ class="el-icon-upload"
+ ></i>
<template v-if="column.edit.type == 'img'">
- <img v-for="(file, imgIndex) in getFilePath(
- scope.row[column.field],
- column
- )" :key="imgIndex" @error="handleImageError"
- @click="viewImg(scope.row, column, file.path, $event, imgIndex)" class="table-img" :src="file.path" />
+ <img
+ v-for="(file, imgIndex) in getFilePath(scope.row[column.field], column)"
+ :key="imgIndex"
+ @error="handleImageError"
+ @click="viewImg(scope.row, column, file.path, $event, imgIndex)"
+ class="table-img"
+ :src="file.path"
+ />
</template>
- <a style="margin-right: 8px" v-else class="t-file" v-for="(file, fIndex) in getFilePath(
- scope.row[column.field],
- column
- )" :key="fIndex" @click="dowloadFile(file)">{{ file.name }}</a>
+ <a
+ style="margin-right: 8px"
+ v-else
+ class="t-file"
+ v-for="(file, fIndex) in getFilePath(scope.row[column.field], column)"
+ :key="fIndex"
+ @click="dowloadFile(file)"
+ >{{ file.name }}</a
+ >
</div>
</template>
- <div v-else-if="
- column.edit &&
- !column.readonly &&
- (column.edit.keep || edit.rowIndex == scope.$index)
- " class="edit-el">
+ <div
+ v-else-if="
+ column.edit && !column.readonly && (column.edit.keep || edit.rowIndex == scope.$index)
+ "
+ class="edit-el"
+ >
<div @click.stop class="e-item">
<div>
<!-- 2020.07.24澧炲姞鏃ユ湡onChange浜嬩欢 -->
- <el-date-picker clearable size="default" style="width: 100%"
- v-if="['date', 'datetime'].indexOf(column.edit.type) != -1" v-model="scope.row[column.field]" @change="(val) => {
- column.onChange &&
- column.onChange(scope.row, column, val);
- }
- " :type="column.edit.type" :placeholder="column.placeholder || column.title"
- :disabledDate="(val) => getDateOptions(val, column)" :value-format="getDateFormat(column)"
- :disabled="initColumnDisabled(scope.row, column)">
+ <el-date-picker
+ clearable
+ size="default"
+ style="width: 100%"
+ v-if="['date', 'datetime'].indexOf(column.edit.type) != -1"
+ v-model="scope.row[column.field]"
+ @change="
+ (val) => {
+ column.onChange && column.onChange(scope.row, column, val)
+ }
+ "
+ :type="column.edit.type"
+ :placeholder="column.placeholder || column.title"
+ :disabledDate="(val) => getDateOptions(val, column)"
+ :value-format="getDateFormat(column)"
+ :disabled="initColumnDisabled(scope.row, column)"
+ >
</el-date-picker>
- <el-time-picker clearable size="default" style="width: 100%" v-else-if="column.edit.type == 'time'"
- v-model="scope.row[column.field]" @change="(val) => {
- column.onChange &&
- column.onChange(scope.row, column, val);
- }
- " :placeholder="column.placeholder || column.title" :value-format="column.format || 'HH:mm:ss'"
- :disabled="initColumnDisabled(scope.row, column)">
+ <el-time-picker
+ clearable
+ size="default"
+ style="width: 100%"
+ v-else-if="column.edit.type == 'time'"
+ v-model="scope.row[column.field]"
+ @change="
+ (val) => {
+ column.onChange && column.onChange(scope.row, column, val)
+ }
+ "
+ :placeholder="column.placeholder || column.title"
+ :value-format="column.format || 'HH:mm:ss'"
+ :disabled="initColumnDisabled(scope.row, column)"
+ >
</el-time-picker>
- <el-switch v-else-if="column.edit.type == 'switch'" v-model="scope.row[column.field]"
- active-color="#0f84ff" inactive-color="rgb(194 194 194)" active-text="鏄�" inactive-text="鍚�"
- inline-prompt @change="(val) => {
- switchChange(val, scope.row, column);
- }
- " :active-value="typeof scope.row[column.field] == 'boolean'
+ <el-switch
+ v-else-if="column.edit.type == 'switch'"
+ v-model="scope.row[column.field]"
+ active-color="#0f84ff"
+ inactive-color="rgb(194 194 194)"
+ active-text="鏄�"
+ inactive-text="鍚�"
+ inline-prompt
+ @change="
+ (val) => {
+ switchChange(val, scope.row, column)
+ }
+ "
+ :active-value="
+ typeof scope.row[column.field] == 'boolean'
? true
: typeof scope.row[column.field] == 'string'
- ? '1'
- : 1
- " :inactive-value="typeof scope.row[column.field] == 'boolean'
- ? false
- : typeof scope.row[column.field] == 'string'
- ? '0'
- : 0
- " :disabled="initColumnDisabled(scope.row, column)">
+ ? '1'
+ : 1
+ "
+ :inactive-value="
+ typeof scope.row[column.field] == 'boolean'
+ ? false
+ : typeof scope.row[column.field] == 'string'
+ ? '0'
+ : 0
+ "
+ :disabled="initColumnDisabled(scope.row, column)"
+ >
</el-switch>
- <template v-else-if="
- ['select', 'selectList'].indexOf(column.edit.type) != -1
- ">
- <el-select-v2 style="width: 100%" :size="size" v-if="column.bind.data.length >= select2Count"
- v-model="scope.row[column.field]" filterable :multiple="column.edit.type == 'select' ? false : true"
- :placeholder="column.placeholder || column.title" :autocomplete="column.autocomplete"
- :options="column.bind.data" @change="
- column.onChange && column.onChange(scope.row, column)
- " clearable :disabled="initColumnDisabled(scope.row, column)">
+ <template v-else-if="['select', 'selectList'].indexOf(column.edit.type) != -1">
+ <el-select-v2
+ style="width: 100%"
+ :size="size"
+ v-if="column.bind.data.length >= select2Count"
+ v-model="scope.row[column.field]"
+ filterable
+ :multiple="column.edit.type == 'select' ? false : true"
+ :placeholder="column.placeholder || column.title"
+ :autocomplete="column.autocomplete"
+ :options="column.bind.data"
+ @change="column.onChange && column.onChange(scope.row, column)"
+ clearable
+ :disabled="initColumnDisabled(scope.row, column)"
+ >
<template #default="{ item }">
{{ item.label }}
</template>
</el-select-v2>
- <el-select size="default" style="width: 100%" v-else v-model="scope.row[column.field]" :filterable="column.filter || column.bind.data.length > 10
- ? true
- : false
- " :multiple="column.edit.type == 'select' ? false : true"
- :placeholder="column.placeholder || column.title" :allow-create="column.autocomplete" @change="
- column.onChange && column.onChange(scope.row, column)
- " clearable :disabled="initColumnDisabled(scope.row, column)">
- <el-option v-for="item in column.bind.data" :key="item.key" v-show="!item.hidden"
- :disabled="item.disabled" :label="item.value" :value="item.key">{{ item.value }}
+ <el-select
+ size="default"
+ style="width: 100%"
+ v-else
+ v-model="scope.row[column.field]"
+ :filterable="column.filter || column.bind.data.length > 10 ? true : false"
+ :multiple="column.edit.type == 'select' ? false : true"
+ :placeholder="column.placeholder || column.title"
+ :allow-create="column.autocomplete"
+ @change="column.onChange && column.onChange(scope.row, column)"
+ clearable
+ :disabled="initColumnDisabled(scope.row, column)"
+ >
+ <el-option
+ v-for="item in column.bind.data"
+ :key="item.key"
+ v-show="!item.hidden"
+ :disabled="item.disabled"
+ :label="item.value"
+ :value="item.key"
+ >{{ item.value }}
</el-option>
</el-select>
</template>
- <el-tree-select style="width: 100%"
+ <el-tree-select
+ style="width: 100%"
v-else-if="column.edit.type == 'treeSelect' || column.edit.type == 'cascader'"
- v-model="scope.row[column.field]" :data="column.bind.data"
- :multiple="column.multiple === undefined ? true : column.multiple" :render-after-expand="false"
+ v-model="scope.row[column.field]"
+ :data="column.bind.data"
+ :multiple="column.multiple === undefined ? true : column.multiple"
+ :render-after-expand="false"
:show-checkbox="true"
- :check-strictly="column.checkStrictly === undefined ? true : column.checkStrictly" check-on-click-node
- node-key="key" @change="column.onChange && column.onChange(scope.row, column)"
- :props="{ label: 'label' }">
- <template #default="{ data, node }">
- {{ data.label }}</template>
+ :check-strictly="column.checkStrictly === undefined ? true : column.checkStrictly"
+ check-on-click-node
+ node-key="key"
+ @change="column.onChange && column.onChange(scope.row, column)"
+ :props="{ label: 'label' }"
+ >
+ <template #default="{ data, node }"> {{ data.label }}</template>
</el-tree-select>
<!-- <div v-else-if="column.edit.type == 'cascader'">4444444</div> -->
<!-- <el-cascader
@@ -181,21 +313,38 @@
@change="column.onChange && column.onChange(scope.row, column)"
>
</el-cascader> -->
- <el-input v-else-if="column.edit.type == 'textarea'" type="textarea"
- :placeholder="column.placeholder || column.title" v-model="scope.row[column.field]"
- :disabled="initColumnDisabled(scope.row, column)">
+ <el-input
+ v-else-if="column.edit.type == 'textarea'"
+ type="textarea"
+ :placeholder="column.placeholder || column.title"
+ v-model="scope.row[column.field]"
+ :disabled="initColumnDisabled(scope.row, column)"
+ >
</el-input>
- <input class="table-input" v-else-if="!column.summary && !column.onKeyPress"
- v-model.lazy="scope.row[column.field]" :placeholder="column.placeholder || column.title"
- :disabled="initColumnDisabled(scope.row, column)" />
- <el-input v-else @change="inputKeyPress(scope.row, column, $event)"
+ <input
+ class="table-input"
+ v-else-if="!column.summary && !column.onKeyPress"
+ v-model.lazy="scope.row[column.field]"
+ :placeholder="column.placeholder || column.title"
+ :disabled="initColumnDisabled(scope.row, column)"
+ />
+ <el-input
+ v-else
+ @change="inputKeyPress(scope.row, column, $event)"
@input="inputKeyPress(scope.row, column, $event)"
- @keyup.enter="inputKeyPress(scope.row, column, $event)" size="default"
- v-model="scope.row[column.field]" :placeholder="column.placeholder || column.title"
- :disabled="initColumnDisabled(scope.row, column)"></el-input>
+ @keyup.enter="inputKeyPress(scope.row, column, $event)"
+ size="default"
+ v-model="scope.row[column.field]"
+ :placeholder="column.placeholder || column.title"
+ :disabled="initColumnDisabled(scope.row, column)"
+ ></el-input>
</div>
<div class="extra" v-if="column.extra && edit.rowIndex == scope.$index">
- <a :style="column.extra.style" style="text-decoration: none" @click="extraClick(scope.row, column)">
+ <a
+ :style="column.extra.style"
+ style="text-decoration: none"
+ @click="extraClick(scope.row, column)"
+ >
<i v-if="column.extra.icon" :class="[column.extra.icon]" />
{{ column.extra.text }}
</a>
@@ -204,42 +353,68 @@
</div>
<!--娌℃湁缂栬緫鍔熻兘鐨勭洿鎺ユ覆鏌撴爣绛�-->
<template v-else>
- <a href="javascript:void(0)" style="text-decoration: none;line-height: 1.3;"
- @click="link(scope.row, column, $event)" v-if="column.link" v-text="scope.row[column.field]"></a>
- <img v-else-if="column.type == 'img'" v-for="(file, imgIndex) in getFilePath(
- scope.row[column.field],
- column
- )" :key="imgIndex" @error="handleImageError"
- @click="viewImg(scope.row, column, file.path, $event, imgIndex)" class="table-img" :src="file.path" />
- <a style="margin-right: 8px" v-else-if="column.type == 'file' || column.type == 'excel'" class="t-file"
- v-for="(file, fIndex) in getFilePath(
- scope.row[column.field],
- column
- )" :key="fIndex" @click="dowloadFile(file)">{{ file.name }}</a>
- <span v-else-if="column.type == 'date'">{{
- formatterDate(scope.row, column)
- }}</span>
- <div v-else-if="column.formatter" @click="formatterClick(scope.row, column, $event)"
- v-html="column.formatter(scope.row, column)"></div>
- <!-- 2021.11.18淇table鏁版嵁婧愯缃负normal鍚庣偣鍑昏$event缂哄け鐨勯棶棰� -->
- <div v-else-if="column.bind && (column.normal || column.edit)"
+ <a
+ href="javascript:void(0)"
+ style="text-decoration: none; line-height: 1.3"
+ @click="link(scope.row, column, $event)"
+ v-if="column.link"
+ v-text="scope.row[column.field]"
+ ></a>
+ <img
+ v-else-if="column.type == 'img'"
+ v-for="(file, imgIndex) in getFilePath(scope.row[column.field], column)"
+ :key="imgIndex"
+ @error="handleImageError"
+ @click="viewImg(scope.row, column, file.path, $event, imgIndex)"
+ class="table-img"
+ :src="file.path"
+ />
+ <a
+ style="margin-right: 8px"
+ v-else-if="column.type == 'file' || column.type == 'excel'"
+ class="t-file"
+ v-for="(file, fIndex) in getFilePath(scope.row[column.field], column)"
+ :key="fIndex"
+ @click="dowloadFile(file)"
+ >{{ file.name }}</a
+ >
+ <span v-else-if="column.type == 'date'">{{ formatterDate(scope.row, column) }}</span>
+ <div
+ v-else-if="column.formatter"
@click="formatterClick(scope.row, column, $event)"
- :style="column.getStyle && column.getStyle(scope.row, column)">
+ v-html="column.formatter(scope.row, column)"
+ ></div>
+ <!-- 2021.11.18淇table鏁版嵁婧愯缃负normal鍚庣偣鍑昏$event缂哄け鐨勯棶棰� -->
+ <div
+ v-else-if="column.bind && (column.normal || column.edit)"
+ @click="formatterClick(scope.row, column, $event)"
+ :style="column.getStyle && column.getStyle(scope.row, column)"
+ >
{{ formatter(scope.row, column, true) }}
</div>
- <div v-else-if="column.click && !column.bind" @click="formatterClick(scope.row, column)">
+ <div
+ v-else-if="column.click && !column.bind"
+ @click="formatterClick(scope.row, column)"
+ >
{{ scope.row[column.field] }}
</div>
- <div @click="() => {
- column.click && formatterClick(scope.row, column);
- }
- " v-else-if="column.bind">
- <el-tag v-if="useTag" class="cell-tag" :class="[isEmptyTag(scope.row, column)]"
- :type="getColor(scope.row, column)" :effect="column.effect">{{ formatter(scope.row, column, true)
- }}</el-tag>
- <template v-else>{{
- formatter(scope.row, column, true)
- }}</template>
+ <div
+ @click="
+ () => {
+ column.click && formatterClick(scope.row, column)
+ }
+ "
+ v-else-if="column.bind"
+ >
+ <el-tag
+ v-if="useTag"
+ class="cell-tag"
+ :class="[isEmptyTag(scope.row, column)]"
+ :type="getColor(scope.row, column)"
+ :effect="column.effect"
+ >{{ formatter(scope.row, column, true) }}</el-tag
+ >
+ <template v-else>{{ formatter(scope.row, column, true) }}</template>
</div>
<span v-else>{{ formatter(scope.row, column, true) }}</span>
@@ -250,26 +425,42 @@
<template v-if="!paginationHide">
<div class="block pagination" key="pagination-01" style="display: flex">
<div style="flex: 1"></div>
- <el-pagination key="pagination-02" @size-change="handleSizeChange" @current-change="handleCurrentChange"
- :current-page="paginations.page" :page-sizes="paginations.sizes" :page-size="paginations.size"
- layout="total, sizes, prev, pager, next, jumper" :total="paginations.total"></el-pagination>
+ <el-pagination
+ key="pagination-02"
+ @size-change="handleSizeChange"
+ @current-change="handleCurrentChange"
+ :current-page="paginations.page"
+ :page-sizes="paginations.sizes"
+ :page-size="paginations.size"
+ layout="total, sizes, prev, pager, next, jumper"
+ :total="paginations.total"
+ ></el-pagination>
</div>
</template>
</div>
<VolBox v-model="uploadModel" title="涓婁紶" :height="228" :width="500" :padding="15" lazy>
<!-- 涓婁紶鍥剧墖銆乪xcel鎴栧叾浠栨枃浠躲�佹枃浠舵暟閲忋�佸ぇ灏忛檺鍒堕兘鍙互锛屽弬鐓olupload缁勪欢api -->
- <div style="height: 200px;display: flex;align-items: center;">
- <VolUpload style="text-align: center; " :autoUpload="currentColumn.edit.autoUpload"
- :multiple="currentColumn.edit.multiple" :url="uploadUrl" :max-file="currentColumn.edit.maxFile"
- :img="currentColumn.edit.type == 'img'" :excel="currentColumn.edit.type == 'excel'"
- :fileTypes="currentColumn.edit.fileTypes ? currentColumn.edit.fileTypes : []" :fileInfo="fileInfo"
- :upload-after="uploadAfter" :upload-before="uploadBefore" :append="currentColumn.edit.accept">
+ <div style="height: 200px; display: flex; align-items: center">
+ <VolUpload
+ style="text-align: center"
+ :autoUpload="currentColumn.edit.autoUpload"
+ :multiple="currentColumn.edit.multiple"
+ :url="uploadUrl"
+ :max-file="currentColumn.edit.maxFile"
+ :img="currentColumn.edit.type == 'img'"
+ :excel="currentColumn.edit.type == 'excel'"
+ :fileTypes="currentColumn.edit.fileTypes ? currentColumn.edit.fileTypes : []"
+ :fileInfo="fileInfo"
+ :upload-after="uploadAfter"
+ :upload-before="uploadBefore"
+ :append="currentColumn.edit.accept"
+ >
<div>{{ currentColumn.message }}</div>
</VolUpload>
</div>
<template #footer>
- <div style="text-align: center; ">
+ <div style="text-align: center">
<el-button type="default" size="small" @click="uploadModel = false">鍏抽棴</el-button>
<el-button type="primary" size="small" @click="saveUpload">淇濆瓨</el-button>
</div>
@@ -278,9 +469,9 @@
<vol-image-viewer ref="viewer"></vol-image-viewer>
</template>
<script>
-import VolTableRender from './VolTable/VolTableRender';
-let _errMsg;
-import { defineComponent, defineAsyncComponent } from 'vue';
+import VolTableRender from './VolTable/VolTableRender'
+let _errMsg
+import { defineComponent, defineAsyncComponent } from 'vue'
export default defineComponent({
emits: ['loadBefore', 'loadAfter', 'rowChange', 'rowClick', 'rowDbClick', 'selectionChange'],
//https://github.com/element-plus/element-plus/issues/1483
@@ -289,20 +480,20 @@
watch: {
'tableData.length': {
handler(newLen, oldLen) {
- this.watchRowSelectChange(newLen, oldLen);
+ this.watchRowSelectChange(newLen, oldLen)
}
},
'rowData.length': {
handler(newLen, oldLen) {
- this.watchRowSelectChange(newLen, oldLen);
+ this.watchRowSelectChange(newLen, oldLen)
}
}
},
components: {
- 'vol-image-viewer': defineAsyncComponent(() => import("./VolImageViewer.vue")),
+ 'vol-image-viewer': defineAsyncComponent(() => import('./VolImageViewer.vue')),
'table-render': VolTableRender,
- VolUpload: defineAsyncComponent(() => import("./VolUpload.vue")),
- VolBox: defineAsyncComponent(() => import("./VolBox.vue")),
+ VolUpload: defineAsyncComponent(() => import('./VolUpload.vue')),
+ VolBox: defineAsyncComponent(() => import('./VolBox.vue'))
},
props: {
rowKey: {
@@ -315,7 +506,7 @@
type: Function,
default: (tree, treeNode, resolve) => {
if (resolve) {
- return resolve([]);
+ return resolve([])
}
}
},
@@ -328,7 +519,7 @@
// 琛ㄦ暟鎹簮,閰嶇疆浜唘rl灏变笉鐢ㄤ紶杩欎釜鍙傛暟浜�
type: Array,
default: () => {
- return [];
+ return []
}
},
columns: {
@@ -346,13 +537,13 @@
linkView: {
type: Function,
default: function () {
- return 1;
+ return 1
}
},
pagination: {
type: Object,
default: function () {
- return { total: 0, size: 30, sortName: '' };
+ return { total: 0, size: 30, sortName: '' }
}
},
url: {
@@ -399,21 +590,21 @@
// 缂栬緫寮�濮�
type: Function,
default: function (row, column, index) {
- return true;
+ return true
}
},
endEditBefore: {
// 缁撴潫缂栬緫鍓�
type: Function,
default: function (row, column, index) {
- return true;
+ return true
}
},
endEditAfter: {
// 缁撴潫缂栬緫鍓�
type: Function,
default: function (row, column, index) {
- return true;
+ return true
}
},
ck: {
@@ -439,31 +630,34 @@
selectable: {
type: Function,
default: (row, index) => {
- return true;
+ return true
}
},
spanMethod: {
type: Function,
- default: ({ row, column, rowIndex, columnIndex }) => {
- }
+ default: ({ row, column, rowIndex, columnIndex }) => {}
},
- lazy: { //鏍戝舰琛ㄦ牸鏄惁榛樿寤惰繜鍔犺浇
+ lazy: {
+ //鏍戝舰琛ㄦ牸鏄惁榛樿寤惰繜鍔犺浇
type: Boolean,
- default: true,
+ default: true
},
- defaultExpandAll: { //鏍戝舰琛ㄦ牸鏄惁灞曞紑鎵�鏈�
+ defaultExpandAll: {
+ //鏍戝舰琛ㄦ牸鏄惁灞曞紑鎵�鏈�
type: Boolean,
default: false
},
- expandRowKeys: { //榛樿灞曞紑琛�
+ expandRowKeys: {
+ //榛樿灞曞紑琛�
type: Array,
default: () => {
return []
}
},
- rowParentField: { //鏍戝舰琛ㄦ牸鐖剁骇id
+ rowParentField: {
+ //鏍戝舰琛ㄦ牸鐖剁骇id
type: String,
- default: ""
+ default: ''
}
},
data() {
@@ -484,7 +678,7 @@
formatConfig: {},
// defaultColor: "",
// 2020.09.06璋冩暣table鍒楁暟鎹簮鐨勮儗鏅鑹�
- colors: ["primary", "success", "info", "warning", "danger"],// ["warning", "success", "danger", "info"],
+ colors: ['primary', 'success', 'info', 'warning', 'danger'], // ["warning", "success", "danger", "info"],
rule: {
phone: /^[1][3,4,5,6,7,8,9][0-9]{9}$/,
decimal: /(^[\-0-9][0-9]*(.[0-9]+)?)$/,
@@ -522,31 +716,31 @@
currentRow: {},
currentColumn: [],
fileInfo: [],
- uploadUrl: "",
+ uploadUrl: '',
uploadModel: false,
smallCell: true
- };
+ }
},
created() {
try {
- this.useTag = this.$global.table && this.$global.table.useTag;
- this.smallCell = this.$global.table && this.$global.table.smallCell;
+ this.useTag = this.$global.table && this.$global.table.useTag
+ this.smallCell = this.$global.table && this.$global.table.smallCell
} catch (error) {
- console.log(error.message);
+ console.log(error.message)
}
- this.realHeight = this.getHeight();
- this.realMaxHeight = this.getMaxHeight();
+ this.realHeight = this.getHeight()
+ this.realMaxHeight = this.getMaxHeight()
this.fxRight = this.columns.some((x) => {
- return x.fixed == 'right';
- });
+ return x.fixed == 'right'
+ })
//2021.09.21绉婚櫎寮哄埗鍥哄畾琛屽彿涓巆heckbox鍒�
if (
this.columns.some((x) => {
- return x.fixed && x.fixed != 'right';
+ return x.fixed && x.fixed != 'right'
})
) {
- this.fixed = true;
+ this.fixed = true
}
//2022.04.06浼樺寲table鍚堣鍥哄畾鍒楁樉绀�
// if (
@@ -563,184 +757,175 @@
// }
// 浠庡悗鍙板姞涓嬫媺妗嗙殑[鏄惁鍚敤鐨刔鏁版嵁婧�
- let keys = [];
- let columnBind = [];
- this.summaryData.push('鍚堣');
+ let keys = []
+ let columnBind = []
+ this.summaryData.push('鍚堣')
if (this.columnIndex) {
- this.summaryData.push(' ');
+ this.summaryData.push(' ')
}
- this.initCellStyleColumns();
+ this.initCellStyleColumns()
this.columns.forEach((x, _index) => {
-
if (!x.hidden) {
// this.summaryIndex[x.field] = _index;
// 2020.10.11淇姹傚拰鍒楅敊浣嶇殑闂
- this.summaryData.push('');
- this.summaryIndex[x.field] = this.summaryData.length - 1;
+ this.summaryData.push('')
+ this.summaryIndex[x.field] = this.summaryData.length - 1
}
// 姹傚拰
if (x.summary && !this.summary) {
- this.summary = true;
+ this.summary = true
}
if (x.children && Array.isArray(x.children)) {
- x.children.forEach(cl => {
+ x.children.forEach((cl) => {
if (cl.bind && cl.bind.key && (!cl.bind.data || cl.bind.data.length == 0)) {
- keys.push(cl.bind.key);
- cl.bind.valueType = cl.type;
- columnBind.push(cl.bind);
+ keys.push(cl.bind.key)
+ cl.bind.valueType = cl.type
+ columnBind.push(cl.bind)
}
})
} else if (x.bind && x.bind.key && (!x.bind.data || x.bind.data.length == 0)) {
// 鍐欏叆杩滅▼
- if (!x.bind.data) x.bind.data = [];
+ if (!x.bind.data) x.bind.data = []
if (x.bind.remote) {
- this.remoteColumns.push(x);
+ this.remoteColumns.push(x)
} else if (this.loadKey) {
- keys.push(x.bind.key);
- x.bind.valueType = x.type;
+ keys.push(x.bind.key)
+ x.bind.valueType = x.type
if (x.edit && x.edit.type) {
x.bind.editType = x.edit.type
}
- columnBind.push(x.bind);
+ columnBind.push(x.bind)
}
}
- });
+ })
if (keys.length > 0) {
- this.http
- .post('/api/Sys_Dictionary/GetVueDictionary', keys)
- .then((dic) => {
- dic.forEach((x) => {
- if (x.data.length > this.select2Count) {
- x.data.forEach((item) => {
- item.label = item.value;
- item.value = item.key;
- });
+ this.http.post('/api/Sys_Dictionary/GetVueDictionary', keys).then((dic) => {
+ dic.forEach((x) => {
+ if (x.data.length > this.select2Count) {
+ x.data.forEach((item) => {
+ item.label = item.value
+ item.value = item.key
+ })
+ }
+ const arrType = ['cascader', 'treeSelect']
+ columnBind.forEach((c) => {
+ if (arrType.indexOf(c.valueType) != -1 || arrType.indexOf(c.editType) != -1) {
+ this.columns.forEach((col) => {
+ if (col.bind && col.bind.key == c.key) {
+ col.bind.orginData = JSON.parse(JSON.stringify(x.data))
+ }
+ })
+ x.data = this.base.convertTree(x.data, (node, data, isRoot) => {
+ if (!node.inited) {
+ node.inited = true
+ node.label = node.value
+ node.value = node.key + ''
+ }
+ })
}
- const arrType = ['cascader', 'treeSelect'];
- columnBind.forEach((c) => {
- if ((arrType.indexOf(c.valueType) != -1 || arrType.indexOf(c.editType) != -1)) {
- this.columns.forEach(col => {
- if (col.bind && col.bind.key == c.key) {
- col.bind.orginData = JSON.parse(JSON.stringify(x.data));
- }
- })
- x.data = this.base.convertTree(x.data, (node, data, isRoot) => {
- if (!node.inited) {
- node.inited = true;
- node.label = node.value;
- node.value = node.key + '';
- }
- });
- }
- // 杞崲鏁版嵁婧愮殑绫诲瀷涓庡垪鐨勭被鍨嬩竴鑷�(2020.04.04)
- else if (c.key == x.dicNo && (c.valueType == "int" || c.valueType == "sbyte")) {
- x.data.forEach((d) => {
- // 2020.09.01澧炲姞瀵规暟瀛楃被鍨嬬殑浜屾鍒ゆ柇
- if (!isNaN(d.key)) {
- d.key = ~~d.key;
- }
- });
- }
- if (c.key == x.dicNo) c.data.push(...x.data);
- });
- });
- });
+ // 杞崲鏁版嵁婧愮殑绫诲瀷涓庡垪鐨勭被鍨嬩竴鑷�(2020.04.04)
+ else if (c.key == x.dicNo && (c.valueType == 'int' || c.valueType == 'sbyte')) {
+ x.data.forEach((d) => {
+ // 2020.09.01澧炲姞瀵规暟瀛楃被鍨嬬殑浜屾鍒ゆ柇
+ if (!isNaN(d.key)) {
+ d.key = ~~d.key
+ }
+ })
+ }
+ if (c.key == x.dicNo) c.data.push(...x.data)
+ })
+ })
+ })
}
- this.paginations.sort = this.pagination.sortName;
+ this.paginations.sort = this.pagination.sortName
// 2020.08.29澧炲姞鑷畾涔夊垎椤垫潯澶у皬
- Object.assign(this.paginations, this.pagination);
+ Object.assign(this.paginations, this.pagination)
if (this.pagination.size) {
- this.paginations.rows = this.pagination.size;
+ this.paginations.rows = this.pagination.size
}
this.enableEdit = this.columns.some((x) => {
- return x.hasOwnProperty('edit');
- });
+ return x.hasOwnProperty('edit')
+ })
let keyColumn = this.columns.find((x) => {
- return x.isKey;
- });
+ return x.isKey
+ })
if (keyColumn) {
- this.key = keyColumn.field;
+ this.key = keyColumn.field
}
- this.defaultLoadPage && this.load();
+ this.defaultLoadPage && this.load()
},
computed: {
filterColumns() {
return this.columns.filter((x, index) => {
if (!x.field) {
- x.field = x.title + index;
+ x.field = x.title + index
}
- return !x.hidden;
- });
+ return !x.hidden
+ })
}
},
methods: {
initCellStyleColumns() {
- this.columns.forEach(x => {
+ this.columns.forEach((x) => {
if (x.cellStyle) {
- this.cellStyleColumns[x.field] = x.cellStyle;
+ this.cellStyleColumns[x.field] = x.cellStyle
}
})
},
watchRowSelectChange(newLen, oldLen) {
if (newLen < oldLen && this.selectRows.length) {
- this.selectRows = [];
- this.$refs.table.clearSelection();
+ this.selectRows = []
+ this.$refs.table.clearSelection()
}
},
switchChange(val, row, column) {
//杩欓噷鍦ㄥ垵濮嬪寲鐨勬椂鍊欎篃浼氳Е鍙慶hange浜嬩欢
if (Object.keys(row).length <= 1) {
- return;
+ return
}
if (column.onChange) {
- column.onChange(val, row, column);
+ column.onChange(val, row, column)
}
},
inputKeyPress(row, column, $event, $e) {
- column.onKeyPress && column.onKeyPress(row, column, $event);
- this.getInputSummaries(null, null, $event, column);
+ column.onKeyPress && column.onKeyPress(row, column, $event)
+ this.getInputSummaries(null, null, $event, column)
},
extraClick(row, column) {
column.extra.click &&
- column.extra.click(
- row,
- column,
- this.url ? this.rowData : this.tableData
- );
+ column.extra.click(row, column, this.url ? this.rowData : this.tableData)
},
headerClick(column, event) {
if (this.clickEdit && this.edit.rowIndex != -1) {
if (
this.rowEndEdit(
- this.url
- ? this.rowData[this.edit.rowIndex]
- : this.tableData[this.edit.rowIndex],
+ this.url ? this.rowData[this.edit.rowIndex] : this.tableData[this.edit.rowIndex],
column
)
) {
- this.edit.rowIndex = -1;
+ this.edit.rowIndex = -1
}
}
// this.edit.rowIndex = -1;
},
rowDbClick(row, column, event) {
//2021.05.23澧炲姞鍙屽嚮琛屼簨浠�
- this.$emit('rowDbClick', { row, column, event });
+ this.$emit('rowDbClick', { row, column, event })
},
rowClick(row, column, event) {
//2022.02.20澧炲姞鐐瑰嚮鏃惰〃鏍煎弬鏁板垽鏂�
if (!column) {
- return;
+ return
}
//姝e湪缂栬緫鏃讹紝绂佹鍑哄彂rowClick浜嬩欢
if (this.edit.rowIndex == -1) {
- this.$emit('rowClick', { row, column, event });
+ this.$emit('rowClick', { row, column, event })
}
// 鐐瑰嚮琛屼簨浠�(2020.11.07)
if (!this.doubleEdit) {
- return;
+ return
}
// 鐐瑰嚮鍏朵粬琛屾椂锛屽鏋滅偣鍑荤殑琛屼笌姝e湪缂栬緫鐨勮鐩稿悓锛屼繚鎸佺紪杈戠姸鎬�
if (this.clickEdit && this.edit.rowIndex != -1) {
@@ -748,25 +933,25 @@
// 鐐瑰嚮鐨勫崟鍏冩牸濡傛灉涓嶅彲浠ョ紪杈戯紝鐩存帴缁撴潫缂栬緫
// 2020.10.12淇缁撴潫缂栬緫鏃讹紝element table楂樼増鏈睘鎬ц幏鍙栦笉鍒扮殑闂
let _col = this.columns.find((x) => {
- return x.field == ((event && event.property) || column.property);
- });
+ return x.field == ((event && event.property) || column.property)
+ })
if (_col && (!_col.edit || _col.readonly)) {
if (this.rowEndEdit(row, event)) {
- this.edit.rowIndex = -1;
+ this.edit.rowIndex = -1
}
}
- return;
+ return
}
if (this.rowEndEdit(row, event && event.property ? event : column)) {
- this.edit.rowIndex = -1;
+ this.edit.rowIndex = -1
}
//褰撴鍦ㄧ紪杈戯紝涓旂偣鍑诲埌鍏朵粬琛屾椂锛屽湪鍘熺紪杈戠殑琛岀粨鏉熺紪杈戝悗锛岃Е鍙戞柊琛岀殑rowClick浜嬩欢
//姝e湪缂栬緫鏃讹紝绂佹鍑哄彂rowClick浜嬩欢
if (this.edit.rowIndex == -1) {
- this.$emit('rowClick', { row, column, event });
+ this.$emit('rowClick', { row, column, event })
}
}
- this.rowBeginEdit(row, column);
+ this.rowBeginEdit(row, column)
},
dowloadFile(file) {
this.base.dowloadFile(
@@ -776,120 +961,118 @@
Authorization: this.$store.getters.getToken()
},
this.http.ipAddress
- );
+ )
},
getFilePath(pathSring, column) {
// 鑾峰彇琛ㄧ殑鍥剧墖涓庢枃浠舵樉绀�
- if (!pathSring) return [];
+ if (!pathSring) return []
// 澧炲姞鍥剧墖鑷畾涔夋搷浣�
// 杩斿洖鏍煎紡蹇呴』鏄痆{name:"鏂囦欢鍚�",path:"鍥剧墖鍏ㄨ矾寰勬垨base64鏍煎紡"}]
if (column.formatter) {
- return column.formatter(pathSring);
+ return column.formatter(pathSring)
}
- let filePath;
+ let filePath
if (column.base64 && pathSring.indexOf('data') != -1) {
filePath = (',' + pathSring)
.split(',data')
.filter((x) => {
- return x;
+ return x
})
.map((m) => {
- return 'data' + m;
- });
+ return 'data' + m
+ })
} else {
- filePath = pathSring.replace(/\\/g, '/').split(',');
+ filePath = pathSring.replace(/\\/g, '/').split(',')
}
- let fileInfo = [];
+ let fileInfo = []
for (let index = 0; index < filePath.length; index++) {
- let file = filePath[index];
+ let file = filePath[index]
// 2020.12.19澧炲姞base64鍥剧墖鏄剧ず
if (column.base64) {
fileInfo.push({
name: '',
- path:
- (file.indexOf('data') == -1 ? 'data:image/png;base64,' : '') +
- file
- });
+ path: (file.indexOf('data') == -1 ? 'data:image/png;base64,' : '') + file
+ })
} else if (file.indexOf('.') != -1) {
- let splitFile = file.split('/');
+ let splitFile = file.split('/')
if (splitFile.length > 0) {
fileInfo.push({
name: splitFile[splitFile.length - 1],
path: this.base.isUrl(file) ? file : this.http.ipAddress + file
- });
+ })
}
}
}
- return fileInfo;
+ return fileInfo
},
// 閲嶇疆table
reset() {
if (this.tableData && this.tableData.length > 0) {
- this.tableData.splice(0);
+ this.tableData.splice(0)
}
if (this.rowData && this.rowData.length > 0) {
- this.rowData.splice(0);
+ this.rowData.splice(0)
}
if (!this.paginationHide) {
- this.paginations.page = 1;
+ this.paginations.page = 1
// this.paginations.rows = 30;
if (this.paginations.wheres && this.paginations.wheres.length > 0) {
- this.paginations.wheres.splice(0);
+ this.paginations.wheres.splice(0)
}
}
- this.errorFiled = '';
- this.edit.columnIndex = -1;
- this.edit.rowIndex = -1;
+ this.errorFiled = ''
+ this.edit.columnIndex = -1
+ this.edit.rowIndex = -1
},
getHeight() {
// 娌℃湁瀹氫箟楂樺害涓庢渶澶ч珮搴︼紝浣跨敤table榛樿鍊�
if (!this.height && !this.maxHeight) {
- return null;
+ return null
}
// 瀹氫箟浜嗘渶澶ч珮搴﹀垯涓嶄娇鐢ㄩ珮搴�
if (this.maxHeight) {
- return null;
+ return null
}
// 浣跨敤褰撳墠瀹氫箟鐨勯珮搴�
- return this.height;
+ return this.height
},
getMaxHeight() {
// 娌℃湁瀹氫箟楂樺害涓庢渶澶ч珮搴︼紝浣跨敤table榛樿鍊�
if (!this.height && !this.maxHeight) {
- return null;
+ return null
}
// 瀹氫箟浜嗘渶澶ч珮搴︿娇鐢ㄦ渶澶ч珮搴�
if (this.maxHeight) {
- return this.maxHeight;
+ return this.maxHeight
}
// 涓嶄娇鐢ㄦ渶澶ч珮搴�
- return null;
+ return null
},
getSelectedOptions(column) {
if (column.bind && column.bind.data && column.bind.data.length > 0) {
- return column.bind.data;
+ return column.bind.data
}
- return [];
+ return []
},
formatterClick(row, column, event) {
if (column.click) {
- column.click(row, column, event);
- event.stopPropagation && event.stopPropagation();
+ column.click(row, column, event)
+ event.stopPropagation && event.stopPropagation()
} else {
- this.rowClick(row, column, event);
+ this.rowClick(row, column, event)
}
},
initIndex({ row, rowIndex }) {
if (this.index) {
- row.elementIndex = rowIndex;
+ row.elementIndex = rowIndex
}
// if (rowIndex%2!==0) {
// return "even-row";
// }
- return;
+ return
},
- toggleEdit(event) { },
+ toggleEdit(event) {},
setEditStatus(status) {
// this.columns.forEach((x) => {
// if (x.hasOwnProperty("edit")) {
@@ -900,162 +1083,154 @@
// 閫氳繃button鎸夐挳鍚敤缂栬緫
beginWithButtonEdit(scope) {
// url?rowData:tableData
- this.rowBeginEdit(scope.row, this.columns[scope.$index]);
+ this.rowBeginEdit(scope.row, this.columns[scope.$index])
},
rowBeginEdit(row, column) {
if (this.edit.rowIndex != -1) {
- return;
+ return
}
- let _row = this.columns.find((x) => x.field == column.property);
+ let _row = this.columns.find((x) => x.field == column.property)
if (_row) {
if (_row.readonly) {
- return;
+ return
}
if (
//涓嶈兘缂栬緫鐨勫瓧娈点�乻witch锛岀偣鍑讳笉寮�鍚惎缂栬緫鍔熻兘
!_row.edit ||
(_row.edit.keep && _row.edit.type == 'switch')
) {
- return;
+ return
}
}
- if (!this.enableEdit) return;
- _errMsg = '';
+ if (!this.enableEdit) return
+ _errMsg = ''
// 缂栬緫鍓�
this.columns
.filter((x) => {
- return x.bind && x.bind.data && x.bind.data.length;
+ return x.bind && x.bind.data && x.bind.data.length
})
.forEach((column) => {
- let val = row[column.field];
+ let val = row[column.field]
if (typeof column.bind.data[0].key == 'string') {
if (typeof val == 'number') {
- row[column.field] = row[column.field] + '';
+ row[column.field] = row[column.field] + ''
}
} else {
//澶氶�夋垨鑰呯骇鑱旂紪杈戝洖鍐�,2023.01.06
if (Array.isArray(val)) {
- val = val.map(v => {
+ val = val.map((v) => {
return v * 1
- });
- row[column.field] = val;
- }
- else if (typeof val == 'string' && val) {
- let _val = val * 1;
+ })
+ row[column.field] = val
+ } else if (typeof val == 'string' && val) {
+ let _val = val * 1
if (_val + '' === val) {
- row[column.field] = _val;
+ row[column.field] = _val
}
}
}
- });
- if (!this.beginEdit(row, column, row.elementIndex)) return;
+ })
+ if (!this.beginEdit(row, column, row.elementIndex)) return
if (row.hasOwnProperty('elementIndex')) {
if (this.edit.rowIndex == row.elementIndex) {
- return;
+ return
}
- this.edit.rowIndex = row.elementIndex;
+ this.edit.rowIndex = row.elementIndex
}
},
rowEndEdit(row, column, event) {
if (this.clickEdit && event) {
- return true;
+ return true
}
if (!this.enableEdit) {
if (!this.errorFiled) {
- if (
- this.edit.rowIndex != -1 &&
- !this.endEditAfter(row, column, this.edit.rowIndex)
- ) {
- return false;
+ if (this.edit.rowIndex != -1 && !this.endEditAfter(row, column, this.edit.rowIndex)) {
+ return false
}
- this.edit.rowIndex = -1;
+ this.edit.rowIndex = -1
}
- return true;
+ return true
}
if (!this.doubleEdit && event) {
- return true;
+ return true
}
- let _row = this.url
- ? this.rowData[this.edit.rowIndex]
- : this.tableData[this.edit.rowIndex];
+ let _row = this.url ? this.rowData[this.edit.rowIndex] : this.tableData[this.edit.rowIndex]
// 缁撴潫缂栬緫鍓�
- if (!this.endEditBefore(_row, column, this.edit.rowIndex)) return false;
+ if (!this.endEditBefore(_row, column, this.edit.rowIndex)) return false
if (this.edit.rowIndex != -1) {
//2022.06.26淇琛ㄦ牸鍐呭鍒囨崲鍚庤鏁颁笉涓�鑷存椂涓嶈兘缂栬緫鐨勯棶棰�
if (this.edit.rowIndex - 1 > (this.rowData || this.tableData).length) {
- this.edit.rowIndex = -1;
- return;
+ this.edit.rowIndex = -1
+ return
}
- let row = (this.url ? this.rowData : this.tableData)[
- this.edit.rowIndex
- ];
+ let row = (this.url ? this.rowData : this.tableData)[this.edit.rowIndex]
for (let index = 0; index < this.columns.length; index++) {
- const _column = this.columns[index];
+ const _column = this.columns[index]
if (_column.edit) {
if (!this.validateRow(row, _column)) {
- return;
+ return
}
}
}
}
- if (!this.endEditAfter(_row, column, this.edit.rowIndex)) return false;
- this.edit.rowIndex = -1;
- return true;
+ if (!this.endEditAfter(_row, column, this.edit.rowIndex)) return false
+ this.edit.rowIndex = -1
+ return true
},
validateRow(row, option1) {
if (!this.validateColum(option1, row)) {
- this.errorFiled = option1.field;
+ this.errorFiled = option1.field
// 2022.05.06 淇敼閿欒淇℃伅閲嶅鐨勯棶棰�
- this.$message.error(option1.title + _errMsg);
- return false;
+ this.$message.error(option1.title + _errMsg)
+ return false
}
- this.errorFiled = '';
- return true;
+ this.errorFiled = ''
+ return true
},
validateColum(option, data) {
- if (option.hidden || option.bind || !data) return true;
- let val = data[option.field];
+ if (option.hidden || option.bind || !data) return true
+ let val = data[option.field]
if (option.require || option.required) {
if (val != '0' && (val === '' || val === undefined)) {
if (!this.errorFiled) {
- _errMsg = '涓嶈兘涓虹┖';
+ _errMsg = '涓嶈兘涓虹┖'
}
- return false;
+ return false
}
}
if (!option.edit) {
- return true;
+ return true
}
- let editType = option.edit.type;
+ let editType = option.edit.type
// 楠岃瘉鏁板瓧
if (editType == 'int' || editType == 'decimal' || editType == 'number') {
- if (val == '' || val == undefined) return true;
+ if (val == '' || val == undefined) return true
if (editType == 'decimal') {
if (!this.rule.decimal.test(val)) {
- _errMsg = '鍙兘鏄暟瀛�';
- return false;
+ _errMsg = '鍙兘鏄暟瀛�'
+ return false
}
} else if (!this.rule.decimal.test(val)) {
- _errMsg = '鍙兘鏄暟瀛�';
- return false;
+ _errMsg = '鍙兘鏄暟瀛�'
+ return false
}
if (
option.edit.min != undefined &&
typeof option.edit.min === 'number' &&
val < option.edit.min
) {
- _errMsg = '涓嶈兘灏忎簬' + option.edit.min;
- return false;
+ _errMsg = '涓嶈兘灏忎簬' + option.edit.min
+ return false
}
if (
option.edit.max != undefined &&
typeof option.edit.max === 'number' &&
val > option.edit.max
) {
- _errMsg = '涓嶈兘澶т簬' + option.edit.max;
- return false;
+ _errMsg = '涓嶈兘澶т簬' + option.edit.max
+ return false
}
- return true;
+ return true
}
// 楠岃瘉瀛楃涓�
@@ -1065,30 +1240,28 @@
typeof option.edit.min === 'number' &&
val.length < option.edit.min
) {
- _errMsg = '鑷冲皯' + option.edit.min + '涓瓧绗�';
- return false;
+ _errMsg = '鑷冲皯' + option.edit.min + '涓瓧绗�'
+ return false
}
if (
option.edit.max != undefined &&
typeof option.edit.max === 'number' &&
val.length > option.edit.max
) {
- _errMsg = '鏈�澶�' + option.edit.max + '涓瓧绗�';
- return false;
+ _errMsg = '鏈�澶�' + option.edit.max + '涓瓧绗�'
+ return false
}
}
- return true;
+ return true
},
delRow() {
- let rows = this.getSelected();
- if (rows.length == 0) return this.$Message.error('璇烽�夋嫨瑕佸垹闄ょ殑琛�!');
+ let rows = this.getSelected()
+ if (rows.length == 0) return this.$Message.error('璇烽�夋嫨瑕佸垹闄ょ殑琛�!')
- let data = this.url ? this.rowData : this.tableData;
- let indexArr = this.getSelectedIndex();
+ let data = this.url ? this.rowData : this.tableData
+ let indexArr = this.getSelectedIndex()
if (indexArr.length == 0) {
- return this.$Message.error(
- "鍒犻櫎鎿嶄綔蹇呴』璁剧疆VolTable鐨勫睘鎬ndex='true'"
- );
+ return this.$Message.error("鍒犻櫎鎿嶄綔蹇呴』璁剧疆VolTable鐨勫睘鎬ndex='true'")
}
// if (indexArr.length == 0 || !this.key) {
// return this.$message.error(
@@ -1106,100 +1279,100 @@
} else {
for (let i = data.length - 1; i >= 0; i--) {
if (indexArr.indexOf(i) != -1) {
- data.splice(i, 1);
+ data.splice(i, 1)
}
}
}
- this.edit.rowIndex = -1;
- return rows;
+ this.edit.rowIndex = -1
+ return rows
},
addRow(row) {
if (!row) {
- row = {};
+ row = {}
}
this.columns.forEach((x) => {
// 2022.05.06 娣诲姞琛屾椂锛屽鏋滃垪鏈夌紪杈戝睘鎬э紝璁剧疆寮�鍚紪杈�(閬垮厤鍏抽棴缂栬緫鍚庯紝鏃犳硶鍐嶆鍚敤缂栬緫)??
//x.readonly = false;
if (!row.hasOwnProperty(x.field)) {
if (x.edit && x.edit.type == 'switch') {
- row[x.field] = x.type == 'bool' ? false : 0;
+ row[x.field] = x.type == 'bool' ? false : 0
} else if (!row.hidden) {
// 2020.09.06娣诲姞琛屾椂锛岃缃粯璁ゅ瓧娈�
- row[x.field] = undefined;
+ row[x.field] = undefined
}
}
- });
+ })
if (!this.url) {
- this.tableData.push(row);
- return;
+ this.tableData.push(row)
+ return
}
- this.rowData.push(row);
+ this.rowData.push(row)
},
viewImg(row, column, url, $event, index) {
- $event.stopPropagation();
- const imgs = this.getFilePath(row[column.field], column).map(x => { return x.path });
- this.$refs.viewer.show(imgs, index);
+ $event.stopPropagation()
+ const imgs = this.getFilePath(row[column.field], column).map((x) => {
+ return x.path
+ })
+ this.$refs.viewer.show(imgs, index)
//this.base.previewImg(url);
// window.open(row[column.field]);
},
link(row, column, $e) {
- $e.stopPropagation();
- this.$props.linkView(row, column);
+ $e.stopPropagation()
+ this.$props.linkView(row, column)
},
getSelected() {
- return this.selectRows;
+ return this.selectRows
},
getSelectedIndex() {
if (!this.index) {
// 鍙湁璁剧疆浜嗗睘鎬ndex鎵嶆湁绱㈠紩琛�
- return [];
+ return []
}
let indexArr = this.selectRows.map((x) => {
- return x.elementIndex;
- });
- return indexArr || [];
+ return x.elementIndex
+ })
+ return indexArr || []
},
GetTableDictionary(rows) {
// 鍒嗛〉鎴栧埛鏂版垨閲嶆柊缁戝畾鏁版嵁婧�
- if (this.remoteColumns.length == 0 || !rows || rows.length == 0) return;
- let remoteInfo = {};
+ if (this.remoteColumns.length == 0 || !rows || rows.length == 0) return
+ let remoteInfo = {}
for (let index = 0; index < this.remoteColumns.length; index++) {
- const column = this.remoteColumns[index];
+ const column = this.remoteColumns[index]
// column.bind.data.splice(0);
- let key = column.bind.key;
- let data = [];
+ let key = column.bind.key
+ let data = []
rows.forEach((row) => {
if (row[column.field] || row[column.field] == '0') {
if (data.indexOf(row[column.field]) == -1) {
- data.push(row[column.field]);
+ data.push(row[column.field])
}
}
- });
+ })
if (data.length > 0) {
- remoteInfo[key] = data;
+ remoteInfo[key] = data
}
}
- if (remoteInfo.length == 0) return;
+ if (remoteInfo.length == 0) return
// ha= Object.assign([], ha, hb)
- this.http
- .post('/api/Sys_Dictionary/GetTableDictionary', remoteInfo)
- .then((dic) => {
- dic.forEach((x) => {
- this.remoteColumns.forEach((column) => {
- if (column.bind.key == x.key) {
- column.bind.data = Object.assign([], column.bind.data, x.data);
- // column.bind.data.push(...x.data);
- }
- });
- });
- this.$emit('dicInited', dic);
- });
+ this.http.post('/api/Sys_Dictionary/GetTableDictionary', remoteInfo).then((dic) => {
+ dic.forEach((x) => {
+ this.remoteColumns.forEach((column) => {
+ if (column.bind.key == x.key) {
+ column.bind.data = Object.assign([], column.bind.data, x.data)
+ // column.bind.data.push(...x.data);
+ }
+ })
+ })
+ this.$emit('dicInited', dic)
+ })
},
load(query, isResetPage) {
// isResetPage閲嶇疆鍒嗛〉鏁版嵁
- if (!this.url) return;
+ if (!this.url) return
if (isResetPage) {
- this.resetPage();
+ this.resetPage()
}
let param = {
page: this.paginations.page,
@@ -1207,11 +1380,11 @@
sort: this.paginations.sort,
order: this.paginations.order,
wheres: [] // 鏌ヨ鏉′欢锛屾牸寮忎负[{ name: "瀛楁", value: "xx" }]
- };
- let status = true;
+ }
+ let status = true
// 鍚堝苟鏌ヨ淇℃伅(鍖呮煡璇㈠垎椤点�佹帓搴忋�佹煡璇㈡潯浠剁瓑)
if (query) {
- param = Object.assign(param, query);
+ param = Object.assign(param, query)
}
/* 鏌ヨ鍓嶅鐞�(濡傛灉闇�瑕佹煡璇㈡潯浠讹紝瀹炵幇缁勪欢鏂规硶loadBefore鏂规硶鍗冲彲:
loadBefore=(param, callBack)=>{
@@ -1220,189 +1393,190 @@
})
*/
this.$emit('loadBefore', param, (result) => {
- status = result;
- });
- if (!status) return;
+ status = result
+ })
+ if (!status) return
if (param.wheres && param.wheres instanceof Array) {
- param.wheres = JSON.stringify(param.wheres);
+ param.wheres = JSON.stringify(param.wheres)
}
- this.loading = true;
- let url = param.url || this.url;
- param.url = undefined;
+ this.loading = true
+ let url = param.url || this.url
+ param.url = undefined
this.http.post(url, param).then(
(data) => {
//2021.06.04淇tree涓嶅埛鏂扮殑闂
if (this.rowKey) {
- this.randomTableKey++;
- this.rowData.splice(0);
+ this.randomTableKey++
+ this.rowData.splice(0)
}
- this.loading = false;
- let rows = data.rows || [];
+ this.loading = false
+ let rows = data.rows || []
// 鏌ヨ杩斿洖缁撴灉鍚庡鐞�
// 2020.10.30澧炲姞鏌ヨ鍚庤繑鍥炴墍鏈夌殑鏌ヨ淇℃伅
this.$emit(
'loadAfter',
rows,
(result) => {
- status = result;
+ status = result
},
data
- );
- if (!status) return;
- this.GetTableDictionary(data.rows);
+ )
+ if (!status) return
+ this.GetTableDictionary(data.rows)
if (this.rowParentField) {
- rows = this.base.convertTree(rows, null, this.rowKey, this.rowParentField);
+ rows = this.base.convertTree(rows, null, this.rowKey, this.rowParentField)
}
- this.rowData = rows;
- this.paginations.total = data.total;
+ this.rowData = rows
+ this.paginations.total = data.total
// 鍚堣
- this.getSummaries(data);
+ this.getSummaries(data)
// this.$nextTick(() => {
// this.$refs.table.doLayout();
// });
},
(error) => {
- this.loading = false;
+ this.loading = false
// this.$Message.error(error || "缃戠粶寮傚父");
}
- );
+ )
}, // 鑾峰彇缁熻
getSummaries(data) {
- if (!this.summary || !data.summary) return;
- this.summaryData.splice(0);
+ if (!this.summary || !data.summary) return
+ this.summaryData.splice(0)
// 寮�鍚簡琛屽彿鐨勶紝+1
if (this.columnIndex) {
- this.summaryData.push('');
+ this.summaryData.push('')
}
// 濡傛灉鏈塩heckbox锛屽簲璇ョ畻浣滄槸绗竴琛�
if (this.ck) {
- this.summaryData.push('');
+ this.summaryData.push('')
}
this.columns.forEach((col) => {
if (col.children && col.children.length) {
col.children.forEach((item) => {
- this.getColumnSummaries(item, data);
- });
+ this.getColumnSummaries(item, data)
+ })
} else {
- this.getColumnSummaries(col, data);
+ this.getColumnSummaries(col, data)
}
- });
+ })
if (this.summaryData.length > 0 && this.summaryData[0] == '') {
- this.summaryData[0] = '鍚堣';
+ this.summaryData[0] = '鍚堣'
}
},
getColumnSummaries(col, data) {
if (!col.hidden) {
if (data.summary.hasOwnProperty(col.field)) {
- let sum = data.summary[col.field];
+ let sum = data.summary[col.field]
//2024.01.07澧炲姞鑷畾涔夊悎璁℃牸寮忓寲
if (col.summaryFormatter) {
sum = col.summaryFormatter(sum, col, data, this.summaryData)
} else if (sum) {
- sum =
- (sum * 1.0).toFixed(col.numberLength || 2).replace('.00', '') *
- 1.0;
+ sum = (sum * 1.0).toFixed(col.numberLength || 2).replace('.00', '') * 1.0
}
- this.summaryData.push(sum);
+ this.summaryData.push(sum)
} else {
- this.summaryData.push('');
+ this.summaryData.push('')
}
}
},
- getInputChangeSummaries() { },
+ getInputChangeSummaries() {},
handleSizeChange(val) {
- this.paginations.size = val;
- this.paginations.rows = val;
- this.load();
+ this.paginations.size = val
+ this.paginations.rows = val
+ this.load()
},
handleCurrentChange(val) {
- this.paginations.page = val;
- this.load();
+ this.paginations.page = val
+ this.load()
},
sortChange(sort) {
- this.paginations.sort = sort.prop;
- this.paginations.order = sort.order == 'ascending' ? 'asc' : 'desc';
- this.load();
+ this.paginations.sort = sort.prop
+ this.paginations.order = sort.order == 'ascending' ? 'asc' : 'desc'
+ this.load()
},
resetPage() {
// 閲嶇疆鏌ヨ鍒嗛〉
// this.paginations.rows = 30;
- this.paginations.page = 1;
+ this.paginations.page = 1
},
selectionChange(selection) {
// console.log(selection);
// 閫夋嫨琛屼簨浠�,鍙湁鍗曢�夋墠瑙﹀彂
- this.selectRows = selection;
+ this.selectRows = selection
if (this.single) {
if (selection.length == 1) {
- this.$emit('rowChange', selection[0]);
+ this.$emit('rowChange', selection[0])
}
if (selection.length > 1) {
- let _row = selection[selection.length - 1];
- this.$refs.table.toggleRowSelection(selection[0]);
- this.selectRows = [_row];
+ let _row = selection[selection.length - 1]
+ this.$refs.table.toggleRowSelection(selection[0])
+ this.selectRows = [_row]
}
}
// 灏唖electionchange鏆撮湶鍑哄幓
- this.$emit('selectionChange', selection);
+ this.$emit('selectionChange', selection)
},
getColor(row, column) {
- let val = row[column.field];
+ let val = row[column.field]
if (column.getColor && typeof column.getColor === 'function') {
- let _color = column.getColor(row, column);
+ let _color = column.getColor(row, column)
if (_color) {
- return _color;
+ return _color
}
}
if (!val && val != '0') {
- return undefined;
+ return undefined
}
if (!this.formatConfig[column.field]) {
- this.formatConfig[column.field] = [val];
- return this.colors[0];
+ this.formatConfig[column.field] = [val]
+ return this.colors[0]
}
- let index = this.formatConfig[column.field].indexOf(val);
+ let index = this.formatConfig[column.field].indexOf(val)
if (index != -1) {
- return this.colors[index];
+ return this.colors[index]
}
if (this.formatConfig[column.field].length > 5) {
- return '';
+ return ''
}
if (index == -1) {
- this.formatConfig[column.field].push(val);
- index = this.formatConfig[column.field].length - 1;
+ this.formatConfig[column.field].push(val)
+ index = this.formatConfig[column.field].length - 1
}
- return this.colors[index] || 'info';
+ return this.colors[index] || 'info'
},
formatterDate(row, column) {
- return (row[column.field] || '').substr(0, 10);
+ return (row[column.field] || '').substr(0, 10)
},
formatter(row, column, template) {
- if (!template) return row[column.property];
- let val = row[column.field];
- if (!val && val != 0) return val;
+ if (!template) return row[column.property]
+ let val = row[column.field]
+ if (!val && val != 0) return val
// 鏄惁鍊�
if (column.edit && column.edit.type == 'switch') {
- return val ? '鏄�' : '鍚�';
+ return val ? '鏄�' : '鍚�'
}
if (!column.bind || !column.bind.data) {
- return row[column.field];
+ return row[column.field]
}
- if (column.edit && (column.edit.type == 'selectList'
- || column.edit.type == 'treeSelect'
- || column.bind.type == "cascader"
- || column.bind.type == "treeSelect")) {
+ if (
+ column.edit &&
+ (column.edit.type == 'selectList' ||
+ column.edit.type == 'treeSelect' ||
+ column.bind.type == 'cascader' ||
+ column.bind.type == 'treeSelect')
+ ) {
if (!Array.isArray(val)) {
- row[column.field] = (val + '').split(',');
+ row[column.field] = (val + '').split(',')
} else {
- val = val.join(',');
+ val = val.join(',')
}
- return this.getSelectFormatter(column, val);
+ return this.getSelectFormatter(column, val)
}
// 缂栬緫澶氶�塼able鏄剧ず
// if (
@@ -1412,200 +1586,199 @@
// column.bind.type == "treeSelect"
// ) {
if (typeof val === 'string' && val.indexOf(',') != -1) {
- return this.getSelectFormatter(column, val);
+ return this.getSelectFormatter(column, val)
}
//}
let source = column.bind.data.filter((x) => {
// return x.key != "" && x.key == val;
// 2020.06.06淇鍗曠嫭浣跨敤table缁勪欢鏃�,key涓烘暟瀛�0鏃惰浆鎹㈡垚鏂囨湰澶辫触鐨勯棶棰�
- return x.key !== '' && x.key !== undefined && x.key + '' === val + '';
- });
- if (source && source.length > 0) val = source[0].label || source[0].value;
- return val;
+ return x.key !== '' && x.key !== undefined && x.key + '' === val + ''
+ })
+ if (source && source.length > 0) val = source[0].label || source[0].value
+ return val
},
getSelectFormatter(column, val) {
// 缂栬緫澶氶�塼able鏄剧ず
- let valArr = (val + "").split(",");
+ let valArr = (val + '').split(',')
for (let index = 0; index < valArr.length; index++) {
- (column.bind.orginData && column.bind.orginData.length
+ ;(column.bind.orginData && column.bind.orginData.length
? column.bind.orginData
- : column.bind.data)
- .forEach((x) => {
- // 2020.06.06淇鏁版嵁婧愪负selectList鏃�,key涓烘暟瀛�0鏃朵笉鑳借浆鎹㈡枃鏈殑闂
- if (x.key !== "" && x.key !== undefined && x.key + "" == valArr[index] + "") {
- valArr[index] = x.label || x.value;
- }
- });
+ : column.bind.data
+ ).forEach((x) => {
+ // 2020.06.06淇鏁版嵁婧愪负selectList鏃�,key涓烘暟瀛�0鏃朵笉鑳借浆鎹㈡枃鏈殑闂
+ if (x.key !== '' && x.key !== undefined && x.key + '' == valArr[index] + '') {
+ valArr[index] = x.label || x.value
+ }
+ })
}
- return valArr.join(",");
+ return valArr.join(',')
},
onChange(scope, val, event, column) {
// 2020.09.03淇onChange涓嶈Е鍙戠殑闂
- let row = scope.row;
+ let row = scope.row
if (column.onChange && !column.onChange(row, val, event)) {
- return;
+ return
}
// 杈撳叆妗嗘眰鍜屽疄鏃惰绠�
- this.getInputSummaries(scope, val, event, column);
+ this.getInputSummaries(scope, val, event, column)
},
// input杈撳叆瀹炴椂姹傚拰
getInputSummaries(scope, val, event, column) {
// column鍒楄缃簡summary灞炴�х殑鎵嶈绠楀��
- if (!column.summary) return;
- let sum = 0;
+ if (!column.summary) return
+ let sum = 0
// let _index = 0;
- (this.url ? this.rowData : this.tableData).forEach((x, index) => {
+ ;(this.url ? this.rowData : this.tableData).forEach((x, index) => {
if (x.hasOwnProperty(column.field) && !isNaN(x[column.field])) {
// _index = index;
- sum += x[column.field] * 1;
+ sum += x[column.field] * 1
}
- });
+ })
if (sum) {
if (column.summary == 'avg') {
- sum = sum / (this.rowData.length || this.tableData.length || 1);
+ sum = sum / (this.rowData.length || this.tableData.length || 1)
}
- sum =
- (sum * 1.0).toFixed(column.numberLength || 2).replace('.00', '') *
- 1.0;
+ sum = (sum * 1.0).toFixed(column.numberLength || 2).replace('.00', '') * 1.0
}
- this.summaryData[this.summaryIndex[column.field]] = sum;
+ this.summaryData[this.summaryIndex[column.field]] = sum
},
getSummaryData({ columns, data }) {
- return this.summaryData;
+ return this.summaryData
},
getCellStyle(row) {
// 2020.12.13澧炲姞璁剧疆鍗曞厓鏍奸鑹�
if (row.column.property) {
return (
this.cellStyleColumns[row.column.property] &&
- this.cellStyleColumns[row.column.property](
- row.row,
- row.rowIndex,
- row.columnIndex
- )
- );
+ this.cellStyleColumns[row.column.property](row.row, row.rowIndex, row.columnIndex)
+ )
}
},
compareDate(date1, date2) {
if (!date2) {
- return true;
+ return true
}
- return (
- date1.valueOf() <
- (typeof date2 == 'number' ? date2 : new Date(date2).valueOf())
- );
+ return date1.valueOf() < (typeof date2 == 'number' ? date2 : new Date(date2).valueOf())
},
getDateOptions(date, item) {
//2021.07.17璁剧疆鏃堕棿鍙�夎寖鍥�
if ((!item.min && !item.max) || !date) {
- return false;
+ return false
}
if (item.min && item.min.indexOf(' ') == -1) {
//涓嶈缃椂鍒嗙锛屽悗闈細鑷姩鍔犱笂 08:00
- item.min = item.min + ' 00:00:000';
+ item.min = item.min + ' 00:00:000'
}
- return (
- this.compareDate(date, item.min) || !this.compareDate(date, item.max)
- );
+ return this.compareDate(date, item.min) || !this.compareDate(date, item.max)
},
getDateFormat(column) {
if (column.format) {
- return column.format;
+ return column.format
}
- if (column.edit.type == "month") {
- return "YYYY-MM";
+ if (column.edit.type == 'month') {
+ return 'YYYY-MM'
}
//瑙乭ttps://day.js.org/docs/zh-CN/display/format
- return column.edit.type == 'date' ? 'YYYY-MM-DD' : 'YYYY-MM-DD HH:mm:ss';
+ return column.edit.type == 'date' ? 'YYYY-MM-DD' : 'YYYY-MM-DD HH:mm:ss'
},
userSelect(selection, row) {
- this.selectRows = selection;
+ this.selectRows = selection
if (!this.single) {
- this.$emit('rowChange', { row, selection });
+ this.$emit('rowChange', { row, selection })
}
},
isEmptyTag(row, column) {
if (!row[column.field] && row[column.field] != '0') {
- return 'empty-tag';
+ return 'empty-tag'
}
- return '';
+ return ''
},
filterChildrenColumn(children) {
if (!children) {
- return [];
+ return []
}
return children.filter((x) => {
- return !x.hidden;
- });
+ return !x.hidden
+ })
},
initColumnDisabled(row, column) {
- return column.getDisabled && column.getDisabled(row, column);
+ return column.getDisabled && column.getDisabled(row, column)
},
showUpload(row, column) {
- this.fileInfo = (row[column.field] || '').split(",")
- .filter(x => { return x })
- .map(item => {
- return { path: item, name: "" };
+ this.fileInfo = (row[column.field] || '')
+ .split(',')
+ .filter((x) => {
+ return x
})
- this.currentRow = row;
- this.currentColumn = column;
+ .map((item) => {
+ return { path: item, name: '' }
+ })
+ this.currentRow = row
+ this.currentColumn = column
if (this.currentColumn.edit.autoUpload === undefined) {
- this.currentColumn.edit.autoUpload = true;
+ this.currentColumn.edit.autoUpload = true
}
if (this.currentColumn.edit.multiple === undefined) {
- this.currentColumn.edit.multiple = false;
+ this.currentColumn.edit.multiple = false
}
if (this.currentColumn.edit.url === undefined) {
this.uploadUrl = 'api/' + (this.url || '').replace('/api', 'api').split('/')[1] + '/upload'
} else {
- this.uploadUrl = this.currentColumn.edit.url;
+ this.uploadUrl = this.currentColumn.edit.url
}
- this.uploadModel = true;
+ this.uploadModel = true
},
uploadAfter(result, files) {
- this.currentColumn.uploadAfter && this.currentColumn.uploadAfter(result, files);
- return true;
+ this.currentColumn.uploadAfter && this.currentColumn.uploadAfter(result, files)
+ return true
},
uploadBefore(files, params) {
- this.currentColumn.uploadBefore && this.currentColumn.uploadBefore(files, this.currentRow, params);
- return true;
+ this.currentColumn.uploadBefore &&
+ this.currentColumn.uploadBefore(files, this.currentRow, params)
+ return true
},
saveUpload() {
//鐢熸垚淇濆瓨鍚庤繑鍥炵殑璺緞
let arr = this.fileInfo.map((x) => {
if (x.path) {
- return x.path;
+ return x.path
}
- return result.data + x.name;
- });
+ return result.data + x.name
+ })
- this.currentRow[this.currentColumn.field] = arr.join(",");
- this.uploadModel = false;
- return true;
+ this.currentRow[this.currentColumn.field] = arr.join(',')
+ this.uploadModel = false
+ return true
},
- expandChange(row, expandedRows) { // 褰撶敤鎴峰鏌愪竴琛屽睍寮�鎴栬�呭叧闂殑鏃�
+ expandChange(row, expandedRows) {
+ // 褰撶敤鎴峰鏌愪竴琛屽睍寮�鎴栬�呭叧闂殑鏃�
if (!this.defaultExpandAll && !this.lazy) {
if (expandedRows) {
if (this.expandRowKeys.indexOf(row[this.rowKey]) == -1) {
this.expandRowKeys.push(row[this.rowKey])
}
} else {
- let _index = this.expandRowKeys.findIndex(x => { return x == row[this.rowKey] });
+ let _index = this.expandRowKeys.findIndex((x) => {
+ return x == row[this.rowKey]
+ })
if (_index != -1) {
- this.expandRowKeys.splice(_index, 1);
+ this.expandRowKeys.splice(_index, 1)
}
}
}
},
handleImageError($e) {
- $e.target.src = this.defaultImg;
+ $e.target.src = this.defaultImg
},
cellSpanMethod({ row, column, rowIndex, columnIndex }) {
- return this.spanMethod({ row, column, rowIndex, columnIndex }, this.url ? this.rowData : this.tableData)
+ return this.spanMethod(
+ { row, column, rowIndex, columnIndex },
+ this.url ? this.rowData : this.tableData
+ )
}
}
-});
+})
</script>
<style lang="less" scoped>
.vol-table {
@@ -1643,7 +1816,7 @@
.e-item {
display: flex;
- >div:first-child {
+ > div:first-child {
flex: 1;
}
}
@@ -1782,7 +1955,6 @@
.small-table ::v-deep(.el-table__cell) {
padding: 6px 0;
font-size: 13px;
-
}
.small-table ::v-deep(.cell-tag) {
--
Gitblit v1.9.3