|
@@ -1,11 +1,30 @@
|
|
|
<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"
|
|
|
- :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
|
|
|
+ "
|
|
|
+ :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">
|
|
@@ -14,8 +33,12 @@
|
|
|
<!-- 是否更新已经存在的用户数据-->
|
|
|
<!-- </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>
|
|
@@ -24,7 +47,11 @@
|
|
|
<el-button @click="upload.open = false">取 消</el-button>
|
|
|
</div>
|
|
|
</el-dialog>
|
|
|
- <Queryfrom :form-vals="templateInfo.where" @getList="getList" ref="mychild"/>
|
|
|
+ <Queryfrom
|
|
|
+ :form-vals="templateInfo.where"
|
|
|
+ @getList="getList"
|
|
|
+ ref="mychild"
|
|
|
+ />
|
|
|
<el-row :gutter="10" class="mb8">
|
|
|
<el-col :span="1.5">
|
|
|
<el-button
|
|
@@ -33,7 +60,7 @@
|
|
|
icon="el-icon-plus"
|
|
|
size="mini"
|
|
|
@click="handleAdd"
|
|
|
- >新增
|
|
|
+ >新增
|
|
|
</el-button>
|
|
|
</el-col>
|
|
|
<el-col :span="1.5">
|
|
@@ -44,7 +71,7 @@
|
|
|
size="mini"
|
|
|
:disabled="single"
|
|
|
@click="handleUpdate"
|
|
|
- >修改
|
|
|
+ >修改
|
|
|
</el-button>
|
|
|
</el-col>
|
|
|
<el-col :span="1.5">
|
|
@@ -55,7 +82,7 @@
|
|
|
size="mini"
|
|
|
:disabled="multiple"
|
|
|
@click="handleDelete"
|
|
|
- >删除
|
|
|
+ >删除
|
|
|
</el-button>
|
|
|
</el-col>
|
|
|
<el-col :span="1.5">
|
|
@@ -64,7 +91,7 @@
|
|
|
icon="el-icon-upload2"
|
|
|
size="mini"
|
|
|
@click="upload.open = true"
|
|
|
- >导入
|
|
|
+ >导入
|
|
|
</el-button>
|
|
|
</el-col>
|
|
|
<el-col :span="1.5">
|
|
@@ -74,37 +101,48 @@
|
|
|
icon="el-icon-download"
|
|
|
size="mini"
|
|
|
@click="handleExport"
|
|
|
- >导出
|
|
|
+ >导出
|
|
|
</el-button>
|
|
|
</el-col>
|
|
|
- <right-toolbar :showSearch.sync="showSearch" @queryTable="pageList"></right-toolbar>
|
|
|
+ <right-toolbar
|
|
|
+ :showSearch.sync="showSearch"
|
|
|
+ @queryTable="pageList"
|
|
|
+ ></right-toolbar>
|
|
|
</el-row>
|
|
|
- <el-table v-loading="loading" :data="tableList" @selection-change="handleSelectionChange">
|
|
|
- <el-table-column type="selection" width="55" align="center"/>
|
|
|
- <span v-for="(key,val) in columns">
|
|
|
- <el-table-column :label="key" align="center" :prop="val"/>
|
|
|
+ <el-table
|
|
|
+ v-loading="loading"
|
|
|
+ :data="tableList"
|
|
|
+ @selection-change="handleSelectionChange"
|
|
|
+ >
|
|
|
+ <el-table-column type="selection" width="55" align="center" />
|
|
|
+ <span v-for="(key, val) in columns" :key="key">
|
|
|
+ <el-table-column :label="key" align="center" :prop="val" />
|
|
|
</span>
|
|
|
- <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
|
|
+ <el-table-column
|
|
|
+ label="操作"
|
|
|
+ align="center"
|
|
|
+ class-name="small-padding fixed-width"
|
|
|
+ >
|
|
|
<template slot-scope="scope">
|
|
|
<el-button
|
|
|
size="mini"
|
|
|
type="text"
|
|
|
icon="el-icon-edit"
|
|
|
@click="handleUpdate(scope.row)"
|
|
|
- >修改
|
|
|
+ >修改
|
|
|
</el-button>
|
|
|
<el-button
|
|
|
size="mini"
|
|
|
type="text"
|
|
|
icon="el-icon-delete"
|
|
|
@click="handleDelete(scope.row)"
|
|
|
- >删除
|
|
|
+ >删除
|
|
|
</el-button>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
</el-table>
|
|
|
<pagination
|
|
|
- v-show="total>0"
|
|
|
+ v-show="total > 0"
|
|
|
:total="total"
|
|
|
:page.sync="queryParams.pageNum"
|
|
|
:limit.sync="queryParams.pageSize"
|
|
@@ -112,19 +150,42 @@
|
|
|
/>
|
|
|
<!-- 添加或修改销售出库单:- 过磅记录生成数据对话框 -->
|
|
|
<el-dialog :title="title" :visible.sync="open" append-to-body>
|
|
|
- <iframe :src="iframeUrl" width="100%" height="600px" style="border: none;" scrolling="no">
|
|
|
- </iframe>
|
|
|
+ <!-- <iframe
|
|
|
+ :src="iframeUrl"
|
|
|
+ width="100%"
|
|
|
+ height="600px"
|
|
|
+ style="border: none"
|
|
|
+ scrolling="no"
|
|
|
+ >
|
|
|
+ </iframe> -->
|
|
|
+ <k-form-build
|
|
|
+ ref="addFromRef"
|
|
|
+ :defaultValue="defaultValue"
|
|
|
+ @submit="tempSubBtn"
|
|
|
+ :value="jsonData"
|
|
|
+ />
|
|
|
+ <div slot="footer" class="dialog-footer">
|
|
|
+ <el-button type="primary" @click="editConfirmHandler">确 定</el-button>
|
|
|
+ <el-button @click="cancel">取 消</el-button>
|
|
|
+ </div>
|
|
|
</el-dialog>
|
|
|
</div>
|
|
|
</template>
|
|
|
<script>
|
|
|
-import {delTableData, dragTableInfo, listTable, unionListTableData, getInfoBySqlKey} from "@/api/tablelist/commonTable";
|
|
|
-import {getToken} from "@/utils/auth";
|
|
|
+import {
|
|
|
+ delTableData,
|
|
|
+ dragTableInfo,
|
|
|
+ listTable,
|
|
|
+ unionListTableData,
|
|
|
+ getInfoBySqlKey,
|
|
|
+ addTableData,
|
|
|
+} from "@/api/tablelist/commonTable";
|
|
|
+import { getToken } from "@/utils/auth";
|
|
|
import Queryfrom from "@/views/tablelist/commonTable/queryfrom.vue";
|
|
|
|
|
|
export default {
|
|
|
name: "listInfo",
|
|
|
- components: {Queryfrom},
|
|
|
+ components: { Queryfrom },
|
|
|
data() {
|
|
|
return {
|
|
|
// 遮罩层
|
|
@@ -161,7 +222,7 @@ export default {
|
|
|
// 是否更新已经存在的数据
|
|
|
updateSupport: 0,
|
|
|
// 设置上传的请求头部
|
|
|
- headers: {Authorization: "Bearer " + getToken()},
|
|
|
+ headers: { Authorization: "Bearer " + getToken() },
|
|
|
// 上传的地址
|
|
|
url: process.env.VUE_APP_BASE_API3 + "common/uploadData",
|
|
|
},
|
|
@@ -169,20 +230,21 @@ export default {
|
|
|
sortState: true,
|
|
|
// 共通查询参数接受子组件的参数
|
|
|
queryParams: {
|
|
|
- pageNum: 1, // 第几页
|
|
|
- pageSize: 10, // 每页大小
|
|
|
- orderByColumn: "", // 根据某列排序
|
|
|
+ pageNum: 1, // 第几页
|
|
|
+ pageSize: 10, // 每页大小
|
|
|
+ orderByColumn: "", // 根据某列排序
|
|
|
isAsc: this.sortState ? "DESC" : "ASC", // desc(降序)或 asc(升序)
|
|
|
// 基本查询参数
|
|
|
basicMap: {
|
|
|
- tableName: "drag_form"
|
|
|
+ tableName: "drag_form",
|
|
|
},
|
|
|
// 当前表字段筛选参数
|
|
|
- queryMap: { // 当前查询基本参数
|
|
|
+ queryMap: {
|
|
|
+ // 当前查询基本参数
|
|
|
// ... key : value 当前页面的筛选条件
|
|
|
// 超级查询的唯一值
|
|
|
- queryCriteriaValue: ""
|
|
|
- }
|
|
|
+ queryCriteriaValue: "",
|
|
|
+ },
|
|
|
},
|
|
|
// 列信息
|
|
|
columns: {},
|
|
@@ -195,7 +257,11 @@ export default {
|
|
|
// 当前表名称
|
|
|
tableName: null,
|
|
|
//存放html代码块
|
|
|
- iframeUrl: '',
|
|
|
+ iframeUrl: "",
|
|
|
+ //存放表单渲染数据
|
|
|
+ jsonData: {},
|
|
|
+ // 回显表格数据,
|
|
|
+ defaultValue: {},
|
|
|
};
|
|
|
},
|
|
|
|
|
@@ -208,45 +274,51 @@ export default {
|
|
|
getList(queryParams) {
|
|
|
this.loading = true;
|
|
|
// 序列化当前查询参数列表
|
|
|
- this.queryParams.queryMap = queryParams.queryMap
|
|
|
+ this.queryParams.queryMap = queryParams.queryMap;
|
|
|
// 获取当前表单结构信息
|
|
|
- dragTableInfo({queryMap: {sqlkey: this.sqlkey}}).then(res => {
|
|
|
- // 得到当前模版信息 --- sql columns queryWhere
|
|
|
- this.templateInfo = res.data.resultMap;
|
|
|
- console.log(this.templateInfo);
|
|
|
- this.tableName = this.templateInfo.template.dtTableName;
|
|
|
- // 得到查询条件
|
|
|
- this.queryFromWhere = res.data.resultMap.where;
|
|
|
- // 得到当前列表信息
|
|
|
- this.columns = JSON.parse(this.templateInfo.template.dtColumnName);
|
|
|
- }).finally(fes => {
|
|
|
- if (this.templateInfo == {}) return;
|
|
|
- // 调用查询需要携带当前table的唯一标识
|
|
|
- this.queryParams.queryMap.sqlkey = this.sqlkey;
|
|
|
- // 根据sql语句查询当前表数据
|
|
|
- unionListTableData(this.queryParams).then(res => {
|
|
|
- this.tableList = [];
|
|
|
- res.rows.forEach(item => {
|
|
|
- this.tableList.push(item.resultMap)
|
|
|
+ dragTableInfo({ queryMap: { sqlkey: this.sqlkey } })
|
|
|
+ .then((res) => {
|
|
|
+ // 得到当前模版信息 --- sql columns queryWhere
|
|
|
+ this.templateInfo = res.data.resultMap;
|
|
|
+ console.log(this.templateInfo);
|
|
|
+ this.tableName = this.templateInfo.template.dtTableName;
|
|
|
+ // 得到查询条件
|
|
|
+ this.queryFromWhere = res.data.resultMap.where;
|
|
|
+ // 得到当前列表信息
|
|
|
+ this.columns = JSON.parse(this.templateInfo.template.dtColumnName);
|
|
|
+ })
|
|
|
+ .finally((fes) => {
|
|
|
+ if (this.templateInfo == {}) return;
|
|
|
+ // 调用查询需要携带当前table的唯一标识
|
|
|
+ this.queryParams.queryMap.sqlkey = this.sqlkey;
|
|
|
+ // 根据sql语句查询当前表数据
|
|
|
+ unionListTableData(this.queryParams).then((res) => {
|
|
|
+ this.tableList = [];
|
|
|
+ res.rows.forEach((item) => {
|
|
|
+ this.tableList.push(item.resultMap);
|
|
|
+ });
|
|
|
+ this.total = res.total;
|
|
|
+ this.loading = false;
|
|
|
});
|
|
|
- this.total = res.total;
|
|
|
- this.loading = false;
|
|
|
});
|
|
|
- });
|
|
|
},
|
|
|
// 取消按钮
|
|
|
cancel() {
|
|
|
this.open = false;
|
|
|
- this.reset();
|
|
|
+ // this.reset();
|
|
|
},
|
|
|
// 分页查询
|
|
|
pageList(row) {
|
|
|
- console.log(row)
|
|
|
+ console.log(row);
|
|
|
// 调用子组件-》携带子组件参数请求后台
|
|
|
- this.$refs.mychild.pageList(row == undefined ? {
|
|
|
- limit: this.queryParams.pageSize,
|
|
|
- page: this.queryParams.pageNum
|
|
|
- } : row);
|
|
|
+ this.$refs.mychild.pageList(
|
|
|
+ row == undefined
|
|
|
+ ? {
|
|
|
+ limit: this.queryParams.pageSize,
|
|
|
+ page: this.queryParams.pageNum,
|
|
|
+ }
|
|
|
+ : row
|
|
|
+ );
|
|
|
},
|
|
|
// 多选框选中数据
|
|
|
handleSelectionChange(selection) {
|
|
@@ -271,24 +343,32 @@ export default {
|
|
|
/** 新增按钮操作 */
|
|
|
handleAdd(row) {
|
|
|
// this.reset();
|
|
|
- getInfoBySqlKey(this.sqlkey).then(({data}) => {
|
|
|
+ this.defaultValue = {};
|
|
|
+ getInfoBySqlKey(this.sqlkey).then(({ data }) => {
|
|
|
const htmlCode = data.dfHtmlTemplate;
|
|
|
- this.iframeUrl = 'data:text/html;charset=utf-8,' + encodeURI(htmlCode);
|
|
|
+ this.iframeUrl = "data:text/html;charset=utf-8," + encodeURI(htmlCode);
|
|
|
+ this.jsonData = JSON.parse(data.dfVueTemplate);
|
|
|
this.open = true;
|
|
|
this.title = "添加信息";
|
|
|
this.form.password = this.initPassword;
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.$refs.addFromRef.reset();
|
|
|
+ });
|
|
|
});
|
|
|
-
|
|
|
},
|
|
|
/** 修改按钮操作 */
|
|
|
handleUpdate(row) {
|
|
|
-
|
|
|
- getInfoBySqlKey(this.sqlkey).then(({data}) => {
|
|
|
+ getInfoBySqlKey(this.sqlkey).then(({ data }) => {
|
|
|
const htmlCode = data.dfHtmlTemplate;
|
|
|
- this.iframeUrl = 'data:text/html;charset=utf-8,' + encodeURI(htmlCode);
|
|
|
+ this.iframeUrl = "data:text/html;charset=utf-8," + encodeURI(htmlCode);
|
|
|
+ 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();
|
|
@@ -305,7 +385,6 @@ export default {
|
|
|
});
|
|
|
},
|
|
|
|
|
|
-
|
|
|
/** 提交按钮 */
|
|
|
submitForm: function () {
|
|
|
this.$refs["form"].validate((valid) => {
|
|
@@ -334,7 +413,7 @@ export default {
|
|
|
let delIds = this.ids;
|
|
|
|
|
|
if (row.id != undefined && row.id != null) {
|
|
|
- delIds = []
|
|
|
+ delIds = [];
|
|
|
delIds.push(row.id);
|
|
|
// if (delIds.findIndex(item => item === row.id) == -1) {
|
|
|
// delIds.push(row.id);
|
|
@@ -342,12 +421,12 @@ export default {
|
|
|
}
|
|
|
let data = {
|
|
|
basicMap: {
|
|
|
- tableName: this.tableName
|
|
|
+ tableName: this.tableName,
|
|
|
},
|
|
|
conditionMap: {
|
|
|
- id: delIds
|
|
|
- }
|
|
|
- }
|
|
|
+ id: delIds,
|
|
|
+ },
|
|
|
+ };
|
|
|
this.$modal
|
|
|
.confirm('是否确认删除"' + delIds + '"的数据项?')
|
|
|
.then(function () {
|
|
@@ -358,26 +437,26 @@ export default {
|
|
|
this.$refs.mychild.pageList();
|
|
|
this.$modal.msgSuccess("删除成功");
|
|
|
})
|
|
|
- .catch(() => {
|
|
|
- });
|
|
|
+ .catch(() => {});
|
|
|
},
|
|
|
/** 导出按钮操作 */
|
|
|
handleExport() {
|
|
|
if (this.ids.length > 0) {
|
|
|
- this.queryParams['execlMap'] = []
|
|
|
- this.ids.forEach(item => {
|
|
|
- this.queryParams.execlMap.push(this.tableList.find(ttem => {
|
|
|
- return ttem.id === item
|
|
|
- }))
|
|
|
- }
|
|
|
- )
|
|
|
+ this.queryParams["execlMap"] = [];
|
|
|
+ this.ids.forEach((item) => {
|
|
|
+ this.queryParams.execlMap.push(
|
|
|
+ this.tableList.find((ttem) => {
|
|
|
+ return ttem.id === item;
|
|
|
+ })
|
|
|
+ );
|
|
|
+ });
|
|
|
}
|
|
|
this.queryParams.execlMap = JSON.stringify(this.queryParams.execlMap);
|
|
|
- console.log(this.queryParams)
|
|
|
+ console.log(this.queryParams);
|
|
|
this.download(
|
|
|
process.env.VUE_APP_BASE_API3 + "dragform/common/export",
|
|
|
{
|
|
|
- ...this.queryParams
|
|
|
+ ...this.queryParams,
|
|
|
},
|
|
|
`文件名称_${new Date().getTime()}.xlsx`
|
|
|
);
|
|
@@ -390,7 +469,8 @@ export default {
|
|
|
/** 下载模板操作 */
|
|
|
importTemplate() {
|
|
|
this.download(
|
|
|
- process.env.VUE_APP_BASE_API3 + `dragform/common/exportTemplate?tableName=${this.tableName}&sqlkey=${this.sqlkey}`,
|
|
|
+ process.env.VUE_APP_BASE_API3 +
|
|
|
+ `dragform/common/exportTemplate?tableName=${this.tableName}&sqlkey=${this.sqlkey}`,
|
|
|
{},
|
|
|
`下载模版名称${new Date().getTime()}.xlsx`
|
|
|
);
|
|
@@ -406,25 +486,67 @@ 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}
|
|
|
+ { dangerouslyUseHTMLString: true }
|
|
|
);
|
|
|
- this.$refs.mychild.pageList({limit: this.queryParams.pageSize, page: this.queryParams.pageNum});
|
|
|
+ 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对象
|
|
|
+ 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();
|
|
|
},
|
|
|
+ //提交编辑结果按钮回调
|
|
|
+ editConfirmHandler() {
|
|
|
+ this.$refs.addFromRef
|
|
|
+ .getData()
|
|
|
+ .then(async (values) => {
|
|
|
+ let data = {
|
|
|
+ basicMap: {
|
|
|
+ tableName: "test",
|
|
|
+ },
|
|
|
+ addListMap: [values],
|
|
|
+ };
|
|
|
+ if (Object.keys(this.defaultValue).length) {
|
|
|
+ this.$modal.msgSuccess("修改成功");
|
|
|
+ } else {
|
|
|
+ let res = await addTableData(data);
|
|
|
+ this.$modal.msgSuccess("添加成功");
|
|
|
+ console.log(res);
|
|
|
+ }
|
|
|
+ this.defaultValue = {};
|
|
|
+ this.open = false;
|
|
|
+ })
|
|
|
+ .catch((res) => {
|
|
|
+ console.log(res);
|
|
|
+ console.log("验证未通过,获取失败");
|
|
|
+ });
|
|
|
+ },
|
|
|
+ // 使用提交数据类型的按钮获取数据
|
|
|
+ tempSubBtn(getData) {
|
|
|
+ getData()
|
|
|
+ .then((values) => {
|
|
|
+ console.log("验证通过", values);
|
|
|
+ })
|
|
|
+ .catch(() => {
|
|
|
+ console.log("验证未通过,获取失败");
|
|
|
+ });
|
|
|
+ },
|
|
|
},
|
|
|
};
|
|
|
</script>
|