|
@@ -1,34 +1,16 @@
|
|
|
<template>
|
|
|
<el-card shadow="always" :body-style="{ padding: '10px' }">
|
|
|
<div class="app-container">
|
|
|
- <el-dialog
|
|
|
- :title="upload.title"
|
|
|
- :visible.sync="upload.open"
|
|
|
- width="400px"
|
|
|
- append-to-body
|
|
|
- >
|
|
|
- <el-upload
|
|
|
- ref="upload"
|
|
|
- :limit="1"
|
|
|
- accept=".xlsx, .xls"
|
|
|
- :headers="upload.headers"
|
|
|
- :action="
|
|
|
- upload.url +
|
|
|
- '?updateSupport=' +
|
|
|
- upload.updateSupport +
|
|
|
- '&tableName=' +
|
|
|
- tableName +
|
|
|
- '&sqlKey=' +
|
|
|
- tableKey
|
|
|
- "
|
|
|
- v-loading="upload.isUploading"
|
|
|
- :disabled="upload.isUploading"
|
|
|
- :on-progress="handleFileUploadProgress"
|
|
|
- :on-success="handleFileSuccess"
|
|
|
- :auto-upload="false"
|
|
|
- :onChange="handleChange"
|
|
|
- drag
|
|
|
- >
|
|
|
+ <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
|
|
|
+ <el-upload ref="upload" :limit="1" accept=".xlsx, .xls" :headers="upload.headers" :action="upload.url +
|
|
|
+ '?updateSupport=' +
|
|
|
+ upload.updateSupport +
|
|
|
+ '&tableName=' +
|
|
|
+ tableName +
|
|
|
+ '&sqlKey=' +
|
|
|
+ tableKey
|
|
|
+ " v-loading="upload.isUploading" :disabled="upload.isUploading" :on-progress="handleFileUploadProgress"
|
|
|
+ :on-success="handleFileSuccess" :auto-upload="false" :onChange="handleChange" drag>
|
|
|
<i class="el-icon-upload"></i>
|
|
|
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
|
|
|
<div class="el-upload__tip text-center" slot="tip">
|
|
@@ -37,12 +19,8 @@
|
|
|
<!-- 是否更新已经存在的用户数据-->
|
|
|
<!-- </div>-->
|
|
|
<span>仅允许导入xls、xlsx格式文件。</span>
|
|
|
- <el-link
|
|
|
- type="primary"
|
|
|
- :underline="false"
|
|
|
- style="font-size: 12px; vertical-align: baseline"
|
|
|
- @click="importTemplate"
|
|
|
- >下载模板
|
|
|
+ <el-link type="primary" :underline="false" style="font-size: 12px; vertical-align: baseline"
|
|
|
+ @click="importTemplate">下载模板
|
|
|
</el-link>
|
|
|
</div>
|
|
|
</el-upload>
|
|
@@ -51,110 +29,51 @@
|
|
|
<el-button @click="upload.open = false">取 消</el-button>
|
|
|
</div>
|
|
|
</el-dialog>
|
|
|
- <Queryfrom
|
|
|
- v-if="QueryfromLoading"
|
|
|
- :formVals="templateInfo.where"
|
|
|
- :statisticList="statisticList"
|
|
|
- :showCount="showCount"
|
|
|
- :showSearch="showSearch"
|
|
|
- @getList="getList"
|
|
|
- ref="mychild"
|
|
|
- />
|
|
|
+ <Queryfrom v-if="QueryfromLoading" :formVals="templateInfo.where" :statisticList="statisticList"
|
|
|
+ :showCount="showCount" :showSearch="showSearch" @getList="getList" ref="mychild" />
|
|
|
<el-row :gutter="10" class="mb8">
|
|
|
<!-- 按钮行 start -->
|
|
|
- <btn-menu-list
|
|
|
- @topBtnHandler="topBtnHandler"
|
|
|
- :topBtnArr="topBtnArr"
|
|
|
- :selection="selection"
|
|
|
- ></btn-menu-list>
|
|
|
- <right-toolbar
|
|
|
- :showCount.sync="showCount"
|
|
|
- :showSearch.sync="showSearch"
|
|
|
- :counts="true"
|
|
|
- @queryTable="pageList"
|
|
|
- ></right-toolbar>
|
|
|
+ <btn-menu-list @topBtnHandler="topBtnHandler" :topBtnArr="topBtnArr" :selection="selection"></btn-menu-list>
|
|
|
+ <right-toolbar :showCount.sync="showCount" :showSearch.sync="showSearch" :counts="true"
|
|
|
+ @queryTable="pageList"></right-toolbar>
|
|
|
</el-row>
|
|
|
- <el-table
|
|
|
- v-loading="loading"
|
|
|
- :data="tableList"
|
|
|
- @selection-change="handleSelectionChange"
|
|
|
- ref="tableRef"
|
|
|
- :cell-style="cellStyle"
|
|
|
- :reserve-selection="true"
|
|
|
- :row-key="getRowKey"
|
|
|
- >
|
|
|
- <el-table-column
|
|
|
- type="selection"
|
|
|
- width="55"
|
|
|
- reserve-selection
|
|
|
- align="center"
|
|
|
- >
|
|
|
+ <el-table v-loading="loading" :data="tableList" @selection-change="handleSelectionChange" ref="tableRef"
|
|
|
+ :cell-style="cellStyle" :reserve-selection="true" :row-key="getRowKey">
|
|
|
+ <el-table-column type="selection" width="55" reserve-selection align="center">
|
|
|
</el-table-column>
|
|
|
- <el-table-column
|
|
|
- v-for="item in columns"
|
|
|
- :key="item.key"
|
|
|
- :label="item.value"
|
|
|
- align="center"
|
|
|
- :prop="item.key"
|
|
|
- >
|
|
|
+ <el-table-column v-for="item in columns" :key="item.key" :label="item.value" align="center" :prop="item.key">
|
|
|
<template slot-scope="scope">
|
|
|
<!-- 存在字段样式或字典样式 -->
|
|
|
- <template
|
|
|
- v-if="
|
|
|
- scope.row.styleFieldObj != undefined &&
|
|
|
- scope.row.styleFieldObj[item.key]
|
|
|
- "
|
|
|
- >
|
|
|
+ <template v-if="scope.row.styleFieldObj != undefined &&
|
|
|
+ scope.row.styleFieldObj[item.key]
|
|
|
+ ">
|
|
|
<!-- 字段样式 -->
|
|
|
<template v-if="scope.row.styleFieldObj[item.key].styleType == 1">
|
|
|
<!-- 一般字体样式 -->
|
|
|
- <template
|
|
|
- v-if="scope.row.styleFieldObj[item.key].fieldStyleType == 0"
|
|
|
- >
|
|
|
- <span
|
|
|
- :style="`color:${
|
|
|
- scope.row.styleFieldObj[item.key].fontColor
|
|
|
- }`"
|
|
|
- >{{ scope.row[item.key] }}</span
|
|
|
- >
|
|
|
+ <template v-if="scope.row.styleFieldObj[item.key].fieldStyleType == 0">
|
|
|
+ <span :style="`color:${scope.row.styleFieldObj[item.key].fontColor
|
|
|
+ }`">{{ scope.row[item.key] }}</span>
|
|
|
</template>
|
|
|
<!-- 标签字体样式 -->
|
|
|
- <template
|
|
|
- v-else-if="
|
|
|
- scope.row.styleFieldObj[item.key].fieldStyleType == 1
|
|
|
- "
|
|
|
- >
|
|
|
- <el-tag
|
|
|
- :type="scope.row.styleFieldObj[item.key].tagType"
|
|
|
- :effect="
|
|
|
- scope.row.styleFieldObj[item.key].isTagFullBg
|
|
|
- ? 'dark'
|
|
|
- : 'light'
|
|
|
- "
|
|
|
- >
|
|
|
+ <template v-else-if="scope.row.styleFieldObj[item.key].fieldStyleType == 1
|
|
|
+ ">
|
|
|
+ <el-tag :type="scope.row.styleFieldObj[item.key].tagType" :effect="scope.row.styleFieldObj[item.key].isTagFullBg
|
|
|
+ ? 'dark'
|
|
|
+ : 'light'
|
|
|
+ ">
|
|
|
{{ scope.row[item.key] }}
|
|
|
</el-tag>
|
|
|
</template>
|
|
|
</template>
|
|
|
<!-- 字典样式 -->
|
|
|
- <template
|
|
|
- v-else-if="scope.row.styleFieldObj[item.key].styleType == 2"
|
|
|
- >
|
|
|
- <span
|
|
|
- v-if="
|
|
|
- scope.row.styleFieldObj[item.key].listClass == '' ||
|
|
|
- scope.row.styleFieldObj[item.key].listClass == 'default'
|
|
|
- "
|
|
|
- >{{ scope.row.styleFieldObj[item.key].dictLabel }}</span
|
|
|
- >
|
|
|
- <el-tag
|
|
|
- v-else
|
|
|
- :type="
|
|
|
- scope.row.styleFieldObj[item.key].listClass == 'primary'
|
|
|
- ? ''
|
|
|
- : scope.row.styleFieldObj[item.key].listClass
|
|
|
- "
|
|
|
- >{{ scope.row.styleFieldObj[item.key].dictLabel }}
|
|
|
+ <template v-else-if="scope.row.styleFieldObj[item.key].styleType == 2">
|
|
|
+ <span v-if="scope.row.styleFieldObj[item.key].listClass == '' ||
|
|
|
+ scope.row.styleFieldObj[item.key].listClass == 'default'
|
|
|
+ ">{{ scope.row.styleFieldObj[item.key].dictLabel }}</span>
|
|
|
+ <el-tag v-else :type="scope.row.styleFieldObj[item.key].listClass == 'primary'
|
|
|
+ ? ''
|
|
|
+ : scope.row.styleFieldObj[item.key].listClass
|
|
|
+ ">{{ scope.row.styleFieldObj[item.key].dictLabel }}
|
|
|
</el-tag>
|
|
|
</template>
|
|
|
</template>
|
|
@@ -164,93 +83,57 @@
|
|
|
</template>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
- <el-table-column
|
|
|
- v-if="isShowExcuteCol"
|
|
|
- label="操作"
|
|
|
- align="center"
|
|
|
- class-name="small-padding fixed-width"
|
|
|
- >
|
|
|
+ <el-table-column v-if="isShowExcuteCol" label="操作" align="center" class-name="small-padding fixed-width">
|
|
|
<template slot-scope="scope">
|
|
|
- <Menu
|
|
|
- :row="scope.row"
|
|
|
- v-for="btnObj in excuteBtnArr"
|
|
|
- :key="btnObj.id"
|
|
|
- :listAll="btnObj"
|
|
|
- @excuteHandler="excuteHandler"
|
|
|
- ></Menu>
|
|
|
+ <Menu :row="scope.row" v-for="btnObj in excuteBtnArr" :key="btnObj.id" :listAll="btnObj"
|
|
|
+ @excuteHandler="excuteHandler"></Menu>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
</el-table>
|
|
|
- <pagination
|
|
|
- v-show="total > 0"
|
|
|
- :total="total"
|
|
|
- :page.sync="queryParams.pageNum"
|
|
|
- :limit.sync="queryParams.pageSize"
|
|
|
- @pagination="pageList"
|
|
|
- />
|
|
|
+ <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
|
|
|
+ @pagination="pageList" />
|
|
|
<!-- 添加或修改 -->
|
|
|
<el-dialog :title="title" :visible.sync="open" append-to-body>
|
|
|
<!-- <template v-else> -->
|
|
|
- <div
|
|
|
- v-show="formType == 'dragFormGroup' && !formListShow"
|
|
|
- class="dialog_loading"
|
|
|
- >
|
|
|
+ <div v-show="formType == 'dragFormGroup' && !formListShow" class="dialog_loading">
|
|
|
<i class="el-icon-loading"></i>
|
|
|
</div>
|
|
|
<template>
|
|
|
- <!-- :style="{ opacity: formListShow ? 1 : 0 }" -->
|
|
|
- <FormList
|
|
|
- v-show="formType == 'dragFormGroup' && formListShow && !isLayout"
|
|
|
- ref="formGroupRef"
|
|
|
- :formList="formList"
|
|
|
- ></FormList>
|
|
|
- <LayoutIndex
|
|
|
- v-show="formType == 'dragFormGroup' && formListShow && isLayout"
|
|
|
- ref="formGroupLayoutRef"
|
|
|
- :layoutData="layoutData"
|
|
|
- ></LayoutIndex>
|
|
|
- <!-- <div v-show="times" class="times">
|
|
|
- <i class="el-icon-loading" style="font-size: 30px"></i>
|
|
|
- </div> -->
|
|
|
- <!-- <el-button @click="showValue">test</el-button> -->
|
|
|
+ <FormList v-show="formType == 'dragFormGroup' && formListShow && !isLayout" ref="formGroupRef"
|
|
|
+ :formList="formList"></FormList>
|
|
|
+ <LayoutIndex v-show="formType == 'dragFormGroup' && formListShow && isLayout" ref="formGroupLayoutRef"
|
|
|
+ :layoutData="layoutData"></LayoutIndex>
|
|
|
</template>
|
|
|
<template>
|
|
|
- <k-form-build
|
|
|
- v-if="jsonData && formType == 'dragForm'"
|
|
|
- class="formBuild"
|
|
|
- ref="addFromRef"
|
|
|
- :dynamicData="dynamicData"
|
|
|
- :defaultValue="defaultValue"
|
|
|
- @submit="tempSubBtn"
|
|
|
- @change="formChangeHandler"
|
|
|
- :value="jsonData"
|
|
|
- :tableData="tableTempList"
|
|
|
- />
|
|
|
+ <k-form-build v-if="jsonData && formType == 'dragForm'" class="formBuild" ref="addFromRef"
|
|
|
+ :dynamicData="dynamicData" :defaultValue="defaultValue" @submit="tempSubBtn" @change="formChangeHandler"
|
|
|
+ :value="jsonData" :tableData="tableTempList" />
|
|
|
</template>
|
|
|
-
|
|
|
- <div slot="footer" class="dialog-footer">
|
|
|
- <el-button type="primary" @click="editConfirmHandler"
|
|
|
- >确 定
|
|
|
+ <template>
|
|
|
+ <el-table v-if="jsonData && formType == 'calculateForm'" :data="calculateTableData" style="width: 100%"
|
|
|
+ :show-summary="showSummary" :summary-method="getformula">
|
|
|
+ <!-- 固定序号列 -->
|
|
|
+ <el-table-column label="序号" width="80" header-align="center" align="center">
|
|
|
+ <template #default="{ $index }">
|
|
|
+ {{ $index + 1 }}
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column v-for="(item, index) in calculateTableColumn" :key="index" :prop="item.prop"
|
|
|
+ :label="item.label" header-align="center" align="center">
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+ </template>
|
|
|
+ <div slot="footer" class="dialog-footer" v-if="jsonData && formType !== 'calculateForm'">
|
|
|
+ <el-button type="primary" @click="editConfirmHandler">确 定
|
|
|
</el-button>
|
|
|
<el-button @click="cancel">取 消</el-button>
|
|
|
</div>
|
|
|
</el-dialog>
|
|
|
|
|
|
<!-- 绑定按钮dialog -->
|
|
|
- <el-dialog
|
|
|
- title="提示"
|
|
|
- :visible.sync="btnDialogVisible"
|
|
|
- :before-close="handleClose"
|
|
|
- >
|
|
|
- <DialogTemplate
|
|
|
- ref="dialogRef"
|
|
|
- :groupKey="groupKey"
|
|
|
- :rowobj="rowobj"
|
|
|
- :subCount="subCount"
|
|
|
- :tableCount="tableCount"
|
|
|
- :subTableName="subTableName"
|
|
|
- @addList="addListHandler"
|
|
|
- >
|
|
|
+ <el-dialog title="提示" :visible.sync="btnDialogVisible" :before-close="handleClose">
|
|
|
+ <DialogTemplate ref="dialogRef" :groupKey="groupKey" :rowobj="rowobj" :subCount="subCount"
|
|
|
+ :tableCount="tableCount" :subTableName="subTableName" @addList="addListHandler">
|
|
|
</DialogTemplate>
|
|
|
<span slot="footer" class="dialog-footer">
|
|
|
<el-button @click="btnDialogVisible = false">取 消</el-button>
|
|
@@ -259,20 +142,9 @@
|
|
|
</el-dialog>
|
|
|
|
|
|
<!-- 自定义弹窗 -->
|
|
|
- <el-dialog
|
|
|
- title="提示"
|
|
|
- :visible.sync="btnDialogVisible"
|
|
|
- :before-close="handleClose"
|
|
|
- >
|
|
|
- <DialogTemplate
|
|
|
- ref="dialogRef"
|
|
|
- :groupKey="groupKey"
|
|
|
- :rowobj="rowobj"
|
|
|
- :subCount="subCount"
|
|
|
- :tableCount="tableCount"
|
|
|
- :subTableName="subTableName"
|
|
|
- @addList="addListHandler"
|
|
|
- >
|
|
|
+ <el-dialog title="提示" :visible.sync="btnDialogVisible" :before-close="handleClose">
|
|
|
+ <DialogTemplate ref="dialogRef" :groupKey="groupKey" :rowobj="rowobj" :subCount="subCount"
|
|
|
+ :tableCount="tableCount" :subTableName="subTableName" @addList="addListHandler">
|
|
|
</DialogTemplate>
|
|
|
<span slot="footer" class="dialog-footer">
|
|
|
<el-button @click="btnDialogVisible = false">取 消</el-button>
|
|
@@ -297,9 +169,7 @@
|
|
|
</span>
|
|
|
<template #footer>
|
|
|
<span>
|
|
|
- <el-button type="primary" @click="toastShow = false"
|
|
|
- >确认</el-button
|
|
|
- >
|
|
|
+ <el-button type="primary" @click="toastShow = false">确认</el-button>
|
|
|
</span>
|
|
|
</template>
|
|
|
</el-dialog>
|
|
@@ -346,7 +216,19 @@ export default {
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
- isLayout:false,
|
|
|
+ calculateTableData: [
|
|
|
+ { date: '2023-10-01', name: '张三', address: '北京市' },
|
|
|
+ { date: '2023-10-02', name: '李四', address: '上海市' },
|
|
|
+ { date: '2023-10-03', name: '王五', address: '广州市' }
|
|
|
+ ],
|
|
|
+ calculateTableColumn: [
|
|
|
+ { prop: 'date', label: '日期', width: '180' },
|
|
|
+ { prop: 'name', label: '姓名', width: '180' },
|
|
|
+ { prop: 'address', label: '地址' }
|
|
|
+ ],
|
|
|
+ formula: 'sum',
|
|
|
+ showSummary: false,
|
|
|
+ isLayout: false,
|
|
|
QueryfromLoading: false,
|
|
|
layoutData: "", //表单组布局数据
|
|
|
times: 1, //请求次数
|
|
@@ -510,9 +392,9 @@ export default {
|
|
|
created() {
|
|
|
// 得到当前展示的table的唯一标识
|
|
|
this.tableKey = this.$route.query.tableKey;
|
|
|
- console.log('this.$route.query',this.$route.query)
|
|
|
+ console.log('this.$route.query', this.$route.query)
|
|
|
// 优化共通模版查询调用逻辑 (Don't fucking change it)
|
|
|
- console.log('this.queryParams',this.queryParams)
|
|
|
+ console.log('this.queryParams', this.queryParams)
|
|
|
this.getList(this.queryParams);
|
|
|
},
|
|
|
mounted() {
|
|
@@ -556,18 +438,18 @@ export default {
|
|
|
/** 查询列表 */
|
|
|
getList(queryParams) {
|
|
|
this.loading = true;
|
|
|
- // 序列化当前查询参数列表
|
|
|
- queryParams && (this.queryParams.queryMap = Object.assign({}, queryParams.queryMap));
|
|
|
- if (typeof queryParams.queryMap.timehorizon != undefined) {
|
|
|
- // timehorizon 时间范围转换字符串回传后台
|
|
|
- this.queryParams.queryMap.timehorizon = JSON.stringify(
|
|
|
- Object.assign({}, queryParams.queryMap.timehorizon)
|
|
|
- );
|
|
|
- }
|
|
|
+ // 序列化当前查询参数列表
|
|
|
+ queryParams && (this.queryParams.queryMap = Object.assign({}, queryParams.queryMap));
|
|
|
+ if (typeof queryParams.queryMap.timehorizon != undefined) {
|
|
|
+ // timehorizon 时间范围转换字符串回传后台
|
|
|
+ this.queryParams.queryMap.timehorizon = JSON.stringify(
|
|
|
+ Object.assign({}, queryParams.queryMap.timehorizon)
|
|
|
+ );
|
|
|
+ }
|
|
|
// 获取当前表单结构信息
|
|
|
dragTableInfo({ queryMap: { tableKey: this.tableKey } })
|
|
|
.then((res) => {
|
|
|
- console.log('[表格中dragTableInfo的结果中的resultMap属性]',res.data.resultMap)
|
|
|
+ console.log('[表格中dragTableInfo的结果中的resultMap属性]', res.data.resultMap)
|
|
|
// 得到当前模版信息 --- sql columns queryWhere
|
|
|
this.templateInfo = res.data.resultMap;
|
|
|
this.QueryfromLoading = true; // 加载查询组件
|
|
@@ -581,6 +463,7 @@ export default {
|
|
|
this.excuteBtnArr = res.data.resultMap.button?.filter(
|
|
|
(item) => item.btnGroupType == "right"
|
|
|
);
|
|
|
+ // console.log('[========excuteBtnArr==============]',this.excuteBtnArr)
|
|
|
this.topBtnArr =
|
|
|
res.data.resultMap.button?.filter(
|
|
|
(item) => item.btnGroupType == "top"
|
|
@@ -702,9 +585,9 @@ export default {
|
|
|
this.$refs.mychild.pageList(
|
|
|
row == undefined
|
|
|
? {
|
|
|
- limit: this.queryParams.pageSize,
|
|
|
- page: this.queryParams.pageNum,
|
|
|
- }
|
|
|
+ limit: this.queryParams.pageSize,
|
|
|
+ page: this.queryParams.pageNum,
|
|
|
+ }
|
|
|
: row
|
|
|
);
|
|
|
},
|
|
@@ -713,9 +596,9 @@ export default {
|
|
|
this.ids = selection.map(
|
|
|
(item) =>
|
|
|
item[
|
|
|
- camelCase(
|
|
|
- this.tableName + "_" + this.templateInfo.template?.primaryKey
|
|
|
- )
|
|
|
+ camelCase(
|
|
|
+ this.tableName + "_" + this.templateInfo.template?.primaryKey
|
|
|
+ )
|
|
|
]
|
|
|
);
|
|
|
this.selection = selection;
|
|
@@ -802,7 +685,7 @@ export default {
|
|
|
// 延迟
|
|
|
sleep(ms) {
|
|
|
var unixtime_ms = new Date().getTime();
|
|
|
- while (new Date().getTime() < unixtime_ms + ms) {}
|
|
|
+ while (new Date().getTime() < unixtime_ms + ms) { }
|
|
|
return "";
|
|
|
},
|
|
|
/** 修改按钮操作 */
|
|
@@ -995,8 +878,76 @@ export default {
|
|
|
console.log(this.times);
|
|
|
return;
|
|
|
},
|
|
|
+ getformula({ columns, data }) {
|
|
|
+ // console.log('[当前合计行的columns或data]', columns, data)
|
|
|
+ // console.log('[当前calculateTableColumn]', this.calculateTableColumn)
|
|
|
+ // 循环columns,将columns.property== this.calculateTableColumn数组中的prop的对象找出,将匹配的this.calculateTableColumn.type的值赋给columns.columns.type
|
|
|
+ // 遍历传入的columns数组,并更新ColumnType
|
|
|
+ columns = columns.map(column => {
|
|
|
+ if (column && column.property) {
|
|
|
+ const matchingColumn = this.calculateTableColumn.find(
|
|
|
+ calcColumn => calcColumn.prop === column.property
|
|
|
+ );
|
|
|
+ if (matchingColumn) {
|
|
|
+ column.ColumnType = matchingColumn.type;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return column;
|
|
|
+ });
|
|
|
+
|
|
|
+ const sums = [];
|
|
|
+ const formula = this.formula; // 假设formula是在组件数据中的变量
|
|
|
+
|
|
|
+ columns.forEach((column, index) => {
|
|
|
+ // 跳过序号列
|
|
|
+ if (index === 0) {
|
|
|
+ // 第一列显示合计行的标题
|
|
|
+ sums[index] = formula === 'sum' ? '合计' :
|
|
|
+ formula === 'min' ? '最小值' :
|
|
|
+ formula === 'max' ? '最大值' :
|
|
|
+ formula === 'average' ? '平均值' : '合计';
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 检查ColumnType是否为numberTotal或result
|
|
|
+ if (!['numberTotal', 'result'].includes(columns[index].ColumnType)) {
|
|
|
+ sums[index] = ''; // 如果不是这两种类型,则不显示合计信息
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取当前列的数据
|
|
|
+ const values = data.map(item => Number(item[column.property]));
|
|
|
|
|
|
+ // 确保所有值都是数字
|
|
|
+ if (values.every(value => !isNaN(value))) {
|
|
|
+ switch (formula) {
|
|
|
+ case 'sum':
|
|
|
+ sums[index] = values.reduce((prev, curr) => prev + curr, 0);
|
|
|
+ break;
|
|
|
+ case 'min':
|
|
|
+ sums[index] = Math.min(...values);
|
|
|
+ break;
|
|
|
+ case 'max':
|
|
|
+ sums[index] = Math.max(...values);
|
|
|
+ break;
|
|
|
+ case 'average':
|
|
|
+ sums[index] = values.reduce((prev, curr) => prev + curr, 0) / values.length;
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ sums[index] = values.reduce((prev, curr) => prev + curr, 0);
|
|
|
+ }
|
|
|
+ // 格式化显示(保留两位小数)
|
|
|
+ sums[index] = Number(sums[index].toFixed(2));
|
|
|
+ } else {
|
|
|
+ sums[index] = '-'; // 如果列中有非数字,显示 -
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ return sums;
|
|
|
+ },
|
|
|
+ // 计算表格方法
|
|
|
async handleCalculate(row, btnData) {
|
|
|
+ console.log("btnData, row", btnData, row);
|
|
|
let nameTable = this.templateInfo.template.dtTableName;
|
|
|
this.rowobj = {};
|
|
|
let obj = {};
|
|
@@ -1014,6 +965,8 @@ export default {
|
|
|
// 新的修改请求
|
|
|
try {
|
|
|
let { btnFormType, btnGroupType } = btnData;
|
|
|
+ // console.log("btnFormType, btnGroupType", btnFormType, btnGroupType);
|
|
|
+ // console.log('this.currentBtnData', this.currentBtnData)
|
|
|
let payLoad = {};
|
|
|
let primary = camelCase(
|
|
|
this.tableName + "_" + this.templateInfo.template?.primaryKey
|
|
@@ -1053,83 +1006,37 @@ export default {
|
|
|
this.$message.error("当前按钮未绑定表单!");
|
|
|
return;
|
|
|
}
|
|
|
- if (btnFormType == "dragFormGroup") {
|
|
|
- //表单组
|
|
|
- if (res.code == 200) {
|
|
|
- if (res.data.mainForm) {
|
|
|
- //表单组
|
|
|
- // 判断是否有布局数据
|
|
|
- this.isLayout =
|
|
|
- res.data.layoutJson &&
|
|
|
- JSON.parse(res.data.layoutJson)?.list.length > 0;
|
|
|
- this.transformDataFormat(res.data);
|
|
|
- if (this.isLayout) {
|
|
|
- //自定义布局
|
|
|
- this.layoutData = JSON.parse(JSON.stringify(res.data));
|
|
|
- }
|
|
|
- } else {
|
|
|
- this.formList = res.data;
|
|
|
- }
|
|
|
- this.open = true;
|
|
|
- if (btnData.btnFormType == "dragFormGroup") {
|
|
|
- if (this.times) {
|
|
|
- this.times = 0;
|
|
|
- // debugger;
|
|
|
- this.$nextTick(async () => {
|
|
|
- // debugger;
|
|
|
- setTimeout(() => {
|
|
|
- this.handleUpdate(row, btnData).then((res) => {
|
|
|
- this.formListShow = true;
|
|
|
- });
|
|
|
- // setTimeout(() => {
|
|
|
- // this.times = 0;
|
|
|
- // }, 1000);
|
|
|
- }, 1000);
|
|
|
- });
|
|
|
- }
|
|
|
- }
|
|
|
- if (this.isLayout) {
|
|
|
- //布局样式
|
|
|
- this.$nextTick(() => {
|
|
|
- // 手动触发布局组件的数据处理函数
|
|
|
- this.$refs.formGroupLayoutRef?.initLayoutData(
|
|
|
- JSON.parse(JSON.stringify(res.data))
|
|
|
- );
|
|
|
- });
|
|
|
- }
|
|
|
- } else {
|
|
|
- this.$message.error("网络异常,请稍后再试");
|
|
|
- }
|
|
|
- } else {
|
|
|
- let optionsData = "",
|
|
|
- templateData = "";
|
|
|
- if (btnGroupType == "top") {
|
|
|
- optionsData = res.data.dfFormSql;
|
|
|
- templateData = res.data.dfVueTemplate;
|
|
|
- } else {
|
|
|
- //修改
|
|
|
- optionsData = res.data.template.dfFormSql;
|
|
|
- templateData = res.data.template.dfVueTemplate;
|
|
|
-
|
|
|
- this.addRealFieldName(res.data.result.resultMap);
|
|
|
- let resultMap = res.data.result.resultMap;
|
|
|
-
|
|
|
- Object.assign(this.defaultValue, resultMap);
|
|
|
- }
|
|
|
- //单个表单
|
|
|
+ if (btnFormType == "calculateForm") {
|
|
|
+ let optionsData = res.data.template.dfFormSql;//暂时不知道是干什么的
|
|
|
+ let templateData = res.data.template.dfVueTemplate;
|
|
|
+ this.addRealFieldName(res.data.result.resultMap);//没返回?
|
|
|
+ let resultMap = res.data.result.resultMap;
|
|
|
+ //this.defaultValue回显表格数据
|
|
|
+ Object.assign(this.defaultValue, resultMap);
|
|
|
+ // dynamicData下拉框动态数据--data上这么备注的,是个要传给k-form-build的对象
|
|
|
+ // 当 optionsData 存在时执行 JSON.parse(optionsData) 并赋值给 this.dynamicData。
|
|
|
optionsData && (this.dynamicData = JSON.parse(optionsData));
|
|
|
this.jsonData = JSON.parse(templateData);
|
|
|
- // console.log('[----- this.jsonData -----]', this.jsonData )
|
|
|
this.open = true;
|
|
|
this.title = "计算表单";
|
|
|
- this.form.password = this.initPassword;
|
|
|
- if (btnGroupType == "right") {
|
|
|
- this.$nextTick(() => {
|
|
|
- this.$refs.addFromRef.setData(res.data.result.resultMap);
|
|
|
- console.log('[----- res.data.result.resultMap -----]', res.data.result.resultMap )
|
|
|
+ let calculateResultMap = res.data.result.calculateResultMap
|
|
|
+ if (calculateResultMap && calculateResultMap.tableColumn && calculateResultMap.tableValue) {
|
|
|
+ this.calculateTableData = calculateResultMap.tableValue
|
|
|
+ this.calculateTableColumn = calculateResultMap.tableColumn
|
|
|
|
|
|
- });
|
|
|
+
|
|
|
+ this.formula = calculateResultMap.formula
|
|
|
+ this.showSummary = calculateResultMap.showSummary
|
|
|
+
|
|
|
+ } else {
|
|
|
+ this.calculateTableData = []
|
|
|
+ this.calculateTableColumn = []
|
|
|
}
|
|
|
+ // if (this.$refs.addFromRef) {
|
|
|
+ // this.$refs.addFromRef.setData(res.data.result.resultMap);
|
|
|
+ // } else {
|
|
|
+ // console.error('addFromRef is undefined');
|
|
|
+ // }
|
|
|
}
|
|
|
} else {
|
|
|
this.subTableName = res.data.result.dragTables[1].dtTableName;
|
|
@@ -1218,9 +1125,9 @@ export default {
|
|
|
defaultValue: mainForm.showValue ? mainForm.showValue[0].resultMap : {},
|
|
|
});
|
|
|
if (subFormList && subFormList.length > 0) {
|
|
|
- console.log("subFormList",subFormList)
|
|
|
+ console.log("subFormList", subFormList)
|
|
|
subFormList.forEach((item) => {
|
|
|
- console.log("sub item",item)
|
|
|
+ console.log("sub item", item)
|
|
|
let showValue = null;
|
|
|
if (item.showValue) {
|
|
|
showValue = item.showValue[0];
|
|
@@ -1270,7 +1177,7 @@ export default {
|
|
|
formType: item.showTemplate.spare == "2" ? "batch" : "normal",
|
|
|
defaultValue,
|
|
|
insertMap: item.insertMap,
|
|
|
- updateMap:item.updateMap,
|
|
|
+ updateMap: item.updateMap,
|
|
|
isMainForm: false,
|
|
|
});
|
|
|
console.log(this.FormNameList)
|
|
@@ -1367,7 +1274,7 @@ export default {
|
|
|
this.$refs.mychild.pageList();
|
|
|
this.$modal.msgSuccess("删除成功");
|
|
|
})
|
|
|
- .catch(() => {});
|
|
|
+ .catch(() => { });
|
|
|
},
|
|
|
// 批量删除接口
|
|
|
handleBatchDelete() {
|
|
@@ -1393,7 +1300,7 @@ export default {
|
|
|
this.$refs.mychild.pageList();
|
|
|
this.$modal.msgSuccess("删除成功");
|
|
|
})
|
|
|
- .catch(() => {});
|
|
|
+ .catch(() => { });
|
|
|
},
|
|
|
/** 导出按钮操作 */
|
|
|
handleExport() {
|
|
@@ -1427,7 +1334,7 @@ export default {
|
|
|
importTemplate() {
|
|
|
this.download(
|
|
|
process.env.VUE_APP_BASE_API1 +
|
|
|
- `common/exportTemplate?tableName=${this.tableName}&sqlkey=${this.templateInfo.template.sqlKey}`,
|
|
|
+ `common/exportTemplate?tableName=${this.tableName}&sqlkey=${this.templateInfo.template.sqlKey}`,
|
|
|
{},
|
|
|
`下载模版名称${new Date().getTime()}.xlsx`
|
|
|
);
|
|
@@ -1443,8 +1350,8 @@ export default {
|
|
|
this.$refs.upload.clearFiles();
|
|
|
this.$alert(
|
|
|
"<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" +
|
|
|
- response.msg +
|
|
|
- "</div>",
|
|
|
+ response.msg +
|
|
|
+ "</div>",
|
|
|
"导入结果",
|
|
|
{ dangerouslyUseHTMLString: true }
|
|
|
);
|
|
@@ -1473,7 +1380,7 @@ export default {
|
|
|
this.addLists.push(...val);
|
|
|
},
|
|
|
// 绑定弹窗Dialog确定按钮
|
|
|
- btnComfirm() {},
|
|
|
+ btnComfirm() { },
|
|
|
// 去掉表名 开头字母小写
|
|
|
formatField(field = "", tableName) {
|
|
|
let temp = field.replace(tableName, "");
|
|
@@ -1501,7 +1408,7 @@ export default {
|
|
|
});
|
|
|
},
|
|
|
// 处理 动态表单 动态表格 修改数据
|
|
|
- getEditBatchData(values, data) {},
|
|
|
+ getEditBatchData(values, data) { },
|
|
|
// 处理 表单组 含有动态表格 新增数据
|
|
|
getFormGroupBatchData(values, index, result) {
|
|
|
let tableName = Object.keys(values.data.batch)[0];
|
|
@@ -1554,16 +1461,16 @@ export default {
|
|
|
item.fieldValue
|
|
|
? item.fieldValue
|
|
|
: this.currentRow[
|
|
|
- camelCase(item.fieldName.replace(".", "_"))
|
|
|
- ];
|
|
|
+ camelCase(item.fieldName.replace(".", "_"))
|
|
|
+ ];
|
|
|
});
|
|
|
conditionData.forEach((item) => {
|
|
|
data.conditionMap[item.fieldName.split(".")[1]] =
|
|
|
item.fieldValue
|
|
|
? item.fieldValue
|
|
|
: this.currentRow[
|
|
|
- camelCase(item.fieldName.replace(".", "_"))
|
|
|
- ];
|
|
|
+ camelCase(item.fieldName.replace(".", "_"))
|
|
|
+ ];
|
|
|
});
|
|
|
}
|
|
|
if (Object.keys(this.defaultValue).length) {
|
|
@@ -1620,13 +1527,13 @@ export default {
|
|
|
promiseArray.push(...item);
|
|
|
});
|
|
|
} else {
|
|
|
- console.log("res",this.FormNameList)
|
|
|
+ console.log("res", this.FormNameList)
|
|
|
promiseArray = this.FormNameList.map((item) => {
|
|
|
- console.log("如何循环---",item);
|
|
|
+ console.log("如何循环---", item);
|
|
|
return this.$refs.formGroupRef?.getFormData(item);
|
|
|
});
|
|
|
}
|
|
|
- console.log(promiseArray,"111111")
|
|
|
+ console.log(promiseArray, "111111")
|
|
|
Promise.all(promiseArray).then(async (res) => {
|
|
|
// console.log("res", res);
|
|
|
// return;
|
|
@@ -1693,8 +1600,8 @@ export default {
|
|
|
item.fieldValue
|
|
|
? item.fieldValue
|
|
|
: this.currentRow[
|
|
|
- camelCase(item.fieldName.replace(".", "_"))
|
|
|
- ];
|
|
|
+ camelCase(item.fieldName.replace(".", "_"))
|
|
|
+ ];
|
|
|
});
|
|
|
payLoad.updateCommonEntityList.push(result);
|
|
|
} else {
|
|
@@ -1744,7 +1651,7 @@ export default {
|
|
|
let fieldName = formItem.split(".")[1];
|
|
|
let value =
|
|
|
this.currentRow[
|
|
|
- camelCase(relateFormItem.replace(".", "_"))
|
|
|
+ camelCase(relateFormItem.replace(".", "_"))
|
|
|
];
|
|
|
result.conditionMap[fieldName] = value;
|
|
|
payLoad.updateCommonEntityList.push(result);
|
|
@@ -1794,11 +1701,11 @@ export default {
|
|
|
});
|
|
|
} else if (this.currentBtnData.btnType == "INITIATED") {
|
|
|
payLoad.updateCommonEntityList = res.map((item, index) => {
|
|
|
- let a={};
|
|
|
- if(item.updateMap?.length){
|
|
|
- item.updateMap.forEach((item) => {
|
|
|
- a[item.fieldName.split(".")[1]] =item.refValue;
|
|
|
- })
|
|
|
+ let a = {};
|
|
|
+ if (item.updateMap?.length) {
|
|
|
+ item.updateMap.forEach((item) => {
|
|
|
+ a[item.fieldName.split(".")[1]] = item.refValue;
|
|
|
+ })
|
|
|
}
|
|
|
let result = {
|
|
|
basicMap: {
|
|
@@ -1819,8 +1726,8 @@ export default {
|
|
|
item.fieldValue
|
|
|
? item.fieldValue
|
|
|
: this.currentRow[
|
|
|
- camelCase(item.fieldName.replace(".", "_"))
|
|
|
- ];
|
|
|
+ camelCase(item.fieldName.replace(".", "_"))
|
|
|
+ ];
|
|
|
});
|
|
|
} else {
|
|
|
// 从表条件
|
|
@@ -1833,7 +1740,7 @@ export default {
|
|
|
return result;
|
|
|
});
|
|
|
}
|
|
|
- console.log( payLoad.updateCommonEntityList,"hmc");
|
|
|
+ console.log(payLoad.updateCommonEntityList, "hmc");
|
|
|
data.basicMap.BpmRunNodeFormDateVo = payLoad;
|
|
|
// return;
|
|
|
try {
|
|
@@ -1910,8 +1817,8 @@ export default {
|
|
|
// 使用提交数据类型的按钮获取数据
|
|
|
tempSubBtn(getData) {
|
|
|
getData()
|
|
|
- .then((values) => {})
|
|
|
- .catch(() => {});
|
|
|
+ .then((values) => { })
|
|
|
+ .catch(() => { });
|
|
|
},
|
|
|
// 判断是否生效行样式
|
|
|
cellStyle({ row, column, rowIndex, columnIndex }) {
|
|
@@ -2054,7 +1961,7 @@ export default {
|
|
|
},
|
|
|
// 操作列回调
|
|
|
excuteHandler(btnData, row) {
|
|
|
- console.log("btnData, row", btnData, row);
|
|
|
+ // console.log("btnData, row", btnData, row);
|
|
|
let { btnType, btnParams, btnFormType } = btnData;
|
|
|
this.formType = btnFormType;
|
|
|
this.currentBtnData = btnData;
|
|
@@ -2226,8 +2133,8 @@ export default {
|
|
|
item.fieldValue
|
|
|
? item.fieldValue
|
|
|
: this.currentRow[
|
|
|
- camelCase(item.fieldName.replace(".", "_"))
|
|
|
- ];
|
|
|
+ camelCase(item.fieldName.replace(".", "_"))
|
|
|
+ ];
|
|
|
});
|
|
|
}
|
|
|
data.basicMap.btnType = this.currentBtnData.btnType;
|
|
@@ -2250,10 +2157,10 @@ export default {
|
|
|
this.$refs.mychild.pageList();
|
|
|
// this.$modal.msgSuccess("操作成功");
|
|
|
})
|
|
|
- .catch(() => {});
|
|
|
+ .catch(() => { });
|
|
|
},
|
|
|
// k-form-build表单变化回调
|
|
|
- formChangeHandler(value, label) {},
|
|
|
+ formChangeHandler(value, label) { },
|
|
|
},
|
|
|
};
|
|
|
</script>
|