优化代码

This commit is contained in:
java110 2022-06-07 19:10:06 +08:00
parent f2b69e828a
commit 3ecb58acf8
3 changed files with 37 additions and 3 deletions

View File

@ -9,6 +9,7 @@
<table class="footable table table-stripped toggle-arrow-tiny" data-page-size="15">
<thead>
<tr>
<th class="text-center"><input type="checkbox" class="i-checks" @click="checkAll($event)"></th>
<th class="text-center"><span><vc:i18n name="物品类型" namespace="resourceEnterManage"></vc:i18n></span></th>
<th class="text-center"><span><vc:i18n name="物品名称" namespace="resourceEnterManage"></vc:i18n></span></th>
<th class="text-center"><span><vc:i18n name="物品规格" namespace="resourceEnterManage"></vc:i18n></span></th>
@ -24,6 +25,9 @@
</thead>
<tbody>
<tr v-for="resourceEnter in resourceEnterManageInfo.purchaseApplyDetailVo">
<td class="text-center">
<input type="checkbox" class="i-checks checkItem" v-bind:value="resourceEnter.resId" v-model="resourceEnterManageInfo.selectResIds">
</td>
<td class="text-center">{{resourceEnter.rstName ? resourceEnter.rstName : '-'}}</td>
<td class="text-center">{{resourceEnter.resName}}</td>
<td class="text-center">{{resourceEnter.specName ? resourceEnter.specName : '-'}}</td>

View File

@ -13,6 +13,7 @@
resOrderType: '',
purchaseApplyDetailVo: [],
resourceSuppliers: [],
selectResIds: [],
}
},
_initMethod: function() {
@ -92,7 +93,19 @@
_submit: function() {
//校验 是否填写正确
let msg = '';
let _tmpPurchaseApplyDetailVo = [];
$that.resourceEnterManageInfo.purchaseApplyDetailVo.forEach(function(item) {
$that.resourceEnterManageInfo.selectResIds.forEach(selectItem => {
if (item.resId == selectItem) {
_tmpPurchaseApplyDetailVo.push(item);
}
})
});
if (_tmpPurchaseApplyDetailVo.length < 1) {
vc.toast('请选择入库物品')
return;
}
_tmpPurchaseApplyDetailVo.forEach(function(item) {
console.log(item);
if (!item.hasOwnProperty("purchaseQuantity") || !item.purchaseQuantity || parseInt(item.purchaseQuantity) < 0) {
msg = '采购数量未填写';
@ -109,6 +122,7 @@
vc.toast(msg);
return;
}
$that.resourceEnterManageInfo.purchaseApplyDetailVo = _tmpPurchaseApplyDetailVo;
vc.http.apiPost(
'/purchase/resourceEnter',
JSON.stringify($that.resourceEnterManageInfo), {
@ -152,7 +166,19 @@
vc.toast("处理失败:" + errInfo);
}
);
}
},
checkAll: function(e) {
var checkObj = document.querySelectorAll('.checkItem'); // 获取所有checkbox项
if (e.target.checked) { // 判定全选checkbox的勾选状态
for (var i = 0; i < checkObj.length; i++) {
if (!checkObj[i].checked) { // 将未勾选的checkbox选项push到绑定数组中
vc.component.resourceEnterManageInfo.selectResIds.push(checkObj[i].value);
}
}
} else { // 如果是去掉全选则清空checkbox选项绑定数组
vc.component.resourceEnterManageInfo.selectResIds = [];
}
},
}
});
})(window.vc);

View File

@ -18,6 +18,7 @@
<th scope="col" class="text-center"><span><vc:i18n name="编号" namespace="printPurchaseApply"></vc:i18n></span></th>
<th scope="col" class="text-center"><span><vc:i18n name="名称" namespace="printPurchaseApply"></vc:i18n></span></th>
<th scope="col" class="text-center"><span><vc:i18n name="编码规格" namespace="printPurchaseApply"></vc:i18n></span></th>
<th scope="col" class="text-center"><span><vc:i18n name="参考价格" namespace="printPurchaseApply"></vc:i18n></span></th>
<th scope="col" class="text-center"><span><vc:i18n name="申请数量" namespace="printPurchaseApply"></vc:i18n></span></th>
<th scope="col" class="text-center"><span><vc:i18n name="采购数量" namespace="printPurchaseApply"></vc:i18n></span></th>
<th scope="col" class="text-center"><span><vc:i18n name="备注" namespace="printPurchaseApply"></vc:i18n></span></th>
@ -28,13 +29,16 @@
<th scope="row" class="text-center">{{index +1}}</th>
<td class="text-center">{{item.resName}}</td>
<td class="text-center">{{item.resCode}}</td>
<td class="text-center">{{item.price}}</td>
<td class="text-center">{{item.quantity}}</td>
<td class="text-center">{{item.purchaseQuantity? item.purchaseQuantity : '-'}}</td>
<td class="text-center">{{item.remark}}</td>
</tr>
<tr>
<th scope="row" class="text-center"><span><vc:i18n name="备注" namespace="printPurchaseApply"></vc:i18n></span></th>
<td colspan="5">{{printPurchaseApplyInfo.description}}</td>
<td colspan="4">{{printPurchaseApplyInfo.description}}</td>
<td class="text-center">参考总价格</td>
<td>{{printPurchaseApplyInfo.totalPrice}}</td>
</tr>
<tr height="60px">
<td colspan="2" class="text-center " style="vertical-align:middle;"><span><vc:i18n name="厂家签字" namespace="printPurchaseApply"></vc:i18n></span></td>
@ -60,4 +64,4 @@
</button>
</div>
</div>
</div>
</div>