| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153 |
- <template>
- <view class="container">
- <view class="gap"></view>
- <view class="body">
- <!-- 左边区域 -->
- <view class="left">
- <view class="left_item" :class="{ active: active_left === index }" v-for="(item, index) in leftList" :key="index" @click="handleChange(index)">
- {{ item }}
- </view>
- </view>
- <!-- 右边区域 -->
- <view class="right">
- <view class="right_item" :class="{ active: active_right === index }" v-for="(item, index) in rightList" :key="index" @click="handleChange2(index)">
- {{ item.name }}
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- // 左边分类数组当前索引
- active_left: 0,
- // 左边分类数组
- leftList: [],
- // 右边分类数组当前索引
- active_right: null,
- // 右边分类数组
- rightList: [],
- // 当前校区Id
- schoolId: null,
- // 报修物品数组
- articleList: [],
- // 报修物品ID
- articleId: ''
- }
- },
- onLoad(options) {
- this.schoolId = options.schoolId
- // console.log(this.schoolId)
- this.getArticleList()
- },
- methods: {
- // 获取物品类型数组
- async getArticleList() {
- const res = await this.$myRequest_repairs({
- url: '/repairArticleType/queryRepairArticleTypeTree',
- data: {
- schoolId: this.schoolId
- }
- })
- // console.log(res)
- if (res.code == '200') {
- this.articleList = res.data
- this.leftList = this.articleList.map((ele) => ele.name)
- this.rightList = this.articleList[this.active_left].children || []
- }
- },
- // 左边数组切换回调
- handleChange(index) {
- this.active_left = index
- this.active_right = null
- this.rightList = this.articleList[this.active_left].children || []
- },
- // 右边数组切换回调
- handleChange2(index) {
- this.active_right = index
- this.articleId = this.articleList[this.active_left].children[this.active_right].id
- const repairsGoods = this.leftList[this.active_left] + '-' + this.rightList[this.active_right].name
- uni.$emit('addRepairsGoods', {
- data: repairsGoods,
- articleId: this.articleId
- })
- uni.navigateBack(1)
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .container {
- width: 100vw;
- height: 100vh;
- .gap {
- height: 10rpx;
- background-color: #f2f2f2;
- }
- .body {
- display: flex;
- height: calc(100vh - 10rpx);
- .left {
- box-sizing: border-box;
- padding: 15rpx;
- width: 198rpx;
- border-right: 1rpx solid #ccc;
- overflow-y: auto;
- .left_item {
- width: 100%;
- height: 80rpx;
- line-height: 80rpx;
- text-align: center;
- font-size: 28rpx;
- overflow: hidden;
- white-space: nowrap;
- text-overflow: ellipsis;
- }
- .active {
- color: #6fb6b8;
- }
- }
- .right {
- box-sizing: border-box;
- padding: 30rpx 40rpx;
- width: 552rpx;
- overflow-y: auto;
- .right_item {
- float: left;
- box-sizing: border-box;
- padding: 10rpx 30rpx;
- margin: 0 32rpx 37rpx 0;
- height: 50rpx;
- line-height: 30rpx;
- text-align: center;
- color: #808080;
- font-size: 28rpx;
- border-radius: 53rpx;
- background-color: #e6e6e6;
- overflow: hidden;
- white-space: nowrap;
- text-overflow: ellipsis;
- }
- .active {
- color: #fff;
- background-color: #6fb6b8;
- }
- }
- }
- }
- </style>
|