瀏覽代碼

仓库模块

asd26269546 2 年之前
父節點
當前提交
e51b15efba

+ 7 - 0
src/assets/css/index.scss

@@ -37,4 +37,11 @@ ul,li{
     top: 20px;
     background: #0084ff;
     border-radius: 2px 2px 2px 2px;
+}
+
+.van-toast{
+    background-color: rgba(0, 0, 0, .7)!important;
+    width:120px!important;
+    height: 120px!important;
+    box-sizing: border-box!important;
 }

+ 57 - 0
src/components/common-list.vue

@@ -0,0 +1,57 @@
+<template>
+    <div class="common-list">
+        <ul>
+            <li v-for="i in data" :key="i.id" @click="listCk(i)">
+                <!-- <div class="left-box">
+                    <van-icon name="location-o" />
+                </div> -->
+                <div class="center-content">
+                    <div v-for="j in config" :key="j.prop"><span>{{ j.label }}:</span>{{ i[j.prop] }}</div>
+                </div>
+                <div class="more-box">
+                    <van-icon name="arrow" />
+                </div>
+            </li>
+        </ul>
+    </div>
+</template>
+<script setup>
+import { ref, getCurrentInstance, onMounted,defineProps } from 'vue'
+const proxy = getCurrentInstance().proxy
+defineProps({
+    data: {
+        type: Array,
+        default: []
+    },
+    config: {
+        type: Object,
+        default: []
+    }
+})
+
+const listCk = (item) => {
+    proxy.$emit('onClick', item)
+}
+</script>
+<style lang="scss">
+.common-list{
+    ul{
+        li{
+            list-style: none;
+            position: relative;
+            display: flex;
+            box-sizing: border-box;
+            align-items: center;
+            justify-content: space-between;
+            padding: 16px;
+            background: #fff;
+            .center-content{
+                flex: 1;
+            }
+            .left-box{
+
+            }
+        }
+    }
+}
+</style>

+ 11 - 0
src/router/index.js

@@ -36,6 +36,17 @@ const routes = [{
 				component: () => import('../views/equipment/warpKnitting.vue')
 			},
 
+			//仓库模块
+			{
+				path: 'warehouseConfig',
+				name: '仓库维护',
+				component: () => import('../views/warehouse/warehouseConfig/index.vue')
+			},
+			{
+				path: 'warehouseConfigAdd',
+				name: '仓库新增',
+				component: () => import('../views/warehouse/warehouseConfig/add.vue')
+			},
 		]
 	},
 	{

+ 4 - 1
src/utils/axios.js

@@ -7,7 +7,7 @@ import { showLoadingToast, closeToast } from 'vant';
 import { getToken } from '@/utils/auth'
 // 是否显示重新登录
 export let isRelogin = { show: false };
-
+import 'vant/lib/index.css'
 axios.defaults.headers['Content-Type'] = 'application/json;charset=utf-8'
 // 创建axios实例
 const service = axios.create({
@@ -159,6 +159,9 @@ export function post(url, data = {}, method = 'post',headers = {}) {
       console.log(res)
       closeToast()
       resolve(res);
+    }).catch(err => {
+      reject(err)
+      closeToast()
     })
   })
 }

+ 7 - 0
src/views/AboutView.vue

@@ -67,7 +67,9 @@
 </template>
 
 <script setup>
+import { showLoadingToast, closeToast } from 'vant';
 import { ref } from 'vue'
+
 const showPicker = ref(false)
 const username = ref('')
 const password = ref('')
@@ -85,5 +87,10 @@ const columns = ref([
       result.value = selectedOptions[0]?.text;
       showPicker.value = false;
     };
+	showLoadingToast({
+        message: '加载中...',
+        forbidClick: true,
+        duration: 0,
+      });
 // @ is an alias to /src
 </script>

+ 1 - 0
src/views/main.vue

@@ -20,6 +20,7 @@
 <script setup>
 import { ref, getCurrentInstance } from 'vue'
 import '../assets/icon/iconfont.css'
+import 'vant/lib/index.css';
 import axios from 'axios'
 const proxy = getCurrentInstance().proxy
 const tabType = ref('home')

+ 110 - 0
src/views/warehouse/warehouseConfig/add.vue

@@ -0,0 +1,110 @@
+<template>
+	<div class="form">
+        <van-nav-bar
+            title="仓库维护"
+            left-text="返回"
+            left-arrow
+            @click-left="onClickLeft"
+
+        >
+        </van-nav-bar>
+		<van-form @submit="onSubmit" label-align="top" style="margin-top:20px">
+			<van-cell-group inset>
+				<van-field
+                    v-model="formData.typeName"
+                    is-link
+                    readonly
+                    label="仓库类型"
+                    placeholder="选择仓库类型"
+                    @click="typeModal = true"
+                    :rules="[{ required: true, message: '仓库类型不能为空' }]"
+                    required
+                />
+                <van-popup v-model:show="typeModal" round position="bottom">
+                    <van-picker
+                        :columns="columns"
+                        @cancel="typeModal = false"
+                        @confirm="onConfirm"
+                    />
+                </van-popup>
+				<van-field
+					v-model="formData.name"
+					name="仓库名称"
+					label="仓库名称"
+					placeholder="请填写仓库名称"
+					:rules="[{ required: true, message: '仓库名称不能为空' }]"
+                    required
+				/>
+                <van-field
+					v-model="formData.remark"
+					rows="3"
+                    type="textarea"
+					name="备注"
+					label="备注"
+					placeholder="请填写备注"
+				/>
+            </van-cell-group>
+			<div style="margin: 16px">
+				<van-button round block type="primary" native-type="submit">
+					提交
+				</van-button>
+			</div>
+		</van-form>
+	</div>
+</template>
+
+<script setup>
+import { ref,getCurrentInstance,onMounted } from 'vue'
+import { showSuccessToast, showFailToast } from 'vant';
+import { useRoute } from 'vue-router'
+
+const proxy = getCurrentInstance().proxy
+const route = useRoute()
+const showPicker = ref(false)
+const typeModal = ref(false)
+const formData = ref({
+    name:null,
+    type:null,
+    typeName:null,
+    remark:null,
+
+})
+
+const getDict = () => {
+    proxy.get('/system/dict/data/list?pageNum=1&pageSize=10&dictType=warehouse_type').then(res => {
+        columns.value = res.rows.map(item => {
+            return {
+                text: item.dictLabel,
+                value: item.dictValue
+            }
+        })
+        formData.value.typeName = columns.value.find(item => item.value == formData.value.type).text
+    })
+}
+
+const columns = ref([])
+
+const onConfirm = ({ selectedOptions }) => {
+    formData.value.type = selectedOptions[0].value
+    formData.value.typeName = selectedOptions[0].text
+    typeModal.value = false
+}
+
+const onClickLeft = () => history.back();
+
+
+const onSubmit = () => {
+    proxy.post('/warehouse/' + (!route.query.id ? 'add' : 'edit'), formData.value).then(res => {
+        setTimeout(() => {
+            showSuccessToast(!route.query.id ? '添加成功' : '编辑成功')
+            proxy.$router.push('/main/warehouseConfig')
+        }, 500);
+    })
+}
+onMounted(() => {
+    formData.value = route.query
+    
+    getDict()
+})
+
+</script>

+ 101 - 0
src/views/warehouse/warehouseConfig/index.vue

@@ -0,0 +1,101 @@
+<template>
+	<van-nav-bar
+		title="仓库维护"
+		left-text="返回"
+		left-arrow
+		@click-left="onClickLeft"
+		@click-right="onClickRight"
+	>
+		<template #right>
+			<van-icon name="plus" />
+		</template>
+	</van-nav-bar>
+	<van-pull-refresh v-model="loading" @refresh="onRefresh" >
+		<van-search v-model="req.keyword"  placeholder="请输入搜索关键词" @search="onRefresh" />
+		<div class="list">
+			<van-list
+				v-model:loading="loading"
+				:finished="finished"
+				finished-text="没有更多了"
+				@load="onLoad"
+				style="margin-bottom:60px"
+			>
+				<commonList :data="listData" @onClick="toDtl" :config="listConfig"></commonList>
+			</van-list>
+		</div>
+	</van-pull-refresh>
+</template>
+<script setup>
+import { ref, getCurrentInstance, onMounted } from 'vue'
+import commonList from '@/components/common-list.vue'
+import { useRoute } from 'vue-router'
+const loading = ref(false)
+const router = useRoute()
+const req = ref({
+	pageNum:1,
+	keyword:null
+})
+const finished = ref(false);
+const proxy = getCurrentInstance().proxy
+const listData = ref([])
+
+
+const listConfig = ref([
+	{
+		label: '仓库名称',
+		prop: 'name',
+	},
+	{
+		label: '仓库类型',
+		prop: 'type',
+	}
+])
+const onRefresh = () => {
+	req.value.pageNum = 1
+	finished.value = false
+	getList('refresh')
+}
+const onLoad = () => {
+    getList()
+}
+
+const onClickLeft = () => proxy.$router.push('/main/working')
+
+const onClickRight = () => {
+	proxy.$router.push('/main/warehouseConfigAdd')
+}
+
+const toDtl = (row) => {
+	console.log(row)
+	proxy.$router.push({
+        path: 'warehouseConfigAdd',
+		query: row
+      })
+}
+
+const getList = (type) => {
+	loading.value = true
+	proxy.post('/warehouse/page',req.value).then(res => {	
+		
+		console.log(req.value)
+		listData.value = type === 'refresh' ? res.data.rows : listData.value.concat(res.data.rows)
+		if(req.value.pageNum * 10 >= res.data.total) {
+			finished.value = true
+		}
+		req.value.pageNum++	
+		loading.value = false
+		
+		
+		
+	}).catch(err => {
+		loading.value = false
+	})
+}
+getList()
+</script>
+
+<style lang="scss" scoped>
+.list {
+	min-height: 70vh;
+}
+</style>