同市易制毒段只校验购买证;同步 Web/H5 表单、额度统计展示与相关回归测试。 Co-authored-by: Cursor <cursoragent@cursor.com>
227 lines
7.5 KiB
Vue
227 lines
7.5 KiB
Vue
<template>
|
|
<div class="mp-stop-section">
|
|
<div class="mp-delivery-heading">
|
|
<h2>送货信息</h2>
|
|
<div
|
|
v-if="!c.props.readonly"
|
|
class="mp-plan-icon-actions"
|
|
role="group"
|
|
aria-label="送货段操作"
|
|
>
|
|
<button
|
|
class="mp-plan-icon-action is-primary"
|
|
type="button"
|
|
aria-label="添加送货段"
|
|
title="添加送货段"
|
|
@click="c.addDelivery"
|
|
><van-icon name="add-o"
|
|
/></button>
|
|
<button
|
|
class="mp-plan-icon-action"
|
|
type="button"
|
|
aria-label="上移送货段"
|
|
title="上移送货段"
|
|
:disabled="c.activeIndex === 0"
|
|
@click="c.moveDelivery(c.activeIndex, -1)"
|
|
><van-icon name="arrow-up"
|
|
/></button>
|
|
<button
|
|
class="mp-plan-icon-action"
|
|
type="button"
|
|
aria-label="下移送货段"
|
|
title="下移送货段"
|
|
:disabled="c.activeIndex >= c.props.modelValue.length - 1"
|
|
@click="c.moveDelivery(c.activeIndex, 1)"
|
|
><van-icon name="arrow-down"
|
|
/></button>
|
|
<button
|
|
class="mp-plan-icon-action is-danger"
|
|
type="button"
|
|
aria-label="删除送货段"
|
|
title="删除送货段"
|
|
:disabled="c.props.modelValue.length <= 1"
|
|
@click="c.removeDelivery(c.activeIndex)"
|
|
><van-icon name="delete-o"
|
|
/></button>
|
|
</div>
|
|
</div>
|
|
<div class="mp-stop-tabs"
|
|
><van-button
|
|
v-for="(item, i) in c.props.modelValue"
|
|
:key="i"
|
|
:type="c.activeIndex === i ? 'primary' : 'default'"
|
|
@click="c.activeIndex = i"
|
|
>#{{ i + 1 }} {{ item.customerName || '未选客户' }}</van-button
|
|
></div
|
|
>
|
|
<article
|
|
v-for="(delivery, index) in c.props.modelValue"
|
|
v-show="c.activeIndex === index"
|
|
:key="mobileStopIdentity(delivery)"
|
|
>
|
|
<van-cell
|
|
class="mp-stop-field-required"
|
|
title="送货客户"
|
|
:label="delivery.customerName || '请选择客户'"
|
|
is-link
|
|
clickable
|
|
@click="openCustomer(index)"
|
|
/>
|
|
<PlPlanContractMultiSelect
|
|
:model-value="delivery.contracts"
|
|
:customer-id="delivery.customerId"
|
|
:trading-entity-name="tradingEntityName"
|
|
:disabled="deliveryContractDisabled(delivery)"
|
|
:required="!!delivery.customerId && !isPlInternalCustomerName(delivery.customerName) && !deliveryContractDisabled(delivery)"
|
|
:readonly="c.props.readonly"
|
|
mobile-sheet
|
|
mobile
|
|
compact-summary
|
|
@update:model-value="c.patchDelivery(index, { contracts: $event })"
|
|
/>
|
|
<div class="mobile-pl-plan-grid">
|
|
<PlanDateField
|
|
:model-value="delivery.deliveryTime"
|
|
label="送货日期"
|
|
required
|
|
:readonly="c.props.readonly"
|
|
@update:model-value="c.patchDelivery(index, { deliveryTime: $event })"
|
|
/>
|
|
<van-field
|
|
:model-value="delivery.contact"
|
|
label="联系方式"
|
|
type="textarea"
|
|
rows="1"
|
|
autosize
|
|
:readonly="c.props.readonly"
|
|
@update:model-value="c.patchDelivery(index, { contact: $event })"
|
|
/>
|
|
</div>
|
|
<PlAddressWithLibrary
|
|
:model-value="delivery.address"
|
|
:lng="delivery.lng"
|
|
:lat="delivery.lat"
|
|
:contact="delivery.contact"
|
|
:disabled="c.props.readonly"
|
|
mobile
|
|
mobile-sheet
|
|
@apply="c.patchDeliveryAddress(index, $event)"
|
|
/>
|
|
<van-field
|
|
:model-value="delivery.notes"
|
|
label="注意事项"
|
|
type="textarea"
|
|
rows="1"
|
|
autosize
|
|
:readonly="c.props.readonly"
|
|
@update:model-value="c.patchDelivery(index, { notes: $event })"
|
|
/>
|
|
<van-cell class="mp-stop-toggle" title="是否同市" label="同市只需购买证"
|
|
><template #right-icon
|
|
><van-switch
|
|
:model-value="delivery.sameCity === 1"
|
|
:disabled="c.props.readonly"
|
|
@update:model-value="c.patchDelivery(index, { sameCity: $event ? 1 : 0 })" /></template
|
|
></van-cell>
|
|
<van-cell
|
|
class="mp-stop-toggle"
|
|
title="生成地磅单"
|
|
:label="c.directionLabel(delivery.dibangDirection)"
|
|
><template #right-icon
|
|
><van-switch
|
|
:model-value="delivery.generateDibang === 1"
|
|
:disabled="c.props.readonly || !c.canManualDibang(delivery.customerName)"
|
|
@update:model-value="c.handleDibangToggle(index, $event)" /></template
|
|
></van-cell>
|
|
<van-button
|
|
v-if="!c.props.readonly"
|
|
block
|
|
plain
|
|
type="primary"
|
|
icon="plus"
|
|
@click="c.handleSelectProductsClick(index)"
|
|
>送货产品</van-button
|
|
>
|
|
<PlPlanStopProductTable
|
|
mobile-delivery
|
|
mobile
|
|
:products="delivery.products"
|
|
:editable="!c.props.readonly"
|
|
:contracts="delivery.contracts"
|
|
:contract-id="c.deliveryContractId(delivery)"
|
|
:exclude-plan-id="c.props.excludePlanId"
|
|
:contract-product-rows="c.contractProductRowsFor(delivery)"
|
|
@remove="c.removeStopProduct(index, $event)"
|
|
/>
|
|
</article>
|
|
<PlanFormPickerSheets
|
|
v-model:show="customerOpen"
|
|
title="选择客户"
|
|
customer
|
|
:context="customerSession"
|
|
@confirm="confirmCustomer"
|
|
/>
|
|
</div>
|
|
</template>
|
|
<script setup lang="ts">
|
|
import PlanDateField from './PlanDateField.vue'
|
|
import { mobileStopIdentity } from './mobileStopIdentity'
|
|
import PlPlanContractMultiSelect from '@/components/business/pl-plan-contract-multi-select/index.vue'
|
|
import PlPlanStopProductTable from '@/components/business/pl-plan-stop-product-table/index.vue'
|
|
import PlAddressWithLibrary from '@/components/business/pl-address-with-library/index.vue'
|
|
import PlanFormPickerSheets from './PlanFormPickerSheets.vue'
|
|
import { isPlInternalCustomerName } from '@/utils/pl-internal-customer'
|
|
import { tradingEntityNameForBelongsCompany } from '@/utils/pl-belongs-company'
|
|
const props = defineProps<{ controller: any }>()
|
|
const c = props.controller
|
|
const tradingEntityName = computed(() =>
|
|
c.props.belongsCompany === undefined
|
|
? undefined
|
|
: tradingEntityNameForBelongsCompany(c.props.belongsCompany)
|
|
)
|
|
|
|
function deliveryContractDisabled(delivery: { customerId?: string; customerName?: string }) {
|
|
return (
|
|
!delivery.customerId ||
|
|
isPlInternalCustomerName(delivery.customerName) ||
|
|
(tradingEntityName.value !== undefined && !tradingEntityName.value)
|
|
)
|
|
}
|
|
const customerOpen = ref(false)
|
|
const customerSession = ref(0)
|
|
let target: any = null
|
|
function openCustomer(index = 0) {
|
|
target = mobileStopIdentity(c.props.modelValue[index])
|
|
customerSession.value++
|
|
customerOpen.value = true
|
|
}
|
|
function confirmCustomer(customer: any) {
|
|
const index = c.props.modelValue.findIndex((row) => mobileStopIdentity(row) === target)
|
|
if (index >= 0) c.applyCustomerFromPicker(index, customer)
|
|
}
|
|
</script>
|
|
<style scoped lang="scss" src="./mobile-stops.scss"></style>
|
|
|
|
<style scoped lang="scss">
|
|
.mp-delivery-heading {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
gap: 4px;
|
|
min-width: 0;
|
|
}
|
|
.mp-delivery-heading h2 {
|
|
flex-shrink: 0;
|
|
margin: 0;
|
|
padding-left: 8px;
|
|
border-left: 3px solid #0a9f6d;
|
|
font-size: 14px;
|
|
line-height: 20px;
|
|
}
|
|
.mp-delivery-heading .mp-plan-icon-actions {
|
|
flex: none;
|
|
flex-wrap: nowrap;
|
|
justify-content: flex-end;
|
|
}
|
|
</style>
|