修改bug

This commit is contained in:
yuanteng 2024-11-05 20:19:45 +08:00
parent ee87e55b63
commit 393e3d9dc9
5 changed files with 92 additions and 33 deletions

View File

@ -1,9 +1,17 @@
<template> <template>
<RouterView></RouterView> <RouterView v-if="isRouterActive"></RouterView>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
//
import { provide , nextTick , ref } from 'vue'
const isRouterActive = ref(true)
provide('reload', () => {
isRouterActive.value = false
nextTick(() => {
isRouterActive.value = true
})
})
</script> </script>

View File

@ -5,12 +5,14 @@
<el-form-item label="添加商品图片"> <el-form-item label="添加商品图片">
<!-- 下面的event的作用,传入当前事件对象 --> <!-- 下面的event的作用,传入当前事件对象 -->
<el-upload <el-upload
ref="uploadProductImg"
action="#" action="#"
list-type="picture-card" list-type="picture-card"
:auto-upload="false" :auto-upload="false"
multiple="true" multiple="true"
:on-remove="handleRemove" :on-remove="handleRemove"
@change="(event: any) => handleChange(event, 0)" @change="(event: any) => handleChange(event, 0)"
:on-exceed="Exceed_ProductImg"
limit="1" > limit="1" >
<el-icon> <el-icon>
<Plus /> <Plus />
@ -20,11 +22,13 @@
<!-- 添加图文描述--> <!-- 添加图文描述-->
<el-form-item label="添加图文描述"> <el-form-item label="添加图文描述">
<el-upload <el-upload
ref="uploadProductDetail"
action="#" action="#"
list-type="picture-card" list-type="picture-card"
:auto-upload="false" :auto-upload="false"
multiple="true" multiple="true"
:on-change="(event: any) => handleChange(event, 1)" :on-change="(event: any) => handleChange(event, 1)"
:on-exceed="Exceed_ProductDetail"
limit="1" limit="1"
:on-remove="handleRemove" :on-remove="handleRemove"
> >
@ -77,9 +81,9 @@
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { ref, onMounted } from 'vue'; import { ref, onMounted , inject} from 'vue';
import { Plus } from '@element-plus/icons-vue'; import { Plus } from '@element-plus/icons-vue';
import { ElMessage, type UploadFile , type UploadProps } from 'element-plus'; import { ElMessage, type UploadFile , type UploadProps , genFileId , type UploadRawFile} from 'element-plus';
import myAxios from "@/api/myAxios"; import myAxios from "@/api/myAxios";
const fileSimple = ref() // const fileSimple = ref() //
const uploadedFiles = ref<UploadFile[]>([]);// const uploadedFiles = ref<UploadFile[]>([]);//
@ -97,12 +101,16 @@ const form = ref({
detailImg: '', //url detailImg: '', //url
inventory: '' // inventory: '' //
}) })
//
const reload : any = inject("reload")
const typeList: any = ref([ const typeList: any = ref([
{ {
value1: '', value1: '',
label: '' label: ''
} }
]) ])
const uploadProductImg : any = ref() //ref
const uploadProductDetail : any = ref() //ref
onMounted(() => { onMounted(() => {
getTypeList() //select getTypeList() //select
}) })
@ -135,8 +143,10 @@ const onSubmit = async () => {
type: 'success', type: 'success',
message: "提交成功" message: "提交成功"
}) })
reload() //
} else { } else {
ElMessage.error("服务错误") ElMessage.error("服务错误")
return;
} }
} }
// //
@ -169,4 +179,16 @@ const loadForm = (value: any, flag: number) => {
const resetForm = () =>{ const resetForm = () =>{
resetFormData.value.resetFields() resetFormData.value.resetFields()
} }
const Exceed_ProductImg: UploadProps['onExceed'] = (files) => { //
uploadProductImg.value!.clearFiles()
const file = files[0] as UploadRawFile
file.uid = genFileId()
uploadProductImg.value!.handleStart(file)
}
const Exceed_ProductDetail: UploadProps['onExceed'] = (files) => { //
uploadProductDetail.value!.clearFiles()
const file = files[0] as UploadRawFile
file.uid = genFileId()
uploadProductDetail.value!.handleStart(file)
}
</script> </script>

View File

@ -3,23 +3,19 @@
<!-- 搜索 --> <!-- 搜索 -->
<div> <div>
<el-input style="width: 200px; height: 30px; margin-right: 10px;" suffix-icon="Search" placeholder="请输入商品名称" <el-input style="width: 200px; height: 30px; margin-right: 10px;" suffix-icon="Search" placeholder="请输入商品名称"
v-model="username"></el-input> v-model="productName"></el-input>
<el-form-item label="商品类型" style="width: 200px; margin-right: 10px;display: inline-block"> <el-form-item label="商品类型" style="width: 200px; margin-right: 10px;display: inline-block">
<el-select v-model="types" placeholder="请选择"> <el-select v-model="editForm.type" @change="(event: any) => searchByType(event)" placeholder="请选择">
<el-option label="材料包" value="材料包" /> <el-option v-for="item in typeList" :key="item.value" :label="item.label" :value="item.value1" />
<el-option label="手持物" value="手持物" />
<el-option label="头饰" value="头饰" />
<el-option label="定制" value="定制" />
<el-option label="积分兑换" value="积分兑换" />
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="商品状态" style="width: 200px;margin-right: 10px;display: inline-block"> <el-form-item label="商品状态" style="width: 200px;margin-right: 10px;display: inline-block">
<el-select v-model="Region" placeholder="请选择"> <el-select v-model="state" placeholder="请选择" @change="(event: any) => searchByState(event)">
<el-option label="已上架" value="上架" /> <el-option label="已上架" value="1" />
<el-option label="已下架" value="下架" /> <el-option label="已下架" value="0" />
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-button class="ml-5" type="primary" @click="load" style="height: 25px;">搜索</el-button> <el-button class="ml-5" type="primary" @click="onSearch(productName)" style="height: 25px;">搜索</el-button>
<el-button type="warning" @click="reset" style="height:25px">重置</el-button> <el-button type="warning" @click="reset" style="height:25px">重置</el-button>
</div> </div>
<div style="margin: 15px 0"> <div style="margin: 15px 0">
@ -101,12 +97,14 @@
<img :src="editForm.goodImg" alt="商品图标" class="thumbnail" style="width: 100px; height: 100px;" /> <img :src="editForm.goodImg" alt="商品图标" class="thumbnail" style="width: 100px; height: 100px;" />
</div> </div>
<el-upload <el-upload
ref="uploadProductImg"
action="#" action="#"
list-type="picture-card" list-type="picture-card"
:auto-upload="false" :auto-upload="false"
multiple="true" multiple="true"
:on-remove="handleRemove" :on-remove="handleRemove"
@change="(event: any) => handleChange(event, 0)" @change="(event: any) => handleChange(event, 0)"
:on-exceed="Exceed_ProductImg"
limit="1" > limit="1" >
<el-icon> <el-icon>
<Plus/> <Plus/>
@ -147,12 +145,14 @@
<img :src="editForm.detailImg" alt="商品图标" class="thumbnail" style="width: 100px; height: 100px;" /> <img :src="editForm.detailImg" alt="商品图标" class="thumbnail" style="width: 100px; height: 100px;" />
</div> </div>
<el-upload <el-upload
ref="uploadProductDetail"
action="#" action="#"
list-type="picture-card" list-type="picture-card"
:auto-upload="false" :auto-upload="false"
multiple="true" multiple="true"
:on-remove="handleRemove" :on-remove="handleRemove"
@change="(event: any) => handleChange(event, 0)" @change="(event: any) => handleChange(event, 1)"
:on-exceed="Exceed_ProductDetail"
limit="1" > limit="1" >
<el-icon> <el-icon>
<Plus/> <Plus/>
@ -173,8 +173,8 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ElMessage , type UploadProps } from 'element-plus'; import { ElMessage , type UploadProps , genFileId ,type UploadRawFile } from 'element-plus';
import { ref, onMounted, toRaw } from 'vue'; import { ref, onMounted, inject } from 'vue';
import myAxios from "@/api/myAxios"; import myAxios from "@/api/myAxios";
const total = ref(0); // const total = ref(0); //
const id = ref([]); const id = ref([]);
@ -184,13 +184,15 @@ const searchParams: any = ref({ //封装分页
}) })
const fileSimple = ref() const fileSimple = ref()
const disabled = ref(true) const disabled = ref(true)
const title = ref('') const title = ref('') //
const username = ref(''); const productName = ref('');
const DialogVisible = ref(false); const DialogVisible = ref(false);
const types = ref(''); const state = ref(''); //select
const Region = ref('');
const tableData : any= ref([]); const tableData : any= ref([]);
const editForm : any = ref({}); const editForm : any = ref({});
const reload : any = inject("reload") //
const uploadProductImg : any = ref() //ref
const uploadProductDetail : any = ref() //ref
const typeList: any = ref([ const typeList: any = ref([
{ {
value1: '', value1: '',
@ -207,11 +209,12 @@ const getProductList = async () => {
// console.log(res.data) // console.log(res.data)
if (res.data.code === 1) { if (res.data.code === 1) {
tableData.value = res.data.data.records; tableData.value = res.data.data.records;
total.value = parseInt(res.data.data.total)// total.value = parseInt(res.data.data.total) //
} else { } else {
ElMessage({ ElMessage({
message: '获取数据失败', message: '获取数据失败',
}); });
return;
} }
} catch (error) { } catch (error) {
ElMessage({ ElMessage({
@ -240,6 +243,16 @@ const saveEdit = async () => { //编辑商品
ElMessage.error('更新失败,请检查字段') ElMessage.error('更新失败,请检查字段')
} }
} }
const searchByType =(event : any)=>{ //
searchParams.value.type = event
searchParams.value.current = 1
getProductList()
}
const searchByState = (event : any) => { ///
searchParams.value.isShelves = event
searchParams.value.current = 1
getProductList()
}
// //
const deleteProduct = async (index: number) => { const deleteProduct = async (index: number) => {
console.log(typeof index) console.log(typeof index)
@ -286,15 +299,26 @@ const handleCurrentChange = (Current: any) => {
searchParams.value.current = Current searchParams.value.current = Current
getProductList() getProductList()
} }
//
const reset = () => { const reset = () => {
username.value = ''; reload()
types.value = '';
Region.value = '';
}; };
// -- // --
const handleRemove: UploadProps['onRemove'] = (uploadFile, uploadFiles) => { const handleRemove: UploadProps['onRemove'] = (uploadFile, uploadFiles) => {
console.log(uploadFile, uploadFiles) console.log(uploadFile, uploadFiles)
} }
const Exceed_ProductImg: UploadProps['onExceed'] = (files , flag) => { //
uploadProductImg.value!.clearFiles()
const file = files[0] as UploadRawFile
file.uid = genFileId()
uploadProductImg.value!.handleStart(file)
}
const Exceed_ProductDetail: UploadProps['onExceed'] = (files) => { //
uploadProductDetail.value!.clearFiles()
const file = files[0] as UploadRawFile
file.uid = genFileId()
uploadProductDetail.value!.handleStart(file)
}
// //
const loadForm = (value: any, flag: number) => { const loadForm = (value: any, flag: number) => {
flag ? editForm.value.type = value : editForm.value.festivalOrder = value // flag=1 "" flag=0 flag ? editForm.value.type = value : editForm.value.festivalOrder = value // flag=1 "" flag=0
@ -321,6 +345,11 @@ const handleChange = async (file: any, flag: number) => {
} }
} }
const onSearch = (data : String)=>{ //
searchParams.value.name = data
searchParams.value.current = 1
getProductList()
}
const delBatch =()=>{ const delBatch =()=>{
// //
} }

View File

@ -1,4 +1,4 @@
<!-- <template>--> <template>
<!--<div>--> <!--<div>-->
<!-- <el-input style="width: 200px; height: 30px; margin-right: 10px;" suffix-icon="Search" placeholder="请输入商品名称"--> <!-- <el-input style="width: 200px; height: 30px; margin-right: 10px;" suffix-icon="Search" placeholder="请输入商品名称"-->
<!-- v-model="id"></el-input>--> <!-- v-model="id"></el-input>-->
@ -67,7 +67,7 @@
<!-- </div>--> <!-- </div>-->
<!-- </template>--> <!-- </template>-->
<!-- </el-dialog>--> <!-- </el-dialog>-->
<!--</template>--> </template>
<!--<script lang="ts" setup>--> <!--<script lang="ts" setup>-->
<!--import {ref} from "vue";--> <!--import {ref} from "vue";-->

View File

@ -71,7 +71,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { ElMessage } from 'element-plus'; import { ElMessage } from 'element-plus';
import myAxios from '@/api/myAxios'; import myAxios from '@/api/myAxios';
import {ref, onMounted} from 'vue' import {ref, onMounted , inject} from 'vue'
// //
const tableData = ref([]) const tableData = ref([])
@ -84,15 +84,15 @@ const searchParams: any = ref({
// //
pageSize: 5 pageSize: 5
}) })
//
const reload : any = inject("reload")
onMounted(() => { onMounted(() => {
getUserList() getUserList()
}) })
const username = ref('') const username = ref('')
//
const reset =()=>{ const reset =()=>{
username.value = '' reload()
onSearch(username.value)
getUserList()
} }
// //
const getUserList = async () => { const getUserList = async () => {