|
|
@@ -0,0 +1,159 @@
|
|
|
+<template>
|
|
|
+ <app-view class="g-form">
|
|
|
+ <Form ref="formRef" class="g-form__container" @submit="formSubmit">
|
|
|
+ <CellGroup inset>
|
|
|
+ <Field name="DeliveryGoodsID" label="品类" :rules="formRules.DeliveryGoodsID" is-link>
|
|
|
+ <template #input>
|
|
|
+ <app-select v-model="formData.DeliveryGoodsID" :options="ftDeliveryGoodsList"
|
|
|
+ :optionProps="{ label: 'deliverygoodsname', value: 'deliverygoodsid' }"
|
|
|
+ @confirm="onDeliveryGoodsChange" />
|
|
|
+ </template>
|
|
|
+ </Field>
|
|
|
+ <Field name="WRStandardID" label="商品" :rules="formRules.WRStandardID" is-link
|
|
|
+ v-if="formData.DeliveryGoodsID">
|
|
|
+ <template #input>
|
|
|
+ <app-select v-model="formData.WRStandardID" :options="goodsList"
|
|
|
+ :optionProps="{ label: 'wrstandardname', value: 'wrstandardid' }" @confirm="onGoodsChange" />
|
|
|
+ </template>
|
|
|
+ </Field>
|
|
|
+ <Field name="FactoryItems" label="仓库" :rules="formRules.FactoryItems" is-link v-if="formData.WRStandardID">
|
|
|
+ <template #input>
|
|
|
+ <app-select :options="warehouseList"
|
|
|
+ :optionProps="{ label: 'dgfactoryitemvalue', value: 'dgfactoryitemid' }"
|
|
|
+ @confirm="onWarehouseChange" />
|
|
|
+ </template>
|
|
|
+ </Field>
|
|
|
+ <Field name="FixedPrice" :rules="formRules.FixedPrice" label="价格">
|
|
|
+ <template #input>
|
|
|
+ <Stepper v-model="formData.FixedPrice" theme="round" :min="0" :decimal-length="2" :default-value="0"
|
|
|
+ :auto-fixed="false" button-size="22" />
|
|
|
+ </template>
|
|
|
+ </Field>
|
|
|
+ <Field name="OrderQty" :rules="formRules.OrderQty" label="数量">
|
|
|
+ <template #input>
|
|
|
+ <Stepper v-model="formData.OrderQty" theme="round" button-size="22" :min="0" :default-value="0"
|
|
|
+ :auto-fixed="false" integer />
|
|
|
+ </template>
|
|
|
+ </Field>
|
|
|
+ <Field label="货款金额">
|
|
|
+ <template #input>
|
|
|
+ <span>{{ amount }}元</span>
|
|
|
+ </template>
|
|
|
+ </Field>
|
|
|
+ <Field label="可用资金">
|
|
|
+ <template #input>
|
|
|
+ <span>{{ accountStore.avaiableMoney.toFixed(2) }}元</span>
|
|
|
+ </template>
|
|
|
+ </Field>
|
|
|
+ </CellGroup>
|
|
|
+ </Form>
|
|
|
+ <template #footer>
|
|
|
+ <div class="g-form__footer">
|
|
|
+ <Button type="primary" @click="formRef?.submit" round block>提交</Button>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </app-view>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script lang="ts" setup>
|
|
|
+import { shallowRef, computed } from 'vue'
|
|
|
+import { CellGroup, Button, Field, Form, FormInstance, Stepper, FieldRule, showSuccessToast, showFailToast } from 'vant'
|
|
|
+import { fullloading } from '@/utils/vant'
|
|
|
+import { BuyOrSell } from '@/constants/order'
|
|
|
+import { useNavigation } from '@/hooks/navigation'
|
|
|
+import { useRequest } from '@/hooks/request'
|
|
|
+import { queryFtDeliveryGoods, queryWrStandardFactoryItem } from '@/services/api/goods'
|
|
|
+import { useHdWROrder } from '@/business/trade'
|
|
|
+import { useAccountStore } from '@/stores'
|
|
|
+import AppSelect from '@mobile/components/base/select/index.vue'
|
|
|
+
|
|
|
+const { routerBack } = useNavigation()
|
|
|
+const { formData, listingSubmit, amount } = useHdWROrder()
|
|
|
+const accountStore = useAccountStore()
|
|
|
+const formRef = shallowRef<FormInstance>()
|
|
|
+
|
|
|
+const { dataList: ftDeliveryGoodsList } = useRequest(queryFtDeliveryGoods)
|
|
|
+const { dataList: wrStandardFactoryItems, run: getWrStandardFactoryItems } = useRequest(queryWrStandardFactoryItem, { manual: true })
|
|
|
+
|
|
|
+const goodsList = shallowRef<Model.FtDeliveryGoodsRsp['wdlst']>([]) // 商品列表
|
|
|
+
|
|
|
+// 仓库列表
|
|
|
+const warehouseList = computed(() => {
|
|
|
+ return wrStandardFactoryItems.value.reduce((res, item) => [...res, ...item.itemlst], [] as Model.WrStandardFactoryItemRsp['itemlst'])
|
|
|
+})
|
|
|
+
|
|
|
+// 表单验证规则
|
|
|
+const formRules: { [key in keyof Proto.HdWROrderReq]?: FieldRule[] } = {
|
|
|
+ DeliveryGoodsID: [{
|
|
|
+ message: '请选择品类',
|
|
|
+ validator: () => {
|
|
|
+ return !!formData.DeliveryGoodsID
|
|
|
+ }
|
|
|
+ }],
|
|
|
+ WRStandardID: [{
|
|
|
+ message: '请选择商品',
|
|
|
+ validator: () => {
|
|
|
+ return !!formData.WRStandardID
|
|
|
+ }
|
|
|
+ }],
|
|
|
+ FactoryItems: [{
|
|
|
+ message: '请选择仓库',
|
|
|
+ validator: () => {
|
|
|
+ return !!formData.FactoryItems
|
|
|
+ }
|
|
|
+ }],
|
|
|
+ FixedPrice: [{
|
|
|
+ message: '请输入价格',
|
|
|
+ validator: () => {
|
|
|
+ return !!formData.FixedPrice
|
|
|
+ }
|
|
|
+ }],
|
|
|
+ OrderQty: [{
|
|
|
+ message: '请输入数量',
|
|
|
+ validator: () => {
|
|
|
+ return !!formData.OrderQty
|
|
|
+ }
|
|
|
+ }],
|
|
|
+}
|
|
|
+
|
|
|
+// 选择品类时触发
|
|
|
+const onDeliveryGoodsChange = (deliverygoodsid: number) => {
|
|
|
+ const item = ftDeliveryGoodsList.value.find((e) => e.deliverygoodsid === deliverygoodsid)
|
|
|
+ if (item) {
|
|
|
+ goodsList.value = item.wdlst
|
|
|
+ }
|
|
|
+ formData.WRStandardID = undefined
|
|
|
+ formData.FactoryItems = undefined
|
|
|
+ formRef.value?.validate('DeliveryGoodsID')
|
|
|
+}
|
|
|
+
|
|
|
+// 选择商品时触发
|
|
|
+const onGoodsChange = (wrstandardid: number) => {
|
|
|
+ formData.FactoryItems = undefined
|
|
|
+ getWrStandardFactoryItems({ wrstandardid })
|
|
|
+ formRef.value?.validate('WRStandardID')
|
|
|
+}
|
|
|
+
|
|
|
+// 选择仓库时触发
|
|
|
+const onWarehouseChange = (dgfactoryitemid: number) => {
|
|
|
+ formData.FactoryItems = [{
|
|
|
+ DGFactoryItemTypeID: 1, // 要素项类型ID
|
|
|
+ DGFactoryItemID: dgfactoryitemid, // 预约要素项类型值
|
|
|
+ ItemTypeMode: 1, // 要素项类型模式
|
|
|
+ }]
|
|
|
+ formRef.value?.validate('FactoryItems')
|
|
|
+}
|
|
|
+
|
|
|
+// 表单提交
|
|
|
+const formSubmit = () => {
|
|
|
+ formData.BuyOrSell = BuyOrSell.Buy
|
|
|
+ fullloading(() => {
|
|
|
+ listingSubmit().then(() => {
|
|
|
+ showSuccessToast('挂牌提交成功。')
|
|
|
+ routerBack()
|
|
|
+ }).catch((err) => {
|
|
|
+ showFailToast(err)
|
|
|
+ })
|
|
|
+ })
|
|
|
+}
|
|
|
+</script>
|