This commit is contained in:
yuanteng 2024-12-17 14:59:10 +08:00
commit e63fe5da2c
4 changed files with 128 additions and 58 deletions

View File

@ -35,20 +35,25 @@
</el-upload>
</el-form-item>
<el-form-item label="服装名称" prop="name">
<el-input v-model="form.name" />
<el-input v-model="form.name" maxlength="30" placeholder="30字以内"/>
</el-form-item>
<el-form-item label="服装价格" prop="price">
<el-form-item label="服装价格(元)" prop="price">
<el-input v-model="form.price" />
</el-form-item>
<el-form-item label="服装类别" prop="intro">
<el-input v-model="form.clothesType" />
<el-form-item label="服装类别" prop="clothesType">
<el-select v-model="clothesType.value" placeholder="请选择" @change="(event:any) => loadForm(event)">
<el-option v-for="item in clothesType" :key="item.value" :label="item.label" :value="item.values" />
</el-select>
</el-form-item>
<el-form-item label="服装简介" prop="intro">
<el-input v-model="form.intro" />
<el-input v-model="form.intro" maxlength="40" placeholder="40字以内"/>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="onSubmit">提交</el-button>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="resetForm">重置</el-button>
</el-form-item>
</el-form>
</div>
</template>
@ -58,7 +63,7 @@
import {Plus} from "@element-plus/icons-vue";
import {ElMessage, genFileId, type UploadProps, type UploadRawFile} from "element-plus";
import myAxios from "@/api/myAxios";
import {inject, ref} from "vue";
import {inject, ref ,onMounted} from "vue";
const fileSimple = ref()
const uploadProductImg : any = ref()
const uploadProductDetail : any = ref()
@ -70,6 +75,53 @@ const form = ref({
price:'',
clothesType:''
})
const clothesType: any = ref([
{
values: '',
label: ''
}
])
onMounted(()=>{
getGrade()
})
const getGrade = async ()=>{
const res = await myAxios.post('/clothesGrade/list',{})
for(let i in res.data.data){
clothesType.value[i] = {
values: res.data.data[i].clothesType,
label:res.data.data[i].clothesType,
}
}
}
const loadForm = (value: any) => {
form.value.clothesType = value
}
const reload : any = inject("reload")
const onSubmit = async () => {
const values = Object.values(form.value);
if (values.some(value => value === null || value === undefined || value === '')) {
ElMessage({
type:'warning',
message:'请检查表单数据是否完整填写'
})
return;
}
const res = await myAxios.post('/clothesInfo/add', { ...form.value })
if (res.data.code === 1) {
ElMessage({
type: 'success',
message: "提交成功"
})
reload() //
} else {
ElMessage.error("服务错误")
return;
}
}
const resetFormData = ref()
const resetForm = () =>{
resetFormData.value.resetFields()
}
const handleRemove: UploadProps['onRemove'] = (uploadFile, uploadFiles) => {
console.log(uploadFile, uploadFiles)
}
@ -104,29 +156,6 @@ const Exceed_ProductDetail: UploadProps['onExceed'] = (files) => { //覆盖商
file.uid = genFileId()
uploadProductDetail.value!.handleStart(file)
}
const reload : any = inject("reload")
const onSubmit = async () => {
const values = Object.values(form.value);
// 使some()
if (values.some(value => value === null || value === undefined || value === '')) {
ElMessage({
type:'warning',
message:'请检查表单数据是否完整填写'
})
return;
}
const res = await myAxios.post('/clothesInfo/add', { ...form.value })
if (res.data.code === 1) {
ElMessage({
type: 'success',
message: "提交成功"
})
reload() //
} else {
ElMessage.error("服务错误")
return;
}
}
</script>

View File

@ -43,6 +43,13 @@
</template>
</el-table-column>
</el-table>
<el-config-provider style="padding: 10px 0" :locale="zhCn">
<el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
:current-page="searchParams.current" :page-size="searchParams.pageSize" :page-sizes="[5, 10, 15, 20]"
:small="null" :disabled="null" :background="null" layout="total, sizes, prev, pager, next, jumper"
:total="total" />
</el-config-provider>
<!-- 弹窗-->
<el-dialog v-model="dialogVisible" title="" width="500">
<el-form :model="order" label-width="auto" style="max-width: 600px" :disabled="disabled">
@ -93,17 +100,13 @@
</template>
<script setup lang="ts">
import { ref,onMounted } from 'vue'
import { ref,onMounted,inject } from 'vue'
import myAxios from "@/api/myAxios";
import zhCn from 'element-plus/es/locale/lang/zh-cn';
import {ElMessage, genFileId, type UploadProps, type UploadRawFile} from "element-plus";
const orders = ref([{}])
const name = ref('')
const searchParams: any = ref({ //
current: 1, //
pageSize: 5, //
sortField: "id", //ID
sortOrder: "descend" //
})
onMounted(()=>{
getList()
})
@ -151,7 +154,6 @@ const editShow = (index: number, row: any,flag:number) => {
const cancel = () => {
dialogVisible.value = false
}
const editForm : any = ref({})
const addType =async () => {
dialogVisible.value = false
const res = await myAxios.post('/advanceOrder/update',{
@ -175,8 +177,25 @@ const Search = (data:any)=>{
searchParams.value.current = 1
getList()
}
//
const reload : any = inject("reload")
const reset = ()=>{
name.value = ''
reload()
}
//
const searchParams: any = ref({
current: 1,
pageSize: 5,
sortField: "id",
sortOrder: "descend"
})
const handleSizeChange = (newSize: any) => {
searchParams.value.pageSize = newSize
getList()
}
const handleCurrentChange = (Current: any) => {
searchParams.value.current = Current
getList()
}
</script>

View File

@ -14,8 +14,8 @@
</template>
</el-table-column>
<el-table-column prop="clothesType" label="等级" ></el-table-column>
<el-table-column prop="minPrice" label="最低价" ></el-table-column>
<el-table-column prop="maxPrice" label="最高价" ></el-table-column>
<el-table-column prop="minPrice" label="最低价(元)" ></el-table-column>
<el-table-column prop="maxPrice" label="最高价(元)" ></el-table-column>
<el-table-column prop="brief" label="简介" ></el-table-column>
<el-table-column label="操作">
<template #default="scope">
@ -48,14 +48,14 @@
<el-form-item label="名称">
<el-input v-model="order.clothesType"/>
</el-form-item>
<el-form-item label="最低价">
<el-input v-model="order.minPrice"/>
<el-form-item label="最低价(元)">
<el-input v-model="order.minPrice" />
</el-form-item>
<el-form-item label="最高">
<el-form-item label="最高价(元)">
<el-input v-model="order.maxPrice"/>
</el-form-item>
<el-form-item label="简介">
<el-input v-model="order.brief"/>
<el-input v-model="order.brief" maxlength="30" placeholder="30字以内"/>
</el-form-item>
</el-form>
<template #footer #default="{ row, $index }">

View File

@ -22,7 +22,7 @@
<el-table-column prop="id" label="序号" width="50"></el-table-column>
<el-table-column prop="name" label="服装名称" ></el-table-column>
<el-table-column prop="clothesType" label="类型"></el-table-column>
<el-table-column prop="price" label="价格"></el-table-column>
<el-table-column prop="price" label="价格(元)"></el-table-column>
<el-table-column prop="image" label="类别图片" width="200">
<template #default="scope"><img :src="scope.row.image" alt="" style="height: 50px;"></template>
</el-table-column>
@ -43,12 +43,13 @@
</el-table-column>
</el-table>
<!-- 分页-->
<div style="padding: 10px 0">
<el-config-provider style="padding: 10px 0" :locale="zhCn">
<el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
:current-page="searchParams.current" :page-size="searchParams.pageSize" :page-sizes="[5, 10, 15, 20]"
:small="null" :disabled="null" :background="null" layout="total, sizes, prev, pager, next, jumper"
:total="total" />
</div>
</el-config-provider>
<!-- 弹窗-->
<el-dialog v-model="dialogVisible" title="" width="500">
<el-form :model="order" label-width="auto" style="max-width: 600px" :disabled="disabled">
@ -89,12 +90,14 @@
</el-upload>
</el-form-item>
<el-form-item label="名称">
<el-input v-model="order.name"/>
<el-input v-model="order.name" maxlength="25" placeholder="25字以内"/>
</el-form-item>
<el-form-item label="类型">
<el-input v-model="order.clothesType"/>
<el-form-item label="类型" prop="clothesType">
<el-select v-model="order.clothesType" @change="(event: any) => loadForm(event)">
<el-option v-for="item in clothesType" :key="item.value" :label="item.label" :value="item.values" />
</el-select>
</el-form-item>
<el-form-item label="价格">
<el-form-item label="价格(元)">
<el-input v-model="order.price"/>
</el-form-item>
<el-form-item label="简介">
@ -104,7 +107,7 @@
<template #footer #default="{ row, $index }">
<div class="dialog-footer">
<el-button @click="cancel">取消</el-button>
<el-button type="primary" @click="addType">
<el-button type="primary" @click="saveEdit">
确定
</el-button>
</div>
@ -113,12 +116,14 @@
</template>
<script setup lang="ts">
import {ref, onMounted} from 'vue'
import {ref, onMounted,inject} from 'vue'
import myAxios from "@/api/myAxios";
import {ElMessage, genFileId, type UploadProps, type UploadRawFile} from "element-plus";
import zhCn from "element-plus/es/locale/lang/zh-cn";
onMounted(()=>{
getList()
getGrade()
})
const orders = ref([{}])
const total = ref(0)
@ -146,6 +151,24 @@ const order=ref({
intro:'',
clothesType:''
})
const clothesType: any = ref([
{
values: '',
label: ''
}
])
const getGrade = async ()=>{
const res = await myAxios.post('/clothesGrade/list',{})
for(let i in res.data.data){
clothesType.value[i] = {
values: res.data.data[i].clothesType,
label:res.data.data[i].clothesType,
}
}
}
const loadForm = (value: any) => {
order.value.clothesType = value
}
const handleRemove: UploadProps['onRemove'] = (uploadFile, uploadFiles) => {
console.log(uploadFile, uploadFiles)
}
@ -190,16 +213,15 @@ const handleCurrentChange = (Current: any) => {
searchParams.value.current = Current
getList()
}
//
const Search = (data:String)=>{
searchParams.value.name = data
searchParams.value.current = 1
getList()
}
// const reload : any = inject("reload")
const reload : any = inject("reload")
const reset =()=>{
name.value=''
reload()
}
const handleSelectionChange = (val:any)=>{
console.log(val)
@ -243,9 +265,9 @@ const delBatch = async ()=>{
}
const editForm : any = ref({})
//
const addType =async ()=>{
const saveEdit =async ()=>{
dialogVisible.value = false
const res = await myAxios('/clothesInfo/update',{...editForm.value})
const res = await myAxios.post('/clothesInfo/update',{...editForm.value})
if(res.data.code === 1) {
ElMessage({
type: 'success',