|
@@ -1,12 +1,13 @@
|
|
<template>
|
|
<template>
|
|
<el-card class="box-card" :body-style="{ padding: '0px' }">
|
|
<el-card class="box-card" :body-style="{ padding: '0px' }">
|
|
<div slot="header" class="clearfix">
|
|
<div slot="header" class="clearfix">
|
|
|
|
+ <el-button icon="el-icon-plus" type="primary" @click="handleAdd">新增</el-button>
|
|
<el-tag class="tag_NO">{{ Number(index) + 1 }}</el-tag>
|
|
<el-tag class="tag_NO">{{ Number(index) + 1 }}</el-tag>
|
|
<span class="title">{{ cardData.title }}</span>
|
|
<span class="title">{{ cardData.title }}</span>
|
|
- <el-button icon="el-icon-plus" type="primary">操作按钮</el-button>
|
|
|
|
</div>
|
|
</div>
|
|
<!-- body -->
|
|
<!-- body -->
|
|
<el-table
|
|
<el-table
|
|
|
|
+ v-loading="loading"
|
|
ref="singleTable"
|
|
ref="singleTable"
|
|
:data="cardData.tableData"
|
|
:data="cardData.tableData"
|
|
height="300"
|
|
height="300"
|
|
@@ -14,28 +15,201 @@
|
|
@current-change="handleCurrentChange"
|
|
@current-change="handleCurrentChange"
|
|
style="width: 100%"
|
|
style="width: 100%"
|
|
>
|
|
>
|
|
- <el-table-column type="index" width="50"> </el-table-column>
|
|
|
|
- <el-table-column property="date" label="日期" width="120">
|
|
|
|
|
|
+ <el-table-column
|
|
|
|
+ label="操作"
|
|
|
|
+ align="center"
|
|
|
|
+ class-name="small-padding fixed-width"
|
|
|
|
+ >
|
|
|
|
+ <template slot-scope="scope">
|
|
|
|
+ <el-dropdown>
|
|
|
|
+ <el-button type="warning" plain size="small">
|
|
|
|
+ 处理<i class="el-icon-arrow-down el-icon--right"></i>
|
|
|
|
+ </el-button>
|
|
|
|
+ <el-dropdown-menu slot="dropdown">
|
|
|
|
+ <el-dropdown-item>
|
|
|
|
+ <el-button
|
|
|
|
+ size="mini"
|
|
|
|
+ type="text"
|
|
|
|
+ icon="el-icon-edit"
|
|
|
|
+ @click="handleUpdate(scope.row)"
|
|
|
|
+ >修改
|
|
|
|
+ </el-button>
|
|
|
|
+ </el-dropdown-item>
|
|
|
|
+ <el-dropdown-item>
|
|
|
|
+ <el-button
|
|
|
|
+ size="mini"
|
|
|
|
+ type="text"
|
|
|
|
+ icon="el-icon-delete"
|
|
|
|
+ @click="handleDelete(scope.row)"
|
|
|
|
+ >删除
|
|
|
|
+ </el-button>
|
|
|
|
+ </el-dropdown-item>
|
|
|
|
+ </el-dropdown-menu>
|
|
|
|
+ </el-dropdown>
|
|
|
|
+ </template>
|
|
</el-table-column>
|
|
</el-table-column>
|
|
- <el-table-column property="name" label="姓名" width="120">
|
|
|
|
|
|
+ <el-table-column
|
|
|
|
+ v-for="item in columns"
|
|
|
|
+ :key="item.key"
|
|
|
|
+ :label="item.value"
|
|
|
|
+ align="center"
|
|
|
|
+ :prop="item.key">
|
|
</el-table-column>
|
|
</el-table-column>
|
|
- <el-table-column property="address" label="地址"> </el-table-column>
|
|
|
|
</el-table>
|
|
</el-table>
|
|
|
|
+ <!-- 添加或修改销售出库单:- 过磅记录生成数据对话框 -->
|
|
|
|
+ <el-dialog :title="title" :visible.sync="open" append-to-body>
|
|
|
|
+ <k-form-build
|
|
|
|
+ class="formBuild"
|
|
|
|
+ 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>
|
|
</el-card>
|
|
</el-card>
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script>
|
|
<script>
|
|
|
|
+import {
|
|
|
|
+ delTableData,
|
|
|
|
+ dragTableInfo,
|
|
|
|
+ listTable,
|
|
|
|
+ unionListTableData,
|
|
|
|
+ getInfoBySqlKey,
|
|
|
|
+ addTableData,
|
|
|
|
+ batchEdit,
|
|
|
|
+ getStatisticList
|
|
|
|
+} from "@/api/tablelist/commonTable";
|
|
|
|
+import {camelCase} from "@/utils";
|
|
|
|
+import {dragGroupTableInfo} from "@/api/relateTable/index"
|
|
|
|
+import { tableInfo } from "@/api/dataEngine";
|
|
|
|
+import {inputDisableComplete} from "@/utils/other";
|
|
|
|
+
|
|
export default {
|
|
export default {
|
|
name: "RelateTableCard",
|
|
name: "RelateTableCard",
|
|
props: ["cardData", "index"],
|
|
props: ["cardData", "index"],
|
|
components: {},
|
|
components: {},
|
|
data() {
|
|
data() {
|
|
return {
|
|
return {
|
|
- currentRow: null,
|
|
|
|
|
|
+ // 弹出层标题
|
|
|
|
+ title: "",
|
|
|
|
+ // cru 弹窗
|
|
|
|
+ open: false,
|
|
|
|
+ // 回显表格数据,
|
|
|
|
+ defaultValue: {},
|
|
|
|
+ //存放表单渲染数据
|
|
|
|
+ jsonData: {},
|
|
|
|
+ // 遮罩层
|
|
|
|
+ loading: true,
|
|
|
|
+ // 表格组标识
|
|
|
|
+ groupKey: null,
|
|
|
|
+ // 共通查询参数接受子组件的参数
|
|
|
|
+ queryParams: {
|
|
|
|
+ pageNum: 1, // 第几页
|
|
|
|
+ pageSize: 10, // 每页大小
|
|
|
|
+ orderByColumn: "", // 根据某列排序
|
|
|
|
+ isAsc: "", // desc(降序)或 asc(升序)
|
|
|
|
+ // 基本查询参数
|
|
|
|
+ basicMap: {
|
|
|
|
+ tableName: "drag_form",
|
|
|
|
+ },
|
|
|
|
+ // 当前表字段筛选参数
|
|
|
|
+ queryMap: {
|
|
|
|
+ // 当前查询基本参数
|
|
|
|
+ // ... key : value 当前页面的筛选条件
|
|
|
|
+ // 超级查询的唯一值
|
|
|
|
+ queryCriteriaValue: "",
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ // 排序方式 默认降序
|
|
|
|
+ sortOrder: true,
|
|
|
|
+ // 当前模版信息
|
|
|
|
+ templateInfo: {},
|
|
|
|
+ // 用户表格数据
|
|
|
|
+ tableList: [],
|
|
|
|
+ // 列信息
|
|
|
|
+ columns: {},
|
|
};
|
|
};
|
|
},
|
|
},
|
|
|
|
+ created() {
|
|
|
|
+ this.groupKey = this.$route.query.groupKey;
|
|
|
|
+ this.getList()
|
|
|
|
+ },
|
|
computed: {},
|
|
computed: {},
|
|
methods: {
|
|
methods: {
|
|
|
|
+ /** 查询列表 */
|
|
|
|
+ async getList(queryParams) {
|
|
|
|
+ this.loading = true;
|
|
|
|
+ // 序列化当前查询参数列表
|
|
|
|
+ queryParams && (this.queryParams.queryMap = queryParams.queryMap);
|
|
|
|
+ // 获取当前表单结构信息
|
|
|
|
+ let result = await dragGroupTableInfo({queryMap: {groupKey: this.groupKey}})
|
|
|
|
+ if(result.code == 200){
|
|
|
|
+ let list = JSON.parse(result.msg)
|
|
|
|
+ let res = await dragTableInfo({queryMap: {tableKey : list[0].tableKey}})
|
|
|
|
+ console.log(res);
|
|
|
|
+ // 得到当前模版信息 --- sql columns queryWhere
|
|
|
|
+ this.templateInfo = res.data.resultMap;
|
|
|
|
+ console.log(this.templateInfo.template);
|
|
|
|
+ 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)
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (this.templateInfo == {}) return;
|
|
|
|
+ // 调用查询需要携带当前table的唯一标识
|
|
|
|
+ this.queryParams.queryMap.sqlKey = this.templateInfo.template.sqlKey;
|
|
|
|
+ this.queryParams.orderByColumn = camelCase(
|
|
|
|
+ this.queryParams.orderByColumn || ""
|
|
|
|
+ );
|
|
|
|
+ // 根据sql语句查询当前表数据
|
|
|
|
+ console.log(this.queryParams)
|
|
|
|
+ unionListTableData(this.queryParams).then((res) => {
|
|
|
|
+ // console.log('unionListTableData');
|
|
|
|
+ console.log('res', res);
|
|
|
|
+ this.tableList = [];
|
|
|
|
+ res.rows.forEach((item) => {
|
|
|
|
+ this.tableList.push(item.resultMap);
|
|
|
|
+ });
|
|
|
|
+ // 驼峰转换
|
|
|
|
+ this.tableList = this.tableList.map((item) => {
|
|
|
|
+ let kv = {};
|
|
|
|
+ for (let itemKey in item) {
|
|
|
|
+ kv[camelCase(itemKey)] = item[itemKey];
|
|
|
|
+ }
|
|
|
|
+ return kv;
|
|
|
|
+ });
|
|
|
|
+ this.total = res.total;
|
|
|
|
+ this.loading = false;
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ },
|
|
|
|
+ // 处理列表信息
|
|
|
|
+ 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;
|
|
|
|
+ },
|
|
handleCurrentChange(val) {
|
|
handleCurrentChange(val) {
|
|
// 调用父组件方法更新表格数据
|
|
// 调用父组件方法更新表格数据
|
|
this.$emit(
|
|
this.$emit(
|
|
@@ -45,6 +219,99 @@ export default {
|
|
this.$props.index
|
|
this.$props.index
|
|
);
|
|
);
|
|
},
|
|
},
|
|
|
|
+ /** 新增按钮操作 */
|
|
|
|
+ handleAdd(row) {
|
|
|
|
+ // this.reset();
|
|
|
|
+ this.defaultValue = {};
|
|
|
|
+ getInfoBySqlKey(this.templateInfo.template.sqlKey).then(({data}) => {
|
|
|
|
+ if (!data || !data.dfVueTemplate) {
|
|
|
|
+ this.$message.error("当前表格未绑定表单!");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ this.jsonData = JSON.parse(data.dfVueTemplate);
|
|
|
|
+ this.open = true;
|
|
|
|
+ this.title = "添加信息";
|
|
|
|
+ // this.form.password = this.initPassword;
|
|
|
|
+ this.$nextTick(() => {
|
|
|
|
+ this.$refs.addFromRef.reset();
|
|
|
|
+ inputDisableComplete();
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+ // 使用提交数据类型的按钮获取数据
|
|
|
|
+ tempSubBtn(getData) {
|
|
|
|
+ getData()
|
|
|
|
+ .then((values) => {
|
|
|
|
+ console.log("验证通过", values);
|
|
|
|
+ })
|
|
|
|
+ .catch(() => {
|
|
|
|
+ console.log("验证未通过,获取失败");
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+ //提交编辑结果按钮回调
|
|
|
|
+ editConfirmHandler() {
|
|
|
|
+ this.$refs.addFromRef
|
|
|
|
+ .getData()
|
|
|
|
+ .then(async (values) => {
|
|
|
|
+ let data = {
|
|
|
|
+ basicMap: {
|
|
|
|
+ tableName: this.tableName,
|
|
|
|
+ },
|
|
|
|
+ addListMap: [values],
|
|
|
|
+ };
|
|
|
|
+ if (Object.keys(this.defaultValue).length) {
|
|
|
|
+ let updateData = {
|
|
|
|
+ // 基本参数
|
|
|
|
+ basicMap: {
|
|
|
|
+ // 表名
|
|
|
|
+ tableName: this.tableName,
|
|
|
|
+ },
|
|
|
|
+ conditionMap: {},
|
|
|
|
+ commMap: {},
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ // 后台接收需要是表中字段真实的名称,无所谓驼峰。
|
|
|
|
+ updateData.conditionMap[this.templateInfo.template?.primaryKey] =
|
|
|
|
+ this.defaultValue[
|
|
|
|
+ camelCase(this.templateInfo.template?.primaryKey)
|
|
|
|
+ ];
|
|
|
|
+ Object.keys(values).map((k) => {
|
|
|
|
+ updateData.commMap[k] = values[k];
|
|
|
|
+ });
|
|
|
|
+ let res = await batchEdit(updateData);
|
|
|
|
+ if (res.code == 200) {
|
|
|
|
+ this.$modal.msgSuccess("修改成功");
|
|
|
|
+ } else {
|
|
|
|
+ this.$modal.msgError("修改失败");
|
|
|
|
+ }
|
|
|
|
+ this.getList();
|
|
|
|
+ } else {
|
|
|
|
+ let res = await addTableData(data);
|
|
|
|
+ if (res.code == 200) {
|
|
|
|
+ this.$modal.msgSuccess("添加成功");
|
|
|
|
+ } else {
|
|
|
|
+ this.$modal.msgError("添加失败");
|
|
|
|
+ }
|
|
|
|
+ this.getList();
|
|
|
|
+ }
|
|
|
|
+ this.defaultValue = {};
|
|
|
|
+ this.toParentVal()
|
|
|
|
+ this.open = false;
|
|
|
|
+ })
|
|
|
|
+ .catch((res) => {
|
|
|
|
+ this.$modal.msgError("表单校验失败,请规范填写数据");
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+ toParentVal(){
|
|
|
|
+ console.log(123);
|
|
|
|
+ this.$emit('tansToParent', this.getList())
|
|
|
|
+ this.$emit('formtansToParent', this.templateInfo.where)
|
|
|
|
+ },
|
|
|
|
+ // 取消按钮
|
|
|
|
+ cancel() {
|
|
|
|
+ this.open = false;
|
|
|
|
+ // this.reset();
|
|
|
|
+ },
|
|
},
|
|
},
|
|
};
|
|
};
|
|
</script>
|
|
</script>
|