123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172 |
- <template>
- <hc-sys navBarUi="hc-bg-white">
- <template #navBar>
- <hc-nav-back-bar ui="hc-bg-white" title="资料填报"/>
- </template>
- <view class="hc-search-bar">
- <uni-search-bar radius="5" bgColor="#f5f5f5" placeholder="搜索" cancelButton="none" @input="searchInput" @confirm="searchConfirm"/>
- </view>
- <view class="hc-page-body">
- <scroll-view scroll-y class="hc-page-menu">
- <template v-for="item in menuData">
- <view class="hc-page-menu-item"
- @click="menuItemClick(item)"
- :class="item.primaryKeyId === menuItem.primaryKeyId ? 'cur': ''"
- >
- <text :class="item.colorStatus === 2 ? 'text-blue-5':item.colorStatus === 3 ? 'text-orange-5': item.colorStatus === 4 ? 'text-green-5': ''">
- {{ item.title }}【{{ item.submitCounts ?? 0 }}】
- </text>
- </view>
- </template>
- </scroll-view>
- <scroll-view scroll-y class="hc-page-data">
- <template v-for="(item, index) in pageNode">
- <view class="hc-page-data-item"
- @click="pageItemClick(item, index)"
- :class="item.primaryKeyId === pageItem.primaryKeyId ? 'cur': ''"
- >
- <text :class="item.colorStatus === 2 ? 'text-blue-5':item.colorStatus === 3 ? 'text-orange-5': item.colorStatus === 4 ? 'text-green-5': ''">
- {{ item.title }}【{{ item.submitCounts ?? 0 }}】
- </text>
- </view>
- </template>
- </scroll-view>
- </view>
- </hc-sys>
- </template>
- <script setup>
- import {ref, onMounted} from "vue";
- import {useAppStore} from "@/store";
- import wbsApi from '~api/data-fill/wbs';
- import {getObjValue, getArrValue, deepClone} from "js-fast-way"
- import {setStorage, delStorage} from "@/utils/storage";
- const store = useAppStore()
- //初始变量
- const contractInfo = ref(store.contractInfo);
- const projectId = ref(store.projectId);
- const contractId = ref(store.contractId);
- //渲染完成
- onMounted(() => {
- delStorage('dataFill')
- getLoadNode()
- })
- let menuData = ref([]);
- let menuItem = ref({});
- //获取数据
- const getLoadNode = async () => {
- uni.showLoading({title: '获取数据中...', mask: true});
- //获取根节点的数据
- const {error, code, data} = await wbsApi.queryWbsTreeData({
- contractId: contractId.value || '',
- contractIdRelation: '',
- primaryKeyId: '',
- parentId: '',
- classifyType: '',
- tableOwner: contractInfo.value?.contractType ?? ''
- })
- //处理根节点的数据
- const nodeData = getArrValue(data)
- if (!error && code === 200 && nodeData.length > 0) {
- const {contractIdRelation, primaryKeyId, id} = getObjValue(nodeData[0])
- const {item, list} = await getChildNodeData({
- contractIdRelation: contractIdRelation ?? '',
- primaryKeyId: id,
- parentId: contractIdRelation ? primaryKeyId : id
- })
- menuItem.value = item
- menuData.value = list
- await menuItemClick(item)
- uni.hideLoading();
- } else {
- menuItem.value = {}
- menuData.value = []
- uni.hideLoading();
- }
- }
- //左侧菜单被点击
- const pageNodes = ref([])
- const pageNode = ref([])
- const pageItem = ref({})
- const menuItemClick = async (item) => {
- pageNodes.value = []
- pageNode.value = []
- menuItem.value = item
- const {contractIdRelation, primaryKeyId, id} = item
- const {list} = await getChildNodeData({
- contractIdRelation: contractIdRelation ?? '',
- primaryKeyId: id,
- parentId: contractIdRelation ? primaryKeyId : id
- })
- pageNodes.value = list
- pageNode.value = list
- }
- //右侧菜单被点击
- const pageItemClick = (item, index) => {
- setStorage('dataFill', {
- title: menuItem.value.title,
- node: pageNode.value,
- index: index,
- })
- uni.navigateTo({
- url: '/pages/data-fill/treeData'
- });
- }
- //获取子节点的数据
- const getChildNodeData = async (obj) => {
- const {error, code, data} = await wbsApi.queryWbsTreeData({
- ...obj,
- contractId: contractId.value || '',
- classifyType: contractInfo.value?.contractType ?? '',
- tableOwner: contractInfo.value?.contractType ?? ''
- })
- //处理二级节点的数据
- const nodeData = getArrValue(data)
- if (!error && code === 200 && nodeData.length > 0) {
- return {
- item: getObjValue(nodeData[0]),
- list: nodeData
- }
- } else {
- return {item: {}, list: []}
- }
- }
- //搜索
- const searchInput = (value) => {
- querySearch(value)
- }
- const searchConfirm = ({value}) => {
- querySearch(value)
- }
- const querySearch = (value) => {
- const pageNodeRes = deepClone(pageNodes.value)
- const results = value ? pageNodeRes.filter(createFilter(value)) : pageNodeRes
- pageNode.value = deepClone(results)
- }
- const createFilter = (value) => {
- return (item) => {
- return (item.title.toLowerCase().indexOf(value.toLowerCase()) >= 0)
- }
- }
- </script>
- <style lang="scss" scoped>
- page {
- background: #FAFBFE;
- }
- </style>
- <style lang="scss" scoped>
- @import "@/style/data-fill/index.scoped.scss";
- </style>
|