|
@@ -0,0 +1,1808 @@
|
|
|
+<template>
|
|
|
+ <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
|
|
|
+ >
|
|
|
+ <i class="el-icon-upload"></i>
|
|
|
+ <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
|
|
|
+ <div class="el-upload__tip text-center" slot="tip">
|
|
|
+
|
|
|
+ <span>仅允许导入xls、xlsx格式文件。</span>
|
|
|
+ <el-link
|
|
|
+ type="primary"
|
|
|
+ :underline="false"
|
|
|
+ style="font-size: 12px; vertical-align: baseline"
|
|
|
+ @click="importTemplate"
|
|
|
+ >下载模板
|
|
|
+ </el-link>
|
|
|
+ </div>
|
|
|
+ </el-upload>
|
|
|
+ <div slot="footer" class="dialog-footer">
|
|
|
+ <el-button type="primary" @click="submitFileForm">确 定</el-button>
|
|
|
+ <el-button @click="upload.open = false">取 消</el-button>
|
|
|
+ </div>
|
|
|
+ </el-dialog>
|
|
|
+ <Queryfrom
|
|
|
+ :form-vals="templateInfo.where"
|
|
|
+ :statisticList="statisticList"
|
|
|
+ :showCount="showCount"
|
|
|
+ :showSearch="showSearch"
|
|
|
+ @getList="getList"
|
|
|
+ ref="mychild"
|
|
|
+ />
|
|
|
+ <!-- <el-row :gutter="10" class="mb8">
|
|
|
+ <el-col :span="1.5">
|
|
|
+ <el-button
|
|
|
+ type="primary"
|
|
|
+ plain
|
|
|
+ icon="el-icon-plus"
|
|
|
+ size="mini"
|
|
|
+ @click="handleAdd"
|
|
|
+ >新增
|
|
|
+ </el-button>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="1.5" v-if="false">
|
|
|
+ <el-button
|
|
|
+ type="success"
|
|
|
+ plain
|
|
|
+ icon="el-icon-edit"
|
|
|
+ size="mini"
|
|
|
+ :disabled="single"
|
|
|
+ @click="handleUpdate"
|
|
|
+ >修改
|
|
|
+ </el-button>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="1.5">
|
|
|
+ <el-button
|
|
|
+ type="danger"
|
|
|
+ plain
|
|
|
+ icon="el-icon-delete"
|
|
|
+ size="mini"
|
|
|
+ :disabled="multiple"
|
|
|
+ @click="handleBatchDelete"
|
|
|
+ >删除
|
|
|
+ </el-button>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="1.5">
|
|
|
+ <el-button
|
|
|
+ plain
|
|
|
+ icon="el-icon-upload2"
|
|
|
+ size="mini"
|
|
|
+ @click="upload.open = true"
|
|
|
+ >导入
|
|
|
+ </el-button>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="1.5">
|
|
|
+ <el-button
|
|
|
+ type="warning"
|
|
|
+ plain
|
|
|
+ icon="el-icon-download"
|
|
|
+ size="mini"
|
|
|
+ @click="handleExport"
|
|
|
+ >导出
|
|
|
+ </el-button>
|
|
|
+ </el-col>
|
|
|
+ <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-column>
|
|
|
+ <!-- <span v-for="(key, val) in columns" :key="key">
|
|
|
+ <el-table-column :label="key" align="center" :prop="val" />
|
|
|
+ </span> -->
|
|
|
+ <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[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>
|
|
|
+ <!-- 标签字体样式 -->
|
|
|
+ <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 }}</el-tag
|
|
|
+ >
|
|
|
+ </template>
|
|
|
+ </template>
|
|
|
+ <!-- 显示默认值 -->
|
|
|
+ <template v-else>
|
|
|
+ {{ scope.row[item.key] }}
|
|
|
+ </template>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <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>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+ <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>
|
|
|
+ <!-- <iframe
|
|
|
+ :src="iframeUrl"
|
|
|
+ width="100%"
|
|
|
+ height="600px"
|
|
|
+ style="border: none"
|
|
|
+ scrolling="no"
|
|
|
+ >
|
|
|
+ </iframe> -->
|
|
|
+ <!-- <template v-else> -->
|
|
|
+ <template>
|
|
|
+ <FormList
|
|
|
+ v-show="formType == 'dragFormGroup'"
|
|
|
+ ref="formGroupRef"
|
|
|
+ :formList="formList"
|
|
|
+ ></FormList>
|
|
|
+ <!-- <el-button @click="showValue">test</el-button> -->
|
|
|
+ </template>
|
|
|
+ <template>
|
|
|
+ <k-form-build
|
|
|
+ v-if="jsonData && formType == 'dragForm'"
|
|
|
+ class="formBuild"
|
|
|
+ ref="addFromRef"
|
|
|
+ :dynamicData="dynamicData"
|
|
|
+ :defaultValue="defaultValue"
|
|
|
+ @submit="tempSubBtn"
|
|
|
+ @change="formChangeHandler"
|
|
|
+ :value="jsonData"
|
|
|
+ />
|
|
|
+ </template>
|
|
|
+
|
|
|
+ <div slot="footer" class="dialog-footer">
|
|
|
+ <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"
|
|
|
+ >
|
|
|
+ </DialogTemplate>
|
|
|
+ <span slot="footer" class="dialog-footer">
|
|
|
+ <el-button @click="btnDialogVisible = false">取 消</el-button>
|
|
|
+ <el-button type="primary" @click="btnComfirm">确 定</el-button>
|
|
|
+ </span>
|
|
|
+ </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"
|
|
|
+ >
|
|
|
+ </DialogTemplate>
|
|
|
+ <span slot="footer" class="dialog-footer">
|
|
|
+ <el-button @click="btnDialogVisible = false">取 消</el-button>
|
|
|
+ <el-button type="primary" @click="btnComfirm">确 定</el-button>
|
|
|
+ </span>
|
|
|
+ </el-dialog>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+<script>
|
|
|
+import {
|
|
|
+ delTableData,
|
|
|
+ dragTableInfo,
|
|
|
+ listTable,
|
|
|
+ unionListTableData,
|
|
|
+ getInfoBySqlKey,
|
|
|
+ btnCommonApi,
|
|
|
+ addTableData,
|
|
|
+ batchEdit,
|
|
|
+ getStatisticList,
|
|
|
+} from "@/api/tablelist/commonTable";
|
|
|
+import { listData } from "@/api/system/tenant/data";
|
|
|
+import { getToken } from "@/utils/auth";
|
|
|
+import Queryfrom from "@/views/tablelist/commonTable/queryfrom.vue";
|
|
|
+import { camelCase, toUnderline } from "@/utils";
|
|
|
+import { inputDisableComplete } from "@/utils/other";
|
|
|
+import Menu from "@/views/tablelist/commonTable/BtnMenu.vue";
|
|
|
+import { checkRole } from "@/utils/permission";
|
|
|
+import DialogTemplate from "@/views/dialogTemplate/components/index.vue";
|
|
|
+import FormList from "@/components/FormGroup/formList.vue";
|
|
|
+import { v4 as uuidv4 } from "uuid";
|
|
|
+
|
|
|
+export default {
|
|
|
+ name: "listInfo",
|
|
|
+ components: { Queryfrom, Menu, DialogTemplate, FormList },
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ // 绑定按钮dialog
|
|
|
+ btnDialogVisible: false,
|
|
|
+ // 绑定修改dialog
|
|
|
+ groupKey: "",
|
|
|
+ // 遮罩层
|
|
|
+ loading: true,
|
|
|
+ // 选中数组
|
|
|
+ ids: [],
|
|
|
+ // 非单个禁用
|
|
|
+ single: true,
|
|
|
+ // 非多个禁用
|
|
|
+ multiple: true,
|
|
|
+ // 显示统计
|
|
|
+ showCount: true,
|
|
|
+ // 显示搜索条件
|
|
|
+ showSearch: true,
|
|
|
+ // 总条数
|
|
|
+ total: 0,
|
|
|
+ // 用户表格数据
|
|
|
+ tableList: [],
|
|
|
+ // 弹出层标题
|
|
|
+ title: "",
|
|
|
+ // 日期范围
|
|
|
+ dateRange: [],
|
|
|
+ // 表单参数
|
|
|
+ form: {},
|
|
|
+ rules: {},
|
|
|
+ // cru 弹窗
|
|
|
+ open: false,
|
|
|
+ // excel共通导入数据
|
|
|
+ upload: {
|
|
|
+ // 是否显示弹出层
|
|
|
+ open: false,
|
|
|
+ // 弹出层标题(
|
|
|
+ title: "",
|
|
|
+ // 是否禁用上传
|
|
|
+ isUploading: false,
|
|
|
+ // 是否更新已经存在的数据
|
|
|
+ updateSupport: 0,
|
|
|
+ // 设置上传的请求头部
|
|
|
+ headers: { Authorization: "Bearer " + getToken() },
|
|
|
+ // 上传的地址
|
|
|
+ url: process.env.VUE_APP_BASE_API1 + "common/uploadData",
|
|
|
+ },
|
|
|
+ // 排序方式 默认降序
|
|
|
+ sortOrder: true,
|
|
|
+ // 共通查询参数接受子组件的参数
|
|
|
+ queryParams: {
|
|
|
+ pageNum: 1, // 第几页
|
|
|
+ pageSize: 10, // 每页大小
|
|
|
+ orderByColumn: "", // 根据某列排序
|
|
|
+ isAsc: "", // desc(降序)或 asc(升序)
|
|
|
+ // 基本查询参数
|
|
|
+ basicMap: {
|
|
|
+ tableName: "drag_form",
|
|
|
+ },
|
|
|
+ // 当前表字段筛选参数
|
|
|
+ queryMap: {
|
|
|
+ // 当前查询基本参数
|
|
|
+ // ... key : value 当前页面的筛选条件
|
|
|
+ // 超级查询的唯一值
|
|
|
+ queryCriteriaValue: "",
|
|
|
+ },
|
|
|
+ },
|
|
|
+ // 列信息
|
|
|
+ columns: {},
|
|
|
+ // 当前模版信息
|
|
|
+ templateInfo: {},
|
|
|
+ // 查询条件
|
|
|
+ queryFromWhere: {},
|
|
|
+ // 当前table唯一标识
|
|
|
+ tableKey: null,
|
|
|
+ // 当前表名称
|
|
|
+ tableName: null,
|
|
|
+ //存放html代码块
|
|
|
+ iframeUrl: "",
|
|
|
+ //存放表单渲染数据
|
|
|
+ jsonData: {},
|
|
|
+ // 回显表格数据,
|
|
|
+ defaultValue: {},
|
|
|
+ // 统计card
|
|
|
+ statisticList: [],
|
|
|
+ // 样式表
|
|
|
+ styleList: [],
|
|
|
+ // 字典样式对象
|
|
|
+ dictStyleObj: {},
|
|
|
+ // 操作列 按钮数据
|
|
|
+ excuteBtnArr: [],
|
|
|
+ // 下拉框动态数据
|
|
|
+ dynamicData: {},
|
|
|
+ // 当前点击按钮的数据
|
|
|
+ currentBtnData: {},
|
|
|
+ // 修改选中行
|
|
|
+ rowobj: {},
|
|
|
+ // 该行的统计信息
|
|
|
+ subCount: [],
|
|
|
+ tableCount: [],
|
|
|
+ // 弹窗新增数据
|
|
|
+ addLists: [],
|
|
|
+ subTableName: "",
|
|
|
+ // 当前点击行的数据
|
|
|
+ currentRow: {},
|
|
|
+ // 操作列是否显示隐藏
|
|
|
+ isShowExcuteCol: false,
|
|
|
+
|
|
|
+ // 表单组数据
|
|
|
+ formList: [],
|
|
|
+ formType: "dragFormGroup",
|
|
|
+ FormNameList: [], //表单组中表格名称
|
|
|
+ FormListDefaultValue: {}, //表单组的默认表单数据
|
|
|
+ };
|
|
|
+ },
|
|
|
+
|
|
|
+ created() {
|
|
|
+ // 得到当前展示的table的唯一标识
|
|
|
+ this.tableKey = this.$route.query.tableKey;
|
|
|
+ },
|
|
|
+ watch: {},
|
|
|
+ computed: {
|
|
|
+ // isShowExcuteCol() {
|
|
|
+ // let res = false;
|
|
|
+ // if (!this.excuteBtnArr || !this.excuteBtnArr.length) {
|
|
|
+ // res = false;
|
|
|
+ // } else {
|
|
|
+ // res = !this.excuteBtnArr?.every((arr) => arr.children.length == 0);
|
|
|
+ // }
|
|
|
+ // this.$nextTick(() => {
|
|
|
+ // console.log(res);
|
|
|
+ // this.$refs.tableRef.doLayout();
|
|
|
+ // });
|
|
|
+ // return res;
|
|
|
+ // },
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ // test
|
|
|
+ showValue() {
|
|
|
+ console.log(this.$refs.formGroupRef);
|
|
|
+ this.$refs.formGroupRef.setDefaultValue();
|
|
|
+ },
|
|
|
+ // 计算操作列的显示与隐藏
|
|
|
+ calcuteExcuteCol() {
|
|
|
+ if (!this.excuteBtnArr || !this.excuteBtnArr.length) {
|
|
|
+ this.isShowExcuteCol = false;
|
|
|
+ } else {
|
|
|
+ this.isShowExcuteCol = !this.excuteBtnArr?.every(
|
|
|
+ (arr) => arr.children.length == 0
|
|
|
+ );
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 获取row-key
|
|
|
+ getRowKey(row) {
|
|
|
+ return row[
|
|
|
+ camelCase(this.tableName + "_" + this.templateInfo.template?.primaryKey)
|
|
|
+ ];
|
|
|
+ },
|
|
|
+ /** 查询列表 */
|
|
|
+ getList(queryParams) {
|
|
|
+ this.loading = true;
|
|
|
+ // 序列化当前查询参数列表
|
|
|
+ queryParams && (this.queryParams.queryMap = queryParams.queryMap);
|
|
|
+ // 获取当前表单结构信息
|
|
|
+ dragTableInfo({ queryMap: { tableKey: this.tableKey } })
|
|
|
+ .then((res) => {
|
|
|
+ // 得到当前模版信息 --- sql columns queryWhere
|
|
|
+ this.templateInfo = res.data.resultMap;
|
|
|
+ this.styleList = res.data.resultMap.style?.map((item) => {
|
|
|
+ item.styleField = camelCase(
|
|
|
+ item.styleField.replace(".", "_") || ""
|
|
|
+ );
|
|
|
+ return item;
|
|
|
+ });
|
|
|
+ // 获取操作列的按钮数据
|
|
|
+ this.excuteBtnArr = res.data.resultMap.button;
|
|
|
+ this.calcuteExcuteCol();
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.$refs.tableRef.doLayout();
|
|
|
+ });
|
|
|
+ this.queryParams.orderByColumn =
|
|
|
+ res.data.resultMap.querySql.orderByColumn;
|
|
|
+ this.sortOrder = JSON.parse(res.data.resultMap.querySql.sortOrder);
|
|
|
+ // 根据拖拽时设置当前列表排列顺序
|
|
|
+ this.queryParams.isAsc = this.sortOrder ? "DESC" : "ASC";
|
|
|
+ this.tableName = this.templateInfo.template.dtTableName;
|
|
|
+ // 得到查询条件
|
|
|
+ this.queryFromWhere = res.data.resultMap.where;
|
|
|
+ // 得到当前列表信息
|
|
|
+ this.columns = this.columnsHandler(
|
|
|
+ JSON.parse(this.templateInfo.template.dtColumnName)
|
|
|
+ );
|
|
|
+ })
|
|
|
+ .finally((fes) => {
|
|
|
+ if (this.templateInfo == {}) return;
|
|
|
+ // 调用查询需要携带当前table的唯一标识
|
|
|
+ this.queryParams.queryMap.sqlkey = this.templateInfo.template.sqlKey;
|
|
|
+ this.queryParams.orderByColumn = camelCase(
|
|
|
+ this.queryParams.orderByColumn || ""
|
|
|
+ );
|
|
|
+ // 根据sql语句查询当前表数据
|
|
|
+ unionListTableData(this.queryParams).then(async (res) => {
|
|
|
+ this.tableList = [];
|
|
|
+ res.rows.forEach((item) => {
|
|
|
+ this.tableList.push(item.resultMap);
|
|
|
+ });
|
|
|
+ // 驼峰转换
|
|
|
+ let tempTableList = [];
|
|
|
+ tempTableList = this.tableList.map((item) => {
|
|
|
+ let kv = {};
|
|
|
+ for (let itemKey in item) {
|
|
|
+ kv[camelCase(itemKey)] = item[itemKey];
|
|
|
+ }
|
|
|
+ return kv;
|
|
|
+ });
|
|
|
+ // this.setDictStyleData().then(() => {
|
|
|
+ // this.tableList = this.setFieldStyleData(this.tableList);
|
|
|
+ // });
|
|
|
+ this.tableList = await this.setFieldStyleData(tempTableList);
|
|
|
+ this.total = res.total;
|
|
|
+ // this.$nextTick(() => {
|
|
|
+ // this.$refs.tableRef?.clearSelection();
|
|
|
+ // });
|
|
|
+ this.loading = false;
|
|
|
+ });
|
|
|
+
|
|
|
+ // 查询统计信息
|
|
|
+ getStatisticList({
|
|
|
+ queryMap: {
|
|
|
+ tableKey: this.templateInfo.template.tableKey,
|
|
|
+ queryCriteriaValue: this.queryParams.queryMap.queryCriteriaValue,
|
|
|
+ },
|
|
|
+ }).then((res) => {
|
|
|
+ this.statisticList = res.data;
|
|
|
+ });
|
|
|
+ });
|
|
|
+ },
|
|
|
+ isUpperCase(char) {
|
|
|
+ return char === char.toUpperCase();
|
|
|
+ },
|
|
|
+ // 下划线命名转驼峰命名
|
|
|
+ toUnderScoreCase(str) {
|
|
|
+ if (str === null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ let sb = "";
|
|
|
+ // 前置字符是否大写
|
|
|
+ let preCharIsUpperCase = true;
|
|
|
+ // 当前字符是否大写
|
|
|
+ let curreCharIsUpperCase = true;
|
|
|
+ // 下一字符是否大写
|
|
|
+ let nexteCharIsUpperCase = true;
|
|
|
+ for (let i = 0; i < str.length; i++) {
|
|
|
+ let c = str.charAt(i);
|
|
|
+ if (i > 0) {
|
|
|
+ preCharIsUpperCase = isUpperCase(str.charAt(i - 1));
|
|
|
+ } else {
|
|
|
+ preCharIsUpperCase = false;
|
|
|
+ }
|
|
|
+
|
|
|
+ curreCharIsUpperCase = isUpperCase(c);
|
|
|
+
|
|
|
+ if (i < str.length - 1) {
|
|
|
+ nexteCharIsUpperCase = isUpperCase(str.charAt(i + 1));
|
|
|
+ }
|
|
|
+
|
|
|
+ if (
|
|
|
+ preCharIsUpperCase &&
|
|
|
+ curreCharIsUpperCase &&
|
|
|
+ !nexteCharIsUpperCase
|
|
|
+ ) {
|
|
|
+ sb += SEPARATOR;
|
|
|
+ } else if (i !== 0 && !preCharIsUpperCase && curreCharIsUpperCase) {
|
|
|
+ sb += SEPARATOR;
|
|
|
+ }
|
|
|
+ sb += c.toLowerCase();
|
|
|
+ }
|
|
|
+
|
|
|
+ return sb;
|
|
|
+ },
|
|
|
+ // 处理列表信息
|
|
|
+ columnsHandler(columns) {
|
|
|
+ let resArr = [];
|
|
|
+ columns.forEach((item) => {
|
|
|
+ for (const key in item) {
|
|
|
+ let tempObj = {};
|
|
|
+ tempObj.key = camelCase(key);
|
|
|
+ tempObj.value = item[key];
|
|
|
+ resArr.push(tempObj);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return resArr;
|
|
|
+ },
|
|
|
+ // 取消按钮
|
|
|
+ cancel() {
|
|
|
+ this.open = false;
|
|
|
+ // this.reset();
|
|
|
+ },
|
|
|
+ // 分页查询
|
|
|
+ pageList(row) {
|
|
|
+ // 调用子组件-》携带子组件参数请求后台
|
|
|
+ this.$refs.mychild.pageList(
|
|
|
+ row == undefined
|
|
|
+ ? {
|
|
|
+ limit: this.queryParams.pageSize,
|
|
|
+ page: this.queryParams.pageNum,
|
|
|
+ }
|
|
|
+ : row
|
|
|
+ );
|
|
|
+ },
|
|
|
+ // 多选框选中数据
|
|
|
+ handleSelectionChange(selection) {
|
|
|
+ this.ids = selection.map(
|
|
|
+ (item) =>
|
|
|
+ item[
|
|
|
+ camelCase(
|
|
|
+ this.tableName + "_" + this.templateInfo.template?.primaryKey
|
|
|
+ )
|
|
|
+ ]
|
|
|
+ );
|
|
|
+ this.single = selection.length != 1;
|
|
|
+ this.multiple = !selection.length;
|
|
|
+ },
|
|
|
+
|
|
|
+ // 更多操作触发
|
|
|
+ handleCommand(command, row) {
|
|
|
+ switch (command) {
|
|
|
+ case "handleResetPwd":
|
|
|
+ this.handleResetPwd(row);
|
|
|
+ break;
|
|
|
+ case "handleAuthRole":
|
|
|
+ this.handleAuthRole(row);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ /** 新增按钮操作 */
|
|
|
+ handleAdd(row) {
|
|
|
+ // this.reset();
|
|
|
+ this.defaultValue = {};
|
|
|
+ this.formType = "dragForm";
|
|
|
+ getInfoBySqlKey(this.templateInfo.template.sqlKey).then(({ data }) => {
|
|
|
+ if (!data || !data.dfVueTemplate) {
|
|
|
+ this.jsonData = false;
|
|
|
+ this.$message.error("当前表格未绑定表单!");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (data.dfFormSql) {
|
|
|
+ let dynamicData = JSON.parse(data.dfFormSql);
|
|
|
+ Object.assign(this.dynamicData, dynamicData);
|
|
|
+ }
|
|
|
+ this.jsonData = JSON.parse(data.dfVueTemplate);
|
|
|
+ this.open = true;
|
|
|
+ this.title = "添加信息";
|
|
|
+ this.form.password = this.initPassword;
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.$refs.addFromRef.reset();
|
|
|
+ inputDisableComplete();
|
|
|
+ });
|
|
|
+ });
|
|
|
+ },
|
|
|
+ longestCommonSubstring(strs) {
|
|
|
+ if (!strs || strs.includes("")) return "";
|
|
|
+ let str1_Length = strs[0].length;
|
|
|
+ let str_Nums = strs.length;
|
|
|
+ let flag = 0;
|
|
|
+ for (let i = 0; i < str1_Length && flag == 0; i++) {
|
|
|
+ let char = strs[0][i];
|
|
|
+ for (var j = 1; j < str_Nums; j++) {
|
|
|
+ if (char !== strs[j][i] || i == strs[j].length) {
|
|
|
+ return strs[1].substring(0, i);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return strs[0];
|
|
|
+ },
|
|
|
+ // 绑定dialog对话框关闭
|
|
|
+ handleClose() {
|
|
|
+ this.btnDialogVisible = false;
|
|
|
+ },
|
|
|
+ getLastUppercaseWord(text) {
|
|
|
+ const pattern = /\b[A-Z][a-z]*\b/g;
|
|
|
+ const matches = [...text.matchAll(pattern)];
|
|
|
+ if (matches.length > 0) {
|
|
|
+ const lastMatch = matches[matches.length - 1][0];
|
|
|
+ return lastMatch;
|
|
|
+ } else {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 延迟
|
|
|
+ sleep(ms) {
|
|
|
+ var unixtime_ms = new Date().getTime();
|
|
|
+ while (new Date().getTime() < unixtime_ms + ms) {}
|
|
|
+ return "";
|
|
|
+ },
|
|
|
+ /** 修改按钮操作 */
|
|
|
+ async handleUpdate(row, btnData) {
|
|
|
+ let nameTable = this.templateInfo.template.dtTableName;
|
|
|
+ this.rowobj = {};
|
|
|
+ let obj = {};
|
|
|
+ this.formList = [];
|
|
|
+ for (let key in row) {
|
|
|
+ let modifiedTable = key
|
|
|
+ .replace(/[A-Z]/g, (match) => `_${match}`)
|
|
|
+ .toLowerCase();
|
|
|
+
|
|
|
+ this.rowobj[modifiedTable] = row[key];
|
|
|
+
|
|
|
+ let str = modifiedTable.substring(nameTable.length + 1);
|
|
|
+ obj[str] = row[key];
|
|
|
+ }
|
|
|
+ // getInfoBySqlKey(this.templateInfo.template.sqlKey).then(({ data }) => {
|
|
|
+ // if (!data || !data.dfVueTemplate) {
|
|
|
+ // this.$message.error("当前表格未绑定表单!");
|
|
|
+ // return;
|
|
|
+ // }});
|
|
|
+
|
|
|
+ // 新的修改请求
|
|
|
+ try {
|
|
|
+ console.log("btnData", btnData);
|
|
|
+ let { btnFormType } = btnData;
|
|
|
+ this.formType = btnFormType;
|
|
|
+ let payLoad = {};
|
|
|
+ let primary = camelCase(
|
|
|
+ this.tableName + "_" + this.templateInfo.template?.primaryKey
|
|
|
+ );
|
|
|
+ // if (btnFormType == "dragFormGroup") {
|
|
|
+ // payLoad.updateCommonEntityList = {
|
|
|
+ // basicMap: {
|
|
|
+ // btnType: this.currentBtnData.btnType,
|
|
|
+ // btnKey: this.currentBtnData.btnKey,
|
|
|
+ // visible: "false",
|
|
|
+ // sqlKey: this.templateInfo.template.sqlKey,
|
|
|
+ // tableName: this.tableName,
|
|
|
+ // },
|
|
|
+ // conditionMap: {},
|
|
|
+ // };
|
|
|
+ // payLoad.updateCommonEntityList.conditionMap[
|
|
|
+ // this.templateInfo.template?.primaryKey
|
|
|
+ // ] = row[primary];
|
|
|
+ // } else {
|
|
|
+ payLoad = {
|
|
|
+ basicMap: {
|
|
|
+ btnType: this.currentBtnData.btnType,
|
|
|
+ btnKey: this.currentBtnData.btnKey,
|
|
|
+ visible: "false",
|
|
|
+ sqlKey: this.templateInfo.template.sqlKey,
|
|
|
+ tableName: this.tableName,
|
|
|
+ },
|
|
|
+ conditionMap: {},
|
|
|
+ };
|
|
|
+ payLoad.conditionMap[this.templateInfo.template?.primaryKey] =
|
|
|
+ row[primary];
|
|
|
+ // }
|
|
|
+
|
|
|
+ let res = await btnCommonApi(payLoad);
|
|
|
+ // 判断是否绑定dialog弹窗
|
|
|
+ if (!this.currentBtnData.btnTableFormGroupKey) {
|
|
|
+ if ((!res.data || !res.data.template) && !res.data?.mainForm) {
|
|
|
+ this.$message.error("当前按钮未绑定表单!");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (btnFormType == "dragFormGroup") {
|
|
|
+ //表单组
|
|
|
+ if (res.code == 200) {
|
|
|
+ if (res.data.mainForm) {
|
|
|
+ //表单组
|
|
|
+ console.log(res.data);
|
|
|
+ this.transformDataFormat(res.data);
|
|
|
+ this.tableName = res.data.mainForm.showTemplate.dfTableName;
|
|
|
+ } else {
|
|
|
+ this.formList = res.data;
|
|
|
+ this.tableName = res.data.dfTableName;
|
|
|
+ }
|
|
|
+ console.log(this.formList);
|
|
|
+ this.open = true;
|
|
|
+ // this.$nextTick(() => {
|
|
|
+ // // this.sleep(1000);
|
|
|
+ // this.$refs.formGroupRef.setDefaultValue();
|
|
|
+ // });
|
|
|
+ } else {
|
|
|
+ this.$message.error("网络异常,请稍后再试");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //单个表单
|
|
|
+ res.data.template.dfFormSql &&
|
|
|
+ (this.dynamicData = JSON.parse(res.data.template.dfFormSql));
|
|
|
+ this.addRealFieldName(res.data.result.resultMap);
|
|
|
+ let resultMap = res.data.result.resultMap;
|
|
|
+
|
|
|
+ Object.assign(this.defaultValue, resultMap);
|
|
|
+ this.jsonData = JSON.parse(res.data.template.dfVueTemplate);
|
|
|
+ this.open = true;
|
|
|
+ this.title = "修改信息";
|
|
|
+ this.form.password = this.initPassword;
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.$refs.addFromRef.setData(res.data.result.resultMap);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ this.subTableName = res.data.result.dragTables[1].dtTableName;
|
|
|
+ this.btnDialogVisible = true;
|
|
|
+ this.groupKey = this.currentBtnData.btnTableFormGroupKey;
|
|
|
+ this.$nextTick(() => {
|
|
|
+ let refChild = this.$refs.dialogRef;
|
|
|
+ refChild.getLists(this.groupKey);
|
|
|
+ });
|
|
|
+
|
|
|
+ let tablesubKey = res.data.result.dragTables[1].tableKey;
|
|
|
+
|
|
|
+ // 查询统计信息
|
|
|
+ getStatisticList({
|
|
|
+ queryMap: {
|
|
|
+ tableKey: tablesubKey,
|
|
|
+ },
|
|
|
+ }).then((res) => {
|
|
|
+ this.subCount = res.data;
|
|
|
+ });
|
|
|
+
|
|
|
+ let prmKey = this.templateInfo.template.primaryKey;
|
|
|
+ let pkey = prmKey.replace(/_([a-z])/g, (match, p1) =>
|
|
|
+ p1.toUpperCase()
|
|
|
+ );
|
|
|
+
|
|
|
+ let data = {
|
|
|
+ queryMap: {
|
|
|
+ tableKey: res.data.result.dragTables[2].tableKey,
|
|
|
+ },
|
|
|
+ };
|
|
|
+
|
|
|
+ let key =
|
|
|
+ "#{" +
|
|
|
+ this.templateInfo.template.dtTableName +
|
|
|
+ "." +
|
|
|
+ this.templateInfo.template.primaryKey;
|
|
|
+
|
|
|
+ data.queryMap[key] =
|
|
|
+ "'" + obj[this.templateInfo.template.primaryKey] + "'";
|
|
|
+
|
|
|
+ getStatisticList(data).then((res) => {
|
|
|
+ this.tableCount = res.data;
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ // let fieldList = Object.keys(resultMap);
|
|
|
+ // let tableName = this.longestCommonSubstring(fieldList);
|
|
|
+ // fieldList.forEach((field) => {
|
|
|
+ // let realField = field.replace(tableName, "");
|
|
|
+ // realField = realField[0].toLocaleLowerCase() + realField.substring(1);
|
|
|
+ // resultMap[realField] = resultMap[field];
|
|
|
+ // });
|
|
|
+ } catch (error) {
|
|
|
+ this.$message.error("网络异常,请稍后再试");
|
|
|
+ console.log(error);
|
|
|
+ }
|
|
|
+ return;
|
|
|
+ // getInfoBySqlKey(this.templateInfo.template.sqlKey).then(({ data }) => {
|
|
|
+ // if (!data || !data.dfVueTemplate) {
|
|
|
+ // this.$message.error("当前表格未绑定表单!");
|
|
|
+ // return;
|
|
|
+ // }
|
|
|
+ // // let fieldList = Object.keys(row);
|
|
|
+ // // let tableName = this.longestCommonSubstring(fieldList);
|
|
|
+ // // fieldList.forEach((field) => {
|
|
|
+ // // let realField = field.replace(tableName, "");
|
|
|
+ // // realField = realField[0].toLocaleLowerCase() + realField.substring(1);
|
|
|
+ // // row[realField] = row[field];
|
|
|
+ // // });
|
|
|
+ // this.addRealFieldName(row);
|
|
|
+ // Object.assign(this.defaultValue, row);
|
|
|
+ // this.jsonData = JSON.parse(data.dfVueTemplate);
|
|
|
+ // this.open = true;
|
|
|
+ // this.title = "修改信息";
|
|
|
+ // this.form.password = this.initPassword;
|
|
|
+ // this.$nextTick(() => {
|
|
|
+ // this.$refs.addFromRef.setData(row);
|
|
|
+ // });
|
|
|
+ // });
|
|
|
+ // return;
|
|
|
+ this.reset();
|
|
|
+ const userId = row.userId || this.ids;
|
|
|
+ getUser(userId).then((response) => {
|
|
|
+ this.form = response.data;
|
|
|
+ this.postOptions = response.posts;
|
|
|
+ this.roleOptions = response.roles;
|
|
|
+ this.$set(this.form, "postIds", response.postIds);
|
|
|
+ this.$set(this.form, "roleIds", response.roleIds);
|
|
|
+ this.open = true;
|
|
|
+ this.title = "修改当前信息";
|
|
|
+ this.form.password = "";
|
|
|
+ });
|
|
|
+ },
|
|
|
+ // 将表单组数据转换成符合单个表单的数据格式
|
|
|
+ transformDataFormat(data) {
|
|
|
+ this.FormNameList = [];
|
|
|
+ let { mainForm, subFormList } = data;
|
|
|
+ this.formList = [];
|
|
|
+ let showValue = mainForm.showValue[0];
|
|
|
+ if (showValue) {
|
|
|
+ mainForm.showTemplate.resultMap = mainForm.showValue;
|
|
|
+ }
|
|
|
+ this.formList.push({
|
|
|
+ template: mainForm.showTemplate,
|
|
|
+ tableName: mainForm.mainFormTable,
|
|
|
+ });
|
|
|
+ this.FormNameList.push({
|
|
|
+ tableName: mainForm.mainFormTable,
|
|
|
+ formItem: mainForm.mainFormItem,
|
|
|
+ relateFormItem: null,
|
|
|
+ });
|
|
|
+ if (subFormList && subFormList.length > 0) {
|
|
|
+ subFormList.forEach((item) => {
|
|
|
+ console.log(item);
|
|
|
+ let showValue = item.showValue[0];
|
|
|
+ if (showValue) {
|
|
|
+ item.showTemplate.resultMap = item.showValue;
|
|
|
+ }
|
|
|
+ this.formList.push({
|
|
|
+ template: item.showTemplate,
|
|
|
+ tableName: item.formItem?.split(".")?.[0],
|
|
|
+ });
|
|
|
+ this.FormNameList.push({
|
|
|
+ tableName: item.formItem?.split(".")?.[0],
|
|
|
+ formItem: item.formItem,
|
|
|
+ relateFormItem: item.relateMainItem,
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 添加真正的字段名
|
|
|
+ addRealFieldName(row) {
|
|
|
+ let fieldList = Object.keys(row);
|
|
|
+ // let tableName = this.longestCommonSubstring(fieldList);
|
|
|
+ let tableName = camelCase(this.tableName);
|
|
|
+ fieldList.forEach((field) => {
|
|
|
+ let realField = field.replace(tableName, "");
|
|
|
+ realField = realField[0].toLocaleLowerCase() + realField.substring(1);
|
|
|
+ row[realField] = row[field];
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ /** 提交按钮 */
|
|
|
+ submitForm: function () {
|
|
|
+ this.$refs["form"].validate((valid) => {
|
|
|
+ if (valid) {
|
|
|
+ if (this.form.userId != undefined) {
|
|
|
+ updateUser(this.form).then((response) => {
|
|
|
+ this.$modal.msgSuccess("修改成功");
|
|
|
+ this.open = false;
|
|
|
+ this.getList();
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ addUser(this.form).then((response) => {
|
|
|
+ this.$modal.msgSuccess("新增成功");
|
|
|
+ this.open = false;
|
|
|
+ this.getList();
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ /** 删除按钮操作
|
|
|
+ *
|
|
|
+ * 删除提示信息语句(标识)
|
|
|
+ * */
|
|
|
+ handleDelete(row, btnData) {
|
|
|
+ let delIds = this.ids;
|
|
|
+ let primary = camelCase(this.templateInfo.template?.primaryKey);
|
|
|
+ // let realyKey=
|
|
|
+ this.addRealFieldName(row);
|
|
|
+ if (row[primary] != undefined && row[primary] != null) {
|
|
|
+ delIds = [];
|
|
|
+ delIds.push(row[primary]);
|
|
|
+ }
|
|
|
+ let data = {
|
|
|
+ basicMap: {
|
|
|
+ btnType: btnData.btnType,
|
|
|
+ btnKey: btnData.btnKey,
|
|
|
+ tableName: this.tableName,
|
|
|
+ },
|
|
|
+ conditionMap: {
|
|
|
+ // id: delIds,
|
|
|
+ },
|
|
|
+ btnParametersMap: {},
|
|
|
+ };
|
|
|
+ if (this.currentBtnData.btnParams) {
|
|
|
+ let btnParams =
|
|
|
+ JSON.parse(this.currentBtnData.btnParams)?.commonFieldData || [];
|
|
|
+ let conditionData =
|
|
|
+ JSON.parse(this.currentBtnData.btnParams).conditionData || [];
|
|
|
+ conditionData.forEach((item) => {
|
|
|
+ data.conditionMap[item.fieldName.split(".")[1]] = item.fieldValue
|
|
|
+ ? item.fieldValue
|
|
|
+ : this.currentRow[camelCase(item.fieldName.replace(".", "_"))];
|
|
|
+ });
|
|
|
+ btnParams.forEach((item) => {
|
|
|
+ data.btnParametersMap[item.fieldName.split(".")[1]] = item.fieldValue
|
|
|
+ ? item.fieldValue
|
|
|
+ : this.currentRow[camelCase(item.fieldName.replace(".", "_"))];
|
|
|
+ });
|
|
|
+ }
|
|
|
+ // data.conditionMap[this.templateInfo.template?.primaryKey] = delIds;
|
|
|
+ this.$modal
|
|
|
+ .confirm('是否确认删除"' + delIds + '"的数据项?')
|
|
|
+ .then(function () {
|
|
|
+ // return delTableData(data);
|
|
|
+ return btnCommonApi(data);
|
|
|
+ })
|
|
|
+ .then(() => {
|
|
|
+ // 调用子组件查询方法 目的是携带上子组件中的查询参数
|
|
|
+ this.$refs.mychild.pageList();
|
|
|
+ this.$modal.msgSuccess("删除成功");
|
|
|
+ })
|
|
|
+ .catch(() => {});
|
|
|
+ },
|
|
|
+ // 批量删除接口
|
|
|
+ handleBatchDelete() {
|
|
|
+ let delIds = this.ids;
|
|
|
+ let primary = camelCase(this.templateInfo.template?.primaryKey);
|
|
|
+ // if (row && row[primary] != undefined && row[primary] != null) {
|
|
|
+ // delIds = [];
|
|
|
+ // delIds.push(row[primary]);
|
|
|
+ // }
|
|
|
+ let data = {
|
|
|
+ basicMap: {
|
|
|
+ tableName: this.tableName,
|
|
|
+ },
|
|
|
+ conditionMap: {
|
|
|
+ // id: delIds,
|
|
|
+ },
|
|
|
+ };
|
|
|
+ // if (this.currentBtnData.btnParams) {
|
|
|
+ // let btnParams = JSON.parse(this.currentBtnData.btnParams);
|
|
|
+ // btnParams.forEach((item) => {
|
|
|
+ // data.btnParametersMap[
|
|
|
+ // this.formatField(item.fieldName, camelCase(this.tableName))
|
|
|
+ // ] = item.fieldValue
|
|
|
+ // ? item.fieldValue
|
|
|
+ // : this.currentRow[item.fieldName];
|
|
|
+ // });
|
|
|
+ // }
|
|
|
+ data.conditionMap[this.templateInfo.template?.primaryKey] = delIds;
|
|
|
+ this.$modal
|
|
|
+ .confirm('是否确认删除"' + delIds + '"的数据项?')
|
|
|
+ .then(function () {
|
|
|
+ return delTableData(data);
|
|
|
+ // return btnCommonApi(data);
|
|
|
+ })
|
|
|
+ .then(() => {
|
|
|
+ // 调用子组件查询方法 目的是携带上子组件中的查询参数
|
|
|
+ this.$refs.mychild.pageList();
|
|
|
+ this.$modal.msgSuccess("删除成功");
|
|
|
+ })
|
|
|
+ .catch(() => {});
|
|
|
+ },
|
|
|
+ /** 导出按钮操作 */
|
|
|
+ handleExport() {
|
|
|
+ let primary = camelCase(this.templateInfo.template?.primaryKey);
|
|
|
+ let realyKey = camelCase(this.tableName + "_" + primary);
|
|
|
+ if (this.ids.length > 0) {
|
|
|
+ this.queryParams["execlMap"] = [];
|
|
|
+ this.ids.forEach((item) => {
|
|
|
+ this.queryParams.execlMap.push(
|
|
|
+ this.tableList.find((ttem) => {
|
|
|
+ return ttem[realyKey] === item;
|
|
|
+ })
|
|
|
+ );
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ this.$message.warning("请至少勾选一条导出数据");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.queryParams.execlMap = JSON.stringify(this.queryParams.execlMap);
|
|
|
+ this.download(
|
|
|
+ process.env.VUE_APP_BASE_API1 + "common/export",
|
|
|
+ {
|
|
|
+ ...this.queryParams,
|
|
|
+ },
|
|
|
+ `文件名称_${new Date().getTime()}.xlsx`
|
|
|
+ );
|
|
|
+ },
|
|
|
+ /** 导入按钮操作 */
|
|
|
+ handleImport() {
|
|
|
+ this.upload.title = "当前导入";
|
|
|
+ this.upload.open = true;
|
|
|
+ },
|
|
|
+ /** 下载模板操作 */
|
|
|
+ importTemplate() {
|
|
|
+ this.download(
|
|
|
+ process.env.VUE_APP_BASE_API1 +
|
|
|
+ `common/exportTemplate?tableName=${this.tableName}&sqlkey=${this.templateInfo.template.sqlKey}`,
|
|
|
+ {},
|
|
|
+ `下载模版名称${new Date().getTime()}.xlsx`
|
|
|
+ );
|
|
|
+ },
|
|
|
+ // 文件上传中处理
|
|
|
+ handleFileUploadProgress(event, file, fileList) {
|
|
|
+ this.upload.isUploading = true;
|
|
|
+ },
|
|
|
+ // 文件上传成功处理
|
|
|
+ handleFileSuccess(response, file, fileList) {
|
|
|
+ this.upload.open = false;
|
|
|
+ this.upload.isUploading = false;
|
|
|
+ this.$refs.upload.clearFiles();
|
|
|
+ this.$alert(
|
|
|
+ "<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" +
|
|
|
+ response.msg +
|
|
|
+ "</div>",
|
|
|
+ "导入结果",
|
|
|
+ { dangerouslyUseHTMLString: true }
|
|
|
+ );
|
|
|
+ this.$refs.mychild.pageList({
|
|
|
+ limit: this.queryParams.pageSize,
|
|
|
+ page: this.queryParams.pageNum,
|
|
|
+ });
|
|
|
+ },
|
|
|
+ //重点在这里
|
|
|
+ handleChange(file, fileList) {
|
|
|
+ file.name = this.tableName + "." + file.name.split(".")[1];
|
|
|
+ fileList.forEach((item) => {
|
|
|
+ item.name = this.tableName + "." + file.name.split(".")[1];
|
|
|
+ });
|
|
|
+ let newFile = new File(
|
|
|
+ [file],
|
|
|
+ this.tableName + "." + file.name.split(".")[1]
|
|
|
+ ); //创建出来也是不可编辑的file对象
|
|
|
+ },
|
|
|
+ // 提交上传文件
|
|
|
+ submitFileForm() {
|
|
|
+ this.$refs.upload.submit();
|
|
|
+ },
|
|
|
+ // 弹窗新增的数
|
|
|
+ addListHandler(val) {
|
|
|
+ this.addLists.push(...val);
|
|
|
+ },
|
|
|
+ // 绑定弹窗Dialog确定按钮
|
|
|
+ btnComfirm() {
|
|
|
+ // let data = {
|
|
|
+ // addListMap:[],
|
|
|
+ // basicMap:{
|
|
|
+ // btnType: 10,
|
|
|
+ // tableName: this.subTableName,
|
|
|
+ // visible: true,
|
|
|
+ // },
|
|
|
+ // commMap: {},
|
|
|
+ // conditionMap: {},
|
|
|
+ // }
|
|
|
+ // // data.addListMap =
|
|
|
+ // btnCommonApi(data).then(res => {
|
|
|
+ // console.log('弹窗确定', res);
|
|
|
+ // })
|
|
|
+ },
|
|
|
+ // 去掉表名 开头字母小写
|
|
|
+ formatField(field = "", tableName) {
|
|
|
+ let temp = field.replace(tableName, "");
|
|
|
+ return toUnderline(temp[0].toLowerCase() + temp.slice(1));
|
|
|
+ },
|
|
|
+ //提交编辑结果按钮回调
|
|
|
+ async editConfirmHandler() {
|
|
|
+ if (this.$refs.addFromRef && this.formType == "dragForm") {
|
|
|
+ this.$refs.addFromRef
|
|
|
+ .getData()
|
|
|
+ .then(async (values) => {
|
|
|
+ let data = {
|
|
|
+ basicMap: {
|
|
|
+ tableName: this.tableName,
|
|
|
+ // btnKey: btnData.btnKey,
|
|
|
+ btnKey: this.currentBtnData.btnKey,
|
|
|
+ },
|
|
|
+ addListMap: [values],
|
|
|
+ conditionMap: {},
|
|
|
+ commMap: {},
|
|
|
+ btnParametersMap: {},
|
|
|
+ };
|
|
|
+ if (this.currentBtnData.btnParams) {
|
|
|
+ let btnParams =
|
|
|
+ JSON.parse(this.currentBtnData.btnParams)?.commonFieldData ||
|
|
|
+ [];
|
|
|
+ let conditionData =
|
|
|
+ JSON.parse(this.currentBtnData.btnParams).conditionData || [];
|
|
|
+ // let
|
|
|
+ btnParams.forEach((item) => {
|
|
|
+ data.btnParametersMap[item.fieldName.split(".")[1]] =
|
|
|
+ item.fieldValue
|
|
|
+ ? item.fieldValue
|
|
|
+ : this.currentRow[
|
|
|
+ camelCase(item.fieldName.replace(".", "_"))
|
|
|
+ ];
|
|
|
+ });
|
|
|
+ conditionData.forEach((item) => {
|
|
|
+ data.conditionMap[item.fieldName.split(".")[1]] =
|
|
|
+ item.fieldValue
|
|
|
+ ? item.fieldValue
|
|
|
+ : this.currentRow[
|
|
|
+ camelCase(item.fieldName.replace(".", "_"))
|
|
|
+ ];
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (Object.keys(this.defaultValue).length) {
|
|
|
+ // data.conditionMap[this.templateInfo.template?.primaryKey] =
|
|
|
+ // this.defaultValue[this.templateInfo.template?.primaryKey];
|
|
|
+ Object.keys(values).map((k) => {
|
|
|
+ data.commMap[k] = values[k];
|
|
|
+ });
|
|
|
+ data.basicMap.btnType = this.currentBtnData.btnType;
|
|
|
+ data.basicMap.visible = true;
|
|
|
+ } else {
|
|
|
+ data.basicMap.btnType = "INSERT";
|
|
|
+ data.basicMap.visible = true;
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ let res = await btnCommonApi(data);
|
|
|
+ if (res.code == 200) {
|
|
|
+ this.$message.success("操作成功");
|
|
|
+ } else {
|
|
|
+ this.$message.error("网络异常,请稍后再试");
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ console.log(error);
|
|
|
+ this.$message.error("网络异常,请稍后再试");
|
|
|
+ }
|
|
|
+ this.getList();
|
|
|
+ this.defaultValue = {};
|
|
|
+ this.open = false;
|
|
|
+ })
|
|
|
+ .catch((res) => {
|
|
|
+ console.log(res);
|
|
|
+ this.$modal.msgError("表单校验失败,请规范填写数据");
|
|
|
+ });
|
|
|
+ } else if (this.formType == "dragFormGroup") {
|
|
|
+ //表单组
|
|
|
+ // console.log(this.$refs.formGroupRef);
|
|
|
+
|
|
|
+ let promiseArray = this.FormNameList.map((item) => {
|
|
|
+ return this.$refs.formGroupRef?.getFormData(item);
|
|
|
+ });
|
|
|
+ Promise.all(promiseArray).then(
|
|
|
+ async (res) => {
|
|
|
+ // 获取到所有表单数据
|
|
|
+ console.log(res);
|
|
|
+ let mainFormData = res[0].data;
|
|
|
+ let data = {
|
|
|
+ basicMap: {
|
|
|
+ tableName: this.tableName,
|
|
|
+ // btnKey: btnData.btnKey,
|
|
|
+ btnKey: this.currentBtnData.btnKey,
|
|
|
+ BpmRunNodeFormDateVo: {},
|
|
|
+ },
|
|
|
+ conditionMap: {},
|
|
|
+ commMap: {},
|
|
|
+ btnParametersMap: {},
|
|
|
+ };
|
|
|
+
|
|
|
+ let btnParams =
|
|
|
+ JSON.parse(this.currentBtnData.btnParams)?.commonFieldData || [];
|
|
|
+ let conditionData =
|
|
|
+ JSON.parse(this.currentBtnData.btnParams)?.conditionData || [];
|
|
|
+ Object.keys(mainFormData).map((k) => {
|
|
|
+ data.commMap[k] = mainFormData[k];
|
|
|
+ });
|
|
|
+ btnParams.forEach((item) => {
|
|
|
+ data.btnParametersMap[item.fieldName.split(".")[1]] =
|
|
|
+ item.fieldValue
|
|
|
+ ? item.fieldValue
|
|
|
+ : this.currentRow[
|
|
|
+ camelCase(item.fieldName.replace(".", "_"))
|
|
|
+ ];
|
|
|
+ });
|
|
|
+ conditionData.forEach((item) => {
|
|
|
+ data.conditionMap[item.fieldName.split(".")[1]] = item.fieldValue
|
|
|
+ ? item.fieldValue
|
|
|
+ : this.currentRow[camelCase(item.fieldName.replace(".", "_"))];
|
|
|
+ });
|
|
|
+
|
|
|
+ console.log("mainFormData", mainFormData);
|
|
|
+ console.log("btnParams", btnParams);
|
|
|
+ console.log("conditionData", conditionData);
|
|
|
+ console.log("btnType", this.currentBtnData.btnType);
|
|
|
+ data.basicMap.btnType = this.currentBtnData.btnType;
|
|
|
+ data.basicMap.visible = true;
|
|
|
+ let payLoad = {};
|
|
|
+ if (this.currentBtnData.btnType == "UPDATE") {
|
|
|
+ //修改
|
|
|
+ payLoad.updateCommonEntityList = res.map((item, index) => {
|
|
|
+ let result = {
|
|
|
+ basicMap: {
|
|
|
+ tableName: item.tableName,
|
|
|
+ },
|
|
|
+ commMap: {
|
|
|
+ ...item.data,
|
|
|
+ },
|
|
|
+ conditionMap: {},
|
|
|
+ };
|
|
|
+ if (index == 0) {
|
|
|
+ //主表条件
|
|
|
+ let conditionData =
|
|
|
+ JSON.parse(this.currentBtnData.btnParams).conditionData ||
|
|
|
+ [];
|
|
|
+ conditionData.forEach((item) => {
|
|
|
+ result.conditionMap[item.fieldName.split(".")[1]] =
|
|
|
+ item.fieldValue
|
|
|
+ ? item.fieldValue
|
|
|
+ : this.currentRow[
|
|
|
+ camelCase(item.fieldName.replace(".", "_"))
|
|
|
+ ];
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ // 从表条件
|
|
|
+ let { formItem, relateFormItem } = item;
|
|
|
+ let fieldName = formItem.split(".")[1];
|
|
|
+ let value =
|
|
|
+ this.currentRow[
|
|
|
+ camelCase(relateFormItem.replace(".", "_"))
|
|
|
+ ];
|
|
|
+ result.conditionMap[fieldName] = value;
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ });
|
|
|
+ } else if (this.currentBtnData.btnType == "INSERT") {
|
|
|
+ // 新增
|
|
|
+ let uuid = uuidv4();
|
|
|
+ console.log(uuid);
|
|
|
+ payLoad.insertCommonEntityList = res.map((item, index) => {
|
|
|
+ let result = {
|
|
|
+ basicMap: {
|
|
|
+ tableName: item.tableName,
|
|
|
+ },
|
|
|
+ addListMap: [
|
|
|
+ {
|
|
|
+ ...item.data,
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ };
|
|
|
+
|
|
|
+ // 添加新增数据的关联条件
|
|
|
+ let { formItem, relateFormItem } = item;
|
|
|
+ console.log(formItem);
|
|
|
+ result.addListMap[0][formItem.split(".")[1]] = uuid;
|
|
|
+ return result;
|
|
|
+ });
|
|
|
+ } else if (this.currentBtnData.btnType == "INITIATED") {
|
|
|
+ // 按照单独的表单投产逻辑收集主表单数据
|
|
|
+ // let mainFormData = res[0].data;//主表单数据
|
|
|
+ // payLoad = {
|
|
|
+ // basicMap: {
|
|
|
+ // tableName: this.tableName,
|
|
|
+ // // btnKey: btnData.btnKey,
|
|
|
+ // btnKey: this.currentBtnData.btnKey,
|
|
|
+ // },
|
|
|
+ // addListMap: mainFormData,
|
|
|
+ // conditionMap: {},
|
|
|
+ // commMap: {},
|
|
|
+ // btnParametersMap: {},
|
|
|
+ // };
|
|
|
+ // if (this.currentBtnData.btnParams) {
|
|
|
+ // let btnParams =
|
|
|
+ // JSON.parse(this.currentBtnData.btnParams)?.commonFieldData ||
|
|
|
+ // [];
|
|
|
+ // let conditionData =
|
|
|
+ // JSON.parse(this.currentBtnData.btnParams).conditionData || [];
|
|
|
+ // // let
|
|
|
+ // btnParams.forEach((item) => {
|
|
|
+ // payLoad.btnParametersMap[item.fieldName.split(".")[1]] =
|
|
|
+ // item.fieldValue
|
|
|
+ // ? item.fieldValue
|
|
|
+ // : this.currentRow[
|
|
|
+ // camelCase(item.fieldName.replace(".", "_"))
|
|
|
+ // ];
|
|
|
+ // });
|
|
|
+ // conditionData.forEach((item) => {
|
|
|
+ // payLoad.conditionMap[item.fieldName.split(".")[1]] =
|
|
|
+ // item.fieldValue
|
|
|
+ // ? item.fieldValue
|
|
|
+ // : this.currentRow[
|
|
|
+ // camelCase(item.fieldName.replace(".", "_"))
|
|
|
+ // ];
|
|
|
+ // });
|
|
|
+ // }
|
|
|
+ // if (Object.keys(this.defaultValue).length) {
|
|
|
+ // // data.conditionMap[this.templateInfo.template?.primaryKey] =
|
|
|
+ // // this.defaultValue[this.templateInfo.template?.primaryKey];
|
|
|
+ // Object.keys(mainFormData).map((k) => {
|
|
|
+ // data.commMap[k] = mainFormData[k];
|
|
|
+ // });
|
|
|
+ // data.basicMap.btnType = this.currentBtnData.btnType;
|
|
|
+ // data.basicMap.visible = true;
|
|
|
+ // } else {
|
|
|
+ // data.basicMap.btnType = "INSERT";
|
|
|
+ // data.basicMap.visible = true;
|
|
|
+ // }
|
|
|
+ // 添加表单组数据处理逻辑
|
|
|
+ payLoad.updateCommonEntityList = res.map((item, index) => {
|
|
|
+ let result = {
|
|
|
+ basicMap: {
|
|
|
+ tableName: item.tableName,
|
|
|
+ },
|
|
|
+ commMap: {
|
|
|
+ ...item.data,
|
|
|
+ },
|
|
|
+ conditionMap: {},
|
|
|
+ };
|
|
|
+ if (index == 0) {
|
|
|
+ //主表条件
|
|
|
+ let conditionData =
|
|
|
+ JSON.parse(this.currentBtnData.btnParams).conditionData ||
|
|
|
+ [];
|
|
|
+ conditionData.forEach((item) => {
|
|
|
+ result.conditionMap[item.fieldName.split(".")[1]] =
|
|
|
+ item.fieldValue
|
|
|
+ ? item.fieldValue
|
|
|
+ : this.currentRow[
|
|
|
+ camelCase(item.fieldName.replace(".", "_"))
|
|
|
+ ];
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ // 从表条件
|
|
|
+ let { formItem, relateFormItem } = item;
|
|
|
+ let fieldName = formItem.split(".")[1];
|
|
|
+ let value =
|
|
|
+ this.currentRow[
|
|
|
+ camelCase(relateFormItem.replace(".", "_"))
|
|
|
+ ];
|
|
|
+ result.conditionMap[fieldName] = value;
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ data.basicMap.BpmRunNodeFormDateVo = payLoad;
|
|
|
+ try {
|
|
|
+ let res = await btnCommonApi(data);
|
|
|
+ if (res.code == 200) {
|
|
|
+ this.$message.success("操作成功");
|
|
|
+ this.getList();
|
|
|
+ this.defaultValue = {};
|
|
|
+ this.open = false;
|
|
|
+ } else {
|
|
|
+ this.$message.error("网络异常,请稍后再试");
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ console.log(error);
|
|
|
+ this.$message.error("网络异常,请稍后再试");
|
|
|
+ }
|
|
|
+ },
|
|
|
+ (err) => {
|
|
|
+ console.log(err);
|
|
|
+ }
|
|
|
+ );
|
|
|
+ } else {
|
|
|
+ // 没有绑定表单
|
|
|
+ let data = {
|
|
|
+ basicMap: {
|
|
|
+ tableName: this.tableName,
|
|
|
+ // btnKey: btnData.btnKey,
|
|
|
+ btnKey: this.currentBtnData.btnKey,
|
|
|
+ btnType: this.currentBtnData.btnType,
|
|
|
+ visible: true,
|
|
|
+ },
|
|
|
+ addListMap: [],
|
|
|
+ conditionMap: {},
|
|
|
+ commMap: {},
|
|
|
+ btnParametersMap: {},
|
|
|
+ };
|
|
|
+ if (this.currentBtnData.btnParams) {
|
|
|
+ let btnParams =
|
|
|
+ JSON.parse(this.currentBtnData.btnParams)?.commonFieldData || [];
|
|
|
+ let conditionData =
|
|
|
+ JSON.parse(this.currentBtnData.btnParams).conditionData || [];
|
|
|
+ conditionData.forEach((item) => {
|
|
|
+ data.conditionMap[item.fieldName.split(".")[1]] = item.fieldValue
|
|
|
+ ? item.fieldValue
|
|
|
+ : this.currentRow[camelCase(item.fieldName.replace(".", "_"))];
|
|
|
+ });
|
|
|
+ btnParams.forEach((item) => {
|
|
|
+ data.btnParametersMap[item.fieldName.split(".")[1]] =
|
|
|
+ item.fieldValue
|
|
|
+ ? item.fieldValue
|
|
|
+ : this.currentRow[camelCase(item.fieldName.replace(".", "_"))];
|
|
|
+ });
|
|
|
+ }
|
|
|
+ // data.basicMap.btnType = this.currentBtnData.btnType;
|
|
|
+ // data.basicMap.visible = true;
|
|
|
+ try {
|
|
|
+ let res = await btnCommonApi(data);
|
|
|
+ if (res.code == 200) {
|
|
|
+ this.$message.success("操作成功");
|
|
|
+ } else {
|
|
|
+ this.$message.error("网络异常,请稍后再试");
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ console.log(error);
|
|
|
+ this.$message.error("网络异常,请稍后再试");
|
|
|
+ }
|
|
|
+ this.getList();
|
|
|
+ this.defaultValue = {};
|
|
|
+ this.open = false;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 使用提交数据类型的按钮获取数据
|
|
|
+ tempSubBtn(getData) {
|
|
|
+ getData()
|
|
|
+ .then((values) => {
|
|
|
+ console.log("验证通过", values);
|
|
|
+ })
|
|
|
+ .catch(() => {
|
|
|
+ console.log("验证未通过,获取失败");
|
|
|
+ });
|
|
|
+ },
|
|
|
+ // 判断是否生效行样式
|
|
|
+ cellStyle({ row, column, rowIndex, columnIndex }) {
|
|
|
+ let rowStyleList = this.styleList.filter((item) => item.styleType == 0);
|
|
|
+ if (!rowStyleList.length) return "";
|
|
|
+ let mainTableName = this.templateInfo.querySql.tableAlias; //主表名
|
|
|
+ for (let i = 0; i < rowStyleList.length; i++) {
|
|
|
+ let item = rowStyleList[i];
|
|
|
+ let judgeRes = this.determineCondition(item.styleCondtion, row);
|
|
|
+ if (judgeRes) {
|
|
|
+ let styleCode = JSON.parse(item.styleCode);
|
|
|
+ return `background-color:${styleCode.rowBgColor};`;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ // 获取生效条件组结果
|
|
|
+ determineCondition(conditionStr, row) {
|
|
|
+ let conditionList = JSON.parse(conditionStr);
|
|
|
+ if (!conditionList.length) return false;
|
|
|
+ return conditionList.every((item) => this.judgeOneCondition(item, row));
|
|
|
+ },
|
|
|
+
|
|
|
+ // 获取单个判断条件结果
|
|
|
+ judgeOneCondition(item, row) {
|
|
|
+ let fullField = camelCase(item.tableName + "_" + item.fieldName);
|
|
|
+ switch (item.condition) {
|
|
|
+ case 1:
|
|
|
+ return row[fullField] > item.flagValue;
|
|
|
+ case 2:
|
|
|
+ return row[fullField] < item.flagValue;
|
|
|
+ case 3:
|
|
|
+ return row[fullField] == item.flagValue;
|
|
|
+ case 4:
|
|
|
+ return row[fullField] >= item.flagValue;
|
|
|
+ case 5:
|
|
|
+ return row[fullField] <= item.flagValue;
|
|
|
+ default:
|
|
|
+ return true; //默认为true
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ // 设置表格字段样式
|
|
|
+ async setFieldStyleData(tableList) {
|
|
|
+ console.log(JSON.parse(JSON.stringify(tableList)));
|
|
|
+ let fieldConditionList = this.styleList.filter(
|
|
|
+ (item) => item.styleType == 1 || item.styleType == 2
|
|
|
+ );
|
|
|
+ if (!fieldConditionList.length) return tableList;
|
|
|
+ let res = await this.setDictStyleData();
|
|
|
+
|
|
|
+ this.dictStyleObj = res.reduce((pre, item) => {
|
|
|
+ return {
|
|
|
+ ...pre,
|
|
|
+ ...item,
|
|
|
+ };
|
|
|
+ }, {});
|
|
|
+ // console.log("this.dictStyleObj", this.dictStyleObj);
|
|
|
+ tableList.forEach((row) => {
|
|
|
+ // if (!row.styleFieldObj) row.styleFieldObj = {};
|
|
|
+ for (let i = 0; i < fieldConditionList.length; i++) {
|
|
|
+ let item = fieldConditionList[i];
|
|
|
+ if (item.styleType == 1) {
|
|
|
+ //字段样式
|
|
|
+ let judgeRes = this.determineCondition(item.styleCondtion, row);
|
|
|
+ if (judgeRes) {
|
|
|
+ let styleCode = JSON.parse(item.styleCode);
|
|
|
+ if (!row.styleFieldObj) row.styleFieldObj = {};
|
|
|
+ row.styleFieldObj[item.styleField] = {
|
|
|
+ styleType: item.styleType,
|
|
|
+ fieldStyleType: styleCode.fieldStyleType,
|
|
|
+ fontColor: styleCode.fontColor,
|
|
|
+ isTagFullBg: styleCode.isTagFullBg,
|
|
|
+ tagType: styleCode.tagType,
|
|
|
+ };
|
|
|
+ // row.styleField = item.styleField; //样式生效字段
|
|
|
+ // row.styleType = item.styleType; //0:行样式 1:字段样式 2:字典样式
|
|
|
+ // row.fieldStyleType = styleCode.fieldStyleType; //0:文本 1:标签
|
|
|
+ // row.fontColor = styleCode.fontColor;
|
|
|
+ // row.isTagFullBg = styleCode.isTagFullBg; //true/false
|
|
|
+ // row.tagType = styleCode.tagType; //string
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //字典样式
|
|
|
+ let dicStyle = this.dictStyleObj[item.styleField]?.find((dict) => {
|
|
|
+ return dict.dictValue == row[item.styleField];
|
|
|
+ });
|
|
|
+ if (dicStyle) {
|
|
|
+ if (!row.styleFieldObj) row.styleFieldObj = {};
|
|
|
+ row.styleFieldObj[item.styleField] = dicStyle; //设置该字段应该显示的字典样式
|
|
|
+ row.styleFieldObj[item.styleField].styleType = 2;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return tableList;
|
|
|
+ },
|
|
|
+
|
|
|
+ //设置表格字典相关数据
|
|
|
+ setDictStyleData() {
|
|
|
+ let fieldConditionList = this.styleList.filter(
|
|
|
+ (item) => item.styleType == 2
|
|
|
+ );
|
|
|
+ if (!fieldConditionList.length) return;
|
|
|
+ let PromiseList = fieldConditionList.map((item) => {
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
+ let temp = {};
|
|
|
+ try {
|
|
|
+ listData({
|
|
|
+ isEnablePaging: false,
|
|
|
+ dictType: item.styleCondtion,
|
|
|
+ }).then((res) => {
|
|
|
+ temp[item.styleField] = res.rows;
|
|
|
+ resolve(temp);
|
|
|
+ });
|
|
|
+ } catch (error) {
|
|
|
+ reject(error);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ return Promise.all(PromiseList);
|
|
|
+ },
|
|
|
+
|
|
|
+ // 内链页面跳转
|
|
|
+ routerHandler(btnData, type) {
|
|
|
+ let { url, commonFieldData } = JSON.parse(btnData.btnParams);
|
|
|
+ let tempArr = [];
|
|
|
+ if (commonFieldData) {
|
|
|
+ let queryArr = JSON.parse(commonFieldData);
|
|
|
+
|
|
|
+ tempArr = queryArr.map((item) => {
|
|
|
+ let key = this.formatField(item.fieldName, camelCase(this.tableName));
|
|
|
+ let value = item.fieldValue
|
|
|
+ ? item.fieldValue
|
|
|
+ : this.currentRow[item.fieldName];
|
|
|
+ return key + "=" + value;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (tempArr.length) {
|
|
|
+ url += "?" + tempArr.join("&");
|
|
|
+ }
|
|
|
+ // let link = btnData.btnParams;
|
|
|
+ if (type == "INNERLINK") {
|
|
|
+ this.$router.push(url);
|
|
|
+ } else {
|
|
|
+ window.open("http://" + url, "_blank");
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ // 操作列回调
|
|
|
+ excuteHandler(btnData, row) {
|
|
|
+ console.log("btnData", btnData, row);
|
|
|
+ let { btnType, btnParams, btnFormType } = btnData;
|
|
|
+ this.currentBtnData = btnData;
|
|
|
+ this.currentRow = JSON.parse(JSON.stringify(row));
|
|
|
+ // 无表单
|
|
|
+ if (btnFormType == "noNeed") {
|
|
|
+ this.noNeedHandler(btnData, row);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ switch (btnType) {
|
|
|
+ case "INNERLINK":
|
|
|
+ this.routerHandler(btnData, btnType);
|
|
|
+ break;
|
|
|
+ case "OUTLINK":
|
|
|
+ this.routerHandler(btnData, btnType);
|
|
|
+ break;
|
|
|
+ case "UPDATE":
|
|
|
+ this.handleUpdate(row, btnData);
|
|
|
+ break;
|
|
|
+ case "EXECUTE":
|
|
|
+ this.handleUpdate(row, btnData);
|
|
|
+ break;
|
|
|
+ case "INITIATED":
|
|
|
+ this.handleUpdate(row, btnData);
|
|
|
+ break;
|
|
|
+ case "DELETE":
|
|
|
+ this.handleDelete(row, btnData);
|
|
|
+ break;
|
|
|
+ case "INSERT":
|
|
|
+ this.handleUpdate(row, btnData);
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ noNeedHandler(btnData, row) {
|
|
|
+ this.$modal
|
|
|
+ .confirm("是否确认执行该操作?")
|
|
|
+ .then(async () => {
|
|
|
+ // 获取默认参数
|
|
|
+ let data = {
|
|
|
+ basicMap: {
|
|
|
+ tableName: this.tableName,
|
|
|
+ // btnKey: btnData.btnKey,
|
|
|
+ btnKey: this.currentBtnData.btnKey,
|
|
|
+ },
|
|
|
+ conditionMap: {},
|
|
|
+ commMap: {},
|
|
|
+ btnParametersMap: {},
|
|
|
+ };
|
|
|
+ console.log(this.currentBtnData, this.currentRow);
|
|
|
+ if (this.currentBtnData.btnParams) {
|
|
|
+ let conditionData =
|
|
|
+ JSON.parse(this.currentBtnData.btnParams).conditionData || [];
|
|
|
+ // let
|
|
|
+ let commonData =
|
|
|
+ JSON.parse(this.currentBtnData.btnParams).commonFieldData || [];
|
|
|
+
|
|
|
+ conditionData.forEach((item) => {
|
|
|
+ data.conditionMap[item.fieldName.split(".")[1]] = item.fieldValue
|
|
|
+ ? item.fieldValue
|
|
|
+ : this.currentRow[camelCase(item.fieldName.replace(".", "_"))];
|
|
|
+ });
|
|
|
+ commonData.forEach((item) => {
|
|
|
+ data.btnParametersMap[item.fieldName.split(".")[1]] =
|
|
|
+ item.fieldValue
|
|
|
+ ? item.fieldValue
|
|
|
+ : this.currentRow[
|
|
|
+ camelCase(item.fieldName.replace(".", "_"))
|
|
|
+ ];
|
|
|
+ });
|
|
|
+ }
|
|
|
+ data.basicMap.btnType = this.currentBtnData.btnType;
|
|
|
+ data.basicMap.visible = true;
|
|
|
+ try {
|
|
|
+ let res = await btnCommonApi(data);
|
|
|
+ if (res.code == 200) {
|
|
|
+ this.$message.success(res.msg);
|
|
|
+ } else {
|
|
|
+ this.$message.error("网络异常,请稍后再试");
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ console.log(error);
|
|
|
+ this.$message.error("网络异常,请稍后再试");
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .then(() => {
|
|
|
+ // 调用子组件查询方法 目的是携带上子组件中的查询参数
|
|
|
+ this.$refs.mychild.pageList();
|
|
|
+ // this.$modal.msgSuccess("操作成功");
|
|
|
+ })
|
|
|
+ .catch(() => {});
|
|
|
+ },
|
|
|
+
|
|
|
+ // k-form-build表单变化回调
|
|
|
+ formChangeHandler(value, label) {
|
|
|
+ // console.log(value, label);
|
|
|
+ },
|
|
|
+ },
|
|
|
+};
|
|
|
+</script>
|
|
|
+
|
|
|
+<style scoped lang="scss">
|
|
|
+::v-deep .el-dialog:not(.is-fullscreen) {
|
|
|
+ min-width: 610px !important;
|
|
|
+}
|
|
|
+</style>
|