Commit 367ceb3d authored by renjintao's avatar renjintao

datagrid com

parent 5e178bdc
......@@ -21,6 +21,12 @@
</div>
<div class="btns">
<slot name="buttons"></slot>
<Button @click="openImportModal">
导入
</Button>
<Button @click="export2Excel">
导出
</Button>
<Button v-if="set&&type=='table'" @click="config=!config">
<Icon type="md-build" title="列设置" />
</Button>
......@@ -64,6 +70,9 @@
</li>
</ul>
</Drawer>
<Modal v-model="ImportModal" title="导入" fullscreen footer-hide>
<ImportExcel v-if="ImportModal" @on-get-data="getData" :columns="columnsNow" />
</Modal>
<FooterToolbar v-if="batch" v-show="footerToolbar">
<div class="tip">已选{{selectItems.length}}</div>
<slot name="batch"></slot>
......@@ -96,6 +105,7 @@ export default {
userConfig: null, //用户页面配置信息。,
// userId: 1
userId: this.$store.state.userInfo.userId,
ImportModal: false,
};
},
props: {
......@@ -212,6 +222,10 @@ export default {
type: Number,
default: 40,
},
title: {
type: String,
default: "导出数据",
}
},
created() {
this.columns.forEach((u) => {
......@@ -462,6 +476,92 @@ export default {
this.footerToolbar = false;
this.$refs.table.selectAll(false);
},
//导入功能
openImportModal() {
this.ImportModal = true
},
getData(val) {
// alert(JSON.stringify(val))
this.$emit("on-import-data", val)
},
closeImport() {
this.ImportModal = false
},
//导出excel
export2Excel() {
//当前显示数据
var where = [];
var conditions = this.conditions;
if (conditions) {
Object.keys(conditions).forEach((u) => {
let v = conditions[u].value;
let op = conditions[u].op;
if (!this.$u.isNull(v)) {
if (op == "Range") {
let times = [];
v.map((u) => {
if (!this.$u.isNull(u)) {
times.push(this.$u.toTime(u));
}
});
v = times.join(",");
} else if (op.indexOf("In") > -1) {
v = v.join(",");
}
if (!this.$u.isNull(v)) {
where.push({
fieldName: u,
fieldValue: v,
conditionalType: op,
});
}
}
});
}
let searchs = {
pageIndex: 1,
conditions: where,
pageSize: 1000
}
this.$api.post(this.action, searchs).then((r) => {
let list = []
list = r.result.items;
const tHeader = []; // 设置Excel的表格第一行的标题
const filterVal = []; //list里对象的属性
var tempCol = [];
var columnsCur = this.$u.clone(this.columnsNow); //导出列标题信息griddata this.$refs.grid.columnsCur
columnsCur.forEach((el) => {
if ((el.hide && !el.import) || (!el.hide && el.key != "action" && el.type != "selection")) {
if (el.code) {
tempCol.push({
key: el.key,
code: el.code
}); //临时存放code数据字典的字段及对应的数据字典code
}
tHeader.push(el.title);
filterVal.push(el.key);
}
});
list.forEach((e) => {
//给导出数据增加数据字典对应的name
tempCol.forEach((ele) => {
e[ele.key] = this.$u.dirName(
this.$store.getters.dictionaryByKey(ele.code),
e[ele.key]
);
});
});
let nowDate = this.$u.getNowTime(); //年月日时分秒yyyyMMddhhmmss
//获取导出数据结束
this.$u.outExcel(this.title +
"(" + nowDate + ")",
tHeader,
filterVal,
list
);
});
},
//导入excel
},
computed: {
columnsNow() {
......
import Api from '@/plugins/request'
import { getJSON } from 'js-cookie';
export default {
index: `${systemUrl}/importcenter/paged`,
paged(params) {
return Api.post(`${systemUrl}/importcenter/paged`, params);
},
get(params) {
return Api.get(`${systemUrl}/importcenter/get`, params);
},
create(params) {
return Api.post(`${systemUrl}/importcenter/create`, params);
},
update(params) {
return Api.post(`${systemUrl}/importcenter/update`, params);
},
delete(id) {
return Api.delete(`${systemUrl}/importcenter/delete`, {
params: {
id: id
}
});
},
deletes(params) {
return Api.post(`${systemUrl}/importcenter/batchdelete`, params);
},
openExcel(params) {//处理时打开以前上传的excel返回数据
return Api.post(`${systemUrl}/importcenter/open`, params);
},
importUser(params) {//用户管理导入
return Api.post(`${systemUrl}/userimportservice/import`, params);
},
updateimportstatus(params) {//用户管理导入
return Api.post(`${systemUrl}/importcenter/updateimportstatus`, params);
},
}
<template>
<div class="h100">
<Tabs type="card" width="100">
<TabPane label="excel数据">
<TablePaste hide-table :input-props="inputProps" @on-success="handleSuccess" @on-error="handleError" />
</TabPane>
<TabPane label="预览">
<Table :border="true" :columns="columnsImport" :data="excelData" :height="tableHeight" ref="tableExcel" class="tableCommon"></Table>
</TabPane>
</Tabs>
</div>
</template>
<script>
import Api from "./api";
export default {
name: "detailExcel",
data() {
return {
entity: {},
downUrl: fileUrlDown,
fileUrlPath: "",
excelRows: 100,
tableHeight: '',
inputProps: {
rows: 10,
placeholder: "请从Excel复制一段表格数据,粘贴在这里",
},
columnsImport: [],
excelData: []
};
},
props: {
eid: Number,
},
created() {
this.excelRows = parseInt((window.innerHeight - 231) / 21) + 1;
this.inputProps.rows = this.excelRows
this.tableHeight = window.innerHeight - 200
},
mounted() {
window.onresize = () => {
///浏览器窗口大小变化
return (() => {
window.screenHeight = window.innerHeight;
this.excelRows = parseInt((window.screenHeight - 231) / 21) + 1;
this.inputProps.rows = this.excelRows
this.tableHeight = window.innerHeight - 200
})();
};
},
methods: {
handleClose() {
this.$emit("on-close");
},
downFile(path) {
//alert(path)
let truePath = path;
if (truePath.length > 2) {
if (
truePath.substring(0, 7).toLowerCase() == "http://" ||
truePath.substring(0, 8).toLowerCase() == "https://"
) {
window.open(truePath, "_blank");
} else {
this.fileUrlPath = this.downUrl + path;
window.open(this.fileUrlPath, "_blank");
}
}
},
//粘贴excel成功
handleSuccess(tableData) {
//初始化数据
this.excelData = [];
this.columnsImport = [];
//处理colum和data
let tabColum = tableData.columns
let tabData = tableData.data
let arrData = []
tabData.forEach(ele => {
let objData = {}
tabColum.forEach(el => {
objData[el.title] = ele[el.key]
})
arrData.push(objData)
})
//处理title和key一致
tabColum.forEach(el => {
el.key = el.title
})
this.columnsImport = tabColum;
this.columnsImport.unshift({
type: 'index',
width: 80,
align: 'right',
title: '序号'
})
this.excelData = arrData;
this.$emit("on-datalength", this.excelData.length)
},
//粘贴excel失败
handleError(tableData, errorIndex) {
//console.log(tableData, errorIndex);
this.$Message.error("表格数据有误");
},
//粘贴excel相关end
},
watch: {
eid(v) {
if (v > 0) {
this.load(v);
}
},
},
};
</script>
<template>
<div class="table-content">
<div class="table-tools">
<div class="table-search">
<Form inline>
<FormItem>
<div style="height:34px;overflow: hidden;padding:0">
<Upload action :before-upload="beforeUpload" ref="uploadfile" :format="formatList">
<Button icon="ios-cloud-upload-outline">上传文件</Button>
</Upload>
</div>
</FormItem>
<FormItem>
<Button type="primary" @click="openInfoModal" :disabled="btnIm">导入</Button>
</FormItem>
</Form>
</div>
<div class="btns">
<Form inline>
<FormItem>
<RadioGroup v-model="excelType" type="button" @on-change="changeExcel" size="small">
<Tooltip content="文件数据">
<Radio label="0">
<Icon type="ios-list-box-outline" />
</Radio>
</Tooltip>
<Tooltip content="粘贴Excel数据">
<Radio label="1">
<Icon type="ios-copy" />
</Radio>
</Tooltip>
</RadioGroup>
</FormItem>
</Form>
</div>
</div>
<div class="table-main" ref="main">
<Table :border="true" :columns="columnsImport" :data="excelData" :height="tdHeightExcel" :no-data-text="noDataText" ref="table" class="tableCommon" v-if="tableImport"></Table>
<component :is="detailExcel" ref="comExcel" @on-datalength="datalength" />
</div>
<FooterToolbar v-if="sheetNames.length>1&&tableImport">
<Form inline>
<FormItem>
<Tabs :animated="false" :value="0" @on-click="sheetClick">
<TabPane :label="item" v-for="(item,index) in sheetNames" :key="index"></TabPane>
</Tabs>
</FormItem>
</Form>
</FooterToolbar>
<Modal v-model="infoModal" :title="titleInfo" fullscreen>
<DataGrid :tool="false" :page="false" :columns="colsIm" :data="dataIm" :height="tdHeightExcel+30" ref="dataImport"></DataGrid>
<div slot="footer">
<Button @click="infoModal=false">关闭</Button>
<Button type="primary" @click="importOk" v-show="imBtn">确定导入</Button>
</div>
</Modal>
</div>
</template>
<script>
import XLSX from "xlsx";
import {
Switch
} from "view-design";
export default {
name: "Edit",
data() {
return {
tabVal: 0,
infoModal: false,
entity: {},
downUrl: fileUrlDown,
fileUrlPath: "",
disabled: false,
detailExcel: null,
tableImport: true,
tdHeightExcel: "",
excelData: [],
excelDataBack: [], //临时存储原始数据
formatList: ["xlsx"],
columnsImport: [],
departArr: [], //部门list
sheetNames: [], //excel的表明
workBook: {},
openDatas: [],
dataType: 0,
//new
colsIm: [],
dataIm: [],
excelType: '0',
btnIm: true,
titleInfo: '',
noDataText: '暂无数据',
imBtn: true,
};
},
props: {
eid: Number,
data: {
// 当作table使用,直接显示数据
type: Array,
default: function () {
return [];
},
},
columns: {
//要显示的字段
type: Array,
default: [],
},
},
created() {
this.tdHeightExcel = window.innerHeight - 180;
//导出对列表头进行预加载start
this.$api.get(`${systemUrl}/Department/GetDepartments`).then((r) => {
this.departArr = r.result.items;
});
//导出对列表头进行预加载end
},
mounted() {
//if (this.eid > 0) {
// this.load(this.eid);
//}
window.onresize = () => {
///浏览器窗口大小变化
return (() => {
window.screenHeight = window.innerHeight;
this.tdHeightExcel = window.screenHeight - 180;
})();
};
},
methods: {
//重新处理colum
loadColum(columns) {
let tempCol = this.$u.clone(columns);
tempCol.unshift({
type: 'index',
width: 80,
align: 'right',
title: '序号'
})
tempCol.forEach((ele, index) => {
if (ele.key == "action" || ele.type == "selection") {
ele.hide = true;
}
});
this.colsIm = tempCol;
//处理原始数据和表头进行对应
let temCol = this.$u.clone(this.colsIm); //原始数据表头
let temColPage = this.$u.clone(columns); //需要显示的页面的表头
//let temData = this.$u.clone(this.excelDataBack); //原始数据
let temData = []; //原始数据
if (this.excelType == "0") {
temData = this.$u.clone(this.excelDataBack)
} else {
temData = this.$u.clone(this.$refs.comExcel.excelData)
}
let arrTitleUse = []; ////使用数据字典的字段
temColPage.forEach((elCode) => {
if (elCode.code) {
arrTitleUse.push({
key: elCode.key,
code: elCode.code,
});
}
});
let useData = []; //重新组织list列表数据
temData.forEach((elData, index) => {
let objTm = {};
temCol.forEach((elTitle) => {
objTm[elTitle.key] = elData[elTitle.title];
});
useData.push(objTm);
});
//对列表里的部门及数据字典项进行处理
useData.forEach(eles => {
//如果导入文件没有departmentid,但存在departmentTitle的话,通过title获取id
if (
eles.departmentTitle &&
eles.departmentTitle != "" &&
(!eles.departmentId || eles.departmentId == "")
) {
this.departArr.forEach((e) => {
if (eles.departmentTitle && eles.departmentTitle == e.name) {
eles.departmentId = e.id;
}
});
} else if (
//如果导入文件没有departmentTitle,但存在departmentid的话,通过id获取departmentTitle
eles.departmentId &&
eles.departmentId + "" != "" &&
(!eles.departmentTitle || eles.departmentTitle == "")
) {
this.departArr.forEach((e) => {
if (eles.departmentId && eles.departmentId == e.id) {
eles.departmentTitle = e.name;
}
});
}
arrTitleUse.forEach((elem) => {
if (eles[elem.key] && eles[elem.key] != "" && eles[elem.key] != null) {
//如果数据字典项对应的DirName字段存在,通过name查询到对应的code,然后赋值
eles[elem.key] = this.$u.dirCode(
this.$store.getters.dictionaryByKey(elem.code),
eles[elem.key]
);
}
});
})
this.dataIm = useData;
},
//导入excel文件
async beforeUpload(file) {
//初始化
this.sheetNames = [];
this.workBook = {};
this.$refs.uploadfile.clearFiles(); //清除上一次上传文件列表
//上传成功后的读取到excel信息
this.workBook = await this.$u.readXLSX(file);
this.sheetNames = this.workBook.SheetNames; //execel里的表明
this.btnIm = false;
this.dealSheet(0); //默认显示第一个表
return false;
},
//对上传的excel表信息进行处理,不对表头进行处理
dealSheet(index) {
this.dataType = 1;
this.columnsImport = [];
this.excelData = [];
this.excelDataBack = [];
const sheet2JSONOpts = {
defval: "", //给defval赋值为空的字符串
};
var csv = XLSX.utils.sheet_to_csv(
this.workBook.Sheets[this.workBook.SheetNames[index]],
sheet2JSONOpts
);
var lines = csv.split("\n"); //第一行标题
var headers = lines[0].split(",");
var headersNow = [];
headersNow.push({
type: 'index',
width: 80,
align: 'right',
title: '序号'
})
headers.forEach((elHead) => {
let headObj = {};
headObj.title = elHead;
headObj.key = elHead;
headersNow.push(headObj);
});
this.columnsImport = headersNow;
var result = [];
for (var i = 1; i < lines.length - 1; i++) {
var obj = {};
var currentline = lines[i].split(",");
for (var j = 0; j < headers.length; j++) {
obj[headers[j]] = currentline[j];
}
result.push(obj);
}
this.excelData = result;
this.excelDataBack = result;
this.changeExcel(0)
},
//切换sheet表重新加载
sheetClick(val) {
this.tabVal = val
this.dealSheet(val);
},
handleClose() {
this.$emit("on-close");
},
cancelExcel() {
this.excelData = [];
this.excelDataBack = [];
this.$refs.uploadfile.clearFiles();
let parms = {
status: 1,
id: this.eid
}
//导入中心列表数据状态更新
this.$emit("on-close");
},
//打开导入数据格式化后的窗口
openInfoModal() {
if ((this.excelType == '0' && this.excelData.length > 0) || (this.excelType == '1' && this.$refs.comExcel.excelData.length > 0)) {
this.imBtn = true;
this.loadColum(this.columns);
this.titleInfo = "批量导入";
this.infoModal = true
} else {
this.imBtn = false;
this.$Message.error("没有可导入的数据!")
}
},
//导入按钮操作
importOk() {
this.importUser();
},
//批量导入用户
importUser() {
let tempData = this.$u.clone(this.dataIm);
this.$emit("on-get-data", tempData)
},
//切换列表和excel按钮
changeExcel(val) {
if (val == 1) {
this.tableImport = false
this.detailExcel = () => import("./detailExcel");
this.excelType = '1';
this.btnIm = true
} else {
this.detailExcel = null;
this.tableImport = true;
this.excelType = '0';
if (this.excelData.length > 0) {
this.btnIm = false
} else {
this.btnIm = true
}
}
},
datalength(val) {
if (val > 0) {
this.btnIm = false
}
},
l(key) {
key = "user" + "." + key;
return this.$t(key);
},
},
watch: {
"columns"() {
this.columns.forEach((u) => {
if (!u.hide) {
u.hide = false;
}
});
this.colsIm = this.$u.clone(this.columns);
},
},
};
</script>
<style lang="less">
.table-content {
position: relative;
height: 100%;
display: flex;
flex-direction: column;
.tip {
display: inline;
}
form {
display: inline-block;
.ivu-form-item {
margin: 0;
vertical-align: middle;
}
}
.table-main {
width: 100%;
text-align: left;
padding: 0;
display: block;
overflow-y: auto;
flex-grow: 1;
tr td .ivu-table-cell {
padding: 0 5px;
}
overflow-x: hidden;
}
.table-tools {
display: flex;
line-height: 50px;
.table-search {
flex-grow: 1;
}
.btns {
min-width: 200px;
text-align: right;
}
}
.table-footer {
line-height: 45px;
background: #f5f5f5;
}
.ivu-footer-toolbar {
text-align: left;
background: #f5f5f5;
.ivu-footer-toolbar-right {
float: left;
}
}
}
</style>
<template>
<div class="h100">
<DataGrid :columns="columns" ref="grid" :action="action">
<DataGrid :columns="columns" ref="grid" :action="action" title="导入中心">
<template slot="easySearch">
<Form ref="formInline" :model="easySearch" inline>
<FormItem prop="keys">
......
<template>
<Layout class="full">
<Layout class="full">
<!-- <Sider hide-trigger :style="{background: '#fff'}" width="260">
<div class="zh-tree" :style="{height:treeHeight+'px'}">
<h3 class="zh-title">产品结构</h3>
......@@ -15,104 +15,83 @@
</div>
</Sider>-->
<Sider hide-trigger v-if="showMenu" class="menu_side" width="300">
<ProductTree @on-hide="onHide" @on-select="productSearch" />
<ProductTree @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>
<a class="menu_play fr" @click="showMenuFn" title="展开">
<Icon type="ios-arrow-forward" size="24" />
</a>
</div>
<Content class="content" :class="!showMenu?'con_bord':''">
<!--:data="dataT"-->
<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="openSendViewModal"
v-if="this.wfstatu==1"
>订单送审</Button>
<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="sendViewModal" title="订单送审" width="1200">
<SendView :row="rowDataArry" ref="orderSendView" />
<div slot="footer">
<Button @click="sendViewModal = false">取消</Button>
<Button type="primary" @click="sendViewOk">确定送审</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>
<!--:data="dataT"-->
<DataGrid :action="action" :columns="columns" :conditions="easySearch" ref="grid" @on-selection-change="onSelect" :batch="true" :border="false" rowKey="id" title="订单管理" @on-import-data="onImportData">
<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="openSendViewModal" v-if="this.wfstatu==1">订单送审</Button>
<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="sendViewModal" title="订单送审" width="1200">
<SendView :row="rowDataArry" ref="orderSendView" />
<div slot="footer">
<Button @click="sendViewModal = false">取消</Button>
<Button type="primary" @click="sendViewOk">确定送审</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>
</Layout>
</template>
<script>
import Api from "./api";
import Add from "./add";
......@@ -124,931 +103,971 @@ import Send from "./send";
import SendView from "./sendView";
import ProductTree from "@/components/page/productTree.vue";
export default {
name: "list",
components: {
Add,
Edit,
Detail,
Search,
Split,
Send,
SendView,
ProductTree
},
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,
sendViewModal: 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"
name: "list",
components: {
Add,
Edit,
Detail,
Search,
Split,
Send,
SendView,
ProductTree
},
data() {
return {
action: Api.index,
showMenu: true,
easySearch: {
keys: {
op: "mesCode,productName",
value: null,
default: true
},
productId: {
op: "In",
value: ""
}
},
params.row.mesCode
);
}
},
addModal: false,
editModal: false,
detailModal: false,
deletelModal: false,
splitModal: false,
ModalInfo: false,
sendModal: false,
sendViewModal: 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,
type: 'workShopName'
},
{
key: "productingPreparationFinishDate",
title: this.l("productingPreparationFinishDate"),
align: "left",
high: true,
hide: true
},
{
key: "quotationPeople",
title: this.l("quotationPeople"),
align: "left",
high: true,
hide: true,
type: "user"
},
{
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: this.wfstatu == 1 ?
(
(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" :
"") : (
(params.row.status == 3 &&
params.row.id == params.row.rootId &&
params.row.divideMark != 0) ||
params.row.id != params.row.rootId ||
params.row.status != 3 ?
"display:none" :
"")
},
"编辑"
),
h(
"op", {
attrs: {
oprate: "remove"
},
on: {
click: () => this.remove(params.row)
},
style: this.wfstatu == 1 ?
(
(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" :
"") : (
(params.row.status == 3 &&
params.row.id == params.row.rootId &&
params.row.divideMark != 0) ||
params.row.id != params.row.rootId ||
params.row.status != 3 ?
"display:none" :
"")
},
"删除"
),
h(
"op", {
attrs: {
oprate: "detail"
},
on: {
click: () => this.split(params.row)
},
style: this.wfstatu == 1 ?
(
(params.row.divideMark != 0 &&
params.row.id == params.row.rootId) ||
params.row.status != 1 ||
params.row.quantity <= 1 ?
"display:none" :
"") : (
(params.row.divideMark != 0 &&
params.row.id == params.row.rootId) ||
params.row.status != 3 ||
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: [],
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: "", //删除提示信息
dataListRetrunNew: {
schemaId: "123327da-42b3-41f6-b785-cf933f137a95", //订单送审的schemaId
idList: [], //订单id List
codeList: [], //订单编号List
operatorIdList: [] //操作员id
}, //确定后返回数据
wfstatu: 1 //流程是否启用1 禁用 0启用
};
},
created() {
this.treeHeight = window.innerHeight - 150;
},
mounted() {
this.initTree();
let params = {
id: "123327da-42b3-41f6-b785-cf933f137a95"
};
this.$api.get(`${workflowUrl}/schema/getbyid`, params).then(res => {
if (res.success) {
let wfStatus = res.result.status;
if (wfStatus == 0) {
this.wfstatu = 1;
} else {
this.wfstatu = 3;
}
}
});
//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"); // 加载数据字典
await store.dispatch('loadDepartments'); //加载部门
},
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;
},
{
key: "taskType",
title: this.l("taskType"),
align: "center",
high: true,
code: "plan.order.taskType",
width: 100
search() {
this.easySearch.keys.value = this.easySearch.keys.value.trim();
this.$refs.grid.reload(this.easySearch);
},
{
key: "quantity",
title: this.l("quantity"),
align: "right",
high: true,
width: 80
detail(row) {
this.detailModal = true;
this.rowData = row;
},
{
key: "taskRequire",
title: this.l("taskRequire"),
align: "left",
easy: true,
high: true,
hide: true
edit(row) {
this.editModal = true;
this.rowData = row;
},
{
key: "status",
title: this.l("status"),
align: "center",
high: true,
code: "plan.order.status",
width: 100
split(row) {
if (row.quantity > 1) {
this.splitModal = true;
this.rowData = row;
} else {
this.$Message.error("数量为1,不能进行分解");
}
},
{
key: "productCode",
title: this.l("productCode"),
align: "left",
easy: true,
high: true,
hide: true
onHide() {
// this.$Message.info("收起左侧树")
this.showMenu = false;
},
{
key: "productName",
title: this.l("productName"),
align: "left",
easy: true,
high: true
showMenuFn() {
//this.$Message.info("展开左侧树")
this.showMenu = true;
},
{
key: "drawnNumber",
title: this.l("drawnNumber"),
align: "left",
easy: true,
high: true
productSearch(id, item, productIds, ids) {
let where = {
bomId: {
op: "In",
value: ids
}
};
this.$refs.grid.reload(where);
},
{
key: "batchNumber",
title: this.l("batchNumber"),
align: "left",
easy: true,
high: true
//确定分解
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("请确定计划数量!");
}
},
{
key: "projectNumber",
title: this.l("projectNumber"),
align: "left",
easy: true,
high: true
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;
},
{
key: "urgencyLevel",
title: this.l("urgencyLevel"),
align: "center",
high: true,
code: "plan.order.urgencyLevel",
width: 100
//打开送审modal
openSendViewModal() {
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.sendViewModal = false;
} else {
this.sendViewModal = true;
}
}, 400);
} else {
this.$Message.error("请选择订单");
}
},
//确定送审
sendViewOk() {
this.dataListRetrunNew.idList = [];
this.dataListRetrunNew.codeList = [];
this.dataListRetrunNew.operatorIdList = [];
this.rowDataArry.forEach(item => {
this.dataListRetrunNew.idList.push(item.id);
this.dataListRetrunNew.codeList.push(item.mesCode);
});
let ues = this.$refs.userProcess;
this.dataListRetrunNew.operatorIdList = this.$refs.orderSendView.getUsers();
//返回审批数据
//alert(JSON.stringify(this.dataListRetrunNew));
this.$http.order.batchstart(this.dataListRetrunNew).then(res => {
if (res.success) {
this.$Message.success("订单送审成功!");
this.$refs.grid.load();
} else {
this.$Message.error("订单送审失败!");
}
});
},
{
key: "productingPreparationPeople",
title: this.l("productingPreparationPeople"),
align: "left",
high: true,
hide: true,
type:'workShopName'
//打开派发
openSendModal() {
this.actIds = [];
this.delNum = 0;
if (this.rowDataArry.length > 0) {
this.rowDataArry.forEach(data => {
this.actIds.push(data.id);
if (data.status != 3) {
//判断非新建状态的订单
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("请选择订单");
}
},
{
key: "productingPreparationFinishDate",
title: this.l("productingPreparationFinishDate"),
align: "left",
high: true,
hide: true
//确定派发
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("操作失败");
});
}
});
},
{
key: "quotationPeople",
title: this.l("quotationPeople"),
align: "left",
high: true,
hide: true,
type: "user"
//单条删除
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);
},
{
key: "quotationFinishDate",
title: this.l("quotationFinishDate"),
align: "left",
high: true,
hide: true
//批量删除
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("请选择订单");
}
},
{
key: "demandStartDate",
title: this.l("demandStartDate"),
align: "left",
high: true,
hide: true,
type: "date"
//删除前判断子订单是否能删除
sondeletecheck(code) {
let param = {
id: code
};
Api.sondeletecheck(param).then(res => {
if (res.result == 1) {
this.delNum += 0;
} else {
this.delNum += 1;
}
});
},
{
key: "demandFinishDate",
title: this.l("demandFinishDate"),
align: "left",
high: true,
hide: true,
type: "date"
//删除前判断子订单
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;
},
{
key: "creatorUserId",
title: this.$t("creatorUserId"),
align: "left",
high: true,
type: "user"
//删除确定
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("操作失败");
});
},
{
key: "creationTime",
title: this.$t("creationTime"),
align: "center",
high: true,
width: 180
removeCancel() {
this.deletelModal = false;
},
{
key: "lastModifierUserId",
title: this.$t("lastModifierUserId"),
hide: true,
align: "left",
high: true,
type: "user"
cancel() {
this.curId = 0;
this.addModal = false;
this.detailModal = false;
this.editModal = false;
this.deletedlModal = false;
},
{
key: "lastModificationTime",
title: this.$t("lastModificationTime"),
hide: true,
align: "center",
high: true,
width: 180
l(key) {
let vkey = "mes_plan" + "." + key;
return this.$t(vkey) || key;
},
{
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:
this.wfstatu == 1
? (
(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"
: "")
: (
(params.row.status == 3 &&
params.row.id == params.row.rootId &&
params.row.divideMark != 0) ||
params.row.id != params.row.rootId ||
params.row.status != 3
? "display:none"
: "")
},
"编辑"
),
h(
"op",
{
attrs: { oprate: "remove" },
on: { click: () => this.remove(params.row) },
style:
this.wfstatu == 1
? (
(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"
: "")
: (
(params.row.status == 3 &&
params.row.id == params.row.rootId &&
params.row.divideMark != 0) ||
params.row.id != params.row.rootId ||
params.row.status != 3
? "display:none"
: "")
},
"删除"
),
h(
"op",
{
attrs: { oprate: "detail" },
on: { click: () => this.split(params.row) },
style:
this.wfstatu == 1
? (
(params.row.divideMark != 0 &&
params.row.id == params.row.rootId) ||
params.row.status != 1 ||
params.row.quantity <= 1
? "display:none"
: "")
: (
(params.row.divideMark != 0 &&
params.row.id == params.row.rootId) ||
params.row.status != 3 ||
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: [],
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: "", //删除提示信息
dataListRetrunNew: {
schemaId: "123327da-42b3-41f6-b785-cf933f137a95", //订单送审的schemaId
idList: [], //订单id List
codeList: [], //订单编号List
operatorIdList: [] //操作员id
}, //确定后返回数据
wfstatu: 1 //流程是否启用1 禁用 0启用
};
},
created() {
this.treeHeight = window.innerHeight - 150;
},
mounted() {
this.initTree();
let params = {
id: "123327da-42b3-41f6-b785-cf933f137a95"
};
this.$api.get(`${workflowUrl}/schema/getbyid`, params).then(res => {
if (res.success) {
let wfStatus = res.result.status;
if (wfStatus == 0) {
this.wfstatu = 1;
} else {
this.wfstatu = 3;
}
}
});
//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"); // 加载数据字典
await store.dispatch('loadDepartments');//加载部门
},
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;
},
//打开送审modal
openSendViewModal() {
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.sendViewModal = false;
} else {
this.sendViewModal = true;
}
}, 400);
} else {
this.$Message.error("请选择订单");
}
},
//确定送审
sendViewOk() {
this.dataListRetrunNew.idList = [];
this.dataListRetrunNew.codeList = [];
this.dataListRetrunNew.operatorIdList = [];
this.rowDataArry.forEach(item => {
this.dataListRetrunNew.idList.push(item.id);
this.dataListRetrunNew.codeList.push(item.mesCode);
});
let ues = this.$refs.userProcess;
this.dataListRetrunNew.operatorIdList = this.$refs.orderSendView.getUsers();
//返回审批数据
//alert(JSON.stringify(this.dataListRetrunNew));
this.$http.order.batchstart(this.dataListRetrunNew).then(res => {
if (res.success) {
this.$Message.success("订单送审成功!");
this.$refs.grid.load();
} 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 != 3) {
//判断非新建状态的订单
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("派发成功");
//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.sendModal = false;
this.$Message.error("派发失败");
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("删除成功");
},
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.deletelModal = false;
this.$Message.error("删除失败");
this.easySearch.productId.value = [];
this.$refs.grid.easySearch();
}
} 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); //手动选择树节点
},
//得到此树节点下所有是产品的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("此节点不是产品,请选择产品节点!");
}
}
}
},
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;
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
);
},
"rootId"
);
this.dataT = this.$u.clone(this.dataT);
//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);
},
//批量导入start
onImportData(val) {
alert(JSON.stringify(val))
this.$refs.grid.closeImport()
},
//批量导入end
}
}
};
</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";
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
</style>
......@@ -61,6 +61,7 @@ import DTSearch from '@/components/page/dtSearch.vue'
import InputTime from '@/components/page/inputTime.vue'
import OutputTime from '@/components/page/outputTime.vue'
import ViewerImg from '@/components/page/viewer.vue'
import ImportExcel from '@/components/page/import/process.vue'
// import FormMaking from 'form-making'
// import 'form-making/dist/FormMaking.css'
......@@ -127,6 +128,7 @@ Vue.component("OutputTime", OutputTime)
Vue.component("ViewerImg", ViewerImg)
Vue.component("StoreTree", StoreTree)
Vue.component("StoreSelect", StoreSelect)
Vue.component("ImportExcel",ImportExcel)
......
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