feat:部门选择

This commit is contained in:
houjunxiang
2025-11-26 18:11:13 +08:00
parent 96cc747150
commit fcc04865f9
15 changed files with 344 additions and 83 deletions

View File

@@ -57,7 +57,7 @@ const goTo = url => {
}
// 生命周期
onMounted(() => {})
// 动态设置 grid 列数
const { gridCol } = useGridCol([400], [2, 3])
</script>

View File

@@ -96,7 +96,6 @@ import SampleDetailPopup from '@/components/sample/sample-detail-popup.vue'
import TaskItem from './components/task-item.vue'
import nx from '@/nx'
import { useListData } from '@/nx/hooks/usePageListData'
import { getDataSourceTypeShow } from '../common'
// 响应式数据
const scrollTop = ref(0)
@@ -136,7 +135,8 @@ const showSampleDetail = (id, index) => {
}
const searchParams = computed(() => ({
taskAssignStatus: 'submitted',
taskAssayStatus: 'submitted'
taskAssayStatus: 'submitted',
assayOperator: userInfo.value.nickname
}))
const { listData, scrollToLower, loadStatus, getInitData } = useListData({

View File

@@ -214,8 +214,8 @@ const getAssayTask = async () => {
rollbackContent.value = ''
const param = {
taskAssignStatus: 'submitted',
taskAssayStatusList: ['not_start', 'saved']
// assayOper: userInfo.value.nickname
taskAssayStatusList: ['not_start', 'saved'],
assayOperator: userInfo.value.nickname
}
const res = await nx.$api.assayTask.getAssayTaskList(param)
if (res) {

View File

@@ -7,6 +7,7 @@
</up-grid-item>
</up-grid>
</view>
<company-dept-dialog />
</template>
<script setup>
import { reactive, ref, computed, onMounted } from 'vue'
@@ -23,7 +24,9 @@ function goSystem(url) {
uni.setStorageSync('defaultModule', url)
uni.reLaunch({ url })
}
onMounted(async () => {
await nx.$api.assayTask.getAssayTaskPage()
})
const { gridCol } = useGridCol([400, 600], [2, 3, 4])
</script>

View File

@@ -1,14 +1,19 @@
<template>
<u-popup :show="show" mode="right" @close="close" @open="open" closeable>
<view style="width: 50vw" class="p20">
<view class="p20 cell-content">
<scroll-view scroll-y="true">
<view class="x-f pb20 pt20">
<u-avatar src=""></u-avatar>
<view class="pl20">您好{{ userInfo.nickname }}</view>
<view>
<view class="pl20">您好{{ userInfo.nickname }}</view>
<view class="pl20">{{ deptName }}</view>
</view>
</view>
<u-cell-group>
<u-cell icon="grid-fill" title="公司部门选择" :is-link="true" @click="handleSelectCompany" />
<u-cell icon="grid-fill" title="模块选择" :is-link="true" @click="handleTo('/pages/index/index')" />
<u-cell icon="order" title="打印设置" :isLink="true" @click="handleTo('/pages/setting/print')"></u-cell>
<u-cell icon="info-circle-fill" title="关于我们" :is-link="true" @click="handleTo('/pages/me/aboutMe')" />
</u-cell-group>
@@ -28,11 +33,14 @@
@cancel="modalShow = false"
/>
</u-popup>
<company-dept-dialog />
</template>
<script setup>
import { ref, computed } from 'vue'
import { ref, computed, onMounted } from 'vue'
import { storeToRefs } from 'pinia'
import nx from '@/nx'
import { VISIT_COMPANY_STORAGE_KEY, VISIT_DEPT_STORAGE_KEY } from '@/nx/config'
// Props & Emits
const props = defineProps({
@@ -46,15 +54,40 @@ const emit = defineEmits(['update:show', 'open', 'close'])
// 响应式数据
const modalShow = ref(false)
const dialogStore = nx.$store('company-dept')
const { companyList, selectedCompanyId, selectedDeptId } = storeToRefs(dialogStore)
// 计算属性
const userInfo = computed(() => nx.$store('user').userInfo)
const deptName = computed(() => {
const selectedCompany = companyList.value.find(company => company.companyId === selectedCompanyId.value)
const selectedDept = selectedCompany?.depts.find(dept => dept.deptId === selectedDeptId.value)
return selectedDept?.deptName || ''
})
// 方法
const handleTo = url => {
nx.$router.go(url)
}
const handleSelectCompany = () => {
dialogStore.open({
companyList: companyList.value,
defaultCompanyId: selectedCompanyId.value,
defaultDeptId: selectedDeptId.value,
onConfirm: ({ companyId, deptId }) => {
const selectedCompany = companyList.value.find(company => company.companyId === selectedCompanyId.value)
const selectedDept = selectedCompany?.depts.find(dept => dept.deptId === selectedDeptId.value)
uni.setStorageSync(VISIT_COMPANY_STORAGE_KEY, {
id: companyId,
name: selectedCompany?.companyName || ''
})
uni.setStorageSync(VISIT_DEPT_STORAGE_KEY, {
id: deptId,
name: selectedDept?.deptName || ''
})
}
})
}
const handleLoginOut = () => {
modalShow.value = true
}
@@ -77,6 +110,18 @@ const close = () => {
emit('close')
emit('update:show', false)
}
onMounted(async () => {
await nx.$api.assayTask.getAssayTaskPage()
})
</script>
<style lang="scss" scoped></style>
<style lang="scss" scoped>
.cell-content {
width: 50vw;
}
@media (max-width: 700px) {
.cell-content {
width: 70vw;
}
}
</style>

View File

@@ -1,6 +1,6 @@
<template>
<view class="container">
<view class="x-f pb20 pt20">
<!-- <view class="x-f pb20 pt20">
<u-avatar src=""></u-avatar> <view class="user-name"><span>您好</span>{{ userInfo.realname }}</view>
</view>
<u-cell-group>
@@ -9,7 +9,7 @@
<u-cell icon="info-circle-fill" title="关于我们" :isLink="true" @click="handleTo('/pages/me/aboutMe')"></u-cell>
</u-cell-group>
<u-button class="mt40" type="warning" :plain="true" text="退出当前账号" @click="handleLoginOut"></u-button>
<my-tabBar :currentTab="1" />
<my-tabBar :currentTab="1" /> -->
</view>
</template>
<script setup>

View File

@@ -28,13 +28,17 @@
<view
>样品名称<text class="black">{{ item.sampleName }}</text></view
>
<view>调拨人<text class="black">{{}}</text></view>
<view
>调拨人<text class="black">{{ item.borrowUser }}</text></view
>
</view>
<view class="x-bc">
<view
>样品编号<text class="black">{{ item.sampleReturnCode }}</text></view
>
<view>调拨时间<text class="black">{{}}</text></view>
<view
>调拨时间<text class="black">{{ nx.$dayjs(item.borrowTime).format('YYYY-MM-DD HH:mm:ss') }}</text></view
>
</view>
<view class="mt4"
>归库编码<text class="black">{{ item.sampleReturnCode }}</text></view
@@ -89,25 +93,17 @@ onShow(() => {
async function getSampleList() {
if (sampleCode.value === '') return
let params = {
pageSize: 999,
pageNo: 1,
returnStatus: 'completed',
dispatchStatus: '1',
sampleReturnCode: sampleCode.value
}
const { list } = await nx.$api.sampleWarehouse.queryReturnToStockSample(params)
if (list.length === 0) {
return uni.showToast({ title: '未查询到该样品信息', icon: 'none' })
}
const existingCodes = new Set(sampleList.value.map(item => item.id)) // 假设唯一标识是 `code`
const newItems = list.filter(item => !existingCodes.has(item.id))
const data = await nx.$api.sampleWarehouse.searchBySampleCode(params)
if (newItems.length === 0) {
const existingCodes = new Set(sampleList.value.map(item => item.id))
if (existingCodes.has(data.id)) {
return uni.showToast({ title: '该样品已存在,无需重复添加', icon: 'none' })
}
sampleList.value.push(...newItems)
sampleList.value.push(data)
}
async function handleSubmit() {
if (givebackUserId.value === '') {
@@ -117,12 +113,14 @@ async function handleSubmit() {
})
}
btnLoading.value = true
const givebackUser = range.value.find(item => item.value === givebackUserId.value)?.nickname
const givebackUser = range.value.find(item => item.value === givebackUserId.value)?.text
await nx.$api.sampleWarehouse
.execSampleDispatch({
detailIds: sampleList.value.map(item => item.id),
.execGiveback({
detailIds: sampleList.value.map(item => item.id).join(','),
givebackUserId: givebackUserId.value,
givebackUser
givebackUser,
warehouseUser: userInfo.value.nickname,
warehouseUserId: userInfo.value.id
})
.finally(() => {
btnLoading.value = false