601 lines
15 KiB
Plaintext
601 lines
15 KiB
Plaintext
<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
|
||
v-hasPermi="[permissionKey + 'add']"
|
||
icon="el-icon-plus"
|
||
size="mini"
|
||
type="primary"
|
||
@click="handleAdd"
|
||
>新增
|
||
</el-button
|
||
>
|
||
</el-col>
|
||
<el-col :span="1.5">
|
||
<el-button
|
||
v-hasPermi="[permissionKey + '_update']"
|
||
:disabled="!isSingleSelected"
|
||
icon="el-icon-edit"
|
||
size="mini"
|
||
type="warning"
|
||
@click="handleUpdate"
|
||
>修改
|
||
</el-button>
|
||
</el-col>
|
||
<el-col :span="1.5">
|
||
<el-button
|
||
v-hasPermi="[permissionKey + '_delete']"
|
||
:disabled="!isSelected"
|
||
icon="el-icon-delete"
|
||
size="mini"
|
||
type="danger"
|
||
@click="handleDelete"
|
||
>删除
|
||
</el-button>
|
||
</el-col>
|
||
<el-popover
|
||
placement="bottom-end"
|
||
style="float: right"
|
||
title="自定义显示列"
|
||
trigger="hover"
|
||
width="250"
|
||
@show="initPopover"
|
||
>
|
||
<headConfig
|
||
ref="headConfig"
|
||
:propThis="propThis"
|
||
@fathers="fathers"
|
||
></headConfig>
|
||
<el-button
|
||
slot="reference"
|
||
class="el-icon-caret-bottom"
|
||
size="mini"
|
||
style="margin-right: 5px"
|
||
type="primary"
|
||
>自定义列
|
||
</el-button>
|
||
</el-popover>
|
||
</el-row>
|
||
<el-row v-if="isSortShow" :gutter="10" class="mb8" style="margin: 10px 0px">
|
||
<el-tag v-for="(item, index) in seqence"
|
||
closable style="margin-right: 6px;"
|
||
type="info"
|
||
@close="handleSeqenceTagClose(index)">
|
||
{{ item | filterSequence(seqenceOptions) }}
|
||
</el-tag>
|
||
</el-row>
|
||
<!-- 列表-->
|
||
<el-table
|
||
v-if="tableData.length"
|
||
ref="table"
|
||
v-loading="loading"
|
||
:data="tableData"
|
||
:height="tableHeight"
|
||
border
|
||
class="tableStyle"
|
||
highlight-current-row
|
||
style="width: 100%"
|
||
@sort-change="sortChange"
|
||
@header-dragend="headerDragend"
|
||
@current-change="handleCurrentRowChange"
|
||
@selection-change="handleSelectionChange"
|
||
>
|
||
<el-table-column type="selection" width="50"/>
|
||
<el-table-column align="center" label="序号" type="index" width="50"/>
|
||
<el-table-column
|
||
v-for="(item, index) in realList"
|
||
:key="index"
|
||
:align="item.align"
|
||
:label="item.tableTitle"
|
||
:min-width="item.width"
|
||
:prop="item.tableProp"
|
||
:show-overflow-tooltip="item.show_overflow_tooltip"
|
||
:sortable="item.notSort == true ? false : `custom`"
|
||
header-align="center"
|
||
></el-table-column>
|
||
</el-table>
|
||
<el-pagination
|
||
:current-page="queryParams.pageNo"
|
||
:page-size="queryParams.pageSize"
|
||
:page-sizes="[10, 20, 50, 100, 200, 500, 1000]"
|
||
:total="total"
|
||
layout="total, sizes, prev, pager, next, jumper"
|
||
@size-change="handlePageSizeChange"
|
||
@current-change="handlePageNumberChange"
|
||
></el-pagination>
|
||
</div>
|
||
</template>
|
||
|
||
<script>
|
||
import selectRowMixin from "@/mixin/selectRowMixin"
|
||
import edit from "./edit"
|
||
|
||
const edgeStatusDict = [
|
||
{
|
||
key: 1,
|
||
text: '成功'
|
||
},
|
||
{
|
||
key: 2,
|
||
text: '失败'
|
||
}
|
||
]
|
||
const erpStatusDict = [
|
||
{
|
||
key: 0,
|
||
text: '待确认'
|
||
},
|
||
{
|
||
key: 1,
|
||
text: '成功'
|
||
},
|
||
{
|
||
key: 2,
|
||
text: '失败'
|
||
}
|
||
]
|
||
const operTypeDict = [
|
||
{
|
||
key: 1,
|
||
text: '新增'
|
||
},
|
||
{
|
||
key: 2,
|
||
text: '修改'
|
||
},
|
||
{
|
||
key: 3,
|
||
text: '删除'
|
||
}
|
||
]
|
||
const orderTypeDict = [
|
||
{
|
||
key: 1,
|
||
text: '订单'
|
||
},
|
||
{
|
||
key: 2,
|
||
text: '子件'
|
||
}
|
||
]
|
||
|
||
export default {
|
||
name: "tempLate",
|
||
mixins: [selectRowMixin],
|
||
components: {},
|
||
data() {
|
||
return {
|
||
permissionKey: 'tempLate',
|
||
tableHeaderKey: 'prodLog',
|
||
tableData: [],
|
||
queryParams: {
|
||
pageSize: 50,
|
||
pageNo: 1
|
||
},
|
||
seqence: [], // 选中的排序
|
||
realList: [],
|
||
tableHeight: undefined,
|
||
total: null,
|
||
loading: false,
|
||
propThis: this,
|
||
seqenceOptions: [],
|
||
orderTypeDict,
|
||
operTypeDict,
|
||
erpStatusDict,
|
||
edgeStatusDict,
|
||
}
|
||
},
|
||
computed: {
|
||
queryFormConfig() {
|
||
return {
|
||
controlList: [
|
||
{
|
||
key: "orderProdNumber",
|
||
label: "生产订单编号",
|
||
type: "input",
|
||
placeholder: "请输入",
|
||
prop: "orderProdNumber",
|
||
},
|
||
{
|
||
key: "edgeStatus",
|
||
multiple: false,
|
||
label: "边缘端同步状态",
|
||
type: "select",
|
||
placeholder: "请选择",
|
||
prop: "edgeStatus",
|
||
options: this.edgeStatusDict,
|
||
optionLabel: "text",
|
||
optionValue: "key"
|
||
},
|
||
{
|
||
key: "erpStatus",
|
||
multiple: false,
|
||
label: "ERP同步状态",
|
||
type: "select",
|
||
placeholder: "请选择",
|
||
prop: "erpStatus",
|
||
options: this.erpStatusDict,
|
||
optionLabel: "text",
|
||
optionValue: "key"
|
||
},
|
||
{
|
||
key: "operType",
|
||
multiple: true,
|
||
label: "操作类型",
|
||
type: "select",
|
||
placeholder: "请选择",
|
||
prop: "operType",
|
||
options: this.operTypeDict,
|
||
optionLabel: "text",
|
||
optionValue: "key"
|
||
},
|
||
{
|
||
key: "orderType",
|
||
multiple: true,
|
||
label: "类型",
|
||
type: "select",
|
||
placeholder: "请选择",
|
||
prop: "orderType",
|
||
options: this.orderTypeDict,
|
||
optionLabel: "text",
|
||
optionValue: "key"
|
||
},
|
||
],
|
||
config: {
|
||
//零散的配置参数
|
||
hasAdvQuery: false, //有无高级查询
|
||
storageMode: true,//记忆模式,开启后每次查询会存储到localstorage中,存储名为下面的storageKey
|
||
storageKey: this.tableHeaderKey,
|
||
propThis: this, //this
|
||
preFixWidthClass: "width_0100", //前置框的宽度calss,不写则为默认100
|
||
marginWidthClass: "width_0180", //空白选择框的宽度calss,不写则为默认180
|
||
},
|
||
defaultList: [
|
||
//默认展示的属性,跟controList里面的key相对应
|
||
"orderProdNumber", "orderType"
|
||
],
|
||
}
|
||
},
|
||
isSortShow() {
|
||
return this.seqence.length
|
||
}
|
||
},
|
||
filters: {
|
||
filterSequence(key, seqenceOptions) {
|
||
const find = seqenceOptions.find(item => item.value === key)
|
||
return find ? find.label : key
|
||
}
|
||
},
|
||
mounted() {
|
||
this.initData()
|
||
},
|
||
methods: {
|
||
async initData() {
|
||
this.$refs.query.init()
|
||
// 排序的展示列表
|
||
let tempList = this.$headerConfig.getList(this.tableHeaderKey)
|
||
this.seqenceOptions = tempList.filter(item => !item.notSort).map(item => [
|
||
{
|
||
value: item.tableProp.replace("Show", "") + " ascending",
|
||
label: item.tableTitle + " 升序"
|
||
},
|
||
{
|
||
value: item.tableProp.replace("Show", "") + " descending",
|
||
label: item.tableTitle + " 降序"
|
||
}
|
||
]).flat()
|
||
|
||
await this.getList(this.initTableHeight)
|
||
const res = await this.$headerConfig.getRealList({tableName: this.tableHeaderKey})
|
||
|
||
this.handleRes(res, async data => {
|
||
// 是否有缓存的表头
|
||
if (data) {
|
||
let temp = JSON.parse(data)
|
||
// console.log('缓存的表头', temp)
|
||
this.realList = temp.headerList
|
||
this.List = temp.List
|
||
} else {
|
||
this.List = this.$headerConfig.getList(this.tableHeaderKey)
|
||
this.realList = this.List
|
||
|
||
let temp = {
|
||
headerList: this.realList,
|
||
List: this.List,
|
||
}
|
||
|
||
const params = {
|
||
tableName: this.tableHeaderKey,
|
||
configure: JSON.stringify(temp),
|
||
}
|
||
this.$headerConfig.updateRealList(params)
|
||
}
|
||
})
|
||
this.$nextTick(() => {
|
||
this.$refs.table.doLayout()
|
||
})
|
||
},
|
||
// 获取列表
|
||
async getList(callback) {
|
||
const orders = this.seqence.map(item => item.replace("ascending", "asc").replace("descending", "desc"))
|
||
const params = Object.assign({}, this.queryParams, {orders})
|
||
|
||
this.loading = true
|
||
const res = await this.$plan.getProdLogList(params)
|
||
this.loading = false
|
||
|
||
this.handleRes(res, data => {
|
||
this.tableData = data.data.map(item => {
|
||
this.parseDict(this.orderTypeDict, item, 'orderType', 'key', 'text')
|
||
this.parseDict(this.operTypeDict, item, 'operType', 'key', 'text')
|
||
this.parseDict(this.erpStatusDict, item, 'erpStatus', 'key', 'text')
|
||
this.parseDict(this.edgeStatusDict, item, 'edgeStatus', 'key', 'text')
|
||
return item
|
||
})
|
||
this.total = data.recordsTotal
|
||
})
|
||
callback && callback()
|
||
},
|
||
// 初始化表格高度
|
||
initTableHeight() {
|
||
if (!this.$refs.table) {
|
||
setTimeout(this.initTableHeight, 30)
|
||
return
|
||
}
|
||
// 顶部导航 84,底部分页 30, 底部padding 20 + border 1 + 1
|
||
this.tableHeight = window.innerHeight - this.$refs.table.$el.offsetTop - 84 - 30 - 22
|
||
// console.log('高度:', this.tableHeight, window.innerHeight, this.$refs.table.$el.offsetTop)
|
||
},
|
||
getQueryParams() {
|
||
this.queryParams = Object.assign({}, this.$refs.query.getQueryParams(), {
|
||
pageSize: this.queryParams.pageSize,
|
||
pageNo: this.queryParams.pageNo
|
||
})
|
||
},
|
||
handleQuery() {
|
||
this.getQueryParams()
|
||
// this.isTreeShow = false //以表格形式显示 ,所以将isTreeShow置为false
|
||
this.queryParams.pageNo = 1
|
||
this.getList()
|
||
},
|
||
resetQuery() {
|
||
this.queryParams = {
|
||
pageSize: 50,
|
||
pageNo: 1
|
||
}
|
||
this.seqence = []
|
||
this.getList()
|
||
},
|
||
// 页数
|
||
handlePageSizeChange(val) {
|
||
this.queryParams.pageSize = val
|
||
this.getList()
|
||
},
|
||
// 页码
|
||
handlePageNumberChange(val) {
|
||
this.queryParams.pageNo = val
|
||
this.getList()
|
||
},
|
||
handleSeqenceTagClose(index) {
|
||
this.seqence.splice(index, 1)
|
||
this.$nextTick(() => {
|
||
this.initTableHeight()
|
||
})
|
||
},
|
||
sortChange({column, prop, order}) {
|
||
let insertValue = prop.replace("Show", "") + " " + order
|
||
let insertEntries = insertValue.split(" ")
|
||
|
||
const hadKeys = this.seqence.map(item => item.split(" ")[0])
|
||
const hadIndex = hadKeys.indexOf(insertEntries[0])
|
||
|
||
if (hadIndex > -1) {
|
||
// this.seqence.splice(hadIndex, 1, insertEntries[1] !== 'null' ? insertValue : undefined)
|
||
insertEntries[1] === 'null' ? this.seqence.splice(hadIndex, 1)
|
||
: this.seqence.splice(hadIndex, 1, insertValue)
|
||
} else {
|
||
this.seqence.push(insertValue)
|
||
}
|
||
|
||
this.$nextTick(() => {
|
||
this.initTableHeight()
|
||
})
|
||
},
|
||
headerDragend(newWidth, oldWidth, column, event) {
|
||
this.realList.forEach((value) => {
|
||
if (column.property === value.tableProp) {
|
||
value.width = newWidth
|
||
}
|
||
})
|
||
this.$refs.headConfig.init()
|
||
setTimeout(() => {
|
||
this.$refs.headConfig.show()
|
||
}, 1000)
|
||
},
|
||
// show 排序时
|
||
async initPopover() {
|
||
const res = await this.$headerConfig.getRealList({tableName: this.tableHeaderKey})
|
||
|
||
this.handleRes(res, data => {
|
||
let temp = JSON.parse(data)
|
||
this.realList = temp.headerList
|
||
this.$refs.headConfig.init()
|
||
})
|
||
},
|
||
fathers(data) {
|
||
// 我估计,List 是用在自定义列按钮里的,realList 是用在表格里的
|
||
this.List = data.configure.List
|
||
const realListWidthMap = Object.fromEntries(this.realList.map(item => [item.tableProp, item.width]))
|
||
|
||
data.configure.List.forEach((value) => {
|
||
realListWidthMap[value.tableProp] && (value.width = realListWidthMap[value.tableProp])
|
||
})
|
||
|
||
data.configure.headerList.forEach((value) => {
|
||
realListWidthMap[value.tableProp] && (value.width = realListWidthMap[value.tableProp])
|
||
})
|
||
|
||
if (!data.configure.headerList.length) return
|
||
|
||
const params = {
|
||
tableName: this.tableHeaderKey,
|
||
configure: JSON.stringify(data.configure),
|
||
}
|
||
|
||
this.realList = data.configure.headerList
|
||
this.$headerConfig.updateRealList(params)
|
||
this.$nextTick(() => {
|
||
this.initTableHeight()
|
||
this.$refs.table && this.$refs.table.doLayout()
|
||
})
|
||
},
|
||
// 新增
|
||
handleAdd() {
|
||
this.$layer.iframe({
|
||
shadeClose: false,
|
||
content: {
|
||
content: edit, //传递的组件对象
|
||
parent: this, //当前的vue对象
|
||
shadeClose: false,
|
||
},
|
||
area: ["80vw", "80vh"],
|
||
title: "新增",
|
||
})
|
||
},
|
||
// 修改
|
||
handleUpdate() {
|
||
this.$layer.iframe({
|
||
shadeClose: false,
|
||
content: {
|
||
content: edit, //传递的组件对象
|
||
parent: this, //当前的vue对象
|
||
shadeClose: false,
|
||
data: {
|
||
row: this.currentRow
|
||
},
|
||
area: ["80vw", "80vh"],
|
||
},
|
||
title: "修改",
|
||
})
|
||
},
|
||
// 删除
|
||
handleDelete() {
|
||
this.$confirm("是否删除?", "提示", {
|
||
confirmButtonText: "确定",
|
||
cancelButtonText: "取消",
|
||
type: "warning",
|
||
})
|
||
.then(() => {
|
||
const params = {
|
||
id: this.currentRow.id,
|
||
}
|
||
this.$jobPosition.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()
|
||
},
|
||
},
|
||
}
|
||
</script>
|
||
|
||
<style lang="scss" scoped>
|
||
.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>
|