更新
This commit is contained in:
@@ -29,6 +29,7 @@
|
||||
</el-select>
|
||||
|
||||
<el-button icon="el-icon-search" type="success" size="small" @click="pageCurrentWB = 1;pageSizeWB = 10;pageCurrent = 1;pageSize = 10;getTableData()">查询</el-button>
|
||||
<el-button :loading="downloadLoading" type="success" icon="el-icon-download" size="small" style="margin-left: 15px" @click="handleDownload()">导出EXCEL</el-button>
|
||||
</el-card>
|
||||
<el-card>
|
||||
<div v-for="(file, key) in hadFile" :key="key">
|
||||
@@ -259,10 +260,13 @@
|
||||
import { projectSelect, machineSelect, groupSelect, basicPartsData, deleteBasicParts, purchasePartsData, deletePurchaseData, getFileData } from '@/api/TechnologyCenter/QueryParts'
|
||||
import { mapGetters } from 'vuex'
|
||||
import { ServerIP } from '@/utils/request'
|
||||
import request from '@/utils/request'
|
||||
|
||||
export default {
|
||||
name: 'Index',
|
||||
data() {
|
||||
return {
|
||||
downloadLoading: false,
|
||||
projectValue: '',
|
||||
project: [],
|
||||
machineValue: '',
|
||||
@@ -342,6 +346,83 @@ export default {
|
||||
this.fetchData()
|
||||
},
|
||||
methods: {
|
||||
async handleDownload() {
|
||||
this.downloadLoading = true
|
||||
await request({
|
||||
url: '',
|
||||
method: 'post',
|
||||
data: {
|
||||
type: '3',
|
||||
name: `declare @项目流水号 int =${this.projectValue}
|
||||
create table #临时表1
|
||||
(
|
||||
id int IDENTITY (1,1) not null,
|
||||
物料名称 nvarchar(50),
|
||||
物料规格 nvarchar(50),
|
||||
物料型号 nvarchar(50),
|
||||
primary key (id)
|
||||
);
|
||||
create table #临时表2
|
||||
(
|
||||
id int IDENTITY (1,1) not null,
|
||||
物料名称 nvarchar(50),
|
||||
物料规格 nvarchar(50),
|
||||
物料型号 nvarchar(50),
|
||||
总数量 int,
|
||||
primary key (id)
|
||||
);
|
||||
insert into #临时表1 select distinct 物料名称,物料规格,物料型号 from dbo.零件查询_物料规格型号_统计查询_视图
|
||||
where 项目流水号=@项目流水号
|
||||
declare @id int =1
|
||||
declare @id2 int
|
||||
declare @物料名称 nvarchar(50)
|
||||
declare @物料规格 nvarchar(50)
|
||||
declare @物料型号 nvarchar(50)
|
||||
declare @总数量 int
|
||||
while (@id<=(select COUNT (id) from #临时表1 ))
|
||||
begin
|
||||
select @物料名称=物料名称,@物料规格=物料规格,@物料型号=物料型号 from #临时表1
|
||||
where id=@id
|
||||
insert into #临时表2 (物料名称,物料规格,物料型号) values (@物料名称,@物料规格,@物料型号)
|
||||
set @id2 = @@IDENTITY
|
||||
select @总数量 = COUNT(物料流水号) from 零件查询_物料规格型号_统计查询_视图
|
||||
where 物料名称=@物料名称 and 物料规格=@物料规格 and 物料型号=@物料型号 and 项目流水号=@项目流水号
|
||||
update #临时表2 set 总数量 = @总数量
|
||||
where id=@id2
|
||||
set @id = @id + 1
|
||||
end
|
||||
select * from #临时表2
|
||||
drop table #临时表1
|
||||
drop table #临时表2`
|
||||
}
|
||||
}).then(res => {
|
||||
if (res.data.length === 0) {
|
||||
this.$message.error('暂无数据')
|
||||
this.downloadLoading = false
|
||||
} else {
|
||||
import('./Export2Excel').then(excel => {
|
||||
const tHeader = ['物料名称', '物料型号', '物料规格', '总数量']
|
||||
const filterVal = ['物料名称', '物料型号', '物料规格', '总数量']
|
||||
const list = res.data
|
||||
const data = this.formatJson(filterVal, list)
|
||||
excel.export_json_to_excel({
|
||||
header: tHeader,
|
||||
data,
|
||||
filename: 'EXCEL',
|
||||
autoWidth: true,
|
||||
bookType: 'xlsx'
|
||||
})
|
||||
this.downloadLoading = false
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
formatJson(filterVal, jsonData) {
|
||||
return jsonData.map(v => filterVal.map(j => {
|
||||
return v[j]
|
||||
}))
|
||||
},
|
||||
// ///////////////////////////////////////////////////↑0910zdy
|
||||
// 在什么情况下需要查询上传的附件,调用this.getFileData()即可根据
|
||||
getFileData(machineValue) {
|
||||
this.hadFile = []
|
||||
|
||||
Reference in New Issue
Block a user