Commit 01580748 authored by renjintao's avatar renjintao

storeIndex、sotreTree、storeSelect、setNum......

parent 7295179d
<template> <template>
<Select v-model="dep" :placeholder="placeholdeinfo" clearable @on-clear="onClear"> <TreeSelect
<Option v-model="dep"
v-for="(item,index) in list" :data="list"
:key="index" @on-change="change"
:value="item.value" :disabled="disabled"
style="display:none" :multiple="multiple"
:label="item.label" :transfer="true"
></Option> />
<Tree key="mytree" :data="data1" ref="mytree" :render="renderContent"></Tree>
</Select>
</template> </template>
<script> <script>
export default { export default {
...@@ -21,15 +19,8 @@ export default { ...@@ -21,15 +19,8 @@ export default {
return { return {
dep: "", dep: "",
list: [], list: [],
data1: [], tempList:[],
selectdata: [], placeholdeinfo: "请选择"
placeholdeinfo: "请选择",
orderSearchForm: {
productId: null, //产品id
productName: "", //产品名称
drawingNo: "", //图号
bomId:null //bomId
}
}; };
}, },
props: { props: {
...@@ -49,108 +40,56 @@ export default { ...@@ -49,108 +40,56 @@ export default {
}, },
mounted() {}, mounted() {},
created() { created() {
this.dep = this.value | "";
this.loadTree(); this.loadTree();
}, },
methods: { methods: {
handleSelect(data) {
if (data.length > 0) {
this.selectdata = [];
this.selectdata = data;
if (data[0].isProduct == "1") {
this.list = [];
this.list.push({ label: data[0].title, value: data[0].id });
this.orderSearchForm.productName = data[0].title;
this.orderSearchForm.productId = data[0].productId;
this.orderSearchForm.drawingNo = data[0].drawingNo;
this.orderSearchForm.bomId = data[0].bomId;
this.$emit(
"on-change",
this.orderSearchForm.productId,
this.orderSearchForm
);
} else {
this.$Message.error("此节点不是产品,请选择产品节点!");
}
}
},
resetFields() {
this.orderSearchForm = {
productId: null, //产品id
productName: "", //产品名称
drawingNo: "", //图号
bomId:null
};
},
loadTree() { loadTree() {
//打开新增订单窗口加载产品 //打开新增订单窗口加载产品
this.resetFields(); let params = {
var sumData = []; conditions: [
this.$http.order.getallselecttree().then(res => { {
if (res.result) { fieldName: "title",
for (var i = 0; i < res.result.length; i++) { fieldValue: name,
sumData = sumData.concat(res.result[i]); conditionalType: "Like"
}
this.data1 = sumData;
} else {
this.$Message.error("加载产品树失败!");
}
});
},
renderContent(h, { root, node, data }) {
//渲染树的样式
return h(
"span",
{
style: {
color: data.isProduct != "1" ? "#249E91" : "#333", //根据选中状态设置样式
cursor: "pointer"
},
on: {
click: () => {
let arrTree = [];
arrTree.push(data);
this.handleSelect(arrTree); //手动选择树节点
}
} }
}, ]
data.title };
); this.$api
.post(`${resourceUrl}/storeroomlocation/paged`, params)
.then(r => {
let res = r.result.items;
this.tempList=this.$u.clone( r.result.items);
var data = this.$u.toTree(
res,
0,
u => {
u.value=u.id;
u.expand = true;
u.selected = false;
u.checked = false;
},
"upId"
);
this.list = this.$u.clone(data);
});
}, },
onClear() { change(v) {
this.list = []; // console.log(v);
this.placeholdeinfo = "请选择"; this.dep = v;
this.resetFields(); var item;
this.$emit("on-change", null, this.orderSearchForm); var items = this.tempList.filter(u => {
return u.id == v;
});
if (items && items.length > 0) {
item = items[0];
}
this.$emit("on-change", v, item);
} }
}, },
watch: { watch: {
value: { value: {
handler(v, o) { handler(v, o) {
this.dep = v | ""; this.dep = v | "";
this.resetFields();
var sumData = [];
this.$http.order.getallselecttree().then(res => {
if (res.result) {
for (var i = 0; i < res.result.length; i++) {
sumData = sumData.concat(res.result[i]);
}
this.data1 = sumData;
let temData = this.$u.clone(this.data1);
this.list = [];
if (v != "" && v != null) {
let dataTemp = this.$u.treeToList(temData);
dataTemp.forEach(data => {
if (data.isProduct == 1 && data.id == this.dep) {
this.placeholdeinfo = data.title;
this.list.push({ label: data.title, value: data.id });
}
});
}
} else {
this.$Message.error("加载产品树失败!");
}
});
}, },
deep: true deep: true
} }
......
...@@ -57,6 +57,7 @@ export default { ...@@ -57,6 +57,7 @@ export default {
res, res,
0, 0,
u => { u => {
u.value=u.id
u.expand = true; u.expand = true;
u.selected = false; u.selected = false;
u.checked = false; u.checked = false;
...@@ -72,14 +73,14 @@ export default { ...@@ -72,14 +73,14 @@ export default {
renderContent(h, { root, node, data }) { renderContent(h, { root, node, data }) {
let type = "md-folder"; let type = "md-folder";
return h("span", [ return h("span", [
h("Icon", { // h("Icon", {
props: { // props: {
type: type // type: type
}, // },
style: { // style: {
marginRight: "8px" // marginRight: "8px"
} // }
}), // }),
h( h(
"span", "span",
{ {
...@@ -95,17 +96,13 @@ export default { ...@@ -95,17 +96,13 @@ export default {
// console.log(b); // console.log(b);
let ids = []; let ids = [];
let productIds = []; let productIds = [];
if (b.bomId !== 0) { ids.push(b.id);
ids.push(b.bomId);
}
productIds.push(b.value); productIds.push(b.value);
if (b.children) { if (b.children) {
addId(b.children); addId(b.children);
function addId(data) { function addId(data) {
data.map(u => { data.map(u => {
if (u.bomId !== 0) { ids.push(u.id);
ids.push(u.bomId);
}
productIds.push(u.value); productIds.push(u.value);
if (u.children) { if (u.children) {
addId(u.children); addId(u.children);
......
...@@ -2,13 +2,13 @@ ...@@ -2,13 +2,13 @@
<Form ref="form" :model="entity" :rules="rules" :label-width="90"> <Form ref="form" :model="entity" :rules="rules" :label-width="90">
<Row> <Row>
<Col :span="12"> <Col :span="12">
<FormItem :label="l('name')" prop="materialCode"> <FormItem :label="l('name')" prop="materialId">
<Materiel v-model="entity.materialId" @on-change="change"></Materiel> <Materiel v-model="entity.materialId" @on-change="change"></Materiel>
</FormItem> </FormItem>
</Col> </Col>
<Col :span="12"> <Col :span="12">
<FormItem :label="l('storeTitle')" prop="storeTitle"> <FormItem :label="l('storeTitle')" prop="storeId">
<StoreSelect v-model="entity.storeId" ></StoreSelect> <StoreSelect v-model="entity.storeId" @on-change="storeChange"></StoreSelect>
</FormItem> </FormItem>
</Col> </Col>
<Col :span="12"> <Col :span="12">
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
</Col> </Col>
<Col :span="12"> <Col :span="12">
<FormItem :label="l('creator')" prop="creator"> <FormItem :label="l('creator')" prop="creator">
<Input v-model="entity.creator" :disabled="true"></Input> <User :value="entity.creator" />
</FormItem> </FormItem>
</Col> </Col>
<Col :span="24"> <Col :span="24">
...@@ -75,18 +75,40 @@ export default { ...@@ -75,18 +75,40 @@ export default {
total: null, total: null,
storeId: null, storeId: null,
storeTitle: "", storeTitle: "",
minNum: null,
brand: "", brand: "",
specifications: "", specifications: "",
batch: "", batch: "",
certificateOfApproval: "", certificateOfApproval: "",
creator: "", creator: this.$store.state.userInfo.userId,
unitPrice: null, unitPrice: null,
originalManufacturer: "", originalManufacturer: "",
remark: "" remark: ""
}, },
rules: { rules: {
name: [{ required: true, message: "必填", trigger: "blur" }] materialId: [
{
required: true,
message: "请选择物料",
type: "string",
trigger: "change"
}
],
storeId: [
{
required: true,
message: "请选择库位",
type: "number",
trigger: "change"
}
],
total: [
{
required: true,
message: "请输入入库数量",
type: "number",
trigger: "change"
}
]
} }
}; };
}, },
...@@ -136,6 +158,10 @@ export default { ...@@ -136,6 +158,10 @@ export default {
this.entity.materialId = e.materialId; this.entity.materialId = e.materialId;
this.entity.materialCode = e.mmcode; this.entity.materialCode = e.mmcode;
}, },
storeChange(v, item) {
this.entity.storeId = item.id;
this.entity.storeTitle = item.title;
},
l(key) { l(key) {
key = "stock" + "." + key; key = "stock" + "." + key;
return this.$t(key); return this.$t(key);
......
...@@ -22,5 +22,8 @@ export default { ...@@ -22,5 +22,8 @@ export default {
}, },
deletes(params) { deletes(params) {
return Api.post(`${resourceUrl}/stock/batchdelete`, params); return Api.post(`${resourceUrl}/stock/batchdelete`, params);
} },
setminnum(params) {
return Api.post(`${resourceUrl}/stock/setminnum`, params);
},
} }
...@@ -9,16 +9,11 @@ ...@@ -9,16 +9,11 @@
</a> </a>
</div> </div>
<Content class="content" :class="!showMenu?'con_bord':''"> <Content class="content" :class="!showMenu?'con_bord':''">
<DataGrid <DataGrid :columns="columns" ref="grid" :action="action" :conditions="easySearch">
:columns="columns"
ref="grid"
:action="action"
:conditions="easySearch"
>
<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" /> <Input placeholder="请输入物料名称/库位名称" v-model="easySearch.keys.value" v-width="240" />
</FormItem> </FormItem>
<FormItem> <FormItem>
<Button type="primary" @click="search">查询</Button> <Button type="primary" @click="search">查询</Button>
...@@ -70,8 +65,40 @@ export default { ...@@ -70,8 +65,40 @@ export default {
easy: true, easy: true,
high: true high: true
}, },
{ key: "total", title: this.l("total"), align: "left", high: true }, {
{ key: "minNum", title: this.l("minNum"), align: "left", high: true }, key: "total",
title: this.l("total"),
align: "right",
high: true,
render: (h, params) => {
let minNum=0
if(params.row.minNum)
{
minNum=params.row.minNum
}
return h(
"Tooltip",
{
props: {
content: "库存不足,总数小于" + minNum,
placement: "top",
disabled: params.row.total > minNum ? true : false
},
class:params.row.total > minNum ? "" : "red"
},
params.row.total
);
}
},
{
key: "minNum",
title: this.l("minNum"),
align: "right",
high: true,
render: (h, params) => {
return h("div", {}, params.row.minNum ? params.row.minNum : "0");
}
},
{ {
key: "storeTitle", key: "storeTitle",
title: this.l("storeTitle"), title: this.l("storeTitle"),
...@@ -82,58 +109,54 @@ export default { ...@@ -82,58 +109,54 @@ export default {
{ {
title: "操作", title: "操作",
key: "action", key: "action",
width: 140, width: 280,
align: "center", align: "center",
render: (h, params) => { render: (h, params) => {
return h("div", { class: "action" }, [ return h("div", { class: "action" }, [
h( h(
"op", "op",
{ {
attrs: { oprate: "detail" }, attrs: {
on: { click: () => this.view(params.row.id) } oprate: "detail",
title: "设置最低库存"
},
on: { click: () => this.setNum(params.row) }
}, },
"查看" "设置最低库存"
), ),
//h('op', { attrs: { oprate: 'copy' }, on: { click: () => this.copy(params.row.id) } }, '克隆'),
h( h(
"op", "op",
{ {
attrs: { oprate: "edit" }, attrs: { oprate: "detail" },
on: { click: () => this.edit(params.row.id) } on: { click: () => this.view(params.row.id) }
},
"编辑"
),
h(
"op",
{
attrs: { oprate: "delete" },
on: { click: () => this.remove(params.row.id) }
}, },
"删除" "查看"
) )
//h('op', { attrs: { oprate: 'copy' }, on: { click: () => this.copy(params.row.id) } }, '克隆'),
// h(
// "op",
// {
// attrs: { oprate: "edit" },
// on: { click: () => this.edit(params.row.id) }
// },
// "编辑"
// ),
// h(
// "op",
// {
// attrs: { oprate: "delete" },
// on: { click: () => this.remove(params.row.id) }
// },
// "删除"
// )
]); ]);
} }
} }
], ],
treeData: [], treeData: [],
treeInputSearch: "",
ocolumn: [], ocolumn: [],
treeHeight: "", treeHeight: "",
tableHeight: "",
ids: [], ids: [],
orderSearchForm: {
productId: "", //产品id
productName: "", //产品名称
taskType: "", //任务类型
quantity: null, //数量
taskRequire: "", //任务接点要求
demandStartDate: "", //开始时间
demandFinishDate: "", //完成时间
remark: "", //备注
projectNumber: "", //项目号
batchNumber: "", //批次号
urgencyLevel: null //紧急程度
},
list: [] list: []
}; };
}, },
...@@ -147,35 +170,13 @@ export default { ...@@ -147,35 +170,13 @@ export default {
return (() => { return (() => {
window.screenHeight = window.innerHeight; window.screenHeight = window.innerHeight;
this.treeHeight = window.screenHeight - 150; this.treeHeight = window.screenHeight - 150;
})(); })();
}; };
}, },
async fetch({ store, params }) { async fetch({ store, params }) {
await store.dispatch("loadDictionary"); // 加载数据字典 await store.dispatch("loadDictionary"); // 加载数据字典
}, },
computed: { computed: {},
searchList() {
let nodeList = this.treeData;
var text = this.treeInputSearch;
var newNodeList = [];
function searchTree(nodeLists, value) {
for (let i = 0; i < nodeLists.length; i++) {
if (nodeLists[i].title.indexOf(value) != -1) {
newNodeList.push(nodeLists[i]);
} else if (nodeLists[i].children.length > 0) {
searchTree(nodeLists[i].children, value);
}
}
}
if (text != "") {
searchTree(nodeList, text);
} else {
return nodeList;
}
return newNodeList;
}
},
methods: { methods: {
ok() { ok() {
this.$refs.grid.load(); this.$refs.grid.load();
...@@ -230,9 +231,15 @@ export default { ...@@ -230,9 +231,15 @@ export default {
this.showMenu = true; this.showMenu = true;
}, },
productSearch(id, item, productIds, ids) { productSearch(id, item, productIds, ids) {
let where = { bomId: { op: "In", value: ids } }; let where = { storeId: { op: "In", value: ids } };
this.$refs.grid.reload(where); this.$refs.grid.reload(where);
}, },
setNum(row) {
this.curId = row.id;
this.title = "设置最低库存";
this.detail = () => import("./setNum");
this.modal = true;
},
l(key) { l(key) {
let vkey = "stock" + "." + key; let vkey = "stock" + "." + key;
return this.$t(vkey) || key; return this.$t(vkey) || key;
...@@ -246,7 +253,6 @@ export default { ...@@ -246,7 +253,6 @@ export default {
for (var i = 0; i < res.result.length; i++) { for (var i = 0; i < res.result.length; i++) {
sumData = sumData.concat(res.result[i]); sumData = sumData.concat(res.result[i]);
} }
this.treeData = sumData;
this.data1 = JSON.parse(JSON.stringify(sumData)); this.data1 = JSON.parse(JSON.stringify(sumData));
} else { } else {
this.$Message.error("加载产品树失败!"); this.$Message.error("加载产品树失败!");
......
<template>
<Form ref="form" :model="entity" :rules="rules" :label-width="90">
<Row>
<Col :span="12">
<FormItem :label="l('name')" prop="name">
<Input v-model="entity.name" disabled></Input>
</FormItem>
</Col>
<Col :span="12">
<FormItem :label="l('storeTitle')" prop="storeTitle">
<Input v-model="entity.storeTitle" disabled></Input>
</FormItem>
</Col>
<Col :span="12">
<FormItem :label="l('minNum')" prop="minNum">
<InputNumber v-model="entity.minNum"></InputNumber>
</FormItem>
</Col>
</Row>
<FormItem>
<Button type="primary" @click="handleSubmit" :disabled="disabled">保存</Button>
<Button @click="handleClose" class="ml20">取消</Button>
</FormItem>
</Form>
</template>
<script>
import Api from "./api";
export default {
name: "Add",
data() {
return {
disabled: false,
entity: {
id: null,
name: "",
materialId: "",
materialCode: "",
storeId: null,
storeTitle: "",
minNum: null
},
rules: {}
};
},
props: {
v: Object,
eid: Number
},
mounted() {
if (this.eid > 0) {
this.load(this.eid);
}
},
methods: {
handleSubmit() {
let params = {
id: this.entity.id,
minNum: this.entity.minNum
};
this.disabled = true;
Api.setminnum(params)
.then(r => {
this.disabled = false;
if (r.success) {
this.$Message.success("设置成功");
this.$emit("on-ok");
} else {
this.$Message.error("设置失败失败");
}
})
.catch(err => {
this.disabled = false;
this.$Message.error("保存失败");
console.warn(err);
});
},
handleClose() {
this.$emit("on-close");
},
load(v) {
Api.get({ id: v }).then(r => {
this.entity = r.result;
});
},
l(key) {
key = "stock" + "." + key;
return this.$t(key);
}
},
watch: {
v() {
this.entity = this.$u.clone(this.v);
},
eid(v) {
if (v > 0) {
this.load(v);
}
}
}
};
</script>
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