2024-09-09 修改了大部分下拉组件为模糊筛选,减轻前端渲染压力

This commit is contained in:
2024-09-09 15:26:17 +08:00
parent fe5d3b70df
commit 563132273c
717 changed files with 107188 additions and 138520 deletions

View File

@@ -0,0 +1,883 @@
<template>
<div class="app-container">
<el-card style="height: 850px;padding: 0">
<el-tabs
v-model="PartType"
type="border-card"
@tab-click="pageCurrent=1;pageCurrent1=1;searchTable();searchTable1()">
<el-tab-pane label="零件图纸" name="零件图纸">
<div style="margin-top: 7px; margin-bottom: 7px">
<el-input
v-model="partsName"
size="small"
placeholder="零件名称"
clearable
style="float: left;width: 200px"/>
<el-button
type="primary"
plain
icon="el-icon-search"
size="small"
style="float: left;margin-left:10px"
@click="pageCurrent=1;searchTable()">查询
</el-button>
<el-button
type="danger"
style="margin-left: 90px;"
size="small"
icon="el-icon-delete"
plain
@click="deletePart">删除
</el-button>
<el-upload
:action="action"
:on-success="uploadSuccess"
:on-error="uploadFailure"
:show-file-list="showFileList"
:file-list="fileList"
style="float: left;"
class="upload-demo"
multiple>
<el-button
type="primary"
style="margin-left: 10px; width:120px"
size="small"
icon="el-icon-upload2"
plain
@click="batchImportOfDrawings">零件图
</el-button>
</el-upload>
<el-button
type="distribution"
style="margin-left: 10px; width:120px"
size="small"
icon="el-icon-upload2"
plain
@click="openDialog">总图
</el-button>
</div>
<div style="margin-top: 10px">
<el-table
v-loading="loading"
:data="tableData"
highlight-current-row
border
stripe
size="small"
style="width: 681px"
height="710px"
@selection-change="handleSelectionChange">
<el-table-column type="selection" align="center" width="50px"/>
<el-table-column :width="setColumnWidth('序号')" type="index" label="序号" align="center"/>
<!--<el-table-column width="170px" label="零件名称" align="center">
<template slot-scope="scope">
{{ scope.row.name }}
</template>
</el-table-column>-->
<el-table-column width="140px" label="图号/型号" align="center" show-overflow-tooltip>
<template slot-scope="scope">
{{ scope.row.name }}
</template>
</el-table-column>
<el-table-column :width="setColumnWidth('文件格式')" label="文件格式" align="center">
<template slot-scope="scope">
{{ scope.row.suffix }}
</template>
</el-table-column>
<el-table-column :width="setColumnWidth('导入时间')" label="导入时间" align="center">
<template slot-scope="scope">
{{ scope.row.导入时间 }}
</template>
</el-table-column>
<el-table-column :width="setColumnWidth('导入人')" label="导入人" align="center">
<template slot-scope="scope">
{{ scope.row.导入人 }}
</template>
</el-table-column>
<el-table-column label="操作" align="center">
<template slot-scope="scope">
<el-tooltip :open-delay="700" effect="dark" content="查看或删除图纸" placement="top">
<el-button type="text" icon="el-icon-picture-outline" size="mini" @click="getNum(scope.row)"/>
</el-tooltip>
</template>
</el-table-column>
</el-table>
</div>
<div class="block" style="margin-top: 10px;">
<el-pagination
:current-page="pageCurrent"
:page-sizes="[10, 20, 30, 40, 100]"
:page-size="pageSize"
:total="total"
layout="total, sizes, prev, pager, next, jumper"
@size-change="handleSizeChanges"
@current-change="handleCurrentChanges"/>
</div>
</el-tab-pane>
<el-tab-pane label="产品图纸" name="产品图纸">
<div style="margin-top: 7px; margin-bottom: 7px">
<el-cascader
ref="cascader"
:options="product"
:show-all-levels="false"
placeholder="产品名称"
clearable
style="float: left"
size="small"
@clear="clearData"
@change="getData"/>
<el-upload
:action="action2"
:on-success="uploadSuccess2"
:on-error="uploadFailure2"
:show-file-list="showFileList2"
:file-list="fileList2"
class="upload-demo"
multiple>
<el-button
type="primary"
style="margin-left: 290px; width:120px"
size="small"
icon="el-icon-upload2"
plain
@click="batchImportOfDrawings1">产品图
</el-button>
</el-upload>
</div>
<div style="margin-top: 10px">
<el-table
v-loading="loading"
:data="tableData1"
highlight-current-row
border
stripe
size="small"
style="width: 611px"
height="710px">
<el-table-column :width="setColumnWidth('序号')" label="序号" type="index" align="center"/>
<el-table-column :width="setColumnWidth('产品名称')" label="产品名称" align="center">
<template slot-scope="scope">
{{ scope.row.name }}
</template>
</el-table-column>
<el-table-column :width="setColumnWidth('文件格式')" label="文件格式" align="center">
<template slot-scope="scope">
{{ scope.row.suffix }}
</template>
</el-table-column>
<el-table-column :width="setColumnWidth('导入时间')" label="导入时间" align="center">
<template slot-scope="scope">
{{ scope.row.导入时间 }}
</template>
</el-table-column>
<el-table-column :width="setColumnWidth('导入人')" label="导入人" align="center">
<template slot-scope="scope">
{{ scope.row.导入人 }}
</template>
</el-table-column>
<el-table-column :width="setColumnWidth('操作')" label="操作" align="center">
<template slot-scope="scope">
<el-tooltip :open-delay="700" effect="dark" content="查看或删除图纸" placement="top">
<el-button type="text" icon="el-icon-picture-outline" size="mini" @click="getNum1(scope.row)"/>
</el-tooltip>
</template>
</el-table-column>
</el-table>
</div>
<div class="block" style="margin-top: 10px;">
<el-pagination
:current-page="pageCurrent1"
:page-sizes="[10, 20, 30, 40, 100]"
:page-size="pageSize1"
:total="total1"
layout="total, sizes, prev, pager, next, jumper"
@size-change="handleSizeChanges1"
@current-change="handleCurrentChanges1"/>
</div>
</el-tab-pane>
</el-tabs>
</el-card>
<el-dialog v-el-drag-dialog :visible.sync="dialogVisible" width="350px">
<div v-for="(file, key) in hadFile" :key="key">
<div class="wrapper">
<div class="content">
<div class="action">
<a v-show="isDeleteShow" class="delete" @click="deleteFileData(file.id)">删除</a>
</div>
<div v-if="file.suffix==='pdf'" class="icon">
<svg-icon icon-class="pdf"/>
</div>
<div v-else-if="file.suffix==='docx'||file.suffix === 'doc'" class="icon">
<svg-icon icon-class="doc"/>
</div>
<div v-else-if="file.suffix==='xlsx' || file.suffix === 'xls'" class="icon">
<svg-icon icon-class="excel"/>
</div>
<div v-else-if="file.suffix==='pptx' || file.suffix === 'ppt'" class="icon">
<svg-icon icon-class="ppt"/>
</div>
<div v-else-if="file.suffix==='jpg' || file.suffix === 'jpeg'|| file.suffix === 'png'" class="icon">
<svg-icon icon-class="pic"/>
</div>
<div v-else class="icon">
<svg-icon icon-class="file"/>
</div>
<a id="appUrl" :href="file.url" target="view_window">
<div class="info">{{ file.name }}</div>
</a>
</div>
</div>
</div>
</el-dialog>
<el-dialog
v-el-drag-dialog
:visible.sync="dialogVisibleMachine"
width="22%">
<span>订单编号</span>
<el-select
v-model="orderValue"
:remote-method="getOrder"
clearable
filterable
size="small"
placeholder="订单编号"
remote
@change="changeOrder">
<el-option
v-for="item in orderArray"
:key="item.value"
:label="item.label"
:value="item.value"/>
</el-select>
<div style="float: right;margin-right: 20px">
<el-upload
:disabled="disabledMachine"
:action="action1"
:on-success="uploadSuccess1"
:on-error="uploadFailure1"
:show-file-list="showFileList1"
:file-list="fileList1"
class="upload-demo"
multiple>
<el-button :disabled="disabledMachine" size="small" type="shengcheng">点击上传</el-button>
</el-upload>
</div>
<div v-for="(file, key) in hadFile1" :key="key">
<div class="wrapper">
<div class="content">
<div class="action">
<a class="delete" @click="deleteFileData1(file.id)">删除</a>
</div>
<div v-if="file.suffix==='pdf'" class="icon">
<svg-icon icon-class="pdf"/>
</div>
<div v-else-if="file.suffix==='docx'||file.suffix === 'doc'" class="icon">
<svg-icon icon-class="doc"/>
</div>
<div v-else-if="file.suffix==='xlsx' || file.suffix === 'xls'" class="icon">
<svg-icon icon-class="excel"/>
</div>
<div v-else-if="file.suffix==='pptx' || file.suffix === 'ppt'" class="icon">
<svg-icon icon-class="ppt"/>
</div>
<div v-else-if="file.suffix==='jpg' || file.suffix === 'jpeg'|| file.suffix === 'png'" class="icon">
<svg-icon icon-class="pic"/>
</div>
<div v-else class="icon">
<svg-icon icon-class="file"/>
</div>
<a id="appUrl1" :href="file.url" target="view_window">
<div class="info">{{ file.name }}</div>
</a>
</div>
</div>
</div>
</el-dialog>
<el-dialog v-el-drag-dialog :visible.sync="dialogVisible1" width="350px">
<div v-for="(file, key) in hadFile2" :key="key">
<div class="wrapper">
<div class="content">
<div class="action">
<a v-show="isDeleteShow1" class="delete" @click="deleteFileData2(file.id)">删除</a>
</div>
<div v-if="file.suffix==='pdf'" class="icon">
<svg-icon icon-class="pdf"/>
</div>
<div v-else-if="file.suffix==='docx'||file.suffix === 'doc'" class="icon">
<svg-icon icon-class="doc"/>
</div>
<div v-else-if="file.suffix==='xlsx' || file.suffix === 'xls'" class="icon">
<svg-icon icon-class="excel"/>
</div>
<div v-else-if="file.suffix==='pptx' || file.suffix === 'ppt'" class="icon">
<svg-icon icon-class="ppt"/>
</div>
<div v-else-if="file.suffix==='jpg' || file.suffix === 'jpeg'|| file.suffix === 'png'" class="icon">
<svg-icon icon-class="pic"/>
</div>
<div v-else class="icon">
<svg-icon icon-class="file"/>
</div>
<a id="appUrl2" :href="file.url" target="view_window">
<div class="info">{{ file.name }}</div>
</a>
</div>
</div>
</div>
</el-dialog>
</div>
</template>
<script>
import { mapGetters } from 'vuex'
import request, { MESDownloadFile, MESUploadFile, MESUploadFileProduct, uploadFileMachine } from '@/utils/request'
export default {
data() {
return {
PartType: '零件图纸',
action: '',
showFileList: false,
hadFile: [],
fileList: [],
multipleSelection_variable: [],
multipleSelection: [],
dialogVisible: false,
close: false, // 是否显示关闭按钮
isDeleteShow: false,
deleteShow: '1',
action1: '',
showFileList1: false,
hadFile1: [],
fileList1: [],
disabledMachine: true,
dialogVisibleMachine: false,
action2: '',
showFileList2: false,
dialogVisible1: false,
isDeleteShow1: false,
hadFile2: [],
fileList2: [],
orderValue: '',
orderArray: [],
machineToolName: '',
machineTool: [],
productValue: '',
productValue1: '',
product: [],
partsName: '',
loading: false, // 数据加载
total: 0, // 分页总数
total1: 0, // 分页总数
tableData: [],
tableData1: [],
pageCurrent: 1, // 分页当前页
pageSize: 100, // 分页每页显示条数
pageCurrent1: 1, // 分页当前页
pageSize1: 100, // 分页每页显示条数
orderName: '', // 排序列名
order: '' // 排序方式
}
},
computed: {
...mapGetters([
'id',
'token'
])
},
created() {
this.fetchData()
this.searchTable()
},
methods: {
fetchData() {
this.getTreeData()
this.getOrder()
},
handleSelectionChange(val) {
this.multipleSelection = val
},
deletePart() {
if (this.multipleSelection.length === 0) {
this.$message.warning('请选择要删除的零件图!')
return
}
this.$confirm('此操作将永久删除图纸, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
const materialGroup = []
this.multipleSelection_variable = this.multipleSelection
this.multipleSelection = []
for (let i = 0; i < this.multipleSelection_variable.length; i++) {
materialGroup[i] = this.multipleSelection_variable[i].uid
}
var param = []
param[0] = ['uid组', materialGroup]
var Data = this.CreateData('12', '机加工MES_零件图PDF表_删除数据', param)
this.ExecDatabase(Data).then(response => {
if (response.data[0].result === '1') {
this.$message.success('删除成功')
this.searchTable()
this.$refs.multipleTable.clearSelection()
} else {
this.$message.success('选入失败')
}
})
}).catch(() => {
this.$message({
type: 'info',
message: '已取消删除'
})
})
},
getOrder(query) {
this.orderArray = []
var param = []
param[0] = ['订单编号', query]
var Data = this.CreateData('11', '订单信息_列表_查询数据_bak', param)
this.ExecDatabase(Data).then(response => {
for (let i = 0; i < response.data.length; i++) {
this.orderArray.push({
label: response.data[i].订单编号,
value: response.data[i].订单流水号
})
}
})
},
getProduct() {
var param = []
var Data = this.CreateData('11', '产品信息_基础表_查询数据', param)
this.ExecDatabase(Data).then(response => {
for (let i = 0; i < response.data.length; i++) {
this.product.push({
label: response.data[i].产品名称,
value: response.data[i].产品名称
})
}
})
},
searchTable() {
let partsName_check
this.partsName ? partsName_check = 1 : partsName_check = 0
var param = []
param[0] = ['零件图号_check', partsName_check]
param[1] = ['零件图号', this.partsName]
var Data = this.CreateData('11', '技术中心_零件图维护_查询', param, this.pageSize, this.pageCurrent)
this.ExecDatabase(Data).then(response => {
this.tableData = response.data.rows
this.total = response.data.total
})
},
getTreeData() {
var param = []
param[0] = ['子节点', 0]
var Data = this.CreateData('11', '产品关系_查询节点', param)
this.ExecDatabase(Data).then(response => {
const data = response.data
this.product = this.tree(data, 0)
})
},
tree(data, pid) {
const result = []
let temp
for (let i = 0; i < data.length; i++) {
if (data[i].父节点 === pid) {
const obj = { label: data[i].节点名称, value: data[i].子节点 }
temp = this.tree(data, data[i].子节点)
if (temp.length > 0) {
obj.children = temp
}
result.push(obj)
}
}
return result
},
clearData() {
this.productValue = ''
this.searchTable()
},
getData(val) {
this.productValue1 = val[val.length - 1]
var param = []
param[0] = ['产品流水号', this.productValue1]
var Data = this.CreateData('11', '产品关系_获取产品名称', param)
this.ExecDatabase(Data).then(response => {
this.productValue = response.data[0].产品名称
}).then(() => {
this.searchTable1()
})
},
searchTable1() {
let productValue_check
this.productValue ? productValue_check = 1 : productValue_check = 0
var param = []
param[0] = ['产品名称_check', productValue_check]
param[1] = ['产品名称', this.productValue]
var Data = this.CreateData('11', '技术中心_产品图维护_查询', param, this.pageSize1, this.pageCurrent1)
this.ExecDatabase(Data).then(response => {
this.tableData1 = response.data.rows
this.total1 = response.data.total
})
},
batchImportOfDrawings() {
this.action = `${MESUploadFile}?&num=1&tableName=机加工MES_零件图PDF表&type=1&UploaderName=${this.id}`
},
batchImportOfDrawings1() {
this.action2 = `${MESUploadFileProduct}?&num=1&tableName=图纸维护_产品图纸&type=1&UploaderName=${this.id}`
},
uploadSuccess(res, file, fileList) {
this.searchTable()
console.log(res, fileList, 1111)
if (res[0].result === '1') {
const index = fileList.indexOf(file)
fileList.splice(index, 1)
} else {
this.str = res[0].result
this.arr = this.str.split('|')
if (this.arr[1] === '无该零件') {
this.$notify.error({
title: '提示',
message: `${this.arr[0]}该零件不存在,请检查上传文件名称是否正确!`,
duration: 0
})
}
if (this.arr[1] === '重复') {
this.$notify.error({
title: '提示',
message: `${this.arr[0]}请勿重复上传!`,
duration: 0
})
}
if (this.arr[1] === '零件图号不正确') {
this.$notify.error({
title: '提示',
message: `${this.arr[0]}和所选图号不符!`,
duration: 0
})
}
}
if (fileList.length === 0) {
this.$message.success('文件上传成功')
}
},
uploadFailure(res, file, fileList) {
fileList.map(file => {
this.$message.error(`${file.name}文件上传失败,请检查上传文件是否正确!`)
})
},
uploadSuccess2(res, file, fileList) {
this.searchTable1()
if (res[0].result === '1') {
const index = fileList.indexOf(file)
fileList.splice(index, 1)
} else {
this.str = res[0].result
this.arr = this.str.split('|')
if (this.arr[1] === '无该产品') {
this.$notify.error({
title: '提示',
message: `${this.arr[0]}该产品不存在,请检查上传文件名称是否正确!`,
duration: 0
})
}
if (this.arr[1] === '重复') {
this.$notify.error({
title: '提示',
message: `${this.arr[0]}请勿重复上传!`,
duration: 0
})
}
if (this.arr[1] === '产品名称不正确') {
this.$notify.error({
title: '提示',
message: `${this.arr[0]}和所选产品不符!`,
duration: 0
})
}
}
if (fileList.length === 0) {
this.$message.success('文件上传成功')
}
},
uploadFailure2(res, file, fileList) {
fileList.map(file => {
this.$message.error(`${file.name}文件上传失败,请检查上传文件是否正确!`)
})
},
// 查看零件图
getNum(row) {
this.num = row.num
this.dialogVisible = true
this.getFileList(row.name)
},
async getFileList(value) {
this.hadFile = []
this.deleteShow === '1' ? this.isDeleteShow = true : this.isDeleteShow = false
if (value) {
await request({
url: '',
method: 'post',
data: {
type: '3',
name: `select * from 机加工MES_零件图PDF表 where 是否启用 = 1 and name = '${value}'`
}
}).then(data => {
this.suffix = data.data
if (data.data.length > 0) {
const server = `${MESDownloadFile}`.split('/')
data.data.map(item => {
this.hadFile.push({
url: `http://${server[2]}/webpage/part/${item.uid}.${item.suffix}`,
name: `${item.name}.${item.suffix}`,
suffix: item.suffix,
id: item.uid
})
})
}
})
}
},
// 删除零件图
async deleteFileData(id) {
this.$confirm('此操作将永久删除该行, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
request({
url: '',
method: 'post',
data: {
type: '3',
name: `delete from 机加工MES_零件图PDF表 where uid = N'${id}'`
}
}).then(response => {
if (response.data.length === 0) {
this.$message.success('删除成功')
this.dialogVisible = false
this.getFileList(this.num)
this.searchTable()
} else {
this.$message.error('删除失败')
this.dialogVisible = false
this.getFileList(this.num)
}
})
}).catch(() => {
this.$message({
type: 'info',
message: '已取消删除'
})
})
},
getNum1(row) {
this.num = row.num
this.dialogVisible1 = true
this.getFileList1(row.name)
},
async getFileList1(value) {
this.hadFile2 = []
this.deleteShow === '1' ? this.isDeleteShow1 = true : this.isDeleteShow1 = false
if (value) {
await request({
url: '',
method: 'post',
data: {
type: '3',
name: `select * from 图纸维护_产品图纸 where 是否启用 = 1 and name = '${value}'`
}
}).then(data => {
this.suffix = data.data
if (data.data.length > 0) {
const server = `${MESDownloadFile}`.split('/')
data.data.map(item => {
this.hadFile2.push({
url: `http://${server[2]}/webpage/part/${item.uid}.${item.suffix}`,
name: `${item.name}.${item.suffix}`,
suffix: item.suffix,
id: item.uid
})
})
}
})
}
},
// 删除零件图
async deleteFileData2(id) {
this.$confirm('此操作将永久删除该行, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
request({
url: '',
method: 'post',
data: {
type: '3',
name: `delete from 图纸维护_产品图纸 where uid = N'${id}'`
}
}).then(response => {
if (response.data.length === 0) {
this.$message.success('删除成功')
this.dialogVisible1 = false
this.getFileList1(this.num)
this.searchTable1()
} else {
this.$message.error('删除失败')
this.dialogVisible1 = false
this.getFileList1(this.num)
}
})
}).catch(() => {
this.$message({
type: 'info',
message: '已取消删除'
})
})
},
openDialog() {
this.orderValue = []
this.hadFile1 = []
this.disabledMachine = true
this.dialogVisibleMachine = true
},
changeOrder() {
this.orderValue === '' ? this.disabledMachine = true : this.disabledMachine = false
this.action1 = `${uploadFileMachine}?&MachineNum=${this.orderValue}`
this.getFileData(this.orderValue)
},
uploadSuccess1(res, file, fileList) {
if (res[0].result === '1') {
const index = fileList.indexOf(file)
fileList.splice(index, 1)
} else {
this.$message.error(`${file.name}文件上传失败,请检查上传文件是否正确!`)
}
if (fileList.length === 0) {
this.$message.success('文件上传成功')
this.getFileData(this.orderValue)
}
},
uploadFailure1(a, file, fileList) {
fileList.map(file => {
this.$message.error(`${file.name}文件上传失败,请检查上传文件是否正确!`)
})
},
// 在什么情况下需要查询上传的附件调用this.getFileData()即可根据
getFileData(orderValue) {
this.hadFile1 = []
var param = []
param[0] = ['订单流水号', orderValue]
var Data = this.CreateData('11', 'PDM_机床总图_查询数据', param)
this.ExecDatabase(Data).then(res => {
this.suffix = res.data
if (res.data.length > 0) {
const server = `${MESDownloadFile}`.split('/')
res.data.map(item => {
this.hadFile1.push({
url: `http://${server[2]}/webpage/file/${item.文件标识}.${item.文件后缀}`,
name: `${item.文件名称}.${item.文件后缀}`,
suffix: item.文件后缀,
id: item.文件标识
})
})
}
})
},
deleteFileData1(id) {
var param = []
param[0] = ['文件标识', id]
var Data = this.CreateData('12', 'PDM_机床总图_删除数据', param)
this.ExecDatabase(Data).then(res => {
if (res.data[0].result === '1') {
this.getFileData(this.orderValue)
this.$message.success('删除成功')
} else {
this.$message.success('删除失败')
}
})
},
handleSizeChanges(val) {
this.pageCurrent = 1
this.pageSize = val
this.searchTable()
},
handleCurrentChanges(val) {
this.pageCurrent = val
this.searchTable()
},
handleSizeChanges1(val) {
this.pageCurrent1 = 1
this.pageSize1 = val
this.searchTable()
},
handleCurrentChanges1(val) {
this.pageCurrent1 = val
this.searchTable()
}
}
}
</script>
<style scoped lang="scss">
/deep/ .el-card__body {
padding: 0px !important;
}
</style>
<style scoped>
.wrapper {
width: 90%;
height: 50px;
overflow: hidden;
border: 1px solid #b8c7d9;
/*float: left;*/
margin: 10px;
}
.content {
position: relative;
padding: 8px 8px 0 8px;
}
.action {
position: absolute;
top: 2px;
right: 8px;
}
.delete {
padding: 0 5px;
border-radius: 3px;
color: #0f84b0;
font-size: 12px;
}
.delete:hover {
background: -webkit-linear-gradient(top, #0ba9e3, #0099d3);
color: #fff;
}
a {
text-decoration: none;
}
.icon {
width: 30px;
height: 30px;
display: inline-block;
margin-right: 7px;
margin-top: 2px;
font-size: 26px;
}
.info {
width: 160px;
height: 50px;
position: absolute;
left: 44px;
line-height: 30px;
display: inline-block;
color: #999;
}
</style>