200 lines
4.9 KiB
Vue
200 lines
4.9 KiB
Vue
<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="collapse-box box">
|
|
<view v-for="(item, index) in pageList.list" :key="index">
|
|
<view class="item">
|
|
<view>
|
|
<view>{{ item.shmCategoryName }}</view>
|
|
</view>
|
|
<view class="op-box">
|
|
<view style="display: flex" @click="edit(item)">
|
|
<up-icon name="edit-pen" color="#909399"></up-icon>
|
|
</view>
|
|
<view
|
|
class="ml-20"
|
|
style="display: flex"
|
|
@click="handleModal(true, item.id)"
|
|
v-if="!item.childrenList"
|
|
>
|
|
<up-icon name="trash" color="#909399"></up-icon>
|
|
</view>
|
|
<view class="ml-20" style="display: flex"
|
|
><up-icon
|
|
:name="item.show ? 'arrow-up' : 'arrow-down'"
|
|
color="#909399"
|
|
@click="item.show = !item.show"
|
|
></up-icon
|
|
></view>
|
|
</view>
|
|
</view>
|
|
|
|
<view class="box" v-if="item.show">
|
|
<view
|
|
v-for="(cItem, index) in item.childrenList"
|
|
:key="index"
|
|
class="item"
|
|
>
|
|
<view>
|
|
<view>{{ cItem.shmCategoryName }}</view>
|
|
</view>
|
|
<view class="op-box">
|
|
<view class="btn" @click="edit(cItem)"> 编辑 </view>
|
|
<view class="btn" @click="handleModal(true, cItem.id)"> 删除 </view>
|
|
</view>
|
|
</view>
|
|
<view class="no-data" v-if="!item.childrenList">暂无数据</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
<SmallModal
|
|
:title="'确认删除吗?'"
|
|
:content="'确认删除后,不能恢复!'"
|
|
:okText="'确认删除'"
|
|
:isMain="true"
|
|
:show="isShowCancelModal"
|
|
@handleModal="(v:boolean) => {handleModal(v, deleteId)}"
|
|
@handleOk="handleOk()"
|
|
/>
|
|
</template>
|
|
<script setup lang="ts">
|
|
import { GoodsApi } from "@/services";
|
|
import SmallModal from "@/components/Modal/smallModal.vue";
|
|
const isShowCancelModal = ref(false);
|
|
const deleteId = ref(0);
|
|
const handleModal = (v: boolean, id: number) => {
|
|
isShowCancelModal.value = v;
|
|
deleteId.value = id;
|
|
};
|
|
const handleOk = () => {
|
|
deleteType({id: deleteId.value})
|
|
};
|
|
|
|
const pageList: PageResult<{
|
|
shmCategoryName: string;
|
|
id: number;
|
|
childrenList: any;
|
|
show?: boolean;
|
|
}> = reactive({
|
|
isLoading: false,
|
|
noMoreData: false,
|
|
total: 0,
|
|
list: [],
|
|
pageNum: 1,
|
|
pageSize: 10,
|
|
});
|
|
const resetPageList = () => {
|
|
pageList.noMoreData = false;
|
|
pageList.total = 0;
|
|
pageList.list = [];
|
|
pageList.pageNum = 1;
|
|
pageList.pageSize = 10;
|
|
};
|
|
const add = () => {
|
|
uni.navigateTo({
|
|
url: "/pagesApp/components/addShipmentType", // 要跳转到的页面路径
|
|
});
|
|
};
|
|
const edit = (item: any) => {
|
|
uni.navigateTo({
|
|
url:
|
|
"/pagesApp/components/addShipmentType?title=编辑出货分类&item=" +
|
|
JSON.stringify(item), // 要跳转到的页面路径
|
|
});
|
|
};
|
|
const deleteType = (item: any) => {
|
|
GoodsApi.deleteById({ id: item.id }).then((res) => {
|
|
if (res.code === 200) {
|
|
getList();
|
|
}
|
|
});
|
|
};
|
|
|
|
const getList = (v?: boolean) => {
|
|
GoodsApi.getShipmentCategory().then((res) => {
|
|
if (res.code === 200) {
|
|
(pageList as any).list = res.data;
|
|
}
|
|
});
|
|
};
|
|
|
|
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;
|
|
}
|
|
}
|
|
.collapse-box {
|
|
margin-top: 30rpx;
|
|
}
|
|
.box {
|
|
background: #ffffff;
|
|
box-shadow: 0rpx 0rpx 10rpx 0rpx rgba(5, 68, 37, 0.12);
|
|
border-radius: 13rpx;
|
|
padding: 0rpx 20rpx;
|
|
font-weight: 400;
|
|
font-size: 26rpx;
|
|
color: #000000;
|
|
line-height: 41rpx;
|
|
.item {
|
|
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);
|
|
}
|
|
.no-data {
|
|
color: #606266;
|
|
font-size: 12px;
|
|
text-align: center;
|
|
padding: 20rpx;
|
|
}
|
|
}
|
|
}
|
|
</style>
|