122 lines
3.1 KiB
JavaScript
122 lines
3.1 KiB
JavaScript
/*
|
|
* @Author: zwq
|
|
* @Date: 2022-08-24 11:19:43
|
|
* @LastEditors: zwq
|
|
* @LastEditTime: 2023-11-02 15:33:39
|
|
* @Description:
|
|
*/
|
|
import { listData } from "@/api/system/dict/data";
|
|
export default {
|
|
data() {
|
|
/* eslint-disable */
|
|
return {
|
|
urlOptions: {
|
|
createURL: '',
|
|
updateURL: '',
|
|
infoURL: '',
|
|
codeURL: '',
|
|
getOption: false, //是否加载获取下拉框方法
|
|
isGetCode: false, //是否加载获取code方法
|
|
getDictList: false, //是否加载获取数据字典方法
|
|
optionArrUrl: [], //需要获取下拉框的方法数组
|
|
optionArr: {}, //需要获取下拉框的方法数组的返回结果
|
|
dictList: {}, //需要获取数据字典的方法数组的返回结果
|
|
},
|
|
visible: false,
|
|
setData: false
|
|
}
|
|
},
|
|
created() {
|
|
},
|
|
activated() {
|
|
},
|
|
methods: {
|
|
init(id) {
|
|
this.dataForm.id = id || "";
|
|
this.visible = true;
|
|
if (this.urlOptions.getOption) {
|
|
this.getArr()
|
|
}
|
|
if (this.urlOptions.getDictList) {
|
|
this.getDict()
|
|
}
|
|
this.$nextTick(() => {
|
|
this.$refs["dataForm"].resetFields();
|
|
if (this.dataForm.id) {
|
|
this.urlOptions.infoURL(id).then(response => {
|
|
this.dataForm = response.data;
|
|
if (this.setData) {
|
|
this.setDataForm()
|
|
}
|
|
});
|
|
} else {
|
|
if (this.urlOptions.isGetCode) {
|
|
this.getCode()
|
|
}
|
|
}
|
|
});
|
|
},
|
|
getCode() {
|
|
this.urlOptions.codeURL()
|
|
.then(({ data: res }) => {
|
|
this.dataForm.code = res;
|
|
})
|
|
.catch(() => {});
|
|
},
|
|
getArr() {
|
|
const params = {
|
|
pageSize: 100,
|
|
pageNo: 1,
|
|
}
|
|
this.urlOptions.optionArrUrl.forEach((item, index) => {
|
|
item(params).then(({ data: res }) => {
|
|
this.$set(this.urlOptions.optionArr, `arr${index}`, res.list)
|
|
})
|
|
.catch(() => {
|
|
});
|
|
});
|
|
},
|
|
/** 查询字典数据列表 */
|
|
getDict() {
|
|
this.nameList.forEach((item,index)=>{
|
|
const queryParams = {
|
|
pageNo: 1,
|
|
pageSize: 99,
|
|
dictType: item,
|
|
}
|
|
listData(queryParams).then(response => {
|
|
this.$set(this.urlOptions.dictList, `dict${index}`, response.data.list)
|
|
});
|
|
})
|
|
},
|
|
// 表单提交
|
|
dataFormSubmit() {
|
|
this.$refs["dataForm"].validate((valid) => {
|
|
if (!valid) {
|
|
return false;
|
|
}
|
|
// 修改的提交
|
|
if (this.dataForm.id) {
|
|
this.urlOptions.updateURL(this.dataForm).then(response => {
|
|
this.$modal.msgSuccess("修改成功");
|
|
this.visible = false;
|
|
this.$emit("refreshDataList");
|
|
});
|
|
return;
|
|
}
|
|
// 添加的提交
|
|
this.urlOptions.createURL(this.dataForm).then(response => {
|
|
this.$modal.msgSuccess("新增成功");
|
|
this.visible = false;
|
|
this.$emit("refreshDataList");
|
|
});
|
|
});
|
|
},
|
|
formClear() {
|
|
if (this.$refs.dataForm!==undefined) {
|
|
this.$refs.dataForm.resetFields();
|
|
}
|
|
}
|
|
}
|
|
}
|