Files
scrq-hd/.svn/pristine/1c/1caad2f58a37b8733ec4c4357fff9ee8fa12e10c.svn-base
2025-07-03 10:34:04 +08:00

525 lines
13 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<div class="app-container">
<query-params
ref="query"
:form="queryFormConfig"
@handleQuery="handleQuery"
@resetQuery="resetQuery"
>
</query-params>
<el-divider></el-divider>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
icon="el-icon-plus"
size="mini"
@click="add"
v-hasPermi="['hkDept_add']"
>新增</el-button
>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
icon="el-icon-edit"
size="mini"
@click="handleUpdate"
:disabled="buttonEnable"
v-hasPermi="['hkDept_edit']"
>修改</el-button
>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
icon="el-icon-delete"
size="mini"
@click="handleDelete"
:disabled="buttonEnable"
v-hasPermi="['hkDept_remove']"
>删除</el-button
>
</el-col>
<el-popover
style="float: right"
placement="bottom-end"
title="自定义显示列"
width="250"
@show="initPopover"
trigger="hover"
>
<headConfig
ref="test"
@fathers="fathers"
:propThis="propThis"
></headConfig>
<el-button
style="margin-right: 5px"
size="mini"
type="primary"
class="el-icon-caret-bottom"
slot="reference"
>自定义列</el-button
>
</el-popover>
</el-row>
<el-row :gutter="10" style="margin: 10px 0px" class="mb8" v-if="isSortShow">
<el-col>
<el-select
ref="select"
@click.native="notSelect"
style="width: 100%"
v-model="seqence"
:multiple="true"
placeholder=""
>
<el-option
v-for="item in seqenceOptions"
:key="item.value"
:label="item.label"
:value="item.value"
>
</el-option>
</el-select>
</el-col>
</el-row>
<el-table
@sort-change="sortChange"
@header-dragend="headerDragend"
v-loading="loading"
highlight-current-row
@current-change="handleCurrentChange"
:data="tableData"
border
v-if="indexShow"
:height="tableHeight"
class="tableStyle"
style="width: 100%"
>
<el-table-column
type="index"
align="center"
label="序号"
width="50"
></el-table-column>
<el-table-column
v-for="(item, index) in realList"
:sortable="item.notSort == true ? false : `custom`"
:prop="item.tableProp"
:key="index"
:align="item.align"
header-align="center"
:min-width="item.width"
:label="item.tableTitle"
:show-overflow-tooltip="item.show_overflow_tooltip"
></el-table-column>
</el-table>
</div>
</template>
<script>
import edit from "./edit";
export default {
name: "hkDept",
components: {},
computed: {
queryFormConfig() {
return {
controlList: [
{
key: "deptCode",
label: "部门编码",
type: "input",
placeholder: "请输入",
prop: "deptCode",
},
{
key: "displayDept",
label: "显示部门",
type: "input",
placeholder: "请输入",
prop: "displayDept",
},
{
key: "actualDept",
label: "实际部门",
type: "input",
placeholder: "请输入",
prop: "actualDept",
},
],
config: {
//零散的配置参数
hasAdvQuery: false, //有无高级查询
storageMode:true,//记忆模式开启后每次查询会存储到localstorage中存储名为下面的storageKey
storageKey:"hkDept",
propThis: this, //this
preFixWidthClass: "width_0100", //前置框的宽度calss不写则为默认100
marginWidthClass: "width_0180", //空白选择框的宽度calss不写则为默认180
},
defaultList: [
//默认展示的属性,跟controList里面的key相对应
"deptCode","displayDept","actualDept"
],
};
},
},
mounted() {
let tempList = this.$headerConfig.getList("hkDept");
tempList.forEach((data, index) => {
if (data.notSort) return;
let temp = {
value: null,
label: null,
};
temp.value = data.tableProp.replace("Show", "") + " ascending";
temp.label = data.tableTitle + " 升序";
this.seqenceOptions.push(temp);
let tempD = {
value: null,
label: null,
};
tempD.value = data.tableProp.replace("Show", "") + " descending";
tempD.label = data.tableTitle + " 降序";
this.seqenceOptions.push(tempD);
});
this.$nextTick(() => {
this.tableHeight =
window.innerHeight - this.$refs.query.offsetHeight - 250;
});
this.getlist();
const params = {
tableName: "hkDept",
};
this.$headerConfig.getRealList(params).then((data) => {
console.log("开始输出真正表格");
if (data.data && data.data.data && data.data.data !== null) {
let temp = JSON.parse(data.data.data);
this.realList = temp.headerList;
this.List = temp.List;
} else {
this.List = this.$headerConfig.getList("hkDept");
this.realList = this.List;
let temp = {
headerList: this.realList,
List: this.List,
};
const params = {
tableName: "hkDept",
configure: JSON.stringify(temp),
};
this.$headerConfig.updateRealList(params).then((value) => {
console.log(value);
});
}
this.indexShow = true;
});
this.$refs.query.init();
},
data() {
return {
currentRow: null,
tableData: [],
queryParams: {},
buttonEnable: true,
isAdd: null,
tableHeight: 0,
indexShow: false,
total: null,
loading: false,
propThis: this,
seqenceOptions: [],
seqence: [],
isSortShow: false,
};
},
methods: {
notSelect() {
this.$refs.select.blur();
},
sortChange({ column, prop, order }) {
console.log(prop);
let sTemp = {
value: null,
label: null,
};
let value = prop.replace("Show", "") + " " + order;
let judgeValue = value.split(" ");
// this.seqence.push(value)
if (this.seqence.length === 0) {
this.seqence.push(value);
console.log(this.seqence);
} else {
for (let i = 0; i < this.seqence.length; i++) {
let judgeSeqence = this.seqence[i].split(" ");
if (judgeValue[0] === judgeSeqence[0]) {
if (judgeValue[1] === "null") {
return;
}
this.seqence.splice(i, 1, value);
console.log(this.seqence);
return;
}
if (i + 1 === this.seqence.length) {
this.seqence.push(value);
console.log(this.seqence);
}
}
}
},
headerDragend(newWidth, oldWidth, column, event) {
// realList
this.realList.forEach((value) => {
if (column.property == value.tableProp) {
value.width = newWidth;
}
});
this.$refs.test.init();
setTimeout(() => {
this.$refs.test.show();
}, 1000);
},
getQueryParams() {
let pageSize = this.queryParams.pageSize;
let pageNo = this.queryParams.pageNo;
this.queryParams = this.$refs.query.getQueryParams(); //返回子组件的queryParams
this.queryParams.pageSize = pageSize;
this.queryParams.pageNo = pageNo;
//取得子组件的queryParams并且与原来的pagesize pageNo合并
},
getlist() {
this.loading = true;
const orders = [];
this.seqence.map((val) => {
orders.push(
val.replace("ascending", "asc").replace("descending", "desc")
);
});
let params = {
displayDept: this.queryParams.displayDept,
actualDept: this.queryParams.actualDept,
deptCode: this.queryParams.deptCode,
orders,
};
this.$hkDept.getList(params).then((resp) => {
if (resp.data.code == 200) {
this.tableData = resp.data.data.data;
this.total = resp.data.data.recordsTotal;
this.loading = false;
}
});
},
Query() {
this.currentPage = 1;
this.getlist();
},
handleCurrentChange(val) {
this.currentRow = val;
if (val === null) {
this.buttonEnable = true;
} else {
this.buttonEnable = false;
}
},
handleQuery() {
this.getQueryParams();
this.isTreeShow = false; //以表格形式显示 所以将isTreeShow置为false
this.getlist();
},
resetQuery() {
this.queryParams = {
name: null,
};
this.seqence = [];
this.getlist();
},
initPopover() {
const params = {
tableName: "hkDept",
};
this.$headerConfig.getRealList(params).then((data) => {
console.log("开始输出真正表格");
let temp = JSON.parse(data.data.data);
console.log(temp);
this.realList = temp.headerList;
console.log(this.realList);
this.$refs.test.init();
});
},
fathers(data) {
this.List = data.configure.List;
data.configure.List.forEach((value) => {
this.realList.forEach((real) => {
if (value.tableProp == real.tableProp) {
value.width = real.width;
}
});
});
data.configure.headerList.forEach((value) => {
this.realList.forEach((real) => {
if (value.tableProp == real.tableProp) {
value.width = real.width;
}
});
});
if (data.configure.headerList.length <= 0) {
return;
}
const params = {
tableName: "hkDept",
configure: JSON.stringify(data.configure),
};
this.realList = data.configure.headerList;
this.$headerConfig.updateRealList(params).then((value) => {
console.log(value);
});
},
add() {
let row = null;
this.isAdd = true;
this.$layer.iframe({
shadeClose: false,
content: {
content: edit, //传递的组件对象
parent: this, //当前的vue对象
shadeClose: false,
},
title: "新增",
});
},
handleUpdate() {
this.isAdd = false;
this.$layer.iframe({
shadeClose: false,
content: {
content: edit, //传递的组件对象
parent: this, //当前的vue对象
shadeClose: false,
},
title: "修改",
});
},
handleDelete() {
this.$confirm("是否删除?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
})
.then(() => {
const params = {
id: this.currentRow.id,
};
this.$hkDept.delete(params).then((data) => {
console.log(data);
if (data.data.code === 200) {
this.$message({
message: "删除成功",
type: "success",
});
this.getlist();
}
});
})
.catch(() => {});
},
},
watch: {
seqence: function () {
this.getlist();
var oldIsSortShow = this.isSortShow;
//判断是否显示排序条件
if (this.seqence.length > 0) {
this.isSortShow = true;
} else {
this.isSortShow = false;
}
//判断table高度
if (oldIsSortShow != this.isSortShow) {
if (this.isSortShow) {
this.tableHeight = this.tableHeight - 47;
} else {
this.tableHeight = this.tableHeight + 47;
}
}
},
},
};
</script>
<style scoped lang="scss">
.el-table th.gutter {
display: table-cell !important;
}
>>> .el-form-item {
padding: 0px;
margin: 0px;
}
>>> .vue-treeselect__control {
height: 20px;
line-height: 28px;
}
>>> .el-divider {
margin: 1px;
}
>>> .el-table__body tr.current-row > td {
background-color: #8ac1ff !important;
cursor: pointer;
}
.el-table >>> tbody tr:hover > td {
background-color: #8ac1ff !important;
}
.mb8 >>> .el-select .el-input__inner {
border: 0px;
}
.mb8 >>> .el-select .el-input__inner {
border: 0px;
padding-right: 35px;
}
.sortSeq >>> .el-input__suffix-inner {
display: none;
}
>>> .el-form-item {
margin-bottom: 10px;
}
.el-divider {
margin-top: 0px;
margin-bottom: 5px;
}
>>> .el-table .el-table__header-wrapper th {
padding: 5px 0;
}
>>> .vue-treeselect__control {
height: 30px !important;
line-height: 30px !important;
}
>>> .vue-treeselect--single .vue-treeselect__input-container {
height: 30px !important;
line-height: 30px !important;
}
// >>> .el-input-group__append{
// padding: 5px;
// }
>>> .el-input-group__append .el-select,
.el-input-group__append .el-button,
.el-input-group__prepend .el-select,
.el-input-group__prepend .el-button {
margin-left: -28px !important;
margin-right: -33px !important;
}
</style>