jsy-app/pages/work/land/index.vue

226 lines
6.4 KiB
Vue
Raw Normal View History

2024-11-20 18:20:46 +08:00
<template>
<view class="index-container" :style="{ height: `${windowHeight}px` }" @touchmove.stop.prevent="() => {}">
<z-paging ref="paging" use-virtual-list @query="getListData" bg-color="#F3F3F3" :loading-more-enabled="false">
<template #top>
<!--搜索框-->
2024-11-22 10:38:49 +08:00
<view class="search" style="margin-top: 30px;">
2024-11-20 18:20:46 +08:00
<u-search placeholder="请输入地块名称/编号" @search="onSearchValue" @custom="onSearchValue"
@clear="onSearchValue(null)" shape="square"></u-search>
2024-11-22 10:38:49 +08:00
<uni-forms ref="form" :model="form" labelWidth="0px" style="margin-top: 5px;">
<uni-forms-item label="" name="">
2024-11-22 17:29:55 +08:00
<cxk-dropdown-tree :dataOptions="treeList" labelField="label" valueField="id" :defaultCheckedKeys="defaultCheckedKeys"
2024-11-22 10:38:49 +08:00
@change="handleTreeChange"></cxk-dropdown-tree>
</uni-forms-item>
</uni-forms>
2024-11-20 18:20:46 +08:00
</view>
</template>
<template #cell="{ item }">
2024-11-22 11:18:50 +08:00
<view class="item-container">
2024-11-20 18:20:46 +08:00
<view style="display: flex; align-items: center; justify-content: space-between;">
<view class="flex-text" style="margin: 15px;">
<view class="flex-text-one" style="color: black;">地块编号</view>
<view>{{item.landNum}}</view>
</view>
<view style="margin-right: 10px;">
<u-tag text="启用" type="success" v-if="item.status == 0" plain plainFill></u-tag>
<u-tag text="禁用" type="error" v-if="item.status == 1" plain plainFill></u-tag>
</view>
2024-11-22 10:38:49 +08:00
<view style="margin-right: 5px;" v-hasPermi="['system:land:edit']">
2024-11-22 11:18:50 +08:00
<u-button text="编辑" type="primary" plain plainFill @click="edit(item)"></u-button>
2024-11-22 10:38:49 +08:00
</view>
2024-11-20 18:20:46 +08:00
</view>
<u-gap height="1" bgColor="#D2D2D2"></u-gap>
2024-11-22 18:24:42 +08:00
<view style="display: flex;justify-content: space-between;align-items: center;" @click="onItemClick(item)">
2024-11-20 18:20:46 +08:00
<view class="data">
<view class="flex-text global-font-size-1">
<view class="flex-text-one">地块名称</view>
<view>{{item.landName}}</view>
</view>
2024-11-21 10:49:27 +08:00
<view class="flex-text global-font-size-1">
<view class="flex-text-one">地块面积</view>
<view>{{item.landArea}}</view>
</view>
2024-11-20 18:20:46 +08:00
<view class="flex-text global-font-size-1" style="margin-top: 5px;">
<view class="flex-text-one">负责人</view>
2024-11-22 10:38:49 +08:00
<view v-if="item.user && item.user.userName">{{item.user.userName}}</view>
2024-11-20 18:20:46 +08:00
</view>
2024-11-22 10:38:49 +08:00
<!-- <view class="flex-text global-font-size-1" style="margin-top: 5px;">
2024-11-20 18:20:46 +08:00
<view class="flex-text-one">手机号码</view>
2024-11-22 10:38:49 +08:00
<view v-if="item.user && item.user.mobilePhone">{{item.user.mobilePhone}}</view>
</view> -->
2024-11-21 10:49:27 +08:00
<view class="flex-text global-font-size-1" style="margin-top: 5px;">
<view class="flex-text-one">所属公司</view>
2024-11-22 11:18:50 +08:00
<view v-if="item.companyGroup && item.companyGroup.companyFullName">
{{item.companyGroup.companyFullName}}</view>
2024-11-20 18:20:46 +08:00
</view>
</view>
2024-11-22 18:24:42 +08:00
<view>
<view v-hasPermi="['land:land:query']" style="margin-right: 10px;">
<u-icon name="arrow-right"></u-icon>
</view>
</view>
2024-11-20 18:20:46 +08:00
</view>
</view>
</template>
</z-paging>
</view>
</template>
2024-11-21 10:49:27 +08:00
<script>
2024-11-20 18:20:46 +08:00
import {
checkPermi
} from "@/utils/permission"
import store from "@/store"
import plugin from "@/plugins"
2024-11-21 10:49:27 +08:00
export default {
data() {
return {
windowHeight: null,
2024-11-22 17:29:55 +08:00
defaultCheckedKeys:"",
2024-11-21 10:49:27 +08:00
paging: null,
2024-11-22 10:38:49 +08:00
form: null,
treeList: [],
2024-11-21 10:49:27 +08:00
query: {
companyId: null,
landName: null
2024-11-22 10:38:49 +08:00
},
2024-11-22 11:18:50 +08:00
selectCompanyObj: {}
2024-11-21 10:49:27 +08:00
}
},
created() {
this.windowHeight = uni.getSystemInfoSync().windowHeight;
2024-11-22 11:18:50 +08:00
2024-11-21 10:49:27 +08:00
},
onShow() {
if (this.paging != null) {
this.$refs.paging.reload()
}
2024-11-22 10:38:49 +08:00
this.getCompanyTree();
this.getListData();
2024-11-21 10:49:27 +08:00
},
onNavigationBarButtonTap(e) {
//如果点击了添加地块
if (e.index == 0) {
2024-11-22 11:18:50 +08:00
if (!this.query.companyId) {
2024-11-22 10:38:49 +08:00
plugin.modal.msgError("请选择要添加地块的公司")
return;
}
2024-11-21 10:49:27 +08:00
if (checkPermi(["system:land:add"])) {
uni.navigateTo({
2024-11-22 11:18:50 +08:00
url: "/pages/work/land/create-new?companyObj=" + encodeURIComponent(JSON.stringify(this
.selectCompanyObj))
2024-11-21 10:49:27 +08:00
})
} else {
plugin.modal.msgError("抱歉暂无权限")
}
}
},
methods: {
2024-11-22 10:38:49 +08:00
/** 查询公司下拉树结构 */
getCompanyTree() {
store
.dispatch("companyTreeSelect", null)
.then(res => {
this.treeList = res.data;
2024-11-22 17:29:55 +08:00
if(this.treeList && this.treeList.length){
let companyList= this.treeList[0].children.filter(x=>x.id!=100);
if(companyList && companyList.length){
this.defaultCheckedKeys = companyList[0].id+"";
}
}
2024-11-22 10:38:49 +08:00
})
.catch(error => {
plugin.modal.msgError(error)
})
.finally(() => {
plugin.modal.closeLoading()
})
},
2024-11-21 10:49:27 +08:00
getListData() {
if (!checkPermi(["system:land:list"])) {
plugin.modal.msgError("抱歉暂无权限")
return
}
2024-11-22 17:29:55 +08:00
if(!this.query.companyId){
return;
}
2024-11-21 10:49:27 +08:00
plugin.modal.loading("获取地块列表...")
if (this.query.landName == null || this.query.landName == "") {
delete this.query["landName"]
}
store
.dispatch("getLandList", this.query)
.then(res => {
this.list = res.data;
this.$refs.paging.complete(this.list)
})
.catch(error => {
plugin.modal.msgError(error)
})
.finally(() => {
plugin.modal.closeLoading()
})
},
onItemClick(item) {
2024-11-20 18:20:46 +08:00
uni.navigateTo({
2024-11-21 10:49:27 +08:00
url: "/pages/work/land/index-detail?item=" + encodeURIComponent(JSON.stringify(item))
2024-11-20 18:20:46 +08:00
})
2024-11-21 10:49:27 +08:00
},
onSearchValue(e) {
2024-11-22 10:38:49 +08:00
this.query.landName = e;
this.getListData();
},
handleTreeChange(values, currentItem) {
this.query.companyId = values;
this.selectCompanyObj = currentItem;
2024-11-21 10:49:27 +08:00
this.getListData();
2024-11-22 10:38:49 +08:00
},
2024-11-22 11:18:50 +08:00
edit(item) {
2024-11-22 10:38:49 +08:00
if (checkPermi(["system:land:edit"])) {
uni.navigateTo({
url: "/pages/work/land/create-new?item=" + encodeURIComponent(JSON.stringify(item))
})
} else {
plugin.modal.msgError("抱歉暂无权限")
}
2024-11-20 18:20:46 +08:00
}
2024-11-22 10:38:49 +08:00
}
2024-11-20 18:20:46 +08:00
}
</script>
<style lang="scss">
.index-container {
height: 100%;
background-color: #f3f3f3;
.list {
margin: 0px 10px;
}
.search {
background-color: white;
padding: 10px;
}
.item-container {
margin: 10px 10px;
background-color: white;
padding-bottom: 10px;
border-radius: 10px;
box-shadow: 1px 1px 2px 2px rgba(0, 0, 0, 0.05);
}
.flex-text {
display: flex;
align-items: center;
.flex-text-one {
color: #939393;
font-weight: bold;
}
}
.data {
margin: 10px 20px;
}
}
</style>