li.shaoyi 3 yıl önce
ebeveyn
işleme
62f769c358

+ 1 - 1
src/business/common/index.ts

@@ -25,7 +25,7 @@ export async function initBaseData() {
     await errorInfoStore.getErrorInfoList()
 
     if (loginStore.getToken()) {
-        await checkToken()
+        await checkToken().then(() => checkTokenLoop())
         await Promise.all([
             userStore.getUserData(),
             menuStore.getUserMenuList(),

+ 1 - 1
src/business/goods/index.ts

@@ -37,7 +37,7 @@ export function useWrstandardList() {
 
 // 采购详细
 export function useWrstandardDetails(wrstandardid: number) {
-    const details = shallowRef<Model.THJWrstandardDetailRsp>()
+    const details = shallowRef<Partial<Model.THJWrstandardDetailRsp>>({})
 
     const getWrstandardDetails = () => {
         return queryTHJWrstandardDetail({

+ 17 - 14
src/packages/mobile/components/base/select/index.vue

@@ -7,7 +7,7 @@
                 </slot>
             </template>
             <template #input>
-                <slot name="input">
+                <slot name="input" :item="props.options[selectedIndex]">
                     <input :value="columnLabel" :placeholder="placeholder" readonly />
                 </slot>
             </template>
@@ -19,7 +19,7 @@
 </template>
 
 <script lang="ts" setup>
-import { shallowRef, computed, PropType } from 'vue'
+import { shallowRef, computed, PropType, watch } from 'vue'
 import { Field, FieldRule, Popup, Picker, PickerOption, FieldInstance } from 'vant'
 
 const props = defineProps({
@@ -73,25 +73,28 @@ const columnLabel = computed(() => {
     return ''
 })
 
-// 更新当前选中的值
-const updateValue = (index: number) => {
-    const item = props.options[index]
-    const value = item[props.optionProps.value]
-    selectedIndex.value = index
-    fieldRef.value?.validate()
-    emit('update:modelValue', value)
-}
-
 const onCancel = (currentValue: PickerOption, currentIndex: number) => {
     showPicker.value = false
-    emit('cancel', currentValue, currentIndex)
+    emit('cancel', props.modelValue, currentIndex)
 }
 
 const onConfirm = (currentValue: PickerOption, currentIndex: number) => {
     showPicker.value = false
-    updateValue(currentIndex)
-    emit('confirm', currentValue, currentIndex)
+    if (selectedIndex.value !== currentIndex) {
+        // 更新当前选中的值
+        const item = props.options[currentIndex]
+        const value = item[props.optionProps.value]
+        selectedIndex.value = currentIndex
+        fieldRef.value?.validate()
+
+        emit('update:modelValue', value)
+        emit('confirm', value, currentIndex)
+    }
 }
+
+watch(() => props.modelValue, (val) => {
+    selectedIndex.value = props.options.findIndex((e) => e[props.optionProps.value] === val)
+})
 </script>
 
 <style lang="less" scoped>

+ 36 - 18
src/packages/mobile/views/goods/details/index.vue

@@ -6,18 +6,19 @@
         <Form ref="formRef" @submit="onSubmit">
             <CellGroup>
                 <app-select v-model="formData.THJDeliveryMode" name="THJDeliveryMode" label="交割方式"
-                    :rules="formRules.THJDeliveryMode" :options="details?.deliverymodes"
+                    :rules="formRules.THJDeliveryMode" :options="details.deliverymodes"
                     :optionProps="{ label: 'enumdicname', value: 'enumitemname' }" />
                 <Field label="交割月份">
                     <template #input>
-                        <app-select v-model="selectedMonth" placeholder="开始月份" :options="months" :is-link="false"
-                            @confirm="monthChange" />
-                        <app-select v-model="formData.PresaleApplyID" placeholder="结束日期" :options="days"
-                            :optionProps="{ label: 'enddate', value: 'presaleapplyid' }" :is-link="false" />
+                        <app-select placeholder="开始月份" :options="deliveryMonths" :is-link="false"
+                            @confirm="onMonthChange" />
+                        <app-select v-model="presaleApplyId" placeholder="结束日期" :options="deliveryDays"
+                            :optionProps="{ label: 'enddate', value: 'presaleapplyid' }" :is-link="false"
+                            @confirm="onDayChange" />
                     </template>
                 </Field>
-                <Field v-model="formData.DepositID" name="refernum" label="支付方式" placeholder="必填"
-                    :rules="formRules.DepositID" />
+                <app-select v-model="formData.DepositID" name="DepositID" label="支付方式" :rules="formRules.DepositID"
+                    :options="presaleApplyDeposits" />
                 <Field v-model="formData.Qty" name="Qty" type="digit" label="采购数量" placeholder="必填"
                     :rules="formRules.Qty" />
             </CellGroup>
@@ -34,11 +35,11 @@ import { useNavigation } from '@/hooks/navigation'
 import { useWrstandardDetails } from '@/business/goods'
 import { usePurchaseOrderDesting } from '@/business/trade'
 import AppSelect from '@mobile/components/base/select/index.vue'
+import Long from 'long'
 
 const { getQueryStringToNumber } = useNavigation()
 const wrstandardid = getQueryStringToNumber('wrstandardid')
 const formRef = shallowRef<FormInstance>()
-const selectedMonth = shallowRef('') // 当前选中的交割月份
 
 const { details, getWrstandardDetails } = useWrstandardDetails(wrstandardid)
 const { formData, formSubmit } = usePurchaseOrderDesting()
@@ -53,11 +54,11 @@ const formRules: { [key in keyof Proto.SpotPresaleDestingOrderReq]?: FieldRule[]
     }],
 }
 
-// 交割月份
-const months = computed(() => {
-    const deliveryMonths = details.value?.deliverymonth ?? []
+// 交割月份列表
+const deliveryMonths = computed(() => {
+    const months = details.value.deliverymonth ?? []
     const monthMap = new Map<string, { label: string, value: string; }>()
-    deliveryMonths.forEach(({ endmonth }) => {
+    months.forEach(({ endmonth }) => {
         if (!monthMap.has(endmonth)) {
             monthMap.set(endmonth, {
                 label: endmonth,
@@ -68,18 +69,35 @@ const months = computed(() => {
     return [...monthMap.values()]
 })
 
-// 交割日期
-const days = computed(() => {
-    const deliveryMonths = details.value?.deliverymonth ?? []
-    return deliveryMonths.filter((e) => e.endmonth === selectedMonth.value)
+// 交割日期列表
+const deliveryDays = shallowRef<Model.THJWrstandardDetailRsp['deliverymonth']>([])
+// 当前选中的预售申请ID
+const presaleApplyId = shallowRef('')
+
+// 预售申请列表
+const presaleApplyDeposits = computed(() => {
+    const deposits = details.value.presaleapplydeposits ?? []
+    return deposits.map(({ depositrate, discountamount }) => ({
+        label: `${depositrate},${discountamount}`,
+        value: discountamount
+    }))
 })
 
-const monthChange = (value: string) => {
-    console.log(value)
+// 切换交割月份
+const onMonthChange = (value: string) => {
+    const months = details.value.deliverymonth ?? []
+    deliveryDays.value = months.filter((e) => e.endmonth === value)
+    presaleApplyId.value = ''
+}
+
+// 切换交割日期
+const onDayChange = (value: string) => {
+    presaleApplyId.value = value
 }
 
 const onSubmit = () => {
     fullloading(() => {
+        formData.PresaleApplyID = Long.fromString(presaleApplyId.value)
         formSubmit().then(() => {
             Toast.success('下单成功')
         }).catch((err) => {

+ 1 - 1
src/packages/mobile/views/home/index.vue

@@ -59,7 +59,7 @@ const tabList: Tabbar[] = [
 ]
 
 const onChange = (index: number) => {
-  if (![2].includes(index)) {
+  if (![1, 2].includes(index)) {
     componentId.value = tabList[index].name
   }
 }

+ 2 - 1
src/types/proto/trade.d.ts

@@ -1,4 +1,5 @@
 import { IMessageHead } from '@/services/socket/trade/protobuf/proto'
+import Long from 'long'
 
 declare global {
     namespace Proto {
@@ -7,7 +8,7 @@ declare global {
             Header?: IMessageHead;
             UserID: number; // 用户ID,必填
             AccountID: number; // 资金账号,必填
-            PresaleApplyID: number; // 预售申请ID,必填
+            PresaleApplyID: Long; // 预售申请ID,必填
             Qty: number; // 预售数量,必填
             DepositID: number; // 定金方式,THJ_PresaleApplyDeposit表ID,必填
             THJDeliveryMode: number; // 交割方式,必填1:平台仓储2:自提