From 2aba6e524f93036a8b4e009c3ef8e6de84471c49 Mon Sep 17 00:00:00 2001
From: rjg <746338628@qq.com>
Date: Fri, 16 May 2025 11:32:31 +0800
Subject: [PATCH] License

---
 src/views/license/license.vue |   83 +++++++++++++++++++++++++++++++++++++++--
 1 files changed, 79 insertions(+), 4 deletions(-)

diff --git a/src/views/license/license.vue b/src/views/license/license.vue
index 0eabc6e..6d1647c 100644
--- a/src/views/license/license.vue
+++ b/src/views/license/license.vue
@@ -1,5 +1,6 @@
 <template>
     <basic-container>
+        
         <avue-crud 
             :option="option" 
             :table-loading="loading" 
@@ -18,9 +19,9 @@
             @current-change="currentChange" 
             @size-change="sizeChange"
             @refresh-change="refreshChange" 
+            
             @on-load="onLoad">
-             <!-- 自定义url -->
-             <template #url="scope">
+                  <template #url="scope">
                 <el-link 
                     :href="scope.row.url" 
                     target="_blank" 
@@ -28,7 +29,6 @@
                     下载证书
                 </el-link>
             </template>
-
             <!-- 自定义过期时间列 -->
             <template #expireDay="scope">
                 <span :style="{ color: isExpired(scope.row.expireDay) ? 'red' : 'inherit' }">
@@ -49,7 +49,57 @@
                     {{ scope.row.checkMachineCode ? '校验机器码' : '不校验' }}
                 </span>
             </template>
+            <template #menu-left>
+            <el-button type="primary" icon="el-icon-plus"
+              @click="createLicenseShow()">新 增
+            </el-button>
+            </template>
         </avue-crud>
+
+        <!-- 新增弹窗 -->
+        <el-dialog title="新增License" 
+      v-model="addDialogVisible"
+      width="70%"
+      :close-on-click-modal="false"
+      @close="resetForm"
+    >
+            <el-form :model="newLicense"  label-width="120px">
+                <el-form-item label="机构ID" prop="licenseId" required>
+                    <el-input v-model="newLicense.licenseId" />
+                </el-form-item>
+                <el-form-item label="机构名称" prop="licenseName" required>
+                    <el-input v-model="newLicense.licenseName" />
+                </el-form-item>
+                <el-form-item label="类型" prop="licenseType" required>
+                    <el-select v-model="newLicense.licenseType" placeholder="请选择">
+                        <el-option label="不验证过期时间" :value="1" />
+                        <el-option label="验证过期时间" :value="2" />
+                    </el-select>
+                </el-form-item>
+                <el-form-item label="过期时间" prop="expireDay">
+                    <el-date-picker v-model="newLicense.expireDay" type="date" placeholder="选择日期" />
+                </el-form-item>
+                <el-form-item label="设备数量" prop="printClientCount">
+                    <el-input-number v-model="newLicense.printClientCount" :min="-1" />
+                </el-form-item>
+                <el-form-item label="是否校验机器码" prop="checkMachineCode">
+                    <el-switch v-model="newLicense.checkMachineCode" />
+                </el-form-item>
+                <el-form-item label="机器码" prop="machineCode">
+                    <el-input v-model="newLicense.machineCode" type="textarea" rows="3" />
+                </el-form-item>
+                <el-form-item label="备注" prop="remark">
+                    <el-input v-model="newLicense.remark" />
+                </el-form-item>
+            </el-form>
+            <template #footer>
+                <div class="dialog-footer">
+                <el-button @click="addDialogVisible = false">取消</el-button>
+                <el-button type="primary" @click="createLicense">保存</el-button>
+                </div>
+            </template>
+            
+        </el-dialog>
     </basic-container>
 </template>
 
@@ -67,6 +117,17 @@
                 total: 0,
             },
             selectionList: [],
+            addDialogVisible: false,
+            newLicense: {
+                licenseId: '',
+                licenseName: '',
+                licenseType: null,
+                expireDay: null,
+                printClientCount: -1,
+                checkMachineCode: false,
+                machineCode: '',
+                remark: '',
+            },
             option: {
                 menuWidth: 300,
                 lazy: true,
@@ -79,7 +140,8 @@
                 viewBtn: true,
                 selection: false,
                 excelBtn: false,
-                addBtn: true,
+              addBtnText: '新建license',
+                 addBtn: false,
                 dialogClickModal: false,
                 grid: false,
                 column: [
@@ -254,6 +316,19 @@
                 }
             );
         },
+        createLicenseShow(){
+                    this.addDialogVisible = true; 
+        },
+        createLicense() {
+            add(this.newLicense).then(() => {
+                this.$message.success('新增成功');
+                this.addDialogVisible = false;
+                this.onLoad(this.page);
+            }).catch(error => {
+                console.error(error);
+                this.$message.error('新增失败');
+            });
+        },
         onLoad(page, params = {}) {
             this.loading = true;
             getList(page.currentPage, page.pageSize, params).then(res => {

--
Gitblit v1.9.3