huangbin 4 роки тому
батько
коміт
dbfb6e18b7

+ 1 - 1
src/common/setup/table/tableQuote.ts

@@ -153,7 +153,7 @@ export function quoteChange(record: QueryQuoteDayRsp, decimalplace = 2) {
 // 幅度(最新价 - 昨结价) / 100 %
 export function quoteAmplitude(record: QueryQuoteDayRsp, decimalplace = 2) {
     const result = quoteChange(record, decimalplace)
-    return result === '--' ? '--' : (+result / 100).toFixed(decimalplace) + '%'
+    return result === '--' ? '--' : (+result / record.presettle * 100).toFixed(decimalplace) + '%'
 }
 
 // (最高价 - 最低价 ) / 最新价  * 100 %

+ 68 - 33
src/views/order/spot_warran/components/spot_warrant_bargain/components/bargain_detail/index.vue

@@ -9,13 +9,22 @@
       <a-form class="inlineForm dialogForm">
         <div class="formBar">
           <a-table :columns="columns"
-                   class="dialogTable dialogTable2"
+                   class="dialogTable dialogTable2 expandLeftTable"
                    :pagination="false"
                    :expandIcon="expandIcon"
+                   :expandedRowKeys="expandedRowKeys"
                    :loading="loading"
+                   :customRow="Rowclick"
                    :expandIconAsCell="false"
-                   rowKey="applyprice"
+                   rowKey="key"
                    :data-source="tableList">
+            <!-- 额外的展开行 -->
+            <template #expandedRowRender="{ record }">
+              <BtnList :btnList="handleBtnList(record)"
+                       class="btn-list-sticky"
+                       :record="record"
+                       @click="action" />
+            </template>
             <template #applystatus="{ text }">
               <span>{{ getBarmaginApplyStatus(text) }}</span>
             </template>
@@ -23,20 +32,12 @@
         </div>
         <a-row :gutter="24"
                type="flex"
-               v-if="isShowBtn()"
                justify="center">
           <a-col :span="24"
                  class="fixedBtns">
             <a-form-item class="btnCenter">
               <a-button class="cancelBtn"
-                        v-if="isMy()"
-                        @click="cancelAction">撤销</a-button>
-              <template v-else>
-                <a-button class="listedBtn ml10"
-                          @click="submit">确认</a-button>
-                <a-button class="ml10 cancelBtn"
-                          @click="refuse">拒绝</a-button>
-              </template>
+                        @click="cancel">取消</a-button>
             </a-form-item>
           </a-col>
         </a-row>
@@ -46,52 +47,56 @@
 </template>
 
 <script lang="ts">
-import { defineComponent, PropType, ref } from 'vue';
-import { enumOrderComponents } from '@/common/constants/enumOrderComponents';
+import { BtnListType } from '@/common/components/btnList/interface';
 import Drawer from '@/common/components/drawer/index.vue';
-import { QueryWrPositionReq, QueryWrTradeBargainApplyQsp, QueryWrTradeBargainApplyReq, WrOrderDetail, WrPosition } from '@/services/go/wrtrade/interface';
-import { getUserId } from '@/services/bus/account';
+import { getBarmaginApplyStatus } from '@/common/constants/enumsName';
+import { BtnList, ModalEnum, queryTableList } from '@/common/export/commonTable';
 import { requestResultLoadingAndInfo } from '@/common/methods/request/resultInfo';
-import { hdWROrder } from '@/services/proto/warehousetrade';
-import { v4 as uuidv4 } from 'uuid';
-import moment from 'moment';
-import { ModalEnum } from '@/common/constants/modalNameEnum';
-import { queryTableList } from '@/common/setup/table';
-import { queryQueryWrTradeBargainApply } from '@/services/go/wrtrade';
-import { getSpotWarrantBargainDetailColumns } from '../../setup';
-import { wrBargainNoAgree, wrBargainBack } from '@/services/proto/WrBargain';
 import { _closeModal } from '@/common/setup/modal/modal';
+import { getTableEvent } from '@/common/setup/table';
+import { expandIcon } from '@/common/setup/table/clolumn';
+import { queryQueryWrTradeBargainApply } from '@/services/go/wrtrade';
+import { QueryWrTradeBargainApplyQsp, QueryWrTradeBargainApplyReq, WrOrderDetail } from '@/services/go/wrtrade/interface';
+import { wrBargainBack, wrBargainNoAgree } from '@/services/proto/WrBargain';
 import { WrBargainBackReq, WrBargainNoAgreeReq } from '@/services/proto/WrBargain/interface';
 import Long from 'long';
-import { getBarmaginApplyStatus } from '@/common/constants/enumsName';
+import { defineComponent, PropType, ref } from 'vue';
+import { getSpotWarrantBargainDetailColumns } from '../../setup';
 
 export default defineComponent({
     name: ModalEnum.spot_warrant_bargain_detail,
-    components: { Drawer },
+    components: { Drawer, BtnList },
     emits: ['cancel', 'update'],
     props: {
         selectedRow: {
-            type: Object as PropType<QueryWrTradeBargainApplyQsp>,
+            type: Object as PropType<QueryWrTradeBargainApplyQsp | WrOrderDetail>,
             default: {},
         },
+        isMy: {
+            type: Boolean,
+            default: true,
+        },
     },
     setup(props, context) {
         // 表格列表数据
         const { loading, tableList, queryTable } = queryTableList<QueryWrTradeBargainApplyQsp>();
         const { visible, cancel } = _closeModal(context);
-        const { wrbargainid } = props.selectedRow;
         const param: QueryWrTradeBargainApplyReq = {
             haswr: 1,
             wrtradeorderid: props.selectedRow.wrtradeorderid,
         };
         queryTable(queryQueryWrTradeBargainApply, param).then((res) => {
+            const arr = res.map((el) => {
+                return Object.assign(el, { key: el.wrbargainid });
+            });
             // 时间 倒序排序
-            tableList.value = res.sort((a, b) => {
+            tableList.value = arr.sort((a, b) => {
                 const time1 = new Date(a.applytime).getTime();
                 const time2 = new Date(b.applytime).getTime();
                 return time2 - time1;
             });
         });
+
         function isShowBtn() {
             let result = false;
             tableList.value.forEach((el) => {
@@ -103,9 +108,35 @@ export default defineComponent({
         }
         // 我对别人的 => 撤销
         // 别人对我的 => 确认、拒绝
-        const { isMy, getColums } = getSpotWarrantBargainDetailColumns(props.selectedRow);
+        const { getColums, isMy } = getSpotWarrantBargainDetailColumns(props.isMy);
+        function handleBtnList(record: QueryWrTradeBargainApplyQsp) {
+            const result = ref<BtnListType[]>([]);
+            if (isMy()) {
+                result.value = [{ lable: '撤销', code: 'cancel', className: 'btnDanger' }];
+            } else {
+                result.value = [
+                    { lable: '确认', code: 'submit', className: 'operBtn' },
+                    { lable: '拒绝', code: 'refuse', className: 'btnDanger' },
+                ];
+            }
+            return record.applystatus === 1 ? result.value : [];
+        }
+        function action({ code }: BtnListType, { wrbargainid }: QueryWrTradeBargainApplyQsp) {
+            switch (code) {
+                case 'cancel':
+                    cancelAction(wrbargainid);
+                    break;
+                case 'submit':
+                    submit(wrbargainid);
+                    break;
+                case 'refuse':
+                    refuse(wrbargainid);
+                    break;
+            }
+        }
+
         // 确认
-        function submit() {
+        function submit(wrbargainid: string) {
             const param: WrBargainNoAgreeReq = {
                 WrBargainID: Long.fromString(wrbargainid),
                 Status: 1,
@@ -115,7 +146,7 @@ export default defineComponent({
             });
         }
         // 拒绝
-        function refuse() {
+        function refuse(wrbargainid: string) {
             const param: WrBargainNoAgreeReq = {
                 WrBargainID: Long.fromString(wrbargainid),
                 Status: 2,
@@ -125,7 +156,7 @@ export default defineComponent({
             });
         }
         // 撤销
-        function cancelAction() {
+        function cancelAction(wrbargainid: string) {
             const param: WrBargainBackReq = {
                 WrBargainID: Long.fromString(wrbargainid),
             };
@@ -134,7 +165,7 @@ export default defineComponent({
             });
         }
         return {
-            visible: true,
+            visible,
             columns: getColums(),
             loading,
             tableList,
@@ -145,6 +176,10 @@ export default defineComponent({
             cancel,
             getBarmaginApplyStatus,
             isShowBtn,
+            handleBtnList,
+            action,
+            expandIcon,
+            ...getTableEvent<QueryWrTradeBargainApplyQsp>(),
         };
     },
 });

+ 2 - 4
src/views/order/spot_warran/components/spot_warrant_bargain/setup.ts

@@ -1,5 +1,3 @@
-import { getUserId } from "@/services/bus/account";
-import { QueryWrTradeBargainApplyQsp } from "@/services/go/wrtrade/interface";
 
 export function getSpotWarrantBargainColumns() {
     const columns = [
@@ -25,7 +23,7 @@ export function getSpotWarrantBargainColumns() {
     })
 }
 
-export function getSpotWarrantBargainDetailColumns(selectedRow: QueryWrTradeBargainApplyQsp) {
+export function getSpotWarrantBargainDetailColumns(is: boolean) {
     const columns = [
         { title: '数量', key: 'applyqty', dataIndex: 'applyqty', align: 'center' },
         { title: '价格', key: 'applyprice', dataIndex: 'applyprice', align: 'center' },
@@ -33,7 +31,7 @@ export function getSpotWarrantBargainDetailColumns(selectedRow: QueryWrTradeBarg
         { title: '状态', key: 'applystatus', dataIndex: 'applystatus', align: 'center', slots: { customRender: 'applystatus' } },
     ];
     function isMy() {
-        return selectedRow.userid === getUserId();
+        return is
     }
     function getColums() {
         return isMy() ? columns : [...columns, { title: '议价人', key: 'username', dataIndex: 'username', align: 'center' }]

+ 1 - 0
src/views/order/spot_warran/components/spot_warrant_pending_order/index.vue

@@ -40,6 +40,7 @@
     <component :is="componentId"
                v-if="componentId"
                :selectedRow="selectedRow"
+               :isMy="false"
                @cancel="closeComponent"></component>
   </section>
 </template>