Handy_Cao пре 2 година
родитељ
комит
67ec8b5207

+ 25 - 0
src/packages/mobile/views/spot/add/components/buy/index.vue

@@ -13,6 +13,8 @@
                         </template>
                     </Field>
                 </template>
+                <Field name="PerformanceTemplateID" label="履约模板" placeholder="请选择" v-model="formData.PerformanceTemplateID" :rules="formRules.PerformanceTemplateID"
+                 @click="showPerformancePlan = true" is-link readonly />
                 <Field name="FixedPrice" :rules="formRules.FixedPrice" label="价格">
                     <template #input>
                         <Stepper v-model="formData.FixedPrice" theme="round" :min="0" :decimal-length="2" :default-value="0"
@@ -38,6 +40,7 @@
             </div>
         </template>
         <component :is="WarehouseReceipt" v-model:show="showWarehouseReceipt" @change="onChange" />
+        <component :is="PerformanceTmp" v-model:show="showPerformancePlan" @change="onPerformanceTmpChange" />
     </app-view>
 </template>
 
@@ -50,12 +53,15 @@ import { useNavigation } from '../../../../../router/navigation'
 import { useHdWROrder } from '@/business/trade'
 
 const WarehouseReceipt = defineAsyncComponent(() => import('./warehouse-receipt.vue'))
+const PerformanceTmp = defineAsyncComponent(() => import('../preformance/index.vue'))
 
 const { routerBack } = useNavigation()
 const { formData, listingSubmit, amount } = useHdWROrder()
 const formRef = shallowRef<FormInstance>()
 const showWarehouseReceipt = shallowRef(false)
+const showPerformancePlan = shallowRef(false)
 const selectedRow = shallowRef<Partial<Model.HoldLBRsp>>({}) //选中的现货仓单
+const performance = shallowRef<Partial<Model.PerformancePlanRsp>>({}) //选中的履约模板
 
 // 表单验证规则
 const formRules: { [key in keyof Proto.HdWROrderReq]?: FieldRule[] } = {
@@ -65,6 +71,12 @@ const formRules: { [key in keyof Proto.HdWROrderReq]?: FieldRule[] } = {
             return !!selectedRow.value.wrfactortypeid
         }
     }],
+    PerformanceTemplateID: [{
+        message: '请选择履约模板',
+        validator: () => {
+            return !!formData.PerformanceTemplateID
+        }
+    }],
     FixedPrice: [{
         message: '请输入价格',
         validator: () => {
@@ -96,6 +108,16 @@ const onChange = (item: Model.HoldLBRsp) => {
     showWarehouseReceipt.value = false
 }
 
+// 选择履约模板
+const onPerformanceTmpChange = (item: Model.PermancePlanTmpRsp) => {
+    performance.value = item
+    formData.PerformanceTemplateID = item.autoid
+    if (formData.PerformanceTemplateID) {
+        formRef.value?.validate('PerformanceTemplateID')
+    }
+    showPerformancePlan.value = false
+}
+
 // 表单提交
 const formSubmit = () => {
     const { wrstandardid, subnum, deliverygoodsid, ladingbillid = '0', wrfactortypeid = '0' } = selectedRow.value
@@ -120,6 +142,9 @@ onBeforeRouteLeave((to, from, next) => {
     if (showWarehouseReceipt.value) {
         showWarehouseReceipt.value = false
         next(false)
+    } else if (showPerformancePlan.value) {
+        showPerformancePlan.value = false
+        next(false)
     } else {
         next()
     }

+ 47 - 0
src/packages/mobile/views/spot/add/components/preformance/index.vue

@@ -0,0 +1,47 @@
+<template>
+    <app-modal direction="right" height="100%">
+        <app-view class="g-form">
+            <template #header>
+                <app-navbar title="选择履约模板" />
+            </template>
+            <RadioGroup class="g-form__container" v-model="checkedRow" v-if="dataList.length">
+                <CellGroup v-for="(item, index) in dataList" :key="index" @click="onChange(item)" inset>
+                    <Cell>
+                        <template #title>
+                            <Radio :name="item" checked-color="#ee0a24">
+                                <ul style="margin-left: .2rem;">
+                                    <li>
+                                        <span>名称:</span>
+                                        <span>{{ item.templatename }}</span>
+                                    </li>
+                                    <ul v-for="(step, i) in item.LstStep" :key="i">
+                                        <span>{{ step.stepinfo }}</span>
+                                        <span>{{ step.stepdate }}</span>
+                                    </ul>
+                                </ul>
+                            </Radio>
+                        </template>
+                    </Cell>
+                </CellGroup>
+            </RadioGroup>
+        </app-view>
+    </app-modal>
+</template>
+
+<script lang="ts" setup>
+import { shallowRef } from 'vue'
+import { RadioGroup, Radio, Cell, CellGroup } from 'vant'
+import { useRequest } from '@/hooks/request'
+import { queryPermancePlanTmp } from '@/services/api/performance'
+import AppModal from '@/components/base/modal/index.vue'
+
+const emit = defineEmits(['update:show', 'change'])
+const checkedRow = shallowRef<Model.PermancePlanTmpRsp>()
+const { dataList } = useRequest(queryPermancePlanTmp)
+
+// 选择履约模板
+const onChange = (item: Model.PermancePlanTmpRsp) => {
+    checkedRow.value = item
+    emit('change', item)
+}
+</script>

+ 35 - 1
src/packages/mobile/views/spot/add/components/sell/index.vue

@@ -2,6 +2,8 @@
     <app-view class="g-form">
         <Form ref="formRef" class="g-form__container" @submit="formSubmit">
             <CellGroup inset>
+                <Field name="PerformanceTemplateID" label="履约模板" placeholder="请选择" v-model="formData.PerformanceTemplateID" :rules="formRules.PerformanceTemplateID"
+                 @click="showPerformancePlan = true" is-link readonly />
                 <Field name="DeliveryGoodsID" label="品类" :rules="formRules.DeliveryGoodsID" is-link>
                     <template #input>
                         <app-select v-model="formData.DeliveryGoodsID" :options="ftDeliveryGoodsList"
@@ -52,11 +54,13 @@
                 <Button type="danger" @click="formRef?.submit" square block>提交</Button>
             </div>
         </template>
+        <component :is="PerformanceTmp" v-model:show="showPerformancePlan" @change="onPerformanceTmpChange" />
     </app-view>
 </template>
 
 <script lang="ts" setup>
-import { shallowRef, computed } from 'vue'
+import { shallowRef, computed, defineAsyncComponent } from 'vue'
+import { onBeforeRouteLeave } from 'vue-router'
 import { CellGroup, Button, Field, Form, FormInstance, Stepper, FieldRule, showSuccessToast, showFailToast } from 'vant'
 import { fullloading } from '@/utils/vant'
 import { BuyOrSell } from '@/constants/order'
@@ -67,10 +71,14 @@ import { useHdWROrder } from '@/business/trade'
 import { useAccountStore } from '@/stores'
 import AppSelect from '../../../../../components/base/select/index.vue'
 
+const PerformanceTmp = defineAsyncComponent(() => import('../preformance/index.vue'))
+
 const { routerBack } = useNavigation()
 const { formData, listingSubmit, amount } = useHdWROrder()
 const accountStore = useAccountStore()
 const formRef = shallowRef<FormInstance>()
+const showPerformancePlan = shallowRef(false)
+const performance = shallowRef<Partial<Model.PerformancePlanRsp>>({}) //选中的履约模板
 
 const { dataList: ftDeliveryGoodsList } = useRequest(queryFtDeliveryGoods)
 const { dataList: wrStandardFactoryItems, run: getWrStandardFactoryItems } = useRequest(queryWrStandardFactoryItem, { manual: true })
@@ -84,6 +92,12 @@ const warehouseList = computed(() => {
 
 // 表单验证规则
 const formRules: { [key in keyof Proto.HdWROrderReq]?: FieldRule[] } = {
+    PerformanceTemplateID: [{
+        message: '请选择履约模板',
+        validator: () => {
+            return !!formData.PerformanceTemplateID
+        }
+    }],
     DeliveryGoodsID: [{
         message: '请选择品类',
         validator: () => {
@@ -116,6 +130,16 @@ const formRules: { [key in keyof Proto.HdWROrderReq]?: FieldRule[] } = {
     }],
 }
 
+// 选择履约模板
+const onPerformanceTmpChange = (item: Model.PermancePlanTmpRsp) => {
+    performance.value = item
+    formData.PerformanceTemplateID = item.autoid
+    if (formData.PerformanceTemplateID) {
+        formRef.value?.validate('PerformanceTemplateID')
+    }
+    showPerformancePlan.value = false
+}
+
 // 选择品类时触发
 const onDeliveryGoodsChange = (deliverygoodsid: number) => {
     const item = ftDeliveryGoodsList.value.find((e) => e.deliverygoodsid === deliverygoodsid)
@@ -156,4 +180,14 @@ const formSubmit = () => {
         })
     })
 }
+
+// 离开页面前关闭组件
+onBeforeRouteLeave((to, from, next) => {
+    if (showPerformancePlan.value) {
+        showPerformancePlan.value = false
+        next(false)
+    } else {
+        next()
+    }
+})
 </script>