export default {
data() {
return {
rawAlldata:[],
checkedAll:false,
pubobj:{},
relationKind:[],
relationVal:"",
Varietyname:"",
dialogFormVisible: false,
PurchaseDate:"",
producDate:"",
voucherName:"",
productList:[],
prodALLData:[],
sizeForm: {},
selListData:[],
fileupload: canTeenAnalysisI.fileupload,
upImgList:[],
needsetID:"",
publictext:{
textname:"新增凭证",
textbutton:"新增"
}
};
},
created() {
},
methods:{
//父级调用的方法
childMethod(valitem){
this.dialogFormVisible=true;
},
chanproductime(val){
},
SaveallInfo(){
var that=this;
if(this.voucherName==""){
that.$message.error("凭证名称不可为空");
return
}
if(this.PurchaseDate=="" || this.PurchaseDate==null){
that.$message.error("进货日期不可为空");
return
}
if(this.producDate=="" || this.producDate==null){
that.$message.error("生产日期不可为空");
return
}
if(this.selListData.length==0){
that.$message.error("关联商品不可为空");
return
}
if(this.upImgList.length==0){
that.$message.error("请上传图片");
return
}
var postdata ={
productIds:this.selListData,
productionDate:this.producDate,
voucherFiles:this.upImgList,
voucherInDate:this.PurchaseDate,
voucherName:this.voucherName,
productTypeId:this.relationVal
}
if(this.publictext.textbutton=="新增"){
//alert("新增")
VoucherApi.AddVoucherinfo(postdata).then(res=> {
if(res.code == 200){
that.$message.success("新增成功");
this.dialogFormVisible=false;
this.$emit('fatherMethod');
}else{
that.$message.error(res.message);
}
// 执行某些操作
})
}else{
this.$set(postdata,"voucherId",this.pubobj.voucherId)
//alert("编辑")
VoucherApi.EditVoucherinfo(postdata).then(res=> {
if(res.code == 200){
that.$message.success("编辑成功");
this.dialogFormVisible=false;
this.$emit('fatherMethod');
}else{
that.$message.error(res.message);
}
// 执行某些操作
})
}
},
selectChanged(val){
if(this.productList.length==0){
this.getprodList(val)
return
}
this.$confirm('此操作将覆盖上次选择的数据, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.relationVal=val;
this.productList =[];
this.selListData=[];
this.getprodList(val)
}).catch((err) => {
console.log(err)
this.relationVal="";
this.$message({
type: 'info',
message: '已取消'
});
});
},
getprodList(val){
this.needsetID =val;
var that = this;
VoucherApi.getrequireproduct(val).then(res=> {
if(res.code == 200){
this.productList = res.data;
this.rawAlldata=res.data;
}else{
that.$message.error(res.message);
}
// 执行某些操作
})
},
clearAllname(){
this.productList= this.rawAlldata;
},
//过滤数据
screenname(val){
var dataall =[]
dataall = this.productList.filter(item => {
if ( item.productName.includes(val) ) {
return true;
}
});
console.log(dataall)
this.productList = dataall;
},
selAllprod(val){
this.selListData=[];
if(val){
for (let i = 0; i < this.productList.length; i++) {
this.selListData.push(this.productList[i].productId)
}
}else{
this.selListData=[];
}
},
getallKind(){
var that = this;
VoucherApi.getcategorylist().then(res=> {
if(res.code == 200){
this.relationKind = res.data;
}else{
that.$message.error(res.message);
}
})
},
choseitem(indexval,itemval){
let arrIndex = this.selListData.indexOf(itemval.productId);
// console.log(arrIndex);
if(arrIndex>-1){
this.selListData.splice(arrIndex,1);
this.checkedAll=false;
}else{
this.selListData.push(itemval.productId);
}
}
}
};
网友评论