罗永浩 5 kuukautta sitten
vanhempi
commit
32286c2005

+ 78 - 30
addons/admin/src/styles/eleadmin/common.scss

@@ -24,7 +24,12 @@ textarea {
   padding: 15px;
 }
 
-h1, h2, h3, h4, h5, h6 {
+h1,
+h2,
+h3,
+h4,
+h5,
+h6 {
   color: $--color-text-primary;
   font-size: 26px;
   font-weight: 500;
@@ -86,56 +91,69 @@ h6 {
   text-decoration: line-through;
 }
 
-.ele-text-small, .ele-text-small > .el-progress__text {
+.ele-text-small,
+.ele-text-small>.el-progress__text {
   font-size: 12px !important;
 }
 
 .ele-bg-primary {
-  background-color: $--color-primary !important;;
+  background-color: $--color-primary !important;
+  ;
 }
 
 .ele-bg-success {
-  background-color: $--color-success !important;;
+  background-color: $--color-success !important;
+  ;
 }
 
 .ele-bg-warning {
-  background-color: $--color-warning !important;;
+  background-color: $--color-warning !important;
+  ;
 }
 
 .ele-bg-danger {
-  background-color: $--color-danger !important;;
+  background-color: $--color-danger !important;
+  ;
 }
 
 .ele-bg-info {
-  background-color: $--color-info !important;;
+  background-color: $--color-info !important;
+  ;
 }
 
 .ele-bg-white {
-  background-color: $--color-white !important;;
+  background-color: $--color-white !important;
+  ;
 }
 
 .ele-bg-base {
-  background-color: $--background-color-base !important;;
+  background-color: $--background-color-base !important;
+  ;
 }
 
 .ele-border-primary {
-  border-color: $--color-primary !important;;
+  border-color: $--color-primary !important;
+  ;
 }
 
 .ele-border-success {
-  border-color: $--color-success !important;;
+  border-color: $--color-success !important;
+  ;
 }
 
 .ele-border-warning {
-  border-color: $--color-warning !important;;
+  border-color: $--color-warning !important;
+  ;
 }
 
 .ele-border-danger {
-  border-color: $--color-danger !important;;
+  border-color: $--color-danger !important;
+  ;
 }
 
 .ele-border-info {
-  border-color: $--color-info !important;;
+  border-color: $--color-info !important;
+  ;
 }
 
 .ele-pull-left {
@@ -184,7 +202,8 @@ h6 {
   width: 100% !important;
 }
 
-.ele-btn-icon, .ele-btn-icon.is-round {
+.ele-btn-icon,
+.ele-btn-icon.is-round {
   padding-left: 12px;
   padding-right: 12px;
 
@@ -199,11 +218,22 @@ h6 {
   }
 }
 
-.el-button + .el-link, .el-button + .el-dropdown, .el-button + .ele-action,
-.el-link + .el-button, .el-link + .el-link, .el-link + .el-dropdown, .el-link + .ele-action,
-.el-dropdown + .el-button, .el-dropdown + .el-link, .el-dropdown + .el-dropdown, .el-dropdown + .ele-action,
-.ele-action + .el-button, .ele-action + .el-link, .ele-action + .el-dropdown, .ele-action + .ele-action,
-.el-tag + .el-tag {
+.el-button+.el-link,
+.el-button+.el-dropdown,
+.el-button+.ele-action,
+.el-link+.el-button,
+.el-link+.el-link,
+.el-link+.el-dropdown,
+.el-link+.ele-action,
+.el-dropdown+.el-button,
+.el-dropdown+.el-link,
+.el-dropdown+.el-dropdown,
+.el-dropdown+.ele-action,
+.ele-action+.el-button,
+.ele-action+.el-link,
+.ele-action+.el-dropdown,
+.ele-action+.ele-action,
+.el-tag+.el-tag {
   margin-left: 10px;
 }
 
@@ -238,12 +268,12 @@ s {
     align-items: flex-end;
   }
 
-  & > .ele-cell-content {
+  &>.ele-cell-content {
     flex: 1;
     box-sizing: border-box;
   }
 
-  & > * + .ele-cell-content {
+  &>*+.ele-cell-content {
     padding-left: 10px;
   }
 
@@ -298,11 +328,11 @@ s {
 }
 
 @media screen and (min-width: 768px) {
-  .ele-admin-sidebar + .ele-admin-body .ele-bottom-tool {
+  .ele-admin-sidebar+.ele-admin-body .ele-bottom-tool {
     padding-left: $--size-side-width + 15px;
   }
 
-  .ele-layout-collapse .ele-admin-sidebar + .ele-admin-body .ele-bottom-tool {
+  .ele-layout-collapse .ele-admin-sidebar+.ele-admin-body .ele-bottom-tool {
     padding-left: $--size-side-width-collapse + 15px;
   }
 }
@@ -313,7 +343,8 @@ s {
 }
 
 /** 水平搜索表单 */
-.ele-form-search .el-form-item, .ele-form-search .ele-form-actions {
+.ele-form-search .el-form-item,
+.ele-form-search .ele-form-actions {
   margin-bottom: 15px;
 }
 
@@ -366,7 +397,8 @@ s {
   &.ele-form-search {
     padding-bottom: 0;
 
-    .el-form-item, .ele-form-actions {
+    .el-form-item,
+    .ele-form-actions {
       margin-bottom: 10px;
     }
   }
@@ -388,22 +420,22 @@ s {
 
 /** 滚动条 */
 @media screen and (min-width: 768px) {
-  :not(html,body)::-webkit-scrollbar {
+  :not(html, body)::-webkit-scrollbar {
     width: 8px;
     height: 8px;
     background: transparent;
   }
 
-  :not(html,body)::-webkit-scrollbar-track {
+  :not(html, body)::-webkit-scrollbar-track {
     background: transparent;
   }
 
-  :not(html,body)::-webkit-scrollbar-thumb {
+  :not(html, body)::-webkit-scrollbar-thumb {
     border-radius: 4px;
     background-color: $--scrollbar-background-color;
   }
 
-  :not(html,body)::-webkit-scrollbar-thumb:hover {
+  :not(html, body)::-webkit-scrollbar-thumb:hover {
     background-color: $--scrollbar-hover-background-color;
   }
 
@@ -432,4 +464,20 @@ s {
   &:hover {
     overflow: auto;
   }
+}
+
+/* 禁用按钮样式 - 去掉背景和边框 */
+button.action-btn:disabled,
+button.edit-btn:disabled,
+button.delete-btn:disabled {
+  background-color: transparent !important;
+  border: none !important;
+  cursor: not-allowed;
+  opacity: 0.5;
+}
+
+/* 兼容其他按钮类 */
+button[disabled] {
+  background-color: transparent !important;
+  border: none !important;
 }

+ 74 - 10
addons/admin/src/views/system/article/components/ExcelImportDialog.vue

@@ -1,11 +1,29 @@
 <template>
     <el-dialog :visible.sync="visible" title="导入 Excel" width="800px">
-        <el-upload :action="uploadUrl" :before-upload="beforeUpload" :on-change="handleFileChange" accept=".xls,.xlsx"
-            :show-file-list="false" :auto-upload="false">
-            <el-button slot="trigger" type="primary" icon="el-icon-upload2">选择 Excel 文件</el-button>
-        </el-upload>
+        <div class="import-header">
+            <el-upload :action="uploadUrl" :before-upload="beforeUpload" :on-change="handleFileChange"
+                accept=".xls,.xlsx" :show-file-list="false" :auto-upload="false">
+                <el-button slot="trigger" type="primary" icon="el-icon-upload2">选择 Excel 文件</el-button>
+            </el-upload>
 
-        <el-button type="primary" :disabled="!file" @click="handleImport" class="mt-10">开始导入</el-button>
+            <el-button type="success" icon="el-icon-download" @click="downloadTemplate">下载导入模板</el-button>
+        </div>
+
+        <div class="import-actions">
+            <el-button type="primary" :disabled="!file" @click="handleImport">开始导入</el-button>
+        </div>
+
+        <!-- 模板说明 -->
+        <div class="template-tips">
+            <el-alert type="info" :closable="false" show-icon>
+                <div slot="title">
+                    <p><strong>模板格式说明:</strong></p>
+                    <p>• 第一行:标题、内容(固定表头)</p>
+                    <p>• 从第二行开始填写数据</p>
+                    <p>• 标题:必填,内容:选填</p>
+                </div>
+            </el-alert>
+        </div>
 
         <!-- 预览区域 -->
         <div v-if="previewData.length" class="excel-preview">
@@ -66,6 +84,36 @@ export default {
             this.file = null;
             this.previewData = [];
         },
+        // 下载导入模板
+        downloadTemplate() {
+            // 创建模板数据
+            const templateData = [
+                ['标题', '内容'],
+                ['示例标题1', '这是示例内容1'],
+                ['示例标题2', '这是示例内容2'],
+            ];
+
+            // 创建工作簿
+            const wb = XLSX.utils.book_new();
+            const ws = XLSX.utils.aoa_to_sheet(templateData);
+
+            // 设置列宽
+            ws['!cols'] = [
+                { wch: 30 },  // 标题列宽
+                { wch: 50 },  // 内容列宽
+            ];
+
+            // 将工作表添加到工作簿
+            XLSX.utils.book_append_sheet(wb, ws, '导入模板');
+
+            // 生成文件名(带时间戳)
+            const fileName = `文章导入模板_${new Date().getTime()}.xlsx`;
+
+            // 下载文件
+            XLSX.writeFile(wb, fileName);
+
+            this.$message.success('模板下载成功');
+        },
         beforeUpload(file) {
             const isExcel =
                 file.type.includes("excel") || file.name.endsWith(".xls") || file.name.endsWith(".xlsx");
@@ -156,8 +204,28 @@ export default {
 </script>
 
 <style scoped>
+.import-header {
+    display: flex;
+    gap: 10px;
+    margin-bottom: 15px;
+    align-items: center;
+}
+
+.import-actions {
+    margin-bottom: 15px;
+}
+
 .el-upload {
-    width: 100%;
+    flex: 1;
+}
+
+.template-tips {
+    margin: 15px 0;
+}
+
+.template-tips p {
+    margin: 5px 0;
+    line-height: 1.6;
 }
 
 .excel-preview {
@@ -178,10 +246,6 @@ export default {
     overflow: hidden;
 }
 
-.mt-10 {
-    margin-top: 10px;
-}
-
 .dialog-footer {
     display: flex;
     justify-content: flex-end;

+ 0 - 0
addons/admin/src/views/system/institution.vue


+ 31 - 3
addons/admin/src/views/system/institution/index.vue

@@ -192,9 +192,37 @@ export default {
             this.$refs.table.reload();
         },
         /* 显示编辑 */
-        edit(row) {
-            this.editForm = Object.assign({ status: 1, link_type: 1, sort: 0 }, row);
-            this.showEdit = true;
+        async edit(row) {
+            // 获取完整数据,确保所有字段都存在
+            const loading = this.$loading({ lock: true });
+            try {
+                const res = await this.$http.get(`/institutions/info?id=${row.id}`);
+                console.log('Response:', res.data.data.data);
+                loading.close();
+                if (res.data.code === 0 && res.data.data.data) {
+                    const data = res.data.data.data;
+                    console.log('Institution data:', data);
+                    this.editForm = {
+                        id: data.id || null,
+                        name: data.name || '',
+                        code: data.code || '',
+                        thumb: data.thumb || '',
+                        link_url: data.link_url || '',
+                        link_type: data.link_type || 1,
+                        mp_appid: data.mp_appid || '',
+                        description: data.description || '',
+                        sort: data.sort || 0,
+                        status: data.status !== undefined ? data.status : 1
+                    };
+                    console.log('EditForm:', this.editForm);
+                    this.showEdit = true;
+                } else {
+                    this.$message.error(res.data.msg || '获取数据失败');
+                }
+            } catch (e) {
+                loading.close();
+                this.$message.error(e.message || '获取数据失败');
+            }
         },
         /* 重置表单 */
         resetForm() {

+ 1 - 1
app/Http/Controllers/Admin/InstitutionController.php

@@ -60,7 +60,7 @@ class InstitutionController extends Backend
         $id = request()->input("id", 0);
         $info = [];
         if ($id) {
-            $info = $this->service->getInfo($id);
+            $info = $this->service->info();
         }
         return message(MESSAGE_OK, true, $info);
     }

+ 1 - 1
app/Models/InstitutionModel.php

@@ -55,6 +55,6 @@ class InstitutionModel extends BaseModel
 
     public function setThumbAttribute($value)
     {
-        return $value ? get_image_path($value) : '';
+        $this->attributes['thumb'] = $value ? get_image_path($value) : '';
     }
 }

+ 15 - 15
app/Services/Common/InstitutionService.php

@@ -64,6 +64,10 @@ class InstitutionService extends BaseService
                 // 格式化时间
                 $item['create_time'] = $item['create_time'] ? datetime($item['create_time'], 'Y-m-d H:i:s') : '';
                 $item['update_time'] = $item['update_time'] ? datetime($item['update_time'], 'Y-m-d H:i:s') : '';
+                // 处理封面图片URL
+                if (isset($item['thumb']) && $item['thumb']) {
+                    $item['thumb'] = get_image_url($item['thumb']);
+                }
                 // 格式化状态
                 $item['status_text'] = $item['status'] == 1 ? '正常' : '不显示';
                 // 格式化链接类型
@@ -142,24 +146,12 @@ class InstitutionService extends BaseService
             return message('院校代码已存在', false);
         }
 
-        // 处理封面图片
+        // 处理封面图片路径(前端传递的是完整 URL,需要转换为相对路径)
         if (!empty($data['thumb'])) {
             $data['thumb'] = get_image_path($data['thumb']);
         }
 
-        // 确保所有必填字段都存在
-        $data = [
-            'name' => $data['name'] ?? '',
-            'code' => $data['code'] ?? '',
-            'thumb' => $data['thumb'] ?? '',
-            'link_url' => $data['link_url'] ?? '',
-            'link_type' => $data['link_type'] ?? 1,
-            'mp_appid' => $data['mp_appid'] ?? '',
-            'description' => $data['description'] ?? '',
-            'sort' => $data['sort'] ?? 0,
-            'status' => $data['status'] ?? 1,
-        ];
-
+        // 直接传递给 parent::edit,确保包含 id 字段用于判断新增/编辑
         return parent::edit($data);
     }
 
@@ -173,7 +165,15 @@ class InstitutionService extends BaseService
         $id = request()->input("id", 0);
         $info = [];
         if ($id) {
-            $info = $this->model->getInfo($id);
+            // 查询记录
+            $record = $this->model->where('id', $id)->where('mark', 1)->first();
+            if ($record) {
+                $info = $record->toArray();
+                // 处理封面图片URL(确保返回完整URL)
+                if (isset($info['thumb']) && $info['thumb']) {
+                    $info['thumb'] = get_image_url($info['thumb']);
+                }
+            }
         }
         return message(MESSAGE_OK, true, $info);
     }