Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fefef41524 | ||
|
|
e97f47b06a | ||
|
|
a4defb2c94 | ||
|
|
8717702b58 | ||
|
|
d30dbad788 | ||
|
|
e92112e9fd |
No files matched your search
@@ -240,6 +240,10 @@ class Tracker:
|
|||||||
if not value:
|
if not value:
|
||||||
return records
|
return records
|
||||||
records.extend(value)
|
records.extend(value)
|
||||||
|
# Gitea comment pages may ignore page and keep returning the same short
|
||||||
|
# list; a short page is the conventional last-page signal.
|
||||||
|
if len(value) < PAGE_SIZE:
|
||||||
|
return records
|
||||||
raise InstallError('issue tracker pagination limit exceeded')
|
raise InstallError('issue tracker pagination limit exceeded')
|
||||||
|
|
||||||
def issues(self):
|
def issues(self):
|
||||||
|
|||||||
@@ -984,11 +984,14 @@ def list_protocols(
|
|||||||
for row in cell_rows
|
for row in cell_rows
|
||||||
)
|
)
|
||||||
if source in (None, SOURCE_DONATION):
|
if source in (None, SOURCE_DONATION):
|
||||||
if status or collected_from or collected_until:
|
# 混合列表(source=None)下状态/采集时间只覆盖细胞存储,捐赠侧跳过。
|
||||||
donation_enabled = False
|
# 科研捐赠单源列表支持 protocolStatus→donation_status;采集时间筛仍不支持捐赠。
|
||||||
else:
|
skip_donation = False
|
||||||
donation_enabled = True
|
if source is None and (status or collected_from or collected_until):
|
||||||
if not donation_enabled:
|
skip_donation = True
|
||||||
|
elif source == SOURCE_DONATION and (collected_from or collected_until):
|
||||||
|
skip_donation = True
|
||||||
|
if skip_donation:
|
||||||
query = None
|
query = None
|
||||||
else:
|
else:
|
||||||
query = apply_donation_scope(
|
query = apply_donation_scope(
|
||||||
@@ -1001,6 +1004,8 @@ def list_protocols(
|
|||||||
if query is None:
|
if query is None:
|
||||||
donation_rows = []
|
donation_rows = []
|
||||||
else:
|
else:
|
||||||
|
if status and source == SOURCE_DONATION:
|
||||||
|
query = query.filter(BizResearchDonation.donation_status == status)
|
||||||
if created_from:
|
if created_from:
|
||||||
query = query.filter(BizResearchDonation.create_time >= created_from)
|
query = query.filter(BizResearchDonation.create_time >= created_from)
|
||||||
if created_until:
|
if created_until:
|
||||||
|
|||||||
@@ -3733,6 +3733,29 @@ def test_protocol_list_filters_status_create_time_and_sample_collect_time():
|
|||||||
assert [item['id'] for item in items] == ['hit']
|
assert [item['id'] for item in items] == ['hit']
|
||||||
|
|
||||||
|
|
||||||
|
def test_donation_list_filters_by_protocol_status_alias():
|
||||||
|
from app.services.market_protocol import list_protocols
|
||||||
|
|
||||||
|
db = _session()
|
||||||
|
_masters(db)
|
||||||
|
hit = _donation(db, 'don-hit', created=datetime(2026, 10, 8, 9, 0))
|
||||||
|
hit.donation_status = 'sxz'
|
||||||
|
miss = _donation(db, 'don-miss', created=datetime(2026, 10, 8, 9, 0))
|
||||||
|
miss.donation_status = 'dsx'
|
||||||
|
db.commit()
|
||||||
|
|
||||||
|
items, total = list_protocols(
|
||||||
|
db,
|
||||||
|
ctx=_ctx('specialist'),
|
||||||
|
user_info=_user(),
|
||||||
|
source='research_donation',
|
||||||
|
protocol_status='sxz',
|
||||||
|
)
|
||||||
|
|
||||||
|
assert total == 1
|
||||||
|
assert [item['id'] for item in items] == ['don-hit']
|
||||||
|
|
||||||
|
|
||||||
def test_cell_create_rolls_back_main_customer_and_children_on_child_failure():
|
def test_cell_create_rolls_back_main_customer_and_children_on_child_failure():
|
||||||
from app.services.market_protocol import create_protocol
|
from app.services.market_protocol import create_protocol
|
||||||
|
|
||||||
|
|||||||
@@ -28,25 +28,27 @@
|
|||||||
class="market-form-fields"
|
class="market-form-fields"
|
||||||
:class="{ 'market-form-fields--grid-2': section.fieldsLayout === 'grid-2' }"
|
:class="{ 'market-form-fields--grid-2': section.fieldsLayout === 'grid-2' }"
|
||||||
>
|
>
|
||||||
<MarketFormField
|
<template v-for="item in fieldsWithInsert" :key="item.field.key">
|
||||||
v-for="field in visibleFields"
|
<slot v-if="item.insertBefore" name="insert" />
|
||||||
:key="field.key"
|
<MarketFormField
|
||||||
:field="field"
|
:field="item.field"
|
||||||
:model-value="value?.[field.key]"
|
:model-value="value?.[item.field.key]"
|
||||||
:options="fieldOptions(field)"
|
:options="fieldOptions(item.field)"
|
||||||
:uploading="uploading"
|
:uploading="uploading"
|
||||||
:disabled="fieldDisabled(field)"
|
:disabled="fieldDisabled(item.field)"
|
||||||
:search-customers="searchCustomers"
|
:search-customers="searchCustomers"
|
||||||
@update:model-value="setValue(field, $event)"
|
@update:model-value="setValue(item.field, $event)"
|
||||||
@upload="$emit('upload', { section, field, file: $event })"
|
@upload="$emit('upload', { section, field: item.field, file: $event })"
|
||||||
@customer-select="$emit('customer-select', { section, ...$event })"
|
@customer-select="$emit('customer-select', { section, ...$event })"
|
||||||
/>
|
/>
|
||||||
|
</template>
|
||||||
|
<slot v-if="appendInsert" name="insert" />
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { computed } from 'vue'
|
import { computed, useSlots } from 'vue'
|
||||||
import MarketFormField from './MarketFormField.vue'
|
import MarketFormField from './MarketFormField.vue'
|
||||||
import { sampleCodeOptionsForRow } from '../reference-options.js'
|
import { sampleCodeOptionsForRow } from '../reference-options.js'
|
||||||
|
|
||||||
@@ -58,9 +60,12 @@ const props = defineProps({
|
|||||||
mode: { type: String, default: 'create' },
|
mode: { type: String, default: 'create' },
|
||||||
uploading: { type: Boolean, default: false },
|
uploading: { type: Boolean, default: false },
|
||||||
disabled: { type: Boolean, default: false },
|
disabled: { type: Boolean, default: false },
|
||||||
searchCustomers: { type: Function, default: null }
|
searchCustomers: { type: Function, default: null },
|
||||||
|
/** 在首个匹配可见字段前插入 #insert 插槽(如协议状态下的项目归属) */
|
||||||
|
insertBeforeKeys: { type: Array, default: () => [] }
|
||||||
})
|
})
|
||||||
const emit = defineEmits(['update:modelValue', 'upload', 'field-change', 'customer-select'])
|
const emit = defineEmits(['update:modelValue', 'upload', 'field-change', 'customer-select'])
|
||||||
|
const slots = useSlots()
|
||||||
const value = computed(() => props.modelValue || {})
|
const value = computed(() => props.modelValue || {})
|
||||||
const rows = computed(() => Array.isArray(props.modelValue) ? props.modelValue : [])
|
const rows = computed(() => Array.isArray(props.modelValue) ? props.modelValue : [])
|
||||||
const visibleFields = computed(() => (props.section.fields || []).filter(
|
const visibleFields = computed(() => (props.section.fields || []).filter(
|
||||||
@@ -71,6 +76,19 @@ const visibleFields = computed(() => (props.section.fields || []).filter(
|
|||||||
!(typeof field.showWhen === 'function' && field.showWhen(value.value) === false) &&
|
!(typeof field.showWhen === 'function' && field.showWhen(value.value) === false) &&
|
||||||
!(field.createOnly && props.mode !== 'create')
|
!(field.createOnly && props.mode !== 'create')
|
||||||
))
|
))
|
||||||
|
const fieldsWithInsert = computed(() => {
|
||||||
|
const keys = props.insertBeforeKeys || []
|
||||||
|
let inserted = false
|
||||||
|
return visibleFields.value.map((field) => {
|
||||||
|
const insertBefore = Boolean(slots.insert) && !inserted && keys.includes(field.key)
|
||||||
|
if (insertBefore) inserted = true
|
||||||
|
return { field, insertBefore }
|
||||||
|
})
|
||||||
|
})
|
||||||
|
const appendInsert = computed(() => {
|
||||||
|
if (!slots.insert || !(props.insertBeforeKeys || []).length) return false
|
||||||
|
return !fieldsWithInsert.value.some((item) => item.insertBefore)
|
||||||
|
})
|
||||||
|
|
||||||
function fieldOptions(field, rowIndex = -1) {
|
function fieldOptions(field, rowIndex = -1) {
|
||||||
const base = field.options || props.options[field.optionKey] || (field.optionKey === 'users' ? props.options.staff : []) || []
|
const base = field.options || props.options[field.optionKey] || (field.optionKey === 'users' ? props.options.staff : []) || []
|
||||||
|
|||||||
@@ -1,27 +1,49 @@
|
|||||||
<template>
|
<template>
|
||||||
<section class="market-form-section">
|
<component :is="embedded ? 'div' : 'section'" :class="rootClass">
|
||||||
<h2>{{ filter ? '项目筛选' : '项目归属' }}<span v-if="required && !editing && !filter"> *</span></h2>
|
<h2 v-if="!embedded">{{ filter ? '项目筛选' : '项目归属' }}<span v-if="required && !editing && !filter"> *</span></h2>
|
||||||
|
<label v-else :id="labelId">所属项目<b v-if="required && !editing && !filter">*</b></label>
|
||||||
<template v-if="editing">
|
<template v-if="editing">
|
||||||
<van-cell title="所属项目" :value="projectLabel(record)" />
|
<template v-if="embedded">
|
||||||
<van-cell title="项目组" :value="record.teamName || '—'" />
|
<div class="market-form-field__control market-form-field__control--text" :aria-labelledby="labelId">
|
||||||
<van-cell label="归属调整请使用 Web 项目归属维护" />
|
{{ projectLabel(record) }}
|
||||||
|
</div>
|
||||||
|
<p class="market-form-field__tip">项目组:{{ record.teamName || '—' }};归属调整请使用 Web 项目归属维护</p>
|
||||||
|
</template>
|
||||||
|
<template v-else>
|
||||||
|
<van-cell title="所属项目" :value="projectLabel(record)" />
|
||||||
|
<van-cell title="项目组" :value="record.teamName || '—'" />
|
||||||
|
<van-cell label="归属调整请使用 Web 项目归属维护" />
|
||||||
|
</template>
|
||||||
</template>
|
</template>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<PresignSelectField
|
<div :class="embedded ? 'market-form-field__control' : undefined">
|
||||||
:model-value="modelValue || ''"
|
<PresignSelectField
|
||||||
:options="selectOptions"
|
:model-value="modelValue || ''"
|
||||||
:disabled="disabled || loading || Boolean(error)"
|
:options="selectOptions"
|
||||||
:loading="loading"
|
:disabled="disabled || loading || Boolean(error)"
|
||||||
searchable
|
:loading="loading"
|
||||||
title="所属项目"
|
searchable
|
||||||
:placeholder="filter ? '全部项目' : '请选择所属项目'"
|
title="所属项目"
|
||||||
@update:model-value="emit('update:modelValue', $event)"
|
:placeholder="filter ? '全部项目' : '请选择所属项目'"
|
||||||
/>
|
@update:model-value="emit('update:modelValue', $event)"
|
||||||
<van-cell v-if="loading" title="正在加载项目…" />
|
/>
|
||||||
<van-cell v-else-if="error" :label="error" title="项目加载失败,点击重试" is-link @click="load" />
|
</div>
|
||||||
<van-cell v-else-if="!options.length" :label="required && !filter ? '请联系管理员配置可选项目后再保存' : '当前没有可选项目'" />
|
<template v-if="embedded">
|
||||||
|
<p v-if="loading" class="market-form-field__tip">正在加载项目…</p>
|
||||||
|
<button v-else-if="error" type="button" class="market-form-field__tip market-form-field__tip--action" @click="load">
|
||||||
|
项目加载失败,点击重试({{ error }})
|
||||||
|
</button>
|
||||||
|
<p v-else-if="!options.length" class="market-form-field__tip">
|
||||||
|
{{ required && !filter ? '请联系管理员配置可选项目后再保存' : '当前没有可选项目' }}
|
||||||
|
</p>
|
||||||
|
</template>
|
||||||
|
<template v-else>
|
||||||
|
<van-cell v-if="loading" title="正在加载项目…" />
|
||||||
|
<van-cell v-else-if="error" :label="error" title="项目加载失败,点击重试" is-link @click="load" />
|
||||||
|
<van-cell v-else-if="!options.length" :label="required && !filter ? '请联系管理员配置可选项目后再保存' : '当前没有可选项目'" />
|
||||||
|
</template>
|
||||||
</template>
|
</template>
|
||||||
</section>
|
</component>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
@@ -35,6 +57,7 @@ const props = defineProps({
|
|||||||
bizType: { type: String, required: true },
|
bizType: { type: String, required: true },
|
||||||
editing: { type: Boolean, default: false },
|
editing: { type: Boolean, default: false },
|
||||||
filter: { type: Boolean, default: false },
|
filter: { type: Boolean, default: false },
|
||||||
|
embedded: { type: Boolean, default: false },
|
||||||
context: { type: Object, default: null },
|
context: { type: Object, default: null },
|
||||||
disabled: { type: Boolean, default: false },
|
disabled: { type: Boolean, default: false },
|
||||||
record: { type: Object, default: () => ({}) }
|
record: { type: Object, default: () => ({}) }
|
||||||
@@ -44,7 +67,9 @@ const options = ref([])
|
|||||||
const required = ref(false)
|
const required = ref(false)
|
||||||
const loading = ref(true)
|
const loading = ref(true)
|
||||||
const error = ref('')
|
const error = ref('')
|
||||||
|
const labelId = `project-assignment-${Math.random().toString(36).slice(2, 9)}`
|
||||||
let controller
|
let controller
|
||||||
|
const rootClass = computed(() => (props.embedded ? 'market-form-field' : 'market-form-section'))
|
||||||
const selectOptions = computed(() => [
|
const selectOptions = computed(() => [
|
||||||
...(!required.value || props.filter ? [{ text: props.filter ? '全部项目' : '暂不归属', value: '' }] : []),
|
...(!required.value || props.filter ? [{ text: props.filter ? '全部项目' : '暂不归属', value: '' }] : []),
|
||||||
...options.value
|
...options.value
|
||||||
|
|||||||
@@ -40,7 +40,8 @@ export function createListFilters(module, source = '') {
|
|||||||
result.source = SOURCES.has(text(source)) ? text(source) : 'cell_storage'
|
result.source = SOURCES.has(text(source)) ? text(source) : 'cell_storage'
|
||||||
return {
|
return {
|
||||||
source: result.source,
|
source: result.source,
|
||||||
protocolStatus: result.protocolStatus
|
protocolStatus: result.protocolStatus,
|
||||||
|
projectId: ''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
|
|||||||
@@ -15,11 +15,13 @@ test('creates isolated defaults for every market module', () => {
|
|||||||
|
|
||||||
assert.deepEqual(first, {
|
assert.deepEqual(first, {
|
||||||
source: 'cell_storage',
|
source: 'cell_storage',
|
||||||
protocolStatus: 'sxz'
|
protocolStatus: 'sxz',
|
||||||
|
projectId: ''
|
||||||
})
|
})
|
||||||
assert.deepEqual(second, {
|
assert.deepEqual(second, {
|
||||||
source: 'research_donation',
|
source: 'research_donation',
|
||||||
protocolStatus: ''
|
protocolStatus: '',
|
||||||
|
projectId: ''
|
||||||
})
|
})
|
||||||
assert.deepEqual(createListFilters('presign'), { orderStatus: '' })
|
assert.deepEqual(createListFilters('presign'), { orderStatus: '' })
|
||||||
assert.deepEqual(createListFilters('payment-chase'), { chaseType: '', payMode: '' })
|
assert.deepEqual(createListFilters('payment-chase'), { chaseType: '', payMode: '' })
|
||||||
@@ -66,8 +68,14 @@ test('drops incomplete ranges and counts only user-selectable filters', () => {
|
|||||||
}), { progressStatus: 'yjq' })
|
}), { progressStatus: 'yjq' })
|
||||||
assert.equal(activeFilterCount('protocol', {
|
assert.equal(activeFilterCount('protocol', {
|
||||||
source: 'cell_storage',
|
source: 'cell_storage',
|
||||||
protocolStatus: 'sxz'
|
protocolStatus: 'sxz',
|
||||||
|
projectId: ''
|
||||||
}), 1)
|
}), 1)
|
||||||
|
assert.equal(activeFilterCount('protocol', {
|
||||||
|
source: 'research_donation',
|
||||||
|
protocolStatus: 'sxz',
|
||||||
|
projectId: 'p1'
|
||||||
|
}), 2)
|
||||||
assert.equal(activeFilterCount('freight', {
|
assert.equal(activeFilterCount('freight', {
|
||||||
transportMode: '', sampleSource: 'research_donation'
|
transportMode: '', sampleSource: 'research_donation'
|
||||||
}), 1)
|
}), 1)
|
||||||
|
|||||||
@@ -313,6 +313,7 @@ test('protocol list uses inline protocol-status dropdown like presign instead of
|
|||||||
|
|
||||||
assert.match(protocol, /inlineDropdownFilters/)
|
assert.match(protocol, /inlineDropdownFilters/)
|
||||||
assert.match(protocol, /全部协议状态/)
|
assert.match(protocol, /全部协议状态/)
|
||||||
|
assert.match(protocol, /source:\s*'research_donation'/)
|
||||||
assert.match(protocol, /filterFields:\s*\[\]/)
|
assert.match(protocol, /filterFields:\s*\[\]/)
|
||||||
assert.doesNotMatch(protocol, /createTimeRange/)
|
assert.doesNotMatch(protocol, /createTimeRange/)
|
||||||
assert.doesNotMatch(protocol, /sampleCollectTimeRange/)
|
assert.doesNotMatch(protocol, /sampleCollectTimeRange/)
|
||||||
@@ -320,6 +321,25 @@ test('protocol list uses inline protocol-status dropdown like presign instead of
|
|||||||
assert.doesNotMatch(filters, /createTimeRange/)
|
assert.doesNotMatch(filters, /createTimeRange/)
|
||||||
assert.match(genericList, /inlineDropdownFilters/)
|
assert.match(genericList, /inlineDropdownFilters/)
|
||||||
assert.match(genericList, /market-list__filter-row/)
|
assert.match(genericList, /market-list__filter-row/)
|
||||||
|
assert.match(genericList, /showProtocolProjectFilter/)
|
||||||
|
assert.match(genericList, /全部项目/)
|
||||||
|
assert.doesNotMatch(genericList, /ProjectAssignmentField/)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('protocol form embeds project assignment inside protocol info before status fields', () => {
|
||||||
|
const form = source('../views/market/MarketModuleForm.vue')
|
||||||
|
const formSection = source('./components/MarketFormSection.vue')
|
||||||
|
const projectField = source('./components/ProjectAssignmentField.vue')
|
||||||
|
|
||||||
|
assert.match(form, /insert-before-keys="\['protocolStatus', 'donationStatus'\]"/)
|
||||||
|
assert.match(form, /#insert/)
|
||||||
|
assert.match(form, /embedded/)
|
||||||
|
assert.match(form, /<ProjectAssignmentField[\s\S]*?embedded/)
|
||||||
|
assert.doesNotMatch(form, /ProjectAssignmentField v-if="context\.module === 'protocol'"/)
|
||||||
|
assert.match(formSection, /insertBeforeKeys/)
|
||||||
|
assert.match(formSection, /name="insert"/)
|
||||||
|
assert.match(projectField, /embedded/)
|
||||||
|
assert.match(projectField, /market-form-field/)
|
||||||
})
|
})
|
||||||
|
|
||||||
test('protocol list exposes mobile batch selection and sequential authorized deletion', () => {
|
test('protocol list exposes mobile batch selection and sequential authorized deletion', () => {
|
||||||
|
|||||||
@@ -478,6 +478,12 @@ export default {
|
|||||||
allText: '全部协议状态',
|
allText: '全部协议状态',
|
||||||
source: 'cell_storage',
|
source: 'cell_storage',
|
||||||
options: CELL_PROTOCOL_STATUS_OPTIONS.map((item) => ({ text: item.label, value: item.value }))
|
options: CELL_PROTOCOL_STATUS_OPTIONS.map((item) => ({ text: item.label, value: item.value }))
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'protocolStatus',
|
||||||
|
allText: '全部协议状态',
|
||||||
|
source: 'research_donation',
|
||||||
|
options: DONATION_PROTOCOL_STATUS_OPTIONS.map((item) => ({ text: item.label, value: item.value }))
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
statusLabel(detail) {
|
statusLabel(detail) {
|
||||||
|
|||||||
@@ -1247,6 +1247,25 @@ body.van-toast--unclickable .presign-order-page * {
|
|||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.market-form-field > .market-form-field__tip,
|
||||||
|
.market-form-field .market-form-field__control--text .market-form-field__tip {
|
||||||
|
display: block;
|
||||||
|
margin: 0;
|
||||||
|
color: #64748b;
|
||||||
|
font-size: 11px;
|
||||||
|
font-weight: 500;
|
||||||
|
line-height: 1.4;
|
||||||
|
}
|
||||||
|
|
||||||
|
.market-form-field > .market-form-field__tip--action {
|
||||||
|
padding: 0;
|
||||||
|
border: 0;
|
||||||
|
background: transparent;
|
||||||
|
color: #0a9f6d;
|
||||||
|
text-align: left;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
.market-form-field > .van-field,
|
.market-form-field > .van-field,
|
||||||
.market-form-field__control {
|
.market-form-field__control {
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
|||||||
@@ -12,25 +12,52 @@
|
|||||||
</van-empty>
|
</van-empty>
|
||||||
</div>
|
</div>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<ProjectAssignmentField v-if="context.module === 'protocol'" ref="projectAssignment"
|
<template v-for="section in leadingSections" :key="section.key">
|
||||||
v-model="formData.projectId" :biz-type="formData.source" :editing="mode === 'edit'"
|
<MarketFormSection
|
||||||
:record="formData" :disabled="fieldsLocked" @update:model-value="dirty = true" />
|
v-if="!(context.module === 'protocol' && section.key === 'protocol')"
|
||||||
<MarketFormSection
|
:section="section"
|
||||||
v-for="section in leadingSections"
|
:model-value="sectionValue(section)"
|
||||||
:key="section.key"
|
:options="formOptions"
|
||||||
:section="section"
|
:source="formData.source"
|
||||||
:model-value="sectionValue(section)"
|
:mode="mode"
|
||||||
:options="formOptions"
|
:uploading="false"
|
||||||
:source="formData.source"
|
:disabled="fieldsLocked"
|
||||||
:mode="mode"
|
:search-customers="searchProtocolCustomers"
|
||||||
:uploading="false"
|
@update:model-value="setSectionValue(section, $event)"
|
||||||
:disabled="fieldsLocked"
|
@upload="uploadField"
|
||||||
:search-customers="searchProtocolCustomers"
|
@field-change="handleFieldChange"
|
||||||
@update:model-value="setSectionValue(section, $event)"
|
@customer-select="handleCustomerSelect"
|
||||||
@upload="uploadField"
|
/>
|
||||||
@field-change="handleFieldChange"
|
<MarketFormSection
|
||||||
@customer-select="handleCustomerSelect"
|
v-else
|
||||||
/>
|
:section="section"
|
||||||
|
:model-value="sectionValue(section)"
|
||||||
|
:options="formOptions"
|
||||||
|
:source="formData.source"
|
||||||
|
:mode="mode"
|
||||||
|
:uploading="false"
|
||||||
|
:disabled="fieldsLocked"
|
||||||
|
:search-customers="searchProtocolCustomers"
|
||||||
|
:insert-before-keys="['protocolStatus', 'donationStatus']"
|
||||||
|
@update:model-value="setSectionValue(section, $event)"
|
||||||
|
@upload="uploadField"
|
||||||
|
@field-change="handleFieldChange"
|
||||||
|
@customer-select="handleCustomerSelect"
|
||||||
|
>
|
||||||
|
<template #insert>
|
||||||
|
<ProjectAssignmentField
|
||||||
|
ref="projectAssignment"
|
||||||
|
embedded
|
||||||
|
v-model="formData.projectId"
|
||||||
|
:biz-type="formData.source"
|
||||||
|
:editing="mode === 'edit'"
|
||||||
|
:record="formData"
|
||||||
|
:disabled="fieldsLocked"
|
||||||
|
@update:model-value="dirty = true"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</MarketFormSection>
|
||||||
|
</template>
|
||||||
|
|
||||||
<section
|
<section
|
||||||
v-if="context.module === 'protocol' && formData.source === 'cell_storage' && showDepositSection"
|
v-if="context.module === 'protocol' && formData.source === 'cell_storage' && showDepositSection"
|
||||||
|
|||||||
@@ -6,8 +6,6 @@
|
|||||||
:show-header="false"
|
:show-header="false"
|
||||||
>
|
>
|
||||||
<div class="market-list__filters">
|
<div class="market-list__filters">
|
||||||
<ProjectAssignmentField v-if="context.module === 'protocol'" v-model="listFilters.projectId"
|
|
||||||
:biz-type="listStatus" filter :context="context" @update:model-value="search" />
|
|
||||||
<div
|
<div
|
||||||
v-if="listFilterTabs.length"
|
v-if="listFilterTabs.length"
|
||||||
class="market-source-tabs"
|
class="market-source-tabs"
|
||||||
@@ -59,15 +57,24 @@
|
|||||||
<span v-if="activeFilters" class="market-list__filter-count">{{ activeFilters }}</span>
|
<span v-if="activeFilters" class="market-list__filter-count">{{ activeFilters }}</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="inlineDropdownFilters.length" class="market-list__filter-row">
|
<div
|
||||||
|
v-if="inlineDropdownFilters.length || showProtocolProjectFilter"
|
||||||
|
class="market-list__filter-row"
|
||||||
|
>
|
||||||
<van-dropdown-menu active-color="#0a9f6d">
|
<van-dropdown-menu active-color="#0a9f6d">
|
||||||
<van-dropdown-item
|
<van-dropdown-item
|
||||||
v-for="field in inlineDropdownFilters"
|
v-for="field in inlineDropdownFilters"
|
||||||
:key="field.key"
|
:key="`${field.source || 'all'}:${field.key}`"
|
||||||
:model-value="listFilters[field.key]"
|
:model-value="listFilters[field.key]"
|
||||||
:options="inlineFilterOptionsByKey[field.key] || []"
|
:options="inlineFilterOptionsByKey[field.key] || []"
|
||||||
@change="(value) => onInlineFilterChange(field.key, value)"
|
@change="(value) => onInlineFilterChange(field.key, value)"
|
||||||
/>
|
/>
|
||||||
|
<van-dropdown-item
|
||||||
|
v-if="showProtocolProjectFilter"
|
||||||
|
:model-value="listFilters.projectId || ''"
|
||||||
|
:options="protocolProjectFilterOptions"
|
||||||
|
@change="(value) => onInlineFilterChange('projectId', value)"
|
||||||
|
/>
|
||||||
</van-dropdown-menu>
|
</van-dropdown-menu>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -154,11 +161,15 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import ProjectAssignmentField from '../../market/components/ProjectAssignmentField.vue'
|
|
||||||
import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue'
|
import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue'
|
||||||
import { showConfirmDialog, showSuccessToast, showToast } from 'vant'
|
import { showConfirmDialog, showSuccessToast, showToast } from 'vant'
|
||||||
import { useRoute, useRouter } from 'vue-router'
|
import { useRoute, useRouter } from 'vue-router'
|
||||||
import { fetchMarketFormOptions, fetchMarketList, performMarketAction } from '../../api/market.js'
|
import {
|
||||||
|
fetchMarketFormOptions,
|
||||||
|
fetchMarketList,
|
||||||
|
fetchProjectOptions,
|
||||||
|
performMarketAction
|
||||||
|
} from '../../api/market.js'
|
||||||
import { intersectAllowedActions } from '../../market/action-policy.js'
|
import { intersectAllowedActions } from '../../market/action-policy.js'
|
||||||
import { deleteMarketItemsSequentially } from '../../market/batch-delete.js'
|
import { deleteMarketItemsSequentially } from '../../market/batch-delete.js'
|
||||||
import {
|
import {
|
||||||
@@ -169,6 +180,7 @@ import {
|
|||||||
import { marketSearchPlaceholder } from '../../market/list-presenter.js'
|
import { marketSearchPlaceholder } from '../../market/list-presenter.js'
|
||||||
import { marketErrorMessage } from '../../market/market-error.js'
|
import { marketErrorMessage } from '../../market/market-error.js'
|
||||||
import { getMarketModule } from '../../market/module-registry.js'
|
import { getMarketModule } from '../../market/module-registry.js'
|
||||||
|
import { projectOptions } from '../../market/project-assignment.js'
|
||||||
import {
|
import {
|
||||||
getMarketRouteContext,
|
getMarketRouteContext,
|
||||||
MARKET_MODULE_TITLES,
|
MARKET_MODULE_TITLES,
|
||||||
@@ -247,6 +259,12 @@ const inlineDropdownFilters = computed(() => {
|
|||||||
const source = listFilters.value.source || listStatus.value
|
const source = listFilters.value.source || listStatus.value
|
||||||
return rows.filter((field) => !field.source || field.source === source)
|
return rows.filter((field) => !field.source || field.source === source)
|
||||||
})
|
})
|
||||||
|
const showProtocolProjectFilter = computed(() => context.value.module === 'protocol')
|
||||||
|
const protocolProjectOptions = ref([])
|
||||||
|
const protocolProjectFilterOptions = computed(() => [
|
||||||
|
{ text: '全部项目', value: '' },
|
||||||
|
...protocolProjectOptions.value
|
||||||
|
])
|
||||||
const activeFilters = computed(() =>
|
const activeFilters = computed(() =>
|
||||||
activeFilterCount(context.value.module, listFilters.value)
|
activeFilterCount(context.value.module, listFilters.value)
|
||||||
)
|
)
|
||||||
@@ -299,6 +317,7 @@ const allDeletableSelected = computed(() =>
|
|||||||
)
|
)
|
||||||
let requestSequence = 0
|
let requestSequence = 0
|
||||||
let abortController = null
|
let abortController = null
|
||||||
|
let projectOptionsController = null
|
||||||
let searchTimer = null
|
let searchTimer = null
|
||||||
|
|
||||||
function normalizeList(result) {
|
function normalizeList(result) {
|
||||||
@@ -360,7 +379,32 @@ function queueSearch() {
|
|||||||
searchTimer = window.setTimeout(search, 350)
|
searchTimer = window.setTimeout(search, 350)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function loadProtocolProjectOptions() {
|
||||||
|
projectOptionsController?.abort()
|
||||||
|
if (!showProtocolProjectFilter.value) {
|
||||||
|
protocolProjectOptions.value = []
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const current = new AbortController()
|
||||||
|
projectOptionsController = current
|
||||||
|
const bizType = listFilters.value.source || listStatus.value || 'cell_storage'
|
||||||
|
try {
|
||||||
|
const data = await fetchProjectOptions(bizType, {
|
||||||
|
signal: current.signal,
|
||||||
|
filter: true,
|
||||||
|
context: context.value
|
||||||
|
})
|
||||||
|
if (projectOptionsController !== current) return
|
||||||
|
protocolProjectOptions.value = projectOptions(data)
|
||||||
|
} catch (error) {
|
||||||
|
if (projectOptionsController === current && error?.name !== 'AbortError') {
|
||||||
|
protocolProjectOptions.value = []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function loadListFilterOptions() {
|
async function loadListFilterOptions() {
|
||||||
|
await loadProtocolProjectOptions()
|
||||||
const optionKeys = [
|
const optionKeys = [
|
||||||
...sheetFilterFields.value.map((field) => field.optionKey),
|
...sheetFilterFields.value.map((field) => field.optionKey),
|
||||||
...inlineDropdownFilters.value.map((field) => field.optionKey)
|
...inlineDropdownFilters.value.map((field) => field.optionKey)
|
||||||
@@ -596,6 +640,7 @@ function switchListStatus(value) {
|
|||||||
tab: next
|
tab: next
|
||||||
}
|
}
|
||||||
router.replace({ query: nextQuery }).catch(() => {})
|
router.replace({ query: nextQuery }).catch(() => {})
|
||||||
|
loadProtocolProjectOptions()
|
||||||
loadPage(true)
|
loadPage(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -644,6 +689,7 @@ onBeforeUnmount(() => {
|
|||||||
const requestId = ++requestSequence
|
const requestId = ++requestSequence
|
||||||
listState.value = invalidateMarketRequestState(listState.value, requestId)
|
listState.value = invalidateMarketRequestState(listState.value, requestId)
|
||||||
abortController?.abort()
|
abortController?.abort()
|
||||||
|
projectOptionsController?.abort()
|
||||||
window.clearTimeout(searchTimer)
|
window.clearTimeout(searchTimer)
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
Reference in new issue
Block a user