add: 新增物料展示,去外协物料打印,导出任务数据,导入载具号功能

This commit is contained in:
yanps
2024-12-19 19:21:44 +08:00
parent ccba70a8cf
commit 8506ec5a04
36 changed files with 989 additions and 393 deletions

View File

@@ -0,0 +1,116 @@
<template>
<el-dialog
title="导入Excel文件"
append-to-body
:visible.sync="dialogVisible"
destroy-on-close
width="400px"
:show-close="true"
@close="close"
@open="open"
>
<el-upload
ref="upload"
class="upload-demo"
action=""
drag
:on-exceed="is_one"
:limit="1"
:auto-upload="false"
:multiple="false"
:show-file-list="true"
:on-change="uploadByJsqd"
:file-list="fileList"
accept=".xlsx,.xls"
>
<i class="el-icon-upload" />
<div class="el-upload__text">
将文件拖到此处
<em>点击上传</em>
</div>
<div slot="tip" class="el-upload__tip">只能上传Excel文件且不超过10MB</div>
</el-upload>
<span slot="footer" class="dialog-footer">
<el-button @click="dialogVisible = false"> </el-button>
<el-button type="primary" @click="submit"> </el-button>
</span>
</el-dialog>
</template>
<script>
import crudVehicle from './vehicle/vehicle'
import CRUD, { crud } from '@crud/crud'
export default {
name: 'UploadDialog',
mixins: [crud()],
components: {},
props: {
dialogShow: {
type: Boolean,
default: false
},
openParam: {
type: String
}
},
data() {
return {
dialogVisible: false,
fileList: [],
file1: ''
}
},
watch: {
dialogShow: {
handler(newValue, oldValue) {
this.dialogVisible = newValue
}
},
openParam: {
handler(newValue, oldValue) {
this.opendtlParam = newValue
}
}
},
methods: {
open() {
},
close() {
this.$emit('update:dialogShow', false)
},
is_one() {
this.crud.notify('只能上传一个excel文件', CRUD.NOTIFICATION_TYPE.WARNING)
},
// 文件校验方法
beforeAvatarUpload(file) {
// 不能导入大小超过2Mb的文件
if (file.size > 10 * 1024 * 1024) {
return false
}
return true
},
// 文件发生改变就会触发的事件
uploadByJsqd(file) {
this.file1 = file
},
submit() {
if (this.beforeAvatarUpload(this.file1)) {
this.fileList.name = this.file1.name
this.fileList.url = ''
var formdata = new FormData()
formdata.append('file', this.file1.raw)
// excelImport请求接口 formdata传递参数
crudVehicle.excelImport(formdata).then((res) => {
this.crud.notify('导入成功', CRUD.NOTIFICATION_TYPE.SUCCESS)
this.$emit('tableChanged3', '')
this.$emit('update:dialogShow', false)
})
} else {
this.crud.notify('文件过大请上传小于10MB的文件〜', CRUD.NOTIFICATION_TYPE.WARNING)
}
}
}
}
</script>

View File

@@ -79,7 +79,6 @@
size="mini"
type="success"
icon="el-icon-upload"
:disabled="crud.selections.length === 0"
@click="uploadExcel()"
>
导出
@@ -267,6 +266,8 @@ import CRUD, { crud, form, header, presenter } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'
import pagination from '@crud/Pagination'
import { downloadFile } from '@/utils'
import { download } from '@/api/data'
const defaultForm = {
task_id: null,
@@ -342,9 +343,9 @@ export default {
this.crud.toQuery()
},
uploadExcel() {
const selectData = this.crud.selections
crudSchBaseTask.upload(selectData).then(res => {
console.log('++++++++++++++++++++', res)
download(this.crud.url + '/upload', this.crud.getQueryParams()).then(res => {
downloadFile(res, crud.title + '数据', 'csv')
this.crud.notify('操作成功', CRUD.NOTIFICATION_TYPE.SUCCESS)
})
},
handTaskStatus(value) {

View File

@@ -46,7 +46,18 @@
</div>
<!--如果想在工具栏加入更多按钮可以使用插槽方式 slot = 'left' or 'right'-->
<crudOperation :permission="permission" />
<crudOperation :permission="permission">
<el-button
slot="right"
class="filter-item"
type="warning"
icon="el-icon-upload2"
size="mini"
@click="uploadShow = true"
>
导入
</el-button>
</crudOperation>
<!--表单组件-->
<el-dialog
:close-on-click-modal="false"
@@ -182,11 +193,11 @@
{{ dict.label.storagevehicle_type[scope.row.vehicle_type] }}
</template>
</el-table-column>
<el-table-column prop="vehicle_code" label="载具编码">
<template slot-scope="scope">
<el-table-column prop="vehicle_code" label="载具编码" />
<!-- <template slot-scope="scope">
<el-link type="warning" @click="toView(scope.row.vehicle_code)">{{ scope.row.vehicle_code }}</el-link>
</template>
</el-table-column>
</el-table-column> -->
<el-table-column prop="vehicle_name" label="载具名称" />
<el-table-column label="是否启用" align="center" prop="is_used">
<template slot-scope="scope">
@@ -235,6 +246,7 @@
/> -->
<pagination />
</div>
<UploadDialog :dialog-show.sync="uploadShow" @tableChanged3="tableChanged3" />
</div>
</template>
@@ -246,6 +258,7 @@ import crudOperation from '@crud/CRUD.operation'
import udOperation from '@crud/UD.operation'
import pagination from '@crud/Pagination'
import { getLodop } from '@/assets/js/lodop/LodopFuncs'
import UploadDialog from '../UploadDialog.vue'
const defaultForm = {
vehicle_code: null,
@@ -256,7 +269,7 @@ const defaultForm = {
export default {
name: 'Storagevehicleinfo',
dicts: ['storagevehicle_type', 'VEHICLE_OVER_TYPE'],
components: { pagination, crudOperation, rrOperation, udOperation },
components: { pagination, crudOperation, rrOperation, udOperation, UploadDialog },
mixins: [presenter(), header(), form(defaultForm), crud()],
cruds() {
return CRUD({
@@ -299,6 +312,7 @@ export default {
materType: '01',
materialShow: false,
dialogVisible: false,
uploadShow: false,
materialForm: {},
resultCodeArr: [],
permission: {},
@@ -330,6 +344,9 @@ export default {
[CRUD.HOOK.beforeRefresh]() {
return true
},
tableChanged3() {
this.crud.toQuery()
},
onCloseDialog() {
this.form = defaultForm
},

View File

@@ -61,4 +61,12 @@ export function getMaterialByVehicle(vehicle_code) {
})
}
export default { add, edit, del, changeActive, getMaterialByVehicle, getVehicle, vehileInfo, updateVehicleMaterial }
export function excelImport(data) {
return request({
url: 'api/bmVehicleInfo/excelImport',
method: 'post',
data
})
}
export default { add, edit, del, changeActive, getMaterialByVehicle, getVehicle, vehileInfo, updateVehicleMaterial, excelImport }