埃驰前端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

95 lines
2.6 KiB

import {
postCreate,
postUpdate,
} from "@/api/wms-api"
import * as allUrlOption from '@/utils/baseData/urlOption'
export const newAndEdiDialogMixins = {
data() {
return {
URLOption_base:allUrlOption[this.$route.name].baseURL,
URLOption_updata:allUrlOption[this.$route.name].updataURL,
URLOption_add:allUrlOption[this.$route.name].addURL,
URLOption_edit:allUrlOption[this.$route.name].editURL,
//form数据显示操控
formReveal: true,
pageStatus: "",
active: 0,
ref: null
}
},
methods: {
//关闭弹窗
closeDialog(val) {
this.pageStatus = ""
if (this.formReveal) {
this.CreateFormData = val
this.displayDialog.newDialog = false
if (this.active) {
this.oldSkipCount = 1;
this.paging();
}
} else {
this.displayDialog.editDialog = false
if (this.active) {
this.paging();
}
}
this.active = 0
},
// //取消
// determine(val) {
// this.FormRemove(val)
// this.closeDialog()
// },
//控制步骤与返回结果
FormResult(val) {
if (val == "success") {
this.active = 1
this.pageStatus = "success"
} else {
this.active = 2
this.pageStatus = "error"
}
},
//提交表单
FormSubmit(val) {
this.ref = val
this.Loading.newAndEdiLoading = true
let _updata = this.formReveal ? this.URLOption_add : this.URLOption_edit
let _url = this.URLOption_updata ? this.URLOption_updata : (_updata ? _updata : this.URLOption_base)
switch (this.formReveal) {
case true:
if(!_updata && !this.URLOption_updata){_url = _url + '/create'}
postCreate(this.CreateFormData, _url).then(res => {
this.oldSkipCount = 1;
this.Loading.newAndEdiLoading = false
this.FormResult("success")
}).catch(err => {
this.Loading.newAndEdiLoading = false
this.FormResult("error")
})
break;
case false:
if(!_updata && !this.URLOption_updata){_url = _url + '/update-by-id'}
postUpdate(this.editFormData, this.propsData.id, _url).then(res => {
this.propsData = res
this.Loading.newAndEdiLoading = false
this.FormResult("success")
}).catch(err => {
this.Loading.newAndEdiLoading = false
this.FormResult("error")
})
}
},
//删除表单、退出dialog
FormClose(val) {
this.closeDialog(val)
},
//回退
goBack() {
this.active = 0
this.pageStatus = ""
}
}
}