This commit is contained in:
GeDashi 2024-12-20 19:08:26 +08:00
parent 67b1c5db2e
commit bd251a7cfe
3 changed files with 459 additions and 7 deletions

View File

@ -0,0 +1,44 @@
import request from '@/utils/request'
// 查询水果产品详情列表
export function listGoodsinformation(query) {
return request({
url: '/system/goodsinformation/list',
method: 'get',
params: query
})
}
// 查询水果产品详情详细
export function getGoodsinformation(goodsinformationid) {
return request({
url: '/system/goodsinformation/' + goodsinformationid,
method: 'get'
})
}
// 新增水果产品详情
export function addGoodsinformation(data) {
return request({
url: '/system/goodsinformation',
method: 'post',
data: data
})
}
// 修改水果产品详情
export function updateGoodsinformation(data) {
return request({
url: '/system/goodsinformation',
method: 'put',
data: data
})
}
// 删除水果产品详情
export function delGoodsinformation(goodsinformationid) {
return request({
url: '/system/goodsinformation/' + goodsinformationid,
method: 'delete'
})
}

View File

@ -33,10 +33,18 @@
@keyup.enter="handleQuery"
/>
</el-form-item>
<el-form-item label="已售数量" prop="amount">
<el-form-item label="商品数量" prop="amount">
<el-input
v-model="queryParams.amount"
placeholder="请输入已售数量"
placeholder="请输入商品数量"
clearable
@keyup.enter="handleQuery"
/>
</el-form-item>
<el-form-item label="商品详情id" prop="goodsinformationid">
<el-input
v-model="queryParams.goodsinformationid"
placeholder="请输入商品详情id"
clearable
@keyup.enter="handleQuery"
/>
@ -96,12 +104,13 @@
<el-table-column label="预售时间" align="center" prop="time1" />
<el-table-column label="提货时间" align="center" prop="time2" />
<el-table-column label="商品价格" align="center" prop="price" />
<el-table-column label="已售数量" align="center" prop="amount" />
<el-table-column label="商品数量" align="center" prop="amount" />
<el-table-column label="商品图片" align="center" prop="picture" width="100">
<template #default="scope">
<image-preview :src="scope.row.picture" :width="50" :height="50"/>
</template>
</el-table-column>
<el-table-column label="商品详情id" align="center" prop="goodsinformationid" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template #default="scope">
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['system:goods:edit']">修改</el-button>
@ -133,12 +142,48 @@
<el-form-item label="商品价格" prop="price">
<el-input v-model="form.price" placeholder="请输入商品价格" />
</el-form-item>
<el-form-item label="已售数量" prop="amount">
<el-input v-model="form.amount" placeholder="请输入已售数量" />
<el-form-item label="商品数量" prop="amount">
<el-input v-model="form.amount" placeholder="请输入商品数量" />
</el-form-item>
<el-form-item label="商品图片" prop="picture">
<image-upload v-model="form.picture"/>
</el-form-item>
<el-form-item label="商品详情id" prop="goodsinformationid">
<el-input v-model="form.goodsinformationid" placeholder="请输入商品详情id" />
</el-form-item>
<el-divider content-position="center">水果产品详情信息</el-divider>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" icon="Plus" @click="handleAddGoodsinformation">添加</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="danger" icon="Delete" @click="handleDeleteGoodsinformation">删除</el-button>
</el-col>
</el-row>
<el-table :data="goodsinformationList" :row-class-name="rowGoodsinformationIndex" @selection-change="handleGoodsinformationSelectionChange" ref="goodsinformation">
<el-table-column type="selection" width="50" align="center" />
<el-table-column label="序号" align="center" prop="index" width="50"/>
<el-table-column label="供应商" prop="supplier" width="150">
<template #default="scope">
<el-input v-model="scope.row.supplier" placeholder="请输入供应商" />
</template>
</el-table-column>
<el-table-column label="规格" prop="standard" width="150">
<template #default="scope">
<el-input v-model="scope.row.standard" placeholder="请输入规格" />
</template>
</el-table-column>
<el-table-column label="产地" prop="locality" width="150">
<template #default="scope">
<el-input v-model="scope.row.locality" placeholder="请输入产地" />
</template>
</el-table-column>
<el-table-column label="保质期限" prop="qualityguaranteeperiod" width="150">
<template #default="scope">
<el-input v-model="scope.row.qualityguaranteeperiod" placeholder="请输入保质期限" />
</template>
</el-table-column>
</el-table>
</el-form>
<template #footer>
<div class="dialog-footer">
@ -156,10 +201,12 @@ import { listGoods, getGoods, delGoods, addGoods, updateGoods } from "@/api/syst
const { proxy } = getCurrentInstance();
const goodsList = ref([]);
const goodsinformationList = ref([]);
const open = ref(false);
const loading = ref(true);
const showSearch = ref(true);
const ids = ref([]);
const checkedGoodsinformation = ref([]);
const single = ref(true);
const multiple = ref(true);
const total = ref(0);
@ -175,7 +222,8 @@ const data = reactive({
time2: null,
price: null,
amount: null,
picture: null
picture: null,
goodsinformationid: null
},
rules: {
}
@ -208,8 +256,10 @@ function reset() {
time2: null,
price: null,
amount: null,
picture: null
picture: null,
goodsinformationid: null
};
goodsinformationList.value = [];
proxy.resetForm("goodsRef");
}
@ -245,6 +295,7 @@ function handleUpdate(row) {
const _goodsId = row.goodsId || ids.value
getGoods(_goodsId).then(response => {
form.value = response.data;
goodsinformationList.value = response.data.goodsinformationList;
open.value = true;
title.value = "修改水果产品增删改查表";
});
@ -254,6 +305,7 @@ function handleUpdate(row) {
function submitForm() {
proxy.$refs["goodsRef"].validate(valid => {
if (valid) {
form.value.goodsinformationList = goodsinformationList.value;
if (form.value.goodsId != null) {
updateGoods(form.value).then(response => {
proxy.$modal.msgSuccess("修改成功");
@ -282,6 +334,43 @@ function handleDelete(row) {
}).catch(() => {});
}
/** 水果产品详情序号 */
function rowGoodsinformationIndex({ row, rowIndex }) {
row.index = rowIndex + 1;
}
/** 水果产品详情添加按钮操作 */
function handleAddGoodsinformation() {
let obj = {};
obj.supplier = "";
obj.standard = "";
obj.locality = "";
obj.qualityguaranteeperiod = "";
obj.particular = "";
obj.picture1 = "";
obj.picture2 = "";
obj.picture3 = "";
goodsinformationList.value.push(obj);
}
/** 水果产品详情删除按钮操作 */
function handleDeleteGoodsinformation() {
if (checkedGoodsinformation.value.length == 0) {
proxy.$modal.msgError("请先选择要删除的水果产品详情数据");
} else {
const goodsinformations = goodsinformationList.value;
const checkedGoodsinformations = checkedGoodsinformation.value;
goodsinformationList.value = goodsinformations.filter(function(item) {
return checkedGoodsinformations.indexOf(item.index) == -1
});
}
}
/** 复选框选中数据 */
function handleGoodsinformationSelectionChange(selection) {
checkedGoodsinformation.value = selection.map(item => item.index)
}
/** 导出按钮操作 */
function handleExport() {
proxy.download('system/goods/export', {

View File

@ -0,0 +1,319 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="供应商" prop="supplier">
<el-input
v-model="queryParams.supplier"
placeholder="请输入供应商"
clearable
@keyup.enter="handleQuery"
/>
</el-form-item>
<el-form-item label="规格" prop="standard">
<el-input
v-model="queryParams.standard"
placeholder="请输入规格"
clearable
@keyup.enter="handleQuery"
/>
</el-form-item>
<el-form-item label="产地" prop="locality">
<el-input
v-model="queryParams.locality"
placeholder="请输入产地"
clearable
@keyup.enter="handleQuery"
/>
</el-form-item>
<el-form-item label="保质期限" prop="qualityguaranteeperiod">
<el-input
v-model="queryParams.qualityguaranteeperiod"
placeholder="请输入保质期限"
clearable
@keyup.enter="handleQuery"
/>
</el-form-item>
<el-form-item label="商品id" prop="goodsid">
<el-input
v-model="queryParams.goodsid"
placeholder="请输入商品id"
clearable
@keyup.enter="handleQuery"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
<el-button 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="Plus"
@click="handleAdd"
v-hasPermi="['system:goodsinformation:add']"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
plain
icon="Edit"
:disabled="single"
@click="handleUpdate"
v-hasPermi="['system:goodsinformation:edit']"
>修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="Delete"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['system:goodsinformation:remove']"
>删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="Download"
@click="handleExport"
v-hasPermi="['system:goodsinformation:export']"
>导出</el-button>
</el-col>
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="goodsinformationList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="商品详情id" align="center" prop="goodsinformationid" />
<el-table-column label="供应商" align="center" prop="supplier" />
<el-table-column label="规格" align="center" prop="standard" />
<el-table-column label="产地" align="center" prop="locality" />
<el-table-column label="保质期限" align="center" prop="qualityguaranteeperiod" />
<el-table-column label="产品描述" align="" prop="particular" width="300"/>
<el-table-column label="图片1" align="center" prop="picture1" width="100">
<template #default="scope">
<image-preview :src="scope.row.picture1" :width="50" :height="50"/>
</template>
</el-table-column>
<el-table-column label="图片2" align="center" prop="picture2" width="100">
<template #default="scope">
<image-preview :src="scope.row.picture2" :width="50" :height="50"/>
</template>
</el-table-column>
<el-table-column label="图片3" align="center" prop="picture3" width="100">
<template #default="scope">
<image-preview :src="scope.row.picture3" :width="50" :height="50"/>
</template>
</el-table-column>
<el-table-column label="商品id" align="center" prop="goodsid" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template #default="scope">
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['system:goodsinformation:edit']">修改</el-button>
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['system:goodsinformation:remove']">删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
v-model:page="queryParams.pageNum"
v-model:limit="queryParams.pageSize"
@pagination="getList"
/>
<!-- 添加或修改水果产品详情对话框 -->
<el-dialog :title="title" v-model="open" width="500px" append-to-body>
<el-form ref="goodsinformationRef" :model="form" :rules="rules" label-width="80px">
<el-form-item label="供应商" prop="supplier">
<el-input v-model="form.supplier" placeholder="请输入供应商" />
</el-form-item>
<el-form-item label="规格" prop="standard">
<el-input v-model="form.standard" placeholder="请输入规格" />
</el-form-item>
<el-form-item label="产地" prop="locality">
<el-input v-model="form.locality" placeholder="请输入产地" />
</el-form-item>
<el-form-item label="保质期限" prop="qualityguaranteeperiod">
<el-input v-model="form.qualityguaranteeperiod" placeholder="请输入保质期限" />
</el-form-item>
<el-form-item label="产品描述" prop="particular">
<el-input v-model="form.particular" type="textarea" placeholder="请输入内容" />
</el-form-item>
<el-form-item label="图片1" prop="picture1">
<image-upload v-model="form.picture1"/>
</el-form-item>
<el-form-item label="图片2" prop="picture2">
<image-upload v-model="form.picture2"/>
</el-form-item>
<el-form-item label="图片3" prop="picture3">
<image-upload v-model="form.picture3"/>
</el-form-item>
<el-form-item label="商品id" prop="goodsid">
<el-input v-model="form.goodsid" placeholder="请输入商品id" />
</el-form-item>
</el-form>
<template #footer>
<div class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</template>
</el-dialog>
</div>
</template>
<script setup name="Goodsinformation">
import { listGoodsinformation, getGoodsinformation, delGoodsinformation, addGoodsinformation, updateGoodsinformation } from "@/api/system/goodsinformation";
const { proxy } = getCurrentInstance();
const goodsinformationList = ref([]);
const open = ref(false);
const loading = ref(true);
const showSearch = ref(true);
const ids = ref([]);
const single = ref(true);
const multiple = ref(true);
const total = ref(0);
const title = ref("");
const data = reactive({
form: {},
queryParams: {
pageNum: 1,
pageSize: 10,
supplier: null,
standard: null,
locality: null,
qualityguaranteeperiod: null,
particular: null,
picture1: null,
picture2: null,
picture3: null,
goodsid: null
},
rules: {
}
});
const { queryParams, form, rules } = toRefs(data);
/** 查询水果产品详情列表 */
function getList() {
loading.value = true;
listGoodsinformation(queryParams.value).then(response => {
goodsinformationList.value = response.rows;
total.value = response.total;
loading.value = false;
});
}
//
function cancel() {
open.value = false;
reset();
}
//
function reset() {
form.value = {
goodsinformationid: null,
supplier: null,
standard: null,
locality: null,
qualityguaranteeperiod: null,
particular: null,
picture1: null,
picture2: null,
picture3: null,
goodsid: null
};
proxy.resetForm("goodsinformationRef");
}
/** 搜索按钮操作 */
function handleQuery() {
queryParams.value.pageNum = 1;
getList();
}
/** 重置按钮操作 */
function resetQuery() {
proxy.resetForm("queryRef");
handleQuery();
}
//
function handleSelectionChange(selection) {
ids.value = selection.map(item => item.goodsinformationid);
single.value = selection.length != 1;
multiple.value = !selection.length;
}
/** 新增按钮操作 */
function handleAdd() {
reset();
open.value = true;
title.value = "添加水果产品详情";
}
/** 修改按钮操作 */
function handleUpdate(row) {
reset();
const _goodsinformationid = row.goodsinformationid || ids.value
getGoodsinformation(_goodsinformationid).then(response => {
form.value = response.data;
open.value = true;
title.value = "修改水果产品详情";
});
}
/** 提交按钮 */
function submitForm() {
proxy.$refs["goodsinformationRef"].validate(valid => {
if (valid) {
if (form.value.goodsinformationid != null) {
updateGoodsinformation(form.value).then(response => {
proxy.$modal.msgSuccess("修改成功");
open.value = false;
getList();
});
} else {
addGoodsinformation(form.value).then(response => {
proxy.$modal.msgSuccess("新增成功");
open.value = false;
getList();
});
}
}
});
}
/** 删除按钮操作 */
function handleDelete(row) {
const _goodsinformationids = row.goodsinformationid || ids.value;
proxy.$modal.confirm('是否确认删除水果产品详情编号为"' + _goodsinformationids + '"的数据项?').then(function() {
return delGoodsinformation(_goodsinformationids);
}).then(() => {
getList();
proxy.$modal.msgSuccess("删除成功");
}).catch(() => {});
}
/** 导出按钮操作 */
function handleExport() {
proxy.download('system/goodsinformation/export', {
...queryParams.value
}, `goodsinformation_${new Date().getTime()}.xlsx`)
}
getList();
</script>