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

303 lines
8.6 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-12-27 10:49:14 +08:00
<custom-nav-bar :left="true" title="地块管理">
<template v-slot:right>
<view class="fixed">
<view align="right" class="iconfont icon-jia icon" v-hasPermi="['system:land:add']" @click="onAdd">
</view>
</view>
</template>
</custom-nav-bar>
2024-11-20 18:20:46 +08:00
<!--搜索框-->
2024-12-27 10:49:14 +08:00
<view class="search">
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-28 18:47:34 +08:00
<cxk-dropdown-tree :dataOptions="treeList" labelField="label" valueField="id"
:defaultCheckedKeys="defaultCheckedKeys" @change="handleTreeChange"
style="width: 78%;float: left;margin-right: 2px;"></cxk-dropdown-tree>
<u-checkbox-group style="width: 20%;float: right;" icon-placement="left"
@change="handleChange">
<u-checkbox active-color="#35842E" label="查全部" name="all"></u-checkbox>
</u-checkbox-group>
2024-11-22 10:38:49 +08:00
</uni-forms-item>
2024-11-28 18:47:34 +08:00
2024-11-22 10:38:49 +08:00
</uni-forms>
2024-11-20 18:20:46 +08:00
</view>
2024-11-28 18:47:34 +08:00
<u-gap height="1" bgColor="#F3F3F3"></u-gap>
<view class="list-size">
<view v-show="list.length > 0">地块数量({{ list.length }})</view>
</view>
2024-11-20 18:20:46 +08:00
</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-28 18:47:34 +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">
2024-11-28 18:47:34 +08:00
{{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>
2024-11-28 18:47:34 +08:00
</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 {
2024-12-02 16:49:48 +08:00
isFirst: true,
2024-11-29 10:20:40 +08:00
user: store.state.user.user,
2024-11-21 10:49:27 +08:00
windowHeight: null,
2024-11-28 18:47:34 +08:00
defaultCheckedKeys: "",
2024-11-21 10:49:27 +08:00
paging: null,
2024-11-22 10:38:49 +08:00
form: null,
2024-12-02 16:49:48 +08:00
list: [],
2024-11-28 18:47:34 +08:00
all: false,
2024-11-22 10:38:49 +08:00
treeList: [],
2024-11-28 18:47:34 +08:00
companyGroupId: null,
2024-11-21 10:49:27 +08:00
query: {
2024-11-28 18:47:34 +08:00
companyGroupIds: "",
2024-11-21 10:49:27 +08:00
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;
},
2025-01-06 12:09:04 +08:00
onLoad() {
let companyId = null;
if (getApp().ijs.land) {
companyId = getApp().ijs.land.companyGroup.companyId
}
this.getCompanyTree(companyId);
2024-12-27 10:54:16 +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.getListData();
2024-11-21 10:49:27 +08:00
},
methods: {
2024-11-22 10:38:49 +08:00
/** 查询公司下拉树结构 */
2025-01-06 12:09:04 +08:00
getCompanyTree(companyId) {
2024-11-29 10:20:40 +08:00
const obj = {
status: 0,
delFlag: "0",
companyTypes: [1, 2, 3],
}
2024-11-22 10:38:49 +08:00
store
2024-11-29 10:20:40 +08:00
.dispatch("companyTreeSelect", obj)
2024-11-22 10:38:49 +08:00
.then(res => {
this.treeList = res.data;
2024-11-28 18:47:34 +08:00
if (this.treeList && this.treeList.length) {
2025-01-06 12:09:04 +08:00
if (companyId) {
this.defaultCheckedKeys = companyId + "";
2024-12-02 16:49:48 +08:00
} else {
2024-11-29 10:20:40 +08:00
let companyList = this.treeList[0].children.filter(x => x.id != 100);
if (companyList && companyList.length) {
this.defaultCheckedKeys = companyList[0].id + "";
}
2024-11-22 17:29:55 +08:00
}
}
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-28 18:47:34 +08:00
if (!this.query.companyGroupIds || this.query.companyGroupIds == "" || this.query.companyGroupIds ==
"101") {
2024-11-22 17:29:55 +08:00
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()
})
},
2024-11-28 18:47:34 +08:00
onAdd() {
if (!this.selectCompanyObj) {
2024-11-25 19:32:59 +08:00
plugin.modal.msgError("请选择要添加地块的公司")
return;
}
if (checkPermi(["system:land:add"])) {
uni.navigateTo({
url: "/pages/work/land/create-new?companyObj=" + encodeURIComponent(JSON.stringify(this
.selectCompanyObj))
})
} else {
plugin.modal.msgError("抱歉暂无权限")
}
},
2024-11-21 10:49:27 +08:00
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) {
2024-11-28 18:47:34 +08:00
this.query.companyGroupIds = "";
this.companyGroupId = values;
2024-11-29 10:20:40 +08:00
this.isFirst = false;
2024-11-22 10:38:49 +08:00
this.selectCompanyObj = currentItem;
2024-11-28 18:47:34 +08:00
if (this.all) {
this.getCompanyGroupIds();
}
this.query.companyGroupIds += values;
2024-11-21 10:49:27 +08:00
this.getListData();
2024-11-22 10:38:49 +08:00
},
2024-11-28 18:47:34 +08:00
getCompanyGroupIds() {
if (this.selectCompanyObj && this.selectCompanyObj.childrenKeys) {
this.selectCompanyObj.childrenKeys.forEach(property => {
if (property) {
this.query.companyGroupIds += property + ",";
}
});
}
},
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-28 18:47:34 +08:00
},
handleChange(e) {
this.all = e && e.length ? true : false;
this.query.companyGroupIds = "";
if (this.all) {
this.getCompanyGroupIds();
}
if (this.companyGroupId) {
this.query.companyGroupIds += this.companyGroupId;
}
this.getListData();
2024-11-29 10:20:40 +08:00
},
// 缓存数据
setStorage(type, data) {
uni.setStorageSync(type, {
userId: this.user.userId,
data: data,
});
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;
}
2024-12-02 16:49:48 +08:00
2024-11-28 18:47:34 +08:00
.list-size {
display: flex;
padding: 5px 5px;
background: white;
justify-content: center;
}
2024-11-20 18:20:46 +08:00
.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>