diff --git a/src/api/product/snCodeField.js b/src/api/product/snCodeField.js index 2d006a9..1f31976 100644 --- a/src/api/product/snCodeField.js +++ b/src/api/product/snCodeField.js @@ -19,7 +19,7 @@ // 导出 const SN_listExport = (data) => { - return instance.post(`snInfo/listExport`, data) + return instance.post(`snInfo/listExport`, data, { responseType: 'blob' }) } export { SN_listExport, SN_batchDelete, SN_listPage, SN_delete, SN_add } diff --git a/src/api/product/snCodeField.js b/src/api/product/snCodeField.js index 2d006a9..1f31976 100644 --- a/src/api/product/snCodeField.js +++ b/src/api/product/snCodeField.js @@ -19,7 +19,7 @@ // 导出 const SN_listExport = (data) => { - return instance.post(`snInfo/listExport`, data) + return instance.post(`snInfo/listExport`, data, { responseType: 'blob' }) } export { SN_listExport, SN_batchDelete, SN_listPage, SN_delete, SN_add } diff --git a/src/components/mycomponent/dialog/snCodeFieldDialog.vue b/src/components/mycomponent/dialog/snCodeFieldDialog.vue index c75e981..68808ff 100644 --- a/src/components/mycomponent/dialog/snCodeFieldDialog.vue +++ b/src/components/mycomponent/dialog/snCodeFieldDialog.vue @@ -164,8 +164,8 @@ hardwareVersion: [{ required: true, message: '此项不能为空', trigger: ['blur', 'change'] }], softwareVersion: [{ required: true, message: '此项不能为空', trigger: ['blur', 'change'] }], productDate: [{ required: true, message: '此项不能为空', trigger: ['blur', 'change'] }], - coreParts: [{ required: true, message: '此项不能为空', trigger: ['blur', 'change'] }], - }, + coreParts: [{ required: true, message: '此项不能为空', trigger: ['blur', 'change'] }] + } } }, computed: { @@ -205,17 +205,19 @@ }, save() { this.$refs['dataForm'].validate((valid) => { - if(valid) { + if (valid) { const temp = { ...this.addInfo } temp.snSegmentNum = this.snSegmentNum SN_add(temp).then(res => { if (res != '') { - this.$message.success('添加成功') - this.close() - this.reset() - } - }) - + this.$message.success('添加成功') + this.close() + this.reset() + this.$nextTick(() => { + this.$refs['dataForm'].clearValidate() + }) + } + }) } }) }, @@ -256,7 +258,7 @@ }) this.addInfo.productId = this.productList[index].id this.addInfo.productName = this.productList[index].productName - this.addInfo.productBrandCode =this.productList[index].brandCode + this.addInfo.productBrandCode = this.productList[index].brandCode this.addInfo.productBrandName = this.productList[index].brandName }, brandCodeChange() { diff --git a/src/api/product/snCodeField.js b/src/api/product/snCodeField.js index 2d006a9..1f31976 100644 --- a/src/api/product/snCodeField.js +++ b/src/api/product/snCodeField.js @@ -19,7 +19,7 @@ // 导出 const SN_listExport = (data) => { - return instance.post(`snInfo/listExport`, data) + return instance.post(`snInfo/listExport`, data, { responseType: 'blob' }) } export { SN_listExport, SN_batchDelete, SN_listPage, SN_delete, SN_add } diff --git a/src/components/mycomponent/dialog/snCodeFieldDialog.vue b/src/components/mycomponent/dialog/snCodeFieldDialog.vue index c75e981..68808ff 100644 --- a/src/components/mycomponent/dialog/snCodeFieldDialog.vue +++ b/src/components/mycomponent/dialog/snCodeFieldDialog.vue @@ -164,8 +164,8 @@ hardwareVersion: [{ required: true, message: '此项不能为空', trigger: ['blur', 'change'] }], softwareVersion: [{ required: true, message: '此项不能为空', trigger: ['blur', 'change'] }], productDate: [{ required: true, message: '此项不能为空', trigger: ['blur', 'change'] }], - coreParts: [{ required: true, message: '此项不能为空', trigger: ['blur', 'change'] }], - }, + coreParts: [{ required: true, message: '此项不能为空', trigger: ['blur', 'change'] }] + } } }, computed: { @@ -205,17 +205,19 @@ }, save() { this.$refs['dataForm'].validate((valid) => { - if(valid) { + if (valid) { const temp = { ...this.addInfo } temp.snSegmentNum = this.snSegmentNum SN_add(temp).then(res => { if (res != '') { - this.$message.success('添加成功') - this.close() - this.reset() - } - }) - + this.$message.success('添加成功') + this.close() + this.reset() + this.$nextTick(() => { + this.$refs['dataForm'].clearValidate() + }) + } + }) } }) }, @@ -256,7 +258,7 @@ }) this.addInfo.productId = this.productList[index].id this.addInfo.productName = this.productList[index].productName - this.addInfo.productBrandCode =this.productList[index].brandCode + this.addInfo.productBrandCode = this.productList[index].brandCode this.addInfo.productBrandName = this.productList[index].brandName }, brandCodeChange() { diff --git a/src/utils/myUtils/mixins/infoDialog.js b/src/utils/myUtils/mixins/infoDialog.js index 4c492f3..ac6af5b 100644 --- a/src/utils/myUtils/mixins/infoDialog.js +++ b/src/utils/myUtils/mixins/infoDialog.js @@ -2,7 +2,7 @@ props: { isShowInfo: { type: Boolean, - default: true + default: false }, // title: '', dataInfo: { diff --git a/src/api/product/snCodeField.js b/src/api/product/snCodeField.js index 2d006a9..1f31976 100644 --- a/src/api/product/snCodeField.js +++ b/src/api/product/snCodeField.js @@ -19,7 +19,7 @@ // 导出 const SN_listExport = (data) => { - return instance.post(`snInfo/listExport`, data) + return instance.post(`snInfo/listExport`, data, { responseType: 'blob' }) } export { SN_listExport, SN_batchDelete, SN_listPage, SN_delete, SN_add } diff --git a/src/components/mycomponent/dialog/snCodeFieldDialog.vue b/src/components/mycomponent/dialog/snCodeFieldDialog.vue index c75e981..68808ff 100644 --- a/src/components/mycomponent/dialog/snCodeFieldDialog.vue +++ b/src/components/mycomponent/dialog/snCodeFieldDialog.vue @@ -164,8 +164,8 @@ hardwareVersion: [{ required: true, message: '此项不能为空', trigger: ['blur', 'change'] }], softwareVersion: [{ required: true, message: '此项不能为空', trigger: ['blur', 'change'] }], productDate: [{ required: true, message: '此项不能为空', trigger: ['blur', 'change'] }], - coreParts: [{ required: true, message: '此项不能为空', trigger: ['blur', 'change'] }], - }, + coreParts: [{ required: true, message: '此项不能为空', trigger: ['blur', 'change'] }] + } } }, computed: { @@ -205,17 +205,19 @@ }, save() { this.$refs['dataForm'].validate((valid) => { - if(valid) { + if (valid) { const temp = { ...this.addInfo } temp.snSegmentNum = this.snSegmentNum SN_add(temp).then(res => { if (res != '') { - this.$message.success('添加成功') - this.close() - this.reset() - } - }) - + this.$message.success('添加成功') + this.close() + this.reset() + this.$nextTick(() => { + this.$refs['dataForm'].clearValidate() + }) + } + }) } }) }, @@ -256,7 +258,7 @@ }) this.addInfo.productId = this.productList[index].id this.addInfo.productName = this.productList[index].productName - this.addInfo.productBrandCode =this.productList[index].brandCode + this.addInfo.productBrandCode = this.productList[index].brandCode this.addInfo.productBrandName = this.productList[index].brandName }, brandCodeChange() { diff --git a/src/utils/myUtils/mixins/infoDialog.js b/src/utils/myUtils/mixins/infoDialog.js index 4c492f3..ac6af5b 100644 --- a/src/utils/myUtils/mixins/infoDialog.js +++ b/src/utils/myUtils/mixins/infoDialog.js @@ -2,7 +2,7 @@ props: { isShowInfo: { type: Boolean, - default: true + default: false }, // title: '', dataInfo: { diff --git a/src/utils/myUtils/mixins/listPage.js b/src/utils/myUtils/mixins/listPage.js index 07f3141..9b8c399 100644 --- a/src/utils/myUtils/mixins/listPage.js +++ b/src/utils/myUtils/mixins/listPage.js @@ -1,6 +1,7 @@ const listMixin = { data() { return { + loading: false, tableData: { rows: [] }, // 品牌表格数据 limit: 10, // 当前的行数 offset: 1, // 当前页 @@ -24,7 +25,7 @@ selectData() { this.queryInfo = { ...this.selectInfo } // 加入搜索内容 // 回到初始页 - if (this.offset == 1) { + if (this.offset === 1) { this.refresh() return } diff --git a/src/api/product/snCodeField.js b/src/api/product/snCodeField.js index 2d006a9..1f31976 100644 --- a/src/api/product/snCodeField.js +++ b/src/api/product/snCodeField.js @@ -19,7 +19,7 @@ // 导出 const SN_listExport = (data) => { - return instance.post(`snInfo/listExport`, data) + return instance.post(`snInfo/listExport`, data, { responseType: 'blob' }) } export { SN_listExport, SN_batchDelete, SN_listPage, SN_delete, SN_add } diff --git a/src/components/mycomponent/dialog/snCodeFieldDialog.vue b/src/components/mycomponent/dialog/snCodeFieldDialog.vue index c75e981..68808ff 100644 --- a/src/components/mycomponent/dialog/snCodeFieldDialog.vue +++ b/src/components/mycomponent/dialog/snCodeFieldDialog.vue @@ -164,8 +164,8 @@ hardwareVersion: [{ required: true, message: '此项不能为空', trigger: ['blur', 'change'] }], softwareVersion: [{ required: true, message: '此项不能为空', trigger: ['blur', 'change'] }], productDate: [{ required: true, message: '此项不能为空', trigger: ['blur', 'change'] }], - coreParts: [{ required: true, message: '此项不能为空', trigger: ['blur', 'change'] }], - }, + coreParts: [{ required: true, message: '此项不能为空', trigger: ['blur', 'change'] }] + } } }, computed: { @@ -205,17 +205,19 @@ }, save() { this.$refs['dataForm'].validate((valid) => { - if(valid) { + if (valid) { const temp = { ...this.addInfo } temp.snSegmentNum = this.snSegmentNum SN_add(temp).then(res => { if (res != '') { - this.$message.success('添加成功') - this.close() - this.reset() - } - }) - + this.$message.success('添加成功') + this.close() + this.reset() + this.$nextTick(() => { + this.$refs['dataForm'].clearValidate() + }) + } + }) } }) }, @@ -256,7 +258,7 @@ }) this.addInfo.productId = this.productList[index].id this.addInfo.productName = this.productList[index].productName - this.addInfo.productBrandCode =this.productList[index].brandCode + this.addInfo.productBrandCode = this.productList[index].brandCode this.addInfo.productBrandName = this.productList[index].brandName }, brandCodeChange() { diff --git a/src/utils/myUtils/mixins/infoDialog.js b/src/utils/myUtils/mixins/infoDialog.js index 4c492f3..ac6af5b 100644 --- a/src/utils/myUtils/mixins/infoDialog.js +++ b/src/utils/myUtils/mixins/infoDialog.js @@ -2,7 +2,7 @@ props: { isShowInfo: { type: Boolean, - default: true + default: false }, // title: '', dataInfo: { diff --git a/src/utils/myUtils/mixins/listPage.js b/src/utils/myUtils/mixins/listPage.js index 07f3141..9b8c399 100644 --- a/src/utils/myUtils/mixins/listPage.js +++ b/src/utils/myUtils/mixins/listPage.js @@ -1,6 +1,7 @@ const listMixin = { data() { return { + loading: false, tableData: { rows: [] }, // 品牌表格数据 limit: 10, // 当前的行数 offset: 1, // 当前页 @@ -24,7 +25,7 @@ selectData() { this.queryInfo = { ...this.selectInfo } // 加入搜索内容 // 回到初始页 - if (this.offset == 1) { + if (this.offset === 1) { this.refresh() return } diff --git a/src/views/product/deviceList.vue b/src/views/product/deviceList.vue index 0b2cb81..257c99a 100644 --- a/src/views/product/deviceList.vue +++ b/src/views/product/deviceList.vue @@ -92,13 +92,6 @@ type="selection" width="55" /> - - { - return instance.post(`snInfo/listExport`, data) + return instance.post(`snInfo/listExport`, data, { responseType: 'blob' }) } export { SN_listExport, SN_batchDelete, SN_listPage, SN_delete, SN_add } diff --git a/src/components/mycomponent/dialog/snCodeFieldDialog.vue b/src/components/mycomponent/dialog/snCodeFieldDialog.vue index c75e981..68808ff 100644 --- a/src/components/mycomponent/dialog/snCodeFieldDialog.vue +++ b/src/components/mycomponent/dialog/snCodeFieldDialog.vue @@ -164,8 +164,8 @@ hardwareVersion: [{ required: true, message: '此项不能为空', trigger: ['blur', 'change'] }], softwareVersion: [{ required: true, message: '此项不能为空', trigger: ['blur', 'change'] }], productDate: [{ required: true, message: '此项不能为空', trigger: ['blur', 'change'] }], - coreParts: [{ required: true, message: '此项不能为空', trigger: ['blur', 'change'] }], - }, + coreParts: [{ required: true, message: '此项不能为空', trigger: ['blur', 'change'] }] + } } }, computed: { @@ -205,17 +205,19 @@ }, save() { this.$refs['dataForm'].validate((valid) => { - if(valid) { + if (valid) { const temp = { ...this.addInfo } temp.snSegmentNum = this.snSegmentNum SN_add(temp).then(res => { if (res != '') { - this.$message.success('添加成功') - this.close() - this.reset() - } - }) - + this.$message.success('添加成功') + this.close() + this.reset() + this.$nextTick(() => { + this.$refs['dataForm'].clearValidate() + }) + } + }) } }) }, @@ -256,7 +258,7 @@ }) this.addInfo.productId = this.productList[index].id this.addInfo.productName = this.productList[index].productName - this.addInfo.productBrandCode =this.productList[index].brandCode + this.addInfo.productBrandCode = this.productList[index].brandCode this.addInfo.productBrandName = this.productList[index].brandName }, brandCodeChange() { diff --git a/src/utils/myUtils/mixins/infoDialog.js b/src/utils/myUtils/mixins/infoDialog.js index 4c492f3..ac6af5b 100644 --- a/src/utils/myUtils/mixins/infoDialog.js +++ b/src/utils/myUtils/mixins/infoDialog.js @@ -2,7 +2,7 @@ props: { isShowInfo: { type: Boolean, - default: true + default: false }, // title: '', dataInfo: { diff --git a/src/utils/myUtils/mixins/listPage.js b/src/utils/myUtils/mixins/listPage.js index 07f3141..9b8c399 100644 --- a/src/utils/myUtils/mixins/listPage.js +++ b/src/utils/myUtils/mixins/listPage.js @@ -1,6 +1,7 @@ const listMixin = { data() { return { + loading: false, tableData: { rows: [] }, // 品牌表格数据 limit: 10, // 当前的行数 offset: 1, // 当前页 @@ -24,7 +25,7 @@ selectData() { this.queryInfo = { ...this.selectInfo } // 加入搜索内容 // 回到初始页 - if (this.offset == 1) { + if (this.offset === 1) { this.refresh() return } diff --git a/src/views/product/deviceList.vue b/src/views/product/deviceList.vue index 0b2cb81..257c99a 100644 --- a/src/views/product/deviceList.vue +++ b/src/views/product/deviceList.vue @@ -92,13 +92,6 @@ type="selection" width="55" /> - - - + diff --git a/src/api/product/snCodeField.js b/src/api/product/snCodeField.js index 2d006a9..1f31976 100644 --- a/src/api/product/snCodeField.js +++ b/src/api/product/snCodeField.js @@ -19,7 +19,7 @@ // 导出 const SN_listExport = (data) => { - return instance.post(`snInfo/listExport`, data) + return instance.post(`snInfo/listExport`, data, { responseType: 'blob' }) } export { SN_listExport, SN_batchDelete, SN_listPage, SN_delete, SN_add } diff --git a/src/components/mycomponent/dialog/snCodeFieldDialog.vue b/src/components/mycomponent/dialog/snCodeFieldDialog.vue index c75e981..68808ff 100644 --- a/src/components/mycomponent/dialog/snCodeFieldDialog.vue +++ b/src/components/mycomponent/dialog/snCodeFieldDialog.vue @@ -164,8 +164,8 @@ hardwareVersion: [{ required: true, message: '此项不能为空', trigger: ['blur', 'change'] }], softwareVersion: [{ required: true, message: '此项不能为空', trigger: ['blur', 'change'] }], productDate: [{ required: true, message: '此项不能为空', trigger: ['blur', 'change'] }], - coreParts: [{ required: true, message: '此项不能为空', trigger: ['blur', 'change'] }], - }, + coreParts: [{ required: true, message: '此项不能为空', trigger: ['blur', 'change'] }] + } } }, computed: { @@ -205,17 +205,19 @@ }, save() { this.$refs['dataForm'].validate((valid) => { - if(valid) { + if (valid) { const temp = { ...this.addInfo } temp.snSegmentNum = this.snSegmentNum SN_add(temp).then(res => { if (res != '') { - this.$message.success('添加成功') - this.close() - this.reset() - } - }) - + this.$message.success('添加成功') + this.close() + this.reset() + this.$nextTick(() => { + this.$refs['dataForm'].clearValidate() + }) + } + }) } }) }, @@ -256,7 +258,7 @@ }) this.addInfo.productId = this.productList[index].id this.addInfo.productName = this.productList[index].productName - this.addInfo.productBrandCode =this.productList[index].brandCode + this.addInfo.productBrandCode = this.productList[index].brandCode this.addInfo.productBrandName = this.productList[index].brandName }, brandCodeChange() { diff --git a/src/utils/myUtils/mixins/infoDialog.js b/src/utils/myUtils/mixins/infoDialog.js index 4c492f3..ac6af5b 100644 --- a/src/utils/myUtils/mixins/infoDialog.js +++ b/src/utils/myUtils/mixins/infoDialog.js @@ -2,7 +2,7 @@ props: { isShowInfo: { type: Boolean, - default: true + default: false }, // title: '', dataInfo: { diff --git a/src/utils/myUtils/mixins/listPage.js b/src/utils/myUtils/mixins/listPage.js index 07f3141..9b8c399 100644 --- a/src/utils/myUtils/mixins/listPage.js +++ b/src/utils/myUtils/mixins/listPage.js @@ -1,6 +1,7 @@ const listMixin = { data() { return { + loading: false, tableData: { rows: [] }, // 品牌表格数据 limit: 10, // 当前的行数 offset: 1, // 当前页 @@ -24,7 +25,7 @@ selectData() { this.queryInfo = { ...this.selectInfo } // 加入搜索内容 // 回到初始页 - if (this.offset == 1) { + if (this.offset === 1) { this.refresh() return } diff --git a/src/views/product/deviceList.vue b/src/views/product/deviceList.vue index 0b2cb81..257c99a 100644 --- a/src/views/product/deviceList.vue +++ b/src/views/product/deviceList.vue @@ -92,13 +92,6 @@ type="selection" width="55" /> - - - + diff --git a/src/views/product/snCodeField.vue b/src/views/product/snCodeField.vue index 3481108..14d8f18 100644 --- a/src/views/product/snCodeField.vue +++ b/src/views/product/snCodeField.vue @@ -67,6 +67,7 @@ - - + @@ -125,8 +125,8 @@ // 逻辑 import { tableRowClassName } from '../../utils/myUtils/changeTableTr' import { listMixin, elDataDialog } from '../../utils/myUtils/mixins/listPage' -import { SN_listPage, SN_batchDelete, SN_delete } from '../../api/product/snCodeField' -import { outToExcel } from '../../utils/myUtils/exportToExcel' +import { SN_listPage, SN_batchDelete, SN_delete, SN_listExport } from '../../api/product/snCodeField' +import { exportFile } from '@/utils/exportutils' export default { components: { @@ -149,18 +149,23 @@ tableRowClassName: tableRowClassName, closeAdd() { this.isShowAdd = false + this.refresh() }, addCategory() { this.isShowAdd = true }, // 获取指定页面 getListPage(limit, offset) { - SN_listPage(`limit=${limit}&offset=${offset}`, this.queryInfo).then(res => { - // 得到相关数据 + this.loading = true + SN_listPage(`limit=${limit}&offset=${offset}`, this.selectInfo).then(res => { + this.loading = false + // 得到相关数据 res.rows.forEach((item, index) => { item.index = (index + 1) + ((offset - 1) * 10) }) this.tableData = res + }).catch(_ => { + this.loading = false }) }, reset() { @@ -168,44 +173,50 @@ keyword: '', productCode: '' } + this.limit = 10 + this.offset = 1 + this.refresh() }, exportToExcel() { - SN_listPage('limit=1000000000&offset=1', {}).then(res => { - outToExcel(res.rows) + // 全屏加载动画 + const loading = this.$loading({ + lock: true, + text: '下载中,请稍后...', + spinner: 'el-icon-loading', + background: 'rgba(0, 0, 0, 0.7)' + }) + SN_listExport(this.selectInfo).then(res => { + console.log() + loading.close() // 关闭加载动画 + console.log('download===', res) + const blob = new Blob([res.data]) + let fileName = '设备sn码列表.xlsx' + fileName = fileName.replace(/-|:| /g, '') + exportFile(blob, fileName) }) }, // 批量删除 BatchDelete() { // 得到选中行 - const dle_ary = this.$refs.multipleTable.selection - const ids = [] - dle_ary.forEach(ele => { - ids.push(ele.id) - }) + const ids = this.$refs.multipleTable.selection.map(item => item.id) SN_batchDelete({ ids: ids }).then(res => { - if (res != '') { - this.$message({ - message: '删除成功', - type: 'success' - }) - this.refresh() - } + this.$message({ + message: '删除成功', + type: 'success' + }) + this.refresh() }) }, // 删除 Bdelete(row) { - // console.log(row); const id = row.id SN_delete({ id: id }).then(res => { - // console.log(res); // 删除成功跟新数据 - if (res != '') { - this.$message({ - message: '删除成功', - type: 'success' - }) - this.refresh() - } + this.$message({ + message: '删除成功', + type: 'success' + }) + this.refresh() }) } }