|
|
@@ -1,7 +1,219 @@
|
|
|
<!-- 我的持仓-现货持仓-提货 -->
|
|
|
<template>
|
|
|
- 提货
|
|
|
+ <app-modal direction="right" height="100%" v-model:show="showModal" :refresh="refresh">
|
|
|
+ <template #default="{ animation }">
|
|
|
+ <app-view class="g-form">
|
|
|
+ <template #header>
|
|
|
+ <app-navbar title="挂牌" @back="closed" />
|
|
|
+ </template>
|
|
|
+ <Form ref="formRef" class="g-form__container" @submit="onSubmit">
|
|
|
+ <CellGroup title="现货持仓信息" inset>
|
|
|
+ <Cell title="商品代码/名称" :value="selectedRow.wrstandardname" />
|
|
|
+ <Cell title="仓库" :value="selectedRow.warehousename" />
|
|
|
+ <Cell title="库存量" :value="selectedRow.qty" />
|
|
|
+ <Cell title="冻结量" :value="selectedRow.freezerqty" />
|
|
|
+ <Cell title="可用量" :value="selectedRow.enableqty" />
|
|
|
+ </CellGroup>
|
|
|
+ <CellGroup title="挂牌信息" inset>
|
|
|
+ <Field name="OrderQty" :rules="formRules.orderQty" label="提货数量">
|
|
|
+ <template #input>
|
|
|
+ <Stepper v-model="orderQty" theme="round" button-size="22" :auto-fixed="false" integer />
|
|
|
+ </template>
|
|
|
+ </Field>
|
|
|
+ <Field label="提货方式" is-link>
|
|
|
+ <template #input>
|
|
|
+ <app-select v-model="formData.AppointmentModel" :options="getAppointmentModelOutList()" />
|
|
|
+ </template>
|
|
|
+ </Field>
|
|
|
+ <Field name="ContractName" label="联系人" v-model="formData.ContactName" placeholder="必填"
|
|
|
+ :rules="formRules.ContactName" right-icon="add-o" @click-right-icon="showContact = true" />
|
|
|
+ <Field name="ContactNum" label="联系方式" v-model="formData.ContactNum" placeholder="必填"
|
|
|
+ :rules="formRules.ContactNum" />
|
|
|
+ <template v-if="formData.AppointmentModel === 1">
|
|
|
+ <Field :rules="formRules.Region" name="Region" label="收货地区" is-link v-if="!animation">
|
|
|
+ <template #input>
|
|
|
+ <component :is="AppRegion" v-model="formData.DistrictID" v-model:label="regionName"
|
|
|
+ @finish="onRegionFinish" />
|
|
|
+ </template>
|
|
|
+ </Field>
|
|
|
+ <Field name="Address" type="textarea" label="收货地址" row="2" v-model="formData.Address"
|
|
|
+ placeholder="必填" :rules="formRules.Address" />
|
|
|
+ </template>
|
|
|
+ <Field name="AppointmentRemark" type="textarea" label="发票信息" rows="2" autosize
|
|
|
+ v-model="formData.AppointmentRemark" placeholder="必填" :rules="formRules.AppointmentRemark"
|
|
|
+ right-icon="add-o" @click-right-icon="showReceipt = true" />
|
|
|
+ </CellGroup>
|
|
|
+ </Form>
|
|
|
+ <template #footer>
|
|
|
+ <div class="g-form__footer">
|
|
|
+ <Button block round type="primary" @click="formRef?.submit">提货</Button>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </app-view>
|
|
|
+ <app-contact v-model:show="showContact" @change="contactChange" />
|
|
|
+ <app-receipt v-model:show="showReceipt" @change="receiptChange" />
|
|
|
+ </template>
|
|
|
+ </app-modal>
|
|
|
</template>
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
+import { shallowRef, PropType, defineAsyncComponent } from 'vue'
|
|
|
+import { CellGroup, Cell, Button, Stepper, Field, Form, FormInstance, FieldRule } from 'vant'
|
|
|
+import { fullloading } from '@/utils/vant'
|
|
|
+import { validateRules } from '@/constants/regex'
|
|
|
+import { getReceiptTypeName } from '@/constants/receipt'
|
|
|
+import { getAppointmentModelOutList } from '@/constants/order'
|
|
|
+import { useWrOutInApply } from '@/business/trade'
|
|
|
+import AppModal from '@/components/base/modal/index.vue'
|
|
|
+import AppSelect from '@mobile/components/base/select/index.vue'
|
|
|
+import AppContact from '@mobile/components/modules/contact/index.vue'
|
|
|
+import AppReceipt from '@mobile/components/modules/receipt/index.vue'
|
|
|
+
|
|
|
+// 地区选择
|
|
|
+const AppRegion = defineAsyncComponent(() => import('@mobile/components/base/region/index.vue'))
|
|
|
+
|
|
|
+const props = defineProps({
|
|
|
+ selectedRow: {
|
|
|
+ type: Object as PropType<Model.HoldLBRsp>,
|
|
|
+ required: true,
|
|
|
+ }
|
|
|
+})
|
|
|
+
|
|
|
+const { formData, applySubmit, orderQty } = useWrOutInApply(props.selectedRow)
|
|
|
+const formRef = shallowRef<FormInstance>()
|
|
|
+const showModal = shallowRef(true)
|
|
|
+const showContact = shallowRef(false) // 显示联系人选择列表
|
|
|
+const showReceipt = shallowRef(false) // 显示发票选择列表
|
|
|
+const refresh = shallowRef(false) // 是否刷新父组件数据
|
|
|
+const regionName = shallowRef('') // 地区名称
|
|
|
+
|
|
|
+// 表单验证规则
|
|
|
+const formRules: { [key in keyof Proto.WROutApplyReq | 'orderQty' | 'Region']?: FieldRule[] } = {
|
|
|
+ orderQty: [{
|
|
|
+ message: '请输入提货数量',
|
|
|
+ validator: () => {
|
|
|
+ return !!orderQty.value
|
|
|
+ }
|
|
|
+ }],
|
|
|
+ ContactName: [{
|
|
|
+ required: true,
|
|
|
+ message: '请输入联系人',
|
|
|
+ }],
|
|
|
+ ContactNum: [{
|
|
|
+ required: true,
|
|
|
+ message: '请输入联系方式',
|
|
|
+ validator: (val) => {
|
|
|
+ if (validateRules.phone.validate(val)) {
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ return validateRules.phone.message
|
|
|
+ }
|
|
|
+ }],
|
|
|
+ Region: [{
|
|
|
+ message: '请选择收货地区',
|
|
|
+ validator: () => {
|
|
|
+ return !!formData.ProvinceID && !!formData.CityID && !!formData.DistrictID
|
|
|
+ }
|
|
|
+ }],
|
|
|
+ Address: [{
|
|
|
+ required: true,
|
|
|
+ message: '请输入收货地址',
|
|
|
+ }],
|
|
|
+ AppointmentRemark: [{
|
|
|
+ required: true,
|
|
|
+ message: '请输入发票信息',
|
|
|
+ }],
|
|
|
+}
|
|
|
+
|
|
|
+// 选择地区
|
|
|
+const onRegionFinish = ([province, city, district]: number[]) => {
|
|
|
+ formData.ProvinceID = province
|
|
|
+ formData.CityID = city
|
|
|
+ formData.DistrictID = district
|
|
|
+ formRef.value?.validate('Region')
|
|
|
+}
|
|
|
+
|
|
|
+// 选择联系信息
|
|
|
+const contactChange = (item: Model.UserReceiveInfoRsp) => {
|
|
|
+ formData.ContactName = item.receivername
|
|
|
+ formData.ContactNum = item.phonenum
|
|
|
+ formData.ProvinceID = item.provinceid
|
|
|
+ formData.CityID = item.cityid
|
|
|
+ formData.DistrictID = item.districtid
|
|
|
+ formData.Address = item.address
|
|
|
+ regionName.value = [item.provincename, item.cityname, item.districtname].join(' ')
|
|
|
+ formRef.value?.validate('Region')
|
|
|
+}
|
|
|
+
|
|
|
+// 选择发票信息
|
|
|
+const receiptChange = (item: Model.WrUserReceiptInfoRsp) => {
|
|
|
+ formData.AppointmentRemark = ''
|
|
|
+ Object.entries(item).forEach(([key, value]) => {
|
|
|
+ if (value !== '') {
|
|
|
+ switch (key) {
|
|
|
+ case 'receipttype': {
|
|
|
+ formData.AppointmentRemark += '发票类型:' + getReceiptTypeName(Number(value)) + '\n'
|
|
|
+ break
|
|
|
+ }
|
|
|
+ case 'username': {
|
|
|
+ formData.AppointmentRemark += '发票抬头:' + value + '\n'
|
|
|
+ break
|
|
|
+ }
|
|
|
+ case 'taxpayerid': {
|
|
|
+ formData.AppointmentRemark += '税号:' + value + '\n'
|
|
|
+ break
|
|
|
+ }
|
|
|
+ case 'receiptbank': {
|
|
|
+ formData.AppointmentRemark += '开户银行:' + value + '\n'
|
|
|
+ break
|
|
|
+ }
|
|
|
+ case 'receiptaccount': {
|
|
|
+ formData.AppointmentRemark += '银行账号:' + value + '\n'
|
|
|
+ break
|
|
|
+ }
|
|
|
+ case 'address': {
|
|
|
+ formData.AppointmentRemark += '企业地址:' + value + '\n'
|
|
|
+ break
|
|
|
+ }
|
|
|
+ case 'contactinfo': {
|
|
|
+ formData.AppointmentRemark += '企业电话:' + value + '\n'
|
|
|
+ break
|
|
|
+ }
|
|
|
+ case 'email': {
|
|
|
+ formData.AppointmentRemark += '邮箱:' + value + '\n'
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+const onSubmit = () => {
|
|
|
+ fullloading((hideLoading) => {
|
|
|
+ applySubmit().then(() => {
|
|
|
+ hideLoading('挂牌成功', 'success')
|
|
|
+ closed(true)
|
|
|
+ }).catch((err) => {
|
|
|
+ hideLoading(err, 'fail')
|
|
|
+ })
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// 关闭弹窗
|
|
|
+const closed = (isRefresh = false) => {
|
|
|
+ refresh.value = isRefresh
|
|
|
+ if (showContact.value) {
|
|
|
+ showContact.value = false
|
|
|
+ } else if (showReceipt.value) {
|
|
|
+ showReceipt.value = false
|
|
|
+ } else {
|
|
|
+ refresh.value = isRefresh
|
|
|
+ showModal.value = false
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// 暴露组件属性给父组件调用
|
|
|
+defineExpose({
|
|
|
+ closed,
|
|
|
+})
|
|
|
</script>
|