|
|
@@ -2,11 +2,22 @@
|
|
|
<div v-if="!tableHidden && dynamicShow" class="dynamic-form-table">
|
|
|
<template v-if="columns && columns.length > 0">
|
|
|
<!--================表内和弹窗模式=================================-->
|
|
|
- <div v-if="mode === 'inner' || mode === 'dialog'" class="dynamic-form-table__inner panel panel-info">
|
|
|
+ <div
|
|
|
+ v-if="mode === 'inner' || mode === 'dialog'"
|
|
|
+ class="dynamic-form-table__inner panel panel-info"
|
|
|
+ >
|
|
|
<div class="panel-heading ibps-clearfix">
|
|
|
- <div v-if="!formDialogVisible" class="ibps-fl dynamic-form-table__label table-tetle-style">{{ field.label }}</div>
|
|
|
+ <div
|
|
|
+ v-if="!formDialogVisible"
|
|
|
+ class="ibps-fl dynamic-form-table__label table-tetle-style"
|
|
|
+ >
|
|
|
+ {{ field.label }}
|
|
|
+ </div>
|
|
|
<!--弹窗模式对话框-->
|
|
|
- <div v-if="toolbarButtons && toolbarButtons.length > 0" class="ibps-fr hidden-print">
|
|
|
+ <div
|
|
|
+ v-if="toolbarButtons && toolbarButtons.length > 0"
|
|
|
+ class="ibps-fr hidden-print"
|
|
|
+ >
|
|
|
<el-button-group>
|
|
|
<el-button
|
|
|
v-for="(button, index) in toolbarButtons"
|
|
|
@@ -24,40 +35,95 @@
|
|
|
<el-table
|
|
|
ref="elTable"
|
|
|
:data="copDataModel"
|
|
|
- :header-cell-style="{ color: '#000', 'font-size': '14px', padding: '4px 0' }"
|
|
|
+ :header-cell-style="{
|
|
|
+ color: '#000',
|
|
|
+ 'font-size': '14px',
|
|
|
+ padding: '4px 0',
|
|
|
+ }"
|
|
|
:row-class-name="tableRowClassName"
|
|
|
:show-summary="showSummary"
|
|
|
:sum-text="sumText"
|
|
|
- :summary-method="hasSummaryMethod ? summaryMethod : null"
|
|
|
+ :summary-method="
|
|
|
+ hasSummaryMethod ? summaryMethod : null
|
|
|
+ "
|
|
|
border
|
|
|
@selection-change="handleSelectionChange"
|
|
|
>
|
|
|
- <el-table-column v-if="!tableReadonly" type="selection" width="50" />
|
|
|
+ <el-table-column
|
|
|
+ v-if="!tableReadonly"
|
|
|
+ type="selection"
|
|
|
+ width="50"
|
|
|
+ />
|
|
|
<el-table-column
|
|
|
v-if="field.field_options.index"
|
|
|
type="index"
|
|
|
- :label="field.field_options.index_name ? field.field_options.index_name : '序号'"
|
|
|
- :width="field.field_options.index_width ? field.field_options.index_width : 50"
|
|
|
+ :label="
|
|
|
+ field.field_options.index_name
|
|
|
+ ? field.field_options.index_name
|
|
|
+ : '序号'
|
|
|
+ "
|
|
|
+ :width="
|
|
|
+ field.field_options.index_width
|
|
|
+ ? field.field_options.index_width
|
|
|
+ : 50
|
|
|
+ "
|
|
|
:index="indexMethod"
|
|
|
/>
|
|
|
<template v-for="(column, j) in displayColumns">
|
|
|
<el-table-column
|
|
|
- v-if="!columnHidden(column) && column.field_type != 'desc' && column.label != ''"
|
|
|
+ v-if="
|
|
|
+ !columnHidden(column) &&
|
|
|
+ column.field_type != 'desc' &&
|
|
|
+ column.label != ''
|
|
|
+ "
|
|
|
:key="j"
|
|
|
show-overflow-tooltip
|
|
|
:prop="column.name"
|
|
|
- :width="column.field_options.custom_class || null"
|
|
|
+ :width="
|
|
|
+ column.field_options.custom_class || null
|
|
|
+ "
|
|
|
>
|
|
|
<template slot="header">
|
|
|
- {{ $utils.isNotEmpty(column.field_options.units) ? column.label + '(' + column.field_options.units + ')' : column.label }}
|
|
|
- <ibps-help v-if="column && column.desc && descPosition === 'lableIcon'" type="tooltip" :content="$utils.formatText(column.desc)" />
|
|
|
+ {{
|
|
|
+ $utils.isNotEmpty(
|
|
|
+ column.field_options.units
|
|
|
+ )
|
|
|
+ ? column.label +
|
|
|
+ "(" +
|
|
|
+ column.field_options.units +
|
|
|
+ ")"
|
|
|
+ : column.label
|
|
|
+ }}
|
|
|
+ <ibps-help
|
|
|
+ v-if="
|
|
|
+ column &&
|
|
|
+ column.desc &&
|
|
|
+ descPosition === 'lableIcon'
|
|
|
+ "
|
|
|
+ type="tooltip"
|
|
|
+ :content="
|
|
|
+ $utils.formatText(column.desc)
|
|
|
+ "
|
|
|
+ />
|
|
|
</template>
|
|
|
<template slot-scope="scope">
|
|
|
- <template v-if="copDataModelCont && copDataModelCont.length > 0 && dynamicShow">
|
|
|
+ <template
|
|
|
+ v-if="
|
|
|
+ copDataModelCont &&
|
|
|
+ copDataModelCont.length > 0 &&
|
|
|
+ dynamicShow
|
|
|
+ "
|
|
|
+ >
|
|
|
<ibps-dynamic-form-table-item
|
|
|
:ref="'formItem' + column.name"
|
|
|
:key="scope.$index + j"
|
|
|
- :models.sync="copDataModelCont[scope.$index + (currentPage - 1) * pageSize]"
|
|
|
+ :models.sync="
|
|
|
+ copDataModelCont[
|
|
|
+ scope.$index +
|
|
|
+ (currentPage - 1) *
|
|
|
+ pageSize
|
|
|
+ ]
|
|
|
+ "
|
|
|
:rights.sync="columnsRights"
|
|
|
:form-data="models"
|
|
|
:field="column"
|
|
|
@@ -80,36 +146,70 @@
|
|
|
fixed="right"
|
|
|
class-name="hidden-print"
|
|
|
label="操作栏目"
|
|
|
- :width="colWidth ? colWidth : (manageButtons.length == 1 ? '85' : '160')"
|
|
|
+ :width="
|
|
|
+ colWidth
|
|
|
+ ? colWidth
|
|
|
+ : manageButtons.length == 1
|
|
|
+ ? '85'
|
|
|
+ : '160'
|
|
|
+ "
|
|
|
>
|
|
|
<template slot-scope="scope">
|
|
|
<el-dropdown v-if="manageButtons.length > 3">
|
|
|
- <ibps-icon name="chevron-circle-down" size="28" class="hidden-print" />
|
|
|
- <el-dropdown-menu slot="dropdown" class="ibps-table-dropdown-menu" style="margin-top: 0.02rem">
|
|
|
+ <ibps-icon
|
|
|
+ name="chevron-circle-down"
|
|
|
+ size="28"
|
|
|
+ class="hidden-print"
|
|
|
+ />
|
|
|
+ <el-dropdown-menu
|
|
|
+ slot="dropdown"
|
|
|
+ class="ibps-table-dropdown-menu"
|
|
|
+ style="margin-top: 0.02rem"
|
|
|
+ >
|
|
|
<ibps-toolbar
|
|
|
:actions="manageButtons"
|
|
|
:socpe="thatSocpe"
|
|
|
:data="scope.row"
|
|
|
position="manage"
|
|
|
class="hidden-print"
|
|
|
- @action-event="(action) => handleActionEvent(action, scope.$index)"
|
|
|
+ @action-event="
|
|
|
+ (action) =>
|
|
|
+ handleActionEvent(
|
|
|
+ action,
|
|
|
+ scope.$index
|
|
|
+ )
|
|
|
+ "
|
|
|
/>
|
|
|
</el-dropdown-menu>
|
|
|
</el-dropdown>
|
|
|
<template v-else>
|
|
|
- <template v-for="(button, index) in manageButtons">
|
|
|
+ <template
|
|
|
+ v-for="(button, index) in manageButtons"
|
|
|
+ >
|
|
|
<el-link
|
|
|
:key="index"
|
|
|
:icon="button.icon"
|
|
|
:type="button.type"
|
|
|
:underline="false"
|
|
|
- @click="handleActionEvent(button, scope.$index)"
|
|
|
+ @click="
|
|
|
+ handleActionEvent(
|
|
|
+ button,
|
|
|
+ scope.$index
|
|
|
+ )
|
|
|
+ "
|
|
|
>{{ button.label }}</el-link>
|
|
|
<!-- <el-button plain size="mini" :key="index" :type="button.type" @click="handleActionEvent(button, scope.$index)">
|
|
|
{{ button.label }}
|
|
|
</el-button> -->
|
|
|
<!-- (manageButtons.length === 3 && index === 0) || index === 1 -->
|
|
|
- <el-divider v-if="index !== manageButtons.length - 1" :key="index" direction="vertical" />
|
|
|
+ <el-divider
|
|
|
+ v-if="
|
|
|
+ index !==
|
|
|
+ manageButtons.length - 1
|
|
|
+ "
|
|
|
+ :key="index"
|
|
|
+ direction="vertical"
|
|
|
+ />
|
|
|
</template>
|
|
|
</template>
|
|
|
</template>
|
|
|
@@ -117,7 +217,10 @@
|
|
|
</el-table>
|
|
|
<!-- 分页 -->
|
|
|
<el-pagination
|
|
|
- v-if="needPage !== 'N' && (mode === 'dialog' || mode === 'inner')"
|
|
|
+ v-if="
|
|
|
+ needPage !== 'N' &&
|
|
|
+ (mode === 'dialog' || mode === 'inner')
|
|
|
+ "
|
|
|
:current-page="currentPage"
|
|
|
:page-size="pageSize"
|
|
|
:page-sizes="pageSizeOptions"
|
|
|
@@ -133,15 +236,53 @@
|
|
|
<template v-else-if="mode === 'block'">
|
|
|
<template v-if="dataModel && dataModel.length > 0">
|
|
|
<template v-for="(data, index) in dataModel">
|
|
|
- <div :key="index" class="dynamic-form-table__block panel panel-info">
|
|
|
+ <div
|
|
|
+ :key="index"
|
|
|
+ class="dynamic-form-table__block panel panel-info"
|
|
|
+ >
|
|
|
<div class="panel-heading ibps-clearfix">
|
|
|
<!--块模式:工具栏-->
|
|
|
- <div class="ibps-fl dynamic-form-table__label"><el-badge v-if="field.field_options.index" :value="index + 1" type="primary" style="top: 0.3em" />{{ field.label }}</div>
|
|
|
- <div v-if="toolbarButtons && toolbarButtons.length > 0" class="ibps-fr">
|
|
|
+ <div class="ibps-fl dynamic-form-table__label">
|
|
|
+ <el-badge
|
|
|
+ v-if="field.field_options.index"
|
|
|
+ :value="index + 1"
|
|
|
+ type="primary"
|
|
|
+ style="top: 0.3em"
|
|
|
+ />{{ field.label }}
|
|
|
+ </div>
|
|
|
+ <div
|
|
|
+ v-if="
|
|
|
+ toolbarButtons &&
|
|
|
+ toolbarButtons.length > 0
|
|
|
+ "
|
|
|
+ class="ibps-fr"
|
|
|
+ >
|
|
|
<el-button-group>
|
|
|
- <template v-for="(button, b) in toolbarButtons">
|
|
|
- <template v-if="!(button.key === 'remove' && dataModel.length === 1)">
|
|
|
- <el-button :key="b" :type="button.type" :icon="button.icon" @click="handleActionEvent(button, b)">
|
|
|
+ <template
|
|
|
+ v-for="(
|
|
|
+ button, b
|
|
|
+ ) in toolbarButtons"
|
|
|
+ >
|
|
|
+ <template
|
|
|
+ v-if="
|
|
|
+ !(
|
|
|
+ button.key ===
|
|
|
+ 'remove' &&
|
|
|
+ dataModel.length === 1
|
|
|
+ )
|
|
|
+ "
|
|
|
+ >
|
|
|
+ <el-button
|
|
|
+ :key="b"
|
|
|
+ :type="button.type"
|
|
|
+ :icon="button.icon"
|
|
|
+ @click="
|
|
|
+ handleActionEvent(
|
|
|
+ button,
|
|
|
+ b
|
|
|
+ )
|
|
|
+ "
|
|
|
+ >
|
|
|
{{ button.label }}
|
|
|
</el-button>
|
|
|
</template>
|
|
|
@@ -173,7 +314,12 @@
|
|
|
</template>
|
|
|
</template>
|
|
|
|
|
|
- <el-table v-else :data="[]" empty-text="您尚未创建任何字段。请在表单中添加字段。" border />
|
|
|
+ <el-table
|
|
|
+ v-else
|
|
|
+ :data="[]"
|
|
|
+ empty-text="您尚未创建任何字段。请在表单中添加字段。"
|
|
|
+ border
|
|
|
+ />
|
|
|
<!--按钮支持自定义对话框-->
|
|
|
<custom-dialog
|
|
|
:visible="customDialogVisible"
|
|
|
@@ -220,7 +366,10 @@ import FormUtils from '../../utils/formUtil'
|
|
|
import FormFieldUtil from '../../utils/formFieldUtil'
|
|
|
|
|
|
import { hasPermission } from '@/business/platform/form/constants/tableButtonTypes'
|
|
|
-import { defaultPageSize, pageSizeOptions } from '@/business/platform/form/constants/fieldOptions'
|
|
|
+import {
|
|
|
+ defaultPageSize,
|
|
|
+ pageSizeOptions
|
|
|
+} from '@/business/platform/form/constants/fieldOptions'
|
|
|
|
|
|
import CustomDialog from '@/business/platform/data/templaterender/custom-dialog/dialog'
|
|
|
import FormrenderDialog from '@/business/platform/form/formrender/dialog'
|
|
|
@@ -231,7 +380,12 @@ import IbpsImport from '@/plugins/import'
|
|
|
const JForm = window.JForm
|
|
|
// 获取子表展示数据
|
|
|
const getShowData = (data, current = 1, size = defaultPageSize) => {
|
|
|
- return data && data.length ? JSON.parse(JSON.stringify(data)).slice((current - 1) * size, current * size) : []
|
|
|
+ return data && data.length
|
|
|
+ ? JSON.parse(JSON.stringify(data)).slice(
|
|
|
+ (current - 1) * size,
|
|
|
+ current * size
|
|
|
+ )
|
|
|
+ : []
|
|
|
}
|
|
|
|
|
|
export default {
|
|
|
@@ -268,7 +422,12 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
data () {
|
|
|
- const { page, pageSize = defaultPageSize, mode = 'inner', colWidth } = this.field.field_options || {}
|
|
|
+ const {
|
|
|
+ page,
|
|
|
+ pageSize = defaultPageSize,
|
|
|
+ mode = 'inner',
|
|
|
+ colWidth
|
|
|
+ } = this.field.field_options || {}
|
|
|
let initData = []
|
|
|
if (page === 'N' || mode === 'block' || !this.value) {
|
|
|
initData = this.value || []
|
|
|
@@ -327,7 +486,8 @@ export default {
|
|
|
},
|
|
|
fieldOptions () {
|
|
|
const fieldOptions = this.field.field_options || {}
|
|
|
- fieldOptions.default_value_type = fieldOptions.default_value_type || 'fixed'
|
|
|
+ fieldOptions.default_value_type =
|
|
|
+ fieldOptions.default_value_type || 'fixed'
|
|
|
return fieldOptions
|
|
|
},
|
|
|
toolbarButtons () {
|
|
|
@@ -337,7 +497,10 @@ export default {
|
|
|
return this.filterButtons('manage')
|
|
|
},
|
|
|
manageButtonWidth () {
|
|
|
- return this.manageButtons.length > 2 || this.manageButtons.length === 1 ? 70 : 150
|
|
|
+ return this.manageButtons.length > 2 ||
|
|
|
+ this.manageButtons.length === 1
|
|
|
+ ? 70
|
|
|
+ : 150
|
|
|
},
|
|
|
mode () {
|
|
|
return this.field.field_options.mode || 'inner'
|
|
|
@@ -385,7 +548,12 @@ export default {
|
|
|
traverse(child.fields)
|
|
|
})
|
|
|
} else {
|
|
|
- if (this.$utils.toBoolean(field.field_options.display, true)) {
|
|
|
+ if (
|
|
|
+ this.$utils.toBoolean(
|
|
|
+ field.field_options.display,
|
|
|
+ true
|
|
|
+ )
|
|
|
+ ) {
|
|
|
displayColumns.push(field)
|
|
|
}
|
|
|
}
|
|
|
@@ -408,7 +576,9 @@ export default {
|
|
|
return bs
|
|
|
},
|
|
|
tableReadonly () {
|
|
|
- return this.readonlyRights ? true : this.tableRights === FormOptions.t.PERMISSIONS.READ
|
|
|
+ return this.readonlyRights
|
|
|
+ ? true
|
|
|
+ : this.tableRights === FormOptions.t.PERMISSIONS.READ
|
|
|
},
|
|
|
tableHidden () {
|
|
|
return this.tableRights === FormOptions.t.PERMISSIONS.HIDE
|
|
|
@@ -477,10 +647,19 @@ export default {
|
|
|
// 字段权限
|
|
|
fieldRights: {
|
|
|
handler (fieldRights) {
|
|
|
- if (this.$utils.isNotEmpty(fieldRights) && this.$utils.isPlainObject(fieldRights)) {
|
|
|
- this.tableRights = this.getRealRights(fieldRights['rights'] || FormOptions.t.PERMISSIONS.EDIT)
|
|
|
- this.columnsRights = this.getColumnsRights(fieldRights['columns'])
|
|
|
- this.buttonsRights = this.getButtonsRights(fieldRights['buttons'])
|
|
|
+ if (
|
|
|
+ this.$utils.isNotEmpty(fieldRights) &&
|
|
|
+ this.$utils.isPlainObject(fieldRights)
|
|
|
+ ) {
|
|
|
+ this.tableRights = this.getRealRights(
|
|
|
+ fieldRights['rights'] || FormOptions.t.PERMISSIONS.EDIT
|
|
|
+ )
|
|
|
+ this.columnsRights = this.getColumnsRights(
|
|
|
+ fieldRights['columns']
|
|
|
+ )
|
|
|
+ this.buttonsRights = this.getButtonsRights(
|
|
|
+ fieldRights['buttons']
|
|
|
+ )
|
|
|
} else {
|
|
|
this.tableRights = FormOptions.t.PERMISSIONS.EDIT
|
|
|
this.columnsRights = this.getColumnsRights({})
|
|
|
@@ -528,33 +707,52 @@ export default {
|
|
|
this.currentPage = 1
|
|
|
} else {
|
|
|
// 其余逻辑(编辑、删除、整表赋值):操作后当前页大于总页数,替换为总页数,否则留在当前页
|
|
|
- this.currentPage = this.currentPage > pageCount ? pageCount : this.currentPage
|
|
|
+ this.currentPage =
|
|
|
+ this.currentPage > pageCount ? pageCount : this.currentPage
|
|
|
}
|
|
|
- this.copDataModel = this.getShowData(val, this.currentPage, this.pageSize)
|
|
|
+ this.copDataModel = this.getShowData(
|
|
|
+ val,
|
|
|
+ this.currentPage,
|
|
|
+ this.pageSize
|
|
|
+ )
|
|
|
this.editFromType = ''
|
|
|
this.$emit('update:value', val)
|
|
|
},
|
|
|
// 处理切换分页
|
|
|
handleCurrentChange (val) {
|
|
|
this.currentPage = val
|
|
|
- this.copDataModel = this.getShowData(this.dataModel, this.currentPage, this.pageSize)
|
|
|
+ this.copDataModel = this.getShowData(
|
|
|
+ this.dataModel,
|
|
|
+ this.currentPage,
|
|
|
+ this.pageSize
|
|
|
+ )
|
|
|
},
|
|
|
// 处理切换分页大小
|
|
|
handleSizeChange (val) {
|
|
|
this.pageSize = val
|
|
|
this.currentPage = 1
|
|
|
- this.copDataModel = this.getShowData(this.dataModel, this.currentPage, this.pageSize)
|
|
|
+ this.copDataModel = this.getShowData(
|
|
|
+ this.dataModel,
|
|
|
+ this.currentPage,
|
|
|
+ this.pageSize
|
|
|
+ )
|
|
|
},
|
|
|
columnHidden (column) {
|
|
|
// 是否隐藏
|
|
|
- return this.columnsRights[column.name] === FormOptions.t.PERMISSIONS.HIDE || column.field_type === 'hidden'
|
|
|
+ return (
|
|
|
+ this.columnsRights[column.name] ===
|
|
|
+ FormOptions.t.PERMISSIONS.HIDE ||
|
|
|
+ column.field_type === 'hidden'
|
|
|
+ )
|
|
|
},
|
|
|
/**
|
|
|
* 获取真实的权限
|
|
|
*/
|
|
|
getRealRights (rights) {
|
|
|
if (this.tableReadonly) {
|
|
|
- return rights === FormOptions.t.PERMISSIONS.HIDE ? rights : FormOptions.t.PERMISSIONS.READ
|
|
|
+ return rights === FormOptions.t.PERMISSIONS.HIDE
|
|
|
+ ? rights
|
|
|
+ : FormOptions.t.PERMISSIONS.READ
|
|
|
} else {
|
|
|
return rights
|
|
|
}
|
|
|
@@ -563,7 +761,10 @@ export default {
|
|
|
const columnsRights = {}
|
|
|
if (this.nameColumns && this.nameColumns.length > 0) {
|
|
|
this.nameColumns.forEach((column) => {
|
|
|
- columnsRights[column.name] = this.getRealRights(rights[column.name] || FormUtils.getDefaultRigths(column))
|
|
|
+ columnsRights[column.name] = this.getRealRights(
|
|
|
+ rights[column.name] ||
|
|
|
+ FormUtils.getDefaultRigths(column)
|
|
|
+ )
|
|
|
})
|
|
|
}
|
|
|
return columnsRights
|
|
|
@@ -573,7 +774,8 @@ export default {
|
|
|
const buttonsRights = {}
|
|
|
if (this.$utils.isNotEmpty(this.buttons)) {
|
|
|
this.buttons.forEach((button) => {
|
|
|
- buttonsRights[button.key] = FormOptions.t.PERMISSIONS.SHOW
|
|
|
+ buttonsRights[button.key] =
|
|
|
+ FormOptions.t.PERMISSIONS.SHOW
|
|
|
})
|
|
|
}
|
|
|
return buttonsRights
|
|
|
@@ -601,8 +803,12 @@ export default {
|
|
|
this.buttons.forEach((button) => {
|
|
|
if (
|
|
|
hasPermission(button.key, position) && // 有位置权限
|
|
|
- (!button.position || button.position === 'all' || button.position === position) && // 有位置权限
|
|
|
- (this.$utils.isEmpty(this.buttonsRights[button.key]) || this.buttonsRights[button.key] !== FormOptions.t.PERMISSIONS.HIDE) // 有按钮权限
|
|
|
+ (!button.position ||
|
|
|
+ button.position === 'all' ||
|
|
|
+ button.position === position) && // 有位置权限
|
|
|
+ (this.$utils.isEmpty(this.buttonsRights[button.key]) ||
|
|
|
+ this.buttonsRights[button.key] !==
|
|
|
+ FormOptions.t.PERMISSIONS.HIDE) // 有按钮权限
|
|
|
) {
|
|
|
const b = JSON.parse(JSON.stringify(button))
|
|
|
b.position = position
|
|
|
@@ -616,8 +822,12 @@ export default {
|
|
|
this.buttons.forEach((button) => {
|
|
|
if (
|
|
|
hasPermission(button.key, position) && // 有位置权限
|
|
|
- (!button.position || button.position === 'all' || button.position === position) && // 有位置权限
|
|
|
- (this.$utils.isEmpty(this.buttonsRights[button.key]) || this.buttonsRights[button.key] !== FormOptions.t.PERMISSIONS.HIDE) && // 有按钮权限
|
|
|
+ (!button.position ||
|
|
|
+ button.position === 'all' ||
|
|
|
+ button.position === position) && // 有位置权限
|
|
|
+ (this.$utils.isEmpty(this.buttonsRights[button.key]) ||
|
|
|
+ this.buttonsRights[button.key] !==
|
|
|
+ FormOptions.t.PERMISSIONS.HIDE) && // 有按钮权限
|
|
|
button.key === 'consult'
|
|
|
) {
|
|
|
// 原按钮权限限制 改为开放查阅按钮 modified by 林总
|
|
|
@@ -632,7 +842,10 @@ export default {
|
|
|
handleActionEvent (button, buttonIndex) {
|
|
|
// 起始下标
|
|
|
const index = (this.currentPage - 1) * this.pageSize + buttonIndex
|
|
|
- this.actionCode = button.key === 'custom' ? button.code || button.key + index : button.key
|
|
|
+ this.actionCode =
|
|
|
+ button.key === 'custom'
|
|
|
+ ? button.code || button.key + index
|
|
|
+ : button.key
|
|
|
this.actionPosition = button.position || 'toolbar'
|
|
|
this.actionButton = button
|
|
|
// 前置事件
|
|
|
@@ -650,6 +863,10 @@ export default {
|
|
|
this.handleAdd()
|
|
|
}
|
|
|
break
|
|
|
+ case 'copyAdd':
|
|
|
+ // 复制添加数据,需要先选择数据,往最后添加数据
|
|
|
+ this.handleCopyAddData(button, index)
|
|
|
+ break
|
|
|
case 'edit':
|
|
|
this.handleDialogMode(index)
|
|
|
break
|
|
|
@@ -678,11 +895,19 @@ export default {
|
|
|
})
|
|
|
},
|
|
|
destoryTable () {
|
|
|
- if (this.$utils.isNotEmpty(window[this.mainCode + 'TableRefs']) && this.$utils.isNotEmpty(window[this.mainCode + 'TableRefs'][this.code])) {
|
|
|
+ if (
|
|
|
+ this.$utils.isNotEmpty(window[this.mainCode + 'TableRefs']) &&
|
|
|
+ this.$utils.isNotEmpty(
|
|
|
+ window[this.mainCode + 'TableRefs'][this.code]
|
|
|
+ )
|
|
|
+ ) {
|
|
|
window[this.mainCode + 'TableRefs'][this.code] = null
|
|
|
delete window[this.mainCode + 'TableRefs'][this.code]
|
|
|
}
|
|
|
- if (this.$utils.isObject(window[this.mainCode + 'TableRefs']) && this.$utils.isEmpty(window[this.mainCode + 'TableRefs'])) {
|
|
|
+ if (
|
|
|
+ this.$utils.isObject(window[this.mainCode + 'TableRefs']) &&
|
|
|
+ this.$utils.isEmpty(window[this.mainCode + 'TableRefs'])
|
|
|
+ ) {
|
|
|
window[this.mainCode + 'TableRefs'] = null
|
|
|
delete window[this.mainCode + 'TableRefs']
|
|
|
}
|
|
|
@@ -692,7 +917,9 @@ export default {
|
|
|
if (this.mode === 'dialog') {
|
|
|
this.handleDialogMode()
|
|
|
} else {
|
|
|
- const defaultValue = await FormUtils.getTableDefaultData(this.field)
|
|
|
+ const defaultValue = await FormUtils.getTableDefaultData(
|
|
|
+ this.field
|
|
|
+ )
|
|
|
await this.addData(JSON.parse(JSON.stringify(defaultValue)))
|
|
|
}
|
|
|
},
|
|
|
@@ -708,13 +935,40 @@ export default {
|
|
|
this.$refs.elTable.doLayout()
|
|
|
}
|
|
|
},
|
|
|
+ // 新增所选择的数据
|
|
|
+ handleCopyAddData (button, index) {
|
|
|
+ const position = button.position
|
|
|
+ const selection = this.getSelection(position, index)
|
|
|
+ ActionUtils.selectedMultiRecord(selection)
|
|
|
+ .then((ids) => {
|
|
|
+ var addDatas = []
|
|
|
+ for (const i of selection) {
|
|
|
+ const object = this.dataModel[i]
|
|
|
+ delete object.$index
|
|
|
+ delete object.id
|
|
|
+ addDatas.push(object)
|
|
|
+ }
|
|
|
+ this.dataModel = JSON.parse(JSON.stringify([...this.dataModel, ...addDatas]))
|
|
|
+ // 初始化运行公式计算
|
|
|
+ this.initRunCalFormula(this.dataModel.length - 1)
|
|
|
+ // 后置事件
|
|
|
+ this.afterScript(this.actionCode, this.actionPosition)
|
|
|
+ if (this.$refs.elTable) {
|
|
|
+ this.$refs.elTable.doLayout()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch(() => {})
|
|
|
+ },
|
|
|
/**
|
|
|
* 获取选择的记录
|
|
|
*/
|
|
|
getSelection (position, index) {
|
|
|
const selection = []
|
|
|
if (position === 'toolbar' && this.mode !== 'block') {
|
|
|
- if (this.multipleSelection && this.multipleSelection.length > 0) {
|
|
|
+ if (
|
|
|
+ this.multipleSelection &&
|
|
|
+ this.multipleSelection.length > 0
|
|
|
+ ) {
|
|
|
const startIndex = (this.currentPage - 1) * this.pageSize
|
|
|
this.multipleSelection.forEach((row) => {
|
|
|
selection.push(row.$index + startIndex)
|
|
|
@@ -728,24 +982,31 @@ export default {
|
|
|
handleRemove (button, index) {
|
|
|
const position = button.position
|
|
|
const selection = this.getSelection(position, index)
|
|
|
- ActionUtils.removeRecord(selection, '确定删除当前数据?', true).then((ids) => {
|
|
|
- for (let i = this.dataModel.length - 1; i >= 0; i--) {
|
|
|
- if (ids.indexOf(i) > -1) {
|
|
|
- this.dataModel.splice(i, 1)
|
|
|
+ ActionUtils.removeRecord(selection, '确定删除当前数据?', true)
|
|
|
+ .then((ids) => {
|
|
|
+ for (let i = this.dataModel.length - 1; i >= 0; i--) {
|
|
|
+ if (ids.indexOf(i) > -1) {
|
|
|
+ this.dataModel.splice(i, 1)
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- this.totalCount = this.dataModel.length
|
|
|
- // 后置事件
|
|
|
- this.afterScript(this.actionCode, position, {
|
|
|
- selection: selection,
|
|
|
- index: index
|
|
|
+ this.totalCount = this.dataModel.length
|
|
|
+ // 后置事件
|
|
|
+ this.afterScript(this.actionCode, position, {
|
|
|
+ selection: selection,
|
|
|
+ index: index
|
|
|
+ })
|
|
|
})
|
|
|
- }).catch(() => {})
|
|
|
+ .catch(() => {})
|
|
|
},
|
|
|
// 初始化运行公式计算
|
|
|
initRunCalFormula (row) {
|
|
|
// 不需要字段的进行公式计算 比如获取但其当前时间,随机数
|
|
|
- FormUtils.runCalFormula(this, this.formula[FormUtils.NOT_NEED_FIELD], this.mainCode, row)
|
|
|
+ FormUtils.runCalFormula(
|
|
|
+ this,
|
|
|
+ this.formula[FormUtils.NOT_NEED_FIELD],
|
|
|
+ this.mainCode,
|
|
|
+ row
|
|
|
+ )
|
|
|
},
|
|
|
handleImport () {
|
|
|
this.importTableDialogVisible = true
|
|
|
@@ -791,7 +1052,9 @@ export default {
|
|
|
ActionUtils.success('导入成功')
|
|
|
})
|
|
|
} else {
|
|
|
- const formData = FormUtils.getTableDefaultColumnData(this.field)
|
|
|
+ const formData = FormUtils.getTableDefaultColumnData(
|
|
|
+ this.field
|
|
|
+ )
|
|
|
IbpsImport.xlsx(file, options).then(({ header, results }) => {
|
|
|
const columnMap = {}
|
|
|
this.nameColumns.forEach((column) => {
|
|
|
@@ -803,7 +1066,10 @@ export default {
|
|
|
if (columnMap[key]) {
|
|
|
const column = columnMap[key]
|
|
|
const name = column.name
|
|
|
- const value = this.importDataFormatter(result[key], column)
|
|
|
+ const value = this.importDataFormatter(
|
|
|
+ result[key],
|
|
|
+ column
|
|
|
+ )
|
|
|
data[name] = value
|
|
|
}
|
|
|
}
|
|
|
@@ -931,10 +1197,20 @@ export default {
|
|
|
case 'select': // 下拉,单选,多选
|
|
|
case 'radio':
|
|
|
case 'checkbox':
|
|
|
- result = this.formatterOptions(value, fieldOptions['options'], 'label', 'val')
|
|
|
+ result = this.formatterOptions(
|
|
|
+ value,
|
|
|
+ fieldOptions['options'],
|
|
|
+ 'label',
|
|
|
+ 'val'
|
|
|
+ )
|
|
|
break
|
|
|
case 'switch': //
|
|
|
- result = this.formatterOptions(value, FormUtils.getSwitchOptions(this.field.field_options), 'label', 'val')
|
|
|
+ result = this.formatterOptions(
|
|
|
+ value,
|
|
|
+ FormUtils.getSwitchOptions(this.field.field_options),
|
|
|
+ 'label',
|
|
|
+ 'val'
|
|
|
+ )
|
|
|
break
|
|
|
default:
|
|
|
result = value
|
|
|
@@ -964,10 +1240,18 @@ export default {
|
|
|
case 'select': // 下拉,单选,多选
|
|
|
case 'radio':
|
|
|
case 'checkbox':
|
|
|
- result = this.formatterOptions(value, fieldOptions['options'], 'val')
|
|
|
+ result = this.formatterOptions(
|
|
|
+ value,
|
|
|
+ fieldOptions['options'],
|
|
|
+ 'val'
|
|
|
+ )
|
|
|
break
|
|
|
case 'switch': //
|
|
|
- result = this.formatterOptions(value, FormUtils.getSwitchOptions(fieldOptions), 'val')
|
|
|
+ result = this.formatterOptions(
|
|
|
+ value,
|
|
|
+ FormUtils.getSwitchOptions(fieldOptions),
|
|
|
+ 'val'
|
|
|
+ )
|
|
|
break
|
|
|
default:
|
|
|
result = value
|
|
|
@@ -978,7 +1262,12 @@ export default {
|
|
|
/**
|
|
|
* 格式化选项
|
|
|
*/
|
|
|
- formatterOptions (value, options, valueKey = 'value', labelKey = 'label') {
|
|
|
+ formatterOptions (
|
|
|
+ value,
|
|
|
+ options,
|
|
|
+ valueKey = 'value',
|
|
|
+ labelKey = 'label'
|
|
|
+ ) {
|
|
|
const optionObj = {}
|
|
|
options.map((option) => {
|
|
|
optionObj[option[valueKey]] = option[labelKey]
|
|
|
@@ -995,7 +1284,9 @@ export default {
|
|
|
},
|
|
|
// =====================对话框模式数据处理 金源信通改=====================
|
|
|
handleDialogMode (index) {
|
|
|
- const data = this.$utils.isNotEmpty(index) ? this.dataModel[index] : {}
|
|
|
+ const data = this.$utils.isNotEmpty(index)
|
|
|
+ ? this.dataModel[index]
|
|
|
+ : {}
|
|
|
this.dialogFormData = {
|
|
|
responses: JSON.parse(JSON.stringify(data)),
|
|
|
// 表单字段权限
|
|
|
@@ -1008,7 +1299,18 @@ export default {
|
|
|
}
|
|
|
if (this.params.formAttrs) {
|
|
|
const formAttrs = this.params.formAttrs
|
|
|
- const allowAttrs = ['inline', 'labelPosition', 'labelWidth', 'labelWidthUnit', 'size', 'statusIcon', 'descPosition', 'read_style', 'colon', 'labelSuffix']
|
|
|
+ const allowAttrs = [
|
|
|
+ 'inline',
|
|
|
+ 'labelPosition',
|
|
|
+ 'labelWidth',
|
|
|
+ 'labelWidthUnit',
|
|
|
+ 'size',
|
|
|
+ 'statusIcon',
|
|
|
+ 'descPosition',
|
|
|
+ 'read_style',
|
|
|
+ 'colon',
|
|
|
+ 'labelSuffix'
|
|
|
+ ]
|
|
|
for (const key in formAttrs) {
|
|
|
if (allowAttrs.indexOf(key) > -1) {
|
|
|
const val = formAttrs[key]
|
|
|
@@ -1044,7 +1346,9 @@ export default {
|
|
|
// =====================对话框模式数据处理= 原====================
|
|
|
|
|
|
handleEditMode (index) {
|
|
|
- const data = this.$utils.isNotEmpty(index) ? this.dataModel[index] : {}
|
|
|
+ const data = this.$utils.isNotEmpty(index)
|
|
|
+ ? this.dataModel[index]
|
|
|
+ : {}
|
|
|
this.dialogFormData = {
|
|
|
responses: JSON.parse(JSON.stringify(data)),
|
|
|
// 表单字段权限
|
|
|
@@ -1057,7 +1361,18 @@ export default {
|
|
|
}
|
|
|
if (this.params.formAttrs) {
|
|
|
const formAttrs = this.params.formAttrs
|
|
|
- const allowAttrs = ['inline', 'labelPosition', 'labelWidth', 'labelWidthUnit', 'size', 'statusIcon', 'descPosition', 'read_style', 'colon', 'labelSuffix']
|
|
|
+ const allowAttrs = [
|
|
|
+ 'inline',
|
|
|
+ 'labelPosition',
|
|
|
+ 'labelWidth',
|
|
|
+ 'labelWidthUnit',
|
|
|
+ 'size',
|
|
|
+ 'statusIcon',
|
|
|
+ 'descPosition',
|
|
|
+ 'read_style',
|
|
|
+ 'colon',
|
|
|
+ 'labelSuffix'
|
|
|
+ ]
|
|
|
for (const key in formAttrs) {
|
|
|
if (allowAttrs.indexOf(key) > -1) {
|
|
|
const val = formAttrs[key]
|
|
|
@@ -1100,7 +1415,11 @@ export default {
|
|
|
|
|
|
async handleAddCustomDialog (button) {
|
|
|
this.customDialogKey = button.dialog
|
|
|
- this.customDialogDynamicParams = await FormUtils.getLinkDynamicParams(button.custom, this.formData)
|
|
|
+ this.customDialogDynamicParams =
|
|
|
+ await FormUtils.getLinkDynamicParams(
|
|
|
+ button.custom,
|
|
|
+ this.formData
|
|
|
+ )
|
|
|
this.customDialogCustom = button.custom
|
|
|
setTimeout(() => {
|
|
|
this.customDialogVisible = true
|
|
|
@@ -1111,7 +1430,9 @@ export default {
|
|
|
if (this.$utils.isEmpty(linkLinkage)) {
|
|
|
return
|
|
|
}
|
|
|
- const defaultValue = await FormUtils.getTableDefaultData(this.field)
|
|
|
+ const defaultValue = await FormUtils.getTableDefaultData(
|
|
|
+ this.field
|
|
|
+ )
|
|
|
for (let i = 0; i < datas.length; i++) {
|
|
|
const data = datas[i]
|
|
|
const model = JSON.parse(JSON.stringify(defaultValue))
|
|
|
@@ -1151,7 +1472,13 @@ export default {
|
|
|
if (!callback) {
|
|
|
callback = () => {}
|
|
|
}
|
|
|
- JForm._beforeSubButton(this, this.actionCode, button.position, params, callback)
|
|
|
+ JForm._beforeSubButton(
|
|
|
+ this,
|
|
|
+ this.actionCode,
|
|
|
+ button.position,
|
|
|
+ params,
|
|
|
+ callback
|
|
|
+ )
|
|
|
},
|
|
|
// 后置脚本
|
|
|
afterScript (action, position, params, callback) {
|
|
|
@@ -1263,7 +1590,7 @@ export default {
|
|
|
|
|
|
.is-required:not(.is-no-asterisk) {
|
|
|
.dynamic-form-table__label:before {
|
|
|
- content: '*';
|
|
|
+ content: "*";
|
|
|
color: #f56c6c;
|
|
|
margin-right: 4px;
|
|
|
}
|