| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708 |
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="UTF-8">
- <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
- <title>YJBDC文章维护</title>
- <script src="https://kylx365-1253256735.file.myqcloud.com/js/jquery-1.10.2.min.js"></script>
- <script src="https://kylx365-1253256735.file.myqcloud.com/js/vue.min.js"></script>
- <style>
- .main00 {
- width: 100%;
- height: 100vh;
- min-height: 600px;
- background: white;
- display: flex;
- flex-direction: column;
- overflow: hidden;
- }
- .ListTop {
- width: 100%;
- height: 60px;
- background: white;
- border-bottom: 1px solid #EEEEEE;
- justify-content: flex-start;
- flex-shrink: 0;
- }
- .ListTop3 {
- margin-left: 40px;
- height: 50px;
- align-items: center;
- }
- .title {
- font-size: 24px;
- color: #333333;
- font-weight: bold;
- }
- .main0 {
- width: 100%;
- background: white;
- flex: 1;
- min-height: 0;
- overflow: hidden;
- display: flex;
- position: relative;
- align-items: flex-start;
- }
- .search-panel {
- width: 400px;
- border-right: 1px solid #EEEEEE;
- background: #F9F9F9;
- display: flex;
- flex-direction: column;
- height: 100%;
- position: relative;
- flex-shrink: 0;
- }
- .search-box {
- padding: 15px;
- border-bottom: 1px solid #EEEEEE;
- background: white;
- width: 100%;
- justify-content: center;
- }
- .search-input {
- width: 200px;
- height: 32px;
- padding: 0 32px 0 12px;
- border: 1px solid #DDDDDD;
- border-radius: 4px;
- font-size: 14px;
- color: #333333;
- }
- .search-input:focus {
- border-color: #4A90E2;
- outline: none;
- }
- .btn33 {
- width: 32px;
- height: 32px;
- margin-left: 8px;
- border-radius: 4px;
- background: #F5F5F5;
- cursor: pointer;
- justify-content: center;
- align-items: center;
- }
- .btn33:hover {
- background: #EEEEEE;
- }
- .json-editor {
- width: calc(100% - 400px);
- padding: 20px;
- overflow-y: auto;
- height: calc(100% - 60px);
- }
- .json-node {
- margin: 5px 0;
- padding: 5px;
- font-family: monospace;
- }
- .json-key {
- color: #881391;
- margin-right: 5px;
- }
- .json-string {
- color: #268BD2;
- }
- .json-number {
- color: #859900;
- }
- .json-boolean {
- color: #CB4B16;
- }
- .json-null {
- color: #93A1A1;
- }
- .editable {
- cursor: pointer;
- }
- .editable:hover {
- background-color: #f0f0f0;
- }
- .json-editor-input {
- width: 100%;
- padding: 4px;
- font-family: monospace;
- border: 1px solid #4A90E2;
- border-radius: 4px;
- }
- .btn-group {
- position: fixed;
- bottom: 20px;
- right: 20px;
- text-align: right;
- padding: 20px;
- background: white;
- box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
- border-radius: 4px;
- }
- .btn {
- min-width: 30px;
- height: 36px;
- padding: 0 16px;
- margin-left: 12px;
- border: none;
- border-radius: 4px;
- cursor: pointer;
- font-size: 14px;
- transition: all 0.3s;
- }
- .btn-primary {
- background: #4A90E2;
- color: white;
- }
- .btn-primary:hover {
- background: #357ABD;
- }
- .btn-default {
- background: white;
- border: 1px solid #DDDDDD;
- color: #666666;
- }
- .btn-default:hover {
- background: #F5F5F5;
- border-color: #CCCCCC;
- }
- .toast {
- position: fixed;
- top: 20px;
- left: 50%;
- transform: translateX(-50%);
- padding: 12px 24px;
- background: rgba(0, 0, 0, 0.7);
- color: white;
- border-radius: 4px;
- z-index: 9999;
- opacity: 0;
- transition: opacity 0.3s;
- }
- .toast.show {
- opacity: 1;
- }
- .toast.success {
- background: #4CAF50;
- }
- .toast.error {
- background: #F44336;
- }
- .toast.info {
- background: #2196F3;
- }
- /* Loading样式 */
- .loading-overlay {
- position: absolute;
- top: 0;
- left: 0;
- width: 100%;
- height: 100%;
- background-color: rgba(255, 255, 255, 0.7);
- display: flex;
- justify-content: center;
- align-items: center;
- z-index: 100;
- }
- .loading-spinner {
- width: 50px;
- height: 50px;
- border: 5px solid #f3f3f3;
- border-top: 5px solid #4A90E2;
- border-radius: 50%;
- animation: spin 1s linear infinite;
- }
- @keyframes spin {
- 0% {
- transform: rotate(0deg);
- }
- 100% {
- transform: rotate(360deg);
- }
- }
- .clear-btn {
- position: absolute;
- right: 12px;
- top: 50%;
- transform: translateY(-50%);
- width: 16px;
- height: 16px;
- background-color: #999;
- border-radius: 50%;
- display: flex;
- align-items: center;
- justify-content: center;
- cursor: pointer;
- transition: background-color 0.2s;
- }
- .clear-btn:hover {
- background-color: #666;
- }
- .clear-x {
- position: relative;
- width: 8px;
- height: 8px;
- }
- .clear-x:before,
- .clear-x:after {
- content: '';
- position: absolute;
- width: 8px;
- height: 2px;
- background-color: white;
- top: 3px;
- left: 0;
- }
- .clear-x:before {
- transform: rotate(45deg);
- }
- .clear-x:after {
- transform: rotate(-45deg);
- }
- .FlexRow {
- display: flex;
- flex-direction: row;
- }
- .FlexColumn {
- display: flex;
- flex-direction: column;
- }
- </style>
- </head>
- <body class="container FlexRow">
- <div id="app" class="main00 FlexColumn">
- <div class="ListTop FlexRow">
- <div class="ListTop3 FlexRow">
- <div class="title">YJBDC文章维护</div>
- </div>
- </div>
- <div class="main0 FlexRow">
- <!-- 左侧搜索面板 -->
- <div class="search-panel" style="position: relative;">
- <div v-if="isSearchLoading" class="loading-overlay">
- <div class="loading-spinner"></div>
- </div>
- <div class="search-box FlexRow">
- <div style="position: relative;">
- <input type="text" class="search-input" v-model="searchText" @keyup.enter="searchArticles"
- placeholder="输入用户ID搜索...">
- <div class="clear-btn" v-show="searchText" @click="clearSearch">
- <span class="clear-x"></span>
- </div>
- </div>
- <div class="btn33 FlexRow" @click="searchArticles">
- <img title="搜索" alt="搜索"
- src="https://kylx365-1253256735.file.myqcloud.com/web/universalpic_search_gray_30x30.png"
- style="width: 20px; height: 20px;" />
- </div>
- </div>
- <!-- 搜索结果列表 -->
- <div class="search-results" style="flex: 1; overflow-y: auto; padding: 10px;">
- <div v-if="articles && articles.length > 0" v-for="(article, index) in articles" :key="index"
- @click="selectArticle(article)"
- style="padding: 10px; margin: 5px 0; background: white; border-radius: 4px; cursor: pointer; transition: background-color 0.2s;"
- :style="{ backgroundColor: selectedArticle === article ? '#e6f3ff' : 'white' }"
- class="search-result-item">
- <div style="font-weight: bold;">文章ID: {{ article.ID }}</div>
- <div style="font-size: 12px; color: #666; margin-top: 4px;">
- 创建时间: {{ article.CreateTime }}
- </div>
- <div style="font-size: 12px; color: #666;">
- 标题: {{ article.ArticleTitle }}
- </div>
- <div style="font-size: 12px; color: #666;">
- 单词表: {{ article.Words }}
- </div>
- <div style="font-size: 12px; color: #666;">
- 是否精选: {{ article.IsFine ? "是" : "否" }}
- </div>
- </div>
- <div v-else-if="articles && articles.length === 0"
- style="text-align: center; color: #999; padding: 20px;">
- 未找到相关文章
- </div>
- </div>
- </div>
- <!-- 右侧文章内容编辑器 -->
- <div class="json-editor" v-if="selectedArticle" style="position: relative;">
- <div v-if="isDetailLoading" class="loading-overlay">
- <div class="loading-spinner"></div>
- </div>
- <div class="json-node">
- <span class="json-key">文章ID:</span>
- <span class="json-number">{{ selectedArticle.ID }}</span>
- </div>
- <div class="json-node">
- <span class="json-key">是否精选:</span>
- <span class="json-number editable" @dblclick="editValue(selectedArticle, 'IsFine', 'IsFine')">
- <template v-if="editingKey === 'IsFine'">
- <label style="margin-right: 10px;">
- <input type="radio" v-model.number="selectedArticle.IsFine" :value="1"
- @change="finishEdit"> 是
- </label>
- <label>
- <input type="radio" v-model.number="selectedArticle.IsFine" :value="0"
- @change="finishEdit"> 否
- </label>
- </template>
- <template v-else>
- {{ selectedArticle.IsFine == 1 || selectedArticle.IsFine == "1" ? "是" : "否" }}
- </template>
- </span>
- </div>
- <div class="json-node">
- <span class="json-key">文章英文标题:</span>
- <span class="json-string editable"
- @dblclick="editValue(selectedArticle, 'ArticleTitle', 'ArticleTitle')">
- <template v-if="editingKey === 'ArticleTitle'">
- <input type="text" class="json-editor-input" v-model="selectedArticle.ArticleTitle"
- @blur="finishEdit" @keyup.enter="finishEdit" v-focus>
- </template>
- <template v-else>
- "{{ selectedArticle.ArticleTitle }}"
- </template>
- </span>
- </div>
- <div class="json-node">
- <span class="json-key">文章中文标题:</span>
- <span class="json-string editable"
- @dblclick="editValue(selectedArticle, 'ArticleTitleCHN', 'ArticleTitleCHN')">
- <template v-if="editingKey === 'ArticleTitleCHN'">
- <input type="text" class="json-editor-input" v-model="selectedArticle.ArticleTitleCHN"
- @blur="finishEdit" @keyup.enter="finishEdit" v-focus>
- </template>
- <template v-else>
- "{{ selectedArticle.ArticleTitleCHN }}"
- </template>
- </span>
- </div>
- <div class="json-node">
- <span class="json-key">文章图片名称:</span>
- <span class="json-string editable"
- @dblclick="editValue(selectedArticle, 'ArticleImage', 'ArticleImage')">
- <template v-if="editingKey === 'ArticleImage'">
- <input type="text" class="json-editor-input" v-model="selectedArticle.ArticleImage"
- @blur="finishEdit" @keyup.enter="finishEdit" v-focus>
- </template>
- <template v-else>
- "{{ selectedArticle.ArticleImage }}"
- </template>
- </span>
- </div>
- <div class="json-node">
- <span class="json-key">创建时间:</span>
- <span class="json-string editable"
- @dblclick="editValue(selectedArticle, 'CreateTime', 'CreateTime')">
- <template v-if="editingKey === 'CreateTime'">
- <input type="text" disabled="true" class="json-editor-input"
- v-model="selectedArticle.CreateTime" @blur="finishEdit" @keyup.enter="finishEdit"
- v-focus>
- </template>
- <template v-else>
- "{{ selectedArticle.CreateTime }}"
- </template>
- </span>
- </div>
- <div class="json-node">
- <span class="json-key">英语文章:</span>
- <span class="json-string editable"
- @dblclick="editValue(selectedArticle, 'ArticleStart', 'ArticleStart')">
- <template v-if="editingKey === 'ArticleStart'">
- <input type="text" disabled="true" class="json-editor-input"
- v-model="selectedArticle.ArticleStart" @blur="finishEdit" @keyup.enter="finishEdit"
- v-focus>
- </template>
- <template v-else>
- "{{ selectedArticle.ArticleStart }}"
- </template>
- </span>
- </div>
- <div class="json-node">
- <span class="json-key">用户ID:</span>
- <span class="json-number editable" @dblclick="editValue(selectedArticle, 'UserID', 'UserID')">
- <template v-if="editingKey === 'UserID'">
- <input type="number" disabled="true" class="json-editor-input"
- v-model.number="selectedArticle.UserID" @blur="finishEdit" @keyup.enter="finishEdit"
- v-focus>
- </template>
- <template v-else>
- {{ selectedArticle.UserID }}
- </template>
- </span>
- </div>
- <div class="json-node">
- <span class="json-key">生成秒数:</span>
- <span class="json-number editable"
- @dblclick="editValue(selectedArticle, 'GenerateTime', 'GenerateTime')">
- <template v-if="editingKey === 'GenerateTime'">
- <input type="number" disabled="true" class="json-editor-input"
- v-model.number="selectedArticle.GenerateTime" @blur="finishEdit"
- @keyup.enter="finishEdit" v-focus>
- </template>
- <template v-else>
- {{ selectedArticle.GenerateTime }}
- </template>
- </span>
- </div>
- <div class="json-node">
- <span class="json-key">使用AI模型:</span>
- <span class="json-string editable"
- @dblclick="editValue(selectedArticle, 'AIProvider', 'AIProvider')">
- <template v-if="editingKey === 'AIProvider'">
- <input type="text" disabled="true" class="json-editor-input"
- v-model="selectedArticle.AIProvider" @blur="finishEdit" @keyup.enter="finishEdit"
- v-focus>
- </template>
- <template v-else>
- "{{ selectedArticle.AIProvider }}"
- </template>
- </span>
- </div>
- <div class="json-node">
- <span class="json-key">提示语:</span>
- <span class="json-string editable" @dblclick="editValue(selectedArticle, 'BuildStr', 'BuildStr')">
- <template v-if="editingKey === 'BuildStr'">
- <input type="text" disabled="true" class="json-editor-input"
- v-model="selectedArticle.BuildStr" @blur="finishEdit" @keyup.enter="finishEdit" v-focus>
- </template>
- <template v-else>
- "{{ selectedArticle.BuildStr }}"
- </template>
- </span>
- </div>
- <div class="json-node">
- <span class="json-key">单词表:</span>
- <span class="json-string editable" @dblclick="editValue(selectedArticle, 'Words', 'Words')">
- <template v-if="editingKey === 'Words'">
- <input type="text" disabled="true" class="json-editor-input" v-model="selectedArticle.Words"
- @blur="finishEdit" @keyup.enter="finishEdit" v-focus>
- </template>
- <template v-else>
- "{{ selectedArticle.Words }}"
- </template>
- </span>
- </div>
- <div class="json-node">
- <span class="json-key">文章难度:</span>
- <span class="json-string editable" @dblclick="editValue(selectedArticle, 'Level', 'Level')">
- <template v-if="editingKey === 'Level'">
- <input type="text" disabled="true" class="json-editor-input" v-model="selectedArticle.Level"
- @blur="finishEdit" @keyup.enter="finishEdit" v-focus>
- </template>
- <template v-else>
- "{{ selectedArticle.Level }}"
- </template>
- </span>
- </div>
- <div class="json-node">
- <span class="json-key">文章类型:</span>
- <span class="json-string editable"
- @dblclick="editValue(selectedArticle, 'ArticleStyle', 'ArticleStyle')">
- <template v-if="editingKey === 'ArticleStyle'">
- <input type="text" disabled="true" class="json-editor-input"
- v-model="selectedArticle.ArticleStyle" @blur="finishEdit" @keyup.enter="finishEdit"
- v-focus>
- </template>
- <template v-else>
- "{{ selectedArticle.ArticleStyle }}"
- </template>
- </span>
- </div>
- <div class="json-node">
- <span class="json-key">用户阅读数:</span>
- <span class="json-number editable" @dblclick="editValue(selectedArticle, 'ReadCount', 'ReadCount')">
- <template v-if="editingKey === 'ReadCount'">
- <input type="number" disabled="true" class="json-editor-input"
- v-model.number="selectedArticle.ReadCount" @blur="finishEdit" @keyup.enter="finishEdit"
- v-focus>
- </template>
- <template v-else>
- {{ selectedArticle.ReadCount }}
- </template>
- </span>
- </div>
- <div class="json-node">
- <span class="json-key">JSON结果:</span>
- <span class="json-string editable"
- @dblclick="editValue(selectedArticle, 'JSONString', 'JSONString')">
- <template v-if="editingKey === 'JSONString'">
- <textarea class="json-editor-input" disabled="true" v-model="selectedArticle.JSONString"
- @blur="finishEdit" @keyup.enter="finishEdit" v-focus></textarea>
- </template>
- <template v-else>
- "{{ selectedArticle.JSONString }}"
- </template>
- </span>
- </div>
- <div class="json-node">
- <span class="json-key">是否删除:</span>
- <span class="json-number editable" @dblclick="editValue(selectedArticle, 'Flag', 'Flag')">
- <template v-if="editingKey === 'Flag'">
- <input type="number" disabled="true" class="json-editor-input"
- v-model.number="selectedArticle.Flag" @blur="finishEdit" @keyup.enter="finishEdit"
- v-focus>
- </template>
- <template v-else>
- {{ selectedArticle.Flag }}
- </template>
- </span>
- </div>
- <div class="btn-group">
- <button class="btn btn-primary" @click="saveArticle">保存</button>
- <button class="btn btn-default" @click="cancelEdit">取消</button>
- </div>
- </div>
- </div>
- <div class="toast" :class="{ show: showToastFlag, [toastType]: showToastFlag }">{{ toastMessage }}</div>
- </div>
-
- <script>
- new Vue({
- el: '#app',
- data: {
- searchText: '',
- articles: [],
- selectedArticle: null,
- isSearchLoading: false,
- isDetailLoading: false,
- editingKey: null,
- toastMessage: '',
- toastType: 'info',
- showToastFlag: false
- },
- methods: {
- searchArticles() {
- if (!this.searchText) return;
- this.isSearchLoading = true;
- $.ajax({
- url: `api/GetYJBDCArticleList?UserID=${this.searchText}&PageCount=100`,
- method: 'GET',
- success: (data) => {
- this.articles = data.result;
- this.isSearchLoading = false;
- },
- error: () => {
- this.isSearchLoading = false;
- }
- });
- },
- selectArticle(article) {
- this.isDetailLoading = true;
- this.selectedArticle = null;
- $.ajax({
- url: `api/GetYJBDCArticleList?UserID=${this.searchText}&ID=${article.ID}`,
- method: 'GET',
- success: (data) => {
- this.selectedArticle = data.result[0];
- this.isDetailLoading = false;
- },
- error: () => {
- this.isDetailLoading = false;
- }
- });
- },
- clearSearch() {
- this.searchText = '';
- this.articles = [];
- this.selectedArticle = null;
- },
- editValue(obj, key, editingKey) {
- this.editingKey = editingKey;
- },
- finishEdit() {
- this.editingKey = null;
- },
- saveArticle() {
- if (!this.selectedArticle) return;
- this.isDetailLoading = true;
- this.selectedArticle.Source = "web";
- $.ajax({
- url: 'api/UpdateYJBDCArticle',
- method: 'POST',
- data: this.selectedArticle,
- success: () => {
- this.isDetailLoading = false;
- this.showToast('保存成功', 'success');
- // 重新加载文章列表和当前选中的文章
- this.searchArticles();
- this.selectArticle(this.selectedArticle);
- },
- error: () => {
- this.isDetailLoading = false;
- alert('保存失败');
- }
- });
- },
- cancelEdit() {
- this.selectedArticle = null;
- },
- showToast(message, type = 'info') {
- this.toastMessage = message;
- this.toastType = type;
- this.showToastFlag = true;
- // 自动隐藏
- setTimeout(() => {
- this.showToastFlag = false;
- }, 3000);
- },
- },
- directives: {
- focus: {
- inserted(el) {
- el.focus();
- }
- }
- }
- });
- </script>
- </body>
- </html>
|