master
xy 2 years ago
parent d8085fe6cf
commit c30916262a

@ -1,5 +1,7 @@
import { save, index, destroy } from "@/api/system/customFormField";
import { Message } from "element-ui";
import {index} from "@/api/system/customFormField";
import {show,save} from "@/api/system/customForm";
import {Message} from "element-ui";
const state = {
formList: [], //更个表单配置信息
copyFormListId: [], //备份原始的字段id数组,以做删除
@ -37,31 +39,50 @@ const mutations = {
};
const actions = {
submit: ({ state, commit }) => {
submit: ({ state, commit }, tableId) => {
return new Promise((resolve, reject) => {
state.formList.forEach((item,index) => {
item.sort = index + 1
})
let formListId = state.formList.filter((i) => !!i.id).map((i) => i.id);
let deleteIds = state.copyFormListId.filter(
(i) => !formListId.includes(i)
);
let promiseAll = [
...state.formList.map((i) => save(i)),
...deleteIds.map((i) => destroy({ id: i })),
];
Promise.all(promiseAll)
.then((res) => {
show({ id: tableId }).then(res => {
state.formList.forEach((item,index) => {
item.sort = index + 1
})
res.fields = state.formList
save(res).then(res1 => {
Message({
type: "success",
message: "保存成功",
});
resolve(res);
type: 'success',
message: res1.msg
})
resolve(res1)
}).catch(err1 => {
reject(err1)
})
.catch((err) => {
reject(err);
});
});
}).catch(err => {
reject(err)
})
})
// return new Promise((resolve, reject) => {
// state.formList.forEach((item,index) => {
// item.sort = index + 1
// })
// let formListId = state.formList.filter((i) => !!i.id).map((i) => i.id);
// let deleteIds = state.copyFormListId.filter(
// (i) => !formListId.includes(i)
// );
// let promiseAll = [
// ...state.formList.map((i) => save(i)),
// ...deleteIds.map((i) => destroy({ id: i })),
// ];
// Promise.all(promiseAll)
// .then((res) => {
// Message({
// type: "success",
// message: "保存成功",
// });
// resolve(res);
// })
// .catch((err) => {
// reject(err);
// });
// });
},
getFormList: ({ state, commit }, custom_form_id) => {
return new Promise((resolve, reject) => {

@ -234,7 +234,7 @@ export default {
},
submit() {
this.$store.dispatch("form/submit").then((res) => {
this.$store.dispatch("form/submit",this.custom_form_id).then((res) => {
setTimeout(() => {
update({ id: this.custom_form_id })
.then((res) => {

Loading…
Cancel
Save