Commit 21a7ed91 authored by renjintao's avatar renjintao

storeTree

parent b6425633
<template>
<div class="flex fd tree-menu">
<h3>
库房库位
<div class="fr mr10 mt10">
<ButtonGroup class="fr" size="small">
<Button
:icon="expand ? 'md-arrow-dropright' : 'md-arrow-dropdown'"
@click="toggle"
title="展开/合并"
></Button>
<Button icon="md-refresh" title="刷新" @click="loadTree"></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" :render="renderContent" ref="tree" @on-select-change="change"></Tree>
</div>
</div>
</div>
</template>
<script>
export default {
name: "",
data() {
return {
keys: "",
expand: false,
list: []
};
},
created() {
this.loadTree();
},
methods: {
loadTree() {
let params = {
conditions: [
{
fieldName: "title",
fieldValue: name,
conditionalType: "Like"
}
]
};
this.$api
.post(`${resourceUrl}/storeroomlocation/paged`, params)
.then(r => {
let res = r.result.items;
var data = this.$u.toTree(
res,
0,
u => {
u.expand = true;
u.selected = false;
u.checked = false;
},
"upId"
);
this.list = this.$u.clone(data);
});
},
toggle() {
this.expand = !this.expand;
},
renderContent(h, { root, node, data }) {
let type = "md-folder";
return h("span", [
h("Icon", {
props: {
type: type
},
style: {
marginRight: "8px"
}
}),
h(
"span",
{
style: {
color: "#000"
}
},
data.title
)
]);
},
change(v, b) {
// console.log(b);
let ids = [];
let productIds = [];
if (b.bomId !== 0) {
ids.push(b.bomId);
}
productIds.push(b.value);
if (b.children) {
addId(b.children);
function addId(data) {
data.map(u => {
if (u.bomId !== 0) {
ids.push(u.bomId);
}
productIds.push(u.value);
if (u.children) {
addId(u.children);
}
});
}
}
this.$emit("on-select", b.bomId, b, productIds, ids);
},
hide() {
this.$emit("on-hide");
}
},
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 < 2) {
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;
}
}
};
</script>
<style lang="less">
.tree-menu {
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:0;
overflow: auto;
padding-left: 10px;
}
.tree {
height: calc(100vh - 215px);
overflow: auto;
}
}
</style>
\ No newline at end of file
<template>
<Layout class="full">
<!-- <Sider hide-trigger :style="{background: '#fff'}" width="260">
<div class="zh-tree" :style="{height:treeHeight+'px'}">
<h3 class="zh-title">产品结构</h3>
<div class="zh-box">
<Input search placeholder="请输入查询条件" v-model="treeInputSearch" />
<Tree
:data="searchList"
:style="{height:(treeHeight-95)+'px'}"
style="overflow:auto;width:215px;"
@on-select-change="selectTreeNode"
></Tree>
</div>
</div>
</Sider>-->
<Sider hide-trigger v-if="showMenu" class="menu_side" width="300">
<StoreTree @on-hide="onHide" @on-select="productSearch" />
</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="content" :class="!showMenu?'con_bord':''">
<DataGrid
:action="action"
:columns="columns"
:conditions="easySearch"
ref="grid"
@on-selection-change="onSelect"
:batch="true"
:border="false"
rowKey="id"
>
<template slot="easySearch">
<Form ref="formInline" :model="easySearch" inline>
<FormItem prop="keys">
<Input placeholder="请输入订单编号/产品名称" v-model="easySearch.keys.value" v-width="300" />
</FormItem>
<FormItem>
<Button type="primary" @click="search">查询</Button>
</FormItem>
</Form>
</template>
<template slot="searchForm">
<Search />
</template>
<template slot="buttons">
<Button type="primary" @click="addModal=true">创建</Button>
</template>
<template slot="batch">
<Button type="primary" class="mr10 ml10" @click="openSendModal">订单派发</Button>
<Button type="primary" class="mr10 ml10" @click="removeList">批量删除</Button>
</template>
</DataGrid>
<Modal v-model="addModal" title="新增" footer-hide width="1200">
<Add @on-close="cancel" @on-ok="addOk" />
</Modal>
<Modal v-model="editModal" title="编辑" footer-hide width="1200">
<Edit :row="rowData" @on-close="cancel" @on-ok="addOk" />
</Modal>
<Modal v-model="detailModal" title="订单详情" width="900">
<Detail :row="rowData" />
</Modal>
<Modal v-model="splitModal" title="订单分解" width="1200">
<Split :row="rowData" ref="orderSplit" />
<div slot="footer">
<Button @click="splitModal = false">取消</Button>
<Button type="primary" @click="orderSplitOk">确定分解</Button>
</div>
</Modal>
<Modal v-model="sendModal" title="订单派发" width="1200">
<Send :row="rowDataArry" ref="orderSend" />
<div slot="footer">
<Button @click="sendModal = false">取消</Button>
<Button type="primary" @click="sendOk">确定派发</Button>
</div>
</Modal>
<Modal v-model="deletelModal" title="删除" @on-ok="removeOk" @on-cancel="cancel">
<p>确定删除 订单:{{delMsg}} ?</p>
</Modal>
<!-- 信息提示 -->
<Modal
v-model="ModalInfo"
title="信息提示"
width="600"
:mask-closable="false"
:scrollable="true"
ok-text="确定"
cancel-text="取消"
>
{{ metCodesStrTxt }}
<div slot="footer">
<Button @click="ModalInfo = false">取消</Button>
<Button type="primary" @click="modalInfoOk">确定</Button>
</div>
</Modal>
</Content>
</Layout>
</template>
<script>
import Api from "./api";
import Add from "./add";
import Edit from "./edit";
import Detail from "./detail";
import Search from "./search";
import Split from "./add";
import Send from "./add";
import StoreTree from "@/components/page/storeTree.vue";
export default {
name: "list",
components: {
Add,
Edit,
Detail,
Search,
Split,
Send,
StoreTree
},
data() {
return {
action: Api.index,
showMenu: true,
easySearch: {
keys: {
op: "mesCode,productName",
value: null,
default: true
},
productId: { op: "In", value: "" }
},
addModal: false,
editModal: false,
detailModal: false,
deletelModal: false,
splitModal: false,
ModalInfo: false,
sendModal: false,
curId: 0,
id: "id",
columns: [
{
key: "selection",
type: "selection",
width: 50,
align: "center"
},
{
key: "id",
title: this.l("id"),
hide: true
},
{
key: "mesCode",
title: this.l("mesCode"),
align: "left",
width: 240,
easy: true,
high: true,
tree: true,
render: (h, params) => {
let name = params.row.mesCode;
let isUpId = params.row.upId;
let isDivideMark = params.row.divideMark;
let rowChildren = params.row.children;
return h(
"div",
{
style: {
cursor: "pointer",
display: "inline",
marginLeft: isDivideMark == 0 && isUpId == 0 ? "20px" : "0px"
}
},
params.row.mesCode
);
}
},
{
key: "taskType",
title: this.l("taskType"),
align: "center",
high: true,
code: "plan.order.taskType",
width: 100
},
{
key: "quantity",
title: this.l("quantity"),
align: "right",
high: true,
width: 80
},
{
key: "taskRequire",
title: this.l("taskRequire"),
align: "left",
easy: true,
high: true,
hide: true
},
{
key: "status",
title: this.l("status"),
align: "center",
high: true,
code: "plan.order.status",
width: 100
},
{
key: "productCode",
title: this.l("productCode"),
align: "left",
easy: true,
high: true,
hide: true
},
{
key: "productName",
title: this.l("productName"),
align: "left",
easy: true,
high: true
},
{
key: "drawnNumber",
title: this.l("drawnNumber"),
align: "left",
easy: true,
high: true
},
{
key: "batchNumber",
title: this.l("batchNumber"),
align: "left",
easy: true,
high: true
},
{
key: "projectNumber",
title: this.l("projectNumber"),
align: "left",
easy: true,
high: true
},
{
key: "urgencyLevel",
title: this.l("urgencyLevel"),
align: "center",
high: true,
code: "plan.order.urgencyLevel",
width: 100
},
{
key: "productingPreparationPeople",
title: this.l("productingPreparationPeople"),
align: "left",
high: true,
hide: true
},
{
key: "productingPreparationFinishDate",
title: this.l("productingPreparationFinishDate"),
align: "left",
high: true,
hide: true
},
{
key: "quotationPeople",
title: this.l("quotationPeople"),
align: "left",
high: true,
hide: true
},
{
key: "quotationFinishDate",
title: this.l("quotationFinishDate"),
align: "left",
high: true,
hide: true
},
{
key: "demandStartDate",
title: this.l("demandStartDate"),
align: "left",
high: true,
hide: true,
type: "date"
},
{
key: "demandFinishDate",
title: this.l("demandFinishDate"),
align: "left",
high: true,
hide: true,
type: "date"
},
{
key: "creatorUserId",
title: this.$t("creatorUserId"),
align: "left",
high: true,
type: "user"
},
{
key: "creationTime",
title: this.$t("creationTime"),
align: "center",
high: true,
width: 180
},
{
key: "lastModifierUserId",
title: this.$t("lastModifierUserId"),
hide: true,
align: "left",
high: true,
type: "user"
},
{
key: "lastModificationTime",
title: this.$t("lastModificationTime"),
hide: true,
align: "center",
high: true,
width: 180
},
{
title: "操作",
key: "action",
width: 180,
align: "left",
render: (h, params) => {
return h("div", { class: "action" }, [
h(
"op",
{
attrs: { oprate: "detail" },
on: { click: () => this.detail(params.row) }
},
"查看"
),
h(
"op",
{
attrs: { oprate: "edit" },
on: { click: () => this.edit(params.row) },
style:
(params.row.status == 1 &&
params.row.id == params.row.rootId &&
params.row.divideMark != 0) ||
params.row.id != params.row.rootId ||
params.row.status != 1
? "display:none"
: ""
},
"编辑"
),
h(
"op",
{
attrs: { oprate: "remove" },
on: { click: () => this.remove(params.row) },
style:
(params.row.status == 1 &&
params.row.id == params.row.rootId &&
params.row.divideMark != 0) ||
params.row.status != 1
? "display:none"
: ""
},
"删除"
),
h(
"op",
{
attrs: { oprate: "detail" },
on: { click: () => this.split(params.row) },
style:
(params.row.divideMark != 0 &&
params.row.id == params.row.rootId) ||
params.row.status != 1 ||
params.row.quantity <= 1
? "display:none"
: ""
},
"分解"
)
]);
}
}
// //传list数据时的判断
// {
// title: "操作",
// key: "action",
// width: 180,
// align: "left",
// render: (h, params) => {
// return h("div", { class: "action" }, [
// h(
// "op",
// {
// attrs: { oprate: "detail" },
// on: { click: () => this.detail(params.row) }
// },
// "查看"
// ),
// h(
// "op",
// {
// attrs: { oprate: "edit" },
// on: { click: () => this.edit(params.row) },
// style:
// (params.row.rootId == 0 && params.row.divideMark == 1) ||
// params.row.rootId != 0 ||
// params.row.status != 1
// ? "display:none"
// : ""
// },
// "编辑"
// ),
// h(
// "op",
// {
// attrs: { oprate: "remove" },
// on: { click: () => this.remove(params.row) },
// style:
// (params.row.rootId == 0 && params.row.divideMark == 1) ||
// params.row.status != 1
// ? // ||(params.row.id != params.row.rootId && this.sondeletecheck1(params.row.rootId)>0)
// "display:none"
// : ""
// },
// "删除"
// ),
// h(
// "op",
// {
// attrs: { oprate: "detail" },
// on: { click: () => this.split(params.row) },
// style:
// params.row.divideMark == 1 ||
// params.row.status != 1 ||
// params.row.quantity <= 1
// ? "display:none"
// : ""
// },
// "分解"
// )
// ]);
// }
// }
],
treeData: [],
treeInputSearch: "",
ocolumn: [],
treeHeight: "",
tableHeight: "",
ids: [],
orderSearchForm: {
productId: "", //产品id
productName: "", //产品名称
taskType: "", //任务类型
quantity: null, //数量
taskRequire: "", //任务接点要求
demandStartDate: "", //开始时间
demandFinishDate: "", //完成时间
remark: "", //备注
projectNumber: "", //项目号
batchNumber: "", //批次号
urgencyLevel: null //紧急程度
},
list: [],
//data测试数据
dataT: [],
dataTemp: [
{
mesCode: "DDBH_20200414_32",
taskType: 2,
productId: 71,
quantity: 10,
remark: "5",
taskRequire: "4",
status: 1,
divideMark: 1,
productName: "铅笔",
drawnNumber: "qianbii11",
rootId: 0,
batchNumber: "5",
projectNumber: "5",
urgencyLevel: 2,
productingPreparationPeople: 0,
productingPreparationFinishDate: "0001-01-01 00:00:00",
quotationPeople: 0,
quotationFinishDate: "0001-01-01 00:00:00",
upId: 0,
demandStartDate: "2020-04-14 00:00:01",
demandFinishDate: "2020-04-15 00:00:01",
rootCode: "DDBH_20200414_32",
creationTime: "2020-04-16 17:21:03",
id: 46
},
{
mesCode: "DDBH_20200414_3202",
taskType: 2,
productId: 71,
quantity: 6,
remark: "5",
taskRequire: "4",
status: 4,
divideMark: 0,
productCode: "No1~No6",
productName: "铅笔",
drawnNumber: "qianbii11",
rootId: 46,
batchNumber: "5",
projectNumber: "5",
urgencyLevel: 2,
productingPreparationPeople: 56,
productingPreparationFinishDate: "2020-04-17 23:59:59",
quotationPeople: 108,
quotationFinishDate: "2020-04-17 23:59:59",
upId: 46,
demandStartDate: "2020-04-14 00:00:01",
demandFinishDate: "2020-04-15 00:00:01",
rootCode: "DDBH_20200414_32",
lastModificationTime: "2020-04-15 10:40:22",
lastModifierUserId: 1,
creationTime: "2020-04-14 17:32:13",
creatorUserId: 1,
id: 52
},
{
mesCode: "DDBH_20200414_320101",
taskType: 2,
productId: 71,
quantity: 3,
remark: "5",
taskRequire: "4",
status: 1,
divideMark: 0,
productName: "铅笔",
drawnNumber: "qianbii11",
rootId: 46,
batchNumber: "5",
projectNumber: "5",
urgencyLevel: 2,
productingPreparationPeople: 0,
productingPreparationFinishDate: "0001-01-01 00:00:00",
quotationPeople: 0,
quotationFinishDate: "0001-01-01 00:00:00",
upId: 51,
demandStartDate: "2020-04-14 00:00:01",
demandFinishDate: "2020-04-15 00:00:01",
rootCode: "DDBH_20200414_32",
lastModificationTime: "2020-04-14 17:50:18",
lastModifierUserId: 1,
creationTime: "2020-04-14 17:32:13",
creatorUserId: 1,
id: 53
},
{
mesCode: "DDBH_20200414_320102",
taskType: 2,
productId: 71,
quantity: 1,
remark: "5",
taskRequire: "4",
status: 1,
divideMark: 0,
productName: "铅笔",
drawnNumber: "qianbii11",
rootId: 46,
batchNumber: "5",
projectNumber: "5",
urgencyLevel: 2,
productingPreparationPeople: 0,
productingPreparationFinishDate: "0001-01-01 00:00:00",
quotationPeople: 0,
quotationFinishDate: "0001-01-01 00:00:00",
upId: 51,
demandStartDate: "2020-04-14 00:00:01",
demandFinishDate: "2020-04-15 00:00:01",
rootCode: "DDBH_20200414_32",
lastModificationTime: "2020-04-14 17:50:18",
lastModifierUserId: 1,
creationTime: "2020-04-14 17:32:13",
creatorUserId: 1,
id: 54
},
{
mesCode: "DDBH_20200414_31",
taskType: 2,
productId: 70,
quantity: 8,
remark: "5",
taskRequire: "4",
status: 4,
divideMark: 0,
productCode: "No1~No8",
productName: "口罩模具",
drawnNumber: "LXG_KZ_001",
rootId: 0,
batchNumber: "5",
projectNumber: "5",
urgencyLevel: 2,
productingPreparationPeople: 56,
productingPreparationFinishDate: "2020-04-16 23:59:59",
quotationPeople: 108,
quotationFinishDate: "2020-04-16 23:59:59",
upId: 0,
demandStartDate: "2020-04-14 00:00:01",
demandFinishDate: "2020-04-15 00:00:01",
rootCode: "DDBH_20200414_31",
isDeleted: false,
creationTime: "2020-04-16 17:21:03",
id: 45
},
{
mesCode: "DDBH_20200414_30",
taskType: 2,
productId: 69,
quantity: 18,
remark: "5",
taskRequire: "4",
status: 4,
divideMark: 0,
productCode: "No1~No18",
productName: "护目镜",
drawnNumber: "LXG_HMJ_001",
rootId: 0,
batchNumber: "5",
projectNumber: "5",
urgencyLevel: 2,
productingPreparationPeople: 56,
productingPreparationFinishDate: "2020-04-16 23:59:59",
quotationPeople: 1,
quotationFinishDate: "2020-04-24 23:59:59",
upId: 0,
demandStartDate: "2020-04-14 00:00:01",
demandFinishDate: "2020-04-15 00:00:01",
rootCode: "DDBH_20200414_30",
isDeleted: false,
creationTime: "2020-04-16 17:21:03",
id: 44
},
{
mesCode: "DDBH_20200414_28",
taskType: 1,
productId: 22,
quantity: 15,
remark: "rr",
taskRequire: "r",
status: 1,
divideMark: 0,
productName: "te",
drawnNumber: "te",
rootId: 0,
batchNumber: "r",
projectNumber: "rr",
urgencyLevel: 2,
productingPreparationPeople: 0,
productingPreparationFinishDate: "0001-01-01 00:00:00",
quotationPeople: 0,
quotationFinishDate: "0001-01-01 00:00:00",
upId: 0,
demandStartDate: "2020-04-14 00:00:01",
demandFinishDate: "2020-04-15 00:00:01",
rootCode: "DDBH_20200414_28",
isDeleted: false,
creationTime: "2020-04-16 17:21:03",
id: 42
}
],
data1: [],
selectdata: [],
//以下为手写死数据集:
orderCatList: [], //订单类型下拉
outerCodeList: [], //型号外部代码下拉
missionCodeList: [], //任务号下拉
stageList: [], //阶段下拉
materailList: [], //材料下拉
routingAccessList: [], //工艺方法下拉
drawNumberList: [], //图号下拉
docNameList: [], //文档名称下拉
ownerGustList: [], //甲方客户下拉
mainDeptList: [], //厂内主体部门下拉
taskTypeList: [], //任务类型
statusList: [], //状态类型
rowData: {}, //编辑、查看的当前行数据
rowDataArry: [],
ModalInfoStaut: "",
sendList: [],
metCodesStrTxt: "",
actIds: [], //批量处理时ids
actMescodes: [],
delNum: 0, //判断是否可以进行修改
arrayIds: [], //选择列表后的ids
delMsg: "" //删除提示信息
};
},
created() {
this.treeHeight = window.innerHeight - 150;
},
mounted() {
this.initTree();
//this.dataformat();//data传数据转为tree类型
this.tableHeight = window.innerHeight - 220;
//this.$refs.CustomTable.getTableHeight(this.tableHeight);
window.onresize = () => {
///浏览器窗口大小变化
return (() => {
window.screenHeight = window.innerHeight;
this.treeHeight = window.screenHeight - 150;
this.tableHeight = window.screenHeight - 220;
//this.$refs.CustomTable.getTableHeight(this.tableHeight);
})();
};
},
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;
}
},
methods: {
addOk() {
this.$refs.grid.load();
this.addModal = false;
this.detailModal = false;
this.editModal = false;
this.curId = 0;
},
search() {
this.easySearch.keys.value = this.easySearch.keys.value.trim();
this.$refs.grid.reload(this.easySearch);
},
detail(row) {
this.detailModal = true;
this.rowData = row;
},
edit(row) {
this.editModal = true;
this.rowData = row;
},
split(row) {
if (row.quantity > 1) {
this.splitModal = true;
this.rowData = row;
} else {
this.$Message.error("数量为1,不能进行分解");
}
},
onHide() {
// this.$Message.info("收起左侧树")
this.showMenu = false;
},
showMenuFn() {
//this.$Message.info("展开左侧树")
this.showMenu = true;
},
productSearch(id, item, productIds, ids) {
let where = { bomId: { op: "In", value: ids } };
this.$refs.grid.reload(where);
},
//确定分解
orderSplitOk() {
let returnDatalist = this.$refs.orderSplit.returnDataList();
let orderQuantity = returnDatalist.quantity;
let orderListQuantity = 0;
let quantyStatu = false; //子订单计划数是否为0或空
let dateStatu = false; //子订单开始完成时间是否为空
if (returnDatalist.items.length > 0) {
returnDatalist.items.forEach(data => {
orderListQuantity = orderListQuantity + parseFloat(data.quantity);
if (parseFloat(data.quantity) == 0 || data.quantity == "") {
quantyStatu = true;
}
if (data.demandDate[0] == "" || data.demandDate[1] == "") {
dateStatu = true;
}
});
if (dateStatu) {
this.$Message.error("子订单开始完成时间不能为空,请重新输入时间!");
return false;
}
if (quantyStatu) {
this.$Message.error("子订单计划数量不能为0,请重新输入计划数量!");
} else if (returnDatalist.quantity != orderListQuantity) {
this.$Message.error(
"计划总数量与订单数量不一致,请重新输入计划数量!"
);
} else {
this.ModalInfo = true;
this.ModalInfoStaut = "split";
this.dataListRetrun = returnDatalist;
this.metCodesStrTxt = "确定分解订单 " + returnDatalist.mesCode + "?";
}
} else {
this.$Message.error("请确定计划数量!");
}
},
modalInfoOk() {
let itemsTemp = [];
this.dataListRetrun.items.forEach(ele => {
let objTemp = {};
objTemp.mesCode = ele.mesCode;
objTemp.quantity = Number(ele.quantity);
objTemp.demandStartDate = ele.demandStartDate + " 00:00:01";
objTemp.demandFinishDate = ele.demandFinishDate + " 23:59:59";
itemsTemp.push(objTemp);
});
let params = {
id: this.dataListRetrun.id,
items: itemsTemp
};
Api.mesorderdivide(params).then(res => {
if (res.result) {
this.$Message.success("订单分解成功!");
this.$refs.grid.load();
} else {
this.$Message.error("订单分解失败!");
}
});
this.splitModal = false;
this.ModalInfo = false;
//确定批量操作
// if (this.ModalInfoStaut == 'orderSendReview') {
// this.$http.order.batchstart(this.dataListRetrun).then((res) => {
// if (res.success) {
// this.$Message.success('订单送审成功!')
// this.easySearch('')
// } else {
// this.$Message.error('订单送审失败!')
// }
// })
// this.ModalOrderSendReview = false
// } else if (this.ModalInfoStaut == 'delOrder') {
// this.$http.order.delOrder(this.dataListRetrunParam).then((res) => {
// if (res.result) {
// this.$Message.success('删除成功!')
// this.easySearch('')
// } else {
// this.$Message.error('删除失败!')
// }
// this.$refs.createOrder.resetFields()
// this.createShow = false
// })
// } else if (this.ModalInfoStaut == 'orderSend') {
// this.$http.order.orderSend(this.dataListRetrun).then((res) => {
// if (res.result) {
// this.$Message.success('订单派发成功!')
// this.easySearch('')
// this.ModalOrderSend = false
// } else {
// this.$Message.error('订单派发失败!')
// }
// })
// } else {
// Api.mesorderdivide(this.dataListRetrun).then(res => {
// if (res.result) {
// this.$Message.success("订单分解成功!");
// } else {
// this.$Message.error("订单分解失败!");
// }
// });
//}
},
//打开派发
openSendModal() {
this.actIds = [];
this.delNum = 0;
if (this.rowDataArry.length > 0) {
this.rowDataArry.forEach(data => {
this.actIds.push(data.id);
if (data.status != 1) {
//判断非新建状态的订单
this.delNum += 1;
}
});
setTimeout(() => {
if (this.delNum > 0) {
this.$Message.error("所选的订单中有不可派发的订单!");
this.actIds = [];
this.sendModal = false;
} else {
this.sendModal = true;
}
}, 400);
} else {
this.$Message.error("请选择订单");
}
},
//确定派发
sendOk() {
this.$refs.orderSend.$refs["formValidate"].validate(valid => {
if (valid) {
let ids = this.arrayIds;
let objInfoTem = this.$refs.orderSend.returnData();
let parms = [];
ids.forEach(e => {
let objInfo = this.$u.clone(objInfoTem);
objInfo.id = e;
parms.push(objInfo);
});
Api.mesorderdistribute(parms)
.then(r => {
if (r.success) {
if (r.result) {
this.$refs.grid.load();
this.sendModal = false;
this.$Message.success("派发成功");
} else {
this.sendModal = false;
this.$Message.error("派发失败");
}
} else {
this.sendModal = false;
this.$Message.error("派发失败");
}
})
.catch(err => {
this.sendModal = false;
this.$Message.error("操作失败");
});
}
});
},
//单条删除
remove(row) {
let metCodesSingle = []; //没有子订单的订单
let metCodesFather = []; //有子订单的原始订单
this.delMsg = "";
this.delNum = 0;
this.actIds = [];
this.$refs.grid.cancelFooterToolbar();
this.actIds.push(row.id);
if (row.id != row.rootId) {
this.sondeletecheck(row.rootId);
metCodesFather.push(row.rootCode);
} else {
metCodesSingle.push(row.mesCode);
}
setTimeout(() => {
if (this.delNum > 0) {
this.$Message.error("删除的原始订单中有非新建状态的子订单!");
this.actIds = [];
return false;
} else {
let metCodesSingleStr = JSON.stringify(metCodesSingle)
.replace("[", "")
.replace("]", "")
.replace(/\"/g, "");
let metCodesFatherStr = JSON.stringify(metCodesFather)
.replace("[", "")
.replace("]", "")
.replace(/\"/g, "");
if (row.id == row.rootId) {
this.delMsg = metCodesSingleStr;
} else {
this.delMsg = metCodesFatherStr + " 的子订单";
}
this.deletelModal = true;
}
}, 400);
},
//批量删除
removeList() {
let metCodesSingle = []; //没有子订单的订单
let metCodesFather = []; //有子订单的原始订单
this.actIds = [];
this.delNum = 0;
if (this.rowDataArry.length > 0) {
this.rowDataArry.forEach(data => {
this.actIds.push(data.id);
if (data.status != 1) {
//判断非新建状态的订单
this.delNum += 1;
} else if (data.id != data.rootId) {
//判断子订单是否可以删除
this.sondeletecheck(data.rootId);
if (data.id != data.rootId && data.status == 1) {
metCodesFather.push(data.rootCode);
}
} else {
if (data.id == data.rootId && data.status == 1) {
metCodesSingle.push(data.mesCode);
}
}
});
setTimeout(() => {
if (this.delNum > 0) {
this.$Message.error("所选的订单中有不可删除的订单!");
this.actIds = [];
this.deletelModal = false;
} else {
this.delMsg = "";
let metCodesFatherNew = Array.from(new Set(metCodesFather));
let metCodesSingleStr = JSON.stringify(metCodesSingle)
.replace("[", "")
.replace("]", "")
.replace(/\"/g, "");
let metCodesFatherStr = JSON.stringify(metCodesFatherNew)
.replace("[", "")
.replace("]", "")
.replace(/\"/g, "");
if (metCodesSingle.length > 0 && metCodesFather.length == 0) {
this.delMsg = metCodesSingleStr;
} else if (
metCodesSingle.length == 0 &&
metCodesFather.length > 0
) {
this.delMsg = metCodesFatherStr + " 的子订单";
} else if (metCodesSingle.length > 0 && metCodesFather.length > 0) {
this.delMsg =
metCodesSingleStr +
" 以及 订单:" +
metCodesFatherStr +
" 的子订单";
}
this.deletelModal = true;
}
}, 400);
} else {
this.$Message.error("请选择订单");
}
},
//删除前判断子订单是否能删除
sondeletecheck(code) {
let param = { id: code };
Api.sondeletecheck(param).then(res => {
if (res.result == 1) {
this.delNum += 0;
} else {
this.delNum += 1;
}
});
},
//删除前判断子订单
sondeletecheck1(code) {
let param = { id: code };
let delStaut = 0;
Api.sondeletecheck(param).then(res => {
if (res.result == 1) {
//可以删除
delStaut = 0;
} else {
delStaut = 1;
}
});
return delStaut;
},
//删除确定
removeOk() {
let params = { ids: this.actIds };
Api.mesorderdelete(params)
.then(r => {
if (r.success) {
if (r.result) {
this.$refs.grid.load();
this.deletelModal = false;
this.$Message.success("删除成功");
} else {
this.deletelModal = false;
this.$Message.error("删除失败");
}
} else {
this.deletelModal = false;
this.$Message.error("删除失败");
}
})
.catch(err => {
this.deletelModal = false;
this.$Message.error("操作失败");
});
},
removeCancel() {
this.deletelModal = false;
},
cancel() {
this.curId = 0;
this.addModal = false;
this.detailModal = false;
this.editModal = false;
this.deletedlModal = false;
},
l(key) {
let vkey = "mes_plan" + "." + key;
return this.$t(vkey) || key;
},
//new tree start
initTree() {
var sumData = [];
this.$http.order.getallselecttree().then(res => {
//alert(JSON.stringify(res))
if (res.result) {
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("加载产品树失败!");
}
});
},
selectTreeNode(value) {
if (value.length > 0) {
this.ids = [];
this.getAllIds(value);
if (this.ids.length > 0) {
this.orderSearchForm.productId = this.ids;
} else {
this.orderSearchForm.productId = [];
}
this.easySearch.productId.value = this.orderSearchForm.productId;
this.$refs.grid.easySearch();
} else {
this.easySearch.productId.value = [];
this.$refs.grid.easySearch();
}
},
//得到此树节点下所有是产品的productId
getAllIds(trees) {
trees.forEach((data, index) => {
var that = this;
if (data.isProduct) {
this.ids.push(data.productId);
}
if (data.children.length > 0) {
this.getAllIds(data.children);
}
});
},
handleSelect(data) {
if (data.length > 0) {
this.selectdata = [];
this.selectdata = data;
this.list = [];
this.list.push({ label: data[0].title, value: data[0].id });
//this.formValidate.classType=data[0].id;
if (data[0].isProduct == "1") {
this.orderSearchForm.productName = data[0].id;
this.orderSearchForm.productId = data[0].productId;
} 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
);
},
//new tree end
//list start
onSelect(a, b) {
//alert(JSON.stringify(a));
//批量选择
let selectRows = a;
this.arrayIds = [];
this.rowDataArry = a;
selectRows.forEach(e => {
this.arrayIds.push(e.id);
});
},
//list end
//将数组数据转为tree
dataformat() {
this.dataT = this.$u.toTree(
this.dataTemp,
0,
u => {
if (u.divideMark == 1) {
u._disabled = true;
}
u._showChildren = true;
},
"rootId"
);
this.dataT = this.$u.clone(this.dataT);
}
}
};
</script>
<style lang="less">
.full {
margin-top: 0;
.content {
margin-top: 10px;
.ivu-icon-ios-add:before {
content: "\f341";
}
.ivu-icon-ios-remove:before {
content: "\f33d";
}
}
}
</style>
\ No newline at end of file
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