Commit d87fcd76 authored by renjintao's avatar renjintao

部门导入page

parent b8520f72
<template> <template>
<div class="table-content myBug"> <div class="table-content">
<div class="table-tools" v-if="tool"> <div class="table-tools" v-if="tool">
<div class="table-search" v-if="easy"> <div class="table-search">
<slot name="easySearch"> <slot name="easySearch" v-if="easy">
<Input <Form inline>
search <FormItem>
enter-button <Input search enter-button :placeholder="placeholder" @on-search="easySearch" v-width="300" v-model="keys" />
:placeholder="placeholder" </FormItem>
@on-search="easySearch" <FormItem>
v-model="keys" <Button v-if="high" @click="modalSearch=true" type="text">
/> <Icon type="md-search" />高级
</slot> </Button>
</div>&nbsp; </FormItem>
<Button v-if="high" @click="modalSearch=true" type="text"> </Form>
<Icon type="md-search" />高级 </slot>
</Button> </div>
<div class="searchBack">
<slot name="searchBack"></slot> <div class="searchBack">
</div> <slot name="searchBack"></slot>
<div class="btns"> </div>
<slot name="buttons"></slot> <div class="btns">
<Button v-if="set&&type=='table'" @click="config=!config"> <slot name="buttons"></slot>
<Icon type="md-build" class="table-set" size="14" title="列设置" /> <Button @click="export2Excel" v-if="exportTitle.length>0">导出</Button>
</Button> <Button v-if="set&&type=='table'" @click="config=!config">
</div> <Icon type="md-build" title="列设置" />
</Button>
</div>
</div> </div>
<div v-if="type=='card'" class="table-card"> <div class="table-main" ref="main">
<Row> <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>
</Row> </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" :row-key="rowKey" stripe></Table>
</div> </div>
<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"
></Table>
<div class="table-footer"> <div class="table-footer">
<div>
<slot name="footer"></slot> <slot name="footer"></slot>
</div>&nbsp; <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" />
<Page
v-if="page"
:total="search.total"
:current="search.page"
class="mr15 mt5 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 v-if="high" v-model="modalSearch" title="高级搜索" draggable width="800" ref="search"> <Modal v-if="high" v-model="modalSearch" title="高级搜索" draggable width="800" ref="search">
<slot name="searchForm"></slot> <slot name="searchForm"></slot>
<div slot="footer"> <div slot="footer">
<Button @click="modalSearch=false" style="margin-left:20px;">取消</Button> <Button @click="modalSearch=false" style="margin-left:20px;">取消</Button>
<Button @click="complexSearch" type="primary" style="margin-left:10px;">查询</Button> <Button @click="complexSearch" type="primary" style="margin-left:10px;">查询</Button>
</div> </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 style="height:65px" v-if="batch" v-show="footerToolbar">
<div class="tip">
已选{{selectItems.length}}
<slot name="batch"></slot>
</div>
<Button @click="footerToolbar=false">取消</Button> <FooterToolbar v-if="batch" v-show="footerToolbar" class="ftball">
<div class="tip">已选{{selectItems.length}}</div>
<slot name="batch"></slot>
<Button @click="cancelBatch">取消</Button>
</FooterToolbar> </FooterToolbar>
</div> </div>
</template> </template>
<script> <script>
export default { export default {
name: "DataGrid", name: "DataGrid",
data() { data() {
return {
keys: "",
selectItems: [],
footerToolbar: false,
modalSearch: false,
search: {
pageIndex: 1,
pageSize: 20,
conditions: [],
},
pageSizeOpts: [20, 50, 100],
tableHeight: 0,
firstY: 0,
config: false,
list: [],
columnsCur: [],
configLoad: false,
userConfig: null, //用户页面配置信息。,
// userId: 1
userId: this.$store.state.userInfo.userId,
};
},
props: {
border: {
//是否显示边框
type: Boolean,
default: true,
},
batch: {
//是否批量操作
type: Boolean,
default: true,
},
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: { op: "name", value: "", default: true }, keys: "",
selectItems: [],
footerToolbar: false,
modalSearch: false,
search: {
pageIndex: 1,
pageSize: 20,
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: [], //工艺规程
}; };
},
},
type: {
type: String,
default: "table",
validator: function (value) {
// 这个值必须匹配下列字符串中的一个
return ["table", "card", "list"].indexOf(value) !== -1;
},
}, },
span: { props: {
type: Number, border: {
default: 24, //是否显示边框
}, type: Boolean,
}, default: true,
created() { },
this.columns.forEach((u) => { batch: {
if (!u.hide) { //是否批量操作
u.hide = false; type: Boolean,
} default: true,
}); },
this.columnsCur = this.$u.clone(this.columns); format: {
}, type: Function,
mounted() { default: null,
if (this.data && this.data.length > 0) { },
this.list = this.data; initsearch: {
return; type: Function,
} default: null,
this.keys = ""; },
this.intY(); lazy: {
if (this.lazy == true) { //懒加载设置,设置为真时候,默认不加载数据。
return; type: Boolean,
} default: false,
if (this.set == true) { },
this.loadUserConfig(); placeholder: {
} type: String,
// else default: "请输入关键字",
// { },
// this.columnsCur = this.$u.clone(this.columns); height: {
// } type: Number,
if (this.height === 0) { default: 0,
window.onresize = () => { },
///浏览器窗口大小变化 tool: {
return (() => { //是否显示工具栏
window.screenHeight = window.innerHeight; type: Boolean,
this.tableHeight = window.screenHeight - this.firstY - 60; default: true,
})(); },
}; easy: {
} else { //是否显示简单搜索
this.tableHeight = this.height; type: Boolean,
} default: true,
//注册拖拽事件。 },
this.$dragging.$on("dragend", (e) => { high: {
// console.log("dragend",e); //是否显示高级搜索
this.saveUserconfig(); type: Boolean,
}); default: true,
}, },
methods: { draggable: {
//数据加载 //是否可以拖拽
load() { type: Boolean,
if (this.height == 0) { default: false,
this.tableHeight = window.innerHeight - this.firstY - 60; },
} set: {
if (this.action) { //是否显示列设置
this.$api.post(this.action, this.search).then((r) => { type: Boolean,
this.list = r.result.items; default: true,
this.search.total = r.result.totalCount; },
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: "",
},
},
created() {
this.columns.forEach((u) => {
if (!u.hide) {
u.hide = false;
}
}); });
} this.columnsCur = this.$u.clone(this.columns);
}, },
columnInit() { mounted() {
if (this.userConfig) { if (this.data && this.data.length > 0) {
var curColumns = []; this.list = this.data;
var config = JSON.parse(this.userConfig.content); return;
// console.warn("2:列比对",config)
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]);
}
});
// console.warn("3:初始化列")
this.columnsCur = curColumns;
} }
} this.keys = "";
}, this.intY();
loadUserConfig() { if (this.lazy == true) {
var query = { return;
conditions: [ }
{ if (this.userId > 0 && this.set) {
fieldName: "creatorUserId", this.loadUserConfig();
fieldValue: this.userId, } else {
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];
// console.warn("1:加载用户配置")
this.columnInit();
}
if (!this.configLoad) {
this.easySearch(); this.easySearch();
}
this.configLoad = true;
} }
}); if (this.height === 0) {
}, this.$nextTick(() => {
saveUserconfig() { this.tableHeight = this.$refs.main.offsetHeight;
let url = `${window.systemUrl}/config/update`; if (this.tableHeight < 300) {
var content = []; this.tableHeight =
this.columnsCur.map((u) => { window.screen.availHeight - this.$refs.main.offsetTop - 200;
content.push({ }
key: u.key, window.onresize = () => {
hide: u.hide, ///浏览器窗口大小变化
}); return (() => {
}); if (this.$refs.main && this.$refs.main.offsetHeight) {
if (!this.userConfig) { this.tableHeight = this.$refs.main.offsetHeight;
url = `${window.systemUrl}/config/create`; if (this.tableHeight < 300) {
var data = { this.tableHeight =
page: window.location.pathname, window.screen.availHeight - this.$refs.main.offsetTop - 150;
component: "Grid", }
key: this.$u.guid(), }
content: JSON.stringify(content), })();
}; };
this.$api.post(url, data).then((r) => { });
this.loadUserConfig(); } else {
this.tableHeight = this.height;
}
//注册拖拽事件。
this.$dragging.$on("dragend", (e) => {
this.saveUserconfig();
}); });
} else { //物料加载类型数据
this.userConfig.content = JSON.stringify(content); //this.getTreeData();
this.$api.post(url, this.userConfig); //this.getcodeRuleData();
} //this.getRoutingHeaderData();
}, },
//展开 methods: {
expand(row, status) { //数据加载
this.$emit("on-expand", row, status); load() {
}, if (this.action) {
//拖拽 //条件初始化处理。
onDragDrop(a, b) { if (this.initsearch) {
this.$emit("on-drag-drop", a, b); this.initsearch(this.search);
},
easySearch() {
if (this.conditions && 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 = [];
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));
} }
}); this.$api.post(this.action, this.search).then((r) => {
v = times.join(","); if (this.format) {
} else if (op.indexOf("In") > -1) { 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,
});
} }
} },
}); columnInit() {
} if (this.userConfig) {
this.search.pageIndex = 1; var curColumns = [];
this.search.conditions = where; var config = JSON.parse(this.userConfig.content);
this.load(); if (config.length == this.columnsCur.length) {
}, config.map((u) => {
pageChange(page) { var item = this.columnsCur.filter((c) => {
this.search.page = page; return c.key == u.key;
this.search.pageIndex = page; });
this.load(); if (item[0]) {
}, item[0].hide = u.hide;
pageSizeChange(size) { curColumns.push(item[0]);
this.search.pageSize = size; }
this.search.pageIndex = 1; });
this.load(); this.columnsCur = curColumns;
}, }
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-selection-change", rows, row);
},
intY() {
if (this.$refs.table != undefined) {
this.firstY = this.$refs.table.$el.getBoundingClientRect().top;
}
},
selectAll(status) {
this.$refs.table.selectAll(status);
},
},
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: { loadUserConfig() {
code: u.code, var query = {
type: type, conditions: [{
value: params.row[values] + "", 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;
}
}); });
}; },
} saveUserconfig() {
if (u.type == "user") { let url = `${window.systemUrl}/config/update`;
u.render = (h, params) => { var content = [];
let values = u.key; this.columnsCur.map((u) => {
return h("User", { content.push({
props: { key: u.key,
value: params.row[values], hide: u.hide,
}, });
}); });
}; if (!this.userConfig) {
} url = `${window.systemUrl}/config/create`;
if (u.type == "date" || u.type == "dateTime") { var data = {
u.render = (h, params) => { page: window.location.pathname,
let values = u.key; component: "Grid",
return h("DTSpan", { key: this.$u.guid(),
props: { content: JSON.stringify(content),
type: u.type, };
value: params.row[values], 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;
return !u.hide; this.reload(conditions);
}); }
return cols; },
}, reload(conditions) {
}, var where = [];
watch: { this.searchConditions = conditions;
"data.length"() { if (conditions) {
this.list = this.data; 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);
},
//批量取消
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 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
}
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.exportTitle + "(" + nowDate + ")",
tHeader,
filterVal,
list
);
});
},
}, },
height() { computed: {
this.tableHeight = this.height; 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>
<style lang="less" scoped> <style lang="less">
.table-content { .table-content {
position: relative; position: relative;
// height: 100%; height: 100%;
.tableCommon { display: flex;
width: 100%; flex-direction: column;
}
.tip { .tip {
display: inline; display: inline;
} }
.tableCommon tr th {
line-height: 30px;
font-size: 14px;
background: #f5f6fa;
}
.tableCommon tr td { form {
line-height: 25px; display: inline-block;
font-size: 14px;
padding: 0 2px;
}
.tableCommon tr td .ivu-table-cell { .ivu-form-item {
padding: 0 5px; margin: 0;
} vertical-align: middle;
.table-card { }
width: 100%;
text-align: left;
padding: 0;
display: block;
overflow-y: auto;
}
.table-tools {
.table-search {
float: left;
line-height: 40px;
} }
.btns {
float: right; .table-main {
line-height: 40px; 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-set { .table-tools {
cursor: pointer; display: flex;
} line-height: 50px;
.table-set:hover { //background: @right-header-bg;
color: orange;
} .table-search {
// .table-footer { flex-grow: 1;
// line-height: 40px; }
// }
} .btns {
.table-columns { min-width: 200px;
max-height: calc(100% - 50px); text-align: right;
overflow: auto; }
li {
list-style: none;
line-height: 40px;
cursor: move;
border-bottom: 1px dotted #249e91;
color: #249e91;
span {
cursor: pointer;
} }
.mr10 {
cursor: pointer; .table-footer {
line-height: 45px;
} }
.move {
float: right; .ivu-footer-toolbar {
margin: 10px 10px 0 0; text-align: left;
cursor: move; background: rgba(0, 0, 0, 0.7);
color: #fff;
} }
.dis { }
color: #aaa;
.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 { .searchBack {
display: inline; display: inline;
margin-left: 20px;
button {
margin-left: 10px;
}
a {
margin-left: 20px; margin-left: 20px;
color: #2680eb;
} button {
a:hover { margin-left: 10px;
color: #249e91; }
}
a {
margin-left: 20px;
color: #2680eb;
}
a:hover {
color: #249e91;
}
} }
</style> </style>
\ No newline at end of file
...@@ -152,12 +152,23 @@ export default { ...@@ -152,12 +152,23 @@ export default {
//重新处理colum //重新处理colum
loadColum(columns) { loadColum(columns) {
let tempCol = this.$u.clone(columns); let tempCol = this.$u.clone(columns);
let doCol = []
tempCol.forEach((ele, index) => { tempCol.forEach((ele, index) => {
if (ele.key == "action" || ele.type == "selection" || ele.key == "ico") { if (ele.key == "action" || ele.type == "selection" || ele.key == "ico") {
ele.hide = true; ele.hide = true;
} }
if (ele.import) {
ele.hide = false
}
let temColObj = {
key: ele.key,
title: ele.title,
align: ele.align ? ele.align : 'left',
hide: ele.hide ? ele.hide : false,
}
doCol.push(temColObj)
}); });
this.colsIm = tempCol; this.colsIm = doCol;
this.colsIm.unshift({ this.colsIm.unshift({
type: 'index', type: 'index',
width: 80, width: 80,
...@@ -350,6 +361,9 @@ export default { ...@@ -350,6 +361,9 @@ export default {
let imData = []; let imData = [];
let imDataError = [] let imDataError = []
this.dataIm.forEach(ele => { this.dataIm.forEach(ele => {
if (ele.parent_Id && ele.parentTitle) { //部门管理导入暂时处置
ele.parent_Id = null
}
if (!ele.ico) { if (!ele.ico) {
imData.push(ele) imData.push(ele)
} else { } else {
......
...@@ -432,6 +432,7 @@ export default { ...@@ -432,6 +432,7 @@ export default {
location:'省市县', location:'省市县',
parent_Id:'上级部门', parent_Id:'上级部门',
property:'属性', property:'属性',
parentTitle:'上级部门'
}, },
instance: { instance: {
id: '主键', id: '主键',
......
...@@ -164,7 +164,7 @@ henq.getDepartAllName = (list,id) => { ...@@ -164,7 +164,7 @@ henq.getDepartAllName = (list,id) => {
list.map(u => { list.map(u => {
if(id==u.id) if(id==u.id)
{ {
names=u.name+"-"+names names=u.name+"/"+names
if (u.parent_Id>0) { if (u.parent_Id>0) {
getDepartAllName(list, u.parent_Id) getDepartAllName(list, u.parent_Id)
} }
......
...@@ -71,6 +71,11 @@ export default { ...@@ -71,6 +71,11 @@ export default {
aId: 0, aId: 0,
rowData: null, rowData: null,
columns: [{ columns: [{
key: "name",
title: this.l("name"),
align: "left",
},
{
key: "parent_Id", key: "parent_Id",
title: this.l("parent_Id"), title: this.l("parent_Id"),
align: "left", align: "left",
...@@ -83,11 +88,6 @@ export default { ...@@ -83,11 +88,6 @@ export default {
) )
} }
}, },
{
key: "name",
title: this.l("name"),
align: "left",
},
{ {
key: "code", key: "code",
title: this.l("code"), title: this.l("code"),
...@@ -101,7 +101,7 @@ export default { ...@@ -101,7 +101,7 @@ export default {
import: true, import: true,
render: (h, params) => { render: (h, params) => {
return h("span", {}, return h("span", {},
this.getCity(params.row.location ? params.row.location : 0)) this.getCityName(params.row.location ? params.row.location : 0))
} }
}, },
{ {
...@@ -277,7 +277,7 @@ export default { ...@@ -277,7 +277,7 @@ export default {
}) })
}, },
//根据value获取当前cityname //根据value获取当前cityname
getCity(val) { getCityName(val) {
let cities = this.$u.clone(this.cityDatas) let cities = this.$u.clone(this.cityDatas)
let label = ""; let label = "";
cities.forEach(ele => { cities.forEach(ele => {
...@@ -287,12 +287,32 @@ export default { ...@@ -287,12 +287,32 @@ export default {
}) })
return label return label
}, },
//根据Id获取上级到本级的部门名称 getCityValue(val) {
let cities = this.$u.clone(this.cityDatas)
let value = "";
cities.forEach(ele => {
if (val == ele.label) {
value = ele.value
}
})
return value
},
//根据Id获取上级的部门名称
getParentDepart(val) { getParentDepart(val) {
let departList = this.$u.clone(this.treeList) let departList = this.$u.clone(this.treeList)
return this.$u.getDepartAllName(departList, val) return this.$u.getDepartAllName(departList, val)
}, },
//根据名称获取上级部门的ID
getParentDepartName(val) {
let departList = this.$u.clone(this.treeList)
let value = null
departList.forEach(ele => {
if (val == ele.name) {
value = ele.id
}
})
return value
},
ok() { ok() {
this.init(); this.init();
this.modal = false; this.modal = false;
...@@ -340,7 +360,7 @@ export default { ...@@ -340,7 +360,7 @@ export default {
); );
}); });
tempCol1.forEach((ele1) => { tempCol1.forEach((ele1) => {
e[ele1.key] = this.getCity(e[ele1.key]); e[ele1.key] = this.getCityName(e[ele1.key]);
}); });
tempCol2.forEach((ele2) => { tempCol2.forEach((ele2) => {
e[ele2.key] = this.getParentDepart(e[ele2.key]); e[ele2.key] = this.getParentDepart(e[ele2.key]);
...@@ -374,12 +394,12 @@ export default { ...@@ -374,12 +394,12 @@ export default {
let tempList = []; let tempList = [];
tempData.forEach((ele) => { tempData.forEach((ele) => {
let obj = { let obj = {
parentTitle: ele.parentTitle ? ele.parentTitle : '', parentTitle: ele.parent_Id ? ele.parent_Id : '',
name: ele.name ? ele.name : '', //部门名称 name: ele.name ? ele.name : '', //部门名称
parent_Id: ele.parent_Id ? ele.parent_Id : 0, //上级部门 [id] parent_Id: ele.parent_Id ? ele.parent_Id : '', //上级部门 [id]
code: ele.code ? ele.code : '', //部门编号 code: ele.code ? ele.code : '', //部门编号
location: ele.location ? ele.location : '', //省市县 location: ele.location ? this.getCityValue(ele.location) : '', //省市县
isProduction: 1, //是否生产班组:1是,0否 isProduction: 0, //是否生产班组:1是,0否
property: ele.property ? ele.property : '' //属性 property: ele.property ? ele.property : '' //属性
}; };
if (ele.name && ele.name != '') { if (ele.name && ele.name != '') {
......
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