|
|
@@ -7,7 +7,41 @@
|
|
|
<Form ref="formRef" class="g-form__container" @submit="formSubmit">
|
|
|
<CellGroup inset>
|
|
|
<Field v-model="formData.InUserID" :rules="formRules.InUserID" name="InUserID" label="转入客户"
|
|
|
- placeholder="必填" />
|
|
|
+ right-icon="arrow" clickable @click="showSearch = true">
|
|
|
+ <template #input>
|
|
|
+ <input placeholder="请选择" :value="selectedUser?.customername" readonly />
|
|
|
+ </template>
|
|
|
+ </Field>
|
|
|
+ <Field name="GoodsID" label="转让商品" :rules="formRules.GoodsID" is-link>
|
|
|
+ <template #input>
|
|
|
+ <app-select v-model="formData.GoodsID" :options="goodsList" :optionProps="{ value: 'goodsid' }"
|
|
|
+ @confirm="onGoodsChange" />
|
|
|
+ </template>
|
|
|
+ </Field>
|
|
|
+ <Field label="可用数量">
|
|
|
+ <template #input>
|
|
|
+ <span>{{ enableqty }}</span>
|
|
|
+ </template>
|
|
|
+ </Field>
|
|
|
+ <Field name="Qty" :rules="formRules.Qty" label="转让数量">
|
|
|
+ <template #input>
|
|
|
+ <Stepper v-model="formData.Qty" theme="round" :min="0" :max="enableqty" :default-value="0"
|
|
|
+ :auto-fixed="false" button-size="22" />
|
|
|
+ </template>
|
|
|
+ </Field>
|
|
|
+ <Field name="TransferPrice" :rules="formRules.TransferPrice" label="转让价格">
|
|
|
+ <template #input>
|
|
|
+ <Stepper v-model="formData.TransferPrice" theme="round" :min="0"
|
|
|
+ :decimal-length="selectedGoods?.decimalplace" :default-value="0" :auto-fixed="false"
|
|
|
+ button-size="22" />
|
|
|
+ </template>
|
|
|
+ </Field>
|
|
|
+ <Field name="FreezeDays" :rules="formRules.FreezeDays" label="冻结天数">
|
|
|
+ <template #input>
|
|
|
+ <Stepper v-model="formData.FreezeDays" theme="round" :min="0" :default-value="0"
|
|
|
+ :auto-fixed="false" button-size="22" />
|
|
|
+ </template>
|
|
|
+ </Field>
|
|
|
</CellGroup>
|
|
|
</Form>
|
|
|
<template #footer>
|
|
|
@@ -16,31 +50,39 @@
|
|
|
</div>
|
|
|
</template>
|
|
|
</app-view>
|
|
|
+ <Search v-model:show="showSearch" @change="onUserChange" />
|
|
|
</app-modal>
|
|
|
</template>
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
-import { shallowRef, reactive, computed } from 'vue'
|
|
|
-import { CellGroup, Button, Field, Form, FormInstance, FieldRule } from 'vant'
|
|
|
-import { fullloading, dialog } from '@/utils/vant'
|
|
|
+import { shallowRef, reactive, computed, defineAsyncComponent } from 'vue'
|
|
|
+import { CellGroup, Button, Field, Form, Stepper, FieldRule } from 'vant'
|
|
|
+import { fullloading } from '@/utils/vant'
|
|
|
import { BuyOrSell } from '@/constants/order'
|
|
|
-import { useRequest } from '@/hooks/request'
|
|
|
import { holderTransferApply } from '@/services/api/trade'
|
|
|
-import { getUserInfo } from '@/services/api/user'
|
|
|
import { usePosition } from '@/business/position'
|
|
|
import { useLoginStore } from '@/stores'
|
|
|
import AppModal from '@/components/base/modal/index.vue'
|
|
|
+import AppSelect from '@mobile/components/base/select/index.vue'
|
|
|
+
|
|
|
+// 搜索客户
|
|
|
+const Search = defineAsyncComponent(() => import('./serach/index.vue'))
|
|
|
|
|
|
const showModal = shallowRef(true)
|
|
|
+const showSearch = shallowRef(false) // 弹出客户搜索界面
|
|
|
const refresh = shallowRef(false) // 是否刷新父组件数据
|
|
|
const formRef = shallowRef()
|
|
|
const loginStore = useLoginStore()
|
|
|
const { positionList } = usePosition(16)
|
|
|
+const selectedUser = shallowRef<Model.UserInfoRsp>() // 当前选择的转入客户
|
|
|
|
|
|
// 可用商品列表
|
|
|
-const goodsList = computed(() => positionList.value.filter((e) => e.enableqty > 0))
|
|
|
+const goodsList = computed(() => positionList.value.filter((e) => e.enableqty > 0).map((e) => ({
|
|
|
+ ...e,
|
|
|
+ label: `${e.goodscode}/${e.goodsname}`
|
|
|
+})))
|
|
|
// 选中的商品
|
|
|
-const selectedGoods = shallowRef<Model.TradePositionRsp>()
|
|
|
+const selectedGoods = computed(() => goodsList.value.find((e) => e.goodsid === formData.GoodsID))
|
|
|
//可用数量
|
|
|
const enableqty = computed(() => selectedGoods.value?.enableqty ?? 0)
|
|
|
|
|
|
@@ -52,30 +94,54 @@ const formData = reactive<Partial<Proto.HolderTransferDetail>>({
|
|
|
|
|
|
// 表单验证规则
|
|
|
const formRules: { [key: string]: FieldRule[] } = {
|
|
|
- ReceiverName: [{
|
|
|
- required: true,
|
|
|
- message: '请输入收货人',
|
|
|
+ InUserID: [{
|
|
|
+ message: '请输入客户编号或手机号',
|
|
|
+ validator: () => !!formData.InUserID
|
|
|
+ }],
|
|
|
+ GoodsID: [{
|
|
|
+ message: '请选择转让商品',
|
|
|
+ validator: () => !!selectedGoods.value
|
|
|
}],
|
|
|
- Address: [{
|
|
|
- required: true,
|
|
|
- message: '请输入详细地址',
|
|
|
+ TransferPrice: [{
|
|
|
+ message: '请输入转让价格',
|
|
|
+ validator: () => formData.TransferPrice ? !!Number(formData.TransferPrice) : false
|
|
|
}],
|
|
|
+ Qty: [{
|
|
|
+ message: '请输入转让数量',
|
|
|
+ validator: () => !!formData.Qty
|
|
|
+ }],
|
|
|
+ FreezeDays: [{
|
|
|
+ message: '请输入冻结天数',
|
|
|
+ required: true
|
|
|
+ }]
|
|
|
+}
|
|
|
+
|
|
|
+// 选择商品时触发
|
|
|
+const onGoodsChange = () => {
|
|
|
+ if ((formData.Qty ?? 0) > enableqty.value) {
|
|
|
+ formData.Qty = enableqty.value
|
|
|
+ }
|
|
|
+ formRef.value?.validate('GoodsID')
|
|
|
+}
|
|
|
+
|
|
|
+// 选择客户时触发
|
|
|
+const onUserChange = (item: Model.UserInfoRsp) => {
|
|
|
+ formData.InUserID = Number(item.userid)
|
|
|
+ selectedUser.value = item
|
|
|
}
|
|
|
|
|
|
// 表单提交
|
|
|
const formSubmit = () => {
|
|
|
fullloading((hideLoading) => {
|
|
|
- const { marketid, goodsid } = selectedGoods.value ?? {}
|
|
|
- formData.GoodsID = goodsid
|
|
|
holderTransferApply({
|
|
|
data: {
|
|
|
Header: {
|
|
|
- MarketID: marketid
|
|
|
+ MarketID: selectedGoods.value?.marketid ?? 0
|
|
|
},
|
|
|
HolderTransferDetails: [formData]
|
|
|
}
|
|
|
}).then(() => {
|
|
|
- hideLoading()
|
|
|
+ hideLoading('提交成功,请稍后查询结果', 'success')
|
|
|
closed(true)
|
|
|
}).catch((err) => {
|
|
|
hideLoading(err, 'fail')
|
|
|
@@ -86,7 +152,12 @@ const formSubmit = () => {
|
|
|
// 关闭弹窗
|
|
|
const closed = (isRefresh = false) => {
|
|
|
refresh.value = isRefresh
|
|
|
- showModal.value = false
|
|
|
+ if (showSearch.value) {
|
|
|
+ showSearch.value = false
|
|
|
+ } else {
|
|
|
+ refresh.value = isRefresh
|
|
|
+ showModal.value = false
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// 暴露组件属性给父组件调用
|