Преглед изворни кода

超短池强势池状态修改
添加特定日期股票修改

Zhangbw пре 1 месец
родитељ
комит
a0e36fe202

+ 11 - 0
src/api/stock/pool/index.ts

@@ -42,6 +42,17 @@ export function removeFromPool(ids: number | number[]) {
   });
 }
 
+/**
+ * 修改股票池状态
+ */
+export function updatePoolStatus(id: number, status: number) {
+  return request({
+    url: '/stock/pool/updateStatus',
+    method: 'put',
+    params: { id, status }
+  });
+}
+
 /**
  * 搜索股票(用于添加到池)
  */

+ 86 - 1
src/views/stock/info/index.vue

@@ -112,6 +112,49 @@
       <pagination v-show="total > 0" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" :total="total" @pagination="getList" />
     </el-card>
 
+    <!-- 加入股票池对话框 -->
+    <el-dialog v-model="poolDialog.visible" :title="poolDialog.title" width="500px" append-to-body>
+      <el-form :model="poolForm" label-width="100px">
+        <el-form-item label="股票名称">
+          <el-input v-model="poolForm.stockName" disabled />
+        </el-form-item>
+        <el-form-item label="股票代码">
+          <el-input v-model="poolForm.stockCode" disabled />
+        </el-form-item>
+        <el-form-item label="加入日期" required>
+          <el-date-picker
+            v-model="poolForm.addDate"
+            type="date"
+            placeholder="选择日期"
+            format="YYYY-MM-DD"
+            value-format="YYYY-MM-DD"
+            :disabled-date="disabledDate"
+            style="width: 100%"
+          />
+        </el-form-item>
+        <el-alert
+          title="说明"
+          type="info"
+          :closable="false"
+          show-icon
+          style="margin-bottom: 15px"
+        >
+          <template #default>
+            <div>选择历史日期时,系统将从历史记录表中自动计算:</div>
+            <ul style="margin: 5px 0 0 20px; padding: 0;">
+              <li>收盘价</li>
+              <li>隔日最高价</li>
+              <li>隔日涨幅</li>
+            </ul>
+          </template>
+        </el-alert>
+      </el-form>
+      <template #footer>
+        <el-button @click="poolDialog.visible = false">取消</el-button>
+        <el-button type="primary" @click="submitAddToPool">确定</el-button>
+      </template>
+    </el-dialog>
+
     <!-- 添加或修改股票信息对话框 -->
     <el-dialog v-model="dialog.visible" :title="dialog.title" width="500px" append-to-body>
       <el-form ref="stockFormRef" :model="form" :rules="rules" label-width="80px">
@@ -153,6 +196,19 @@ const single = ref(true);
 const multiple = ref(true);
 const total = ref(0);
 
+// 加入股票池对话框
+const poolDialog = reactive({
+  visible: false,
+  title: ''
+});
+
+const poolForm = ref({
+  stockCode: '',
+  stockName: '',
+  poolType: 1,
+  addDate: ''
+});
+
 let refreshTimer: ReturnType<typeof setTimeout> | null = null;
 let isPageVisible = true; // 页面是否可见
 
@@ -302,9 +358,38 @@ const getChangeClass = (val: any) => {
 /** 加入股票池 */
 const handleAddToPool = async (row: any, poolType: number) => {
   const poolName = poolType === 1 ? '超短池' : '强势池';
+  poolDialog.title = `加入${poolName}`;
+  poolForm.value = {
+    stockCode: row.stockCode,
+    stockName: row.stockName,
+    poolType: poolType,
+    addDate: new Date().toISOString().split('T')[0] // 默认今天
+  };
+  poolDialog.visible = true;
+};
+
+/** 禁用未来日期 */
+const disabledDate = (time: Date) => {
+  return time.getTime() > Date.now();
+};
+
+/** 提交加入股票池 */
+const submitAddToPool = async () => {
+  if (!poolForm.value.addDate) {
+    proxy?.$modal.msgWarning('请选择加入日期');
+    return;
+  }
+
+  const poolName = poolForm.value.poolType === 1 ? '超短池' : '强势池';
   try {
-    await addToPool({ stockCode: row.stockCode, stockName: row.stockName, poolType: poolType });
+    await addToPool({
+      stockCode: poolForm.value.stockCode,
+      stockName: poolForm.value.stockName,
+      poolType: poolForm.value.poolType,
+      addDate: poolForm.value.addDate
+    });
     proxy?.$modal.msgSuccess(`已加入${poolName}`);
+    poolDialog.visible = false;
     await refreshQuotesOnly();
   } catch (error) {
     console.error('加入股票池失败:', error);

+ 71 - 2
src/views/stock/shortPool/index.vue

@@ -90,8 +90,11 @@
             <el-tag v-else type="info">已移除</el-tag>
           </template>
         </el-table-column>
-        <el-table-column label="操作" align="center" width="100">
+        <el-table-column label="操作" align="center" width="150">
           <template #default="scope">
+            <el-tooltip content="修改状态" placement="top">
+              <el-button v-has-permi="['stock:pool:edit']" link type="primary" icon="Edit" @click="handleUpdateStatus(scope.row)"></el-button>
+            </el-tooltip>
             <el-tooltip content="移除" placement="top">
               <el-button v-has-permi="['stock:pool:remove']" link type="danger" icon="Delete" @click="handleDelete(scope.row)"></el-button>
             </el-tooltip>
@@ -101,12 +104,40 @@
 
       <pagination v-show="total > 0" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" :total="total" @pagination="getList" />
     </el-card>
+
+    <!-- 修改状态对话框 -->
+    <el-dialog v-model="statusDialogVisible" title="修改状态" width="400px" append-to-body>
+      <el-form :model="statusForm" label-width="80px">
+        <el-form-item label="股票名称">
+          <el-input v-model="statusForm.stockName" disabled />
+        </el-form-item>
+        <el-form-item label="股票代码">
+          <el-input v-model="statusForm.stockCode" disabled />
+        </el-form-item>
+        <el-form-item label="当前状态">
+          <el-tag v-if="statusForm.currentStatus === 2" type="success">当前有效</el-tag>
+          <el-tag v-else-if="statusForm.currentStatus === 1" type="warning">历史有效</el-tag>
+          <el-tag v-else type="info">已移除</el-tag>
+        </el-form-item>
+        <el-form-item label="新状态">
+          <el-select v-model="statusForm.newStatus" placeholder="请选择状态">
+            <el-option label="当前有效" :value="2" />
+            <el-option label="历史有效" :value="1" />
+            <el-option label="已移除" :value="0" />
+          </el-select>
+        </el-form-item>
+      </el-form>
+      <template #footer>
+        <el-button @click="statusDialogVisible = false">取消</el-button>
+        <el-button type="primary" @click="submitStatusChange">确定</el-button>
+      </template>
+    </el-dialog>
   </div>
 </template>
 
 <script setup name="ShortPool" lang="ts">
 import { ref, onMounted, onUnmounted, onActivated, onDeactivated, getCurrentInstance } from 'vue';
-import { listStockPool, removeFromPool } from '@/api/stock/pool';
+import { listStockPool, removeFromPool, updatePoolStatus } from '@/api/stock/pool';
 
 const { proxy } = getCurrentInstance() as ComponentInternalInstance;
 
@@ -119,6 +150,16 @@ const ids = ref<number[]>([]);
 const multiple = ref(true);
 const total = ref(0);
 
+// 修改状态对话框
+const statusDialogVisible = ref(false);
+const statusForm = ref({
+  id: null as number | null,
+  stockName: '',
+  stockCode: '',
+  currentStatus: null as number | null,
+  newStatus: null as number | null
+});
+
 let refreshTimer: ReturnType<typeof setTimeout> | null = null;
 let isPageVisible = true; // 页面是否可见
 
@@ -272,6 +313,34 @@ const handleDelete = async (row?: any) => {
   await getList();
 };
 
+/** 修改状态按钮 */
+const handleUpdateStatus = (row: any) => {
+  statusForm.value = {
+    id: row.id,
+    stockName: row.stockName,
+    stockCode: row.stockCode,
+    currentStatus: row.status,
+    newStatus: row.status
+  };
+  statusDialogVisible.value = true;
+};
+
+/** 提交状态修改 */
+const submitStatusChange = async () => {
+  if (statusForm.value.newStatus === statusForm.value.currentStatus) {
+    proxy?.$modal.msgWarning('状态未改变');
+    return;
+  }
+  try {
+    await updatePoolStatus(statusForm.value.id!, statusForm.value.newStatus!);
+    proxy?.$modal.msgSuccess('状态修改成功');
+    statusDialogVisible.value = false;
+    await getList();
+  } catch (error) {
+    console.error('修改状态失败:', error);
+  }
+};
+
 /** 格式化价格 */
 const formatPrice = (val: any) => (val != null ? Number(val).toFixed(2) : '-');
 

+ 71 - 2
src/views/stock/strongPool/index.vue

@@ -90,8 +90,11 @@
             <el-tag v-else type="info">已移除</el-tag>
           </template>
         </el-table-column>
-        <el-table-column label="操作" align="center" width="100">
+        <el-table-column label="操作" align="center" width="150">
           <template #default="scope">
+            <el-tooltip content="修改状态" placement="top">
+              <el-button v-has-permi="['stock:pool:edit']" link type="primary" icon="Edit" @click="handleUpdateStatus(scope.row)"></el-button>
+            </el-tooltip>
             <el-tooltip content="移除" placement="top">
               <el-button v-has-permi="['stock:pool:remove']" link type="danger" icon="Delete" @click="handleDelete(scope.row)"></el-button>
             </el-tooltip>
@@ -101,12 +104,40 @@
 
       <pagination v-show="total > 0" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" :total="total" @pagination="getList" />
     </el-card>
+
+    <!-- 修改状态对话框 -->
+    <el-dialog v-model="statusDialogVisible" title="修改状态" width="400px" append-to-body>
+      <el-form :model="statusForm" label-width="80px">
+        <el-form-item label="股票名称">
+          <el-input v-model="statusForm.stockName" disabled />
+        </el-form-item>
+        <el-form-item label="股票代码">
+          <el-input v-model="statusForm.stockCode" disabled />
+        </el-form-item>
+        <el-form-item label="当前状态">
+          <el-tag v-if="statusForm.currentStatus === 2" type="success">当前有效</el-tag>
+          <el-tag v-else-if="statusForm.currentStatus === 1" type="warning">历史有效</el-tag>
+          <el-tag v-else type="info">已移除</el-tag>
+        </el-form-item>
+        <el-form-item label="新状态">
+          <el-select v-model="statusForm.newStatus" placeholder="请选择状态">
+            <el-option label="当前有效" :value="2" />
+            <el-option label="历史有效" :value="1" />
+            <el-option label="已移除" :value="0" />
+          </el-select>
+        </el-form-item>
+      </el-form>
+      <template #footer>
+        <el-button @click="statusDialogVisible = false">取消</el-button>
+        <el-button type="primary" @click="submitStatusChange">确定</el-button>
+      </template>
+    </el-dialog>
   </div>
 </template>
 
 <script setup name="StrongPool" lang="ts">
 import { ref, onMounted, onUnmounted, onActivated, onDeactivated, getCurrentInstance } from 'vue';
-import { listStockPool, removeFromPool } from '@/api/stock/pool';
+import { listStockPool, removeFromPool, updatePoolStatus } from '@/api/stock/pool';
 
 const { proxy } = getCurrentInstance() as ComponentInternalInstance;
 
@@ -119,6 +150,16 @@ const ids = ref<number[]>([]);
 const multiple = ref(true);
 const total = ref(0);
 
+// 修改状态对话框
+const statusDialogVisible = ref(false);
+const statusForm = ref({
+  id: null as number | null,
+  stockName: '',
+  stockCode: '',
+  currentStatus: null as number | null,
+  newStatus: null as number | null
+});
+
 let refreshTimer: ReturnType<typeof setTimeout> | null = null;
 let isPageVisible = true; // 页面是否可见
 
@@ -272,6 +313,34 @@ const handleDelete = async (row?: any) => {
   await getList();
 };
 
+/** 修改状态按钮 */
+const handleUpdateStatus = (row: any) => {
+  statusForm.value = {
+    id: row.id,
+    stockName: row.stockName,
+    stockCode: row.stockCode,
+    currentStatus: row.status,
+    newStatus: row.status
+  };
+  statusDialogVisible.value = true;
+};
+
+/** 提交状态修改 */
+const submitStatusChange = async () => {
+  if (statusForm.value.newStatus === statusForm.value.currentStatus) {
+    proxy?.$modal.msgWarning('状态未改变');
+    return;
+  }
+  try {
+    await updatePoolStatus(statusForm.value.id!, statusForm.value.newStatus!);
+    proxy?.$modal.msgSuccess('状态修改成功');
+    statusDialogVisible.value = false;
+    await getList();
+  } catch (error) {
+    console.error('修改状态失败:', error);
+  }
+};
+
 /** 格式化价格 */
 const formatPrice = (val: any) => (val != null ? Number(val).toFixed(2) : '-');