Commit 44312e7a authored by 仇晓婷's avatar 仇晓婷

制造资源

parent c53b13f9
<template> <template>
<div> <div>
<Table border :columns="columns" :data="cartList" class="tableCommon" height="300"> <Table border :columns="columns" :data="cartList" class="tableCommon" height="300">
<template slot-scope="{ row, index }" slot="numberAvailable"> <template slot-scope="{ row, index }" slot="count">
<InputNumber <InputNumber
:max="row.numberAvailable1" :max="row.numberAvailable"
:min="1" :min="1"
v-model="row.numberAvailable" v-model="row.count"
@on-change="inputOrderCat(row,index)" @on-change="inputOrderCat(row,index)"
></InputNumber> ></InputNumber>
</template> </template>
...@@ -92,7 +92,7 @@ export default { ...@@ -92,7 +92,7 @@ export default {
}, },
{ {
key: "numberAvailable", key: "numberAvailable",
title: "借出数", title: this.l("numberAvailable"),
align: "left", align: "left",
easy: true, easy: true,
}, },
...@@ -123,10 +123,10 @@ export default { ...@@ -123,10 +123,10 @@ export default {
}, },
}, },
{ {
title: this.l("numberAvailable"), title: this.l("count"),
key: "numberAvailable", key: "count",
width: 100, width: 100,
slot: "numberAvailable", slot: "count",
}, },
{ {
title: this.l("action"), title: this.l("action"),
...@@ -181,33 +181,37 @@ export default { ...@@ -181,33 +181,37 @@ export default {
this.resource.customer = name; this.resource.customer = name;
}, },
handleSubmit() { handleSubmit() {
var items = []; if (this.cartList.length > 0) {
let count = 0; var items = [];
this.cartList.forEach((data) => { let count = 0;
let objList = Object.assign({}, this.resource); this.cartList.forEach((data) => {
delete objList.item; let objList = Object.assign({}, this.resource);
console.log(data); delete objList.item;
objList.resourceId = data.resourceId; console.log(data);
objList.resourceCode = data.resourceCode; objList.resourceId = data.resourceId;
objList.resourceMainId = data.id; objList.resourceCode = data.resourceCode;
objList.count = data.numberAvailable; objList.resourceMainId = data.id;
items.push(objList); objList.count = data.count;
count += 1; items.push(objList);
}); count += 1;
this.resource.item = items; });
if (this.resource.customerId == 0) { this.resource.item = items;
} if (this.resource.customerId == 0) {
this.$refs.form.validate((v) => {
if (v) {
Api.cartCreate(this.resource).then((r) => {
if (r.success) {
this.$Message.success("保存成功");
this.$emit("substr", count, -1);
this.$emit("on-ok");
}
});
} }
}); this.$refs.form.validate((v) => {
if (v) {
Api.cartCreate(this.resource).then((r) => {
if (r.success) {
this.$Message.success("保存成功");
this.$emit("substr", count, -1);
this.$emit("on-ok");
}
});
}
});
} else {
this.$Message.error("借出车不能为空");
}
}, },
handleClose() { handleClose() {
this.$emit("on-close"); this.$emit("on-close");
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
<template slot="easySearch"> <template slot="easySearch">
<Form ref="formInline" :model="easySearch" inline> <Form ref="formInline" :model="easySearch" inline>
<FormItem prop="keys"> <FormItem prop="keys">
<Input placeholder="请输入资源名称/资源编码" v-model="easySearch.keys.value" v-width="260" /> <Input clearable placeholder="请输入资源名称/资源编码/编码" v-model.trim="easySearch.keys.value" v-width="260" />
</FormItem> </FormItem>
<FormItem> <FormItem>
<Button type="primary" @click="search">查询</Button> <Button type="primary" @click="search">查询</Button>
...@@ -79,7 +79,7 @@ export default { ...@@ -79,7 +79,7 @@ export default {
action: Api.index, action: Api.index,
showMenu: true, showMenu: true,
easySearch: { easySearch: {
keys: { op: "name,storeTitle,materialCode", value: null }, keys: { op: "nameOfResource,code,resourceCode", value: null },
}, },
fscreeen: false, fscreeen: false,
modal: false, modal: false,
...@@ -378,29 +378,32 @@ export default { ...@@ -378,29 +378,32 @@ export default {
this.$Message.error("资源无库存"); this.$Message.error("资源无库存");
} }
} else { } else {
this.$Message.success("已加入借出车,请在借出车查看"); // this.$Message.success("已加入借出车,请在借出车查看");
let arr = this.selectRows.concat(this.cartList); //两个数组对象合并
let a = []; let newArr = []; //盛放去重后数据的新数组
let n = []; //一个新的临时数组 arr.forEach(function (item) {
a = this.selectRows.concat(this.cartList); let hasPush = false;
//遍历当前数组 newArr.forEach((item2, index, thisArr) => {
for (var i = 0; i < a.length; i++) { if (item.id == item2.id) {
//如果当前数组的第i已经保存进了临时数组,那么跳过, hasPush = true;
//否则把当前项push到临时数组里面 thisArr[index] = { ...item, ...item2 };
if (n.indexOf(a[i]) == -1) n.push(a[i]); return;
} }
console.log(n); });
this.cartList = n; !hasPush && newArr.push(item);
this.cartListCount = n.length; });
this.cartList = newArr;
this.cartListCount = newArr.length;
this.$store.commit("setCart", this.cartList); this.$store.commit("setCart", this.cartList);
this.$store.commit("setCartCount", this.cartListCount); this.$store.commit("setCartCount", this.cartListCount);
this.$refs.grid.load(); this.$refs.grid.load();
this.$refs.grid.footerToolbar = false;
} }
}, },
//移除借出车 //移除借出车
substr(value, index) { substr(value, index) {
console.log(value); // console.log(value);
console.log(index); // console.log(index);
if (index > -1) { if (index > -1) {
this.cartListCount -= value; this.cartListCount -= value;
this.cartList.splice(index, 1); this.cartList.splice(index, 1);
...@@ -417,8 +420,8 @@ export default { ...@@ -417,8 +420,8 @@ export default {
this.$store.commit("setCart", this.cartList); this.$store.commit("setCart", this.cartList);
this.$store.commit("setCartCount", this.cartListCount); this.$store.commit("setCartCount", this.cartListCount);
} }
console.log(this.$store.state.count); // console.log(this.$store.state.count);
console.log(this.$store.state.cart); // console.log(this.$store.state.cart);
}, },
showCart() { showCart() {
if (this.$store.state.count > 0) { if (this.$store.state.count > 0) {
......
...@@ -61,6 +61,11 @@ export default { ...@@ -61,6 +61,11 @@ export default {
title: "领料人", title: "领料人",
key: "customer", key: "customer",
}, },
{
title: "状态",
key: "status",
code: "resource.record.status",
},
{ {
title: this.l("action"), title: this.l("action"),
key: "action", key: "action",
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
enter-button enter-button
placeholder="请输入借出人/名称/编码" placeholder="请输入借出人/名称/编码"
@on-search="easySearch" @on-search="easySearch"
v-model="search.name" v-model.trim="search.name"
style="width:240px" style="width:240px"
/>&nbsp; />&nbsp;
<Table <Table
...@@ -15,7 +15,16 @@ ...@@ -15,7 +15,16 @@
class="tableCommon" class="tableCommon"
@on-selection-change="selectInfo" @on-selection-change="selectInfo"
height="300" height="300"
></Table> >
<template slot-scope="{ row, index }" slot="count">
<InputNumber
:max="row.count"
:min="1"
v-model="row.count"
@on-change="inputOrderCat(row,index)"
></InputNumber>
</template>
</Table>
<Form :label-width="110" class="mt20 mb20"> <Form :label-width="110" class="mt20 mb20">
<Row> <Row>
<Col span="15">&nbsp;</Col> <Col span="15">&nbsp;</Col>
...@@ -92,6 +101,7 @@ export default { ...@@ -92,6 +101,7 @@ export default {
title: this.l("count"), title: this.l("count"),
key: "count", key: "count",
width: 120, width: 120,
slot: "count",
}, },
], ],
search: { search: {
...@@ -111,10 +121,24 @@ export default { ...@@ -111,10 +121,24 @@ export default {
this.get(); this.get();
}, },
methods: { methods: {
get() { get(name) {
Api.paged({ trollerId: this.eid }).then((r) => { let data = { trollerId: this.eid };
if (name) {
data.name = name;
}
Api.paged(data).then((r) => {
if (r.success) { if (r.success) {
this.dataList = r.result.items; let items = [];
let dataList1 = [];
dataList1 = r.result.items;
dataList1.forEach((data) => {
let objList = data;
objList.count1 = parseFloat(data.count);
objList.count = parseFloat(data.count);
objList.state = "3";
items.push(objList);
});
this.dataList = items;
} }
}); });
}, },
...@@ -143,15 +167,8 @@ export default { ...@@ -143,15 +167,8 @@ export default {
return this.$t(vkey) || key; return this.$t(vkey) || key;
}, },
easySearch() { easySearch() {
Api.paged({ trollerId: this.eid, name: $.trim(this.search.name) }).then( this.get(this.search.name);
(r) => {
if (r.success) {
this.dataList = r.result.items;
}
}
);
}, },
}, },
watch: {}, watch: {},
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment