Commit 736da3b1 authored by 骆瑛's avatar 骆瑛

页面组件化

parent 4bd186e6
export default {
name: 'ColumnSlot',
functional: true,
inject: ['tableRoot'],
props: {
row: Object,
index: Number,
column: {
type: Object,
default: null
}
},
render: (h, ctx) => {
return h('span', ctx.injections.tableRoot()[ctx.props.column.slot]({
row: ctx.props.row,
column: ctx.props.column,
index: ctx.props.index
}));
}
};
\ No newline at end of file
<template>
<div class="treeTbale">
<div class="treeTbale">
<div class="table-tools">
<div class="table-search">
<slot name="easySearch"></slot>
......@@ -14,98 +14,230 @@
<table>
<thead>
<tr>
<th v-for="(column,index) in cloneColumns" :key="index" v-if="column.hide!=true">
<th v-for="(column, index) in cloneColumns" :key="index">
<label v-if="column.type === 'selection'">
<input type="checkbox" v-model="checks" @click="handleCheckAll" />全选
<Checkbox v-model="all"></Checkbox>
</label>
<label v-else>
{{ renderHeader(column, index) }}
<span class="ivu-table-sort" v-if="column.sortable">
<Icon type="arrow-up-b" :class="{on: column._sortType === 'asc'}" @click.native="handleSort(index, 'asc')" />
<Icon type="arrow-down-b" :class="{on: column._sortType === 'desc'}" @click.native="handleSort(index, 'desc')" />
<Icon
type="arrow-up-b"
:class="{ on: column._sortType === 'asc' }"
@click.native="handleSort(index, 'asc')"
/>
<Icon
type="arrow-down-b"
:class="{ on: column._sortType === 'desc' }"
@click.native="handleSort(index, 'desc')"
/>
</span>
</label>
</th>
</tr>
</thead>
<tbody>
<tr v-for="(item,index) in initItems" :key="item.id" v-show="show(item)" class="treetr" :class="{'child-tr':item.parent}">
<td v-for="(column,snum) in columns" :key="column.key" :style="tdStyle(column)">
<!-- <label>
<input
v-if="column.type === 'selection'"
type="checkbox"
:value="item.id"
v-model="checkGroup"
@click="handleCheckClick(item,$event,index)"
/>
</label>-->
<tr
v-for="(item, index) in initItems"
:key="item.id"
v-show="show(item)"
class="treetr"
:draggable="drag"
@dragstart="dragstart($event, index, item)"
@dragover="dragover($event, index, item)"
@drop="dragdrop($event, index, item)"
>
<td
v-for="(column, snum) in columns"
:key="column.key"
:style="tdStyle(column)"
>
<!-- 多选 -->
<label v-if="column.type === 'selection'" @click="handleCheckClick(item, $event, index)">
<Checkbox v-model="item.checked" ></Checkbox>
</label>
<!-- 图标 -->
<div v-if="column.type === 'icon'">
<i class="icon-set" size="small" @click="RowClick(item,$event,index,action.text)" v-for="action in (column.actions)" :key="action.text">
<Icon :type="action.type" :title="action.text" :style="action.style" />
<i
class="icon-set"
size="small"
@click="RowClick(item, $event, index, action.text)"
v-for="action in column.actions"
:key="action.text"
>
<Icon
:type="action.type"
:title="action.text"
:style="action.style"
/>
</i>
</div>
<div v-if="column.type === 'icons'">
<Icon :type="item[column.key]" size="20" />
</div>
<state v-if="column.code" :code="column.code" :value="item[column.key]" />
<state
v-if="column.code"
:code="column.code"
:value="item[column.key]"
/>
<!-- 操作 -->
<div v-if="column.type === 'action'" class="action" style="text-align:left;">
<op v-for="action in (column.actions)" :key="action.text" @click="RowClick(item,$event,index,action.text)" :type="action.type" size="small" style=" margin:0 5px;" :class="action.text=='删除'? 'remove' : (action.text=='新增' ? 'add': (action.text=='编辑' ?'edit':''))" v-show="(item.type=='3'&&action.text=='新增')||(item.children.length>0&&action.text=='删除')?false:true">{{action.text}}</op>
<div
v-if="column.type === 'action'"
class="action"
style="text-align: left"
>
<op
v-for="action in column.actions"
:key="action.text"
@click="RowClick(item, $event, index, action.text)"
:type="action.type"
size="small"
style="margin: 0 5px"
:class="
action.text == '删除'
? 'remove'
: action.text == '新增'
? 'add'
: action.text == '编辑'
? 'edit'
: ''
"
v-show="
(item.type == '3' && action.text == '新增') ||
(item.children.length > 0 && action.text == '删除')
? false
: true
"
>{{ action.text }}</op
>
</div>
<!-- 类型 -->
<div v-if="column.type === 'menuRender'" style="text-align:center;">
<Button :ghost="item[column.key] ==0 ?false:true" size="small" :type="item[column.key] ==0 ? 'default' :item[column.key] == 1 ? 'info' :item[column.key] == 2?'error':'warning'">{{item[column.key] == 0 ? '子系统':item[column.key] == 1 ? '目录': item[column.key] == 2 ? '菜单' : '按钮'}}</Button>
<div v-if="column.type === 'menuRender'" style="text-align: center">
<Button
:ghost="item[column.key] == 0 ? false : true"
size="small"
:type="
item[column.key] == 0
? 'default'
: item[column.key] == 1
? 'info'
: item[column.key] == 2
? 'error'
: 'warning'
"
>{{
item[column.key] == 0
? "子系统"
: item[column.key] == 1
? "目录"
: item[column.key] == 2
? "菜单"
: "按钮"
}}</Button
>
</div>
<!-- 状态 -->
<div v-if="column.type === 'menuIsshow'" style="text-align:center;">
<Button :ghost="item[column.key] == 1 ? true :false" :disabled="item[column.key] == 1 ? false :true" size="small" :type="item[column.key] == 1 ? 'info' :'default'">{{item[column.key] == 1 ? '显示': '隐藏'}}</Button>
<div v-if="column.type === 'menuIsshow'" style="text-align: center">
<Button
:ghost="item[column.key] == 1 ? true : false"
:disabled="item[column.key] == 1 ? false : true"
size="small"
:type="item[column.key] == 1 ? 'info' : 'default'"
>{{ item[column.key] == 1 ? "显示" : "隐藏" }}</Button
>
</div>
<!-- 打开方式 -->
<div v-if="column.type === 'menuTarget'">
<span :style="item[column.key] == 0?'color:#006699':item[column.key] == 1?'color:black':''">{{item[column.key] == 0 ? '本页面': item[column.key] == 1?'新页面':''}}</span>
<span
:style="
item[column.key] == 0
? 'color:#006699'
: item[column.key] == 1
? 'color:black'
: ''
"
>{{
item[column.key] == 0
? "本页面"
: item[column.key] == 1
? "新页面"
: ""
}}</span
>
</div>
<!-- 菜单名称、排序、请求地址 -->
<label @click="toggle(index,item)" v-if="!column.type&&!column.code&&!column.render">
<span v-if="snum==iconRow()">
<!-- 树图标 -->
<span @click="toggle(index, item)" v-if="snum == iconRow()">
<i v-html="item.spaceHtml"></i>
<a v-if="item.children&&item.children.length>0">
<i class="ivu-icon" :class="{'ivu-icon-ios-arrow-forward':!item.expanded,'ivu-icon-ios-arrow-down':item.expanded }"></i>
</a>
<i v-else class="ms-tree-space"></i>
<a v-if="item.children && item.children.length > 0">
<i
class="ivu-icon"
:class="{
'ivu-icon-ios-arrow-forward': !item.expanded,
'ivu-icon-ios-arrow-down': item.expanded,
}"
></i> </a
><i v-else class="ms-tree-space"></i>
</span>
{{renderBody(item,column) }}
<!-- 菜单名称、排序、请求地址 -->
<label
v-if="
!column.type && !column.code && !column.render && !column.slot
"
>
{{ renderBody(item, column) }}
</label>
<table-expand v-if="column.render&&!column.type" :row="item" :column="column" :index="snum" :render="column.render"></table-expand>
<table-expand
v-if="column.render && !column.type && !column.solt"
:row="item"
:column="column"
:index="snum"
:render="column.render"
></table-expand>
<column-slot
v-if="column.slot"
:row="item"
:column="column"
:index="snum"
></column-slot>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</template>
<script>
import TableExpand from './expand'
import TableExpand from "./expand";
import ColumnSlot from "./columnSolt";
export default {
name: 'treeGrid',
components: {
TableExpand
},
name: "treeGrid",
components: { TableExpand, ColumnSlot },
props: {
columns: Array,
items: {
type: Array,
default () {
return []
default() {
return [];
},
},
iconName: false,
drag:{
type:Boolean,
default:false
},
spaceWidth:{
type:Number,
default:20
}
},
iconName: false
provide() {
return {
tableRoot: this.slots,
};
},
data() {
return {
color: '#19be6b',
color: "#19be6b",
all:true,
initItems: [], // 处理后数据数组
cloneColumns: [], // 处理后的表头数据
checkGroup: [], // 复选框数组
......@@ -113,119 +245,134 @@ export default {
screenWidth: document.body.clientWidth, // 自适应宽
tdsWidth: 0, // td总宽
timer: false, // 控制监听时长
dataLength: 0 // 树形数据长度
}
dataLength: 0, // 树形数据长度
dragIndex:-1,//拖拽开始的序号
};
},
computed: {
tableWidth() {
return this.tdsWidth > this.screenWidth && this.screenWidth > 0 ?
`${this.screenWidth}px` :
'100%'
}
return this.tdsWidth > this.screenWidth && this.screenWidth > 0
? `${this.screenWidth}px`
: "100%";
},
},
watch: {
screenWidth(val) {
if (!this.timer) {
this.screenWidth = val
this.timer = true
this.screenWidth = val;
this.timer = true;
setTimeout(() => {
this.timer = false
}, 400)
this.timer = false;
}, 400);
}
},
items() {
if (this.items) {
this.initItems = []
this.dataLength = this.Length(this.items)
this.initData(this.deepCopy(this.items), 1, null)
this.checkGroup = this.renderCheck(this.items)
this.initItems = [];
this.dataLength = this.Length(this.items);
this.initData(this.deepCopy(this.items), 1, null);
this.checkGroup = this.renderCheck(this.items);
if (this.checkGroup.length == this.dataLength) {
this.checks = true
this.checks = true;
} else {
this.checks = false
this.checks = false;
}
}
},
columns: {
handler() {
this.cloneColumns = this.makeColumns()
this.cloneColumns = this.makeColumns();
},
deep: true
deep: true,
},
checkGroup(data) {
this.checkAllGroupChange(data)
}
this.checkAllGroupChange(data);
},
},
mounted() {
console.warn("treegrid", this.$scopedSlots);
if (this.items) {
this.dataLength = this.Length(this.items)
this.initData(this.deepCopy(this.items), 1, null)
this.cloneColumns = this.makeColumns()
this.checkGroup = this.renderCheck(this.items)
this.dataLength = this.Length(this.items);
this.initData(this.deepCopy(this.items), 1, null);
this.cloneColumns = this.makeColumns();
this.checkGroup = this.renderCheck(this.items);
if (this.checkGroup.length == this.dataLength) {
this.checks = true
this.checks = true;
} else {
this.checks = false
this.checks = false;
}
}
// 绑定onresize事件 监听屏幕变化设置宽
this.$nextTick(() => {
this.screenWidth = document.body.clientWidth
})
this.screenWidth = document.body.clientWidth;
});
window.onresize = () =>
(() => {
window.screenWidth = document.body.clientWidth
this.screenWidth = window.screenWidth
})()
window.screenWidth = document.body.clientWidth;
this.screenWidth = window.screenWidth;
})();
},
methods: {
slots() {
return this.$scopedSlots;
},
//拖拽
dragstart(e,index, row ) {
this.dragIndex=index;
console.log(index)
},
dragover(e,index, row ) {
e.preventDefault();
},
dragdrop(e,index, row ) {
event.preventDefault();
this.$emit("on-drag-drop",this.dragIndex,index,this.initItems)
},
// 有无多选框折叠位置优化
iconRow() {
var num = 0;
for (let i = 0, len = this.columns.length; i < len; i++) {
if (this.columns[i].type == 'selection') {
return 1
if (this.columns[i].tree) {
num = i;
}
}
return 0
return num;
},
// 设置td宽度,td的align
tdStyle(column) {
const style = {}
const style = {};
if (column.align) {
style['text-align'] = column.align
style["text-align"] = column.align;
}
if (column.width) {
style['width'] = `${column.width}px`
style["width"] = `${column.width}px`;
}
if (column.hide == true) {
style['display'] = `none`
}
return style
return style;
},
// 排序事件
handleSort(index, type) {
this.cloneColumns.forEach((col) => (col._sortType = 'normal'))
this.cloneColumns.forEach((col) => (col._sortType = "normal"));
if (this.cloneColumns[index]._sortType === type) {
this.cloneColumns[index]._sortType = 'normal'
this.cloneColumns[index]._sortType = "normal";
} else {
this.cloneColumns[index]._sortType = type
this.cloneColumns[index]._sortType = type;
}
this.$emit(
'on-sort-change',
"on-sort-change",
this.cloneColumns[index].key,
this.cloneColumns[index]._sortType
)
);
},
// 点击某一行事件
RowClick(data, event, index, text) {
// this.iconName = true;
const result = this.makeData(data)
this.$emit('on-row-click', result, event, index, text)
const result = this.makeData(data);
this.$emit("on-row-click", result, event, index, text);
},
//点击图标
RowClickIcon(event, index, text) {
this.$emit('on-icon-click', event, index, text)
this.$emit("on-icon-click", event, index, text);
},
//修改排序
updataOrderNum(data, event, index, text) {
......@@ -233,9 +380,9 @@ export default {
// console.log(event.orderNum + "nnnnnnnn");
var data = {
id: event.id,
orderNum: event.orderNum
}
this.updata(data)
orderNum: event.orderNum,
};
this.updata(data);
},
//修改颜色
updataColor(data, event, index, text) {
......@@ -243,144 +390,140 @@ export default {
//console.log(event.color + "nnnnnnnn");
var data = {
id: event.id,
color: event.color
}
this.updata(data)
color: event.color,
};
this.updata(data);
},
//修改单个字段
updata(data) {
this.$http.dic
.dicUpdate(data)
.then((res) => {
this.$Message.success(res.msg)
this.$parent.getInfo()
this.$Message.success(res.msg);
this.$parent.getInfo();
})
.catch((error) => {
this.$Message.error(error.msg)
})
this.$Message.error(error.msg);
});
},
// 点击事件 返回数据处理
makeData(data) {
const t = this.type(data)
let o
if (t === 'array') {
o = []
} else if (t === 'object') {
o = {}
const t = this.type(data);
let o;
if (t === "array") {
o = [];
} else if (t === "object") {
o = {};
} else {
return data
return data;
}
if (t === 'array') {
if (t === "array") {
for (let i = 0; i < data.length; i++) {
o.push(this.makeData(data[i]))
o.push(this.makeData(data[i]));
}
} else if (t === 'object') {
} else if (t === "object") {
for (const i in data) {
if (
i != 'spaceHtml' &&
i != 'parent' &&
i != 'level' &&
i != 'expanded' &&
i != 'isShow' &&
i != 'load'
i != "spaceHtml" &&
i != "parent" &&
i != "level" &&
i != "expanded" &&
i != "isShow" &&
i != "load"
) {
o[i] = this.makeData(data[i])
o[i] = this.makeData(data[i]);
}
}
}
return o
return o;
},
// 处理表头数据
makeColumns() {
const columns = this.deepCopy(this.columns)
this.tdsWidth = 0
const columns = this.deepCopy(this.columns);
this.tdsWidth = 0;
columns.forEach((column, index) => {
column._index = index
column._width = column.width ? column.width : ''
column._sortType = 'normal'
this.tdsWidth += column.width ? parseFloat(column.width) : 0
})
return columns
column._index = index;
column._width = column.width ? column.width : "";
column._sortType = "normal";
this.tdsWidth += column.width ? parseFloat(column.width) : 0;
});
return columns;
},
// 数据处理 增加自定义属性监听
initData(items, level, parent) {
// this.initItems = []
let spaceHtml = ''
for (let i = 1; i < level; i++) {
spaceHtml +=
"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<i class='ms-tree-space'></i>"
}
let spaceHtml = "<i class='ms-tree-space' style='width:"+this.spaceWidth*level+"px'></i>";
items.forEach((item, index) => {
item = Object.assign({}, item, {
parent,
level,
spaceHtml
})
if (typeof item.expanded === 'undefined') {
spaceHtml,
});
if (typeof item.expanded === "undefined") {
item = Object.assign({}, item, {
expanded: true
})
expanded: true,
});
}
if (typeof item.show === 'undefined') {
if (typeof item.show === "undefined") {
item = Object.assign({}, item, {
isShow: true
})
isShow: true,
});
}
if (typeof item.isChecked === 'undefined') {
if (typeof item.isChecked === "undefined") {
item = Object.assign({}, item, {
isChecked: false
})
isChecked: false,
});
}
item = Object.assign({}, item, {
load: !!item.expanded
})
this.initItems.push(item)
load: !!item.expanded,
});
this.initItems.push(item);
if (item.children && item.expanded) {
this.initData(item.children, level + 1, item)
this.initData(item.children, level + 1, item);
}
items.splice(index, 1, item)
})
items.splice(index, 1, item);
});
},
// 隐藏显示
show(item) {
return (
item.level == 1 || (item.parent && item.parent.expanded && item.isShow)
)
);
},
toggle(index, item) {
const level = item.level + 1
let spaceHtml = ''
const level = item.level + 1;
let spaceHtml = "";
for (let i = 1; i < level; i++) {
spaceHtml += "<i class='ms-tree-space'></i>"
spaceHtml += "<i class='ms-tree-space'></i>";
}
if (item.children) {
if (item.expanded) {
item.expanded = !item.expanded
this.close(index, item)
item.expanded = !item.expanded;
this.close(index, item);
} else {
item.expanded = !item.expanded
item.expanded = !item.expanded;
if (item.load) {
this.open(index, item)
this.open(index, item);
} else {
item.load = true
item.load = true;
item.children.forEach((child, childIndex) => {
this.initItems.splice(index + childIndex + 1, 0, child)
this.initItems.splice(index + childIndex + 1, 0, child);
// 设置监听属性
this.$set(this.initItems[index + childIndex + 1], 'parent', item)
this.$set(this.initItems[index + childIndex + 1], 'level', level)
this.$set(this.initItems[index + childIndex + 1], "parent", item);
this.$set(this.initItems[index + childIndex + 1], "level", level);
this.$set(
this.initItems[index + childIndex + 1],
'spaceHtml',
"spaceHtml",
spaceHtml
)
this.$set(this.initItems[index + childIndex + 1], 'isShow', true)
);
this.$set(this.initItems[index + childIndex + 1], "isShow", true);
this.$set(
this.initItems[index + childIndex + 1],
'expanded',
"expanded",
false
)
})
);
});
}
}
}
......@@ -388,42 +531,42 @@ export default {
open(index, item) {
if (item.children) {
item.children.forEach((child, childIndex) => {
child.isShow = true
child.isShow = true;
if (child.children && child.expanded) {
this.open(index + childIndex + 1, child)
this.open(index + childIndex + 1, child);
}
})
});
}
},
close(index, item) {
if (item.children) {
item.children.forEach((child, childIndex) => {
child.isShow = false
child.expanded = false
child.isShow = false;
child.expanded = false;
if (child.children) {
this.close(index + childIndex + 1, child)
this.close(index + childIndex + 1, child);
}
})
});
}
},
// 点击check勾选框,判断是否有children节点 如果有就一并勾选
handleCheckClick(data, event, index) {
data.isChecked = !data.isChecked
const arr = data.children
data.isChecked = !data.isChecked;
const arr = data.children;
if (arr) {
if (data.isChecked) {
this.checkGroup.push(data.id)
this.checkGroup.push(data.id);
for (let i = 0; i < arr.length; i++) {
this.checkGroup.push(arr[i].id)
this.checkGroup.push(arr[i].id);
}
} else {
for (let i = 0; i < this.checkGroup.length; i++) {
if (this.checkGroup[i] == data.id) {
this.checkGroup.splice(i, 1)
this.checkGroup.splice(i, 1);
}
for (let j = 0; j < arr.length; j++) {
if (this.checkGroup[i] == arr[j].id) {
this.checkGroup.splice(i, 1)
this.checkGroup.splice(i, 1);
}
}
}
......@@ -432,159 +575,150 @@ export default {
},
// checkbox 全选 选择事件
handleCheckAll() {
this.checks = !this.checks
this.checks = !this.checks;
if (this.checks) {
this.checkGroup = this.getArray(
this.checkGroup.concat(this.All(this.items))
)
);
} else {
this.checkGroup = []
this.checkGroup = [];
}
// this.$emit('on-selection-change', this.checkGroup)
},
// 数组去重
getArray(a) {
const hash = {}
const len = a.length
const result = []
const hash = {};
const len = a.length;
const result = [];
for (let i = 0; i < len; i++) {
if (!hash[a[i]]) {
hash[a[i]] = true
result.push(a[i])
hash[a[i]] = true;
result.push(a[i]);
}
}
return result
return result;
},
checkAllGroupChange(data) {
if (this.dataLength > 0 && data.length === this.dataLength) {
this.checks = true
this.checks = true;
} else {
this.checks = false
this.checks = false;
}
this.$emit('on-selection-change', this.checkGroup)
this.$emit("on-selection-change", this.checkGroup);
},
All(data) {
let arr = []
let arr = [];
data.forEach((item) => {
arr.push(item.id)
arr.push(item.id);
if (item.children && item.children.length > 0) {
arr = arr.concat(this.All(item.children))
arr = arr.concat(this.All(item.children));
}
})
return arr
});
return arr;
},
// 返回树形数据长度
Length(data) {
let {
length
} = data
let { length } = data;
data.forEach((child) => {
if (child.children) {
length += this.Length(child.children)
length += this.Length(child.children);
}
})
return length
});
return length;
},
// 返回表头
renderHeader(column, $index) {
if ('renderHeader' in this.columns[$index]) {
return this.columns[$index].renderHeader(column, $index)
if ("renderHeader" in this.columns[$index]) {
return this.columns[$index].renderHeader(column, $index);
}
return column.title || '#'
return column.title || "#";
},
// 返回内容
renderBody(row, column, index) {
return row[column.key]
return row[column.key];
},
// 默认选中
renderCheck(data) {
let arr = []
let arr = [];
data.forEach((item) => {
if (item._checked) {
arr.push(item.id)
arr.push(item.id);
}
if (item.children && item.children.length > 0) {
arr = arr.concat(this.renderCheck(item.children))
arr = arr.concat(this.renderCheck(item.children));
}
})
return arr
});
return arr;
},
// 深度拷贝函数
deepCopy(data) {
const t = this.type(data)
let o
let i
let ni
if (t === 'array') {
o = []
} else if (t === 'object') {
o = {}
const t = this.type(data);
let o;
let i;
let ni;
if (t === "array") {
o = [];
} else if (t === "object") {
o = {};
} else {
return data
return data;
}
if (t === 'array') {
if (t === "array") {
for (i = 0, ni = data.length; i < ni; i++) {
o.push(this.deepCopy(data[i]))
o.push(this.deepCopy(data[i]));
}
return o
return o;
}
if (t === 'object') {
if (t === "object") {
for (i in data) {
o[i] = this.deepCopy(data[i])
o[i] = this.deepCopy(data[i]);
}
return o
return o;
}
},
type(obj) {
const {
toString
} = Object.prototype
const { toString } = Object.prototype;
const map = {
'[object Boolean]': 'boolean',
'[object Number]': 'number',
'[object String]': 'string',
'[object Function]': 'function',
'[object Array]': 'array',
'[object Date]': 'date',
'[object RegExp]': 'regExp',
'[object Undefined]': 'undefined',
'[object Null]': 'null',
'[object Object]': 'object'
}
return map[toString.call(obj)]
}
"[object Boolean]": "boolean",
"[object Number]": "number",
"[object String]": "string",
"[object Function]": "function",
"[object Array]": "array",
"[object Date]": "date",
"[object RegExp]": "regExp",
"[object Undefined]": "undefined",
"[object Null]": "null",
"[object Object]": "object",
};
return map[toString.call(obj)];
},
},
beforeDestroy() {
window.onresize = null
}
}
window.onresize = null;
},
};
</script>
<style lang="less">
.treeTbale {
overflow: 0 auto;
width: 100% !important;
.table-tools {
line-height: 40px;
// background: @right-header-bg;
.table-search {
float: left;
line-height: 40px;
min-width: 300px;
}
.btns {
float: right;
line-height: 40px;
}
tr:hover {
background: #f7f7f7;
}
}
.icon-set {
font-size: 17px;
margin-left: 5px;
......@@ -594,28 +728,23 @@ export default {
.icon-set .ivu-icon {
cursor: pointer;
}
table {
border-spacing: 0;
border-collapse: collapse;
margin: 0 auto;
width: 100%;
th {
background: #f8f8f9;
}
td,
th {
border: #dcdee2 solid 1px;
line-height: 40px;
padding: 0 5px;
}
tr.treetr:hover td {
background: #f7f7f7;
}
.ms-tree-space {
position: relative;
top: 1px;
......
......@@ -54,21 +54,23 @@
></Input> </FormItem
></Col>
</Row>
<Row>
<Col :span="24">
<Row type="flex" justify="center" align="middle">
<div class="textIcon" @click="upClick(upDrop)">
<Icon :type="iconType" />{{ textUp }}
</div>
<Divider orientation="left">扩展属性</Divider>
</Row>
<Row style="margin-top: 10px">
<Tabs>
<TabPane label="实体定义" name="base"> </TabPane>
<TabPane
v-for="tab in content.dtos"
<!-- <TabPane
v-for="tab in dtos"
:key="tab.code"
:label="tab.name"
>
</TabPane>
</TabPane> -->
<!-- <Button @click="modal1 = true" size="small" slot="extra"
>增加</Button
> -->
......@@ -121,9 +123,11 @@
<span class="demo-auto-complete-title">{{
option.name
}}</span>
<span class="demo-auto-complete-count" style="float: right">{{
option.code
}}</span>
<span
class="demo-auto-complete-count"
style="float: right"
>{{ option.code }}</span
>
</Option>
</AutoComplete>
</Col>
......@@ -140,7 +144,6 @@
>
<template slot-scope="{ row, index }" slot="columnDescription">
<Input
v-on:input="onIpnt(row, index)"
v-model="row.columnDescription"
@on-change="setRow(row, index)"
placeholder="请输入"
......@@ -158,12 +161,18 @@
</template>
<template slot-scope="{ row, index }" slot="propertyName">
<Input
v-on:input="onIpnt(row, index)"
v-model="row.propertyName"
@on-change="setRow(row, index)"
placeholder="请输入"
/>
</template>
<template slot-scope="{ row, index }" slot="dbColumnName">
<Input
v-model="row.dbColumnName"
@on-change="setRow(row, index)"
placeholder="请输入"
/>
</template>
<template slot-scope="{ row, index }" slot="code">
<Input
@on-change="setRow(row, index)"
......@@ -180,7 +189,7 @@
</template>
<template slot-scope="{ row, index }" slot="unit">
<Dictionary
:disabled="row.dataType != 1 && row.dataType != 2"
:disabled="row.dataType != 0 && row.dataType != 8"
@on-change="setRow(row, index)"
v-model="row.unit"
code="materail.category.dataType"
......@@ -191,20 +200,21 @@
</template>
<template slot-scope="{ row, index }" slot="length">
<Input
:disabled="row.dataType != 0 && row.dataType != 8"
v-model="row.length"
@on-change="setRow(row, index)"
placeholder="请输入"
/>
</template>
<template slot-scope="{ row, index }" slot="link">
<!-- <template slot-scope="{ row, index }" slot="link">
<Input
v-model="row.link"
@on-change="setRow(row, index)"
placeholder="请输入"
number
/>
</template>
</template> -->
<template slot-scope="{ row, index }" slot="systemName">
<state code="project.main.systemName" :value="row.systemName" />
</template>
......@@ -248,57 +258,24 @@
</FormItem>
</Col>
</Row>
</Row>
</Form>
</template>
<script>
import Dtos from "./dtos"
import Api from "./api";
export default {
name: "Add",
data() {
return {
formline: {
name: "",
code: "",
},
ruleInline: {
name: [{ required: true, message: "请输入名称", trigger: "blur" }],
code: [{ required: true, message: "请输入编码", trigger: "blur" }],
},
// modal1: false,
iconType: "ios-arrow-up",
textUp: "收起",
upDrop: true,
completeValue: "",
completeList: [],
codeList: [],
checkList: [
// {
// // mid: maxId + 1,
// // field: "c" + maxId,
// systemName: 0,
// columnDescription: "", // 中文名称
// dbColumnName: "", // 字段名称
// dataType: 0, // 数据库中字段类型
// propertyName: "", //程序中的字段名称
// propertyType: "", // 程序中的字段类型
// code: "", // 数据字典编码
// isNullable: false, // 是否可空
// isKey: false, // 是否主键
// unit: 0, // 单位
// length: 0, //
// decimalDigits: 0, // 精度
// link: 0, //外键 表的
// defaultValue: "", // 默认值
// control: 0,
// add: 0,
// uniqueness: 0, // 唯一性 0 不限制 1 表内唯一 2 表内某条件下唯一
// ruleType: "", // 邮箱 ,电话,等,
// busType: 0, // 0 系统字段 1 业务字段 2 自定义字段
// fieldType: 3,
// action: 1,
// add: 0 //新增标识
// }
],
checkList: [],
systemValue: 0,
columns1: [
{
title: "序号",
......@@ -328,6 +305,21 @@ export default {
width: 150,
high: true,
},
{
title: "字段名称",
key: "dbColumnName",
align: "center",
slot: "dbColumnName",
width: 150,
high: true,
renderHeader: (h, params) => {
return h("div", [
h("span", "字段名称("),
h("span", { style: { color: "red" } }, "*"),
h("span", ")"),
]);
},
},
{
title: "属性(*)",
align: "center",
......@@ -342,6 +334,7 @@ export default {
]);
},
},
{
title: "关联",
key: "code",
......@@ -367,11 +360,6 @@ export default {
align: "center",
slot: "systemName",
width: 190,
// render: (h, params) => {
// return h("div", [
// h("span", {}, this.sysDist(params.row.systemName)),
// ]);
// },
},
{
title: "是否可空",
......@@ -442,42 +430,26 @@ export default {
name: [{ required: true, message: "必填", trigger: "blur" }],
code: [{ required: true, message: "必填", trigger: "blur" }],
},
content: {
base: [],
dtos: [],
},
// content:{
// base:[]
// },
dtos:[]
};
},
components:{
Dtos
},
props: {
v: Object,
eid: Number,
},
mounted() {
this.seachChange();
if (this.eid > 0) {
this.load(this.eid);
this.seachChange();
}
},
methods: {
// okModal(name) {
// this.$refs[name].validate((valid) => {
// if (valid) {
// let obj = {
// name: this.formline.name,
// code: this.formline.code,
// list: [],
// };
// this.content.dtos.push(obj);
// console.log(this.content.dtos);
// this.$refs[name].resetFields();
// this.modal1 = false;
// }
// });
// },
// cancelModal(name) {
// this.$refs[name].resetFields();
// this.modal1 = false;
// },
onDragDrop(a, b) {
this.checkList.splice(b, 0, ...this.checkList.splice(a, 1));
},
......@@ -521,12 +493,12 @@ export default {
if (row.add == 0) {
//新增的删除,直接删
this.checkList.splice(index, 1);
let objArr = {
name: row.columnDescription,
code: row.code,
id: row.id,
};
this.completeList.push(objArr);
// let objArr = {
// name: row.columnDescription,
// code: row.code,
// id: row.id,
// };
// this.completeList.push(objArr);
} else {
row.action = 2; //返回的默认删除,删除后保存在arr数组中,添加标识action = 2,然后点击保存的时候,一起传给后台
this.$set(this.checkList, index, row);
......@@ -534,36 +506,19 @@ export default {
this.checkList.splice(index, 1);
}
},
onIpnt(a, b) {
console.log(a, b);
},
setRow(row, index) {
// if (index >= 1) {
// console.log(this.checkList.length)
// for(var i=1;i<this.checkList.length;i++){
// if (this.checkList[0].columnDescription == this.checkList[i].columnDescription) {
// this.$Message.error("表格名称重复!");
// row.columnDescription = "";
// return;
// }
// if (this.checkList[0].propertyName == this.checkList[i].propertyName) {
// this.$Message.error("表格属性重复!");
// row.propertyName = "";
// return;
// }
// }
// }
if (row.dataType == 0 || row.dataType == 8) {
row.length = 50;
} else {
}else{
row.length = 0;
}
if (row.dbColumnName=="") {
row.propertyName = row.dbColumnName;
}
this.$set(this.checkList, index, row);
},
addNew(index, e) {
let id = "",
code = "",
name = "",
let name = "",
flag = false;
if (index == 0 && e == "{}") {
this.checkList.forEach((s, index) => {
......@@ -579,26 +534,9 @@ export default {
if (flag == true) {
return;
}
} else if (index == 1 && JSON.stringify(e) != "{}") {
id = e.id;
code = e.code;
name = e.name;
} else {
this.$Message.warning("请选择导入字段!");
return;
}
// let maxId = 0;
// this.checkList.map((u) => {
// if (u.mid > maxId) {
// maxId = u.mid;
// }
// });
let obj = {
id: id,
code: code,
// mid: maxId + 1,
// field: "c" + maxId,
systemName: 0,
dbColumnName: "",
systemName: this.systemValue,
columnDescription: name,
defaultValue: "",
isNullable: false,
......@@ -610,11 +548,18 @@ export default {
propertyName: "", //程序中的字段名称
propertyType: "", // 程序中的字段类型
fieldType: 3,
// categoryId: 0,
action: 1,
add: 0, //新增标识
};
this.checkList.push(obj);
} else if (index == 1 && JSON.stringify(e) != "{}") {
JSON.parse(e.content).map((item) => {
this.checkList.push(item);
});
} else {
this.$Message.warning("请选择导入字段!");
return;
}
},
handleSubmit() {
let keys = false;
......@@ -629,6 +574,23 @@ export default {
return (keys = true);
}
});
if (this.checkList.length >= 2) {
for (var i = 1; i < this.checkList.length; i++) {
if (
this.checkList[0].columnDescription ==
this.checkList[i].columnDescription
) {
this.$Message.error("表格名称重复!");
return (keys = true);
}
if (
this.checkList[0].propertyName == this.checkList[i].propertyName
) {
this.$Message.error("表格属性重复!");
return (keys = true);
}
}
}
if (keys == true) {
return;
}
......@@ -659,7 +621,7 @@ export default {
load(v) {
Api.get({ id: v }).then((r) => {
this.entity = r.result;
this.content.base = this.checkList;
this.content = this.checkList;
this.entity.id = 0;
});
},
......@@ -669,6 +631,13 @@ export default {
},
},
watch: {
"entity.type": function (newVal, oldVal) {
if (newVal == 0) {
this.systemValue = 0;
} else if (newVal == 1) {
this.systemValue = 1;
}
},
v() {
this.entity = this.$u.clone(this.v);
},
......
<template>
<div>
<Row style="margin-bottom: 10px" :gutter="10">
<Col :span="6">
<AutoComplete
v-model="completeValue"
icon="ios-search"
placeholder="请搜索"
style="width: 100%"
>
<Option
v-for="option in completeList"
:value="option.name"
:key="option.code"
>
<span class="demo-auto-complete-title">
{{ option.name }}
</span>
<span class="demo-auto-complete-count" style="float: right">{{
option.code
}}</span>
</Option>
</AutoComplete>
</Col>
<Col :span="2">
<Button type="primary" @click="importColumns">导入</Button>
</Col>
</Row>
<Table
:columns="columns1"
:data="checkList"
border
:draggable="true"
@on-drag-drop="onDragDrop"
>
<template slot-scope="{ row, index }" slot="columnDescription">
<Input
v-model="row.columnDescription"
@on-change="setRow(row, index)"
placeholder="请输入"
/>
</template>
<template slot-scope="{ row, index }" slot="dataType">
<Dictionary
@on-change="setRow(row, index)"
v-model="row.dataType"
code="materail.category.dataType"
type="select"
:value="row.dataType"
:key="row.dataType"
></Dictionary>
</template>
<template slot-scope="{ row, index }" slot="propertyName">
<Input
v-model="row.propertyName"
@on-change="setRow(row, index)"
placeholder="请输入"
/>
</template>
<template slot-scope="{ row, index }" slot="dbColumnName">
<Input
v-model="row.dbColumnName"
@on-change="setRow(row, index)"
placeholder="请输入"
/>
</template>
<template slot-scope="{ row, index }" slot="code">
<Input
@on-change="setRow(row, index)"
v-model="row.code"
:disabled="row.dataType != 3 && row.dataType != 10"
placeholder="请输入"
/>
</template>
<template slot-scope="{ row, index }" slot="isNullable">
<Checkbox
v-model="row.isNullable"
@on-change="setRow(row, index)"
></Checkbox>
</template>
<template slot-scope="{ row, index }" slot="unit">
<Dictionary
:disabled="row.dataType != 0 && row.dataType != 8"
@on-change="setRow(row, index)"
v-model="row.unit"
code="materail.category.dataType"
type="select"
:value="row.dataType"
:key="row.dataType"
></Dictionary>
</template>
<template slot-scope="{ row, index }" slot="length">
<Input
:disabled="row.dataType != 0 && row.dataType != 8"
v-model="row.length"
@on-change="setRow(row, index)"
placeholder="请输入"
/>
</template>
<!--
<template slot-scope="{ row, index }" slot="link">
<Input
v-model="row.link"
@on-change="setRow(row, index)"
placeholder="请输入"
number
/>
</template> -->
<template slot-scope="{ row, index }" slot="systemName">
<state code="project.main.systemName" :value="row.systemName" />
</template>
<template slot-scope="{ row, index }" slot="list">
<Checkbox v-model="row.list" @on-change="setRow(row, index)">
</Checkbox>
</template>
<template slot-scope="{ row, index }" slot="add">
<Checkbox v-model="row.add" @on-change="setRow(row, index)"> </Checkbox>
</template>
<template slot-scope="{ row, index }" slot="uniqueness">
<Checkbox
v-model="row.uniqueness"
@on-change="setRow(row, index)"
></Checkbox>
</template>
<template slot-scope="{ row, index }" slot="defaultValue">
<Input v-model="row.defaultValue" placeholder="请输入" />
</template>
<template slot-scope="{ row, index }" slot="action">
<a
@click="remove(index, row)"
style="color: #ff7a8b"
v-if="row.fieldType > 1"
>删除</a
>
</template>
</Table>
<Button type="dashed" long @click="addNew(0, '{}')" class="mt10"
>新增属性</Button
>
</div>
</template>
<script>
export default {
// name: '',
data() {
return {
checkList: this.list,
completeValue: "",
completeList: [],
columns1: [
{
title: "序号",
type: "index",
width: 70,
align: "center",
},
{
title: "名称(*)",
align: "center",
key: "columnDescription",
slot: "columnDescription",
width: 150,
renderHeader: (h, params) => {
return h("div", [
h("span", "名称("),
h("span", { style: { color: "red" } }, "*"),
h("span", ")"),
]);
},
},
{
title: "类型",
key: "dataType",
align: "center",
slot: "dataType",
width: 150,
high: true,
},
{
title: "字段名称",
key: "dbColumnName",
align: "center",
slot: "dbColumnName",
width: 150,
high: true,
renderHeader: (h, params) => {
return h("div", [
h("span", "字段名称("),
h("span", { style: { color: "red" } }, "*"),
h("span", ")"),
]);
},
},
{
title: "属性(*)",
align: "center",
key: "propertyName",
slot: "propertyName",
high: false,
renderHeader: (h, params) => {
return h("div", [
h("span", "属性("),
h("span", { style: { color: "red" } }, "*"),
h("span", ")"),
]);
},
},
{
title: "关联",
key: "code",
align: "center",
slot: "code",
},
{
title: "单位",
key: "unit",
align: "center",
slot: "unit",
},
{
title: "长度",
key: "length",
align: "center",
slot: "length",
},
{
title: "业务类型",
key: "systemName",
align: "center",
slot: "systemName",
width: 190,
},
{
title: "是否可空",
key: "isNullable",
align: "center",
slot: "isNullable",
width: 100,
},
{
title: "业务设置",
align: "center",
children: [
{
title: "列表",
key: "list",
align: "center",
slot: "list",
width: 70,
},
{
title: "新增",
key: "add",
align: "center",
slot: "add",
width: 70,
},
{
title: "唯一",
key: "uniqueness",
align: "center",
slot: "uniqueness",
width: 70,
},
{
title: "默认值",
key: "defaultValue",
align: "center",
slot: "defaultValue",
},
],
},
{
width: 80,
title: "操作",
slot: "action",
align: "center",
},
],
};
},
props: {
list: Array,
default:()=>{
return []
}
},
created() {
},
methods: {
importColumns() {
//导入
let changeId = {};
if (this.completeList.length > 0) {
this.completeList.map((e, index) => {
if (e.name == this.completeValue) {
changeId = e;
this.completeList.splice(index, 1);
this.completeValue = "";
}
});
this.addNew(1, changeId);
}
},
onDragDrop(a, b) {
this.checkList.splice(b, 0, ...this.checkList.splice(a, 1));
},
remove(index, row) {
if (row.add == 0) {
//新增的删除,直接删
this.checkList.splice(index, 1);
let objArr = {
name: row.title,
code: row.code,
id: row.id,
};
this.completeList.push(objArr);
} else {
row.action = 2; //返回的默认删除,删除后保存在arr数组中,添加标识action = 2,然后点击保存的时候,一起传给后台
this.$set(this.checkList, index, row);
this.arr.push(row);
this.checkList.splice(index, 1);
}
},
setRow(row, index) {
console.log(row.list);
if (row.list == true) {
this.dtos[0].list.push(row);
} else {
this.dtos[0].list.map((q, i) => {
if (q.propertyName == row.propertyName) {
this.dtos[0].list.splice(i, 1);
}
});
}
console.log(this.dtos[0].list);
if (row.dataType == 0 || row.dataType == 8) {
row.length = 50;
} else {
row.length = 0;
}
if (row.dbColumnName == "") {
row.propertyName = row.dbColumnName;
}
this.$set(this.checkList, index, row);
},
addNew(index, e) {
let name = "",
flag = false;
if (index == 0 && e == "{}") {
this.checkList.forEach((s, index) => {
if (s.columnDescription == "") {
this.$Message.warning("请填写表格名称!");
return (flag = true);
}
if (s.propertyName == "") {
this.$Message.warning("请填写表格属性!");
return (flag = true);
}
});
if (flag == true) {
return;
}
let obj = {
dbColumnName: "",
systemName: this.systemValue,
columnDescription: name,
defaultValue: "",
isNullable: false,
unit: 0,
link: 0,
dataType: 0,
isKey: false, // 是否主键
length: 50,
propertyName: "", //程序中的字段名称
propertyType: "", // 程序中的字段类型
fieldType: 3,
action: 1,
add: 0, //新增标识
};
this.checkList.push(obj);
} else if (index == 1 && JSON.stringify(e) != "{}") {
JSON.parse(e.content).map((item) => {
this.checkList.push(item);
});
} else {
this.$Message.warning("请选择导入字段!");
return;
}
},
},
watch:{
list(v){
this.checkList=v;
}
}
};
</script>
<style scoped>
</style>
\ No newline at end of file
......@@ -22,14 +22,7 @@
><FormItem :label="l('englishName')" prop="englishName">
<Input v-model="entity.englishName"> </Input> </FormItem
></Col>
<Col :span="12">
<FormItem :label="l('status')" prop="status">
<Dictionary
code="base.project_atom.status"
v-model="entity.status"
></Dictionary>
</FormItem>
</Col>
<Col :span="12"
><FormItem :label="l('code')" prop="code">
<Input v-model="entity.code"> </Input> </FormItem
......@@ -42,6 +35,15 @@
><FormItem :label="l('version')" prop="version">
<InputNumber v-model="entity.version"></InputNumber> </FormItem
></Col>
<Col :span="12">
<FormItem :label="l('status')" prop="status">
<Dictionary
type="radio"
code="base.project_atom.status"
v-model="entity.status"
></Dictionary>
</FormItem>
</Col>
<Col :span="24"
><FormItem :label="l('description')" prop="description">
<Input
......@@ -56,9 +58,50 @@
<div class="textIcon" @click="upClick(upDrop)">
<Icon :type="iconType" />{{ textUp }}
</div>
</Row>
<Divider orientation="left">扩展属性</Divider>
<Row style="margin-bottom: 10px" :gutter="10">
</Row>
<Row style="margin-top: 10px">
<Tabs type="card" v-model="currTab" @on-click="handleContextMenu" >
<TabPane label="实体定义" name="base" > </TabPane>
<TabPane v-for="tab in dtos" :key="tab.code" :label="tab.name" :name="tab.code" ></TabPane>
<Button @click="modal1 = true" size="small" slot="extra" style="margin-right: 10px;"
>增加</Button>
<Button size="small" slot="extra"
>默认增加</Button>
<Modal
v-model="modal1"
title="增加"
@on-ok="okModal('formline')"
@on-cancel="cancelModal('formline')"
>
<Form
:model="formline"
ref="formline"
:rules="ruleInline"
:label-width="80"
>
<p>
<FormItem label="名称:" prop="name">
<Input
v-model="formline.name"
placeholder="请输入名称"
></Input>
</FormItem>
</p>
<p>
<FormItem label="编码:" prop="code">
<Input
v-model="formline.code"
placeholder="请输入编码"
></Input>
</FormItem>
</p>
</Form>
</Modal>
</Tabs>
</Row>
<!-- <Row style="margin-bottom: 10px" :gutter="10">
<Col :span="6">
<AutoComplete
v-model="completeValue"
......@@ -84,34 +127,19 @@
<Button type="primary" @click="importColumns">导入</Button>
</Col>
</Row>
<Table :columns="columns" :data="checkList" border>
<template slot-scope="{ row, index }" slot="title">
<div v-if="row.fieldType == 1 || row.fieldType == 2">
{{ row.title }}
</div>
<Table
:columns="columns1"
:data="checkList"
border
:draggable="true"
@on-drag-drop="onDragDrop"
>
<template slot-scope="{ row, index }" slot="columnDescription">
<Input
v-model="row.title"
placeholder="请输入名称"
@on-blur="setRow(row, index)"
v-if="row.fieldType == 3"
/>
</template>
<template slot-scope="{ row, index }" slot="note">
<Select
v-if="row.dataType == 3"
v-model="row.note"
clearable
transfer
v-model="row.columnDescription"
@on-change="setRow(row, index)"
>
<Option
v-for="item in codeList"
:value="item.code"
:key="item.code"
>{{ item.name }}</Option
>
</Select>
<span v-else>{{ row.note }}</span>
placeholder="请输入"
/>
</template>
<template slot-scope="{ row, index }" slot="dataType">
<Dictionary
......@@ -123,48 +151,99 @@
:key="row.dataType"
></Dictionary>
</template>
<template slot-scope="{ row, index }" slot="unitName">
<template slot-scope="{ row, index }" slot="propertyName">
<Input
v-model="row.propertyName"
@on-change="setRow(row, index)"
placeholder="请输入"
/>
</template>
<template slot-scope="{ row, index }" slot="dbColumnName">
<Input
v-model="row.dbColumnName"
@on-change="setRow(row, index)"
placeholder="请输入"
/>
</template>
<template slot-scope="{ row, index }" slot="code">
<Input
@on-change="setRow(row, index)"
v-model="row.code"
:disabled="row.dataType != 3 && row.dataType != 10"
placeholder="请输入"
/>
</template>
<template slot-scope="{ row, index }" slot="isNullable">
<Checkbox
v-model="row.isNullable"
@on-change="setRow(row, index)"
></Checkbox>
</template>
<template slot-scope="{ row, index }" slot="unit">
<Dictionary
v-if="row.dataType == 1 || row.dataType == 2"
:disabled="row.dataType != 0 && row.dataType != 8"
@on-change="setRow(row, index)"
v-model="row.unitName"
code="material.main.unitName"
v-model="row.unit"
code="materail.category.dataType"
type="select"
placeholder="请选择单位"
:value="row.unitName"
:key="row.unitName"
:value="row.dataType"
:key="row.dataType"
></Dictionary>
</template>
<template slot-scope="{ row, index }" slot="required">
<Checkbox
v-model="row.required"
<template slot-scope="{ row, index }" slot="length">
<Input
:disabled="row.dataType != 0 && row.dataType != 8"
v-model="row.length"
@on-change="setRow(row, index)"
></Checkbox>
placeholder="请输入"
/>
</template>
<template slot-scope="{ row, index }" slot="isUnique">
<template slot-scope="{ row, index }" slot="link">
<Input
v-model="row.link"
@on-change="setRow(row, index)"
placeholder="请输入"
number
/>
</template>
<template slot-scope="{ row, index }" slot="systemName">
<state code="project.main.systemName" :value="row.systemName" />
</template>
<template slot-scope="{ row, index }" slot="list">
<Checkbox v-model="row.list" @on-change="setRow(row, index)">
</Checkbox>
</template>
<template slot-scope="{ row, index }" slot="add">
<Checkbox v-model="row.add" @on-change="setRow(row, index)">
</Checkbox>
</template>
<template slot-scope="{ row, index }" slot="uniqueness">
<Checkbox
v-model="row.isUnique"
v-model="row.uniqueness"
@on-change="setRow(row, index)"
></Checkbox>
</template>
<template slot-scope="{ row, index }" slot="defaultValue">
<Input v-model="row.defaultValue" placeholder="请输入" />
</template>
<template slot-scope="{ row, index }" slot="action">
<a
@click="remove(index, row)"
style="color: #ff7a8b"
v-if="row.fieldType > 1"
>删除</a>
>删除</a
>
</template>
</Table>
<Button type="dashed" long @click="addNew(0,'{}')" class="mt10"
>新增属性</Button
>
<Button type="dashed" long @click="addNew(0, '{}')" class="mt10" >新增属性</Button> -->
<!-- <Dtos :list="checkList"></Dtos> -->
<component :is="detail" :list="checkList" />
</Col>
<Col :span="24" class="tr mt10">
<FormItem>
<Button type="primary" @click="handleSubmit" :disabled="disabled"
>保存</Button
>
>保存</Button>
<Button @click="handleClose" class="ml20">取消</Button>
</FormItem>
</Col>
......@@ -177,6 +256,48 @@ export default {
name: "Edit",
data() {
return {
currTab:'base',
detail:null,
contextData: null,
formline: {
name: "",
code: "",
},
ruleInline: {
name: [{ required: true, message: "请输入名称", trigger: "blur" }],
code: [{ required: true, message: "请输入编码", trigger: "blur" }],
},
modal1: false,
content: {
base: [],
},
dtos: [
{
name: "列表",
code: "list",
type: 0,
list: [],
},
{
name: "新增",
code: "Add",
type: 1,
list: [],
},
{
name: "编辑",
code: "Edit",
type: 1,
list: [],
},
{
name: "查询",
code: "Search",
type: 1,
list: [],
},
],
systemValue: 0,
iconType: "ios-arrow-up",
textUp: "收起",
upDrop: true,
......@@ -184,52 +305,132 @@ export default {
completeList: [],
codeList: [],
checkList: [],
columns: [
columns1: [
{
title: "序号",
type: "index",
width: 80,
width: 70,
align: "center",
},
{
title: "属性名称",
key: "title",
slot: "title",
title: "名称(*)",
align: "center",
key: "columnDescription",
slot: "columnDescription",
width: 150,
renderHeader: (h, params) => {
return h("div", [
h("span", "名称("),
h("span", { style: { color: "red" } }, "*"),
h("span", ")"),
]);
},
},
{
title: "属性类型",
title: "类型",
key: "dataType",
align: "center",
slot: "dataType",
width: 200,
width: 150,
high: true,
},
{
title: "设置",
key: "note",
title: "字段名称",
key: "dbColumnName",
align: "center",
slot: "note",
slot: "dbColumnName",
width: 150,
high: true,
renderHeader: (h, params) => {
return h("div", [
h("span", "字段名称("),
h("span", { style: { color: "red" } }, "*"),
h("span", ")"),
]);
},
},
{
title: "属性(*)",
align: "center",
key: "propertyName",
slot: "propertyName",
high: false,
renderHeader: (h, params) => {
return h("div", [
h("span", "属性("),
h("span", { style: { color: "red" } }, "*"),
h("span", ")"),
]);
},
},
{
title: "关联",
key: "code",
align: "center",
slot: "code",
},
{
title: "单位",
key: "unitName",
key: "unit",
align: "center",
slot: "unitName",
width: "150",
slot: "unit",
},
{
title: "必填",
key: "required",
title: "长度",
key: "length",
align: "center",
slot: "required",
width: 80,
slot: "length",
},
{
title: "业务类型",
key: "systemName",
align: "center",
slot: "systemName",
width: 190,
},
{
title: "是否可空",
key: "isNullable",
align: "center",
slot: "isNullable",
width: 100,
},
{
title: "业务设置",
align: "center",
children: [
{
title: "列表",
key: "list",
align: "center",
slot: "list",
width: 70,
},
{
title: "新增",
key: "add",
align: "center",
slot: "add",
width: 70,
},
{
title: "唯一",
key: "isUnique",
key: "uniqueness",
align: "center",
slot: "isUnique",
width: 80,
slot: "uniqueness",
width: 70,
},
{
title: "默认值",
key: "defaultValue",
align: "center",
slot: "defaultValue",
},
],
},
{
width: 80,
title: "操作",
......@@ -248,27 +449,52 @@ export default {
props: {
eid: Number,
},
mounted() {
if (this.eid > 0) {
this.load(this.eid);
this.seachChange();
}
this.detail=()=>import('./dtos')
},
methods: {
importColumns() {
//导入
let changeId = {};
if (this.completeList.length > 0) {
this.completeList.map((e, index) => {
if (e.name == this.completeValue) {
changeId = e;
this.completeList.splice(index, 1);
this.completeValue = "";
handleContextMenu(data) {console.log("+=========================")
console.log(data)
this.contextData = data;
},
okModal(name) {
this.$refs[name].validate((valid) => {
if (valid) {
let obj = {
name: this.formline.name,
code: this.formline.code,
list: [],
};
this.dtos.push(obj);
console.log(this.dtos);
this.$refs[name].resetFields();
this.modal1 = false;
}
});
this.addNew(1,changeId);
}
},
cancelModal(name) {
this.$refs[name].resetFields();
this.modal1 = false;
},
// importColumns() {
// //导入
// let changeId = {};
// if (this.completeList.length > 0) {
// this.completeList.map((e, index) => {
// if (e.name == this.completeValue) {
// changeId = e;
// this.completeList.splice(index, 1);
// this.completeValue = "";
// }
// });
// this.addNew(1, changeId);
// }
// },
upClick(value) {
this.upDrop = !value;
if (value) {
......@@ -293,71 +519,98 @@ export default {
})
.catch((err) => {});
},
remove(index, row) {
if (row.add == 0) {
//新增的删除,直接删
this.checkList.splice(index, 1);
let objArr = {
name: row.title,
code: row.code,
id: row.id,
};
this.completeList.push(objArr);
} else {
row.action = 2; //返回的默认删除,删除后保存在arr数组中,添加标识action = 2,然后点击保存的时候,一起传给后台
this.$set(this.checkList, index, row);
this.arr.push(row);
this.checkList.splice(index, 1);
}
},
setRow(row, index) {
this.$set(this.checkList, index, row);
},
addNew(index,e) {
let id = "",
code = "",
name = "";
if (index == 0 && e=='{}') {
id = "";
code = "";
name = "";
} else if(index == 1 && JSON.stringify(e)!='{}'){
id = e.id;
code = e.code;
name = e.name;
}else{
this.$Message.warning("请选择导入字段!");
return;
}
let maxId = 0;
this.checkList.map((u) => {
if (u.mid > maxId) {
maxId = u.mid;
}
});
let obj = {
id: id,
code: code,
mid: maxId + 1,
field: "c" + maxId,
title: name,
note: "",
unitName: "",
dataType: 0,
required: false,
isunique: false,
fieldType: 3,
categoryId: 0,
action: 1,
add: 0, //新增标识
};
this.checkList.push(obj);
},
// onDragDrop(a, b) {
// this.checkList.splice(b, 0, ...this.checkList.splice(a, 1));
// },
// remove(index, row) {
// if (row.add == 0) {
// //新增的删除,直接删
// this.checkList.splice(index, 1);
// let objArr = {
// name: row.title,
// code: row.code,
// id: row.id,
// };
// this.completeList.push(objArr);
// } else {
// row.action = 2; //返回的默认删除,删除后保存在arr数组中,添加标识action = 2,然后点击保存的时候,一起传给后台
// this.$set(this.checkList, index, row);
// this.arr.push(row);
// this.checkList.splice(index, 1);
// }
// },
// setRow(row, index) {
// console.log(row.list)
// if(row.list==true){
// this.dtos[0].list.push(row)
// }else{
// this.dtos[0].list.map((q,i)=>{
// if(q.propertyName==row.propertyName){
// this.dtos[0].list.splice(i,1)
// }
// })
// }
// console.log(this.dtos[0].list)
// if (row.dataType == 0 || row.dataType == 8) {
// row.length = 50;
// } else {
// row.length = 0;
// }
// if (row.dbColumnName == "") {
// row.propertyName = row.dbColumnName;
// }
// this.$set(this.checkList, index, row);
// },
// addNew(index, e) {
// let name = "",
// flag = false;
// if (index == 0 && e == "{}") {
// this.checkList.forEach((s, index) => {
// if (s.columnDescription == "") {
// this.$Message.warning("请填写表格名称!");
// return (flag = true);
// }
// if (s.propertyName == "") {
// this.$Message.warning("请填写表格属性!");
// return (flag = true);
// }
// });
// if (flag == true) {
// return;
// }
// let obj = {
// dbColumnName: "",
// systemName: this.systemValue,
// columnDescription: name,
// defaultValue: "",
// isNullable: false,
// unit: 0,
// link: 0,
// dataType: 0,
// isKey: false, // 是否主键
// length: 50,
// propertyName: "", //程序中的字段名称
// propertyType: "", // 程序中的字段类型
// fieldType: 3,
// action: 1,
// add: 0, //新增标识
// };
// this.checkList.push(obj);
// } else if (index == 1 && JSON.stringify(e) != "{}") {
// JSON.parse(e.content).map((item) => {
// this.checkList.push(item);
// });
// } else {
// this.$Message.warning("请选择导入字段!");
// return;
// }
// },
load(v) {
Api.get({ id: v }).then((r) => {
this.entity = r.result;
this.checkList = JSON.parse(r.result.content);
console.log(this.checkList)
this.checkList.map((v) => {
if (v.fieldType > 1) {
v.fieldType = 1;
......@@ -368,6 +621,7 @@ export default {
}
});
});
});
},
handleSubmit() {
......@@ -401,11 +655,18 @@ export default {
},
},
watch: {
eid(v) {
if (v != 0) {
this.load(v);
"entity.type": function (newVal, oldVal) {
if (newVal == 0) {
this.systemValue = 0;
} else if (newVal == 1) {
this.systemValue = 1;
}
},
// eid(v) {
// if (v != 0) {
// this.load(v);
// }
// },
},
};
</script>
......
......@@ -22,7 +22,7 @@
</template>
</DataGrid>
<!-- fullscreen -->
<Modal v-model="modal" :title="title" width="1200" footer-hide fullscreen >
<Modal v-model="modal" :title="title" width="1200" footer-hide fullscreen>
<component :is="detail" :eid="curId" @on-close="cancel" @on-ok="ok" />
</Modal>
</div>
......@@ -58,48 +58,6 @@ export default {
align: "left",
high: true,
},
// {
// key: "creationTime",
// title: this.l("creationTime"),
// align: "left",
// high: true,
// },
// {
// key: "creatorUserId",
// title: this.l("creatorUserId"),
// align: "left",
// high: true,
// },
// {
// key: "lastModificationTime",
// title: this.l("lastModificationTime"),
// align: "left",
// high: true,
// },
// {
// key: "lastModifierUserId",
// title: this.l("lastModifierUserId"),
// align: "left",
// high: true,
// },
// {
// key: "isDeleted",
// title: this.l("isDeleted"),
// align: "left",
// high: true,
// },
// {
// key: "deletionTime",
// title: this.l("deletionTime"),
// align: "left",
// high: true,
// },
// {
// key: "deleterUserId",
// title: this.l("deleterUserId"),
// align: "left",
// high: true,
// },
{
key: "name",
title: this.l("name"),
......@@ -114,16 +72,20 @@ export default {
easy: true,
high: true,
},
{ key: "status", title: this.l("status"), align: "left", high: true , code:'base.project_atom.status'},
// { key: "upId", title: this.l("upId"), align: "left", high: true },
// { key: "level", title: this.l("level"), align: "left", high: true },
// {
// key: "tenantId",
// title: this.l("tenantId"),
// align: "left",
// high: true,
// },
{ key: "type", title: this.l("type"), align: "left", high: true , code:'base.project_atom.type'},
{
key: "status",
title: this.l("status"),
align: "left",
high: true,
code: "base.project_atom.status",
},
{
key: "type",
title: this.l("type"),
align: "left",
high: true,
code: "base.project_atom.type",
},
{
key: "englishFullName",
title: this.l("englishFullName"),
......@@ -138,22 +100,9 @@ export default {
easy: true,
high: true,
},
// {
// key: "inheritCategoryId",
// title: this.l("inheritCategoryId"),
// align: "left",
// high: true,
// },
{ key: "module", title: this.l("module"), align: "left", high: true },
{ key: "version", title: this.l("version"), align: "left", high: true },
// {
// key: "projectId",
// title: this.l("projectId"),
// align: "left",
// high: true,
// },
{
title: "操作",
key: "action",
......@@ -169,7 +118,6 @@ export default {
},
"查看"
),
//h('op', { attrs: { oprate: 'copy' }, on: { click: () => this.copy(params.row.id) } }, '克隆'),
h(
"op",
{
......@@ -192,9 +140,7 @@ export default {
],
};
},
mounted() {
console.log(this);
},
mounted() {},
async fetch({ store, params }) {
await store.dispatch("loadDictionary"); // 加载数据字典
},
......@@ -276,5 +222,3 @@ export default {
},
};
</script>
<style lang="less">
</style>
\ No newline at end of file
<template>
<Form ref="form" :model="condition" :label-width="90">
<Row>
<Col :span="12" :v-if="condition.id.show"><FormItem :label="$t('id')" prop="id"> <Input v-model="condition.id.value"> </Input>
</FormItem></Col>
<Col :span="12" :v-if="condition.creationTime.show"><FormItem :label="l('creationTime')" prop="creationTime"> <DatePicker type="daterange" v-model="condition.creationTime.value"></DatePicker>
</FormItem></Col>
<Col :span="12" :v-if="condition.creatorUserId.show"><FormItem :label="l('creatorUserId')" prop="creatorUserId"> <Input v-model="condition.creatorUserId.value"> </Input>
</FormItem></Col>
<Col :span="12" :v-if="condition.lastModificationTime.show"><FormItem :label="l('lastModificationTime')" prop="lastModificationTime"> <DatePicker type="daterange" v-model="condition.lastModificationTime.value"></DatePicker>
</FormItem></Col>
<Col :span="12" :v-if="condition.lastModifierUserId.show"><FormItem :label="l('lastModifierUserId')" prop="lastModifierUserId"> <Input v-model="condition.lastModifierUserId.value"> </Input>
</FormItem></Col>
<Col :span="12" :v-if="condition.deletionTime.show"><FormItem :label="l('deletionTime')" prop="deletionTime"> <DatePicker type="daterange" v-model="condition.deletionTime.value"></DatePicker>
</FormItem></Col>
<Col :span="12" :v-if="condition.name.show"><FormItem :label="l('name')" prop="name"> <Input v-model="condition.name.value"> </Input>
</FormItem></Col>
<Col :span="12" :v-if="condition.upId.show"><FormItem :label="l('upId')" prop="upId"> <Input v-model="condition.upId.value"> </Input>
</FormItem></Col>
<Col :span="12" :v-if="condition.level.show"><FormItem :label="l('level')" prop="level"> <Input v-model="condition.level.value"> </Input>
</FormItem></Col>
<Col :span="12" :v-if="condition.tenantId.show"><FormItem :label="l('tenantId')" prop="tenantId"> <Input v-model="condition.tenantId.value"> </Input>
</FormItem></Col>
<Col :span="12" :v-if="condition.type.show"><FormItem :label="l('type')" prop="type"> <Input v-model="condition.type.value"> </Input>
</FormItem></Col>
<Col :span="12" :v-if="condition.englishFullName.show"><FormItem :label="l('englishFullName')" prop="englishFullName"> <Input v-model="condition.englishFullName.value"> </Input>
</FormItem></Col>
<Col :span="12" :v-if="condition.englishName.show"><FormItem :label="l('englishName')" prop="englishName"> <Input v-model="condition.englishName.value"> </Input>
</FormItem></Col>
<Col :span="12" :v-if="condition.status.show"><FormItem :label="l('status')" prop="status"> <Input v-model="condition.status.value"> </Input>
</FormItem></Col>
<Col :span="24" :v-if="condition.description.show"><FormItem :label="l('description')" prop="description"> <Input v-model="condition.description.value"> </Input>
</FormItem></Col>
<Col :span="12" :v-if="condition.inheritCategoryId.show"><FormItem :label="l('inheritCategoryId')" prop="inheritCategoryId"> <Input v-model="condition.inheritCategoryId.value"> </Input>
</FormItem></Col>
<Col :span="12" :v-if="condition.code.show"><FormItem :label="l('code')" prop="code"> <Input v-model="condition.code.value"> </Input>
</FormItem></Col>
<Col :span="12" :v-if="condition.module.show"><FormItem :label="l('module')" prop="module"> <Input v-model="condition.module.value"> </Input>
</FormItem></Col>
<Col :span="12" :v-if="condition.version.show"><FormItem :label="l('version')" prop="version"> <Input v-model="condition.version.value"> </Input>
</FormItem></Col>
<Col :span="12" :v-if="condition.projectId.show"><FormItem :label="l('projectId')" prop="projectId"> <Input v-model="condition.projectId.value"> </Input>
</FormItem></Col>
<Col :span="12" :v-if="condition.id.show"
><FormItem :label="$t('id')" prop="id">
<Input v-model="condition.id.value" number> </Input> </FormItem
></Col>
<Col :span="12" :v-if="condition.creationTime.show"
><FormItem :label="l('creationTime')" prop="creationTime">
<DatePicker
type="daterange"
v-model="condition.creationTime.value"
></DatePicker> </FormItem
></Col>
<Col :span="12" :v-if="condition.creatorUserId.show"
><FormItem :label="l('creatorUserId')" prop="creatorUserId">
<Input v-model="condition.creatorUserId.value"> </Input> </FormItem
></Col>
<Col :span="12" :v-if="condition.lastModificationTime.show"
><FormItem
:label="l('lastModificationTime')"
prop="lastModificationTime"
>
<DatePicker
type="daterange"
v-model="condition.lastModificationTime.value"
></DatePicker> </FormItem
></Col>
<Col :span="12" :v-if="condition.lastModifierUserId.show"
><FormItem :label="l('lastModifierUserId')" prop="lastModifierUserId">
<Input v-model="condition.lastModifierUserId.value">
</Input> </FormItem
></Col>
<Col :span="12" :v-if="condition.deletionTime.show"
><FormItem :label="l('deletionTime')" prop="deletionTime">
<DatePicker
type="daterange"
v-model="condition.deletionTime.value"
></DatePicker> </FormItem
></Col>
<Col :span="12" :v-if="condition.name.show"
><FormItem :label="l('name')" prop="name">
<Input v-model="condition.name.value"> </Input> </FormItem
></Col>
<Col :span="12" :v-if="condition.upId.show"
><FormItem :label="l('upId')" prop="upId">
<Input v-model="condition.upId.value"> </Input> </FormItem
></Col>
<Col :span="12" :v-if="condition.level.show"
><FormItem :label="l('level')" prop="level">
<Input v-model="condition.level.value"> </Input> </FormItem
></Col>
<Col :span="12" :v-if="condition.tenantId.show"
><FormItem :label="l('tenantId')" prop="tenantId">
<Input v-model="condition.tenantId.value"> </Input> </FormItem
></Col>
<Col :span="12" :v-if="condition.type.show"
><FormItem :label="l('type')" prop="type">
<Input v-model="condition.type.value"> </Input> </FormItem
></Col>
<Col :span="12" :v-if="condition.englishFullName.show"
><FormItem :label="l('englishFullName')" prop="englishFullName">
<Input v-model="condition.englishFullName.value"> </Input> </FormItem
></Col>
<Col :span="12" :v-if="condition.englishName.show"
><FormItem :label="l('englishName')" prop="englishName">
<Input v-model="condition.englishName.value"> </Input> </FormItem
></Col>
<Col :span="12" :v-if="condition.status.show"
><FormItem :label="l('status')" prop="status">
<Input v-model="condition.status.value"> </Input> </FormItem
></Col>
<Col :span="24" :v-if="condition.description.show"
><FormItem :label="l('description')" prop="description">
<Input v-model="condition.description.value"> </Input> </FormItem
></Col>
<Col :span="12" :v-if="condition.inheritCategoryId.show"
><FormItem :label="l('inheritCategoryId')" prop="inheritCategoryId">
<Input v-model="condition.inheritCategoryId.value">
</Input> </FormItem
></Col>
<Col :span="12" :v-if="condition.code.show"
><FormItem :label="l('code')" prop="code">
<Input v-model="condition.code.value"> </Input> </FormItem
></Col>
<Col :span="12" :v-if="condition.module.show"
><FormItem :label="l('module')" prop="module">
<Input v-model="condition.module.value"> </Input> </FormItem
></Col>
<Col :span="12" :v-if="condition.version.show"
><FormItem :label="l('version')" prop="version">
<Input v-model="condition.version.value"> </Input> </FormItem
></Col>
<Col :span="12" :v-if="condition.projectId.show"
><FormItem :label="l('projectId')" prop="projectId">
<Input v-model="condition.projectId.value"> </Input> </FormItem
></Col>
</Row>
</Form>
</template>
<script>
import Api from './api'
export default {
name: 'Add',
import Api from "./api";
export default {
name: "Add",
data() {
return {
condition: {
id:{op:"Equal",value:null,show:true},
creationTime:{op:"Range",value:null,show:true},
creatorUserId:{op:"Equal",value:null,show:true},
lastModificationTime:{op:"Range",value:null,show:true},
lastModifierUserId:{op:"Equal",value:null,show:true},
deletionTime:{op:"Range",value:null,show:true},
name:{op:"Equal",value:null,show:true},
upId:{op:"Equal",value:null,show:true},
level:{op:"Equal",value:null,show:true},
tenantId:{op:"Equal",value:null,show:true},
type:{op:"Equal",value:null,show:true},
englishFullName:{op:"Equal",value:null,show:true},
englishName:{op:"Equal",value:null,show:true},
status:{op:"Equal",value:null,show:true},
description:{op:"Equal",value:null,show:true},
inheritCategoryId:{op:"Equal",value:null,show:true},
code:{op:"Equal",value:null,show:true},
module:{op:"Equal",value:null,show:true},
version:{op:"Equal",value:null,show:true},
projectId:{op:"Equal",value:null,show:true},
id: { op: "Equal", value: null, show: true },
creationTime: { op: "Range", value: null, show: true },
creatorUserId: { op: "Equal", value: null, show: true },
lastModificationTime: { op: "Range", value: null, show: true },
lastModifierUserId: { op: "Equal", value: null, show: true },
deletionTime: { op: "Range", value: null, show: true },
name: { op: "Equal", value: null, show: true },
upId: { op: "Equal", value: null, show: true },
level: { op: "Equal", value: null, show: true },
tenantId: { op: "Equal", value: null, show: true },
type: { op: "Equal", value: null, show: true },
englishFullName: { op: "Equal", value: null, show: true },
englishName: { op: "Equal", value: null, show: true },
status: { op: "Equal", value: null, show: true },
description: { op: "Equal", value: null, show: true },
inheritCategoryId: { op: "Equal", value: null, show: true },
code: { op: "Equal", value: null, show: true },
module: { op: "Equal", value: null, show: true },
version: { op: "Equal", value: null, show: true },
projectId: { op: "Equal", value: null, show: true },
},
}
};
},
methods: {
handleClose() {
this.$emit('on-close')
this.$emit("on-close");
},
l(key) {
key = "project_atom" + "." + key;
return this.$t(key)
}
}
}
return this.$t(key);
},
},
};
</script>
\ No newline at end of file
......@@ -9,11 +9,11 @@
<FormItem :label="l('code')" prop="code">
<Input v-model="entity.code"> </Input> </FormItem>
</Col>
<Col :span="12">
<!-- <Col :span="12">
<FormItem :label="l('type')" prop="type">
<Dictionary code="base.project.type" v-model="entity.type" ></Dictionary>
</FormItem>
</Col>
</Col> -->
<Col :span="12"
><FormItem :label="l('englishFullName')" prop="englishFullName">
<Input v-model="entity.englishFullName"> </Input> </FormItem
......@@ -75,8 +75,10 @@ export default {
props: {
v: Object,
eid: Number,
typeValue:Number
},
mounted() {
this.entity.type=this.typeValue;
// if (this.eid > 0) {
// this.load(this.eid);
// }
......
......@@ -18,11 +18,17 @@
<Search />
</template>
<template slot="buttons">
<Button type="primary" @click="add">新增</Button>
<Button type="primary" @click="add()">新增</Button>
</template>
</TreeGrid>
<Modal v-model="modal" :title="title" width="1200" footer-hide>
<component :is="detail" :eid="curId" @on-close="cancel" @on-ok="ok" />
<component
:is="detail"
:typeValue="typeValue"
:eid="curId"
@on-close="cancel"
@on-ok="ok"
/>
</Modal>
</div>
</template>
......@@ -47,16 +53,12 @@ export default {
easySearch: {
keys: { op: "name,englishFullName,englishName,code", value: null },
},
typeValue: 0,
modal: false,
title: "新增",
detail: null,
curId: 0,
columns: [
{
key: "label",
title: "分类名称",
align: "left",
},
{
key: "name",
title: this.l("name"),
......@@ -64,6 +66,7 @@ export default {
hide: true,
easy: true,
high: true,
tree: true,
},
{
......@@ -162,6 +165,7 @@ export default {
Api.treepaged(data).then((r) => {
this.treeData = [];
this.treeData = r.result;
this.treeList=r.result;
this.treeData = this.$u.toTree(
r.result,
0,
......@@ -178,18 +182,20 @@ export default {
this.curId = 0;
},
search() {
console.log(this.easySearch);
console.log(this.$refs.grid);
// this.init();
// console.log(this.easySearch);
// console.log(this.$refs.grid);
this.init();
// this.$refs.grid.reload(this.easySearch);
},
add() {
this.typeValue = 0;
this.curId = 0;
this.title = "新增";
this.detail = () => import("./add");
this.modal = true;
},
rowadd(id) {
this.typeValue = 1;
this.curId = id;
this.title = "新增";
this.detail = () => import("./add");
......@@ -208,6 +214,13 @@ export default {
this.modal = true;
},
remove(id) {
var len=this.treeList.filter(u=>{
return u.upId==id
}).length;
if(len>0){
this.$Message.warning("包含子对象,不能删除!")
return;
}
Api.delete(id).then((r) => {
if (r.success) {
this.init();
......
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