|
@@ -264,6 +264,7 @@ import {
|
|
|
listTable,
|
|
|
unionListTableData,
|
|
|
getInfoBySqlKey,
|
|
|
+ btnCommonApi,
|
|
|
addTableData,
|
|
|
batchEdit,
|
|
|
getStatisticList,
|
|
@@ -274,6 +275,7 @@ import Queryfrom from "@/views/tablelist/commonTable/queryfrom.vue";
|
|
|
import { camelCase } from "@/utils";
|
|
|
import { inputDisableComplete } from "@/utils/other";
|
|
|
import Menu from "./BtnMenu.vue";
|
|
|
+import { checkRole } from "@/utils/permission";
|
|
|
|
|
|
export default {
|
|
|
name: "listInfo",
|
|
@@ -595,31 +597,69 @@ export default {
|
|
|
},
|
|
|
|
|
|
/** 修改按钮操作 */
|
|
|
- handleUpdate(row) {
|
|
|
+ async handleUpdate(row) {
|
|
|
console.log(row);
|
|
|
- getInfoBySqlKey(this.templateInfo.template.sqlKey).then(({ data }) => {
|
|
|
- if (!data || !data.dfVueTemplate) {
|
|
|
+
|
|
|
+ // 新的修改请求
|
|
|
+ try {
|
|
|
+ let payLoad = {
|
|
|
+ basicMap: {
|
|
|
+ btnType: 8,
|
|
|
+ visible: "false",
|
|
|
+ sqlKey: this.templateInfo.template.sqlKey,
|
|
|
+ tableName: this.tableName,
|
|
|
+ },
|
|
|
+ conditionMap: {},
|
|
|
+ };
|
|
|
+ let primary = camelCase(
|
|
|
+ this.tableName + "_" + this.templateInfo.template?.primaryKey
|
|
|
+ );
|
|
|
+ payLoad.conditionMap[this.templateInfo.template?.primaryKey] =
|
|
|
+ row[primary];
|
|
|
+ let res = await btnCommonApi(payLoad);
|
|
|
+ if (!res.data || !res.data.template.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);
|
|
|
+ res.data.template.dfFormSql &&
|
|
|
+ (this.dynamicData = JSON.parse(res.data.template.dfFormSql));
|
|
|
+ this.addRealFieldName(res.data.result.resultMap);
|
|
|
+ Object.assign(this.defaultValue, res.data.result.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(row);
|
|
|
+ this.$refs.addFromRef.setData(res.data.result.resultMap);
|
|
|
});
|
|
|
- });
|
|
|
+ } 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) => {
|
|
@@ -678,6 +718,7 @@ export default {
|
|
|
}
|
|
|
let data = {
|
|
|
basicMap: {
|
|
|
+ btnType: 9,
|
|
|
tableName: this.tableName,
|
|
|
},
|
|
|
conditionMap: {
|
|
@@ -688,7 +729,8 @@ export default {
|
|
|
this.$modal
|
|
|
.confirm('是否确认删除"' + delIds + '"的数据项?')
|
|
|
.then(function () {
|
|
|
- return delTableData(data);
|
|
|
+ // return delTableData(data);
|
|
|
+ return btnCommonApi(data);
|
|
|
})
|
|
|
.then(() => {
|
|
|
// 调用子组件查询方法 目的是携带上子组件中的查询参数
|
|
@@ -779,46 +821,76 @@ export default {
|
|
|
tableName: this.tableName,
|
|
|
},
|
|
|
addListMap: [values],
|
|
|
+ conditionMap: {},
|
|
|
+ commMap: {},
|
|
|
};
|
|
|
if (Object.keys(this.defaultValue).length) {
|
|
|
- let updateData = {
|
|
|
- // 基本参数
|
|
|
- basicMap: {
|
|
|
- // 表名
|
|
|
- tableName: this.tableName,
|
|
|
- },
|
|
|
- conditionMap: {},
|
|
|
- commMap: {},
|
|
|
- };
|
|
|
-
|
|
|
+ //修改
|
|
|
// 后台接收需要是表中字段真实的名称,无所谓驼峰。
|
|
|
- updateData.conditionMap[this.templateInfo.template?.primaryKey] =
|
|
|
+ data.conditionMap[this.templateInfo.template?.primaryKey] =
|
|
|
this.defaultValue[
|
|
|
camelCase(this.templateInfo.template?.primaryKey)
|
|
|
];
|
|
|
Object.keys(values).map((k) => {
|
|
|
- updateData.commMap[k] = values[k];
|
|
|
+ data.commMap[k] = values[k];
|
|
|
});
|
|
|
- let res = await batchEdit(updateData);
|
|
|
- if (res.code == 200) {
|
|
|
- this.$modal.msgSuccess("修改成功");
|
|
|
- } else {
|
|
|
- this.$modal.msgError("修改失败");
|
|
|
- }
|
|
|
- this.getList();
|
|
|
+ data.basicMap.btnType = 8;
|
|
|
+ data.basicMap.visible = true;
|
|
|
} else {
|
|
|
- let res = await addTableData(data);
|
|
|
+ data.basicMap.btnType = 10;
|
|
|
+ data.basicMap.visible = true;
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ let res = await btnCommonApi(data);
|
|
|
if (res.code == 200) {
|
|
|
- this.$modal.msgSuccess("添加成功");
|
|
|
+ this.$message.success("操作成功");
|
|
|
} else {
|
|
|
- this.$modal.msgError("添加失败");
|
|
|
+ this.$message.error("网络异常,请稍后再试");
|
|
|
}
|
|
|
- this.getList();
|
|
|
+ } catch (error) {
|
|
|
+ console.log(error);
|
|
|
+ this.$message.error("网络异常,请稍后再试");
|
|
|
}
|
|
|
+ // 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.open = false;
|
|
|
})
|
|
|
.catch((res) => {
|
|
|
+ console.log(res);
|
|
|
this.$modal.msgError("表单校验失败,请规范填写数据");
|
|
|
});
|
|
|
},
|