This commit is contained in:
xiao-fajia 2024-09-18 14:59:50 +08:00
commit 12bdfea200
5 changed files with 570 additions and 4 deletions

View File

@ -0,0 +1,45 @@
import request from '@/utils/request'
// 创建配件库
export function createWares(data) {
return request({
url: '/repair/wares/create',
method: 'post',
data: data
})
}
// 更新配件库
export function updateWares(data) {
return request({
url: '/repair/wares/update',
method: 'put',
data: data
})
}
// 删除配件库
export function deleteWares(id) {
return request({
url: '/repair/wares/delete?id=' + id,
method: 'delete'
})
}
// 获得配件库
export function getWares(id) {
return request({
url: '/repair/wares/get?id=' + id,
method: 'get'
})
}
// 获得配件库分页
export function getWaresPage(params) {
return request({
url: '/repair/wares/page',
method: 'get',
params
})
}

View File

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

View File

@ -1,7 +1,7 @@
<template> <template>
<div class="app-container"> <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-form ref="formRef" :model="formData" :rules="formRules" v-loading="formLoading" label-width="100px">
<el-row :gutter="20"> <el-row :gutter="20">
<el-col :span="12"> <el-col :span="12">
@ -15,7 +15,6 @@
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
<el-row :gutter="20"> <el-row :gutter="20">
<el-col :span="12"> <el-col :span="12">
<el-form-item label="成本" prop="cost"> <el-form-item label="成本" prop="cost">
@ -28,7 +27,6 @@
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
<el-row :gutter="20"> <el-row :gutter="20">
<el-col :span="12"> <el-col :span="12">
<el-form-item label="规格" prop="spec"> <el-form-item label="规格" prop="spec">
@ -44,7 +42,6 @@
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
<el-row :gutter="20"> <el-row :gutter="20">
<el-col :span="12"> <el-col :span="12">
<el-form-item label="分类" prop="type"> <el-form-item label="分类" prop="type">

View File

@ -0,0 +1,346 @@
<template>
<div class="app-container">
<!-- 对话框(添加 / 修改) -->
<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-col>
</el-row>
<el-row :gutter="20">
<el-col :span="12">
<el-form-item label="所属分类" prop="type">
<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-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">
<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-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-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-number v-model="formData.stock" :max="10"></el-input-number>
</el-form-item>
</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-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-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 type="textarea" v-model="formData.carModel" placeholder="请输入适用车型"/>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="备注" prop="remark">
<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>
<el-button @click="dialogVisible = false"> </el-button>
</div>
</el-dialog>
</div>
</template>
<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: {TreeSelect,ImageUpload},
data() {
return {
//
dialogTitle: "",
//
dialogVisible: false,
// 12
formLoading: false,
//
formData: {
barCode: undefined,
code: undefined,
name: undefined,
model: undefined,
price: undefined,
type: undefined,
unit: undefined,
warehouse: undefined,
miniStock: undefined,
maxStock: undefined,
stock: undefined,
img: undefined,
attribute: undefined,
corpId: undefined,
coverImg: undefined,
carModel: undefined,
remark: undefined,
dataForm: undefined,
corpIds: [],
status: '01',
},
//
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: {
/** 打开弹窗 */
async open(id) {
this.dialogVisible = true;
this.reset();
//
if (id) {
this.formLoading = true;
try {
const res = await WaresApi.getWares(id);
this.formData = res.data;
this.title = "修改配件库";
} finally {
this.formLoading = false;
}
}
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() {
//
await this.$refs["formRef"].validate();
this.formLoading = true;
try {
this.formData.corpId = this.formData.corpIds + ''
const data = this.formData;
//
if (data.id) {
await WaresApi.updateWares(data);
this.$modal.msgSuccess("修改成功");
this.dialogVisible = false;
this.$emit('success');
return;
}
//
await WaresApi.createWares(data);
this.$modal.msgSuccess("新增成功");
this.dialogVisible = false;
this.$emit('success');
} finally {
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 = {
barCode: undefined,
code: undefined,
name: undefined,
model: undefined,
price: undefined,
type: undefined,
unit: undefined,
warehouse: undefined,
miniStock: undefined,
maxStock: undefined,
stock: undefined,
img: undefined,
attribute: undefined,
corpId: undefined,
coverImg: undefined,
carModel: undefined,
remark: undefined,
dataForm: undefined,
corpIds: [],
status: '01',
};
this.resetForm("formRef");
}
}
};
</script>

View File

@ -0,0 +1,174 @@
<template>
<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="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="createTime">
<el-date-picker v-model="queryParams.createTime" style="width: 240px" value-format="yyyy-MM-dd HH:mm:ss"
type="daterange"
range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"
:default-time="['00:00:00', '23:59:59']"/>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<!-- 操作工具栏 -->
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="openForm(undefined)"
v-hasPermi="['repair:wares:create']">新增
</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="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">
<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">
<template v-slot="scope">
<el-button size="mini" type="text" icon="el-icon-edit" @click="openForm(scope.row.id)"
v-hasPermi="['repair:wares:update']">修改
</el-button>
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
v-hasPermi="['repair:wares:delete']">删除
</el-button>
</template>
</el-table-column>
</el-table>
<!-- 分页组件 -->
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
@pagination="getList"/>
<!-- 对话框(添加 / 修改) -->
<WaresForm ref="formRef" @success="getList"/>
</div>
</template>
<script>
import * as WaresApi from '@/api/repair/wares';
import WaresForm from './WaresForm.vue';
export default {
name: "Wares",
components: {
WaresForm,
},
data() {
return {
//
loading: true,
//
showSearch: true,
//
total: 0,
//
list: [],
//
isExpandAll: true,
//
refreshTable: true,
//
currentRow: {},
//
queryParams: {
pageNo: 1,
pageSize: 10,
barCode: null,
code: null,
name: null,
model: null,
price: null,
type: null,
unit: null,
warehouse: null,
miniStock: null,
maxStock: null,
stock: null,
img: null,
attribute: null,
corpId: null,
coverImg: null,
carModel: null,
remark: null,
createTime: [],
},
};
},
created() {
this.getList();
},
methods: {
/** 查询列表 */
async getList() {
try {
this.loading = true;
const res = await WaresApi.getWaresPage(this.queryParams);
this.list = res.data.records;
this.total = res.data.total;
} finally {
this.loading = false;
}
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNo = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
/** 添加/修改操作 */
openForm(id) {
this.$refs["formRef"].open(id);
},
/** 删除按钮操作 */
async handleDelete(row) {
const id = row.id;
await this.$modal.confirm('是否确认删除配件库编号为"' + id + '"的数据项?')
try {
await WaresApi.deleteWares(id);
await this.getList();
this.$modal.msgSuccess("删除成功");
} catch {
}
},
}
};
</script>