|
|
@@ -0,0 +1,163 @@
|
|
|
+<!-- 交易市场-仓单交易-挂牌 -->
|
|
|
+<template>
|
|
|
+ <app-drawer title="挂牌" v-model:show="show" :width="800" :loading="loading" :refresh="refresh">
|
|
|
+ <el-form ref="formRef" class="el-form--horizontal" label-width="100px" :model="formData" :rules="formRules">
|
|
|
+ <el-form-item prop="PerformanceTemplateID" label="履约方式">
|
|
|
+ <Performance :market-id="17201" v-model="formData.PerformanceTemplateID" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item prop="DeliveryGoodsID" label="品类">
|
|
|
+ <el-select placeholder="请选择" v-model="formData.DeliveryGoodsID" @change="onDeliveryGoodsChange">
|
|
|
+ <el-option :label="item.deliverygoodsname" :value="item.deliverygoodsid"
|
|
|
+ v-for="(item, index) in ftDeliveryGoodsList" :key="index" />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item prop="WRStandardID" label="商品">
|
|
|
+ <el-select placeholder="请选择" v-model="formData.WRStandardID" @change="onGoodsChange">
|
|
|
+ <el-option :label="item.wrstandardname" :value="item.wrstandardid" v-for="(item, index) in goodsList"
|
|
|
+ :key="index" />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item prop="dgFactoryItemId" label="仓库">
|
|
|
+ <el-select placeholder="请选择" v-model="dgFactoryItemId" @change="onWarehouseChange">
|
|
|
+ <el-option :label="item.dgfactoryitemvalue" :value="item.dgfactoryitemid"
|
|
|
+ v-for="(item, index) in warehouseList" :key="index" />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item prop="FixedPrice" label="挂牌价格">
|
|
|
+ <el-input-number placeholder="请输入" :min="0" :precision="2" v-model="formData.FixedPrice" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item prop="OrderQty" label="挂牌数量">
|
|
|
+ <el-input-number placeholder="请输入" :min="0" :precision="0" v-model="formData.OrderQty" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="货款金额">
|
|
|
+ <span>{{ amount }}</span>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="可用资金">
|
|
|
+ <span>{{ accountStore.avaiableMoney.toFixed(2) }}</span>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ <template #footer>
|
|
|
+ <el-button type="info" @click="onCancel(false)">取消</el-button>
|
|
|
+ <el-button type="primary" @click="onSubmit">提交</el-button>
|
|
|
+ </template>
|
|
|
+ </app-drawer>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script lang="ts" setup>
|
|
|
+import { shallowRef, computed } from 'vue'
|
|
|
+import { ElMessage, FormInstance, FormRules } from 'element-plus'
|
|
|
+import { BuyOrSell } from '@/constants/order'
|
|
|
+import { useRequest } from '@/hooks/request'
|
|
|
+import { queryFtDeliveryGoods, queryWrStandardFactoryItem } from '@/services/api/goods'
|
|
|
+import { useHdWROrder } from '@/business/trade'
|
|
|
+import { useAccountStore } from '@/stores'
|
|
|
+import AppDrawer from '@pc/components/base/drawer/index.vue'
|
|
|
+import Performance from '@pc/components/modules/performance/index.vue'
|
|
|
+
|
|
|
+const { formData, listingSubmit, loading, amount } = useHdWROrder()
|
|
|
+const accountStore = useAccountStore()
|
|
|
+const show = shallowRef(true)
|
|
|
+const refresh = shallowRef(false)
|
|
|
+const formRef = shallowRef<FormInstance>()
|
|
|
+const dgFactoryItemId = shallowRef<number>()
|
|
|
+
|
|
|
+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: FormRules = {
|
|
|
+ PerformanceTemplateID: [{
|
|
|
+ required: true,
|
|
|
+ message: '请选择履约方式'
|
|
|
+ }],
|
|
|
+ DeliveryGoodsID: [{
|
|
|
+ required: true,
|
|
|
+ message: '请选择品类'
|
|
|
+ }],
|
|
|
+ WRStandardID: [{
|
|
|
+ required: true,
|
|
|
+ message: '请选择商品'
|
|
|
+ }],
|
|
|
+ dgFactoryItemId: [{
|
|
|
+ required: true,
|
|
|
+ validator: (rule, value, callback) => {
|
|
|
+ if (dgFactoryItemId.value) {
|
|
|
+ callback()
|
|
|
+ } else {
|
|
|
+ callback(new Error('请选择仓库'))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }],
|
|
|
+ FixedPrice: [{
|
|
|
+ required: true,
|
|
|
+ validator: (rule, value, callback) => {
|
|
|
+ if (value) {
|
|
|
+ callback()
|
|
|
+ } else {
|
|
|
+ callback(new Error('请输入挂牌价格'))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }],
|
|
|
+ OrderQty: [{
|
|
|
+ required: true,
|
|
|
+ validator: (rule, value, callback) => {
|
|
|
+ if (value) {
|
|
|
+ callback()
|
|
|
+ } else {
|
|
|
+ callback(new Error('请输入挂牌数量'))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }],
|
|
|
+}
|
|
|
+
|
|
|
+// 选择品类时触发
|
|
|
+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
|
|
|
+ dgFactoryItemId.value = undefined
|
|
|
+}
|
|
|
+
|
|
|
+// 选择商品时触发
|
|
|
+const onGoodsChange = (wrstandardid: number) => {
|
|
|
+ formData.FactoryItems = undefined
|
|
|
+ dgFactoryItemId.value = undefined
|
|
|
+ getWrStandardFactoryItems({ wrstandardid })
|
|
|
+}
|
|
|
+
|
|
|
+// 选择仓库时触发
|
|
|
+const onWarehouseChange = (dgfactoryitemid: number) => {
|
|
|
+ formData.FactoryItems = [{
|
|
|
+ DGFactoryItemTypeID: 1, // 要素项类型ID
|
|
|
+ DGFactoryItemID: dgfactoryitemid, // 预约要素项类型值
|
|
|
+ ItemTypeMode: 1, // 要素项类型模式
|
|
|
+ }]
|
|
|
+}
|
|
|
+
|
|
|
+const onCancel = (isRefresh = false) => {
|
|
|
+ show.value = false
|
|
|
+ refresh.value = isRefresh
|
|
|
+}
|
|
|
+
|
|
|
+const onSubmit = () => {
|
|
|
+ formRef.value?.validate((valid) => {
|
|
|
+ if (valid) {
|
|
|
+ formData.BuyOrSell = BuyOrSell.Buy
|
|
|
+ listingSubmit().then(() => {
|
|
|
+ ElMessage.success('提交成功')
|
|
|
+ onCancel(true)
|
|
|
+ }).catch((err) => {
|
|
|
+ ElMessage.error('提交失败:' + err)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+}
|
|
|
+</script>
|