|
//此js文件是用来自定义扩展业务代码,可以扩展一些自定义页面或者重新配置生成的代码
|
|
import { el, fa, th } from "element-plus/es/locales.mjs";
|
|
let extension = {
|
components: {
|
//查询界面扩展组件
|
gridHeader: '',
|
gridBody: '',
|
gridFooter: '',
|
//新建、编辑弹出框扩展组件
|
modelHeader: '',
|
modelBody: '',
|
modelFooter: ''
|
},
|
tableAction: '', //指定某张表的权限(这里填写表名,默认不用填写)
|
buttons: { view: [], box: [], detail: [] }, //扩展的按钮
|
methods: {
|
//获取表单配置
|
getOption(field) {
|
let option;
|
this.detailOptions.columns.forEach(x => {
|
if (x.field == field) {
|
option = x;
|
}
|
// x.forEach(item => {
|
// if (item.field == field) {
|
// option = item;
|
// }
|
// })
|
})
|
return option;
|
},
|
//下面这些方法可以保留也可以删除
|
onInit() {
|
// let enableBtn = this.buttons.find(x => x.value == 'Add');
|
// if (enableBtn) {
|
// this.detailOptions.columns.forEach(x => {
|
// if (x.field == 'materielCode' || x.field == 'batchNo' || x.field == 'orderQuantity') {
|
// x.readonly = false
|
// }
|
// });
|
// }
|
},
|
onInited() {
|
//框架初始化配置后
|
//如果要配置明细表,在此方法操作
|
this.detailOptions.columns.forEach(x => {
|
|
if (x.field == 'materielCode') {
|
x.onChange = (val, option) => {
|
// this.$error(val.materielCode)
|
this.http.post("/api/MaterielInfo/Getmaterianame", { Extra: val.materielCode }, true).then(
|
source => {
|
if (!source.status) return this.$error(source.message);
|
val.materielName = source.data.materielName;
|
// this.$success(source.data.materielName);
|
this.refresh();
|
})
|
// let locationCodes = this.getOption("locationCode");
|
// locationCodes.bind.data.splice(0);
|
// this.http.post("/api/LocationInfo/GetLocationCodes", { Extra: val.materielCode }, true).then(
|
// source => {
|
// if (!source.status) return this.$error(source.message);
|
// val.materielName = source.message;
|
// for (let i = 0; i < source.data.length; i++) {
|
// locationCodes.bind.data.push({ key: source.data[i], value: source.data[i] });
|
// }
|
// this.refresh();
|
// })
|
}
|
}
|
});
|
},
|
searchBefore(param) {
|
//界面查询前,可以给param.wheres添加查询参数
|
//返回false,则不会执行查询
|
return true;
|
},
|
searchAfter(result) {
|
//查询后,result返回的查询数据,可以在显示到表格前处理表格的值
|
return true;
|
},
|
addBefore(formData) {
|
//新建保存前formData为对象,包括明细表,可以给给表单设置值,自己输出看formData的值
|
let req = true;
|
// let locationCodes = formData.detailData.map(x=>{
|
// // this.$error(x.locationCode);
|
// return x.locationCode
|
// });
|
|
formData.detailData.forEach(x => {
|
// if ('locationCode' in x) {
|
// // return this.$error(x.batchNo);
|
// }
|
if (!x.hasOwnProperty('batchNo')) {
|
req = false;
|
return this.$error("柜号不能为空");
|
}
|
})
|
// if (formData.detailData.length > 3) return this.$error("入库单明细不能超过3个");
|
return req;
|
},
|
updateBefore(formData) {
|
//编辑保存前formData为对象,包括明细表、删除行的Id
|
// this.$error(formData.detailData.length)
|
// if (formData.detailData.length > 3) return this.$error("入库单明细不能超过3个");
|
return true;
|
},
|
rowClick({ row, column, event }) {
|
//查询界面点击行事件
|
// this.$refs.table.$refs.table.toggleRowSelection(row); //单击行时选中当前行;
|
},
|
modelOpenAfter(row) {
|
//点击编辑、新建按钮弹出框后,可以在此处写逻辑,如,从后台获取数据
|
//(1)判断是编辑还是新建操作: this.currentAction=='Add';
|
//(2)给弹出框设置默认值
|
//(3)this.editFormFields.字段='xxx';
|
//如果需要给下拉框设置默认值,请遍历this.editFormOptions找到字段配置对应data属性的key值
|
//看不懂就把输出看:console.log(this.editFormOptions)
|
if (this.currentAction == 'Add') {
|
let locationCodes = this.getOption("locationCode");
|
locationCodes.bind.data.splice(0);
|
this.http.post("/api/LocationInfo/GetLocationCodes", null, true).then(
|
source => {
|
if (!source.status) return this.$error(source.message);
|
for (let i = 0; i < source.data.length; i++) {
|
locationCodes.bind.data.push({ key: source.data[i], value: source.data[i] });
|
}
|
this.refresh();
|
})
|
this.editFormOptions.forEach(x => {
|
x.forEach(option => {
|
if (option.field == 'orderNo' || option.field == 'orderType') {
|
option.readonly = false
|
}
|
})
|
})
|
this.detailOptions.columns.forEach(x => {
|
if (x.field == 'materielCode' || x.field == 'batchNo' || x.field == 'orderQuantity' || x.field == 'locationCode') {
|
x.readonly = false
|
}
|
});
|
} else {
|
this.editFormOptions.forEach(x => {
|
x.forEach(option => {
|
if (option.field == 'orderNo' || option.field == 'orderType') {
|
option.readonly = true
|
}
|
})
|
})
|
// this.detailOptions.columns.forEach(x => {
|
// if (x.field == 'materielCode' || x.field == 'batchNo' || x.field == 'orderQuantity' || x.field == 'locationCode') {
|
// x.readonly = true// row.orderStatus > 0
|
// }
|
// });
|
}
|
// if (row.orderStatus != '0') {
|
// this.detailOptions.columns.forEach(x => {
|
// if (x.field == 'materielCode' || x.field == 'batchNo' || x.field == 'orderQuantity') {
|
// x.readonly = row.orderStatus > 0
|
// }
|
// });
|
// } else {
|
// this.detailOptions.columns.forEach(x => {
|
// if (x.field == 'materielCode' || x.field == 'batchNo' || x.field == 'orderQuantity') {
|
// x.disabled = true;
|
// }
|
// })
|
// }
|
}
|
}
|
};
|
export default extension;
|