白胚维护完成

This commit is contained in:
ljx120 2024-12-23 10:41:00 +08:00
parent 2919bdfc90
commit 7d27322db5
4 changed files with 75 additions and 16 deletions

View File

@ -21,7 +21,7 @@ function httpRequest(url : string, method : any, data = {}, headerCustom = {}) {
const finalHeader = Object.assign({}, header, headerCustom);
uni.setStorageSync('baseURL', myconfig.base_url)
uni.request({
url: myconfig.base_url + url, // 拼接基础URL和请求路径
url: url==='http://192.168.1.2:7000/v1/auth/login'?url:myconfig.base_url + url, // 拼接基础URL和请求路径
method: method,
data: data, // 如果是GET请求data应该为null
header: finalHeader,

View File

@ -44,7 +44,7 @@ const onSubmit = () => {
'username':username.value,
'password':password.value,
}
postAction('/v1/auth/login',data,{'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'}).then((res:any) => {
postAction('http://192.168.1.2:7000/v1/auth/login',data,{'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'}).then((res:any) => {
if (res.code === 200) {
const token = res.data;
localStorage.setItem("token", token);

View File

@ -10,13 +10,15 @@ const level = ref('' as any)
const id= ref('' as any)
onMounted(()=>{
init()
})
const init =()=>{
getAction('/rawFabricLevels',{page:1,size:100}).then((res:any)=>{
if(res.code===200){
list.value=res.data.recond
list.value=res.data.record
}
})
})
}
const onClickLeft = () =>{
history.back()
}
@ -37,6 +39,7 @@ const submit =()=>{
if(res.code===200){
showPop.value=false
showToast('编辑成功!')
init()
}
})
}else{
@ -44,6 +47,7 @@ const submit =()=>{
if(res.code===200){
showPop.value=false
showToast('提交成功!')
init()
}
})
}
@ -53,6 +57,7 @@ const delItem = (item:any) =>{
deleteAction(url).then((res:any)=>{
if(res.code===200){
showToast('删除成功!')
init()
}
})
}
@ -75,8 +80,8 @@ const delItem = (item:any) =>{
<view class="grid-item">操作</view>
</view>
<view class="grid-container" v-for="(item,index) in list" :key="index">
<view class="grid-item">{{item.name}}</view>
<view class="grid-item">{{item.id}}</view>
<view class="grid-item">{{item.level}}</view>
<view
class="grid-item"><span style="color: #35a5f7" @click="edit(item)">编辑</span> &nbsp;&nbsp; <span
style="color: red" @click="delItem(item)">删除

View File

@ -1,23 +1,65 @@
<script lang="ts" setup>
import { ref } from 'vue'
import { onMounted, ref } from 'vue'
import { deleteAction, getAction, postAction, putAction } from '../../common/http';
import { showToast } from 'vant';
const showPop = ref(false)
const list= ref([{}] as any[])
const form = ref({list:[{}]} as any)
const list= ref([] as any[])
const form = ref({active:false} as any)
const name = ref('')
onMounted(()=>{
init()
})
const init=()=>{
getAction('/suppliers',{page:1,size:100}).then((res:any)=>{
if(res.code===200){
list.value=res.data.record
}
})
}
const onClickLeft = () =>{
history.back()
}
const onClickRight=()=>{
showPop.value=true
form.value={active:false}
}
const edit = (item:any) =>{
console.log(item)
form.value=item
showPop.value=true
}
const submit =()=>{
if(form.value.id){
putAction('/suppliers',{id:form.value.id,name:form.value.name,active:form.value.active}).then((res:any)=>{
if(res.code===200){
showPop.value=false
showToast('提交成功!')
init()
}
})
}else{
postAction('/suppliers',{name:form.value.name,active:form.value.active}).then((res:any)=>{
if(res.code===200){
showPop.value=false
showToast('提交成功!')
init()
}
})
}
}
//
const del=(item:any)=>{
let url='/suppliers/'+item.id
deleteAction(url).then((res:any)=>{
if(res.code===200){
showToast('删除成功!')
init()
}
})
}
</script>
@ -31,6 +73,18 @@ const submit =()=>{
@click-left="onClickLeft"
@click-right="onClickRight"
/>
<view>
<van-cell-group inset>
<van-field
v-model="name"
name="供应商名称"
label="供应商名称"
colon
class="bot"
label-width="6em"
/>
</van-cell-group>
</view>
<view class="content">
<view class="grid-container">
<view class="grid-item">编号</view>
@ -39,12 +93,12 @@ const submit =()=>{
<view class="grid-item">操作</view>
</view>
<view class="grid-container" v-for="(item,index) in list" :key="index">
<view class="grid-item">{{item.name}}</view>
<view class="grid-item">{{item.id}}</view>
<view class="grid-item">{{item.name}}</view>
<view class="grid-item">{{item.id}}</view>
<view
class="grid-item"><span style="color: #35a5f7" @click="edit(item)">编辑</span> &nbsp;&nbsp; <span
style="color: red">删除
style="color: red" @click="del(item)">删除
</span></view>
</view>
</view>
@ -65,9 +119,9 @@ const submit =()=>{
/>
<van-field name="状态" label="状态" colon label-width="6em">
<template #input>
<van-radio-group v-model="form.type1" direction="horizontal">
<van-radio name="1">启用</van-radio>
<van-radio name="2">禁用</van-radio>
<van-radio-group v-model="form.active" direction="horizontal">
<van-radio :name="true">启用</van-radio>
<van-radio :name="false">禁用</van-radio>
</van-radio-group>
</template>
</van-field>