Commit 3e99b4c1 authored by renjintao's avatar renjintao

Merge branch 'master' of git.mes123.com:zhouyx/mes-ui

parents da089700 d58fef4f
<template> <template>
<div class="table-content"> <div class="table-content1">
<div class="table-tools"> <div class="table-tools">
<div class="table-search"> <div class="table-search">
<slot name="easySearch"></slot> <slot name="easySearch"></slot>
...@@ -46,11 +46,6 @@ ...@@ -46,11 +46,6 @@
</th> </th>
</tr> </tr>
</thead> </thead>
</table>
</div>
<div class="table-body">
<table>
<tbody> <tbody>
<tr <tr
v-for="(item, index) in trs" v-for="(item, index) in trs"
...@@ -784,7 +779,7 @@ export default { ...@@ -784,7 +779,7 @@ export default {
@table_line_height: 50px; @table_line_height: 50px;
@table_hover: #f2f8fe; @table_hover: #f2f8fe;
@table_border: #accef7; @table_border: #accef7;
.table-content { .table-content1 {
position: relative; position: relative;
height: 100%; height: 100%;
display: flex; display: flex;
......
<template>
<div class="table-content">
<div class="table-tools" v-if="tool">
<div class="table-search">
<slot name="easySearch" v-if="easy">
<Form inline>
<FormItem>
<Input search enter-button :placeholder="placeholder" @on-search="easySearch" v-width="300" v-model="keys" />
</FormItem>
<FormItem>
<Button v-if="high" @click="modalSearch = true" type="text">
<Icon type="md-search" />高级
</Button>
</FormItem>
</Form>
</slot>
</div>
<div class="searchBack">
<slot name="searchBack"></slot>
</div>
<div class="btns">
<slot name="buttons"></slot>
<Button @click="export2Excel" v-if="exportTitle.length > 0">导出</Button>
<Button v-if="set && type == 'table'" @click="config = !config">
<Icon type="md-build" title="列设置" />
</Button>
</div>
</div>
<div class="table-main" ref="main">
<Row v-if="type == 'card'" :gutter="40">
<Col :span="span" v-for="(row, i) in list" :key="i">
<slot name="card" :row="row">
<span>{{ row.id }}</span>
</slot>
</Col>
<Col v-if="list.length == 0" span="24" class="zan-wu">
<h4>暂无数据</h4>
</Col>
</Row>
<Table v-else :border="border" :columns="columnsNow" :data="list" :height="tableHeight" :draggable="draggable" ref="table" class="tableCommon" @on-expand="expand" @on-drag-drop="onDragDrop" @on-selection-change="selectionChange" @on-select="onSelect" @on-select-all="allChange" @on-sort-change="sortChange" :row-key="rowKey" stripe></Table>
</div>
<div class="table-footer">
<slot name="footer"></slot>
<Page v-if="page" :total="search.total" :current="search.page" class="fr" show-total size="small" show-elevator show-sizer :page-size="search.pageSize" :page-size-opts="pageSizeOpts" @on-change="pageChange" @on-page-size-change="pageSizeChange" />
</div>
<Modal v-if="high" v-model="modalSearch" title="高级搜索" draggable width="800" ref="search">
<slot name="searchForm"></slot>
<div slot="footer">
<Button @click="modalSearch = false" style="margin-left: 20px">取消</Button>
<Button @click="complexSearch" type="primary" style="margin-left: 10px">查询</Button>
</div>
</Modal>
<Drawer title="列设置" v-if="set" v-model="config" :scrollable="true" placement="left" :mask="false">
<div slot="header">
列设置
<a @click="undoConfig" class="ml50">
<Icon type="md-refresh" title="恢复初始设置" />
</a>
</div>
<ul class="table-columns">
<li v-for="(li, index) in columnsCur" :key="index" v-dragging="{ item: li, list: columnsCur, group: 'li' }">
<label @click="columnChange(li, index)" :class="{ dis: li.hide }">
<Icon :type="li.hide ? 'md-eye-off' : 'md-eye'" size="16" class="mr10" />
<span>{{ li.title }}</span>
</label>
<Icon type="ios-move" class="move" size="18" />
</li>
</ul>
</Drawer>
<FooterToolbar v-if="batch" v-show="footerToolbar" class="ftball">
<div class="tip">已选{{ selectItems.length }}</div>
<slot name="batch"></slot>
<Button @click="cancelBatch">取消</Button>
</FooterToolbar>
</div>
</template>
<script>
import ColumnSlot from "./treeGrid/columnSolt";
export default {
name: "DataGrid",
components: {
ColumnSlot
},
data() {
return {
keys: "",
selectItems: [],
footerToolbar: false,
modalSearch: false,
search: {
pageIndex: 1,
pageSize: 20,
sortBy: this.conditions.sortBy ? this.conditions.sortBy : 'id',
isDesc: true,
conditions: [],
},
searchConditions: this.search,
pageSizeOpts: [20, 50, 100],
tableHeight: 0,
firstY: 0,
config: false,
list: [],
columnsCur: [],
configLoad: false,
userConfig: null, //用户页面配置信息。,
// userId: 1
userId: this.$store.state.userInfo.userId,
treeData: [], //物料数据
codeRuleData: [], //物料编码
routingHeaderData: [], //工艺规程
allUser: [], //所有user
};
},
props: {
border: {
//是否显示边框
type: Boolean,
default: true,
},
batch: {
//是否批量操作
type: Boolean,
default: true,
},
format: {
type: Function,
default: null,
},
initsearch: {
type: Function,
default: null,
},
lazy: {
//懒加载设置,设置为真时候,默认不加载数据。
type: Boolean,
default: false,
},
placeholder: {
type: String,
default: "请输入关键字",
},
height: {
type: Number,
default: 0,
},
tool: {
//是否显示工具栏
type: Boolean,
default: true,
},
easy: {
//是否显示简单搜索
type: Boolean,
default: true,
},
high: {
//是否显示高级搜索
type: Boolean,
default: true,
},
draggable: {
//是否可以拖拽
type: Boolean,
default: false,
},
set: {
//是否显示列设置
type: Boolean,
default: true,
},
page: {
//是否分页
type: Boolean,
default: true,
},
data: {
// 当作table使用,直接显示数据
type: Array,
default: function () {
return [];
},
},
columns: {
//要显示的字段
type: Array,
default: [],
},
action: {
//接口地址
type: String,
default: "",
},
conditions: {
//查询条件
type: Object,
default: function () {
return {
keys: {
op: "name",
value: "",
default: true,
},
};
},
},
type: {
type: String,
default: "table",
validator: function (value) {
// 这个值必须匹配下列字符串中的一个
return ["table", "card", "list"].indexOf(value) !== -1;
},
},
span: {
//栅格数
type: Number,
default: 24,
},
//table控件children子数据控制功能
rowKey: {
type: [String, Number],
},
gutter: {
//间距
type: Number,
default: 40,
},
exportTitle: {
type: String,
default: "",
},
},
provide() {
return {
tableRoot: this.slots,
};
},
created() {
this.initColumns();
},
mounted() {
if (this.data && this.data.length > 0) {
this.list = this.data;
return;
}
this.keys = "";
this.intY();
if (this.lazy == true) {
return;
}
if (this.userId > 0 && this.set) {
this.loadUserConfig();
} else {
this.easySearch();
}
if (this.height === 0) {
this.$nextTick(() => {
this.tableHeight = this.$refs.main.offsetHeight;
if (this.tableHeight < 300) {
this.tableHeight =
window.screen.availHeight - this.$refs.main.offsetTop - 200;
}
window.onresize = () => {
///浏览器窗口大小变化
return (() => {
if (this.$refs.main && this.$refs.main.offsetHeight) {
this.tableHeight = this.$refs.main.offsetHeight;
if (this.tableHeight < 300) {
this.tableHeight =
window.screen.availHeight - this.$refs.main.offsetTop - 150;
}
}
})();
};
});
} else {
this.tableHeight = this.height;
}
//注册拖拽事件。
this.$dragging.$on("dragend", (e) => {
this.saveUserconfig();
});
//物料加载类型数据
this.getTreeData();
this.getcodeRuleData();
this.getRoutingHeaderData();
this.getAllUser(); //获取所有用户
},
methods: {
//列初始化 slot 支持;
slots() {
return this.$scopedSlots;
},
initColumns() {
this.columns.forEach((u) => {
if (!u.hide) {
u.hide = false;
}
});
var items = this.$u.clone(this.columns);
// var soct=this.$scopedSlots;
// // console.warn("that.$scopedSlots()",soct["action"]());
// items.forEach((u) => {
// if (u.slot) {
// u.render = (h, params) => {
// return h(
// "span",
// // soct[u.slot]({
// // row: params.row,
// // column: params.column,
// // index: params.index,
// // })
// params.row.id
// );
// };
// delete u.slot;
// }
// });
this.columnsCur = items;
// console.log("cur", items,this.columnsCur);
},
//数据加载
load() {
if (this.action) {
//条件初始化处理。
if (this.initsearch) {
this.initsearch(this.search);
}
this.$api.post(this.action, this.search).then((r) => {
if (this.format) {
this.list = this.format(r.result.items);
} else {
this.list = r.result.items;
}
this.search.total = r.result.totalCount || r.result.count;
});
}
},
columnInit() {
if (this.userConfig) {
var curColumns = [];
var config = JSON.parse(this.userConfig.content);
if (config.length == this.columnsCur.length) {
config.map((u) => {
var item = this.columnsCur.filter((c) => {
return c.key == u.key;
});
if (item[0]) {
item[0].hide = u.hide;
curColumns.push(item[0]);
}
});
this.columnsCur = curColumns;
}
}
},
loadUserConfig() {
var query = {
conditions: [{
fieldName: "creatorUserId",
fieldValue: this.userId,
conditionalType: "Equal",
},
{
fieldName: "component",
fieldValue: "Grid",
conditionalType: "Equal",
},
{
fieldName: "page",
fieldValue: window.location.pathname,
conditionalType: "Equal",
},
],
pageSize: 1,
};
this.$api.post(`${window.systemUrl}/config/list`, query).then((r) => {
if (r.success) {
if (r.result.length == 1) {
this.userConfig = r.result[0];
this.columnInit();
}
if (!this.configLoad) {
this.easySearch();
}
this.configLoad = true;
}
});
},
sortChange(column, key, order) {
this.search.sortBy = key;
this.search.isDesc = order == "desc";
this.search.pageIndex = 1;
this.load();
},
saveUserconfig() {
let url = `${window.systemUrl}/config/update`;
var content = [];
this.columnsCur.map((u) => {
content.push({
key: u.key,
hide: u.hide,
});
});
if (!this.userConfig) {
url = `${window.systemUrl}/config/create`;
var data = {
page: window.location.pathname,
component: "Grid",
key: this.$u.guid(),
content: JSON.stringify(content),
};
this.$api.post(url, data).then((r) => {
this.loadUserConfig();
});
} else {
this.userConfig.content = JSON.stringify(content);
this.$api.post(url, this.userConfig);
}
},
//展开
expand(row, status) {
this.$emit("on-expand", row, status);
},
//拖拽
onDragDrop(a, b) {
this.$emit("on-drag-drop", a, b);
},
easySearch() {
if (
this.conditions &&
this.conditions.keys &&
this.conditions.keys.default
) {
//判断没有传入条件的用默认的查询
this.conditions.keys.value = this.keys;
}
this.reload(this.conditions);
},
undoConfig() {
//列设置恢复初始化
this.columnsCur = this.$u.clone(this.columns);
this.saveUserconfig();
},
complexSearch() {
var search = this.$refs.search.$children.filter((u) => {
return u.condition;
});
if (search) {
var conditions = search[0].condition;
this.reload(conditions);
}
},
reload(conditions) {
var where = [];
this.searchConditions = 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" && Array.isArray(v)) {
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 && Array.isArray(v)) {
v = v.join(",");
}
if (!this.$u.isNull(v)) {
where.push({
fieldName: u,
fieldValue: v,
conditionalType: op,
});
}
}
});
}
this.search.pageIndex = 1;
this.search.conditions = where;
this.load();
},
pageChange(page) {
this.search.page = page;
this.search.pageIndex = page;
this.load();
},
pageSizeChange(size) {
this.search.pageSize = size;
this.search.pageIndex = 1;
this.load();
},
columnChange(item, i) {
item.hide = !item.hide;
this.$set(this.columnsCur, item, i);
this.saveUserconfig();
},
selectionChange(items) {
this.$emit("on-selection-change", items);
this.selectItems = items;
this.footerToolbar = items.length > 0;
},
onSelect(rows, row) {
this.$emit("on-change", rows, row);
},
allChange(items) {
this.$emit("all-change", items);
},
intY() {
if (this.$refs.table != undefined) {
this.firstY = this.$refs.table.$el.getBoundingClientRect().top;
}
},
selectAll(status) {
this.$refs.table.selectAll(status);
},
//获取所有用户信息
getAllUser() {
this.$api
.post(`${systemUrl}/user/paged`, {
conditions: [],
pageIndex: 1,
pageSize: 100000,
})
.then((r) => {
if (r.success) {
let tempUserInfo = r.result.items;
tempUserInfo.forEach((ele) => {
let temObj = {
userId: ele.id,
name: ele.userName,
};
this.allUser.push(temObj);
});
}
});
},
getUserName(id) {
let name = "";
this.allUser.forEach((ele) => {
if (id == ele.userId) {
name = ele.name;
}
});
return name;
},
//批量取消
cancelBatch() {
this.footerToolbar = false;
this.$refs.table.selectAll(false);
},
//导出excel
export2Excel() {
//当前显示数据
var where = [];
var conditions = this.searchConditions;
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 && Array.isArray(v)) {
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 tempCol1 = []; //存放物料相关表头
var tempCol2 = []; //存放工艺规程相关表头
var tempColUser = []; //存放type=user的表头
var columnsCur = this.$u.clone(this.columnsCur); //导出列标题信息griddata this.$refs.grid.columnsCur
columnsCur.forEach((el) => {
if (
(el.hide && el.import) ||
(!el.hide &&
el.key != "action" &&
el.type != "selection" &&
el.key != "ico")
) {
if (el.code) {
tempCol.push({
key: el.key,
code: el.code,
}); //临时存放code数据字典的字段及对应的数据字典code
}
if (el.materialKey) {
tempCol1.push({
key: el.key,
code: el.materialKey,
}); //临时存放物料管理大类和子类列表
}
if (el.techKey) {
tempCol2.push({
key: el.key,
code: el.techKey,
}); //临时存放工艺规程相关转换
}
if (el.type && el.type == "user") {
tempColUser.push({
key: el.key,
code: el.type,
}); //临时存放user列
}
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]
// );
// });
tempCol.forEach((elem) => {
if (e[elem.key] && e[elem.key] != "" && e[elem.key] != null) {
//如果数据字典项对应的DirName字段存在,通过name查询到对应的code,然后赋值。
let codeArr = [];
let keyValue = e[elem.key];
if (
keyValue.length > 0 &&
(keyValue.indexOf(",") > -1 || keyValue.indexOf(",") > -1)
) {
//如果对应的数据包含多个数据字典项,比如包含“,”或“,”
if (keyValue.indexOf(",") > -1) {
codeArr = keyValue.split(",");
}
if (keyValue.indexOf > -1) {
codeArr = keyValue.split(",");
}
}
if (codeArr.length <= 1) {
//对应的数据包含一个数据字典项
e[elem.key] = this.$u.dirName(
this.$store.getters.dictionaryByKey(elem.code),
e[elem.key]
);
} else {
//对应的数据包含多个数据字典项
let codeInfo = "";
codeArr.forEach((el) => {
codeInfo =
codeInfo +
this.$u.dirName(
this.$store.getters.dictionaryByKey(elem.code),
el
) +
",";
});
e[elem.key] = codeInfo.substr(0, codeInfo.length - 1);
}
}
});
//导出数据增加对应的物料管理信息 code: 1【rootCategoryId 大类】 2【categoryId 大类】 3【codeRuleId 编码名称】
tempCol1.forEach((elcol1) => {
if (elcol1.code == 1) {
e[elcol1.key] = this.getType1(e[elcol1.key]);
} else if (elcol1.code == 2) {
e[elcol1.key] = this.getType2(e[elcol1.key]);
} else if (elcol1.code == 3) {
e[elcol1.key] = this.getType3(e[elcol1.key]);
}
});
//导出工艺规程相关转换表头信息
tempCol2.forEach((elcol2) => {
if (elcol2.code == 1) {
e[elcol2.key] = this.getRoutingHeaderName(e[elcol2.key]);
}
});
//导出username相关信息
tempColUser.forEach((eluser) => {
if (e[eluser.key] && e[eluser.key] != "" && e[eluser.key] != null) {
e[eluser.key] = this.getUserName(e[eluser.key]);
}
});
});
let nowDate = this.$u.getNowTime(); //年月日时分秒yyyyMMddhhmmss
//获取导出数据结束
this.$u.outExcel(
this.exportTitle + "(" + nowDate + ")",
tHeader,
filterVal,
list
);
});
},
//物料大类和子类的解析start
getTreeData() {
let data = {
conditions: [],
};
this.$api.post(`${material}/category/list`, data).then((r) => {
this.treeData = r.result;
});
},
getType1(val) {
let tempTreeList = this.$u.clone(this.treeData);
let rootName = "";
tempTreeList.forEach((ele) => {
if (ele.upId == 0 && ele.id == val) {
rootName = ele.name;
}
});
return rootName;
},
getType2(val) {
let tempTreeList = this.$u.clone(this.treeData);
let childrenName = "";
tempTreeList.forEach((ele) => {
if (ele.upId > 0 && ele.id == val) {
childrenName = ele.name;
}
});
return childrenName;
},
//获取编码名称
getcodeRuleData() {
let data = {
conditions: [],
};
this.$api.post(`${material}/coderule/paged`, data).then((r) => {
if (r.success) {
this.codeRuleData = r.result.items || [];
}
});
},
getType3(val) {
let codeRuleDataList = this.$u.clone(this.codeRuleData);
let codeRuleName = "";
codeRuleDataList.forEach((ele) => {
if (ele.id == val) {
codeRuleName = ele.name;
}
});
return codeRuleName;
},
//物料大类和子类的解析end
//工艺规程的解析start
//获取工艺规程名称
getRoutingHeaderData() {
let data = {
conditions: [],
};
this.$api.post(`${technologyUrl}routingheader/list`, data).then((r) => {
if (r.success) {
this.routingHeaderData = r.result || [];
}
});
},
getRoutingHeaderName(val) {
let routingHeaderDataList = this.$u.clone(this.routingHeaderData);
let routingHeaderName = "";
routingHeaderDataList.forEach((ele) => {
if (ele.id == val) {
routingHeaderName = ele.name;
}
});
return routingHeaderName;
},
//工艺规程的解析end
},
computed: {
columnsNow() {
var cols = this.columnsCur.filter((u) => {
if (u.code) {
u.render = (h, params) => {
let values = u.key;
let type = "text";
if (u.category) {
type = u.category;
}
return h("state", {
props: {
code: u.code,
type: type,
value: params.row[values] + "",
},
});
};
}
if (u.type == "user") {
u.render = (h, params) => {
let values = u.key;
if (params.row[values]) {
return h("User", {
props: {
value: params.row[values],
},
});
}
};
}
if (u.type == "workShopName") {
u.render = (h, params) => {
let values = u.key;
if (params.row[values]) {
return h("WorkShopName", {
props: {
value: params.row[values],
},
});
}
};
}
if (u.type == "date" || u.type == "dateTime") {
u.render = (h, params) => {
let values = u.key;
return h("DTSpan", {
props: {
type: u.type,
value: params.row[values],
},
});
};
}
return !u.hide;
});
return cols;
},
},
watch: {
data() {
this.list = this.data;
},
height() {
this.tableHeight = this.height;
},
columns() {
this.columns.forEach((u) => {
if (!u.hide) {
u.hide = false;
}
});
this.columnsCur = this.$u.clone(this.columns);
},
},
};
</script>
<style lang="less">
@import "../../assets/css/custom.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;
.zan-wu {
height: 600px;
line-height: 600px;
text-align: center;
}
}
.table-tools {
display: flex;
line-height: 50px;
background: @right-header-bg;
.table-search {
flex-grow: 1;
}
.btns {
min-width: 200px;
text-align: right;
}
}
.table-footer {
line-height: 45px;
}
.ivu-footer-toolbar {
text-align: left;
background: rgba(0, 0, 0, 0.7);
color: #fff;
}
}
.table-columns {
max-height: calc(100% - 50px);
overflow: auto;
li {
list-style: none;
line-height: 40px;
cursor: move;
border-bottom: 1px dotted #249e91;
color: #249e91;
span {
cursor: pointer;
}
.mr10 {
cursor: pointer;
}
.move {
float: right;
margin: 10px 10px 0 0;
cursor: move;
}
.dis {
color: #aaa;
}
}
}
.searchBack {
display: inline;
margin-left: 20px;
button {
margin-left: 10px;
}
a {
margin-left: 20px;
color: #2680eb;
}
a:hover {
color: #249e91;
}
}
</style>
...@@ -1137,6 +1137,8 @@ export default { ...@@ -1137,6 +1137,8 @@ export default {
multipleEquip: "是否多台安排设备", // 否 是 multipleEquip: "是否多台安排设备", // 否 是
multipleEquipIds: "设备id", //用英文逗号分隔 multipleEquipIds: "设备id", //用英文逗号分隔
discrete: '离散值', discrete: '离散值',
routingHeaderCode:'工艺编号',
routingHeaderName:'工艺名称',
}, },
routing_header: { routing_header: {
id: '', id: '',
......
<template> <template>
<div style="padding: 0;" class="excute"> <div style="padding: 0" class="excute">
<DataGrid style="margin-top:2px; margin-bottom: -5px;" :columns="columns" ref="grid" :easy="false" :high="false" :set="false" :border="false" :data="data1" :height="gridHeight" :page="false" :size="size"></DataGrid> <DataGrid
style="margin-top: 2px; margin-bottom: -5px"
:columns="columns"
ref="grid"
:easy="false"
:high="false"
:set="false"
:border="false"
:data="data1"
:height="gridHeight"
:page="false"
:size="size"
></DataGrid>
<Modal v-model="editModal" title="编辑" footer-hide width="1000"> <Modal v-model="editModal" title="编辑" footer-hide width="1000">
<Edit :row="rowData" @on-close="cancel" @on-option-ok="addOk" /> <Edit :row="rowData" @on-close="cancel" @on-option-ok="addOk" />
</Modal> </Modal>
<Modal v-model="insertlModal" :title="insertTItle" @on-ok="insertOk" @on-cancel="cancel"> <Modal
<p>确定进行 {{ insertTItle }} 操作?</p> v-model="insertlModal"
:title="insertTItle"
@on-ok="insertOk"
@on-cancel="cancel"
>
<p>确定进行 {{ insertTItle }} 操作?</p>
</Modal> </Modal>
<Modal v-model="setParsModal" title="工序参数设置" footer-hide width="1000"> <Modal v-model="setParsModal" title="工序参数设置" footer-hide width="1000">
<Add @on-parameter-ok="addOk" @on-close="cancel" :opTaskPk="setParams.opTaskPk" :partTaskPk="setParams.partTaskPk" :taskSeq="setParams.taskSeq" :count="setParams.count" :row="rowData" /> <Add
@on-parameter-ok="addOk"
@on-close="cancel"
:opTaskPk="setParams.opTaskPk"
:partTaskPk="setParams.partTaskPk"
:taskSeq="setParams.taskSeq"
:count="setParams.count"
:row="rowData"
/>
</Modal> </Modal>
</div> </div>
</template> </template>
<script> <script>
...@@ -18,534 +43,554 @@ import Api from "../api"; ...@@ -18,534 +43,554 @@ import Api from "../api";
import Edit from "./edit"; import Edit from "./edit";
import Add from "../options"; import Add from "../options";
export default { export default {
name: "list", name: "list",
components: { components: {
Edit, Edit,
Add Add,
},
props: {
rowId: {
type: Number,
}, },
props: { },
rowId: { data() {
type: Number return {
action: Api.index,
easySearch: {
keys: {
op: "task_seq",
value: null,
},
},
setParsModal: false,
editModal: false,
detailModal: false,
insertlModal: false,
rowIndex: null,
curId: 0,
gridHeight: 150,
size: "small",
columns: [
{
title: " ",
width: 130,
},
{
key: "insert_flag",
title: this.l("insert_flag"),
align: "center",
high: true,
width: 60,
render: (h, params) => {
return h(
"Tooltip",
{
props: {
content:
params.row.insert_flag == 1 ? "取消插单" : "进行插单",
placement: "top",
},
class: "ico",
},
[
h("Icon", {
attrs: {
type:
params.row.insert_flag == 1
? "ios-flag"
: "ios-flag-outline",
size: 20,
color: params.row.insert_flag == 1 ? "#2680EB" : "#aaa",
},
on: {
click: () =>
this.changeFlag(params.row.op_task_pk, params.index),
},
}),
]
);
},
},
{
key: "task_seq",
title: this.l("task_seq"),
align: "left",
easy: true,
high: true,
},
{
key: "op_task_pk",
title: this.l("op_task_pk"),
align: "left",
high: true,
hide: true,
},
{
key: "task_name",
title: this.l("task_name"),
align: "left",
easy: true,
high: true,
hide: true,
},
{
key: "taskseq_des",
title: this.l("task_name"),
align: "left",
easy: true,
high: true,
},
{
key: "part_task_pk",
title: this.l("part_task_pk"),
align: "left",
high: true,
hide: true,
},
{
key: "routingHeaderCode",
title: this.l("routingHeaderCode"),
align: "left",
easy: true,
high: true,
},
{
key: "routingHeaderName",
title: this.l("routingHeaderName"),
align: "left",
easy: true,
high: true,
},
{
key: "put_into_qty",
title: this.l("put_into_qty"),
align: "left",
high: true,
hide: true,
},
{
key: "plan_start",
title: this.l("plan_start"),
align: "center",
high: true,
width: 140,
hide: true,
},
{
key: "plan_finish",
title: this.l("plan_finish"),
align: "center",
high: true,
width: 140,
hide: true,
},
{
key: "firsT_EQUIP_CODE",
title: this.l("first_equip"),
align: "left",
// render: (h, params) => { //test:PCZYBZBH_20200804_1 params.row.firsT_EQUIP_CODE
// return h("span", {}, this.getResourceName(params.row.firsT_EQUIP_CODE))
// }
},
{
key: "setup_time",
title: this.l("setup_time"),
align: "right",
high: true,
type: "outputTime",
},
{
key: "run_time",
title: this.l("run_time"),
align: "right",
high: true,
type: "outputTime",
},
{
key: "outside_time",
title: this.l("outside_time"),
align: "right",
high: true,
type: "outputTime",
},
{
key: "transport_time",
title: this.l("transport_time"),
align: "right",
high: true,
hide: true,
type: "outputTime",
},
{
key: "check_time",
title: this.l("check_time"),
align: "right",
high: true,
hide: true,
type: "outputTime",
},
{
key: "efficiency_value",
title: this.l("efficiency_value"),
align: "right",
high: true,
},
{
key: "machine_rule",
title: this.l("machine_rule"),
align: "center",
easy: true,
high: true,
width: 140,
},
{
key: "singleout",
title: this.l("singleout"),
align: "left",
high: true,
hide: true,
},
{
key: "equip_type",
title: this.l("equip_type"),
align: "left",
easy: true,
high: true,
},
{
key: "first_equip",
title: this.l("first_equip"),
align: "left",
easy: true,
high: true,
hide: true,
},
{
key: "cal_id",
title: this.l("cal_id"),
align: "left",
easy: true,
high: true,
},
{
key: "plan_method",
title: this.l("plan_method"),
align: "left",
easy: true,
high: true,
},
{
key: "over_time",
title: this.l("over_time"),
align: "left",
easy: true,
high: true,
},
{
key: "isdiscrete",
title: this.l("isdiscrete"),
align: "center",
easy: true,
high: true,
},
{
key: "discrete_value",
title: this.l("discrete_value"),
align: "right",
high: true,
},
{
key: "multi_machine",
title: this.l("multi_machine"),
align: "center",
easy: true,
high: true,
},
{
key: "notes",
title: this.l("notes"),
align: "left",
easy: true,
high: true,
hide: true,
},
{
key: "workshopcode",
title: this.l("workshopcode"),
align: "left",
easy: true,
high: true,
hide: true,
},
{
key: "routing_detail_id",
title: this.l("routing_detail_id"),
align: "left",
high: true,
hide: true,
},
{
key: "routing_header_id",
title: this.l("routing_header_id"),
align: "left",
high: true,
hide: true,
},
{
key: "comb_param",
title: this.l("comb_param"),
align: "left",
easy: true,
high: true,
hide: true,
},
{
key: "rule_qty",
title: this.l("rule_qty"),
align: "left",
high: true,
hide: true,
},
{
title: "操作",
key: "action",
width: 140,
align: "center",
render: (h, params) => {
return h(
"div",
{
class: "action",
},
[
h("op", {
attrs: {
icon: "md-options",
type: "icon",
oprate: "detail",
title: "工序参数设置",
},
on: {
click: () => this.openParms(params.row),
},
}),
h("op", {
attrs: {
icon: "md-create",
type: "icon",
title: "編輯工序",
oprate: "edit",
},
on: {
click: () => this.edit(params.row),
},
}),
h("op", {
attrs: {
icon: "ios-trash",
type: "icon",
title: "删除工序",
oprate: "delete",
msg: "确认要刪除工序吗?",
},
on: {
click: () => this.remove(params.row, params.index),
},
}),
]
);
},
},
],
data1: [],
insertTItle: "插单",
selectRoutingDetail: {}, //需那种工序
//设置参数开始
setParams: {
opTaskPk: 0, //工单ID
partTaskPk: 0, //生产计划ID
taskSeq: "", //工序编号
count: 0, //生产计划数量
},
//设置参数结束
rowData: {}, //编辑时传入行数据
resources: [],
types: [],
};
},
mounted() {
this.loadData(this.rowId);
},
async fetch({ store, params }) {
await store.dispatch("loadDictionary"); // 加载数据字典
},
created() {
this.types = this.$store.getters.dictionaryByKey("aps.resource.type");
this.getResource();
},
methods: {
//根据点击副组件传过来id进行加载数据
loadData(expendId) {
let params = {
id: expendId,
};
Api.getbyorderid(params).then((res) => {
if (res.success) {
this.gridHeight = 50;
this.gridHeight = (res.result.length + 1) * 47;
this.data1 = res.result;
} }
});
}, },
data() {
return {
action: Api.index,
easySearch: {
keys: {
op: "task_seq",
value: null
}
},
setParsModal: false,
editModal: false,
detailModal: false,
insertlModal: false,
rowIndex: null,
curId: 0,
gridHeight: 150,
size: "small",
columns: [{
title: " ",
width: 130
},
{
key: "insert_flag",
title: this.l("insert_flag"),
align: "center",
high: true,
width: 60,
render: (h, params) => {
return h(
"Tooltip", {
props: {
content: params.row.insert_flag == 1 ? "取消插单" : "进行插单",
placement: "top"
},
class: "ico"
},
[
h("Icon", {
attrs: {
type: params.row.insert_flag == 1 ?
"ios-flag" : "ios-flag-outline",
size: 20,
color: params.row.insert_flag == 1 ? "#2680EB" : "#aaa"
},
on: {
click: () =>
this.changeFlag(params.row.op_task_pk, params.index)
}
})
]
);
}
},
{
key: "task_seq",
title: this.l("task_seq"),
align: "left",
easy: true,
high: true
},
{
key: "op_task_pk",
title: this.l("op_task_pk"),
align: "left",
high: true,
hide: true
},
{
key: "task_name",
title: this.l("task_name"),
align: "left",
easy: true,
high: true,
hide: true
},
{
key: "taskseq_des",
title: this.l("task_name"),
align: "left",
easy: true,
high: true
},
{
key: "part_task_pk",
title: this.l("part_task_pk"),
align: "left",
high: true,
hide: true
},
{
key: "put_into_qty",
title: this.l("put_into_qty"),
align: "left",
high: true,
hide: true
},
{
key: "plan_start",
title: this.l("plan_start"),
align: "center",
high: true,
width: 140,
hide: true
},
{
key: "plan_finish",
title: this.l("plan_finish"),
align: "center",
high: true,
width: 140,
hide: true
},
{
key: "firsT_EQUIP_CODE",
title: this.l("first_equip"),
align: "left",
// render: (h, params) => { //test:PCZYBZBH_20200804_1 params.row.firsT_EQUIP_CODE
// return h("span", {}, this.getResourceName(params.row.firsT_EQUIP_CODE))
// }
},
{
key: "setup_time",
title: this.l("setup_time"),
align: "right",
high: true,
type: "outputTime"
},
{
key: "run_time",
title: this.l("run_time"),
align: "right",
high: true,
type: "outputTime"
},
{
key: "outside_time",
title: this.l("outside_time"),
align: "right",
high: true,
type: "outputTime"
},
{
key: "transport_time",
title: this.l("transport_time"),
align: "right",
high: true,
hide: true,
type: "outputTime"
},
{
key: "check_time",
title: this.l("check_time"),
align: "right",
high: true,
hide: true,
type: "outputTime"
},
{
key: "efficiency_value",
title: this.l("efficiency_value"),
align: "right",
high: true
},
{
key: "machine_rule",
title: this.l("machine_rule"),
align: "center",
easy: true,
high: true,
width: 140
},
{
key: "singleout",
title: this.l("singleout"),
align: "left",
high: true,
hide: true
},
{
key: "equip_type",
title: this.l("equip_type"),
align: "left",
easy: true,
high: true
},
{
key: "first_equip",
title: this.l("first_equip"),
align: "left",
easy: true,
high: true,
hide: true
},
{
key: "cal_id",
title: this.l("cal_id"),
align: "left",
easy: true,
high: true
},
{
key: "plan_method",
title: this.l("plan_method"),
align: "left",
easy: true,
high: true
},
{
key: "over_time",
title: this.l("over_time"),
align: "left",
easy: true,
high: true
},
{
key: "isdiscrete",
title: this.l("isdiscrete"),
align: "center",
easy: true,
high: true
},
{
key: "discrete_value",
title: this.l("discrete_value"),
align: "right",
high: true
},
{
key: "multi_machine",
title: this.l("multi_machine"),
align: "center",
easy: true,
high: true
},
{
key: "notes",
title: this.l("notes"),
align: "left",
easy: true,
high: true,
hide: true
},
{ //插单事件start----
key: "workshopcode", changeFlag(id, index) {
title: this.l("workshopcode"), this.rowIndex = index;
align: "left", if (this.data1[this.rowIndex].insert_flag == 1) {
easy: true, this.insertTItle = "取消插单";
high: true, } else {
hide: true this.insertTItle = "插单";
}, }
{ this.insertlModal = true;
key: "routing_detail_id",
title: this.l("routing_detail_id"),
align: "left",
high: true,
hide: true
},
{
key: "routing_header_id",
title: this.l("routing_header_id"),
align: "left",
high: true,
hide: true
},
{
key: "comb_param",
title: this.l("comb_param"),
align: "left",
easy: true,
high: true,
hide: true
},
{
key: "rule_qty",
title: this.l("rule_qty"),
align: "left",
high: true,
hide: true
},
{
title: "操作",
key: "action",
width: 140,
align: "center",
render: (h, params) => {
return h("div", {
class: "action"
}, [
h("op", {
attrs: {
icon: "md-options",
type: "icon",
oprate: "detail",
title: "工序参数设置"
},
on: {
click: () => this.openParms(params.row)
}
}),
h("op", {
attrs: {
icon: "md-create",
type: "icon",
title: "編輯工序",
oprate: "edit"
},
on: {
click: () => this.edit(params.row)
}
}),
h("op", {
attrs: {
icon: "ios-trash",
type: "icon",
title: "删除工序",
oprate: "delete",
msg: "确认要刪除工序吗?"
},
on: {
click: () => this.remove(params.row, params.index)
}
})
]);
}
}
],
data1: [],
insertTItle: "插单",
selectRoutingDetail: {}, //需那种工序
//设置参数开始
setParams: {
opTaskPk: 0, //工单ID
partTaskPk: 0, //生产计划ID
taskSeq: "", //工序编号
count: 0 //生产计划数量
},
//设置参数结束
rowData: {}, //编辑时传入行数据
resources: [],
types: [],
};
}, },
mounted() { insertOk() {
this.loadData(this.rowId); //this.loadData(this.row)
}, if (this.data1[this.rowIndex].insert_flag == 1) {
async fetch({ //根据插单数据状态进行插单或取消插单操作
store, let params1 = {
params partTaskPks: [],
}) { opTaskPks: [this.data1[this.rowIndex].op_task_pk],
await store.dispatch("loadDictionary"); // 加载数据字典 };
}, Api.cancelinsertorder(params1)
created() { .then((res) => {
this.types = this.$store.getters.dictionaryByKey("aps.resource.type"); if (res.success) {
this.getResource(); this.$Message.success("取消插单成功!");
}, this.data1[this.rowIndex].insert_flag = 0;
methods: {
//根据点击副组件传过来id进行加载数据
loadData(expendId) {
let params = {
id: expendId
};
Api.getbyorderid(params).then(res => {
if (res.success) {
this.gridHeight = 50;
this.gridHeight = (res.result.length + 1) * 47;
this.data1 = res.result;
}
});
},
//插单事件start----
changeFlag(id, index) {
this.rowIndex = index;
if (this.data1[this.rowIndex].insert_flag == 1) {
this.insertTItle = "取消插单";
} else { } else {
this.insertTItle = "插单"; this.$Message.error("取消插单失败!");
} }
this.insertlModal = true; })
}, .catch((err) => {
insertOk() { this.$Message.error("数据异常!");
//this.loadData(this.row) });
if (this.data1[this.rowIndex].insert_flag == 1) { } else {
//根据插单数据状态进行插单或取消插单操作 let params = {
let params1 = { partTaskPks: [],
partTaskPks: [], opTaskPks: [this.data1[this.rowIndex].op_task_pk],
opTaskPks: [this.data1[this.rowIndex].op_task_pk] };
}; Api.saveinsertorder(params)
Api.cancelinsertorder(params1) .then((res) => {
.then(res => { if (res.success) {
if (res.success) { this.$Message.success("插单成功!");
this.$Message.success("取消插单成功!"); this.data1[this.rowIndex].insert_flag = 1;
this.data1[this.rowIndex].insert_flag = 0;
} else {
this.$Message.error("取消插单失败!");
}
})
.catch(err => {
this.$Message.error("数据异常!");
});
} else { } else {
let params = { this.$Message.error("插单失败!");
partTaskPks: [],
opTaskPks: [this.data1[this.rowIndex].op_task_pk]
};
Api.saveinsertorder(params)
.then(res => {
if (res.success) {
this.$Message.success("插单成功!");
this.data1[this.rowIndex].insert_flag = 1;
} else {
this.$Message.error("插单失败!");
}
})
.catch(err => {
this.$Message.error("数据异常!");
});
} }
this.setParsModal = false; })
this.detailModal = false; .catch((err) => {
this.editModal = false; this.$Message.error("数据异常!");
this.insertlModal = false; });
}, }
//插单事件end---- this.setParsModal = false;
this.detailModal = false;
this.editModal = false;
this.insertlModal = false;
},
//插单事件end----
//单个工序进行参设置start---- //单个工序进行参设置start----
openParms(row) { openParms(row) {
this.setParams = { this.setParams = {
opTaskPk: row.op_task_pk, opTaskPk: row.op_task_pk,
partTaskPk: row.part_task_pk, partTaskPk: row.part_task_pk,
taskSeq: row.task_seq, taskSeq: row.task_seq,
count: row.put_into_qty count: row.put_into_qty,
}; };
this.rowData = row; this.rowData = row;
this.setParsModal = true; this.setParsModal = true;
}, },
//单个工序进行参数设置end---- //单个工序进行参数设置end----
//编辑工序start---- //编辑工序start----
edit(row) { edit(row) {
this.rowData = row; this.rowData = row;
this.editModal = true; this.editModal = true;
}, },
//编辑工序end---- //编辑工序end----
//删除工序事件start----- //删除工序事件start-----
remove(row, index) { remove(row, index) {
//this.curId = Number(id); //this.curId = Number(id);
this.rowIndex = index; this.rowIndex = index;
this.selectRoutingDetail = row; this.selectRoutingDetail = row;
let params = { let params = {
partPk: this.selectRoutingDetail.part_task_pk, partPk: this.selectRoutingDetail.part_task_pk,
detailIdstr: this.selectRoutingDetail.routing_detail_id detailIdstr: this.selectRoutingDetail.routing_detail_id,
}; };
Api.removeoptasksimluate(params).then(r => { Api.removeoptasksimluate(params).then((r) => {
if (r.success) { if (r.success) {
this.$Message.success("删除成功"); this.$Message.success("删除成功");
this.data1.splice(this.rowIndex, 1); this.data1.splice(this.rowIndex, 1);
}
});
},
addOk() {
this.data1 = [];
this.loadData(this.rowId);
this.setParsModal = false;
this.editModal = false;
},
//删除工序时间end-----
cancel() {
this.curId = 0;
this.setParsModal = false;
this.detailModal = false;
this.editModal = false;
this.deletedlModal = false;
this.insertlModal = false;
},
//根据firsT_EQUIP_CODE返回对应的首选资源
getResourceName(code) {
let name = ""
let resources = this.$u.clone(this.resources);
if (code && code != '') {
resources.forEach(e => {
if (e.code == code) {
let type = e.type
this.types.forEach(el => {
if (type && type != '' && el.code == e.type) {
name = el.name + "/" + e.title
}
})
}
})
}
return name;
},
//获取首选资源所有的数据
getResource() {
let url = `${systemUrl}/planresource/list`;
let name = ""
this.$api
.post(url, {
pageSize: 2000
})
.then(r => {
this.resources = r.result;
});
},
l(key) {
let vkey = "mes_op_task_plan_simulate" + "." + key;
return this.$t(vkey) || key;
} }
} });
},
addOk() {
this.data1 = [];
this.loadData(this.rowId);
this.setParsModal = false;
this.editModal = false;
},
//删除工序时间end-----
cancel() {
this.curId = 0;
this.setParsModal = false;
this.detailModal = false;
this.editModal = false;
this.deletedlModal = false;
this.insertlModal = false;
},
//根据firsT_EQUIP_CODE返回对应的首选资源
getResourceName(code) {
let name = "";
let resources = this.$u.clone(this.resources);
if (code && code != "") {
resources.forEach((e) => {
if (e.code == code) {
let type = e.type;
this.types.forEach((el) => {
if (type && type != "" && el.code == e.type) {
name = el.name + "/" + e.title;
}
});
}
});
}
return name;
},
//获取首选资源所有的数据
getResource() {
let url = `${systemUrl}/planresource/list`;
let name = "";
this.$api
.post(url, {
pageSize: 2000,
})
.then((r) => {
this.resources = r.result;
});
},
l(key) {
let vkey = "mes_op_task_plan_simulate" + "." + key;
return this.$t(vkey) || key;
},
},
}; };
</script> </script>
<style lang="less"> <style lang="less">
.excute table tr th span, .excute table tr th span,
.excute table tr td { .excute table tr td {
font-size: 10px; font-size: 10px;
} }
</style> </style>
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