Commit 01580748 authored by renjintao's avatar renjintao

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

parent 7295179d
<template>
<Select v-model="dep" :placeholder="placeholdeinfo" clearable @on-clear="onClear">
<Option
v-for="(item,index) in list"
:key="index"
:value="item.value"
style="display:none"
:label="item.label"
></Option>
<Tree key="mytree" :data="data1" ref="mytree" :render="renderContent"></Tree>
</Select>
<TreeSelect
v-model="dep"
:data="list"
@on-change="change"
:disabled="disabled"
:multiple="multiple"
:transfer="true"
/>
</template>
<script>
export default {
......@@ -21,15 +19,8 @@ export default {
return {
dep: "",
list: [],
data1: [],
selectdata: [],
placeholdeinfo: "请选择",
orderSearchForm: {
productId: null, //产品id
productName: "", //产品名称
drawingNo: "", //图号
bomId:null //bomId
}
tempList:[],
placeholdeinfo: "请选择"
};
},
props: {
......@@ -49,108 +40,56 @@ export default {
},
mounted() {},
created() {
this.dep = this.value | "";
this.loadTree();
},
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() {
//打开新增订单窗口加载产品
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;
} 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); //手动选择树节点
}
let params = {
conditions: [
{
fieldName: "title",
fieldValue: name,
conditionalType: "Like"
}
},
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() {
this.list = [];
this.placeholdeinfo = "请选择";
this.resetFields();
this.$emit("on-change", null, this.orderSearchForm);
change(v) {
// console.log(v);
this.dep = v;
var item;
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: {
value: {
handler(v, o) {
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
}
......
......@@ -57,6 +57,7 @@ export default {
res,
0,
u => {
u.value=u.id
u.expand = true;
u.selected = false;
u.checked = false;
......@@ -72,14 +73,14 @@ export default {
renderContent(h, { root, node, data }) {
let type = "md-folder";
return h("span", [
h("Icon", {
props: {
type: type
},
style: {
marginRight: "8px"
}
}),
// h("Icon", {
// props: {
// type: type
// },
// style: {
// marginRight: "8px"
// }
// }),
h(
"span",
{
......@@ -95,17 +96,13 @@ export default {
// console.log(b);
let ids = [];
let productIds = [];
if (b.bomId !== 0) {
ids.push(b.bomId);
}
ids.push(b.id);
productIds.push(b.value);
if (b.children) {
addId(b.children);
function addId(data) {
data.map(u => {
if (u.bomId !== 0) {
ids.push(u.bomId);
}
ids.push(u.id);
productIds.push(u.value);
if (u.children) {
addId(u.children);
......
......@@ -2,13 +2,13 @@
<Form ref="form" :model="entity" :rules="rules" :label-width="90">
<Row>
<Col :span="12">
<FormItem :label="l('name')" prop="materialCode">
<FormItem :label="l('name')" prop="materialId">
<Materiel v-model="entity.materialId" @on-change="change"></Materiel>
</FormItem>
</Col>
<Col :span="12">
<FormItem :label="l('storeTitle')" prop="storeTitle">
<StoreSelect v-model="entity.storeId" ></StoreSelect>
<FormItem :label="l('storeTitle')" prop="storeId">
<StoreSelect v-model="entity.storeId" @on-change="storeChange"></StoreSelect>
</FormItem>
</Col>
<Col :span="12">
......@@ -38,7 +38,7 @@
</Col>
<Col :span="12">
<FormItem :label="l('creator')" prop="creator">
<Input v-model="entity.creator" :disabled="true"></Input>
<User :value="entity.creator" />
</FormItem>
</Col>
<Col :span="24">
......@@ -75,18 +75,40 @@ export default {
total: null,
storeId: null,
storeTitle: "",
minNum: null,
brand: "",
specifications: "",
batch: "",
certificateOfApproval: "",
creator: "",
creator: this.$store.state.userInfo.userId,
unitPrice: null,
originalManufacturer: "",
remark: ""
},
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 {
this.entity.materialId = e.materialId;
this.entity.materialCode = e.mmcode;
},
storeChange(v, item) {
this.entity.storeId = item.id;
this.entity.storeTitle = item.title;
},
l(key) {
key = "stock" + "." + key;
return this.$t(key);
......
......@@ -22,5 +22,8 @@ export default {
},
deletes(params) {
return Api.post(`${resourceUrl}/stock/batchdelete`, params);
}
},
setminnum(params) {
return Api.post(`${resourceUrl}/stock/setminnum`, params);
},
}
......@@ -9,16 +9,11 @@
</a>
</div>
<Content class="content" :class="!showMenu?'con_bord':''">
<DataGrid
:columns="columns"
ref="grid"
:action="action"
:conditions="easySearch"
>
<DataGrid :columns="columns" ref="grid" :action="action" :conditions="easySearch">
<template slot="easySearch">
<Form ref="formInline" :model="easySearch" inline>
<FormItem prop="keys">
<Input placeholder="请输入关键字物料名称/库位名称" v-model="easySearch.keys.value" />
<Input placeholder="请输入物料名称/库位名称" v-model="easySearch.keys.value" v-width="240" />
</FormItem>
<FormItem>
<Button type="primary" @click="search">查询</Button>
......@@ -70,8 +65,40 @@ export default {
easy: 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",
title: this.l("storeTitle"),
......@@ -82,58 +109,54 @@ export default {
{
title: "操作",
key: "action",
width: 140,
width: 280,
align: "center",
render: (h, params) => {
return h("div", { class: "action" }, [
h(
"op",
{
attrs: { oprate: "detail" },
on: { click: () => this.view(params.row.id) }
attrs: {
oprate: "detail",
title: "设置最低库存"
},
on: { click: () => this.setNum(params.row) }
},
"查看"
"设置最低库存"
),
//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) }
attrs: { oprate: "detail" },
on: { click: () => this.view(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: [],
treeInputSearch: "",
ocolumn: [],
treeHeight: "",
tableHeight: "",
ids: [],
orderSearchForm: {
productId: "", //产品id
productName: "", //产品名称
taskType: "", //任务类型
quantity: null, //数量
taskRequire: "", //任务接点要求
demandStartDate: "", //开始时间
demandFinishDate: "", //完成时间
remark: "", //备注
projectNumber: "", //项目号
batchNumber: "", //批次号
urgencyLevel: null //紧急程度
},
list: []
};
},
......@@ -147,35 +170,13 @@ export default {
return (() => {
window.screenHeight = window.innerHeight;
this.treeHeight = window.screenHeight - 150;
})();
};
},
async fetch({ store, params }) {
await store.dispatch("loadDictionary"); // 加载数据字典
},
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;
}
},
computed: {},
methods: {
ok() {
this.$refs.grid.load();
......@@ -230,9 +231,15 @@ export default {
this.showMenu = true;
},
productSearch(id, item, productIds, ids) {
let where = { bomId: { op: "In", value: ids } };
let where = { storeId: { op: "In", value: ids } };
this.$refs.grid.reload(where);
},
setNum(row) {
this.curId = row.id;
this.title = "设置最低库存";
this.detail = () => import("./setNum");
this.modal = true;
},
l(key) {
let vkey = "stock" + "." + key;
return this.$t(vkey) || key;
......@@ -246,7 +253,6 @@ export default {
for (var i = 0; i < res.result.length; i++) {
sumData = sumData.concat(res.result[i]);
}
this.treeData = sumData;
this.data1 = JSON.parse(JSON.stringify(sumData));
} else {
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