master
xy 2 years ago
parent d8085fe6cf
commit c30916262a

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

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

Loading…
Cancel
Save