add:物料
This commit is contained in:
35
wms_pro/qd/src/api/wms/base_manage/material/material.js
Normal file
35
wms_pro/qd/src/api/wms/base_manage/material/material.js
Normal file
@@ -0,0 +1,35 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
export function add(data) {
|
||||
return request({
|
||||
url: 'api/bmMaterial',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export function del(ids) {
|
||||
return request({
|
||||
url: 'api/bmMaterial',
|
||||
method: 'delete',
|
||||
data: ids
|
||||
})
|
||||
}
|
||||
|
||||
export function edit(data) {
|
||||
return request({
|
||||
url: 'api/bmMaterial',
|
||||
method: 'put',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export function excelImport(data) {
|
||||
return request({
|
||||
url: 'api/mdMeMaterialbase/excelImport',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export default { add, edit, del, excelImport }
|
||||
124
wms_pro/qd/src/views/wms/base_manage/material/UploadDialog.vue
Normal file
124
wms_pro/qd/src/views/wms/base_manage/material/UploadDialog.vue
Normal file
@@ -0,0 +1,124 @@
|
||||
<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 crudMaterialbase from '@/api/wms/basedata/master/materialbase'
|
||||
import CRUD, { crud } from '@crud/crud'
|
||||
import { download2 } from '@/api/data'
|
||||
import { downloadFile } from '@/utils'
|
||||
|
||||
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:传递参数
|
||||
crudMaterialbase.excelImport(formdata).then((res) => {
|
||||
this.crud.notify('导入成功', CRUD.NOTIFICATION_TYPE.SUCCESS)
|
||||
this.$emit('tableChanged3', '')
|
||||
this.$emit('update:dialogShow', false)
|
||||
}).catch(err => {
|
||||
const list = err.response.data.message
|
||||
download2('/api/produceWorkorder/download', list).then(result => {
|
||||
downloadFile(result, '错误信息汇总', 'xlsx')
|
||||
crud.downloadLoading = false
|
||||
})
|
||||
})
|
||||
} else {
|
||||
this.crud.notify('文件过大,请上传小于10MB的文件〜', CRUD.NOTIFICATION_TYPE.WARNING)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
439
wms_pro/qd/src/views/wms/base_manage/material/index.vue
Normal file
439
wms_pro/qd/src/views/wms/base_manage/material/index.vue
Normal file
@@ -0,0 +1,439 @@
|
||||
<template>
|
||||
<div v-loading.fullscreen.lock="fullscreenLoading" class="app-container">
|
||||
<!--工具栏-->
|
||||
<div class="head-container">
|
||||
<div v-if="crud.props.searchToggle">
|
||||
<!-- 搜索 -->
|
||||
<el-form
|
||||
:inline="true"
|
||||
class="demo-form-inline"
|
||||
label-position="right"
|
||||
label-width="80px"
|
||||
label-suffix=":"
|
||||
>
|
||||
<el-form-item label="物料类别">
|
||||
<treeselect
|
||||
v-model="query.material_type_id"
|
||||
:load-options="loadChildNodes"
|
||||
:options="classes1"
|
||||
offset-height="30px;"
|
||||
style="width: 200px; height: 30px;"
|
||||
placeholder="请选择"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="模糊查询">
|
||||
<el-input
|
||||
v-model="query.search"
|
||||
clearable
|
||||
style="width: 200px"
|
||||
size="mini"
|
||||
placeholder="输入物料编码或名称"
|
||||
prefix-icon="el-icon-search"
|
||||
class="filter-item"
|
||||
/>
|
||||
</el-form-item>
|
||||
<rrOperation />
|
||||
</el-form>
|
||||
|
||||
</div>
|
||||
<!--如果想在工具栏加入更多按钮,可以使用插槽方式, slot = 'left' or 'right'-->
|
||||
<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"
|
||||
:before-close="crud.cancelCU"
|
||||
:visible.sync="crud.status.cu > 0"
|
||||
:title="crud.status.title"
|
||||
width="1200px"
|
||||
>
|
||||
<el-form ref="form" :model="form" :rules="rules" size="mini" label-width="110px">
|
||||
<el-row>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="物料编码" prop="material_code">
|
||||
<el-input v-model="form.material_code" style="width: 200px;" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="物料名称" prop="material_name">
|
||||
<el-input v-model="form.material_name" style="width: 200px;" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
|
||||
<el-form-item label="规格" prop="material_spec">
|
||||
<label slot="label">规 格</label>
|
||||
<el-input v-model="form.material_spec" style="width: 200px;" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="型号" prop="material_model">
|
||||
<label slot="label">型 号</label>
|
||||
<el-input v-model="form.material_model" style="width: 200px;" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="外部标识" prop="ext_id">
|
||||
<el-input v-model="form.ext_id" style="width: 200px;" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="物料分类" prop="material_type_id">
|
||||
<treeselect
|
||||
v-model="form.material_type_id"
|
||||
:load-options="loadChildNodes"
|
||||
:options="classes2"
|
||||
style="width: 200px;"
|
||||
placeholder="请选择"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="产品系列">
|
||||
<treeselect
|
||||
v-model="form.product_series"
|
||||
:options="classes3"
|
||||
:auto-load-root-options="false"
|
||||
:load-options="loadChildNodes"
|
||||
style="width: 200px;"
|
||||
placeholder="请选择"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="是否启用" prop="is_used">
|
||||
<el-switch
|
||||
v-model="form.is_used"
|
||||
active-color="#13ce66"
|
||||
inactive-color="#ff4949"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="text" @click="crud.cancelCU">取消</el-button>
|
||||
<el-button :loading="crud.cu === 2" type="primary" @click="crud.submitCU">确认</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
<!--表格渲染-->
|
||||
<el-table
|
||||
ref="table"
|
||||
v-loading="crud.loading"
|
||||
:data="crud.data"
|
||||
size="mini"
|
||||
style="width: 100%;"
|
||||
@selection-change="crud.selectionChangeHandler"
|
||||
>
|
||||
<el-table-column prop="material_code" label="物料编码" width="160" />
|
||||
<el-table-column prop="material_name" label="物料名称" width="180" show-overflow-tooltip />
|
||||
<el-table-column prop="material_spec" label="物料规格" width="140" />
|
||||
<el-table-column prop="material_model" label="物料型号" />
|
||||
<el-table-column prop="class_name" label="物料分类" width="140" />
|
||||
<el-table-column prop="unit_name" label="计量单位" />
|
||||
<el-table-column prop="net_weight" label="单重(g)" />
|
||||
<el-table-column prop="product_series_name" label="系列" />
|
||||
<el-table-column label="启用" align="center" prop="is_used">
|
||||
<template slot-scope="scope">
|
||||
<el-switch
|
||||
v-model="scope.row.is_used"
|
||||
active-color="#409EFF"
|
||||
inactive-color="#F56C6C"
|
||||
@change="changeEnabled(scope.row, scope.row.is_used)"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="update_optname" label="修改人" />
|
||||
<el-table-column
|
||||
prop="update_time"
|
||||
label="修改时间"
|
||||
:min-width="flexWidth('update_time',crud.data,'修改时间')"
|
||||
/>
|
||||
<el-table-column
|
||||
v-permission="['admin','Materialbase:edit','Materialbase:del']"
|
||||
fixed="right"
|
||||
label="操作"
|
||||
width="120px"
|
||||
align="center"
|
||||
>
|
||||
<template slot-scope="scope">
|
||||
<udOperation
|
||||
:data="scope.row"
|
||||
:permission="permission"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<!--分页组件-->
|
||||
<pagination />
|
||||
</div>
|
||||
<UploadDialog :dialog-show.sync="uploadShow" @tableChanged3="crud.toQuery()" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import crudMaterialbase from '@/api/wms/base_manage/material/material'
|
||||
import CRUD, { crud, form, header, presenter } from '@crud/crud'
|
||||
import rrOperation from '@crud/RR.operation'
|
||||
import crudOperation from '@crud/CRUD.operation'
|
||||
import udOperation from '@crud/UD.operation'
|
||||
import pagination from '@crud/Pagination'
|
||||
import Treeselect, { LOAD_CHILDREN_OPTIONS } from '@riophae/vue-treeselect'
|
||||
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
|
||||
// import crudClassstandard from '@/api/wms/basedata/master/classstandard'
|
||||
// import crudMdPbMeasureunit from '@/api/wms/basedata/master/mdPbMeasureunit'
|
||||
import UploadDialog from '@/views/wms/base_manage/material/UploadDialog'
|
||||
|
||||
const defaultForm = {
|
||||
material_id: null,
|
||||
ass_unit_id: null,
|
||||
material_code: null,
|
||||
material_name: null,
|
||||
material_spec: null,
|
||||
material_model: null,
|
||||
english_name: null,
|
||||
base_unit_id: null,
|
||||
approve_fileno: null,
|
||||
print_no: null,
|
||||
material_type_id: null,
|
||||
len_unit_id: null,
|
||||
length: null,
|
||||
width: null,
|
||||
height: null,
|
||||
limit_qty: null,
|
||||
weight_unit_id: null,
|
||||
gross_weight: null,
|
||||
net_weight: null,
|
||||
cubage_unit_id: null,
|
||||
cubage: null,
|
||||
create_id: null,
|
||||
create_name: null,
|
||||
create_time: null,
|
||||
update_optid: null,
|
||||
update_optname: null,
|
||||
update_time: null,
|
||||
is_used_time: null,
|
||||
is_used: null,
|
||||
is_delete: null,
|
||||
ext_id: null,
|
||||
material_height_type: null,
|
||||
product_series: null
|
||||
}
|
||||
export default {
|
||||
name: 'Material',
|
||||
// 数据字典
|
||||
dicts: ['is_used'],
|
||||
components: { pagination, crudOperation, rrOperation, udOperation, Treeselect, UploadDialog },
|
||||
mixins: [presenter(), header(), form(defaultForm), crud()],
|
||||
cruds() {
|
||||
return CRUD({
|
||||
title: '物料',
|
||||
optShow: { add: true, reset: true },
|
||||
url: 'api/bmMaterial',
|
||||
idField: 'material_id',
|
||||
sort: 'material_id,desc',
|
||||
crudMethod: { ...crudMaterialbase }
|
||||
})
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
classes1: [],
|
||||
classes2: [],
|
||||
classes3: [],
|
||||
dialogShow: false,
|
||||
uploadShow: false,
|
||||
fullscreenLoading: false,
|
||||
measure_unit: [],
|
||||
productSeries: [],
|
||||
permission: {},
|
||||
rules: {
|
||||
material_id: [
|
||||
{ required: true, message: '不能为空', trigger: 'blur' }
|
||||
],
|
||||
material_code: [
|
||||
{ required: true, message: '物料编码不能为空', trigger: 'blur' }
|
||||
],
|
||||
material_name: [
|
||||
{ required: true, message: '物料名称不能为空', trigger: 'blur' }
|
||||
],
|
||||
material_type_id: [
|
||||
{ required: true, message: '物料分类不能为空', trigger: 'blur' }
|
||||
],
|
||||
create_id: [
|
||||
{ required: true, message: '不能为空', trigger: 'blur' }
|
||||
],
|
||||
create_time: [
|
||||
{ required: true, message: '不能为空', trigger: 'blur' }
|
||||
],
|
||||
is_used: [
|
||||
{ required: true, message: '是否启用不能为空', trigger: 'blur' }
|
||||
],
|
||||
material_height_type: [
|
||||
{ required: true, message: '不能为空', trigger: 'blur' }
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.initClass1()
|
||||
this.initClass2()
|
||||
this.initClass3()
|
||||
},
|
||||
methods: {
|
||||
// 钩子:在获取表格数据之前执行,false 则代表不获取数据
|
||||
[CRUD.HOOK.beforeRefresh]() {
|
||||
return true
|
||||
},
|
||||
initClass1() {
|
||||
const param = {
|
||||
parent_class_code: '09'
|
||||
}
|
||||
crudClassstandard.getClassType(param).then(res => {
|
||||
const data = res.content
|
||||
this.buildTree(data)
|
||||
this.classes1 = data
|
||||
})
|
||||
},
|
||||
format_isOrNot(row, column, value) {
|
||||
return value === true ? '是' : '否'
|
||||
},
|
||||
initClass2() {
|
||||
const param = {
|
||||
parent_class_code: '09'
|
||||
}
|
||||
crudClassstandard.getClassType(param).then(res => {
|
||||
const data = res.content
|
||||
this.buildTree(data)
|
||||
this.classes2 = data
|
||||
})
|
||||
},
|
||||
initClass3() {
|
||||
const param = {
|
||||
parent_class_code: '07'
|
||||
}
|
||||
crudClassstandard.getClassType(param).then(res => {
|
||||
const data = res.content
|
||||
this.buildTree(data)
|
||||
this.classes3 = data
|
||||
})
|
||||
},
|
||||
[CRUD.HOOK.beforeToCU](crud, form) {
|
||||
},
|
||||
getSubTypes(type, id) {
|
||||
const that = this
|
||||
crudClassstandard.getClassSuperior(id).then(res => {
|
||||
const data = res.content
|
||||
that.buildTree(data)
|
||||
if (type == '02') {
|
||||
that.classes2 = data
|
||||
}
|
||||
if (type == '03') {
|
||||
that.classes3 = data
|
||||
}
|
||||
})
|
||||
},
|
||||
synchronize() {
|
||||
this.dialogShow = true
|
||||
},
|
||||
queryClassId() {
|
||||
const param = {
|
||||
'class_idStr': this.class_idStr
|
||||
}
|
||||
crudClassstandard.queryClassById(param).then(res => {
|
||||
this.classes = res.content.map(obj => {
|
||||
if (obj.hasChildren) {
|
||||
obj.children = null
|
||||
}
|
||||
return obj
|
||||
})
|
||||
})
|
||||
},
|
||||
buildTree(classes) {
|
||||
classes.forEach(data => {
|
||||
if (data.children) {
|
||||
this.buildTree(data.children)
|
||||
}
|
||||
if (data.hasChildren && !data.children) {
|
||||
data.children = null // 重点代码
|
||||
}
|
||||
})
|
||||
},
|
||||
// 改变状态
|
||||
changeEnabled(data, val) {
|
||||
this.$confirm('此操作将修改' + data.material_name + '状态, 是否继续?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
crudMaterialbase.edit(data).then(res => {
|
||||
this.crud.notify('操作成功', CRUD.NOTIFICATION_TYPE.SUCCESS)
|
||||
}).catch(() => {
|
||||
if (data.is_used === false) {
|
||||
data.is_used = true
|
||||
return
|
||||
}
|
||||
if (data.is_used === true) {
|
||||
data.is_used = false
|
||||
}
|
||||
})
|
||||
}).catch(() => {
|
||||
if (data.is_used === false) {
|
||||
data.is_used = true
|
||||
return
|
||||
}
|
||||
if (data.is_used === true) {
|
||||
data.is_used = false
|
||||
}
|
||||
})
|
||||
},
|
||||
// 获取子节点数据
|
||||
loadChildNodes({ action, parentNode, callback }) {
|
||||
if (action === LOAD_CHILDREN_OPTIONS) {
|
||||
crudClassstandard.getClass({ pid: parentNode.id }).then(res => {
|
||||
parentNode.children = res.content.map(function(obj) {
|
||||
if (obj.hasChildren) {
|
||||
obj.children = null
|
||||
}
|
||||
return obj
|
||||
})
|
||||
setTimeout(() => {
|
||||
callback()
|
||||
}, 100)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style rel="stylesheet/scss" lang="scss" scoped>
|
||||
.treeselect-main {
|
||||
width: 204px;
|
||||
line-height: 28px;
|
||||
|
||||
.vue-treeselect__placeholder {
|
||||
line-height: 28px;
|
||||
}
|
||||
|
||||
.vue-treeselect__control {
|
||||
height: 28px !important;
|
||||
}
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user