|
@@ -20,6 +20,21 @@
|
|
<el-button type="primary" :loading="confirmLoading" @click="handleAdd">确 定</el-button>
|
|
<el-button type="primary" :loading="confirmLoading" @click="handleAdd">确 定</el-button>
|
|
</span>
|
|
</span>
|
|
</el-dialog>
|
|
</el-dialog>
|
|
|
|
+ <el-dialog title="批量导入" :visible.sync="bulkImportVisible" width="600px" @close="importClose">
|
|
|
|
+ <div class="card_bulkImport">
|
|
|
|
+ <el-upload ref="mYupload" class="upload-demo" drag action="#" :limit="1" multiple :http-request="UploadImage">
|
|
|
|
+ <i class="el-icon-upload"></i>
|
|
|
|
+ <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
|
|
|
|
+ <div class="el-upload__tip" slot="tip">请上传xls或者xlsx格式文件</div>
|
|
|
|
+ </el-upload>
|
|
|
|
+ <div style="margin-top: 15px;">
|
|
|
|
+ <el-button size="medium" type="primary" icon="el-icon-upload" :loading="importFlag"
|
|
|
|
+ @click="immediateImport">确定导入</el-button>
|
|
|
|
+ <el-button size="medium" icon="el-icon-download" :loading="downloadFlag"
|
|
|
|
+ @click="templateDownload">模板下载</el-button>
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+ </el-dialog>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</template>
|
|
|
|
|
|
@@ -30,6 +45,8 @@
|
|
addGasCylinder,
|
|
addGasCylinder,
|
|
putGasCylinder,
|
|
putGasCylinder,
|
|
delGasCylinder,
|
|
delGasCylinder,
|
|
|
|
+ waybillImport,
|
|
|
|
+ exportTemplate,
|
|
} from '@/api/inspection'
|
|
} from '@/api/inspection'
|
|
import actionBar from '@/components/actionBar'
|
|
import actionBar from '@/components/actionBar'
|
|
import tables from '@/components/tables'
|
|
import tables from '@/components/tables'
|
|
@@ -58,6 +75,10 @@
|
|
innerCode: '',
|
|
innerCode: '',
|
|
},
|
|
},
|
|
operateList: [{
|
|
operateList: [{
|
|
|
|
+ type: 'import',
|
|
|
|
+ title: '导入',
|
|
|
|
+ icon: 'el-icon-upload',
|
|
|
|
+ }, {
|
|
type: 'add',
|
|
type: 'add',
|
|
title: '添加钢瓶',
|
|
title: '添加钢瓶',
|
|
icon: 'el-icon-plus',
|
|
icon: 'el-icon-plus',
|
|
@@ -77,6 +98,10 @@
|
|
confirmLoading: false,
|
|
confirmLoading: false,
|
|
operationType: '',
|
|
operationType: '',
|
|
clientId: '',
|
|
clientId: '',
|
|
|
|
+ bulkImportVisible: false,
|
|
|
|
+ importFlag: false,
|
|
|
|
+ downloadFlag: false,
|
|
|
|
+ importFile: null,
|
|
}
|
|
}
|
|
},
|
|
},
|
|
mounted() {
|
|
mounted() {
|
|
@@ -116,13 +141,15 @@
|
|
this.operationType = type
|
|
this.operationType = type
|
|
if (type == 'add') {
|
|
if (type == 'add') {
|
|
this.staffTitle = '添加钢瓶'
|
|
this.staffTitle = '添加钢瓶'
|
|
|
|
+ const arr = [...this.cylinderRule]
|
|
|
|
+ arr.forEach((item, index) => {
|
|
|
|
+ item.disabled = false
|
|
|
|
+ })
|
|
|
|
+ this.cylinderRule = arr
|
|
|
|
+ this.cylinderDialog = true
|
|
|
|
+ } else if (type == 'import') {
|
|
|
|
+ this.bulkImportVisible = true
|
|
}
|
|
}
|
|
- const arr = [...this.cylinderRule]
|
|
|
|
- arr.forEach((item, index) => {
|
|
|
|
- item.disabled = false
|
|
|
|
- })
|
|
|
|
- this.cylinderRule = arr
|
|
|
|
- this.cylinderDialog = true
|
|
|
|
},
|
|
},
|
|
buttonData(row, type) {
|
|
buttonData(row, type) {
|
|
let arrRow = JSON.parse(JSON.stringify(row))
|
|
let arrRow = JSON.parse(JSON.stringify(row))
|
|
@@ -195,6 +222,61 @@
|
|
// console.log('取消')
|
|
// console.log('取消')
|
|
});
|
|
});
|
|
},
|
|
},
|
|
|
|
+ // 导入
|
|
|
|
+ immediateImport() {
|
|
|
|
+ if (this.importFile) {
|
|
|
|
+ this.importFlag = true
|
|
|
|
+ let formData = new FormData();
|
|
|
|
+ formData.append('file', this.importFile);
|
|
|
|
+ formData.append('customerName', this.orderCustomer);
|
|
|
|
+ waybillImport(formData).then(res => {
|
|
|
|
+ if (res.code == 200) {
|
|
|
|
+ this.bulkImportVisible = false
|
|
|
|
+ this.importFlag = false
|
|
|
|
+ this.getList()
|
|
|
|
+ this.$message({
|
|
|
|
+ message: '恭喜你,导入成功',
|
|
|
|
+ type: 'success'
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ } else {
|
|
|
|
+ this.$message({
|
|
|
|
+ message: '请先选择上传文件',
|
|
|
|
+ type: 'warning'
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ // 导出模板
|
|
|
|
+ templateDownload() {
|
|
|
|
+ this.downloadFlag = true
|
|
|
|
+ exportTemplate().then(response => {
|
|
|
|
+ let arrList = response.fileName.split('.')
|
|
|
|
+ let fixedStr = decodeURIComponent(arrList[0]);
|
|
|
|
+ let filename = fixedStr + '.' + arrList[1]
|
|
|
|
+ // this.blobDownload(response, filename)
|
|
|
|
+ this.blobDownload(response.data, filename)
|
|
|
|
+ this.downloadFlag = false
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ // 导出文件流
|
|
|
|
+ blobDownload(data, name) {
|
|
|
|
+ let m = this;
|
|
|
|
+ var content = data;
|
|
|
|
+ var data = new Blob([content], {
|
|
|
|
+ type: "application/vnd.ms-excel;charset=utf-8"
|
|
|
|
+ });
|
|
|
|
+ var downloadUrl = window.URL.createObjectURL(data);
|
|
|
|
+ var anchor = document.createElement("a");
|
|
|
|
+ anchor.href = downloadUrl;
|
|
|
|
+ anchor.download = name;
|
|
|
|
+ anchor.click();
|
|
|
|
+ window.URL.revokeObjectURL(data);
|
|
|
|
+ },
|
|
|
|
+ // 上传文件
|
|
|
|
+ UploadImage(param) {
|
|
|
|
+ this.importFile = param.file
|
|
|
|
+ },
|
|
changeSize(val) {
|
|
changeSize(val) {
|
|
this.Pagination.PageSize = val
|
|
this.Pagination.PageSize = val
|
|
this.getList()
|
|
this.getList()
|
|
@@ -203,6 +285,10 @@
|
|
this.Pagination.PageIndex = val
|
|
this.Pagination.PageIndex = val
|
|
this.getList()
|
|
this.getList()
|
|
},
|
|
},
|
|
|
|
+ importClose() {
|
|
|
|
+ this.importFile = null
|
|
|
|
+ this.$refs['mYupload'].clearFiles();
|
|
|
|
+ },
|
|
closeDialog() {
|
|
closeDialog() {
|
|
const arr = [...this.cylinderRule]
|
|
const arr = [...this.cylinderRule]
|
|
arr.forEach((item, index) => {
|
|
arr.forEach((item, index) => {
|
|
@@ -217,4 +303,32 @@
|
|
</script>
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
<style lang="scss" scoped>
|
|
|
|
+ .card_bulkImport {
|
|
|
|
+ width: 100%;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ ::v-deep .el-upload {
|
|
|
|
+ width: 100%;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ ::v-deep .el-upload-dragger .el-upload__text {
|
|
|
|
+ color: #fff;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ ::v-deep .el-upload__tip {
|
|
|
|
+ color: #fff;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ ::v-deep .el-upload-list__item-name {
|
|
|
|
+ color: #fff;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ ::v-deep .el-upload-list__item-name:hover {
|
|
|
|
+ color: #000;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ ::v-deep .el-upload-dragger {
|
|
|
|
+ width: 100%;
|
|
|
|
+ background-color: unset !important;
|
|
|
|
+ }
|
|
</style>
|
|
</style>
|