配件库管理

This commit is contained in:
PQZ 2024-09-18 14:12:35 +08:00
parent b68b9de81a
commit 683c9adf16
4 changed files with 261 additions and 144 deletions

View File

@ -198,6 +198,10 @@ export const DICT_TYPE = {
REPAIR_PART_DISPOSAL: 'repair_part_disposal',
//单位
REPAIR_UNIT: 'repair_unit',
//配件属性
REPAIR_WARES_ATTRIBUTE: 'wares_attribute',
//配件来源
REPAIR_WARES_DATA_FORM: 'wares_data_form',
}
/**

View File

@ -1,7 +1,7 @@
<template>
<div class="app-container">
<!-- 对话框(添加 / 修改) -->
<el-dialog :title="dialogTitle" :visible.sync="dialogVisible" width="45%" v-dialogDrag append-to-body>
<el-dialog :title="dialogTitle" :visible.sync="dialogVisible" width="50%" v-dialogDrag append-to-body>
<el-form ref="formRef" :model="formData" :rules="formRules" v-loading="formLoading" label-width="100px">
<el-row :gutter="20">
<el-col :span="12">

View File

@ -1,61 +1,166 @@
<template>
<div class="app-container">
<!-- 对话框(添加 / 修改) -->
<el-dialog :title="dialogTitle" :visible.sync="dialogVisible" width="45%" v-dialogDrag append-to-body>
<el-dialog :title="dialogTitle" :visible.sync="dialogVisible" width="50%" v-dialogDrag append-to-body>
<el-form ref="formRef" :model="formData" :rules="formRules" v-loading="formLoading" label-width="100px">
<el-collapse v-model="activeNames">
<!--基本信息-->
<el-collapse-item title="商品基本信息" name="1">
<el-row :gutter="20">
<el-col :span="12">
<el-form-item label="条形码" prop="barCode">
<el-input v-model="formData.barCode" placeholder="请输入条形码"/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="商品编码" prop="code">
<el-input v-model="formData.code" placeholder="请输入商品编码"/>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="20">
<el-col :span="12">
<el-form-item label="商品名称" prop="name">
<el-input v-model="formData.name" placeholder="请输入商品名称"/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="规格型号" prop="model">
<el-input v-model="formData.model" placeholder="请输入规格型号"/>
</el-form-item>
<el-form-item label="销售价格" prop="price">
<el-input v-model="formData.price" placeholder="请输入销售价格"/>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="20">
<el-col :span="12">
<el-form-item label="所属分类" prop="type">
<el-select v-model="formData.type" placeholder="请选择所属分类">
<el-option label="请选择字典生成" value=""/>
<TreeSelect
v-model="formData.type"
:options="baseTypeTree"
:normalizer="normalizer"
placeholder="请选择所属分类"
/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="计量单位" prop="unit">
<el-select v-model="formData.unit" placeholder="请选择单位">
<el-option v-for="dict in this.getDictDatas(DICT_TYPE.REPAIR_UNIT)"
:key="dict.value" :label="dict.label" :value="dict.value"/>
</el-select>
</el-form-item>
<el-form-item label="计量单位" prop="unit">
<el-input v-model="formData.unit" placeholder="请输入计量单位"/>
</el-col>
</el-row>
<el-row :gutter="20">
<el-col :span="12">
<el-form-item label="销售价格" prop="price">
<el-input-number v-model="formData.price" :precision="2" :step="0.1" :max="10"></el-input-number>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="默认仓库" prop="warehouse">
<el-input v-model="formData.warehouse" placeholder="请输入默认仓库"/>
<TreeSelect
v-model="formData.warehouse"
:options="baseWarehouseTree"
:normalizer="normalizer"
placeholder="请选择仓库"
/>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="20">
<el-col :span="12">
<el-form-item label="最低库存" prop="miniStock">
<el-input v-model="formData.miniStock" placeholder="请输入最低库存"/>
<el-input-number v-model="formData.miniStock" :max="10"></el-input-number>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="最高库存" prop="maxStock">
<el-input v-model="formData.maxStock" placeholder="请输入最高库存"/>
<el-input-number v-model="formData.maxStock" :max="10"></el-input-number>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="20">
<el-col :span="12">
<el-form-item label="当前库存" prop="stock">
<el-input v-model="formData.stock" placeholder="请输入当前库存"/>
<el-input-number v-model="formData.stock" :max="10"></el-input-number>
</el-form-item>
<el-form-item label="产品图片" prop="img">
<el-input v-model="formData.img" placeholder="请输入产品图片"/>
</el-col>
<el-col :span="12">
<el-form-item label="状态" prop="status">
<el-switch
v-model="formData.status"
active-color="#13ce66"
inactive-color="#ff4949"
active-value="01"
inactive-value="02">
</el-switch>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="20">
<el-col :span="12">
<el-form-item label="来源" prop="dataForm">
<el-select v-model="formData.dataForm" placeholder="请选择来源">
<el-option v-for="dict in this.getDictDatas(DICT_TYPE.REPAIR_WARES_DATA_FORM)"
:key="dict.value" :label="dict.label" :value="dict.value"/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="配件属性" prop="attribute">
<el-input v-model="formData.attribute" placeholder="请输入配件属性"/>
<el-select v-model="formData.attribute" placeholder="请选择单位">
<el-option v-for="dict in this.getDictDatas(DICT_TYPE.REPAIR_WARES_ATTRIBUTE)"
:key="dict.value" :label="dict.label" :value="dict.value"/>
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="20">
<el-col :span="24">
<el-form-item label="适用子公司" prop="corpId">
<el-input v-model="formData.corpId" placeholder="请输入适用子公司"/>
</el-form-item>
<el-form-item label="封面图片" prop="coverImg">
<el-input v-model="formData.coverImg" placeholder="请输入封面图片"/>
<el-select v-model="formData.corpIds" multiple placeholder="请选择">
<el-option
v-for="item in companyList"
:key="item.id"
:label="item.corpName"
:value="item.id">
</el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="适用车型" prop="carModel">
<el-input v-model="formData.carModel" placeholder="请输入适用车型"/>
<el-input type="textarea" v-model="formData.carModel" placeholder="请输入适用车型"/>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="备注" prop="remark">
<el-input v-model="formData.remark" placeholder="请输入备注"/>
<el-input type="textarea" v-model="formData.remark" placeholder="请输入备注"/>
</el-form-item>
</el-col>
</el-row>
</el-collapse-item>
<el-collapse-item title="附件信息" name="2">
<el-row :gutter="20">
<el-col :span="24">
<el-form-item label="产品图片" prop="img">
<ImageUpload v-model="formData.img" />
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="封面图片" prop="coverImg">
<ImageUpload :limit="1" v-model="formData.coverImg" />
</el-form-item>
</el-col>
</el-row>
</el-collapse-item>
</el-collapse>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm" :disabled="formLoading"> </el-button>
@ -67,10 +172,16 @@
<script>
import * as WaresApi from '@/api/repair/wares';
import * as BaseTypeApi from '@/api/base/type';
import {getCompanyList} from '@/api/base/company'
import TreeSelect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import * as BaseWarehouseApi from '@/api/base/warehouse';
import ImageUpload from '@/components/ImageUpload';
export default {
name: "WaresForm",
components: {},
components: {TreeSelect,ImageUpload},
data() {
return {
//
@ -98,9 +209,25 @@ export default {
coverImg: undefined,
carModel: undefined,
remark: undefined,
dataForm: undefined,
corpIds: [],
status: '01',
},
//
formRules: {},
formRules: {
name: [{required: true, message: '商品名称不能为空', trigger: 'blur'}],
barCode: [{required: true, message: '条形码不能为空', trigger: 'blur'}],
price: [{required: true, message: '销售价格不能为空', trigger: 'blur'}],
unit: [{required: true, message: '计量单位不能为空', trigger: 'blur'}],
type: [{required: true, message: '所属分类不能为空', trigger: 'blur'}],
},
activeNames: ['1', '2'],
//
baseTypeTree: [],
//
companyList: [],
//
baseWarehouseTree: []
};
},
methods: {
@ -120,6 +247,36 @@ export default {
}
}
this.title = "新增配件库";
//
await this.getBaseTypeTree();
//
await this.listCompany();
//
await this.getBaseWarehouseTree();
},
/** 获得配置类型树 */
async getBaseTypeTree() {
this.baseTypeTree = [];
let param = {
type: '02'
}
const res = await BaseTypeApi.getBaseTypeList(param);
const root = {id: 0, name: '顶级配置类型', children: []};
root.children = this.handleTree(res.data, 'id', 'parentId', "children", "0")
this.baseTypeTree.push(root)
},
/** 查询子公司 */
async listCompany() {
const res = await getCompanyList()
this.companyList = res.data
},
/** 获得仓库树 */
async getBaseWarehouseTree() {
this.baseWarehouseTree = [];
const res = await BaseWarehouseApi.getBaseWarehouseList();
const root = {id: 0, name: '顶级仓库', children: []};
root.children = this.handleTree(res.data, 'id', 'parentId', "children", "0")
this.baseWarehouseTree.push(root)
},
/** 提交按钮 */
async submitForm() {
@ -127,6 +284,7 @@ export default {
await this.$refs["formRef"].validate();
this.formLoading = true;
try {
this.formData.corpId = this.formData.corpIds + ''
const data = this.formData;
//
if (data.id) {
@ -145,6 +303,18 @@ export default {
this.formLoading = false;
}
},
/** 转换仓库数据结构 */
normalizer(node) {
if (node.children && !node.children.length) {
delete node.children;
}
return {
id: node.id,
label: node.name,
children: node.children
};
},
/** 表单重置 */
reset() {
this.formData = {
@ -165,6 +335,9 @@ export default {
coverImg: undefined,
carModel: undefined,
remark: undefined,
dataForm: undefined,
corpIds: [],
status: '01',
};
this.resetForm("formRef");
}

View File

@ -2,59 +2,12 @@
<div class="app-container">
<!-- 搜索工作栏 -->
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="条形码" prop="barCode">
<el-input v-model="queryParams.barCode" placeholder="请输入条形码" clearable @keyup.enter.native="handleQuery"/>
</el-form-item>
<el-form-item label="商品编码" prop="code">
<el-input v-model="queryParams.code" placeholder="请输入商品编码" clearable @keyup.enter.native="handleQuery"/>
</el-form-item>
<el-form-item label="商品名称" prop="name">
<el-input v-model="queryParams.name" placeholder="请输入商品名称" clearable @keyup.enter.native="handleQuery"/>
</el-form-item>
<el-form-item label="规格型号" prop="model">
<el-input v-model="queryParams.model" placeholder="请输入规格型号" clearable @keyup.enter.native="handleQuery"/>
</el-form-item>
<el-form-item label="销售价格" prop="price">
<el-input v-model="queryParams.price" placeholder="请输入销售价格" clearable @keyup.enter.native="handleQuery"/>
</el-form-item>
<el-form-item label="所属分类" prop="type">
<el-select v-model="queryParams.type" placeholder="请选择所属分类" clearable size="small">
<el-option label="请选择字典生成" value=""/>
</el-select>
</el-form-item>
<el-form-item label="计量单位" prop="unit">
<el-input v-model="queryParams.unit" placeholder="请输入计量单位" clearable @keyup.enter.native="handleQuery"/>
</el-form-item>
<el-form-item label="默认仓库" prop="warehouse">
<el-input v-model="queryParams.warehouse" placeholder="请输入默认仓库" clearable @keyup.enter.native="handleQuery"/>
</el-form-item>
<el-form-item label="最低库存" prop="miniStock">
<el-input v-model="queryParams.miniStock" placeholder="请输入最低库存" clearable @keyup.enter.native="handleQuery"/>
</el-form-item>
<el-form-item label="最高库存" prop="maxStock">
<el-input v-model="queryParams.maxStock" placeholder="请输入最高库存" clearable @keyup.enter.native="handleQuery"/>
</el-form-item>
<el-form-item label="当前库存" prop="stock">
<el-input v-model="queryParams.stock" placeholder="请输入当前库存" clearable @keyup.enter.native="handleQuery"/>
</el-form-item>
<el-form-item label="产品图片" prop="img">
<el-input v-model="queryParams.img" placeholder="请输入产品图片" clearable @keyup.enter.native="handleQuery"/>
</el-form-item>
<el-form-item label="配件属性" prop="attribute">
<el-input v-model="queryParams.attribute" placeholder="请输入配件属性" clearable @keyup.enter.native="handleQuery"/>
</el-form-item>
<el-form-item label="适用子公司" prop="corpId">
<el-input v-model="queryParams.corpId" placeholder="请输入适用子公司" clearable @keyup.enter.native="handleQuery"/>
</el-form-item>
<el-form-item label="封面图片" prop="coverImg">
<el-input v-model="queryParams.coverImg" placeholder="请输入封面图片" clearable @keyup.enter.native="handleQuery"/>
</el-form-item>
<el-form-item label="适用车型" prop="carModel">
<el-input v-model="queryParams.carModel" placeholder="请输入适用车型" clearable @keyup.enter.native="handleQuery"/>
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="queryParams.remark" placeholder="请输入备注" clearable @keyup.enter.native="handleQuery"/>
</el-form-item>
<el-form-item label="创建时间" prop="createTime">
<el-date-picker v-model="queryParams.createTime" style="width: 240px" value-format="yyyy-MM-dd HH:mm:ss"
type="daterange"
@ -74,36 +27,37 @@
v-hasPermi="['repair:wares:create']">新增
</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"
:loading="exportLoading"
v-hasPermi="['repair:wares:export']">导出
</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
<el-table-column label="条形码" align="center" prop="barCode"/>
<el-table-column label="商品编码" align="center" prop="code"/>
<el-table-column label="商品名称" align="center" prop="name"/>
<el-table-column label="规格型号" align="center" prop="model"/>
<el-table-column label="销售价格" align="center" prop="price"/>
<el-table-column label="所属分类" align="center" prop="type"/>
<el-table-column label="计量单位" align="center" prop="unit"/>
<el-table-column label="默认仓库" align="center" prop="warehouse"/>
<el-table-column label="最低库存" align="center" prop="miniStock"/>
<el-table-column label="最高库存" align="center" prop="maxStock"/>
<el-table-column label="当前库存" align="center" prop="stock"/>
<el-table-column label="产品图片" align="center" prop="img"/>
<el-table-column label="配件属性" align="center" prop="attribute"/>
<el-table-column label="适用子公司" align="center" prop="corpId"/>
<el-table-column label="封面图片" align="center" prop="coverImg"/>
<el-table-column label="适用车型" align="center" prop="carModel"/>
<el-table-column label="备注" align="center" prop="remark"/>
<el-table-column label="创建时间" align="center" prop="createTime" width="180">
<el-table-column label="商品名称" align="left" prop="name"/>
<el-table-column label="规格" align="left" prop="model"/>
<el-table-column label="商品编码" align="left" prop="code"/>
<el-table-column label="所属分类" align="left" prop="typeName"/>
<el-table-column label="销售价格" align="right" prop="price"/>
<el-table-column label="条形码" align="left" prop="barCode"/>
<el-table-column label="计量单位" align="center" prop="unit">
<template v-slot="scope">
<span>{{ parseTime(scope.row.createTime) }}</span>
<dict-tag :type="DICT_TYPE.REPAIR_UNIT" :value="scope.row.unit"/>
</template>
</el-table-column>
<el-table-column label="配件属性" align="center" prop="attribute">
<template v-slot="scope">
<dict-tag :type="DICT_TYPE.REPAIR_WARES_ATTRIBUTE" :value="scope.row.attribute"/>
</template>
</el-table-column>
<el-table-column label="状态" align="center" prop="status">
<template v-slot="scope">
<el-tag v-if="scope.row.status == '01'" type="success">正常</el-tag>
<el-tag v-if="scope.row.status == '02'" type="danger">禁用</el-tag>
</template>
</el-table-column>
<el-table-column label="所属子公司" align="left" prop="corpNames"/>
<el-table-column label="默认仓库" align="left" prop="warehouseName"/>
<el-table-column label="来源" align="center" prop="dataForm">
<template v-slot="scope">
<dict-tag :type="DICT_TYPE.REPAIR_WARES_DATA_FORM" :value="scope.row.dataForm"/>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
@ -138,8 +92,6 @@ export default {
return {
//
loading: true,
//
exportLoading: false,
//
showSearch: true,
//
@ -186,7 +138,7 @@ export default {
try {
this.loading = true;
const res = await WaresApi.getWaresPage(this.queryParams);
this.list = res.data.list;
this.list = res.data.records;
this.total = res.data.total;
} finally {
this.loading = false;
@ -217,18 +169,6 @@ export default {
} catch {
}
},
/** 导出按钮操作 */
async handleExport() {
await this.$modal.confirm('是否确认导出所有配件库数据项?');
try {
this.exportLoading = true;
const data = await WaresApi.exportWaresExcel(this.queryParams);
this.$download.excel(data, '配件库.xls');
} catch {
} finally {
this.exportLoading = false;
}
},
}
};
</script>