feat:样品库管理

This commit is contained in:
houjunxiang
2025-11-21 17:56:33 +08:00
parent 7ee3df9ab9
commit 753766893b
24 changed files with 818 additions and 218 deletions

View File

@@ -12,13 +12,16 @@ onLaunch(async () => {
// #ifdef APP-PLUS // #ifdef APP-PLUS
let sysInfo = uni.getSystemInfoSync() let sysInfo = uni.getSystemInfoSync()
let brand = sysInfo.brand.toLowerCase() let brand = sysInfo.brand.toLowerCase()
if (brand === 'chainway') {
if (brand === 'huawei') {
plus.screen.lockOrientation('landscape') plus.screen.lockOrientation('landscape')
} }
if (brand === 'urovo') {
urovo.scanRegister(data => { urovo.scanRegister(data => {
console.log('优博讯扫码结果:' + data) console.log('优博讯扫码结果:' + data)
$store('biz').scanQRInfo = data $store('biz').scanQRInfo = data
}) })
}
// #endif // #endif
}) })

View File

@@ -70,7 +70,7 @@ const open = () => {
justify-content: space-between; justify-content: space-between;
margin-bottom: 10px; margin-bottom: 10px;
border-bottom: 1px solid #eee; border-bottom: 1px solid #eee;
padding: 4px 0; padding: 8px 0;
} }
.label-my { .label-my {
color: #606266; color: #606266;
@@ -80,7 +80,8 @@ const open = () => {
text-align: center; text-align: center;
font-size: 18px; font-size: 18px;
font-weight: 400; font-weight: 400;
padding: 10px; padding: 20px;
padding-top: 35px;
background-color: $uni-color-primary; background-color: $uni-color-primary;
color: #fff; color: #fff;
} }

View File

@@ -1,8 +1,8 @@
// 在此不用配置接口前缀 // 在此不用配置接口前缀
const isDev = process.env.NODE_ENV === 'development' const isDev = process.env.NODE_ENV === 'development'
// const BaseUrl = isDev ? 'http://192.168.26.116:888/admin-api' : 'http://192.168.26.116:888/admin-api' const BaseUrl = isDev ? 'http://192.168.26.116:888/admin-api' : 'http://192.168.26.116:888/admin-api'
const BaseUrl = isDev ? 'http://192.168.26.190:48080/admin-api' : 'http://192.168.26.116:888/admin-api' // const BaseUrl = isDev ? 'http://192.168.26.163:48080/admin-api' : 'http://192.168.26.116:888/admin-api'
//
// const BaseUrl = isDev ? 'http://localhost:9999' : '' // const BaseUrl = isDev ? 'http://localhost:9999' : ''
const upgradeBaseUrl = 'http://192.168.26.116:888' const upgradeBaseUrl = 'http://192.168.26.116:888'

View File

@@ -11,7 +11,7 @@ export default {
execReturnToStock: data => execReturnToStock: data =>
request({ request({
url: '/qms/business-sub-sample/execReturnToStock', url: '/qms/business-sub-sample/execReturnToStock',
method: 'GET', method: 'POST',
data data
}), }),
// 库位变更 // 库位变更
@@ -42,6 +42,20 @@ export default {
method: 'POST', method: 'POST',
data data
}), }),
// 调拨创建临时数据
createDispatchTempData: data =>
request({
url: '/qms/business-sample-dispatch/createTempData',
method: 'POST',
data
}),
// 按样品添加内部调拨数据
addDispatchSample: data =>
request({
url: '/qms/business-sample-dispatch/addBySampleCode',
method: 'POST',
data
}),
// 查询待归还样品 // 查询待归还样品
searchBySampleCode: params => searchBySampleCode: params =>
request({ request({

View File

@@ -34,5 +34,12 @@ export default {
url: '/sys/app-client-role/getListByUserIdAndClientId', url: '/sys/app-client-role/getListByUserIdAndClientId',
method: 'GET' method: 'GET'
}) })
} },
// 获取当前部门下的用户
getAssignUserList: params =>
request({
url: '/qms/bus/sample/task-assign/getAssignUserList',
method: 'GET',
params
})
} }

View File

@@ -7,7 +7,7 @@ export function useListData({ searchParams, api, needInitListData = false, proce
const loadingData = ref(true) const loadingData = ref(true)
const pageParams = reactive({ const pageParams = reactive({
pageNo: 1, pageNo: 1,
pageSize: 5 pageSize: 10
}) })
const total = ref(0) const total = ref(0)
const loadStatus = ref('loadmore') const loadStatus = ref('loadmore')

View File

@@ -5,13 +5,13 @@
<u-col span="2" class="text-center" style="position: relative"> <u-col span="2" class="text-center" style="position: relative">
<slot name="tag" v-if="$slots.tag" :task="task"></slot> <slot name="tag" v-if="$slots.tag" :task="task"></slot>
<template v-else> <template v-else>
<u-icon :color="taskStyle(task)" name="tags-fill" size="40"></u-icon> <u-icon :color="taskStyle(task)" name="tags-fill" size="50"></u-icon>
<text class="seq">{{ seq }}</text> <text class="seq">{{ seq }}</text>
</template> </template>
</u-col> </u-col>
<u-col span="10"> <u-col span="10">
<view class="fs18">{{ task.taskNo }}</view> <view class="fs20">{{ task.taskNo }}</view>
<view class="mt3 mb3">{{ task.taskName }}{{ task.assayOper }}</view> <view class="mt8 mb8">{{ task.taskName }}{{ task.assayOper }}</view>
<view class="x-f"> <view class="x-f">
<u-icon name="clock"></u-icon> <u-icon name="clock"></u-icon>
<text class="ml5">{{ taskOperatorTime }}</text> <text class="ml5">{{ taskOperatorTime }}</text>
@@ -75,8 +75,8 @@ const taskStyle = task => {
} }
.seq { .seq {
position: absolute; position: absolute;
top: 12px; top: 20px;
left: 12px; left: 20px;
color: #fff; color: #fff;
font-size: 11px; font-size: 11px;
} }

View File

@@ -8,7 +8,7 @@
</view> </view>
<u-gap height="5" bg-color="#0055A2"></u-gap> <u-gap height="5" bg-color="#0055A2"></u-gap>
<scroll-view <scroll-view
style="height: 75vh" style="height: 82vh"
scroll-y scroll-y
scroll-with-animation scroll-with-animation
class="content-main-left" class="content-main-left"
@@ -37,7 +37,7 @@
</view> </view>
<u-gap height="5" bg-color="#0055A2"></u-gap> <u-gap height="5" bg-color="#0055A2"></u-gap>
<view> <view>
<scroll-view scroll-y scroll-with-animation style="height: calc(75vh - 60px)"> <scroll-view scroll-y scroll-with-animation style="height: calc(82vh - 60px)">
<block v-for="(sample, index) in sampleList" :key="index"> <block v-for="(sample, index) in sampleList" :key="index">
<view class="sample-item"> <view class="sample-item">
<u-row @click="showSampleDetail(sample.businessAssayTaskDataId, index)"> <u-row @click="showSampleDetail(sample.businessAssayTaskDataId, index)">
@@ -50,7 +50,7 @@
<view> <view>
<text class="pl5">{{ sample.sampleAssayCode }}</text> <text class="pl5">{{ sample.sampleAssayCode }}</text>
</view> </view>
<view> <view class="mt10">
<text class="pl5"> <text class="pl5">
{{ sample.sampleName }} {{ sample.sampleName }}
</text> </text>
@@ -58,7 +58,7 @@
</u-col> </u-col>
<u-col span="4"> <u-col span="4">
<view> <view>
<text style="padding-left: 10px" v-html="sample.assayProject"></text> <rich-text :nodes="sample.assayProject"> </rich-text>
</view> </view>
</u-col> </u-col>
</u-row> </u-row>
@@ -171,10 +171,9 @@ onBackPress(() => {
<style lang="scss" scoped> <style lang="scss" scoped>
.content-title-name { .content-title-name {
height: 50px; height: 60px;
box-sizing: border-box; box-sizing: border-box;
font-size: 20px; font-size: 20px;
font-weight: 300;
padding: 10px; padding: 10px;
text-align: center; text-align: center;
display: flex; display: flex;

View File

@@ -8,8 +8,9 @@
</navbar-back> </navbar-back>
<u-row gutter="8"> <u-row gutter="8">
<u-col span="3"> <u-col span="3" style="height: 60px">
<up-tabs <up-tabs
class="content-tabs"
:current="activeAssayTypeIndex" :current="activeAssayTypeIndex"
:list="assayGroups" :list="assayGroups"
lineColor="#5ac725" lineColor="#5ac725"
@@ -24,15 +25,15 @@
></up-tabs> ></up-tabs>
<u-gap height="5" bg-color="#0055A2"></u-gap> <u-gap height="5" bg-color="#0055A2"></u-gap>
</u-col> </u-col>
<u-col span="6"> <u-col span="6" style="height: 60px">
<view class="content-title-name"> <view class="content-title-name">
<view class="current-sample-code">{{ currentSampleData.sampleCode }}</view> <view class="current-sample-code">{{ currentSampleData.sampleCode }}</view>
<view>数据采集或录入</view> <view>数据采集或录入</view>
</view> </view>
<u-gap height="5" bg-color="#0055A2"></u-gap> <u-gap height="5" bg-color="#0055A2"></u-gap>
</u-col> </u-col>
<u-col span="3"> <u-col span="3" style="height: 60px">
<u-dropdown style="height: 35px"> <u-dropdown>
<u-dropdown-item <u-dropdown-item
v-model="curParameterKey" v-model="curParameterKey"
:title="curParameterTitle" :title="curParameterTitle"
@@ -63,7 +64,7 @@
<view> <view>
{{ sample.sampleCode }} {{ sample.sampleCode }}
</view> </view>
<view> {{ sample.sampleName }} </view> <view class="mt10"> {{ sample.sampleName }} </view>
</view> </view>
</view> </view>
</scroll-view> </scroll-view>
@@ -149,8 +150,8 @@
</view> </view>
</u-col> </u-col>
<u-col span="3"> <u-col span="3">
<view> <view class="pt10">
<scroll-view class="content-right-scroll" scroll-y scroll-with-animation> <scroll-view class="content-right-scroll" scroll-y scroll-with-animation :scroll-top="scrollFieldTop">
<view> <view>
<!-- <template v-for="(fields, groupIndex) in fieldGroup" :key="'group_' + groupIndex"> --> <!-- <template v-for="(fields, groupIndex) in fieldGroup" :key="'group_' + groupIndex"> -->
<!-- <view> --> <!-- <view> -->
@@ -168,7 +169,7 @@
<template v-for="(fields, groupIndex) in currentGroup"> <template v-for="(fields, groupIndex) in currentGroup">
<up-collapse-item v-if="fields.label !== '全部'"> <up-collapse-item v-if="fields.label !== '全部'">
<template #title> <template #title>
<text class="font-bold">{{ fields.label }}</text> <text class="font-bold fs18">{{ fields.label }}</text>
</template> </template>
<template v-for="(field, fieldIndex) in fields.fields" :key="groupIndex + '-' + fieldIndex"> <template v-for="(field, fieldIndex) in fields.fields" :key="groupIndex + '-' + fieldIndex">
<view <view
@@ -281,6 +282,7 @@ const taskIngredientsStatus = ref('') //配料状态
const configReportTemplateKey = ref('') const configReportTemplateKey = ref('')
const elId = nx.$helper.uuid() const elId = nx.$helper.uuid()
const scrollTop = ref(0) //tab标题的滚动条位置 const scrollTop = ref(0) //tab标题的滚动条位置
const scrollFieldTop = ref(0)
const menuHeight = ref(0) // 左边菜单的高度 const menuHeight = ref(0) // 左边菜单的高度
const menuItemHeight = ref(0) // 左边菜单item的高度 const menuItemHeight = ref(0) // 左边菜单item的高度
const weightDataIsToZero = ref(false) //重量数据是否归零 const weightDataIsToZero = ref(false) //重量数据是否归零
@@ -879,6 +881,7 @@ watch(
const collapseRef = ref() const collapseRef = ref()
const activeCollapses = ref([]) const activeCollapses = ref([])
function handleAssayTypeChange({ index, value }) { function handleAssayTypeChange({ index, value }) {
scrollFieldTop.value = 0
activeAssayTypeKey.value = value activeAssayTypeKey.value = value
activeAssayTypeIndex.value = index activeAssayTypeIndex.value = index
currentSampleIndex.value = 0 currentSampleIndex.value = 0
@@ -1217,25 +1220,37 @@ onBackPress(() => {
color: #fff; color: #fff;
display: flex; display: flex;
} }
.content-title-name { .content-title-name {
font-size: 18px; font-size: 22px;
font-weight: 300;
padding: 4px 0;
display: flex; display: flex;
align-items: center;
justify-content: center; justify-content: center;
height: 100%;
}
.content-tabs {
height: 100%;
:deep(.u-tabs__wrapper) {
height: 100%;
}
} }
.current-sample-code { .current-sample-code {
font-weight: bold; font-weight: bold;
margin-right: 20px; margin-right: 20px;
} }
:deep(.u-dropdown) {
height: 100%;
.u-dropdown__menu {
height: 60px !important;
.u-dropdown__menu__item__text {
font-size: 18px !important;
}
}
}
.form-item-my { .form-item-my {
display: flex; display: flex;
align-items: center; align-items: center;
min-height: 35px; min-height: 35px;
font-size: 13px; font-size: 16px;
border-bottom: 1px solid #dcdcdc; border-bottom: 1px solid #dcdcdc;
} }
.selected-field { .selected-field {
@@ -1285,10 +1300,10 @@ onBackPress(() => {
color: #c0c4cc; color: #c0c4cc;
} }
.content-left-scroll { .content-left-scroll {
height: 68vh; height: 75vh;
} }
.content-right-scroll { .content-right-scroll {
height: 68vh; height: 74vh;
} }
.valid-warning { .valid-warning {
color: orange; color: orange;
@@ -1302,7 +1317,7 @@ onBackPress(() => {
align-items: center; align-items: center;
font-size: 16px; font-size: 16px;
color: #444; color: #444;
padding: 4px 8px; padding: 8px 16px;
box-sizing: border-box; box-sizing: border-box;
border-bottom: 2px dotted #444; border-bottom: 2px dotted #444;
} }
@@ -1335,8 +1350,9 @@ onBackPress(() => {
position: relative; position: relative;
.code { .code {
position: absolute; position: absolute;
top: 15px; font-style: 18px;
left: 55px; top: 25px;
left: 70px;
} }
} }
@@ -1405,7 +1421,7 @@ onBackPress(() => {
.field-name { .field-name {
font-size: 26px; font-size: 26px;
padding: 8px; padding: 16px;
width: 100%; width: 100%;
} }

View File

@@ -8,7 +8,7 @@
<up-badge v-if="taskList.length > 0" class="ml5" :value="taskList.length" type="warning"></up-badge> <up-badge v-if="taskList.length > 0" class="ml5" :value="taskList.length" type="warning"></up-badge>
</view> </view>
<u-gap height="5" bg-color="#0055A2"></u-gap> <u-gap height="5" bg-color="#0055A2"></u-gap>
<scroll-view style="height: 75vh" scroll-y scroll-with-animation class="content-main-left"> <scroll-view style="height: 82vh" scroll-y scroll-with-animation class="content-main-left">
<template v-if="taskList.length > 0"> <template v-if="taskList.length > 0">
<TaskItem <TaskItem
v-for="(task, index) in taskList" v-for="(task, index) in taskList"
@@ -29,7 +29,7 @@
</view> </view>
<u-gap height="5" bg-color="#0055A2"></u-gap> <u-gap height="5" bg-color="#0055A2"></u-gap>
<view> <view>
<scroll-view scroll-y scroll-with-animation style="height: calc(75vh - 60px)"> <scroll-view scroll-y scroll-with-animation style="height: calc(82vh - 60px)">
<u-checkbox-group placement="column" v-model="checkedSampleCodes"> <u-checkbox-group placement="column" v-model="checkedSampleCodes">
<block v-for="(sample, index) in sampleList" :key="index"> <block v-for="(sample, index) in sampleList" :key="index">
<view v-if="currentTask.reviewCount === sample.reviewCount" class="sample-item"> <view v-if="currentTask.reviewCount === sample.reviewCount" class="sample-item">
@@ -52,13 +52,13 @@
<view> <view>
{{ sample.sampleAssayCode }} {{ sample.sampleAssayCode }}
</view> </view>
<view> <view class="mt10">
{{ sample.sampleName }} {{ sample.sampleName }}
</view> </view>
</u-col> </u-col>
<u-col span="6"> <u-col span="6">
<view> <view>
<text class="pl10" v-html="sample.assayProject"> </text> <rich-text :nodes="sample.assayProject"> </rich-text>
</view> </view>
</u-col> </u-col>
</u-row> </u-row>
@@ -263,10 +263,9 @@ onBackPress(() => {
<style lang="scss" scoped> <style lang="scss" scoped>
.content-title-name { .content-title-name {
height: 50px; height: 60px;
box-sizing: border-box; box-sizing: border-box;
font-size: 20px; font-size: 22px;
font-weight: 300;
padding: 10px; padding: 10px;
text-align: center; text-align: center;
display: flex; display: flex;

View File

@@ -13,7 +13,7 @@ import { reactive, ref, computed, onMounted } from 'vue'
import nx from '@/nx' import nx from '@/nx'
import { useGridCol } from '@/nx/hooks/useGridCol' import { useGridCol } from '@/nx/hooks/useGridCol'
let list = reactive([ let list = reactive([
{ url: '/pages/lims/index/index', name: '设备管理', icon: '设备管理' }, // { url: '/pages/lims/index/index', name: '设备管理', icon: '设备管理' },
{ url: '/pages/analysis/index/index', name: '分析管理', icon: '分析管理' }, { url: '/pages/analysis/index/index', name: '分析管理', icon: '分析管理' },
{ url: '/pages/sampleWarehouse/index/index', name: '样品库管理', icon: '样品库管理' } { url: '/pages/sampleWarehouse/index/index', name: '样品库管理', icon: '样品库管理' }
]) ])

View File

@@ -9,7 +9,7 @@
<view class="header"> <view class="header">
<image src="/static/images/login/logo.png"></image> <image src="/static/images/login/logo.png"></image>
</view> </view>
<view class="text-center pt10 fs22 font-bold"> 实验室管理系统 </view>
<view class="list"> <view class="list">
<view class="list-call"> <view class="list-call">
<u-icon name="account" color="#0055a2" size="30"></u-icon> <u-icon name="account" color="#0055a2" size="30"></u-icon>
@@ -20,11 +20,16 @@
<input <input
class="sl-input" class="sl-input"
v-model="loginInfo.password" v-model="loginInfo.password"
type="text" :type="passwordFieldType"
maxlength="32" maxlength="32"
placeholder="请输入密码" placeholder="请输入密码"
password="true"
/> />
<u-icon
:name="passwordVisible ? 'eye-fill' : 'eye-off'"
color="#0055a2"
size="30"
@click="togglePasswordVisibility"
></u-icon>
</view> </view>
</view> </view>
<view class="login-btn"> <view class="login-btn">
@@ -56,6 +61,14 @@ let loginInfo = reactive({
password: 'P@ssword25', password: 'P@ssword25',
captchaVerification: '' captchaVerification: ''
}) })
const passwordVisible = ref(false)
const passwordFieldType = ref('password')
function togglePasswordVisibility() {
passwordVisible.value = !passwordVisible.value
passwordFieldType.value = passwordVisible.value ? 'text' : 'password'
}
onShow(() => { onShow(() => {
//检查APP更新 //检查APP更新
// #ifdef APP-PLUS // #ifdef APP-PLUS
@@ -186,6 +199,6 @@ function onCaptchaError(error) {
} }
.login-btn { .login-btn {
margin-top: 20px; margin-top: 50px;
} }
</style> </style>

View File

@@ -1,7 +1,159 @@
<template> <template>
<view> </view> <navbar-back title="调拨归还"></navbar-back>
<view class="pl8 pr8 pt8">
<view class="x-f">
<text class="pl6">归还人</text>
<uni-data-select v-model="givebackUserId" :localdata="range" placeholder="请选择样品归还人"></uni-data-select>
</view>
<view class="border-b p6 x-f"
><view class="pr16">库管员</view><text>{{ userInfo.nickname }}</text></view
>
<up-input
style="padding-top: 20px"
border="bottom"
v-model="sampleCode"
placeholder="请扫描需要归还的样品编号"
prefixIcon="scan"
fontSize="16"
prefixIconStyle="font-size: 30px;"
@confirm="getSampleList"
>
</up-input>
<uni-section v-if="sampleList.length > 0" type="line" title="归还样品明细" titleFontSize="15px">
<template #right> <up-text type="error" size="18" bold :text="sampleList.length"></up-text></template>
<scroll-view style="height: 49vh" scroll-y scroll-with-animation>
<uni-card margin="5px" v-for="item in sampleList" class="sample-item">
<view class="x-bc">
<view
>样品名称<text class="black">{{ item.sampleName }}</text></view
>
<view>调拨人<text class="black">{{}}</text></view>
</view>
<view class="x-bc">
<view
>样品编号<text class="black">{{ item.sampleReturnCode }}</text></view
>
<view>调拨时间<text class="black">{{}}</text></view>
</view>
<view class="mt4"
>归库编码<text class="black">{{ item.sampleReturnCode }}</text></view
>
<view class="mt4"
>样品库名称<text class="black">{{ item.warehouseName }}</text></view
>
<view class="mt4"
>库位码<text class="black">{{ item.warehouseLocationCode }}</text></view
>
</uni-card>
</scroll-view>
<up-button type="primary" :loading="btnLoading" style="width: 50%" text="提交" @click="handleSubmit"></up-button>
</uni-section>
</view>
</template> </template>
<script setup></script> <script setup>
import { computed, ref, toRefs, watch, onMounted } from 'vue'
import { debounce } from 'lodash'
import nx from '@/nx'
import { onLoad, onShow } from '@dcloudio/uni-app'
<style lang="scss" scoped></style> const btnLoading = ref(false)
let sampleCode = ref('')
let sampleList = ref([])
const range = ref([])
const userInfo = computed(() => nx.$store('user').userInfo)
const givebackUserId = ref('')
const { scanQRInfo } = toRefs(nx.$store('biz'))
watch(scanQRInfo, newVal => {
debouncedHandleScan(newVal)
})
const debouncedHandleScan = debounce(val => {
if (!val) return
scanQRInfo.value = ''
if (nx.$router.getCurrentPage().route !== 'pages/sampleWarehouse/dispatchGiveBack/index') return
try {
sampleCode.value = val
getSampleList()
} catch (error) {
uni.showToast({
title: '请扫描正确的样品编码',
icon: 'none'
})
}
}, 300)
onShow(() => {
scanQRInfo.value = ''
})
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))
if (newItems.length === 0) {
return uni.showToast({ title: '该样品已存在,无需重复添加', icon: 'none' })
}
sampleList.value.push(...newItems)
}
async function handleSubmit() {
if (givebackUserId.value === '') {
return uni.showToast({
title: '请选择样品归还人',
icon: 'none'
})
}
btnLoading.value = true
const givebackUser = range.value.find(item => item.value === givebackUserId.value)?.nickname
await nx.$api.sampleWarehouse
.execSampleDispatch({
detailIds: sampleList.value.map(item => item.id),
givebackUserId: givebackUserId.value,
givebackUser
})
.finally(() => {
btnLoading.value = false
})
uni.showToast({
title: '归还成功',
icon: 'none'
})
handleReset()
}
function handleReset() {
sampleCode.value = ''
sampleList.value = []
}
onMounted(async () => {
const data = await nx.$api.user.getAssignUserList()
range.value = data.map(item => ({ text: item.nickname, value: item.id }))
})
</script>
<style lang="scss" scoped>
.sample-item {
position: relative;
pointer-events: none;
.item-checkbox {
position: absolute;
right: 5px;
top: 5px;
}
}
:deep(.uni-select__input-placeholder) {
font-size: 16px;
}
</style>

View File

@@ -69,6 +69,7 @@
<script setup> <script setup>
import { ref, reactive, computed, onMounted, toRefs, watch } from 'vue' import { ref, reactive, computed, onMounted, toRefs, watch } from 'vue'
import { onShow } from '@dcloudio/uni-app' import { onShow } from '@dcloudio/uni-app'
import { debounce } from 'lodash'
import nx from '@/nx' import nx from '@/nx'
const changeType = ref('sample') const changeType = ref('sample')
@@ -134,24 +135,23 @@ function handleChangeType(e) {
let isFirstInput = ref(true) let isFirstInput = ref(true)
const { scanQRInfo } = toRefs(nx.$store('biz')) const { scanQRInfo } = toRefs(nx.$store('biz'))
watch(scanQRInfo, newVal => { watch(scanQRInfo, newVal => {
if (!newVal) return debouncedHandleScan(newVal)
})
const debouncedHandleScan = debounce(val => {
if (!val) return
scanQRInfo.value = '' scanQRInfo.value = ''
if (nx.$router.getCurrentPage().route !== 'pages/sampleWarehouse/execChangeLocation/index') return if (nx.$router.getCurrentPage().route !== 'pages/sampleWarehouse/execChangeLocation/index') return
try { try {
console.log(newVal) const isJson = nx.$helper.isJsonString(val)
const isJson = nx.$helper.isJsonString(newVal)
console.log(isJson)
if (isFirstInput.value) { if (isFirstInput.value) {
handleFirstScan(newVal, isJson) handleFirstScan(val, isJson)
} else { } else {
handleSecondScan(newVal, isJson) handleSecondScan(val, isJson)
} }
} catch (error) { } catch (error) {
uni.showToast({ title: '扫码内容解析失败', icon: 'none' }) uni.showToast({ title: '扫码内容解析失败', icon: 'none' })
} }
}) }, 300)
function handleFirstScan(rawValue, isJson) { function handleFirstScan(rawValue, isJson) {
if (changeType.value === 'sample') { if (changeType.value === 'sample') {
// 按样品变更:首扫应为纯字符串(样品编号) // 按样品变更:首扫应为纯字符串(样品编号)

View File

@@ -12,7 +12,7 @@
<up-grid :col="gridCol" :border="false"> <up-grid :col="gridCol" :border="false">
<up-grid-item class="mb20 mt20" v-for="item in menuItemList" :key="item.url" @click="goTo(item.url)"> <up-grid-item class="mb20 mt20" v-for="item in menuItemList" :key="item.url" @click="goTo(item.url)">
<u-icon :name="item.otherConf.icon" color="#0055A2" size="80" /> <u-icon :name="item.otherConf.icon" color="#0055A2" size="60" />
<view class="grid-text">{{ item.name }}</view> <view class="grid-text">{{ item.name }}</view>
</up-grid-item> </up-grid-item>
</up-grid> </up-grid>
@@ -104,6 +104,6 @@ const { gridCol } = useGridCol([400], [2, 3])
<style scoped lang="scss"> <style scoped lang="scss">
.grid-text { .grid-text {
font-size: 24px; font-size: 18px;
} }
</style> </style>

View File

@@ -29,16 +29,26 @@
<script setup> <script setup>
import { ref, reactive, computed, onMounted, toRefs, watch } from 'vue' import { ref, reactive, computed, onMounted, toRefs, watch } from 'vue'
import { onShow } from '@dcloudio/uni-app' import { onShow } from '@dcloudio/uni-app'
import { debounce } from 'lodash'
import nx from '@/nx' import nx from '@/nx'
const { scanQRInfo } = toRefs(nx.$store('biz')) const { scanQRInfo } = toRefs(nx.$store('biz'))
watch(scanQRInfo, newVal => { watch(scanQRInfo, newVal => {
if (!newVal) return debouncedHandleScan(newVal)
})
const debouncedHandleScan = debounce(val => {
if (!val) return
scanQRInfo.value = '' scanQRInfo.value = ''
if (nx.$router.getCurrentPage().route !== 'pages/sampleWarehouse/returnToStock/index') return if (nx.$router.getCurrentPage().route !== 'pages/sampleWarehouse/returnToStock/index') return
try { try {
if (nx.$helper.isJsonString(newVal)) { if (nx.$helper.isJsonString(val)) {
const codeObj = JSON.parse(newVal) const codeObj = JSON.parse(val)
if (codeObj.code === locationCode.value) {
return uni.showToast({
title: '请勿重复扫描',
icon: 'none'
})
}
locationCode.value = codeObj.code locationCode.value = codeObj.code
} else { } else {
if (!locationCode.value) { if (!locationCode.value) {
@@ -48,7 +58,7 @@ watch(scanQRInfo, newVal => {
}) })
return return
} else { } else {
sampleCode.value = newVal sampleCode.value = val
// 执行归库 // 执行归库
handleReturnToStock() handleReturnToStock()
} }
@@ -56,7 +66,7 @@ watch(scanQRInfo, newVal => {
} catch (error) { } catch (error) {
uni.showToast({ title: '扫码内容解析失败', icon: 'none' }) uni.showToast({ title: '扫码内容解析失败', icon: 'none' })
} }
}) }, 300)
onShow(() => { onShow(() => {
scanQRInfo.value = '' scanQRInfo.value = ''
}) })
@@ -69,11 +79,11 @@ function handleReturnToStock() {
nx.$api.sampleWarehouse nx.$api.sampleWarehouse
.execReturnToStock({ .execReturnToStock({
warehouseLocationCode: locationCode.value, warehouseLocationCode: locationCode.value,
sampleCode: sampleCode.value sampleReturnCode: sampleCode.value
}) })
.then(res => { .then(res => {
successCount.value++ successCount.value++
if (res.print) { if (res.isPrint) {
uni.showToast({ uni.showToast({
title: `归库成功,归库码为【${res.code}`, title: `归库成功,归库码为【${res.code}`,
duration: 3000, duration: 3000,

View File

@@ -11,6 +11,7 @@
><text>申请事由</text><text>{{ applyData.applyContent }}</text></view ><text>申请事由</text><text>{{ applyData.applyContent }}</text></view
> >
<up-input <up-input
v-if="showAction"
style="padding-top: 20px" style="padding-top: 20px"
border="bottom" border="bottom"
v-model="sampleCode" v-model="sampleCode"
@@ -37,12 +38,14 @@
<view class="mt4" <view class="mt4"
>库位码<text class="black">{{ item.warehouseLocationCode }}</text></view >库位码<text class="black">{{ item.warehouseLocationCode }}</text></view
> >
<up-checkbox class="item-checkbox" :name="item.sampleReturnCode"> </up-checkbox> <up-checkbox v-if="showAction" class="item-checkbox" :name="item.sampleReturnCode"> </up-checkbox>
</uni-card> </uni-card>
</up-checkbox-group> </up-checkbox-group>
</scroll-view> </scroll-view>
<up-button <up-button
v-if="showAction"
type="primary" type="primary"
:loading="btnLoading"
:disabled="checkedSampleCodes.length !== sampleList.length" :disabled="checkedSampleCodes.length !== sampleList.length"
style="width: 50%" style="width: 50%"
text="提交" text="提交"
@@ -56,10 +59,16 @@
import { computed, ref, toRefs, watch } from 'vue' import { computed, ref, toRefs, watch } from 'vue'
import nx from '@/nx' import nx from '@/nx'
import { onLoad, onShow } from '@dcloudio/uni-app' import { onLoad, onShow } from '@dcloudio/uni-app'
import { debounce } from 'lodash'
let btnLoading = ref(false)
let sampleCode = ref('') let sampleCode = ref('')
let applyData = ref({ applyUser: '张三', applyTime: '2021-01-01 10:10:10', applyContent: '测试' }) let applyData = ref({})
let sampleList = ref([]) let sampleList = ref([])
const showAction = computed(() => {
return applyData.value.finishStatus === 'pending'
})
async function getDetailList() { async function getDetailList() {
const { list } = await nx.$api.sampleWarehouse.querySampleDispatchApplyDetail({ const { list } = await nx.$api.sampleWarehouse.querySampleDispatchApplyDetail({
parentId: applyData.value.id, parentId: applyData.value.id,
@@ -71,15 +80,18 @@ let checkedSampleCodes = ref([])
const { flagInfo, scanQRInfo } = toRefs(nx.$store('biz')) const { flagInfo, scanQRInfo } = toRefs(nx.$store('biz'))
onLoad(async options => { onLoad(async options => {
applyData.value = flagInfo applyData.value = flagInfo.value
getDetailList() getDetailList()
}) })
watch(scanQRInfo, newVal => { watch(scanQRInfo, newVal => {
if (!newVal) return debouncedHandleScan(newVal)
})
const debouncedHandleScan = debounce(val => {
if (!val) return
scanQRInfo.value = '' scanQRInfo.value = ''
if (nx.$router.getCurrentPage().route !== 'pages/sampleWarehouse/sampleDispatchExternal/detail') return if (nx.$router.getCurrentPage().route !== 'pages/sampleWarehouse/sampleDispatchExternal/detail') return
try { try {
sampleCode.value = newVal sampleCode.value = val
if ( if (
sampleCode.value === sampleList.value.find(item => item.sampleReturnCode === sampleCode.value)?.sampleReturnCode sampleCode.value === sampleList.value.find(item => item.sampleReturnCode === sampleCode.value)?.sampleReturnCode
) { ) {
@@ -103,13 +115,16 @@ watch(scanQRInfo, newVal => {
icon: 'none' icon: 'none'
}) })
} }
}) }, 300)
onShow(() => { onShow(() => {
scanQRInfo.value = '' scanQRInfo.value = ''
}) })
async function handleSubmit() { async function handleSubmit() {
await nx.$api.sampleWarehouse.execSampleDispatch({ id: applyData.value.id }) btnLoading.value = true
await nx.$api.sampleWarehouse.execSampleDispatch({ id: applyData.value.id }).finally(() => {
btnLoading.value = false
})
uni.showToast({ uni.showToast({
title: '调拨成功', title: '调拨成功',
icon: 'none' icon: 'none'

View File

@@ -11,7 +11,7 @@
<scroll-view style="height: 82vh" scroll-y scroll-with-animation @scrolltolower="handleScrolltolower"> <scroll-view style="height: 82vh" scroll-y scroll-with-animation @scrolltolower="handleScrolltolower">
<view class="data-item" v-for="(item, index) in listData" @click="handleDetail(item)"> <view class="data-item" v-for="(item, index) in listData" @click="handleDetail(item)">
<view <view
>申请人<text>{{ item.applyUser }}</text></view >申请人<text class="pl20">{{ item.applyUser }}</text></view
> >
<view <view
>申请时间<text>{{ nx.$dayjs(item.applyTime).format('YYYY-MM-DD HH:mm:ss') }}</text></view >申请时间<text>{{ nx.$dayjs(item.applyTime).format('YYYY-MM-DD HH:mm:ss') }}</text></view

View File

@@ -1,6 +1,10 @@
<template> <template>
<navbar-back title="样品调拨"></navbar-back> <navbar-back title="样品调拨"></navbar-back>
<view class="pl8 pr8"> <view class="pl8 pr8 pt8">
<view class="x-f">
<text class="pl6">领取人</text>
<uni-data-select v-model="receiverId" :localdata="range" placeholder="请选择样品领取人"></uni-data-select>
</view>
<view class="border-b p6 x-f" <view class="border-b p6 x-f"
><view class="pr16">库管员</view><text>{{ userInfo.nickname }}</text></view ><view class="pr16">库管员</view><text>{{ userInfo.nickname }}</text></view
> >
@@ -12,6 +16,7 @@
prefixIcon="scan" prefixIcon="scan"
fontSize="16" fontSize="16"
prefixIconStyle="font-size: 30px;" prefixIconStyle="font-size: 30px;"
@confirm="getScanSample"
> >
</up-input> </up-input>
@@ -33,48 +38,96 @@
> >
</uni-card> </uni-card>
</scroll-view> </scroll-view>
<up-button :disabled="!receiver" type="primary" style="width: 50%" text="提交" @click="handleSubmit"></up-button> <up-button type="primary" :loading="btnLoading" style="width: 50%" text="提交" @click="handleSubmit"></up-button>
</uni-section> </uni-section>
</view> </view>
</template> </template>
<script setup> <script setup>
import { computed, ref, toRefs, watch } from 'vue' import { computed, ref, toRefs, watch, onMounted } from 'vue'
import nx from '@/nx' import nx from '@/nx'
import { onLoad, onShow } from '@dcloudio/uni-app' import { onLoad, onShow } from '@dcloudio/uni-app'
const btnLoading = ref(false)
let sampleCode = ref('') let sampleCode = ref('')
let sampleList = ref([]) let sampleList = ref([])
let receiver = ref('') const range = ref([])
const userInfo = computed(() => nx.$store('user').userInfo) const userInfo = computed(() => nx.$store('user').userInfo)
const receiverId = ref('')
const { scanQRInfo } = toRefs(nx.$store('biz')) const { scanQRInfo } = toRefs(nx.$store('biz'))
watch(scanQRInfo, newVal => { watch(scanQRInfo, newVal => {
if (!newVal) return debouncedHandleScan(newVal)
})
const debouncedHandleScan = debounce(val => {
if (!val) return
scanQRInfo.value = '' scanQRInfo.value = ''
if (nx.$router.getCurrentPage().route !== 'pages/sampleWarehouse/sampleDispatchExternal/detail') return if (nx.$router.getCurrentPage().route !== 'pages/sampleWarehouse/sampleDispatchInternal/index') return
try { try {
sampleCode.value = newVal sampleCode.value = val
getScanSample()
} catch (error) { } catch (error) {
uni.showToast({ uni.showToast({
title: '请扫描正确的样品编码', title: '请扫描正确的样品编码',
icon: 'none' icon: 'none'
}) })
} }
}) }, 300)
onShow(() => { onShow(() => {
scanQRInfo.value = '' scanQRInfo.value = ''
}) })
let dispatchTempId = ref('')
// 创建临时数据
async function createDispatchTempData() {
const data = await nx.$api.sampleWarehouse.createDispatchTempData()
dispatchTempId.value = data.id
}
async function getScanSample() {
if (sampleCode.value === '') return
await nx.$api.sampleWarehouse.addDispatchSample({ id: dispatchTempId.value, sampleReturnCode: sampleCode.value })
getSampleList()
}
async function getSampleList() {
const { list } = await nx.$api.sampleWarehouse.querySampleDispatchApplyDetail({
pageSize: 999,
pageNo: 1,
parentId: dispatchTempId.value
})
sampleList.value = list
}
async function handleSubmit() { async function handleSubmit() {
await nx.$api.sampleWarehouse.execSampleDispatch({}) if (receiverId.value === '') {
return uni.showToast({
title: '请选择样品领取人',
icon: 'none'
})
}
btnLoading.value = true
const receiver = range.value.find(item => item.value === receiverId.value)?.nickname
await nx.$api.sampleWarehouse
.execSampleDispatch({
id: dispatchTempId.value,
applyUserId: receiverId.value,
applyUser: receiver
})
.finally(() => {
btnLoading.value = false
})
uni.showToast({ uni.showToast({
title: '调拨成功', title: '调拨成功',
icon: 'none' icon: 'none'
}) })
uni.navigateBack()
} }
function handleReset() {
sampleCode.value = ''
sampleList.value = []
createDispatchTempData()
}
onMounted(async () => {
const data = await nx.$api.user.getAssignUserList()
range.value = data.map(item => ({ text: item.nickname, value: item.id }))
handleReset()
})
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@@ -87,4 +140,7 @@ async function handleSubmit() {
top: 5px; top: 5px;
} }
} }
:deep(.uni-select__input-placeholder) {
font-size: 16px;
}
</style> </style>

View File

@@ -58,15 +58,19 @@
<script setup> <script setup>
import { ref, computed, onMounted, toRefs, watch } from 'vue' import { ref, computed, onMounted, toRefs, watch } from 'vue'
import { onShow } from '@dcloudio/uni-app' import { onShow } from '@dcloudio/uni-app'
import { debounce } from 'lodash'
import nx from '@/nx' import nx from '@/nx'
const { scanQRInfo } = toRefs(nx.$store('biz')) const { scanQRInfo } = toRefs(nx.$store('biz'))
watch(scanQRInfo, newVal => { watch(scanQRInfo, newVal => {
if (!newVal) return debouncedHandleScan(newVal)
})
const debouncedHandleScan = debounce(val => {
if (!val) return
scanQRInfo.value = '' scanQRInfo.value = ''
if (nx.$router.getCurrentPage().route !== 'pages/sampleWarehouse/sampleSearch/index') return if (nx.$router.getCurrentPage().route !== 'pages/sampleWarehouse/sampleSearch/index') return
try { try {
sampleCode.value = newVal sampleCode.value = val
handleSearch() handleSearch()
} catch (error) { } catch (error) {
uni.showToast({ uni.showToast({
@@ -74,7 +78,7 @@ watch(scanQRInfo, newVal => {
icon: 'none' icon: 'none'
}) })
} }
}) }, 300)
onShow(() => { onShow(() => {
scanQRInfo.value = '' scanQRInfo.value = ''
}) })

View File

@@ -52,6 +52,7 @@
import { computed, ref, toRefs, watch, reactive } from 'vue' import { computed, ref, toRefs, watch, reactive } from 'vue'
import nx from '@/nx' import nx from '@/nx'
import { onLoad, onShow } from '@dcloudio/uni-app' import { onLoad, onShow } from '@dcloudio/uni-app'
import { debounce } from 'lodash'
const takeOffType = ref('sample') const takeOffType = ref('sample')
const takeOffTypeOptions = reactive([ const takeOffTypeOptions = reactive([
@@ -75,11 +76,14 @@ const userInfo = computed(() => nx.$store('user').userInfo)
const { scanQRInfo } = toRefs(nx.$store('biz')) const { scanQRInfo } = toRefs(nx.$store('biz'))
watch(scanQRInfo, newVal => { watch(scanQRInfo, newVal => {
if (!newVal) return debouncedHandleScan(newVal)
})
const debouncedHandleScan = debounce(val => {
if (!val) return
scanQRInfo.value = '' scanQRInfo.value = ''
if (nx.$router.getCurrentPage().route !== 'pages/sampleWarehouse/sampleTakeOff/index') return if (nx.$router.getCurrentPage().route !== 'pages/sampleWarehouse/sampleTakeOff/index') return
try { try {
const isJson = nx.$helper.isJsonString(newVal) const isJson = nx.$helper.isJsonString(val)
const isSample = takeOffType.value === 'sample' const isSample = takeOffType.value === 'sample'
if (isJson) { if (isJson) {
if (isSample) { if (isSample) {
@@ -88,11 +92,11 @@ watch(scanQRInfo, newVal => {
icon: 'none' icon: 'none'
}) })
} }
const codeObj = JSON.parse(newVal) const codeObj = JSON.parse(val)
targetCode.value = codeObj.code targetCode.value = codeObj.code
} else { } else {
if (isSample) { if (isSample) {
targetCode.value = newVal targetCode.value = val
} else { } else {
return uni.showToast({ return uni.showToast({
title: '请扫描正确库位码', title: '请扫描正确库位码',
@@ -107,7 +111,7 @@ watch(scanQRInfo, newVal => {
icon: 'none' icon: 'none'
}) })
} }
}) }, 300)
onShow(() => { onShow(() => {
scanQRInfo.value = '' scanQRInfo.value = ''
}) })
@@ -138,7 +142,7 @@ async function handleSubmit() {
if (takeOffType.value === 'warehouseLocation') { if (takeOffType.value === 'warehouseLocation') {
params.locationCode = targetCode.value params.locationCode = targetCode.value
} else { } else {
params.sampleCode = targetCode.value params.sampleReturnCodes = sampleList.value.map(item => item.sampleReturnCode)
} }
btnLoading.value = true btnLoading.value = true
await nx.$api.sampleWarehouse.execTakeOff(params).finally(() => { await nx.$api.sampleWarehouse.execTakeOff(params).finally(() => {

View File

@@ -1,3 +1,15 @@
## 1.1.02025-08-19
- 新增 插槽 selected empty option
- 新增 mutiple 属性,支持多选功能
- 新增 wrap 属性,支持选中的文字超过一行显示
- 新增 align 属性,支持修改选中的文字显示的位置
- 新增 hideRight 属性,支持隐藏右侧所有按钮
- 新增 mode 属性,支持修改边框样式
- 新增 事件 open close clear
## 1.0.102025-04-14
- 修复 清除按钮不展示问题
## 1.0.92025-03-26
- 优化 默认背景为白色与整体组件保持风格统一
## 1.0.82024-03-28 ## 1.0.82024-03-28
- 修复 在vue2下:style动态绑定导致编译失败的bug - 修复 在vue2下:style动态绑定导致编译失败的bug
## 1.0.72024-01-20 ## 1.0.72024-01-20

View File

@@ -2,14 +2,21 @@
<view class="uni-stat__select"> <view class="uni-stat__select">
<span v-if="label" class="uni-label-text hide-on-phone">{{label + ''}}</span> <span v-if="label" class="uni-label-text hide-on-phone">{{label + ''}}</span>
<view class="uni-stat-box" :class="{'uni-stat__actived': current}"> <view class="uni-stat-box" :class="{'uni-stat__actived': current}">
<view class="uni-select" :class="{'uni-select--disabled':disabled}"> <view class="uni-select" :class="{'uni-select--disabled':disabled, 'uni-select--wrap': shouldWrap , 'border-default': mode == 'default','border-bottom': mode == 'underline'}">
<view class="uni-select__input-box" @click="toggleSelector"> <view class="uni-select__input-box" @click="toggleSelector" :class="{'uni-select__input-box--wrap': shouldWrap}">
<view v-if="current" class="uni-select__input-text">{{textShow}}</view> <view v-if="slotSelected" class="slot-content padding-top-bottom" :class="{'uni-select__input-text--wrap': shouldWrap}">
<view v-else class="uni-select__input-text uni-select__input-placeholder">{{typePlaceholder}}</view> <slot name="selected" :selectedItems="getSelectedItems()"></slot>
<view v-if="current && clear && !disabled" @click.stop="clearVal"> </view>
<template v-else>
<view v-if="textShow" class="uni-select__input-text" :class="{'uni-select__input-text--wrap': shouldWrap}">
<view class="padding-top-bottom" :class="'align-'+align">{{textShow}}</view>
</view>
<view v-else class="uni-select__input-text uni-select__input-placeholder" :class="'align-'+align">{{typePlaceholder}}</view>
</template>
<view key="clear-button" v-if="!hideRight && shouldShowClear && clear && !disabled" @click.stop="clearVal">
<uni-icons type="clear" color="#c0c4cc" size="24" /> <uni-icons type="clear" color="#c0c4cc" size="24" />
</view> </view>
<view v-else> <view key="arrow-button" v-else-if="!hideRight">
<uni-icons :type="showSelector? 'top' : 'bottom'" size="14" color="#999" /> <uni-icons :type="showSelector? 'top' : 'bottom'" size="14" color="#999" />
</view> </view>
</view> </view>
@@ -17,13 +24,35 @@
<view class="uni-select__selector" :style="getOffsetByPlacement" v-if="showSelector"> <view class="uni-select__selector" :style="getOffsetByPlacement" v-if="showSelector">
<view :class="placement=='bottom'?'uni-popper__arrow_bottom':'uni-popper__arrow_top'"></view> <view :class="placement=='bottom'?'uni-popper__arrow_bottom':'uni-popper__arrow_top'"></view>
<scroll-view scroll-y="true" class="uni-select__selector-scroll"> <scroll-view scroll-y="true" class="uni-select__selector-scroll">
<view class="uni-select__selector-empty" v-if="mixinDatacomResData.length === 0"> <template v-if="slotEmpty && mixinDatacomResData.length === 0">
<view class="uni-select__selector-empty">
<slot name="empty" :empty="emptyTips"></slot>
</view>
</template>
<template v-else>
<view v-if="mixinDatacomResData.length === 0" class="uni-select__selector-empty">
<text>{{emptyTips}}</text> <text>{{emptyTips}}</text>
</view> </view>
<view v-else class="uni-select__selector-item" v-for="(item,index) in mixinDatacomResData" :key="index" </template>
<template v-if="slotOption">
<view v-for="(itemData,index) in mixinDatacomResData" :key="index" @click="change(itemData)">
<slot name="option" :item="itemData" :itemSelected="multiple? getCurrentValues().includes(itemData.value):getCurrentValues() == itemData.value"></slot>
</view>
</template>
<template v-else>
<view v-if="!multiple && mixinDatacomResData.length > 0" class="uni-select__selector-item" v-for="(item,index) in mixinDatacomResData" :key="index"
@click="change(item)"> @click="change(item)">
<text :class="{'uni-select__selector__disabled': item.disable}">{{formatItemName(item)}}</text> <text :class="{'uni-select__selector__disabled': item.disable}">{{formatItemName(item)}}</text>
</view> </view>
<view v-if="multiple && mixinDatacomResData.length > 0" >
<checkbox-group @change="checkBoxChange">
<label class="uni-select__selector-item" v-for="(item,index) in mixinDatacomResData" :key="index" >
<checkbox :value="index+''" :checked="getCurrentValues().includes(item.value)" :disabled="item.disable"></checkbox>
<view :class="{'uni-select__selector__disabled': item.disable}">{{formatItemName(item)}}</view>
</label>
</checkbox-group>
</view>
</template>
</scroll-view> </scroll-view>
</view> </view>
</view> </view>
@@ -36,22 +65,56 @@
* DataChecklist 数据选择器 * DataChecklist 数据选择器
* @description 通过数据渲染的下拉框组件 * @description 通过数据渲染的下拉框组件
* @tutorial https://uniapp.dcloud.io/component/uniui/uni-data-select * @tutorial https://uniapp.dcloud.io/component/uniui/uni-data-select
* @property {String} value 默认值 * @property {String|Array} value 默认值,多选时为数组
* @property {Array} localdata 本地数据 ,格式 [{text:'',value:''}] * @property {Array} localdata 本地数据 ,格式 [{text:'',value:''}]
* @property {Boolean} clear 是否可以清空已选项 * @property {Boolean} clear 是否可以清空已选项
* @property {Boolean} emptyText 没有数据时显示的文字 ,本地数据无效 * @property {Boolean} emptyText 没有数据时显示的文字 ,本地数据无效
* @property {String} label 左侧标题 * @property {String} label 左侧标题
* @property {String} placeholder 输入框的提示文字 * @property {String} placeholder 输入框的提示文字
* @property {Boolean} disabled 是否禁用 * @property {Boolean} disabled 是否禁用
* @property {Boolean} multiple 是否多选模式
* @property {Boolean} wrap 是否允许选中文本换行显示
* @property {String} placement 弹出位置 * @property {String} placement 弹出位置
* @value top 顶部弹出 * @value top 顶部弹出
* @value bottom 底部弹出default) * @value bottom 底部弹出default)
* @property {String} align 选择文字的位置
* @value left 显示左侧
* @value center 显示中间
* @value right 显示 右侧
* @property {Boolean} hideRight 是否隐藏右侧按钮
* @property {String} mode 边框样式
* @value default 四周边框
* @value underline 下边框
* @value none 无边框
* @event {Function} change 选中发生变化触发 * @event {Function} change 选中发生变化触发
* @event {Function} open 选择框开启时触发
* @event {Function} close 选择框关闭时触发
* @event {Function} clear 点击清除按钮之后触发
*/ */
export default { export default {
name: "uni-data-select", name: "uni-data-select",
mixins: [uniCloud.mixinDatacom || {}], mixins: [uniCloud.mixinDatacom || {}],
emits: [
'open',
'close',
'update:modelValue',
'input',
'clear',
'change'
],
model: {
prop: 'modelValue',
event: 'update:modelValue'
},
options: {
// #ifdef MP-TOUTIAO
virtualHost: false,
// #endif
// #ifndef MP-TOUTIAO
virtualHost: true
// #endif
},
props: { props: {
localdata: { localdata: {
type: Array, type: Array,
@@ -60,11 +123,11 @@
} }
}, },
value: { value: {
type: [String, Number], type: [String, Number, Array],
default: '' default: ''
}, },
modelValue: { modelValue: {
type: [String, Number], type: [String, Number, Array],
default: '' default: ''
}, },
label: { label: {
@@ -99,6 +162,26 @@
placement: { placement: {
type: String, type: String,
default: 'bottom' default: 'bottom'
},
multiple: {
type: Boolean,
default: false
},
wrap: {
type: Boolean,
default: false
},
align:{
type: String,
default: "left"
},
hideRight: {
type: Boolean,
default: false
},
mode:{
type: String,
default: 'default'
} }
}, },
data() { data() {
@@ -133,20 +216,35 @@
common common
}, },
valueCom() { valueCom() {
// #ifdef VUE3 if (this.value === '') return this.modelValue
return this.modelValue; if (this.modelValue === '') return this.value
// #endif return this.value
// #ifndef VUE3
return this.value;
// #endif
}, },
textShow() { textShow() {
// 长文本显示 // 长文本显示
let text = this.current; if (this.multiple) {
if (text.length > 10) { const currentValues = this.getCurrentValues();
return text.slice(0, 25) + '...'; if (Array.isArray(currentValues) && currentValues.length > 0) {
const selectedItems = this.mixinDatacomResData.filter(item => currentValues.includes(item.value));
return selectedItems.map(item => this.formatItemName(item)).join(', ');
} else {
return ''; // 空数组时返回空字符串,显示占位符
} }
return text; } else {
return this.current;
}
},
shouldShowClear() {
if (this.multiple) {
const currentValues = this.getCurrentValues();
return Array.isArray(currentValues) && currentValues.length > 0;
} else {
return !!this.current;
}
},
shouldWrap() {
// 只有在多选模式、开启换行、且有内容时才应用换行样式
return this.multiple && this.wrap && !!this.textShow;
}, },
getOffsetByPlacement() { getOffsetByPlacement() {
switch (this.placement) { switch (this.placement) {
@@ -155,10 +253,38 @@
case 'bottom': case 'bottom':
return "top:calc(100% + 12px);"; return "top:calc(100% + 12px);";
} }
},
slotSelected(){
// #ifdef VUE2
return this.$scopedSlots ? this.$scopedSlots.selected : false
// #endif
// #ifdef VUE3
return this.$slots ? this.$slots.selected : false
// #endif
},
slotEmpty(){
// #ifdef VUE2
return this.$scopedSlots ? this.$scopedSlots.empty : false
// #endif
// #ifdef VUE3
return this.$slots ? this.$slots.empty : false
// #endif
},
slotOption(){
// #ifdef VUE2
return this.$scopedSlots ? this.$scopedSlots.option : false
// #endif
// #ifdef VUE3
return this.$slots ? this.$slots.option : false
// #endif
} }
}, },
watch: { watch: {
showSelector:{
handler(val,old){
val ? this.$emit('open') : this.$emit('close')
}
},
localdata: { localdata: {
immediate: true, immediate: true,
handler(val, old) { handler(val, old) {
@@ -178,9 +304,20 @@
} }
} }
}, },
}, },
methods: { methods: {
getSelectedItems() {
const currentValues = this.getCurrentValues();
let _minxData = this.mixinDatacomResData
// #ifdef MP-WEIXIN || MP-TOUTIAO
_minxData = JSON.parse(JSON.stringify(this.mixinDatacomResData))
// #endif
if (this.multiple) {
return _minxData.filter(item => currentValues.includes(item.value)) || [];
} else {
return _minxData.filter(item => item.value === currentValues) || [];
}
},
debounce(fn, time = 100) { debounce(fn, time = 100) {
let timer = null let timer = null
return function(...args) { return function(...args) {
@@ -190,6 +327,23 @@
}, time) }, time)
} }
}, },
// 检查项目是否已选中
isSelected(item) {
if (this.multiple) {
const currentValues = this.getCurrentValues();
return Array.isArray(currentValues) && currentValues.includes(item.value);
} else {
return this.getCurrentValues() === item.value;
}
},
// 获取当前选中的值
getCurrentValues() {
if (this.multiple) {
return Array.isArray(this.valueCom) ? this.valueCom : (this.valueCom ? [this.valueCom] : []);
} else {
return this.valueCom;
}
},
// 执行数据库查询 // 执行数据库查询
query() { query() {
this.mixinDatacomEasyGet(); this.mixinDatacomEasyGet();
@@ -201,7 +355,7 @@
} }
}, },
initDefVal() { initDefVal() {
let defValue = '' let defValue = this.multiple ? [] : ''
if ((this.valueCom || this.valueCom === 0) && !this.isDisabled(this.valueCom)) { if ((this.valueCom || this.valueCom === 0) && !this.isDisabled(this.valueCom)) {
defValue = this.valueCom defValue = this.valueCom
} else { } else {
@@ -212,48 +366,106 @@
if (strogeValue || strogeValue === 0) { if (strogeValue || strogeValue === 0) {
defValue = strogeValue defValue = strogeValue
} else { } else {
let defItem = '' let defItem = this.multiple ? [] : ''
if (this.defItem > 0 && this.defItem <= this.mixinDatacomResData.length) { if (this.defItem > 0 && this.defItem <= this.mixinDatacomResData.length) {
defItem = this.mixinDatacomResData[this.defItem - 1].value defItem = this.multiple ? [this.mixinDatacomResData[this.defItem - 1].value] : this.mixinDatacomResData[this.defItem - 1].value
} }
defValue = defItem defValue = defItem
} }
if (defValue || defValue === 0) { if (defValue || defValue === 0 || (this.multiple && Array.isArray(defValue) && defValue.length > 0)) {
this.emit(defValue) this.emit(defValue)
} }
} }
if (this.multiple) {
const selectedValues = Array.isArray(defValue) ? defValue : (defValue ? [defValue] : []);
const selectedItems = this.mixinDatacomResData.filter(item => selectedValues.includes(item.value));
this.current = selectedItems.map(item => this.formatItemName(item));
} else {
const def = this.mixinDatacomResData.find(item => item.value === defValue) const def = this.mixinDatacomResData.find(item => item.value === defValue)
this.current = def ? this.formatItemName(def) : '' this.current = def ? this.formatItemName(def) : ''
}
}, },
/** /**
* @param {[String, Number]} value * @param {[String, Number, Array]} value
* 判断用户给的 value 是否同时为禁用状态 * 判断用户给的 value 是否同时为禁用状态
*/ */
isDisabled(value) { isDisabled(value) {
if (Array.isArray(value)) {
// 对于数组,如果任意一个值被禁用,则认为整体被禁用
return value.some(val => {
return this.mixinDatacomResData.some(item => item.value === val && item.disable);
});
} else {
let isDisabled = false; let isDisabled = false;
this.mixinDatacomResData.forEach(item => { this.mixinDatacomResData.forEach(item => {
if (item.value === value) { if (item.value === value) {
isDisabled = item.disable isDisabled = item.disable
} }
}) })
return isDisabled; return isDisabled;
}
}, },
clearVal() { clearVal() {
this.emit('') const emptyValue = this.multiple ? [] : '';
this.emit(emptyValue)
this.current = this.multiple ? [] : ''
if (this.collection) { if (this.collection) {
this.removeCache() this.removeCache()
} }
this.$emit('clear')
},
checkBoxChange(res){
let range = res.detail.value
let currentValues = range && range.length > 0? range.map((item)=>{
const index = parseInt(item, 10);
if (isNaN(index)) {
console.error(`无效索引: ${item}`);
}
if (index < 0 || index >= this.mixinDatacomResData.length) {
console.error(`索引越界: ${index}`);
}
return this.mixinDatacomResData[index].value;
}) : []
const selectedItems = this.mixinDatacomResData.filter(dataItem => currentValues.includes(dataItem.value));
this.current = selectedItems.map(dataItem => this.formatItemName(dataItem));
this.emit(currentValues);
}, },
change(item) { change(item) {
if (!item.disable) { if (!item.disable) {
if (this.multiple) {
// 多选模式
let currentValues = this.getCurrentValues();
if (!Array.isArray(currentValues)) {
currentValues = currentValues ? [currentValues] : [];
}
const itemValue = item.value;
const index = currentValues.indexOf(itemValue);
if (index > -1) {
currentValues.splice(index, 1);
} else {
currentValues.push(itemValue);
}
const selectedItems = this.mixinDatacomResData.filter(dataItem => currentValues.includes(dataItem.value));
this.current = selectedItems.map(dataItem => this.formatItemName(dataItem));
this.emit(currentValues);
} else {
// 单选模式
this.showSelector = false this.showSelector = false
this.current = this.formatItemName(item) this.current = this.formatItemName(item)
this.emit(item.value) this.emit(item.value)
} }
}
}, },
emit(val) { emit(val) {
this.$emit('input', val) this.$emit('input', val)
@@ -330,6 +542,11 @@
$uni-main-color: #333 !default; $uni-main-color: #333 !default;
$uni-secondary-color: #909399 !default; $uni-secondary-color: #909399 !default;
$uni-border-3: #e5e5e5; $uni-border-3: #e5e5e5;
$uni-primary: #2979ff !default;
$uni-success: #4cd964 !default;
$uni-warning: #f0ad4e !default;
$uni-error: #dd524d !default;
$uni-info: #909399 !default;
/* #ifndef APP-NVUE */ /* #ifndef APP-NVUE */
@media screen and (max-width: 500px) { @media screen and (max-width: 500px) {
@@ -352,6 +569,7 @@
} }
.uni-stat-box { .uni-stat-box {
background-color: #fff;
width: 100%; width: 100%;
flex: 1; flex: 1;
} }
@@ -370,9 +588,16 @@
margin-right: 5px; margin-right: 5px;
} }
.border-bottom {
border-bottom: solid 1px $uni-border-3;
}
.border-default {
border: 1px solid $uni-border-3;
}
.uni-select { .uni-select {
font-size: 14px; font-size: 14px;
border: 1px solid $uni-border-3;
box-sizing: border-box; box-sizing: border-box;
border-radius: 4px; border-radius: 4px;
padding: 0 5px; padding: 0 5px;
@@ -384,15 +609,20 @@
/* #endif */ /* #endif */
flex-direction: row; flex-direction: row;
align-items: center; align-items: center;
border-bottom: solid 1px $uni-border-3;
width: 100%; width: 100%;
flex: 1; flex: 1;
height: 35px; min-height: 35px;
&--disabled { &--disabled {
background-color: #f5f7fa; background-color: #f5f7fa;
cursor: not-allowed; cursor: not-allowed;
} }
&--wrap {
height: auto;
min-height: 35px;
// align-items: flex-start;
}
} }
.uni-select__label { .uni-select__label {
@@ -404,7 +634,8 @@
} }
.uni-select__input-box { .uni-select__input-box {
height: 35px; // height: 35px;
width: 0px;
position: relative; position: relative;
/* #ifndef APP-NVUE */ /* #ifndef APP-NVUE */
display: flex; display: flex;
@@ -412,6 +643,24 @@
flex: 1; flex: 1;
flex-direction: row; flex-direction: row;
align-items: center; align-items: center;
&--wrap {
.uni-select__input-text {
margin-right: 8px;
}
}
.padding-top-bottom {
padding-top: 5px;
padding-bottom: 5px;
}
.slot-content {
width: 100%;
display: flex;
flex-direction: row;
flex-wrap: wrap;
}
} }
.uni-select__input { .uni-select__input {
@@ -463,15 +712,18 @@
display: flex; display: flex;
cursor: pointer; cursor: pointer;
/* #endif */ /* #endif */
flex-direction: row;
align-items: center;
line-height: 35px; line-height: 35px;
font-size: 14px; font-size: 14px;
text-align: center;
/* border-bottom: solid 1px $uni-border-3; */ /* border-bottom: solid 1px $uni-border-3; */
padding: 0px 10px; padding: 0px 10px;
} }
.uni-select__selector-item:hover {
background-color: #f9f9f9;
.uni-select__selector-item-check {
margin-left: auto;
} }
.uni-select__selector-empty:last-child, .uni-select__selector-empty:last-child,
@@ -490,8 +742,7 @@
.uni-popper__arrow_bottom, .uni-popper__arrow_bottom,
.uni-popper__arrow_bottom::after, .uni-popper__arrow_bottom::after,
.uni-popper__arrow_top, .uni-popper__arrow_top,
.uni-popper__arrow_top::after, .uni-popper__arrow_top::after {
{
position: absolute; position: absolute;
display: block; display: block;
width: 0; width: 0;
@@ -544,11 +795,22 @@
text-overflow: ellipsis; text-overflow: ellipsis;
-o-text-overflow: ellipsis; -o-text-overflow: ellipsis;
overflow: hidden; overflow: hidden;
&--wrap {
white-space: normal;
text-overflow: initial;
-o-text-overflow: initial;
overflow: visible;
word-wrap: break-word;
word-break: break-all;
// line-height: 1.5;
}
} }
.uni-select__input-placeholder { .uni-select__input-placeholder {
color: $uni-base-color; color: $uni-base-color;
font-size: 12px; font-size: 12px;
margin: 1px 0;
} }
.uni-select--mask { .uni-select--mask {
@@ -559,4 +821,17 @@
left: 0; left: 0;
z-index: 2; z-index: 2;
} }
.align-left {
text-align: left;
}
.align-center {
text-align: center;
}
.align-right {
text-align: right;
}
</style> </style>

View File

@@ -1,7 +1,7 @@
{ {
"id": "uni-data-select", "id": "uni-data-select",
"displayName": "uni-data-select 下拉框选择器", "displayName": "uni-data-select 下拉框选择器",
"version": "1.0.8", "version": "1.1.0",
"description": "通过数据驱动的下拉框选择器", "description": "通过数据驱动的下拉框选择器",
"keywords": [ "keywords": [
"uni-ui", "uni-ui",
@@ -12,12 +12,14 @@
], ],
"repository": "https://github.com/dcloudio/uni-ui", "repository": "https://github.com/dcloudio/uni-ui",
"engines": { "engines": {
"HBuilderX": "^3.1.1" "HBuilderX": "^3.1.1",
"uni-app": "^4.45",
"uni-app-x": ""
}, },
"directories": { "directories": {
"example": "../../temps/example_temps" "example": "../../temps/example_temps"
}, },
"dcloudext": { "dcloudext": {
"sale": { "sale": {
"regular": { "regular": {
"price": "0.00" "price": "0.00"
@@ -35,50 +37,68 @@
"permissions": "无" "permissions": "无"
}, },
"npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui", "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui",
"type": "component-vue" "type": "component-vue",
"darkmode": "x",
"i18n": "x",
"widescreen": "x"
}, },
"uni_modules": { "uni_modules": {
"dependencies": ["uni-load-more"], "dependencies": [
"uni-load-more"
],
"encrypt": [], "encrypt": [],
"platforms": { "platforms": {
"cloud": { "cloud": {
"tcb": "y", "tcb": "",
"aliyun": "y", "aliyun": "",
"alipay": "n" "alipay": ""
}, },
"client": { "client": {
"App": { "uni-app": {
"app-vue": "u", "vue": {
"app-nvue": "n" "vue2": "",
"vue3": "√"
}, },
"H5-mobile": { "web": {
"Safari": "y", "safari": "",
"Android Browser": "y", "chrome": ""
"微信浏览器(Android)": "y",
"QQ浏览器(Android)": "y"
}, },
"H5-pc": { "app": {
"Chrome": "y", "vue": "",
"IE": "y", "nvue": "-",
"Edge": "y", "android": "",
"Firefox": "y", "ios": "",
"Safari": "y" "harmony": ""
}, },
"小程序": { "mp": {
"微信": "y", "weixin": "",
"阿里": "u", "alipay": "",
"百度": "u", "toutiao": "",
"字节跳动": "u", "baidu": "-",
"QQ": "u", "kuaishou": "-",
"京东": "u" "jd": "-",
"harmony": "-",
"qq": "-",
"lark": "-"
}, },
"快应用": { "quickapp": {
"华为": "u", "huawei": "-",
"联盟": "u" "union": "-"
}
}, },
"Vue": { "uni-app-x": {
"vue2": "y", "web": {
"vue3": "y" "safari": "-",
"chrome": "-"
},
"app": {
"android": "-",
"ios": "-",
"harmony": "-"
},
"mp": {
"weixin": "-"
}
} }
} }
} }