update: 供应商分类

This commit is contained in:
admin 2024-03-17 12:13:48 +08:00
parent 028b83b6a8
commit 6877be2963
4 changed files with 341 additions and 0 deletions

View File

@ -317,6 +317,18 @@
"navigationBarTitleText": "库存卡管理" "navigationBarTitleText": "库存卡管理"
} }
}, },
{
"path": "supplierType",
"style": {
"navigationBarTitleText": "供应商分类管理"
}
},
{
"path": "components/addSupplierType",
"style": {
"navigationBarTitleText": "新增供应商分类"
}
},
{ {
"path": "components/addSupplier", "path": "components/addSupplier",
"style": { "style": {

View File

@ -0,0 +1,180 @@
<template>
<view class="c-card">
<u-form
labelPosition="left"
:model="model1"
:rules="rules"
ref="form"
:labelWidth="100"
:labelStyle="{ padding: '0rpx 10rpx' }"
>
<u-form-item
:prop="`formData[${item.key}]`"
:label="item.name"
:required="item.required"
v-for="(item, index) in formAttrList"
:key="index"
@click="item.fn"
>
<u-textarea
v-if="item.type === 'textarea'"
v-model="(model1.formData as any)[item.key]"
:placeholder="`请输入${item.name}`"
></u-textarea>
<u-input
v-if="item.type === 'select' || item.type === 'input'"
v-model="(model1.formData as any)[item.key]"
:placeholder="`${item.type === 'select' ? '选择' : '输入'}${
item.name
}`"
:clearable="true"
:customStyle="{}"
border="none"
>
<template #suffix>
<text>
{{ item.unit }}
</text>
</template>
</u-input>
<template #right v-if="item.type === 'select'">
<u-icon name="arrow-right"></u-icon>
</template>
</u-form-item>
</u-form>
<block v-for="(item, index) in formAttrList" :key="index">
<u-action-sheet
v-if="item.type === 'select'"
:actions="contrlModalParams[item.childKey].list"
:title="contrlModalParams[item.childKey].title"
:show="contrlModalParams[item.childKey].isShow"
@select="(v: any) => handleSelect(item.childKey, v)"
@close="contrlModalParams[item.childKey].isShow = false"
:closeOnClickAction="true"
></u-action-sheet>
</block>
</view>
<view class="btn-box">
<u-button type="primary" text="保存" @click="save()"></u-button>
</view>
</template>
<script setup lang="ts">
import { StockCardApi, SupplierApi } from "@/services";
import { formatDate } from "@/utils";
import { DeviceType, ImagesType, OrderType, StockCardType } from "@/utils/enum";
import { onLoad } from "@dcloudio/uni-app";
import _ from "underscore";
const model1 = reactive<any>({
formData: {},
});
const rules = ref({
"userInfo.userName": {
type: "string",
required: true,
message: "请输入手机号",
trigger: ["blur", "change"],
},
"userInfo.password": {
type: "string",
required: true,
message: "请输入密码",
trigger: ["blur", "change"],
},
});
const contrlModalParams = reactive<any>({
cardType: {
isShow: false,
title: "标题",
list: [{
id: 1,
name: '出库卡'
},{
id: 2,
name: '入库卡'
}],
}
});
const formAttrList = reactive<any>([
{
name: "供应商分类",
key: "name",
type: "input",
required: true,
},
]);
const handleSelect = (key: string, v: any) => {
contrlModalParams[key].isShow = false;
if (key === "cardType") {
model1.formData.typeName = v.name;
model1.formData.type = v.id;
}
};
const save = () => {
if (model1.formData.id) {
SupplierApi.updateSupplierType(model1.formData).then((res) => {
if (res.code === 200) {
uni.redirectTo({
url: "/pagesApp/supplierType", //
});
}
});
} else {
SupplierApi.addSupplierType(model1.formData).then((res) => {
if (res.code === 200) {
uni.redirectTo({
url: "/pagesApp/supplierType", //
});
}
});
}
};
onLoad((option) => {
//
const title = (option as any).title;
model1.formData = JSON.parse((option as any).item);
if (model1.formData.type === 1) {
model1.formData.typeName = '出库卡'
}else if (model1.formData.type === 2) {
model1.formData.typeName = '入库卡'
}
//
uni.setNavigationBarTitle({
title: title,
});
});
</script>
<style lang="scss" scoped>
.c-card {
background: #ffffff;
// box-shadow: 0rpx 0rpx 10rpx 0rpx rgba(5, 68, 37, 0.12);
border-radius: 13rpx;
margin: 30rpx 25rpx;
padding: 10rpx 20rpx;
::v-deep .u-form-item {
height: auto;
}
::v-deep .u-form-item + .u-form-item {
border-top: 1rpx solid rgba(233, 233, 233, 0.76);
}
}
.btn-box {
margin-top: 60rpx;
display: flex;
background: #ffffff;
box-shadow: 0rpx 0rpx 10rpx 0rpx rgba(0, 56, 93, 0.12);
border-radius: 13rpx 13rpx 0rpx 0rpx;
padding: 25rpx 50rpx;
position: sticky;
bottom: 0rpx;
z-index: 999;
::v-deep button {
border-radius: 43rpx;
}
}
</style>

View File

@ -0,0 +1,140 @@
<template>
<view class="c-card">
<view class="search">
<u-search
placeholder="请输入供应商分类"
v-model="state.name"
:showAction="false"
:bgColor="'#fff'"
:borderColor="'rgba(0, 0, 0, 0.1)'"
:placeholderColor="'#C1C1C1'"
@search="handleSearch()"
></u-search>
<view class="btn" @click="add"> 新增 </view>
</view>
<view class="box">
<view v-for="(item, index) in pageList.list" :key="index">
<view>
<view>{{ item.name }}</view>
</view>
<view class="op-box">
<view class="btn" @click="edit(item)"> 编辑 </view>
<view class="btn" @click="deleteType(item)"> 删除 </view>
</view>
</view>
</view>
</view>
</template>
<script setup lang="ts">
import { StockCardApi, SupplierApi } from "@/services";
import { StockCardType } from "@/utils/enum";
const keyword = ref("");
const state = reactive<any>({
name: "",
});
const pageList: PageResult<StockCard> = reactive({
total: 0,
list: [],
pageNum: 1,
pageSize: 10,
});
const add = () => {
uni.navigateTo({
url: "/pagesApp/components/addSupplierType", //
});
};
const edit = (item: any) => {
uni.navigateTo({
url:
"/pagesApp/components/addSupplierType?title=编辑供应商分类&item=" +
JSON.stringify(item), //
});
};
const deleteType = (item: any) => {
SupplierApi.updateSupplierType({ isDeleted: true, id: item.id }).then((res) => {
if (res.code === 200) {
getList();
}
});
};
const handleSearch = () => {
getList();
};
const getList = () => {
let params: any = {
pageSize: 10,
pageNum: 1,
name: state.name,
};
if (state.supplierTypeId > -1) {
params.supplierTypeId = state.supplierTypeId;
}
SupplierApi.getSupplierTypePage(params).then((res) => {
if (res.code === 200) {
if (res.code === 200) {
(pageList as any).list = (res.data as any).list;
}
}
});
};
onMounted(() => {
getList();
});
</script>
<style lang="scss" scoped>
.c-card {
margin: 30rpx 25rpx;
.search {
display: flex;
align-items: center;
justify-content: space-between;
.btn {
background: #00dcee;
border-radius: 24rpx;
border: 1px solid #00dcee;
font-weight: 500;
font-size: 26rpx;
color: #ffffff;
margin-left: 50rpx;
padding: 6rpx 30rpx;
}
}
.box {
background: #ffffff;
box-shadow: 0rpx 0rpx 10rpx 0rpx rgba(5, 68, 37, 0.12);
border-radius: 13rpx;
padding: 10rpx 25rpx;
font-weight: 400;
font-size: 26rpx;
color: #000000;
line-height: 41rpx;
margin-top: 30rpx;
> view {
display: flex;
align-items: center;
justify-content: space-between;
padding: 20rpx 0rpx;
.op-box {
display: flex;
.btn + .btn {
margin-left: 20rpx;
}
.btn {
background: #ff9d55;
border-radius: 24rpx;
font-weight: 500;
font-size: 26rpx;
color: #ffffff;
padding: 6rpx 30rpx;
}
}
}
> view + view {
border-top: 1px solid rgba(233, 233, 233, 0.76);
}
}
}
</style>

View File

@ -428,6 +428,15 @@ const appList = reactive([
}); });
}, },
}, },
{
icon: "16.png",
title: "供应商分类",
fn: () => {
uni.navigateTo({
url: "/pagesApp/supplierType", //
});
},
},
]); ]);
const tabMenuList = reactive([ const tabMenuList = reactive([