Commit f5c6af41 authored by renjintao's avatar renjintao

物料管理

parent 8018f5c3
<template>
<div class="classification">
<div class="classification">
<Layout>
<Sider width="300" v-if="showMenu">
<div class="p-list">
<h3>
<Dropdown @on-click="clickItem">
<a href="javascript:void(0)">
{{downName}}
<Icon type="ios-arrow-down"></Icon>
</a>
<DropdownMenu slot="list">
<DropdownItem
v-for="item in cityList"
:key="item.id"
:name="item.id"
>{{ item.name }}</DropdownItem>
</DropdownMenu>
</Dropdown>
<div class="fr mr10 mt10">
<ButtonGroup class="fr" size="small">
<Button icon="md-add" title="新增顶级" @click="addNew"></Button>
<Button
:icon="expand ? 'md-arrow-dropright' : 'md-arrow-dropdown'"
@click="toggle"
title="展开/合并"
></Button>
<Button icon="md-refresh" title="刷新" @click="loadTree(model8)"></Button>
<Button icon="md-rewind" title="收起" @click="hide"></Button>
</ButtonGroup>
<Sider width="300" v-if="showMenu">
<div class="p-list">
<h3>
<Dropdown @on-click="clickItem">
<a href="javascript:void(0)">
{{downName}}
<Icon type="ios-arrow-down"></Icon>
</a>
<DropdownMenu slot="list">
<DropdownItem v-for="item in cityList" :key="item.id" :name="item.id">{{ item.name }}</DropdownItem>
</DropdownMenu>
</Dropdown>
<div class="fr mr10 mt10">
<ButtonGroup class="fr" size="small">
<Button icon="md-add" title="新增顶级" @click="addNew"></Button>
<Button :icon="expand ? 'md-arrow-dropright' : 'md-arrow-dropdown'" @click="toggle" title="展开/合并"></Button>
<Button icon="md-refresh" title="刷新" @click="loadTree(model8)"></Button>
<Button icon="md-rewind" title="收起" @click="hide"></Button>
</ButtonGroup>
</div>
</h3>
<div class="search">
<Input search placeholder="关键字" v-model="keys" clearable />
</div>
<div class="fg">
<div class="tree">
<Tree :data="data" ref="tree" @on-select-change="change" :render="renderContent"></Tree>
<Dropdown transfer ref="contentMenu" style="display: none;" trigger="click" placement="right-start">
<DropdownMenu slot="list" ref="ppp" style="min-width: 80px;">
<DropdownItem @click.native="add">
<a>添加</a>
</DropdownItem>
<DropdownItem name="edit" @click.native="edit">
<a>修改</a>
</DropdownItem>
<DropdownItem name="del" @click.native="remove">
<a>删除</a>
</DropdownItem>
</DropdownMenu>
</Dropdown>
</div>
</div>
</div>
</h3>
<div class="search">
<Input search placeholder="关键字" v-model="keys" clearable />
</div>
<div class="fg">
<div class="tree">
<Tree :data="data" ref="tree" @on-select-change="change" :render="renderContent"></Tree>
<Dropdown
transfer
ref="contentMenu"
style="display: none;"
trigger="click"
placement="right-start"
>
<DropdownMenu slot="list" ref="ppp" style="min-width: 80px;">
<DropdownItem @click.native="add">
<a>添加</a>
</DropdownItem>
<DropdownItem name="edit" @click.native="edit">
<a>修改</a>
</DropdownItem>
<DropdownItem name="del" @click.native="remove">
<a>删除</a>
</DropdownItem>
</DropdownMenu>
</Dropdown>
</div>
</div>
</Sider>
<div v-if="!showMenu" class="show_menu">
<a class="menu_play fr" @click="showMenuFn" title="展开">
<Icon type="ios-arrow-forward" size="24" />
</a>
</div>
</Sider>
<div v-if="!showMenu" class="show_menu">
<a class="menu_play fr" @click="showMenuFn" title="展开">
<Icon type="ios-arrow-forward" size="24" />
</a>
</div>
<Content :class="!showMenu?'con_bord':''">
<MasterData ref="dataTable" @on-edit="editRow" :root="root" @on-ok="ok" />
</Content>
<Content :class="!showMenu?'con_bord':''">
<MasterData ref="dataTable" @on-edit="editRow" :root="root" @on-ok="ok" />
</Content>
</Layout>
<Modal v-model="modal" :title="title" width="1500" footer-hide :mask-closable="false">
<component
:is="detail"
:eid="curId"
:nodeInfo="nodeInfo"
@on-close="cancel"
@on-ok="ok"
ref="chlidren"
/>
<component :is="detail" :eid="curId" :nodeInfo="nodeInfo" @on-close="cancel" @on-ok="ok" ref="chlidren" />
</Modal>
</div>
</div>
</template>
<script>
import MasterData from "./masterData.vue";
import Api from "./api";
export default {
components: {
MasterData
},
name: "classification",
data() {
return {
model8: "",
root: {
id: 0,
ids: []
},
downName: "请选择类型",
cityList: [],
keys: "",
expand: false,
list: [],
nodeInfo: {
codeRuleId: ""
},
modal: false,
title: "新增",
curId: 0,
detail: null,
showMenu: true,
dataList: []
};
},
async fetch({ store, params }) {
await store.dispatch("loadDictionary"); // 加载数据字典
},
created() {
// this.loadTree();
this.listSlecet();
},
methods: {
clickItem(val) {
this.nodeInfo.codeRuleId = val;
this.model8 = val;
this.loadTree(this.nodeInfo.codeRuleId);
this.cityList.forEach(e => {
if (val == e.id) {
this.downName = e.name;
}
});
this.model8 = val;
},
listSlecet() {
let data = {
conditions: [],
sortBy: "id",
isDesc: false
};
Api.pagedSlecet(data).then(r => {
this.cityList = r.result.items;
this.downName = this.cityList[0].name;
this.model8 = this.cityList[0].id;
this.nodeInfo.codeRuleId = this.cityList[0].id;
this.loadTree(this.nodeInfo.codeRuleId);
});
},
showMenuFn() {
//this.$Message.info("展开左侧树")
this.showMenu = true;
},
ok(row) {
this.loadTree(this.nodeInfo.codeRuleId);
this.modal = false;
this.curId = 0;
// if (row) {
// this.dataList.map((e, index) => {
// if (e.id == row.id) {
// this.$set(this.$refs.dataTable.dataColumns, index, row);
// }
// });
// }
},
addNew() {
if (this.model8) {
this.curId = 0;
this.title = "新增";
this.detail = () => import("./add");
this.modal = true;
this.$refs.chlidren.arr = [];
} else {
this.$Message.error("请先选择类型");
}
components: {
MasterData
},
add() {
this.curId = 0;
this.title = "新增";
this.detail = () => import("./sonAdd");
this.modal = true;
name: "classification",
data() {
return {
model8: "",
root: {
id: 0,
ids: []
},
downName: "请选择类型",
cityList: [],
keys: "",
expand: false,
list: [],
nodeInfo: {
codeRuleId: ""
},
modal: false,
title: "新增",
curId: 0,
detail: null,
showMenu: true,
dataList: []
};
},
editRow(row) {
this.nodeInfo = row;
this.edit();
async fetch({
store,
params
}) {
await store.dispatch("loadDictionary"); // 加载数据字典
},
edit() {
if (this.nodeInfo.upId == 0) {
this.detail = () => import("./edit");
this.$refs.chlidren.arr = [];
} else {
this.detail = () => import("./sonEdit");
}
this.curId = this.nodeInfo.id;
this.title = "编辑";
this.modal = true;
created() {
// this.loadTree();
this.listSlecet();
},
remove() {
// console.log(this.nodeInfo);
if (this.nodeInfo.children.length > 1) {
this.$Message.error("因为有子级,不能直接删除");
} else {
this.$Modal.confirm({
title: "删除",
content: "<p>您确定要删除吗?</p>",
onOk: () => {
Api.delete(this.nodeInfo.id).then(r => {
if (r.success) {
methods: {
clickItem(val) {
this.nodeInfo.codeRuleId = val;
this.model8 = val;
this.loadTree(this.nodeInfo.codeRuleId);
this.cityList.forEach(e => {
if (val == e.id) {
this.downName = e.name;
}
});
this.model8 = val;
},
listSlecet() {
let data = {
conditions: [],
sortBy: "id",
isDesc: false
};
Api.pagedSlecet(data).then(r => {
this.cityList = r.result.items;
this.downName = this.cityList[0].name;
this.model8 = this.cityList[0].id;
this.nodeInfo.codeRuleId = this.cityList[0].id;
this.loadTree(this.nodeInfo.codeRuleId);
this.$Message.success("删除成功");
}
});
},
onCancel: () => {
this.$Message.success("取消删除");
}
});
}
},
cancel() {
this.curId = 0;
this.modal = false;
},
renderContent(h, { root, node, data }) {
return h(
"span",
{
on: {
click: () => {
this.handleSelect(data); //手动选择树节点
},
//右键点击事件
contextmenu: e => {
e.preventDefault();
this.$refs.contentMenu.$refs.reference = event.target;
this.$refs.contentMenu.currentVisible = !this.$refs.contentMenu
.currentVisible;
this.nodeInfo = data;
},
showMenuFn() {
//this.$Message.info("展开左侧树")
this.showMenu = true;
},
ok(row) {
this.loadTree(this.nodeInfo.codeRuleId);
this.modal = false;
this.curId = 0;
// if (row) {
// this.dataList.map((e, index) => {
// if (e.id == row.id) {
// this.$set(this.$refs.dataTable.dataColumns, index, row);
// }
// });
// }
},
addNew() {
if (this.model8) {
this.curId = 0;
this.title = "新增";
this.detail = () => import("./add");
this.modal = true;
this.$refs.chlidren.arr = [];
} else {
this.$Message.error("请先选择类型");
}
}
},
data.title +
"(" +
(data.totalMaterialCount == undefined
? "0"
: data.totalMaterialCount) +
")"
);
},
handleSelect(data) {
// let tableData = [];
// let obj = {};
// let children = 0;
// if (data.upId == 0 && data.children.length > 0) {
// data.children.forEach(e => {
// if (e.children.length > 0) {
// children = 1;
// } else {
// children = 0;
// }
// obj = {
// id: e.id,
// name: e.name,
// code: e.code,
// status: e.status,
// children: children,
// upId: e.upId,
// description: e.description
// };
// tableData.push(obj);
// });
// this.dataList = tableData;
// this.$refs.dataTable.dataColumns = tableData;
// }
},
loadTree(id) {
let data = {
conditions: [
{ fieldName: "codeRuleId", fieldValue: id, conditionalType: "Equal" }
],
sortBy: "code",
isDesc: false
};
Api.list(data).then(r => {
var data = this.$u.toTree(
r.result,
0,
u => {
u.title = u.code + u.name;
u.value = u.id;
u.expand = true;
},
"upId"
);
this.list = this.$u.clone(data);
});
},
toggle() {
if (this.model8) {
this.expand = !this.expand;
} else {
this.$Message.error("请先选择类型");
}
},
change(v, b) {
// console.log(v);
// alert(JSON.stringify(b));
let ids = [];
ids.push(b.id);
if (b.children) {
addId(b.children);
function addId(data) {
data.map(u => {
ids.push(u.id);
if (u.children) {
addId(u.children);
add() {
this.curId = 0;
this.title = "新增";
this.detail = () => import("./sonAdd");
this.modal = true;
},
editRow(row) {
this.nodeInfo = row;
this.edit();
},
edit() {
if (this.nodeInfo.upId == 0) {
this.detail = () => import("./edit");
this.$refs.chlidren.arr = [];
} else {
this.detail = () => import("./sonEdit");
}
this.curId = this.nodeInfo.id;
this.title = "编辑";
this.modal = true;
},
remove() {
// console.log(this.nodeInfo);
if (this.nodeInfo.children.length > 1) {
this.$Message.error("因为有子级,不能直接删除");
} else {
this.$Modal.confirm({
title: "删除",
content: "<p>您确定要删除吗?</p>",
onOk: () => {
Api.delete(this.nodeInfo.id).then(r => {
if (r.success) {
this.loadTree(this.nodeInfo.codeRuleId);
this.$Message.success("删除成功");
}
});
},
onCancel: () => {
this.$Message.success("取消删除");
}
});
}
},
cancel() {
this.curId = 0;
this.modal = false;
},
renderContent(h, {
root,
node,
data
}) {
return h(
"span", {
on: {
click: () => {
this.handleSelect(data); //手动选择树节点
},
//右键点击事件
contextmenu: e => {
e.preventDefault();
this.$refs.contentMenu.$refs.reference = event.target;
this.$refs.contentMenu.currentVisible = !this.$refs.contentMenu
.currentVisible;
this.nodeInfo = data;
}
}
},
data.title +
"(" +
(data.totalMaterialCount == undefined ?
"0" :
data.totalMaterialCount) +
")"
);
},
handleSelect(data) {
// let tableData = [];
// let obj = {};
// let children = 0;
// if (data.upId == 0 && data.children.length > 0) {
// data.children.forEach(e => {
// if (e.children.length > 0) {
// children = 1;
// } else {
// children = 0;
// }
// obj = {
// id: e.id,
// name: e.name,
// code: e.code,
// status: e.status,
// children: children,
// upId: e.upId,
// description: e.description
// };
// tableData.push(obj);
// });
// this.dataList = tableData;
// this.$refs.dataTable.dataColumns = tableData;
// }
},
loadTree(id) {
let data = {
conditions: [{
fieldName: "codeRuleId",
fieldValue: id,
conditionalType: "Equal"
}],
sortBy: "code",
isDesc: false
};
Api.list(data).then(r => {
var data = this.$u.toTree(
r.result,
0,
u => {
u.title = u.code + u.name;
u.value = u.id;
u.expand = true;
},
"upId"
);
this.list = this.$u.clone(data);
});
},
toggle() {
if (this.model8) {
this.expand = !this.expand;
} else {
this.$Message.error("请先选择类型");
}
},
change(v, b) {
// console.log(v);
// alert(JSON.stringify(b));
let ids = [];
ids.push(b.id);
if (b.children) {
addId(b.children);
function addId(data) {
data.map(u => {
ids.push(u.id);
if (u.children) {
addId(u.children);
}
});
}
}
});
this.root.ids = ids;
this.root.id = b.id;
// this.root.codeRuleId=b.codeRuleId
},
hide() {
this.showMenu = false;
}
}
this.root.ids = ids;
this.root.id = b.id;
// this.root.codeRuleId=b.codeRuleId
},
hide() {
this.showMenu = false;
}
},
computed: {
data() {
let items = this.$u.clone(this.list);
let expand = this.expand;
let result = [];
search(this.keys, items);
function search(keys, data) {
data.map(u => {
if (keys.length < u.title) {
u.expand = expand;
result.push(u);
} else {
u.expand = expand;
if (u.title.indexOf(keys) > -1) {
result.push(u);
} else if (u.children) {
search(keys, u.children);
computed: {
data() {
let items = this.$u.clone(this.list);
let expand = this.expand;
let result = [];
search(this.keys, items);
function search(keys, data) {
data.map(u => {
if (keys.length < u.title) {
u.expand = expand;
result.push(u);
} else {
u.expand = expand;
if (u.title.indexOf(keys) > -1) {
result.push(u);
} else if (u.children) {
search(keys, u.children);
}
}
});
}
}
});
}
return result;
return result;
}
}
}
};
</script>
<style lang="less" >
<style lang="less">
.classification {
font-family: Microsoft YaHei;
font-family: Microsoft YaHei;
.ivu-layout-sider {
background: rgba(255, 255, 255, 1);
margin-right: 10px;
box-shadow: 0px 2px 10px rgba(0, 0, 0, 0.15);
height: 87vh;
.ivu-layout-sider {
background: rgba(255, 255, 255, 1);
margin-right: 10px;
box-shadow: 0px 2px 10px rgba(0, 0, 0, 0.15);
height: 87vh;
h4 {
height: 30px;
line-height: 30px;
background: #eee;
padding-left: 10px;
}
.p-list {
h3 {
height: 50px;
font-size: 14px;
font-family: Microsoft YaHei;
font-weight: bold;
line-height: 50px;
color: rgba(81, 90, 110, 1);
background: rgba(245, 246, 250, 1);
opacity: 1;
padding-left: 10px;
}
.search {
height: 50px;
padding: 5px 10px;
}
.fg {
flex: none;
height: 100%;
overflow: auto;
padding-left: 10px;
}
.tree {
height: calc(100vh - 215px);
overflow: auto;
}
h4 {
height: 30px;
line-height: 30px;
background: #eee;
padding-left: 10px;
}
.p-list {
h3 {
height: 50px;
font-size: 14px;
font-family: Microsoft YaHei;
font-weight: bold;
line-height: 50px;
color: rgba(81, 90, 110, 1);
background: rgba(245, 246, 250, 1);
opacity: 1;
padding-left: 10px;
}
.search {
height: 50px;
padding: 5px 10px;
}
.fg {
flex: none;
height: 100%;
overflow: auto;
padding-left: 10px;
}
.tree {
height: calc(100vh - 215px);
overflow: auto;
}
}
}
}
.show_menu {
width: 30px;
height: 30px;
position: fixed;
top: 100px;
left: 0;
z-index: 9;
.menu_play {
width: 30px;
height: 30px;
line-height: 34px;
font-size: 14px;
text-align: center;
color: #515a6e;
border-top-right-radius: 5px;
border-bottom-right-radius: 5px;
background: #ffffff;
box-shadow: #ccc 2px 2px 4px 1px;
.show_menu {
width: 30px;
height: 30px;
position: fixed;
top: 100px;
left: 0;
z-index: 9;
.menu_play {
width: 30px;
height: 30px;
line-height: 34px;
font-size: 14px;
text-align: center;
color: #515a6e;
border-top-right-radius: 5px;
border-bottom-right-radius: 5px;
background: #ffffff;
box-shadow: #ccc 2px 2px 4px 1px;
}
.menu_play:hover {
background-color: #2d8cf0;
color: white;
}
}
.menu_play:hover {
background-color: #2d8cf0;
color: white;
.ivu-layout-content {
// margin-left: 5px;
background: rgba(255, 255, 255, 1);
box-shadow: 0px 2px 10px rgba(0, 0, 0, 0.15);
overflow: auto;
padding: 10px;
height: 87vh;
overflow-y: hidden;
}
}
.ivu-layout-content {
// margin-left: 5px;
background: rgba(255, 255, 255, 1);
box-shadow: 0px 2px 10px rgba(0, 0, 0, 0.15);
overflow: auto;
padding: 10px;
height: 87vh;
overflow-y: hidden;
}
}
</style>
\ No newline at end of file
</style>
<template>
<div class="master-data">
<div class="master-data">
<!-- <Table border :columns="columns" :data="dataColumns" :height="tableHeight"></Table> -->
<DataGrid
:columns="columns"
ref="grid"
:conditions="easySearch"
:action="action"
:high="false"
:height="tableHeight"
>
<template slot="easySearch">
<Form ref="formInline" :model="easySearch" inline>
<FormItem prop="keys">
<Input placeholder="请输入编码/名称" v-width="200" v-model="easySearch.keys.value" clearable />
</FormItem>
<FormItem>
<Button type="primary" @click="search">查询</Button>
</FormItem>
</Form>
</template>
<DataGrid :columns="columns" ref="grid" :conditions="easySearch" :action="action" :high="false" :height="tableHeight">
<template slot="easySearch">
<Form ref="formInline" :model="easySearch" inline>
<FormItem prop="keys">
<Input placeholder="请输入编码/名称" v-width="200" v-model="easySearch.keys.value" clearable />
</FormItem>
<FormItem>
<Button type="primary" @click="search">查询</Button>
</FormItem>
</Form>
</template>
</DataGrid>
</div>
</div>
</template>
<script>
import Api from "./api";
export default {
name: "masterData",
props: ["root"],
data() {
return {
action: Api.index,
tableHeight: "",
dataColumns: [],
easySearch: {
keys: { op: "code,name", value: null },
id: { op: "In", value: "" }
},
columns: [
// {
// key: "index",
// title: "#",
// align: "left",
// width: 60
// },
{
key: "code",
title: "编码",
align: "left"
},
{
key: "name",
title: "名称",
align: "left"
},
{
key: "status",
title: "状态",
align: "left",
code: "materail.category.status"
},
{
key: "description",
title: "描述",
align: "left"
},
{
title: "操作",
key: "action",
width: 260,
align: "left",
render: (h, params) => {
return h("div", { class: "action" }, [
h(
"op",
name: "masterData",
props: ["root"],
data() {
return {
action: Api.index,
tableHeight: "",
dataColumns: [],
easySearch: {
keys: {
op: "code,name",
value: null
},
id: {
op: "In",
value: ""
}
},
columns: [
// {
// key: "index",
// title: "#",
// align: "left",
// width: 60
// },
{
attrs: { oprate: "edit" },
on: { click: () => this.edit(params.row) }
key: "code",
title: "编码",
align: "left"
},
"编辑"
),
h(
"op",
{
attrs: { oprate: "delete" },
on: { click: () => this.remove(params.row.id) }
key: "name",
title: "名称",
align: "left"
},
"删除"
)
]);
}
}
]
};
},
async fetch({ store, params }) {
await store.dispatch("loadDictionary"); // 加载数据字典
},
created() {
this.tableHeight = window.innerHeight - 220;
},
mounted() {
window.onresize = () => {
///浏览器窗口大小变化
return (() => {
window.screenHeight = window.innerHeight;
{
key: "status",
title: "状态",
align: "left",
code: "materail.category.status"
},
{
key: "description",
title: "描述",
align: "left"
},
{
title: "操作",
key: "action",
width: 260,
align: "left",
render: (h, params) => {
return h("div", {
class: "action"
}, [
h(
"op", {
attrs: {
oprate: "edit"
},
on: {
click: () => this.edit(params.row)
}
},
"编辑"
),
h(
"op", {
attrs: {
oprate: "delete"
},
on: {
click: () => this.remove(params.row.id)
}
},
"删除"
)
]);
}
}
]
};
},
async fetch({
store,
params
}) {
await store.dispatch("loadDictionary"); // 加载数据字典
},
created() {
this.tableHeight = window.innerHeight - 220;
})();
};
},
methods: {
search() {
// alert(JSON.stringify(this.easySearch));
console.log(this.easySearch);
this.$refs.grid.reload(this.easySearch);
},
edit(row) {
this.$emit("on-edit", row);
mounted() {
window.onresize = () => {
///浏览器窗口大小变化
return (() => {
window.screenHeight = window.innerHeight;
this.tableHeight = window.innerHeight - 220;
})();
};
},
remove(id) {
Api.delete(id).then(r => {
if (r.success) {
this.$refs.grid.reload(this.easySearch);
this.$Message.success("删除成功");
methods: {
search() {
// alert(JSON.stringify(this.easySearch));
console.log(this.easySearch);
this.$refs.grid.reload(this.easySearch);
},
edit(row) {
this.$emit("on-edit", row);
},
remove(id) {
Api.delete(id).then(r => {
if (r.success) {
this.$refs.grid.reload(this.easySearch);
this.$Message.success("删除成功");
}
});
}
});
}
},
watch: {
root: {
handler(newName, oldName) {
if (newName.id) {
this.easySearch.id.value = newName.ids;
this.$refs.grid.reload(this.easySearch);
} else {
this.easySearch.id.value = "-1";
},
watch: {
root: {
handler(newName, oldName) {
if (newName.id) {
this.easySearch.id.value = newName.ids;
this.$refs.grid.reload(this.easySearch);
} else {
this.easySearch.id.value = "-1";
}
},
immediate: true,
deep: true
}
},
immediate: true,
deep: true
}
}
};
</script>
<style lang="less" scoped>
.spare-parts {
width: 100%;
height: 100%;
width: 100%;
height: 100%;
}
</style>
\ No newline at end of file
</style>
<template>
<div class="classification">
<div class="classification">
<Layout>
<Sider width="300" v-if="showMenu">
<div class="p-list">
<h3>
<Dropdown @on-click="clickItem">
<a href="javascript:void(0)">
{{downName}}
<Icon type="ios-arrow-down"></Icon>
</a>
<DropdownMenu slot="list">
<DropdownItem
v-for="item in cityList"
:key="item.id"
:name="item.id"
>{{ item.name }}</DropdownItem>
</DropdownMenu>
</Dropdown>
<div class="fr mr10 mt10">
<ButtonGroup class="fr ddi" size="small">
<Button
:icon="expand ? 'md-arrow-dropright' : 'md-arrow-dropdown'"
@click="toggle"
title="展开/合并"
></Button>
<Button icon="md-refresh" title="刷新" @click="loadTree(model8)"></Button>
<Button icon="md-rewind" title="收起" @click="hide"></Button>
</ButtonGroup>
<Sider width="300" v-if="showMenu">
<div class="p-list">
<h3>
<Dropdown @on-click="clickItem">
<a href="javascript:void(0)">
{{downName}}
<Icon type="ios-arrow-down"></Icon>
</a>
<DropdownMenu slot="list">
<DropdownItem v-for="item in cityList" :key="item.id" :name="item.id">{{ item.name }}</DropdownItem>
</DropdownMenu>
</Dropdown>
<div class="fr mr10 mt10">
<ButtonGroup class="fr ddi" size="small">
<Button :icon="expand ? 'md-arrow-dropright' : 'md-arrow-dropdown'" @click="toggle" title="展开/合并"></Button>
<Button icon="md-refresh" title="刷新" @click="loadTree(model8)"></Button>
<Button icon="md-rewind" title="收起" @click="hide"></Button>
</ButtonGroup>
</div>
</h3>
<div class="search">
<Input search placeholder="关键字" v-model="keys" clearable />
</div>
<div class="fg">
<div class="tree">
<Tree :data="data" ref="tree" @on-select-change="change" :render="renderContent"></Tree>
</div>
</div>
</div>
</h3>
<div class="search">
<Input search placeholder="关键字" v-model="keys" clearable />
</div>
<div class="fg">
<div class="tree">
<Tree :data="data" ref="tree" @on-select-change="change" :render="renderContent"></Tree>
</div>
</div>
</Sider>
<div v-if="!showMenu" class="show_menu">
<a class="menu_play fr" @click="showMenuFn" title="展开">
<Icon type="ios-arrow-forward" size="24" />
</a>
</div>
</Sider>
<div v-if="!showMenu" class="show_menu">
<a class="menu_play fr" @click="showMenuFn" title="展开">
<Icon type="ios-arrow-forward" size="24" />
</a>
</div>
<Content :class="!showMenu?'con_bord':''">
<MasterData ref="dataTable" :nodeInfo="nodeInfo" @on-ok="ok" />
</Content>
<Content :class="!showMenu?'con_bord':''">
<MasterData ref="dataTable" :nodeInfo="nodeInfo" @on-ok="ok" />
</Content>
</Layout>
</div>
</div>
</template>
<script>
import MasterData from "./masterData.vue";
import Api from "./api";
export default {
components: {
MasterData,
},
name: "masterData",
data() {
return {
model8: "",
type: "",
keys: "",
cityList: [],
expand: false,
list: [],
nodeInfo: {
categoryId: 0,
rootCategoryId: 0,
ids: [],
addChange: true,
codeRuleId: 0,
},
downName: "请选择类型",
modal: false,
title: "新增",
curId: 0,
detail: null,
showMenu: true,
dataList: [],
codeRuleId: "",
};
},
async fetch({ store, params }) {
await store.dispatch("loadDictionary"); // 加载数据字典
},
created() {
// this.loadTree();
this.listSlecet();
},
methods: {
clickItem(val) {
this.codeRuleId = val;
this.nodeInfo.codeRuleId = val;
this.model8 = val;
this.loadTree(this.codeRuleId);
this.cityList.forEach((e) => {
if (val == e.id) {
this.downName = e.name;
}
});
},
listSlecet() {
let data = {
conditions: [],
sortBy: "id",
isDesc: false,
};
Api.pagedSlecet(data).then((r) => {
this.cityList = r.result.items;
this.downName = this.cityList[0].name;
this.model8 = this.cityList[0].id;
this.nodeInfo.codeRuleId = this.cityList[0].id;
this.loadTree(this.nodeInfo.codeRuleId);
});
components: {
MasterData,
},
showMenuFn() {
//this.$Message.info("展开左侧树")
this.showMenu = true;
name: "masterData",
data() {
return {
model8: "",
type: "",
keys: "",
cityList: [],
expand: false,
list: [],
nodeInfo: {
categoryId: 0,
rootCategoryId: 0,
rootCategoryName: "",
ids: [],
addChange: true,
codeRuleId: 0,
},
downName: "请选择类型",
modal: false,
title: "新增",
curId: 0,
detail: null,
showMenu: true,
dataList: [],
codeRuleId: "",
rootCategoryId: null,
categoryId: null,
};
},
ok(row) {
this.loadTree(this.codeRuleId);
// this.modal = false;
// this.curId = 0;
// if (row) {
// this.dataList.map((e, index) => {
// if (e.id == row.id) {
// this.$set(this.$refs.dataTable.dataColumns, index, row);
// }
// });
// }
async fetch({
store,
params
}) {
await store.dispatch("loadDictionary"); // 加载数据字典
},
cancel() {
this.curId = 0;
this.modal = false;
created() {
// this.loadTree();
this.listSlecet();
},
renderContent(h, { root, node, data }) {
return h(
"span",
{
on: {
click: () => {
this.handleSelect(root, data); //手动选择树节点
},
},
methods: {
clickItem(val) {
this.codeRuleId = val;
this.nodeInfo.codeRuleId = val;
this.model8 = val;
this.loadTree(this.codeRuleId);
this.cityList.forEach((e) => {
if (val == e.id) {
this.downName = e.name;
}
});
},
data.title +
"(" +
(data.totalMaterialCount == undefined
? "0"
: data.totalMaterialCount) +
")"
);
},
handleSelect(root, data) {
let pid = null; //定义最顶级id
let upId = data.upId;
let roots = root;
function addId(roots, upId) {
roots.map((u) => {
if (u.node.id == upId) {
if (u.node.upId == 0) {
pid = u.node.id;
listSlecet() {
let data = {
conditions: [],
sortBy: "id",
isDesc: false,
};
Api.pagedSlecet(data).then((r) => {
this.cityList = r.result.items;
this.downName = this.cityList[0].name;
this.model8 = this.cityList[0].id;
this.nodeInfo.codeRuleId = this.cityList[0].id;
this.loadTree(this.nodeInfo.codeRuleId);
});
},
showMenuFn() {
//this.$Message.info("展开左侧树")
this.showMenu = true;
},
ok(row) {
this.loadTree(this.codeRuleId);
// this.modal = false;
// this.curId = 0;
// if (row) {
// this.dataList.map((e, index) => {
// if (e.id == row.id) {
// this.$set(this.$refs.dataTable.dataColumns, index, row);
// }
// });
// }
},
cancel() {
this.curId = 0;
this.modal = false;
},
renderContent(h, {
root,
node,
data
}) {
return h(
"span", {
on: {
click: () => {
this.handleSelect(root, data); //手动选择树节点
},
},
},
data.title +
"(" +
(data.totalMaterialCount == undefined ?
"0" :
data.totalMaterialCount) +
")"
);
},
handleSelect(root, data) {
let pid = -1; //定义最顶级id
var pname = "";
var upId = data.upId;
let roots = root;
function addId(roots, upId) {
roots.map((u) => {
if (u.node.id == upId) {
if (u.node.upId == 0) {
pid = u.node.id;
pname = u.node.name;
} else {
upId = u.node.upId;
addId(roots, upId);
}
}
});
}
addId(roots, upId);
this.nodeInfo.categoryId = data.id;
this.nodeInfo.rootCategoryName = data.name;
if (pid == -1) {
this.nodeInfo.rootCategoryId = data.id;
this.nodeInfo.rootCategoryName = data.name;
} else {
upId = u.node.upId;
addId(roots, upId);
this.nodeInfo.rootCategoryId = pid;
this.nodeInfo.rootCategoryName = pname
}
}
});
}
addId(roots, upId);
this.nodeInfo.categoryId = data.id;
if (pid == null) {
this.nodeInfo.rootCategoryId = data.id;
} else {
this.nodeInfo.rootCategoryId = pid;
}
},
loadTree(id) {
let data = {
conditions: [
{ fieldName: "codeRuleId", fieldValue: id, conditionalType: "Equal" },
],
sortBy: "code",
isDesc: false,
};
Api.list(data).then((r) => {
var data = this.$u.toTree(
r.result,
0,
(u) => {
u.title = u.code + u.name;
u.value = u.id;
u.expand = true;
},
"upId"
);
this.list = this.$u.clone(data);
});
},
toggle() {
if (this.model8) {
this.expand = !this.expand;
} else {
this.$Message.error("请先选择类型");
}
},
change(v, b) {
if (b.level < b.ruleLevel && b.children.length > 0) {
this.nodeInfo.addChange = false;
} else {
this.nodeInfo.addChange = true;
}
let ids = [];
ids.push(b.value);
if (b.children) {
addId(b.children);
function addId(data) {
data.map((u) => {
ids.push(u.value);
if (u.children) {
addId(u.children);
},
loadTree(id) {
let data = {
conditions: [{
fieldName: "codeRuleId",
fieldValue: id,
conditionalType: "Equal"
}, ],
sortBy: "code",
isDesc: false,
};
Api.list(data).then((r) => {
var data = this.$u.toTree(
r.result,
0,
(u) => {
u.title = u.code + u.name;
u.value = u.id;
u.expand = true;
},
"upId"
);
this.list = this.$u.clone(data);
});
},
toggle() {
if (this.model8) {
this.expand = !this.expand;
} else {
this.$Message.error("请先选择类型");
}
});
}
}
this.nodeInfo.ids = ids;
},
hide() {
this.showMenu = false;
},
change(v, b) {
if (b.level < b.ruleLevel && b.children.length > 0) {
this.nodeInfo.addChange = false;
} else {
this.nodeInfo.addChange = true;
}
let ids = [];
ids.push(b.value);
if (b.children) {
addId(b.children);
function addId(data) {
data.map((u) => {
ids.push(u.value);
if (u.children) {
addId(u.children);
}
});
}
}
this.nodeInfo.ids = ids;
},
hide() {
this.showMenu = false;
},
},
},
computed: {
data() {
let items = this.$u.clone(this.list);
let expand = this.expand;
let result = [];
search(this.keys, items);
function search(keys, data) {
data.map((u) => {
if (keys.length < u.title) {
u.expand = expand;
result.push(u);
} else {
u.expand = expand;
if (u.title.indexOf(keys) > -1) {
result.push(u);
} else if (u.children) {
search(keys, u.children);
computed: {
data() {
let items = this.$u.clone(this.list);
let expand = this.expand;
let result = [];
search(this.keys, items);
function search(keys, data) {
data.map((u) => {
if (keys.length < u.title) {
u.expand = expand;
result.push(u);
} else {
u.expand = expand;
if (u.title.indexOf(keys) > -1) {
result.push(u);
} else if (u.children) {
search(keys, u.children);
}
}
});
}
}
});
}
return result;
return result;
},
},
},
};
</script>
<style lang="less" >
<style lang="less">
.classification {
font-family: Microsoft YaHei;
font-family: Microsoft YaHei;
.ivu-layout-sider {
background: rgba(255, 255, 255, 1);
margin-right: 10px;
box-shadow: 0px 2px 10px rgba(0, 0, 0, 0.15);
height: 88vh;
.ivu-layout-sider {
background: rgba(255, 255, 255, 1);
margin-right: 10px;
box-shadow: 0px 2px 10px rgba(0, 0, 0, 0.15);
height: 88vh;
h4 {
height: 30px;
line-height: 30px;
background: #eee;
padding-left: 10px;
}
.p-list {
h3 {
height: 50px;
font-size: 14px;
font-family: Microsoft YaHei;
font-weight: bold;
line-height: 50px;
color: rgba(81, 90, 110, 1);
background: rgba(245, 246, 250, 1);
opacity: 1;
padding-left: 10px;
}
.search {
height: 50px;
padding: 5px 10px;
}
.fg {
flex: none;
height: 100%;
overflow: auto;
padding-left: 10px;
}
.tree {
height: calc(100vh - 215px);
overflow: auto;
}
h4 {
height: 30px;
line-height: 30px;
background: #eee;
padding-left: 10px;
}
.p-list {
h3 {
height: 50px;
font-size: 14px;
font-family: Microsoft YaHei;
font-weight: bold;
line-height: 50px;
color: rgba(81, 90, 110, 1);
background: rgba(245, 246, 250, 1);
opacity: 1;
padding-left: 10px;
}
.search {
height: 50px;
padding: 5px 10px;
}
.fg {
flex: none;
height: 100%;
overflow: auto;
padding-left: 10px;
}
.tree {
height: calc(100vh - 215px);
overflow: auto;
}
}
}
}
.show_menu {
width: 30px;
height: 30px;
position: fixed;
top: 100px;
left: 0;
z-index: 9;
.menu_play {
width: 30px;
height: 30px;
line-height: 34px;
font-size: 14px;
text-align: center;
color: #515a6e;
border-top-right-radius: 5px;
border-bottom-right-radius: 5px;
background: #ffffff;
box-shadow: #ccc 2px 2px 4px 1px;
.show_menu {
width: 30px;
height: 30px;
position: fixed;
top: 100px;
left: 0;
z-index: 9;
.menu_play {
width: 30px;
height: 30px;
line-height: 34px;
font-size: 14px;
text-align: center;
color: #515a6e;
border-top-right-radius: 5px;
border-bottom-right-radius: 5px;
background: #ffffff;
box-shadow: #ccc 2px 2px 4px 1px;
}
.menu_play:hover {
background-color: #2d8cf0;
color: white;
}
}
.menu_play:hover {
background-color: #2d8cf0;
color: white;
.ivu-layout-content {
// margin-left: 5px;
background: rgba(255, 255, 255, 1);
box-shadow: 0px 2px 10px rgba(0, 0, 0, 0.15);
overflow: auto;
padding: 10px;
height: 88vh;
overflow-y: hidden;
}
}
.ivu-layout-content {
// margin-left: 5px;
background: rgba(255, 255, 255, 1);
box-shadow: 0px 2px 10px rgba(0, 0, 0, 0.15);
overflow: auto;
padding: 10px;
height: 88vh;
overflow-y: hidden;
}
}
</style>
\ No newline at end of file
</style>
<template>
<div class="master-data">
<DataGrid
:columns="cols"
ref="grid"
:conditions="easySearch"
:action="action"
:initsearch="sets"
:high="false"
:format="formatFun"
:height="tableHeight"
@on-selection-change="onSelect"
>
<template slot="easySearch">
<Form ref="formInline" :model="easySearch" inline>
<FormItem prop="keys">
<Input
placeholder="请输入编码/名称/状态"
v-width="200"
v-model="easySearch.keys.value"
clearable
/>
</FormItem>
<FormItem>
<Button type="primary" @click="search">查询</Button>
</FormItem>
</Form>
</template>
<div class="master-data">
<DataGrid :columns="cols" ref="grid" :conditions="easySearch" :action="action" :initsearch="sets" :high="false" :format="formatFun" :height="tableHeight" @on-selection-change="onSelect" :exportTitle="exportTitle">
<template slot="easySearch">
<Form ref="formInline" :model="easySearch" inline>
<FormItem prop="keys">
<Input placeholder="请输入编码/名称/状态" v-width="200" v-model="easySearch.keys.value" clearable />
</FormItem>
<FormItem>
<Button type="primary" @click="search">查询</Button>
</FormItem>
</Form>
</template>
<template slot="buttons">
<Button type="primary" @click="add">新增</Button>
</template>
<template slot="batch">
<Button type="primary" @click="modalSchedule">批量送审</Button>
</template>
<template slot="buttons">
<Button type="primary" @click="add">新增</Button>
<Button @click="openModalIm">导入</Button>
</template>
<template slot="batch">
<Button type="primary" @click="modalSchedule">批量送审</Button>
</template>
</DataGrid>
<Modal
v-model="modal"
:title="title"
width="1000"
footer-hide
:mask-closable="false"
:fullscreen="fullscreen"
>
<component
:is="detail"
:eid="curId"
:rootCategoryId="rootCategoryId"
:rowsTable="rowsTable"
:nodeInfo="nodeInfo"
@on-close="cancel"
@on-cancel="cancel"
@on-ok="ok"
ref="chlidren"
/>
<Modal v-model="modal" :title="title" width="1000" footer-hide :mask-closable="false" :fullscreen="fullscreen">
<component :is="detail" :eid="curId" :rootCategoryId="rootCategoryId" :rowsTable="rowsTable" :nodeInfo="nodeInfo" @on-close="cancel" @on-cancel="cancel" @on-ok="ok" ref="chlidren" />
</Modal>
</div>
<ImportExcel ref="importExcel" @on-get-data="getData" :columns="cols" :open="ModalIm" @on-cancel="ModalImCancel" @on-ok="ok" />
</div>
</template>
<script>
import Api from "./api";
// import Search from "./search";
export default {
name: "masterData",
components: {
// Search
},
props: ["nodeInfo"],
data() {
return {
action: Api.index,
tableHeight: "",
modal: false,
title: "新增",
curId: 0,
rootCategoryId: 0,
selectRows: [],
rowsTable: [],
fullscreen: false,
detail: null,
sets: v => {
v.categoryId = this.nodeInfo.categoryId;
v.rootCategoryId = this.nodeInfo.rootCategoryId;
},
easySearch: {
keys: { op: "code,name", value: null },
categoryId: {
op: "In",
value: this.nodeInfo.ids
}
},
columns: [
{
type: "selection",
width: 70,
align: "center"
},
{
key: "code",
title: "编码",
align: "left",
render: (h, params) => {
return h(
"a",
{
props: {},
on: {
click: () => this.details(params.row)
name: "masterData",
components: {
// Search
},
props: ["nodeInfo"],
data() {
return {
action: Api.index,
tableHeight: "",
modal: false,
title: "新增",
curId: 0,
rootCategoryId: 0,
selectRows: [],
rowsTable: [],
fullscreen: false,
detail: null,
sets: v => {
v.categoryId = this.nodeInfo.categoryId;
v.rootCategoryId = this.nodeInfo.rootCategoryId;
},
easySearch: {
keys: {
op: "code,name",
value: null
},
categoryId: {
op: "In",
value: this.nodeInfo.ids
}
},
!params.row.code ? "未分配" : params.row.code
);
}
},
{
key: "name",
title: "名称",
align: "left"
},
{
key: "status",
title: "状态",
align: "left",
render: (h, params) => {
return h("state", {
props: {
code: "material.main.status",
type: "text",
value: params.row.status + ""
}
});
}
},
{
key: "version",
title: "版本",
align: "left",
code: "material.main.version"
},
{
key: "drawing",
title: "图号",
align: "left"
},
{
key: "creationTime",
title: "创建时间",
hide: true,
align: "left",
type: "date"
},
{
key: "creatorUserId",
title: "创建人",
hide: true,
align: "left",
type: "user"
},
{
title: "操作",
key: "action",
width: 150,
align: "left",
render: (h, params) => {
return h("div", { class: "action" }, [
h(
"op",
},
columns: [{
type: "selection",
width: 70,
align: "center"
},
{
attrs: { oprate: "edit" },
on: { click: () => this.edit(params.row) }
key: "code",
title: "编码",
align: "left",
render: (h, params) => {
return h(
"a", {
props: {},
on: {
click: () => this.details(params.row)
}
},
!params.row.code ? "未分配" : params.row.code
);
}
},
"编辑"
),
h(
"op",
{
attrs: { oprate: "delete" },
on: { click: () => this.remove(params.row.id) }
key: "name",
title: "名称",
align: "left"
},
params.row.status == 3 ? "" : "删除"
),
h(
"op",
{
attrs: { oprate: "edit" },
on: { click: () => this.send(params.row) }
key: "status",
title: "状态",
align: "center",
code: "material.main.status",
},
(params.row.status == 0 || params.row.status == 1) &&
this.status == 0
? "送审"
: ""
)
]);
}
}
], //基础咧
cols: [], //
status: null
};
},
async fetch({ store, params }) {
await store.dispatch("loadDictionary"); // 加载数据字典
},
created() {
this.tableHeight = window.innerHeight - 220;
if (this.nodeInfo.rootCategoryId == 0) {
this.cols = this.columns;
} else {
this.initCols();
}
Api.getbyid({
id: "b6303ddc-8b5e-40a3-a51b-294657d1d913"
}).then(r => {
this.status = r.result.status; //status为0的话为启用,有送审,为1的话,流程是禁用的,没有送审按钮
this.nodeInfo.status = this.status;
});
},
mounted() {
window.onresize = () => {
///浏览器窗口大小变化
return (() => {
window.screenHeight = window.innerHeight;
{
key: "version",
title: "版本",
align: "left",
code: "material.main.version"
},
{
key: "drawing",
title: "图号",
align: "left"
},
{
key: "creationTime",
title: "创建时间",
hide: true,
align: "left",
type: "date"
},
{
key: "creatorUserId",
title: "创建人",
hide: true,
align: "left",
type: "user"
},
{
title: "操作",
key: "action",
width: 150,
align: "left",
render: (h, params) => {
return h("div", {
class: "action"
}, [
h(
"op", {
attrs: {
oprate: "edit"
},
on: {
click: () => this.edit(params.row)
}
},
"编辑"
),
h(
"op", {
attrs: {
oprate: "delete"
},
on: {
click: () => this.remove(params.row.id)
}
},
params.row.status == 3 ? "" : "删除"
),
h(
"op", {
attrs: {
oprate: "edit"
},
on: {
click: () => this.send(params.row)
}
},
(params.row.status == 0 || params.row.status == 1) &&
this.status == 0 ?
"送审" :
""
)
]);
}
}
], //基础咧
cols: [], //
status: null,
ModalIm: false,
addCol: [],
exportTitle: '物料管理',
};
},
async fetch({
store,
params
}) {
await store.dispatch("loadDictionary"); // 加载数据字典
},
created() {
this.tableHeight = window.innerHeight - 220;
})();
};
},
methods: {
//格式化原始数据
formatFun(data) {
data.map(e => {
if (e.status == 0) {
e._disabled = false;
if (this.nodeInfo.rootCategoryId == 0) {
this.cols = this.columns;
} else {
e._disabled = true;
this.initCols();
}
});
return data;
},
onSelect(a, b) {
// console.log(a);
// console.log(b);
//批量选择
this.rootCategoryId = a[0].rootCategoryId;
this.selectRows = a;
Api.getbyid({
id: "b6303ddc-8b5e-40a3-a51b-294657d1d913"
}).then(r => {
this.status = r.result.status; //status为0的话为启用,有送审,为1的话,流程是禁用的,没有送审按钮
this.nodeInfo.status = this.status;
});
},
modalSchedule() {
this.fullscreen = true;
this.rowsTable = this.selectRows;
this.title = "物料送审";
this.curId = 0;
this.detail = () => import("./submit");
this.modal = true;
mounted() {
window.onresize = () => {
///浏览器窗口大小变化
return (() => {
window.screenHeight = window.innerHeight;
this.tableHeight = window.innerHeight - 220;
})();
};
},
search() {
this.$refs.grid.reload(this.easySearch);
},
initCols(delay) {
let conditions = [
{
conditionalType: "Equal",
fieldName: "categoryId",
fieldValue: this.nodeInfo.rootCategoryId
}
];
methods: {
//格式化原始数据
formatFun(data) {
data.map(e => {
if (e.status == 0) {
e._disabled = false;
} else {
e._disabled = true;
}
});
return data;
},
onSelect(a, b) {
// console.log(a);
// console.log(b);
//批量选择
this.rootCategoryId = a[0].rootCategoryId;
this.selectRows = a;
},
modalSchedule() {
this.fullscreen = true;
this.rowsTable = this.selectRows;
this.title = "物料送审";
this.curId = 0;
this.detail = () => import("./submit");
this.modal = true;
},
search() {
this.$refs.grid.reload(this.easySearch);
},
initCols(delay) {
let conditions = [{
conditionalType: "Equal",
fieldName: "categoryId",
fieldValue: this.nodeInfo.rootCategoryId
}];
Api.listTable({
conditions: conditions,
sortBy: "id",
isDesc: false
}).then(r => {
if (r.result) {
var items = r.result.filter(u => {
return (
!this.columns.some(p => {
return p.key == u.field;
}) && u.dataType != 5
);
});
this.addCol = items;
this.cols = this.$u.clone(this.columns);
let extra = items.map(u => {
console.log(u);
var col = {
key: u.field,
title: u.title
};
if (u.dataType == 3) {
col.code = u.note;
}
if (u.dataType == 4) {
col.type = "date";
}
if (u.unitName && (u.dataType == 1 || u.dataType == 2)) {
var units = this.$store.getters.dictionaryByKey(
"material.main.unitName"
);
Api.listTable({
conditions: conditions,
sortBy: "id",
isDesc: false
}).then(r => {
if (r.result) {
var items = r.result.filter(u => {
return (
!this.columns.some(p => {
return p.key == u.field;
}) && u.dataType != 5
);
});
this.cols = this.$u.clone(this.columns);
let extra = items.map(u => {
console.log(u);
var col = {
key: u.field,
title: u.title
};
if (u.dataType == 3) {
col.code = u.note;
let item = units.filter(p => {
return p.code == u.unitName;
});
// console.log(units, item);
col.title += "(" + item[0].name + ")";
}
return col;
});
this.cols = this.cols.concat(extra);
var action = this.cols.splice(this.columns.length - 1, 1);
this.cols.push(this.columns[this.columns.length - 1]);
if (delay) {
delay();
}
// console.log(this.cols)
}
});
this.exportTitle = "物料管理-" + this.nodeInfo.rootCategoryName;
},
add() {
if (this.nodeInfo.categoryId) {
if (this.nodeInfo.addChange == true) {
this.fullscreen = false;
this.curId = 0;
this.title = "新增";
this.detail = () => import("./add");
this.modal = true;
} else {
this.$Message.error("请在设置的分类层级数下添加物料");
}
} else {
this.$Message.error("请先选择分类");
}
if (u.dataType == 4) {
col.type = "date";
},
edit(row) {
this.fullscreen = false;
this.curId = row.id;
this.title = "编辑";
this.detail = () => import("./edit");
this.modal = true;
},
remove(id) {
Api.delete(id).then(r => {
if (r.success) {
this.$refs.grid.reload(this.easySearch);
this.$Message.success("删除成功");
}
});
},
details(row) {
this.fullscreen = true;
this.curId = row.id;
this.rootCategoryId = row.rootCategoryId;
this.title = "详情";
this.detail = () => import("./details");
this.rowsTable = [];
this.modal = true;
},
send(row) {
this.fullscreen = true;
this.curId = row.id;
this.rootCategoryId = row.rootCategoryId;
this.title = "物料送审";
this.detail = () => import("./submit");
this.rowsTable = [];
this.modal = true;
},
ok() {
this.$refs.grid.reload(this.easySearch);
this.modal = false;
this.curId = 0;
},
cancel() {
this.curId = 0;
this.modal = false;
},
//批量导入start
//导入功能
openModalIm() {
if (this.nodeInfo.categoryId) {
this.ModalIm = true
} else {
this.$Message.error("请先选择分类");
}
if (u.unitName && (u.dataType == 1 || u.dataType == 2)) {
var units = this.$store.getters.dictionaryByKey(
"material.main.unitName"
);
let item = units.filter(p => {
return p.code == u.unitName;
});
// console.log(units, item);
col.title += "(" + item[0].name + ")";
}
return col;
});
this.cols = this.cols.concat(extra);
var action = this.cols.splice(this.columns.length - 1, 1);
this.cols.push(this.columns[this.columns.length - 1]);
if (delay) {
delay();
}
// console.log(this.cols)
}
});
},
add() {
if (this.nodeInfo.categoryId) {
if (this.nodeInfo.addChange == true) {
this.fullscreen = false;
this.curId = 0;
this.title = "新增";
this.detail = () => import("./add");
this.modal = true;
} else {
this.$Message.error("请在设置的分类层级数下添加物料");
}
} else {
this.$Message.error("请先选择分类");
}
},
edit(row) {
this.fullscreen = false;
this.curId = row.id;
this.title = "编辑";
this.detail = () => import("./edit");
this.modal = true;
},
remove(id) {
Api.delete(id).then(r => {
if (r.success) {
this.$refs.grid.reload(this.easySearch);
this.$Message.success("删除成功");
}
});
},
details(row) {
this.fullscreen = true;
this.curId = row.id;
this.rootCategoryId = row.rootCategoryId;
this.title = "详情";
this.detail = () => import("./details");
this.rowsTable = [];
this.modal = true;
},
send(row) {
this.fullscreen = true;
this.curId = row.id;
this.rootCategoryId = row.rootCategoryId;
this.title = "物料送审";
this.detail = () => import("./submit");
this.rowsTable = [];
this.modal = true;
},
ok() {
this.$refs.grid.reload(this.easySearch);
this.modal = false;
this.curId = 0;
},
ModalImCancel() {
this.ModalIm = false
},
getData(val) {
let url = `${material}/materialimportservice/import`;
alert(JSON.stringify(this.cols))
this.$refs.importExcel.deelData(url, this.cols, this.formatMethod(val))
},
//根据页面二次处理数据
formatMethod(val) {
let tempData = this.$u.clone(val);
let tempList = [];
tempData.forEach((ele) => {
let obj = {
name: ele.name ? ele.name : '',
version: ele.version ? Number(ele.version) : '',
drawing: ele.drawing ? ele.drawing : '',
description: ele.description ? ele.description : "",
code: 0,
status: this.nodeInfo.status == 1 ? 3 : 0,
codeRuleId: this.nodeInfo.codeRuleId,
categoryId: this.nodeInfo.categoryId, //左侧树点击的id
customProperties: {},
rootCategoryId: this.nodeInfo.rootCategoryId, //左侧树点击的数据的最顶层id
};
this.addCol.forEach(el => {
obj[el.field] = ele[el.field]
})
if (ele.name && ele.name != '') {
obj.ico = false
} else {
obj.ico = true
}
tempList.push(obj);
});
return tempList
},
//批量导入end
},
cancel() {
this.curId = 0;
this.modal = false;
}
},
watch: {
nodeInfo: {
handler(newName, oldName) {
// console.log("ovo", newName, oldName);
if (newName.rootCategoryId) {
this.initCols(() => {
if (newName.categoryId) {
this.easySearch.categoryId.value = newName.ids;
this.$refs.grid.reload(this.easySearch);
}
});
}
if (!newName.categoryId) {
this.easySearch.categoryId.value = "-1";
watch: {
nodeInfo: {
handler(newName, oldName) {
// console.log("ovo", newName, oldName);
if (newName.rootCategoryId) {
this.initCols(() => {
if (newName.categoryId) {
this.easySearch.categoryId.value = newName.ids;
this.$refs.grid.reload(this.easySearch);
}
});
}
if (!newName.categoryId) {
this.easySearch.categoryId.value = "-1";
}
},
immediate: true,
deep: true
}
},
immediate: true,
deep: true
}
}
};
</script>
<style lang="less" >
<style lang="less">
.master-data {
.ivu-footer-toolbar-right {
margin-right: 72% !important;
}
.ivu-footer-toolbar-right {
margin-right: 72% !important;
}
}
</style>
\ No newline at end of file
</style>
......@@ -27,7 +27,7 @@ window.apsUrl = `http://${systemApi.aps}:10111/api/services/app`;//aps排产(61)
window.technologyUrl =`http://${address}:10000/technology/`;//新工艺规程接口
window.iconImg = `/imgicon/`;
window.mncImg = `/images/mnc/`;//mnc图片
window.material = `http://${address}:10000/material`; //物料管理
window.material = `http://${address}:10000/material`; //物料管理 10032
window.Platform = `http://${address}:10000/platform`; //计划管理10131
/* window.systemUrl = `http://${address}:10020/api/services/app`; //System-api 系统管理(基础数据)
......
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