Commit a3f9bc47 authored by renjintao's avatar renjintao

workhourManage detail\indx\zh-cn\datagrid...

parent 925dc4cf
<template> <template>
<div class="table-content"> <div class="table-content">
<div class="table-tools" v-if="tool"> <div class="table-tools" v-if="tool">
<div class="table-search"> <div class="table-search">
<slot name="easySearch" v-if="easy"> <slot name="easySearch" v-if="easy">
<Form inline> <Form inline>
<FormItem> <FormItem>
<Input <Input search enter-button :placeholder="placeholder" @on-search="easySearch" v-width="300" v-model="keys" />
search </FormItem>
enter-button <FormItem>
:placeholder="placeholder" <Button v-if="high" @click="modalSearch = true" type="text">
@on-search="easySearch" <Icon type="md-search" />高级
v-width="300" </Button>
v-model="keys" </FormItem>
/> </Form>
</FormItem> </slot>
<FormItem> </div>
<Button v-if="high" @click="modalSearch = true" type="text">
<Icon type="md-search" />高级
</Button>
</FormItem>
</Form>
</slot>
</div>
<div class="searchBack"> <div class="searchBack">
<slot name="searchBack"></slot> <slot name="searchBack"></slot>
</div> </div>
<div class="btns"> <div class="btns">
<slot name="buttons"></slot> <slot name="buttons"></slot>
<Button @click="export2Excel" v-if="exportTitle.length > 0" <Button @click="export2Excel" v-if="exportTitle.length > 0">导出</Button>
>导出</Button <Button v-if="set && type == 'table'" @click="config = !config">
> <Icon type="md-build" title="列设置" />
<Button v-if="set && type == 'table'" @click="config = !config"> </Button>
<Icon type="md-build" title="列设置" /> </div>
</Button>
</div>
</div> </div>
<div class="table-main" ref="main"> <div class="table-main" ref="main">
<Row v-if="type == 'card'" :gutter="40"> <Row v-if="type == 'card'" :gutter="40">
<Col :span="span" v-for="(row, i) in list" :key="i"> <Col :span="span" v-for="(row, i) in list" :key="i">
<slot name="card" :row="row"> <slot name="card" :row="row">
<span>{{ row.id }}</span> <span>{{ row.id }}</span>
</slot> </slot>
</Col> </Col>
<Col v-if="list.length == 0" span="24" class="zan-wu"> <Col v-if="list.length == 0" span="24" class="zan-wu">
<h4>暂无数据</h4> <h4>暂无数据</h4>
</Col> </Col>
</Row> </Row>
<Table <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>
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>
<div class="table-footer"> <div class="table-footer">
<slot name="footer"></slot> <slot name="footer"></slot>
<Page <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" />
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> </div>
<Modal <Modal v-if="high" v-model="modalSearch" title="高级搜索" draggable width="800" ref="search">
v-if="high" <slot name="searchForm"></slot>
v-model="modalSearch" <div slot="footer">
title="高级搜索" <Button @click="modalSearch = false" style="margin-left: 20px">取消</Button>
draggable <Button @click="complexSearch" type="primary" style="margin-left: 10px">查询</Button>
width="800" </div>
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> </Modal>
<Drawer <Drawer title="列设置" v-if="set" v-model="config" :scrollable="true" placement="left" :mask="false">
title="列设置" <div slot="header">
v-if="set" 列设置
v-model="config" <a @click="undoConfig" class="ml50">
:scrollable="true" <Icon type="md-refresh" title="恢复初始设置" />
placement="left" </a>
:mask="false" </div>
> <ul class="table-columns">
<div slot="header"> <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 }">
<a @click="undoConfig" class="ml50"> <Icon :type="li.hide ? 'md-eye-off' : 'md-eye'" size="16" class="mr10" />
<Icon type="md-refresh" title="恢复初始设置" /> <span>{{ li.title }}</span>
</a> </label>
</div> <Icon type="ios-move" class="move" size="18" />
<ul class="table-columns"> </li>
<li </ul>
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> </Drawer>
<FooterToolbar v-if="batch" v-show="footerToolbar" class="ftball"> <FooterToolbar v-if="batch" v-show="footerToolbar" class="ftball">
<div class="tip">已选{{ selectItems.length }}</div> <div class="tip">已选{{ selectItems.length }}</div>
<slot name="batch"></slot> <slot name="batch"></slot>
<Button @click="cancelBatch">取消</Button> <Button @click="cancelBatch">取消</Button>
</FooterToolbar> </FooterToolbar>
</div> </div>
</template> </template>
<script> <script>
import ColumnSlot from "./treeGrid/columnSolt"; import ColumnSlot from "./treeGrid/columnSolt";
export default { export default {
name: "DataGrid", name: "DataGrid",
components: { ColumnSlot }, components: {
data() { ColumnSlot
return {
keys: "",
selectItems: [],
footerToolbar: false,
modalSearch: false,
search: {
pageIndex: 1,
pageSize: 20,
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: { data() {
//是否批量操作
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 { return {
keys: { keys: "",
op: "name", selectItems: [],
value: "", footerToolbar: false,
default: true, 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
}; };
},
},
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: "",
}, },
}, props: {
provide() { border: {
return { //是否显示边框
tableRoot: this.slots, type: Boolean,
}; default: true,
}, },
created() { batch: {
this.initColumns(); //是否批量操作
}, type: Boolean,
mounted() { default: true,
},
if (this.data && this.data.length > 0) { format: {
this.list = this.data; type: Function,
return; default: null,
} },
this.keys = ""; initsearch: {
this.intY(); type: Function,
if (this.lazy == true) { default: null,
return; },
} lazy: {
if (this.userId > 0 && this.set) { //懒加载设置,设置为真时候,默认不加载数据。
this.loadUserConfig(); type: Boolean,
} else { default: false,
this.easySearch(); },
} placeholder: {
if (this.height === 0) { type: String,
this.$nextTick(() => { default: "请输入关键字",
this.tableHeight = this.$refs.main.offsetHeight; },
if (this.tableHeight < 300) { height: {
this.tableHeight = type: Number,
window.screen.availHeight - this.$refs.main.offsetTop - 200; default: 0,
} },
window.onresize = () => { tool: {
///浏览器窗口大小变化 //是否显示工具栏
return (() => { type: Boolean,
if (this.$refs.main && this.$refs.main.offsetHeight) { default: true,
this.tableHeight = this.$refs.main.offsetHeight; },
if (this.tableHeight < 300) { easy: {
this.tableHeight = //是否显示简单搜索
window.screen.availHeight - this.$refs.main.offsetTop - 150; 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,
}; };
});
} 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() { created() {
this.columns.forEach((u) => { this.initColumns();
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);
}, },
//数据加载 mounted() {
load() {
if (this.action) { if (this.data && this.data.length > 0) {
//条件初始化处理。 this.list = this.data;
if (this.initsearch) { return;
this.initsearch(this.search);
} }
this.$api.post(this.action, this.search).then((r) => { this.keys = "";
if (this.format) { this.intY();
this.list = this.format(r.result.items); if (this.lazy == true) {
} else { return;
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;
} }
} if (this.userId > 0 && this.set) {
}, this.loadUserConfig();
loadUserConfig() { } else {
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.easySearch();
}
this.configLoad = true;
} }
}); if (this.height === 0) {
}, this.$nextTick(() => {
sortChange(column, key, order) { this.tableHeight = this.$refs.main.offsetHeight;
this.search.sortBy = key; if (this.tableHeight < 300) {
this.search.isDesc = order == "desc"; this.tableHeight =
this.search.pageIndex = 1; window.screen.availHeight - this.$refs.main.offsetTop - 200;
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));
} }
}); window.onresize = () => {
v = times.join(","); ///浏览器窗口大小变化
} else if (op.indexOf("In") > -1 && Array.isArray(v)) { return (() => {
v = v.join(","); if (this.$refs.main && this.$refs.main.offsetHeight) {
} this.tableHeight = this.$refs.main.offsetHeight;
if (!this.$u.isNull(v)) { if (this.tableHeight < 300) {
where.push({ this.tableHeight =
fieldName: u, window.screen.availHeight - this.$refs.main.offsetTop - 150;
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);
}); });
} } else {
}); this.tableHeight = this.height;
},
getUserName(id) {
let name = "";
this.allUser.forEach((ele) => {
if (id == ele.userId) {
name = ele.name;
} }
}); //注册拖拽事件。
return name; this.$dragging.$on("dragend", (e) => {
this.saveUserconfig();
});
//物料加载类型数据
this.getTreeData();
this.getcodeRuleData();
this.getRoutingHeaderData();
this.getAllUser(); //获取所有用户
}, },
//批量取消 methods: {
cancelBatch() { //列初始化 slot 支持;
this.footerToolbar = false; slots() {
this.$refs.table.selectAll(false); return this.$scopedSlots;
}, },
initColumns() {
this.columns.forEach((u) => {
if (!u.hide) {
u.hide = false;
}
});
//导出excel var items = this.$u.clone(this.columns);
export2Excel() { // var soct=this.$scopedSlots;
//当前显示数据 // // console.warn("that.$scopedSlots()",soct["action"]());
var where = []; // items.forEach((u) => {
var conditions = this.searchConditions; // if (u.slot) {
if (conditions) { // u.render = (h, params) => {
Object.keys(conditions).forEach((u) => { // return h(
let v = conditions[u].value; // "span",
let op = conditions[u].op; // // soct[u.slot]({
if (!this.$u.isNull(v)) { // // row: params.row,
if (op == "Range") { // // column: params.column,
let times = []; // // index: params.index,
v.map((u) => { // // })
if (!this.$u.isNull(u)) { // params.row.id
times.push(this.$u.toTime(u)); // );
// };
// 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) => {
v = times.join(","); if (this.format) {
} else if (op.indexOf("In") > -1 && Array.isArray(v)) { this.list = this.format(r.result.items);
v = v.join(","); } else {
} this.list = r.result.items;
if (!this.$u.isNull(v)) { }
where.push({ this.search.total = r.result.totalCount || r.result.count;
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); columnInit() {
filterVal.push(el.key); if (this.userConfig) {
} var curColumns = [];
}); var config = JSON.parse(this.userConfig.content);
list.forEach((e) => { if (config.length == this.columnsCur.length) {
//给导出数据增加数据字典对应的name config.map((u) => {
// tempCol.forEach((ele) => { var item = this.columnsCur.filter((c) => {
// e[ele.key] = this.$u.dirName( return c.key == u.key;
// this.$store.getters.dictionaryByKey(ele.code), });
// e[ele.key] if (item[0]) {
// ); item[0].hide = u.hide;
// }); curColumns.push(item[0]);
tempCol.forEach((elem) => { }
if (e[elem.key] && e[elem.key] != "" && e[elem.key] != null) { });
//如果数据字典项对应的DirName字段存在,通过name查询到对应的code,然后赋值。 this.columnsCur = curColumns;
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(","); },
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;
} }
} });
if (codeArr.length <= 1) { },
//对应的数据包含一个数据字典项 sortChange(column, key, order) {
e[elem.key] = this.$u.dirName( this.search.sortBy = key;
this.$store.getters.dictionaryByKey(elem.code), this.search.isDesc = order == "desc";
e[elem.key] this.search.pageIndex = 1;
); this.load();
} else { },
//对应的数据包含多个数据字典项 saveUserconfig() {
let codeInfo = ""; let url = `${window.systemUrl}/config/update`;
codeArr.forEach((el) => { var content = [];
codeInfo = this.columnsCur.map((u) => {
codeInfo + content.push({
this.$u.dirName( key: u.key,
this.$store.getters.dictionaryByKey(elem.code), hide: u.hide,
el });
) + });
","; 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();
}); });
e[elem.key] = codeInfo.substr(0, codeInfo.length - 1); } else {
} this.userConfig.content = JSON.stringify(content);
this.$api.post(url, this.userConfig);
} }
}); },
//导出数据增加对应的物料管理信息 code: 1【rootCategoryId 大类】 2【categoryId 大类】 3【codeRuleId 编码名称】 //展开
tempCol1.forEach((elcol1) => { expand(row, status) {
if (elcol1.code == 1) { this.$emit("on-expand", row, status);
e[elcol1.key] = this.getType1(e[elcol1.key]); },
} else if (elcol1.code == 2) { //拖拽
e[elcol1.key] = this.getType2(e[elcol1.key]); onDragDrop(a, b) {
} else if (elcol1.code == 3) { this.$emit("on-drag-drop", a, b);
e[elcol1.key] = this.getType3(e[elcol1.key]); },
easySearch() {
if (
this.conditions &&
this.conditions.keys &&
this.conditions.keys.default
) {
//判断没有传入条件的用默认的查询
this.conditions.keys.value = this.keys;
} }
}); this.reload(this.conditions);
//导出工艺规程相关转换表头信息 },
tempCol2.forEach((elcol2) => { undoConfig() {
if (elcol2.code == 1) { //列设置恢复初始化
e[elcol2.key] = this.getRoutingHeaderName(e[elcol2.key]); 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);
} }
}); },
//导出username相关信息 reload(conditions) {
tempColUser.forEach((eluser) => { var where = [];
if (e[eluser.key] && e[eluser.key] != "" && e[eluser.key] != null) { this.searchConditions = conditions;
e[eluser.key] = this.getUserName(e[eluser.key]); 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();
let nowDate = this.$u.getNowTime(); //年月日时分秒yyyyMMddhhmmss },
//获取导出数据结束 pageChange(page) {
this.$u.outExcel( this.search.page = page;
this.exportTitle + "(" + nowDate + ")", this.search.pageIndex = page;
tHeader, this.load();
filterVal, },
list pageSizeChange(size) {
); this.search.pageSize = size;
}); this.search.pageIndex = 1;
}, this.load();
//物料大类和子类的解析start },
getTreeData() { columnChange(item, i) {
let data = { item.hide = !item.hide;
conditions: [], this.$set(this.columnsCur, item, i);
}; this.saveUserconfig();
this.$api.post(`${material}/category/list`, data).then((r) => { },
this.treeData = r.result; selectionChange(items) {
}); this.$emit("on-selection-change", items);
}, this.selectItems = items;
getType1(val) { this.footerToolbar = items.length > 0;
let tempTreeList = this.$u.clone(this.treeData); },
let rootName = ""; onSelect(rows, row) {
tempTreeList.forEach((ele) => { this.$emit("on-change", rows, row);
if (ele.upId == 0 && ele.id == val) { },
rootName = ele.name; allChange(items) {
} this.$emit("all-change", items);
}); },
return rootName; intY() {
}, if (this.$refs.table != undefined) {
getType2(val) { this.firstY = this.$refs.table.$el.getBoundingClientRect().top;
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: { selectAll(status) {
code: u.code, this.$refs.table.selectAll(status);
type: type, },
value: params.row[values] + "", //获取所有用户信息
}, 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;
} },
if (u.type == "user") {
u.render = (h, params) => { //批量取消
let values = u.key; cancelBatch() {
if (params.row[values]) { this.footerToolbar = false;
return h("User", { this.$refs.table.selectAll(false);
props: { },
value: params.row[values],
}, //导出excel
}); export2Excel() {
} //当前显示数据
}; var where = [];
} var conditions = this.searchConditions;
if (u.type == "workShopName") { if (conditions) {
u.render = (h, params) => { Object.keys(conditions).forEach((u) => {
let values = u.key; let v = conditions[u].value;
if (params.row[values]) { let op = conditions[u].op;
return h("WorkShopName", { if (!this.$u.isNull(v)) {
props: { if (op == "Range") {
value: params.row[values], 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,
if (u.type == "date" || u.type == "dateTime") { conditions: where,
u.render = (h, params) => { pageSize: 1000,
let values = u.key; };
return h("DTSpan", { this.$api.post(this.action, searchs).then((r) => {
props: { let list = [];
type: u.type, list = r.result.items;
value: params.row[values], 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
return !u.hide; getTreeData() {
}); let data = {
return cols; conditions: [],
}, };
}, this.$api.post(`${material}/category/list`, data).then((r) => {
watch: { this.treeData = r.result;
data() { });
this.list = this.data; },
}, getType1(val) {
height() { let tempTreeList = this.$u.clone(this.treeData);
this.tableHeight = this.height; let rootName = "";
}, tempTreeList.forEach((ele) => {
columns() { if (ele.upId == 0 && ele.id == val) {
this.columns.forEach((u) => { rootName = ele.name;
if (!u.hide) { }
u.hide = false; });
} return rootName;
}); },
this.columnsCur = this.$u.clone(this.columns); 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> </script>
...@@ -946,116 +882,117 @@ export default { ...@@ -946,116 +882,117 @@ export default {
@import "../../assets/css/custom.less"; @import "../../assets/css/custom.less";
.table-content { .table-content {
position: relative; position: relative;
height: 100%; height: 100%;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
.tip { .tip {
display: inline; display: inline;
} }
form { form {
display: inline-block; display: inline-block;
.ivu-form-item { .ivu-form-item {
margin: 0; margin: 0;
vertical-align: middle; vertical-align: middle;
}
} }
}
.table-main { .table-main {
width: 100%; width: 100%;
text-align: left; text-align: left;
padding: 0; padding: 0;
display: block; display: block;
overflow-y: auto; overflow-y: auto;
flex-grow: 1; flex-grow: 1;
tr td .ivu-table-cell { tr td .ivu-table-cell {
padding: 0 5px; padding: 0 5px;
} }
overflow-x: hidden; overflow-x: hidden;
.zan-wu {
height: 600px; .zan-wu {
line-height: 600px; height: 600px;
text-align: center; line-height: 600px;
text-align: center;
}
} }
}
.table-tools { .table-tools {
display: flex; display: flex;
line-height: 50px; line-height: 50px;
background: @right-header-bg; background: @right-header-bg;
.table-search { .table-search {
flex-grow: 1; flex-grow: 1;
} }
.btns { .btns {
min-width: 200px; min-width: 200px;
text-align: right; text-align: right;
}
} }
}
.table-footer { .table-footer {
line-height: 45px; line-height: 45px;
} }
.ivu-footer-toolbar { .ivu-footer-toolbar {
text-align: left; text-align: left;
background: rgba(0, 0, 0, 0.7); background: rgba(0, 0, 0, 0.7);
color: #fff; color: #fff;
} }
} }
.table-columns { .table-columns {
max-height: calc(100% - 50px); max-height: calc(100% - 50px);
overflow: auto; overflow: auto;
li { li {
list-style: none; list-style: none;
line-height: 40px; line-height: 40px;
cursor: move; cursor: move;
border-bottom: 1px dotted #249e91; border-bottom: 1px dotted #249e91;
color: #249e91; color: #249e91;
span { span {
cursor: pointer; cursor: pointer;
} }
.mr10 { .mr10 {
cursor: pointer; cursor: pointer;
} }
.move { .move {
float: right; float: right;
margin: 10px 10px 0 0; margin: 10px 10px 0 0;
cursor: move; cursor: move;
} }
.dis { .dis {
color: #aaa; color: #aaa;
}
} }
}
} }
.searchBack { .searchBack {
display: inline; display: inline;
margin-left: 20px; margin-left: 20px;
button { button {
margin-left: 10px; margin-left: 10px;
} }
a { a {
margin-left: 20px; margin-left: 20px;
color: #2680eb; color: #2680eb;
} }
a:hover { a:hover {
color: #249e91; color: #249e91;
} }
} }
</style> </style>
...@@ -2155,5 +2155,19 @@ document_category: { ...@@ -2155,5 +2155,19 @@ document_category: {
template: '模板', template: '模板',
attachment: '附件', attachment: '附件',
type: '模版类型', type: '模版类型',
},
workHour: {
userTitle: '员工姓名',
userCardNo: '员工编号',
totalWorkHour: '工时数量',
planQuantity: '计划数量',
qualified: '合格数量',
action: '操作',
mesCode: '订单编号',
productName: '产品名称',
drawnNumber: '产品图号',
routingDetailSeq: '工序号',
routingDetailName: '工序名称',
workHour: '工时数量',
} }
} }
\ No newline at end of file
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<div class="detail"> <div class="detail">
<DataGrid :columns="columns" ref="grid" :data="data" :set="false"> <DataGrid :columns="columns" ref="grid" :data="data" :set="false">
<template slot="easySearch"> <template slot="easySearch">
<p class="pl10">用户姓名:<span class="mr20">{{entity.name}}</span>用户编号:<span class="mr20">{{entity.id}}</span>工时数量:<span class="mr20">{{entity.creatorUserId}}</span>计划数量:<span class="mr20">{{entity.creatorUserId}}</span>合格数量:<span class="mr20">{{entity.creatorUserId}}</span></p> <p class="pl10">{{this.l('userTitle')}}<span class="mr20">{{entity.userTitle}}</span>{{this.l('userTitle')}}<span class="mr20">{{entity.userCardNo}}</span>{{this.l('totalWorkHour')}}<span class="mr20">{{entity.totalWorkHour}}</span>{{this.l('planQuantity')}}<span class="mr20">{{entity.planQuantity}}</span>{{this.l('qualified')}}<span class="mr20">{{entity.qualified}}</span></p>
</template> </template>
</DataGrid> </DataGrid>
</div> </div>
...@@ -30,39 +30,36 @@ export default { ...@@ -30,39 +30,36 @@ export default {
fileUrlPath: "", fileUrlPath: "",
columns: [{ columns: [{
key: "mesCode", key: "mesCode",
title: '订单编号', title: this.l('mesCode'),
align: "left", align: "left",
easy: true,
high: true,
}, },
{ {
key: "productName", key: "productName",
title: '产品名称', title: this.l('productName'),
align: "left", align: "left",
easy: true,
high: true,
}, },
{ {
key: "drawnNumber", key: "drawnNumber",
title: '产品图号', title: this.l('drawnNumber'),
align: "left", align: "left",
easy: true,
high: true,
}, },
{ {
key: "routingDetailSeq", key: "routingDetailSeq",
title: '工序号', title: this.l('routingDetailSeq'),
align: "left", align: "right",
easy: true, width: 100,
high: true,
}, },
{ {
key: "routingDetailName", key: "routingDetailName",
title: '工序名称', title: this.l('routingDetailName'),
align: "left", align: "left",
easy: true, },
high: true, {
} key: "workHour",
title: this.l('workHour'),
align: "right",
},
], ],
data: [], data: [],
}; };
...@@ -100,6 +97,10 @@ export default { ...@@ -100,6 +97,10 @@ export default {
handleClose() { handleClose() {
this.$emit("on-close"); this.$emit("on-close");
}, },
l(key) {
let vkey = "workHour" + "." + key;
return this.$t(vkey) || key;
},
}, },
watch: { watch: {
row(v) { row(v) {
......
<template> <template>
<div class="h100"> <div class="h100">
<DataGrid :columns="columns" ref="grid" :action="action"> <DataGrid :columns="columns" ref="grid" :action="action" :conditions="easySearch">
<template slot="easySearch"> <template slot="easySearch">
<Form ref="formInline" :model="easySearch" inline> <Form ref="formInline" :model="easySearch" inline>
<FormItem prop="keys"> <FormItem prop="keys">
...@@ -35,6 +35,7 @@ export default { ...@@ -35,6 +35,7 @@ export default {
op: "userTitle,userCardNo", op: "userTitle,userCardNo",
value: null value: null
}, },
sortBy: 'totalWorkHour'
}, },
modal: false, modal: false,
full: false, full: false,
...@@ -50,41 +51,41 @@ export default { ...@@ -50,41 +51,41 @@ export default {
title: "序号", title: "序号",
}, { }, {
key: "userTitle", key: "userTitle",
title: '员工姓名', title: this.l('userTitle'),
align: "left", align: "left",
easy: true, easy: true,
high: true, high: true,
}, },
{ {
key: "userCardNo", key: "userCardNo",
title: '员工编号', title: this.l('userCardNo'),
align: "left", align: "left",
easy: true, easy: true,
high: true, high: true,
}, },
{ {
key: "totalWorkHour", key: "totalWorkHour",
title: '工时数量', title: this.l('totalWorkHour'),
align: "left", align: "left",
easy: true, easy: true,
high: true, high: true,
}, },
{ {
key: "planQuantity", key: "planQuantity",
title: '计划数量', title: this.l('planQuantity'),
align: "left", align: "left",
easy: true, easy: true,
high: true, high: true,
}, },
{ {
key: "qualified", key: "qualified",
title: '合格数量', title: this.l('qualified'),
align: "left", align: "left",
easy: true, easy: true,
high: true, high: true,
}, },
{ {
title: "操作", title: this.l("action"),
key: "action", key: "action",
width: 140, width: 140,
align: "center", align: "center",
...@@ -141,7 +142,7 @@ export default { ...@@ -141,7 +142,7 @@ export default {
this.modal = false; this.modal = false;
}, },
l(key) { l(key) {
let vkey = "import_center" + "." + key; let vkey = "workHour" + "." + key;
return this.$t(vkey) || key; return this.$t(vkey) || key;
}, },
}, },
......
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