2023-01-06 10:03:31 +08:00
|
|
|
/*
|
|
|
|
* @Author: zwq
|
|
|
|
* @Date: 2022-08-24 11:19:43
|
|
|
|
* @LastEditors: zwq
|
|
|
|
* @LastEditTime: 2023-01-05 10:54:13
|
|
|
|
* @Description:
|
|
|
|
*/
|
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
/* eslint-disable */
|
|
|
|
return {
|
|
|
|
urlOptions: {
|
|
|
|
submitURL: '',
|
|
|
|
infoURL: '',
|
|
|
|
getOption: false,
|
|
|
|
optionArrUrl: [],
|
|
|
|
optionArr: {}
|
|
|
|
},
|
|
|
|
visible: false,
|
|
|
|
setData:false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
created() {
|
|
|
|
},
|
|
|
|
activated() {
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
init(id) {
|
|
|
|
this.dataForm.id = id || "";
|
|
|
|
this.visible = true;
|
|
|
|
if (this.urlOptions.getOption) {
|
|
|
|
this.getArr()
|
|
|
|
}
|
|
|
|
this.$nextTick(() => {
|
|
|
|
this.$refs["dataForm"].resetFields();
|
|
|
|
if (this.dataForm.id) {
|
|
|
|
this.$http
|
|
|
|
.get(`${this.urlOptions.infoURL}/${this.dataForm.id}`)
|
|
|
|
.then(({ data: res }) => {
|
|
|
|
if (res.code !== 0) {
|
|
|
|
return this.$message.error(res.msg);
|
|
|
|
}
|
|
|
|
this.dataForm = res.data;
|
|
|
|
if(this.setData){
|
|
|
|
this.setDataForm()
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.catch(() => { });
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
getArr() {
|
|
|
|
this.urlOptions.optionArrUrl.forEach((item, index) => {
|
|
|
|
this.$http
|
|
|
|
.get(item, {
|
|
|
|
params: {
|
|
|
|
page: 1,
|
|
|
|
limit: 500,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
.then(({ data: res }) => {
|
|
|
|
if (res.code !== 0) {
|
|
|
|
return this.$message.error(res.msg);
|
|
|
|
}
|
|
|
|
this.$set(this.urlOptions.optionArr, `arr${index}`, res.data.list)
|
|
|
|
})
|
|
|
|
.catch(() => {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
// 表单提交
|
|
|
|
dataFormSubmit() {
|
|
|
|
this.$refs["dataForm"].validate((valid) => {
|
|
|
|
if (!valid) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
this.$http[!this.dataForm.id ? "post" : "put"](this.urlOptions.submitURL, this.dataForm)
|
|
|
|
.then(({ data: res }) => {
|
|
|
|
if (res.code !== 0) {
|
|
|
|
return this.$message.error(res.msg);
|
|
|
|
}
|
|
|
|
this.$message({
|
|
|
|
message: this.$t("prompt.success"),
|
|
|
|
type: "success",
|
|
|
|
duration: 500,
|
|
|
|
onClose: () => {
|
|
|
|
this.visible = false;
|
|
|
|
this.$emit("refreshDataList");
|
|
|
|
},
|
|
|
|
});
|
|
|
|
})
|
|
|
|
.catch(() => { });
|
|
|
|
});
|
|
|
|
},
|
|
|
|
formClear() {
|
|
|
|
this.$refs.dataForm.resetFields()
|
|
|
|
}
|
|
|
|
}
|
2023-05-11 16:22:07 +08:00
|
|
|
}
|