5 changed files with 1166 additions and 311 deletions
@ -0,0 +1,796 @@ |
|||||||
|
@@master_page.html |
||||||
|
<style> |
||||||
|
.filed-container { |
||||||
|
width: 100%; |
||||||
|
height: 100%; |
||||||
|
background-color: #fff; |
||||||
|
padding: 20px; |
||||||
|
position: relative; |
||||||
|
display: flex; |
||||||
|
flex-flow: column nowrap; |
||||||
|
gap: 20px; |
||||||
|
} |
||||||
|
.filed-container::before { |
||||||
|
content: ''; |
||||||
|
position: absolute; |
||||||
|
top: 0; |
||||||
|
left: 50%; |
||||||
|
width: 2px; |
||||||
|
height: 100%; |
||||||
|
background-image: linear-gradient( |
||||||
|
to bottom, |
||||||
|
#e6f3ff, |
||||||
|
#fff7e6 |
||||||
|
); |
||||||
|
border-radius: 50%; |
||||||
|
} |
||||||
|
.info-container { |
||||||
|
display: flex; |
||||||
|
align-items: center; |
||||||
|
} |
||||||
|
.info-item { |
||||||
|
flex: 1; |
||||||
|
display: flex; |
||||||
|
justify-content: center; |
||||||
|
align-items: center; |
||||||
|
flex-flow: column; |
||||||
|
gap: 20px; |
||||||
|
} |
||||||
|
.footer { |
||||||
|
display: flex; |
||||||
|
justify-content: space-between; |
||||||
|
} |
||||||
|
.footer-item { |
||||||
|
display: flex; |
||||||
|
align-items: center; |
||||||
|
gap: 10px; |
||||||
|
} |
||||||
|
.info-item-title { |
||||||
|
display: flex; |
||||||
|
align-items: center; |
||||||
|
font-weight: bold; |
||||||
|
font-size: 16px; |
||||||
|
display: flex; |
||||||
|
gap: 10px; |
||||||
|
} |
||||||
|
.info-item-upload { |
||||||
|
display: flex; |
||||||
|
align-items: center; |
||||||
|
gap: 5px; |
||||||
|
cursor: pointer; |
||||||
|
font-weight: initial; |
||||||
|
font-size: 14px; |
||||||
|
color: #419ff8; |
||||||
|
border-bottom: 1px solid #419ff8; |
||||||
|
} |
||||||
|
.info-item-input-container { |
||||||
|
display: flex; |
||||||
|
align-items: center; |
||||||
|
gap: 5px; |
||||||
|
} |
||||||
|
.info-item-input { |
||||||
|
width: 200px; |
||||||
|
height: 32px; |
||||||
|
padding: 4px 11px; |
||||||
|
border: 1px solid #d9d9d9; |
||||||
|
border-radius: 4px; |
||||||
|
transition: all 0.3s; |
||||||
|
font-size: 14px; |
||||||
|
color: #333; |
||||||
|
outline: none; |
||||||
|
box-sizing: border-box; |
||||||
|
} |
||||||
|
.info-form-container { |
||||||
|
display: flex; |
||||||
|
flex-flow: row nowrap; |
||||||
|
align-items: center; |
||||||
|
gap: 10px; |
||||||
|
} |
||||||
|
.table { |
||||||
|
width: 100%; |
||||||
|
table-layout: fixed; |
||||||
|
border-collapse: collapse; |
||||||
|
} |
||||||
|
.table th, |
||||||
|
.table td { |
||||||
|
overflow: hidden; |
||||||
|
text-overflow: ellipsis; |
||||||
|
white-space: nowrap; |
||||||
|
} |
||||||
|
.table th:nth-child(1), |
||||||
|
.table td:nth-child(1) { |
||||||
|
width: 70px; |
||||||
|
} |
||||||
|
.table th:nth-child(2), |
||||||
|
.table td:nth-child(2), |
||||||
|
.table th:nth-child(6), |
||||||
|
.table td:nth-child(6) { |
||||||
|
width: 125px; |
||||||
|
} |
||||||
|
.table th:nth-child(3), |
||||||
|
.table td:nth-child(3), |
||||||
|
.table th:nth-child(7), |
||||||
|
.table td:nth-child(7) { |
||||||
|
width: 120px; |
||||||
|
} |
||||||
|
.table th:nth-child(4), |
||||||
|
.table td:nth-child(4), |
||||||
|
.table th:nth-child(8), |
||||||
|
.table td:nth-child(8) { |
||||||
|
width: 100px; |
||||||
|
} |
||||||
|
.table th:nth-child(5), |
||||||
|
.table td:nth-child(5), |
||||||
|
.table th:nth-child(9), |
||||||
|
.table td:nth-child(9) { |
||||||
|
width: 100px; |
||||||
|
} |
||||||
|
.table th:nth-child(10), |
||||||
|
.table td:nth-child(10) { |
||||||
|
width: 70px; |
||||||
|
text-align: center; |
||||||
|
} |
||||||
|
.footer-item-button { |
||||||
|
display: flex; |
||||||
|
align-items: center; |
||||||
|
justify-content: center; |
||||||
|
padding: 8px 16px; |
||||||
|
border-radius: 999px; |
||||||
|
font-size: 14px; |
||||||
|
cursor: pointer; |
||||||
|
transition: all 0.3s; |
||||||
|
border: none; |
||||||
|
color: #333; |
||||||
|
gap: 5px; |
||||||
|
} |
||||||
|
.table-row { |
||||||
|
display: flex; |
||||||
|
flex-flow: row nowrap; |
||||||
|
align-items: center; |
||||||
|
justify-content: center; |
||||||
|
} |
||||||
|
.local-park, |
||||||
|
.third-park { |
||||||
|
width: 100%; |
||||||
|
flex: 1; |
||||||
|
display: flex; |
||||||
|
flex-flow: row nowrap; |
||||||
|
align-items: center; |
||||||
|
justify-content: center; |
||||||
|
} |
||||||
|
.local-park th, |
||||||
|
.third-park th { |
||||||
|
flex: 1; |
||||||
|
} |
||||||
|
.table-item-input { |
||||||
|
width: 100%; |
||||||
|
padding: 8px 12px; |
||||||
|
border-radius: 4px; |
||||||
|
border: none; |
||||||
|
font-size: 14px; |
||||||
|
color: #606266; |
||||||
|
background-color: #fff; |
||||||
|
transition: border-color 0.2s ease; |
||||||
|
outline: none; |
||||||
|
box-sizing: border-box; |
||||||
|
|
||||||
|
&:disabled { |
||||||
|
background-color: #f5f7fa; |
||||||
|
border-color: #e4e7ed; |
||||||
|
color: #c0c4cc; |
||||||
|
cursor: not-allowed; |
||||||
|
} |
||||||
|
|
||||||
|
&::placeholder { |
||||||
|
color: #c0c4cc; |
||||||
|
} |
||||||
|
} |
||||||
|
.table-item-select { |
||||||
|
width: 100%; |
||||||
|
padding: 8px 12px; |
||||||
|
border: 1px solid #dcdfe6; |
||||||
|
border-radius: 4px; |
||||||
|
font-size: 14px; |
||||||
|
color: #606266; |
||||||
|
outline: none; |
||||||
|
box-sizing: border-box; |
||||||
|
border: none; |
||||||
|
&:disabled { |
||||||
|
background-color: #f5f7fa; |
||||||
|
border-color: #e4e7ed; |
||||||
|
color: #c0c4cc; |
||||||
|
cursor: not-allowed; |
||||||
|
} |
||||||
|
|
||||||
|
&::placeholder { |
||||||
|
color: #c0c4cc; |
||||||
|
} |
||||||
|
} |
||||||
|
.table-item-button { |
||||||
|
display: inline-flex; |
||||||
|
align-items: center; |
||||||
|
justify-content: center; |
||||||
|
border-radius: 50%; |
||||||
|
border: none; |
||||||
|
padding: 8px; |
||||||
|
background-color: transparent; |
||||||
|
color: #606266; |
||||||
|
cursor: pointer; |
||||||
|
transition: all 0.2s ease; |
||||||
|
height: 32px; |
||||||
|
width: 32px; |
||||||
|
&:hover { |
||||||
|
background-color: #f2f6fc; |
||||||
|
color: #409eff; |
||||||
|
} |
||||||
|
|
||||||
|
&:active { |
||||||
|
background-color: #ecf5ff; |
||||||
|
} |
||||||
|
|
||||||
|
.mdi { |
||||||
|
font-size: 20px; |
||||||
|
} |
||||||
|
|
||||||
|
&[title='保存'] { |
||||||
|
color: #67c23a; |
||||||
|
|
||||||
|
&:hover { |
||||||
|
background-color: #f0f9eb; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
&[title='取消'] { |
||||||
|
color: #909399; |
||||||
|
|
||||||
|
&:hover { |
||||||
|
background-color: #f4f4f5; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
&[title='删除'] { |
||||||
|
color: #f56c6c; |
||||||
|
|
||||||
|
&:hover { |
||||||
|
background-color: #fef0f0; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
.info-item-upload-name { |
||||||
|
color: #01c853; |
||||||
|
} |
||||||
|
</style> |
||||||
|
<div |
||||||
|
id="apibox" |
||||||
|
class="card" |
||||||
|
> |
||||||
|
<section class="filed-container"> |
||||||
|
<section class="info-container"> |
||||||
|
<section class="info-item"> |
||||||
|
<section class="info-item-title"> |
||||||
|
本地表 |
||||||
|
<section |
||||||
|
class="info-item-upload-name" |
||||||
|
v-show="localJosnName" |
||||||
|
> |
||||||
|
{{`(${localJosnName})`}} |
||||||
|
</section> |
||||||
|
<section |
||||||
|
class="info-item-upload" |
||||||
|
@click="uploadLocalFile" |
||||||
|
> |
||||||
|
<input |
||||||
|
type="file" |
||||||
|
style="opacity: 0; display: none" |
||||||
|
id="localFile" |
||||||
|
accept=".json" |
||||||
|
/> |
||||||
|
<i class="mdi mdi-cloud-upload"></i> |
||||||
|
导入本地表 |
||||||
|
</section> |
||||||
|
</section> |
||||||
|
<section class="info-form-container"> |
||||||
|
<section class="info-item-input-container"> |
||||||
|
表名<input |
||||||
|
type="text" |
||||||
|
class="info-item-input" |
||||||
|
v-model="cachesData.SYSTEM_TABLE_NAME" |
||||||
|
placeholder="请输入表名" |
||||||
|
/> |
||||||
|
</section> |
||||||
|
<section class="info-item-input-container"> |
||||||
|
表注释<input |
||||||
|
type="text" |
||||||
|
class="info-item-input" |
||||||
|
v-model="cachesData.SYSTEM_TABLE_CNNAME" |
||||||
|
placeholder="请输入表注释" |
||||||
|
/> |
||||||
|
</section> |
||||||
|
</section> |
||||||
|
</section> |
||||||
|
<section class="info-item"> |
||||||
|
<section class="info-item-title"> |
||||||
|
三方表 |
||||||
|
<section |
||||||
|
class="info-item-upload-name" |
||||||
|
v-show="thirdJsonName" |
||||||
|
> |
||||||
|
({{thirdJsonName}}) |
||||||
|
</section> |
||||||
|
<section |
||||||
|
class="info-item-upload" |
||||||
|
@click="uploadThirdFile" |
||||||
|
> |
||||||
|
<input |
||||||
|
type="file" |
||||||
|
style="opacity: 0; display: none" |
||||||
|
id="thirdFile" |
||||||
|
accept=".json" |
||||||
|
/> |
||||||
|
<i class="mdi mdi-cloud-upload"></i> |
||||||
|
导入三方表 |
||||||
|
</section> |
||||||
|
</section> |
||||||
|
<section class="info-form-container"> |
||||||
|
<section class="info-item-input-container"> |
||||||
|
表名<input |
||||||
|
type="text" |
||||||
|
class="info-item-input" |
||||||
|
v-model="cachesData.OBJECT_TABLE_NAME" |
||||||
|
placeholder="请输入表名" |
||||||
|
/> |
||||||
|
</section> |
||||||
|
<section class="info-item-input-container"> |
||||||
|
表注释<input |
||||||
|
type="text" |
||||||
|
class="info-item-input" |
||||||
|
v-model="cachesData.OBJECT_TABLE_CNNAME" |
||||||
|
placeholder="请输入表注释" |
||||||
|
/> |
||||||
|
</section> |
||||||
|
</section> |
||||||
|
</section> |
||||||
|
</section> |
||||||
|
<table class="table"> |
||||||
|
<thead> |
||||||
|
<tr> |
||||||
|
<th>序号</th> |
||||||
|
<th style="background-color: #e6f3ff">字段名</th> |
||||||
|
<th style="background-color: #e6f3ff"> |
||||||
|
字段注释 |
||||||
|
</th> |
||||||
|
<th style="background-color: #e6f3ff"> |
||||||
|
字段类型 |
||||||
|
</th> |
||||||
|
<th style="background-color: #e6f3ff"> |
||||||
|
字典名称 |
||||||
|
</th> |
||||||
|
<th style="background-color: #fff7e6">字段名</th> |
||||||
|
<th style="background-color: #fff7e6"> |
||||||
|
字段注释 |
||||||
|
</th> |
||||||
|
<th style="background-color: #fff7e6"> |
||||||
|
字段类型 |
||||||
|
</th> |
||||||
|
<th style="background-color: #fff7e6"> |
||||||
|
字典名称 |
||||||
|
</th> |
||||||
|
<th>操作</th> |
||||||
|
</tr> |
||||||
|
</thead> |
||||||
|
<tbody> |
||||||
|
<tr |
||||||
|
v-for="(item, index) in data" |
||||||
|
:key="index" |
||||||
|
> |
||||||
|
<td style="width: 150px">{{index + 1}}</td> |
||||||
|
<td |
||||||
|
style=" |
||||||
|
background-color: #f5f9ff; |
||||||
|
position: relative; |
||||||
|
" |
||||||
|
> |
||||||
|
{{item.SYSTEM_FIELD}} |
||||||
|
</td> |
||||||
|
<td style="background-color: #f5f9ff"> |
||||||
|
{{item.SYSTEM_NAME}} |
||||||
|
</td> |
||||||
|
<td style="background-color: #f5f9ff"> |
||||||
|
{{item.SYSTEM_FIELD_TYPE}} |
||||||
|
</td> |
||||||
|
<td style="background-color: #f5f9ff"> |
||||||
|
{{item.SYSTEM_DICT_NAME}} |
||||||
|
</td> |
||||||
|
<td style="background-color: #fffbf2"> |
||||||
|
{{item.INTERFACE_FIELD}} |
||||||
|
</td> |
||||||
|
<td style="background-color: #fffbf2"> |
||||||
|
{{item.INTERFACE_NAME}} |
||||||
|
</td> |
||||||
|
<td style="background-color: #fffbf2"> |
||||||
|
{{item.OBJECT_FIELD_TYPE}} |
||||||
|
</td> |
||||||
|
<td style="background-color: #fffbf2"> |
||||||
|
{{item.OBJECT_DICT_NAME}} |
||||||
|
</td> |
||||||
|
<td> |
||||||
|
<button |
||||||
|
@click="deleteField(index)" |
||||||
|
class="table-item-button" |
||||||
|
title="删除" |
||||||
|
> |
||||||
|
<i class="mdi mdi-delete"></i> |
||||||
|
</button> |
||||||
|
</td> |
||||||
|
</tr> |
||||||
|
<tr v-show="isEditing"> |
||||||
|
<td style="width: 150px">{{data.length + 1}}</td> |
||||||
|
<td |
||||||
|
style=" |
||||||
|
background-color: #f5f9ff; |
||||||
|
position: relative; |
||||||
|
" |
||||||
|
> |
||||||
|
<input |
||||||
|
v-model="submitData.SYSTEM_FIELD" |
||||||
|
class="table-item-select" |
||||||
|
placeholder="请输入字段名" |
||||||
|
style=" |
||||||
|
z-index: 1; |
||||||
|
position: absolute; |
||||||
|
top: 50%; |
||||||
|
left: 0%; |
||||||
|
width: 80%; |
||||||
|
border: none; |
||||||
|
transform: translateY(-50%) translateX(10%); |
||||||
|
" |
||||||
|
/> |
||||||
|
<select |
||||||
|
id="localSelect" |
||||||
|
class="table-item-select" |
||||||
|
style=" |
||||||
|
position: absolute; |
||||||
|
z-index: 0; |
||||||
|
top: 50%; |
||||||
|
left: 0%; |
||||||
|
width: 90%; |
||||||
|
transform: translateY(-50%) translateX(10%); |
||||||
|
" |
||||||
|
title="请选择字段名称" |
||||||
|
@change="localChange" |
||||||
|
> |
||||||
|
<option |
||||||
|
v-for="(type,index) in Object.keys(localJsonData)" |
||||||
|
:key="index" |
||||||
|
:value="type" |
||||||
|
> |
||||||
|
<section>{{type}}</section> |
||||||
|
</option> |
||||||
|
</select> |
||||||
|
</td> |
||||||
|
<td style="background-color: #f5f9ff"> |
||||||
|
<input |
||||||
|
v-model="submitData.SYSTEM_NAME" |
||||||
|
class="table-item-input" |
||||||
|
placeholder="请输入字段名" |
||||||
|
/> |
||||||
|
</td> |
||||||
|
<td style="background-color: #f5f9ff"> |
||||||
|
<select |
||||||
|
v-model="submitData.SYSTEM_FIELD_TYPE" |
||||||
|
class="table-item-input" |
||||||
|
placeholder="请选择字段类型" |
||||||
|
> |
||||||
|
<option |
||||||
|
v-for="type in dict.filedType" |
||||||
|
:key="type.VALUE" |
||||||
|
:value="type.VALUE" |
||||||
|
> |
||||||
|
{{type.LABEL}} |
||||||
|
</option> |
||||||
|
</select> |
||||||
|
</td> |
||||||
|
<td style="background-color: #f5f9ff"> |
||||||
|
<input |
||||||
|
v-model="submitData.SYSTEM_DICT_NAME" |
||||||
|
class="table-item-input" |
||||||
|
placeholder="请输入字典名称" |
||||||
|
:style="{display: submitData.SYSTEM_FIELD_TYPE == 'dict' ? 'block' : 'none'}" |
||||||
|
/> |
||||||
|
</td> |
||||||
|
<td |
||||||
|
style=" |
||||||
|
background-color: #fffbf2; |
||||||
|
position: relative; |
||||||
|
" |
||||||
|
> |
||||||
|
<input |
||||||
|
v-model="submitData.INTERFACE_FIELD" |
||||||
|
class="table-item-select" |
||||||
|
placeholder="请输入字段名" |
||||||
|
style=" |
||||||
|
z-index: 1; |
||||||
|
position: absolute; |
||||||
|
top: 50%; |
||||||
|
left: 0%; |
||||||
|
width: 80%; |
||||||
|
border: none; |
||||||
|
transform: translateY(-50%) translateX(10%); |
||||||
|
" |
||||||
|
/> |
||||||
|
<select |
||||||
|
id="thridSelect" |
||||||
|
class="table-item-select" |
||||||
|
style=" |
||||||
|
position: absolute; |
||||||
|
z-index: 0; |
||||||
|
top: 50%; |
||||||
|
left: 0%; |
||||||
|
width: 90%; |
||||||
|
transform: translateY(-50%) translateX(10%); |
||||||
|
" |
||||||
|
title="请选择字段名称" |
||||||
|
@change="thridChange" |
||||||
|
> |
||||||
|
<option |
||||||
|
v-for="(type,index) in Object.keys(thirdJsonData)" |
||||||
|
:key="index" |
||||||
|
:value="type" |
||||||
|
> |
||||||
|
{{type}} |
||||||
|
</option> |
||||||
|
</select> |
||||||
|
</td> |
||||||
|
<td style="background-color: #fffbf2"> |
||||||
|
<input |
||||||
|
v-model="submitData.INTERFACE_NAME" |
||||||
|
class="table-item-input" |
||||||
|
placeholder="请输入字段注释" |
||||||
|
/> |
||||||
|
</td> |
||||||
|
<td style="background-color: #fffbf2"> |
||||||
|
<select |
||||||
|
v-model="submitData.OBJECT_FIELD_TYPE" |
||||||
|
class="table-item-input" |
||||||
|
placeholder="请选择字段类型" |
||||||
|
> |
||||||
|
<option |
||||||
|
v-for="type in dict.filedType" |
||||||
|
:key="type.VALUE" |
||||||
|
:value="type.VALUE" |
||||||
|
> |
||||||
|
{{type.LABEL}} |
||||||
|
</option> |
||||||
|
</select> |
||||||
|
</td> |
||||||
|
<td style="background-color: #fffbf2"> |
||||||
|
<input |
||||||
|
v-model="submitData.OBJECT_DICT_NAME" |
||||||
|
class="table-item-input" |
||||||
|
placeholder="请输入字典名称" |
||||||
|
:style="{display: submitData.OBJECT_FIELD_TYPE == 'dict' ? 'block' : 'none'}" |
||||||
|
/> |
||||||
|
</td> |
||||||
|
<td> |
||||||
|
<button |
||||||
|
@click="saveField(index)" |
||||||
|
class="table-item-button" |
||||||
|
title="保存" |
||||||
|
> |
||||||
|
<i class="mdi mdi-content-save"></i> |
||||||
|
</button> |
||||||
|
<button |
||||||
|
@click="cancelField(index)" |
||||||
|
class="table-item-button" |
||||||
|
title="取消" |
||||||
|
> |
||||||
|
<i class="mdi mdi-cancel"></i> |
||||||
|
</button> |
||||||
|
</td> |
||||||
|
</tr> |
||||||
|
</tbody> |
||||||
|
</table> |
||||||
|
<section class="footer"> |
||||||
|
<section class="footer-item"> |
||||||
|
<button |
||||||
|
class="footer-item-button" |
||||||
|
style="background-color: #419ff8; color: #fff" |
||||||
|
@click="addNewField" |
||||||
|
> |
||||||
|
<i class="mdi mdi-plus"></i> 新增字段 |
||||||
|
</button> |
||||||
|
</section> |
||||||
|
<section class="footer-item"> |
||||||
|
<button |
||||||
|
class="footer-item-button" |
||||||
|
style="background-color: #ff8903; color: #fff" |
||||||
|
@click="cancelAll" |
||||||
|
> |
||||||
|
<i class="mdi mdi-close"></i>取消 |
||||||
|
</button> |
||||||
|
<button |
||||||
|
class="footer-item-button" |
||||||
|
style="background-color: #01c853; color: #fff" |
||||||
|
@click="saveAll" |
||||||
|
> |
||||||
|
<i class="mdi mdi-check"></i>保存 |
||||||
|
</button> |
||||||
|
</section> |
||||||
|
</section> |
||||||
|
</section> |
||||||
|
</div> |
||||||
|
<script> |
||||||
|
var vueObj = new Vue({ |
||||||
|
el: '#apibox', |
||||||
|
data() { |
||||||
|
return { |
||||||
|
dict: { |
||||||
|
filedType: [], |
||||||
|
}, |
||||||
|
isEditing: true, |
||||||
|
data: [ |
||||||
|
{ |
||||||
|
SYSTEM_NAME: '测试1', |
||||||
|
SYSTEM_FIELD: 'test1', |
||||||
|
INTERFACE_NAME: '测试2', |
||||||
|
INTERFACE_FIELD: 'test2', |
||||||
|
SYSTEM_FIELD_TYPE: 'value', |
||||||
|
SYSTEM_DICT_NAME: '', |
||||||
|
OBJECT_FIELD_TYPE: 'value', |
||||||
|
OBJECT_DICT_NAME: '', |
||||||
|
}, |
||||||
|
{ |
||||||
|
SYSTEM_NAME: '测试2', |
||||||
|
SYSTEM_FIELD: 'test2', |
||||||
|
INTERFACE_NAME: '测试3', |
||||||
|
INTERFACE_FIELD: 'test3', |
||||||
|
SYSTEM_FIELD_TYPE: 'value', |
||||||
|
SYSTEM_DICT_NAME: '', |
||||||
|
OBJECT_FIELD_TYPE: 'value', |
||||||
|
OBJECT_DICT_NAME: '', |
||||||
|
}, |
||||||
|
], |
||||||
|
localJsonData: {}, |
||||||
|
localJosnName: '', |
||||||
|
thirdJsonData: {}, |
||||||
|
thirdJsonName: '', |
||||||
|
submitData: { |
||||||
|
SYSTEM_NAME: '', |
||||||
|
SYSTEM_FIELD: '', |
||||||
|
INTERFACE_NAME: '', |
||||||
|
INTERFACE_FIELD: '', |
||||||
|
SYSTEM_FIELD_TYPE: 'value', |
||||||
|
SYSTEM_DICT_NAME: '', |
||||||
|
OBJECT_FIELD_TYPE: 'value', |
||||||
|
OBJECT_DICT_NAME: '', |
||||||
|
}, |
||||||
|
cachesData: { |
||||||
|
ID: 0.0, |
||||||
|
OBJECT_TABLE_NAME: 'test2', |
||||||
|
OBJECT_TABLE_CNNAME: '测试2', |
||||||
|
SYSTEM_TABLE_CNNAME: '测试1', |
||||||
|
SYSTEM_TABLE_NAME: 'test1', |
||||||
|
}, |
||||||
|
} |
||||||
|
}, |
||||||
|
created() { |
||||||
|
this.getDictOption() |
||||||
|
}, |
||||||
|
mounted() {}, |
||||||
|
methods: { |
||||||
|
getDictOption() { |
||||||
|
axios |
||||||
|
.get( |
||||||
|
'/dict_data/simpleList?type=std_filed_type', |
||||||
|
jwHeader |
||||||
|
) |
||||||
|
.then(res => { |
||||||
|
this.dict.filedType = res.data |
||||||
|
}) |
||||||
|
}, |
||||||
|
uploadLocalFile() { |
||||||
|
document.getElementById('localFile').click() |
||||||
|
document.getElementById('localFile').onchange = |
||||||
|
() => { |
||||||
|
const file = |
||||||
|
document.getElementById('localFile').files[0] |
||||||
|
this.localJosnName = file.name |
||||||
|
const reader = new FileReader() |
||||||
|
reader.readAsText(file) |
||||||
|
reader.onload = () => { |
||||||
|
this.localJsonData = JSON.parse(reader.result) |
||||||
|
} |
||||||
|
} |
||||||
|
}, |
||||||
|
uploadThirdFile() { |
||||||
|
document.getElementById('thirdFile').click() |
||||||
|
document.getElementById('thirdFile').onchange = |
||||||
|
() => { |
||||||
|
const file = |
||||||
|
document.getElementById('thirdFile').files[0] |
||||||
|
this.thirdJsonName = file.name |
||||||
|
const reader = new FileReader() |
||||||
|
reader.readAsText(file) |
||||||
|
reader.onload = () => { |
||||||
|
this.thirdJsonData = JSON.parse(reader.result) |
||||||
|
} |
||||||
|
} |
||||||
|
}, |
||||||
|
addNewField() { |
||||||
|
this.submitData = { |
||||||
|
SYSTEM_NAME: '', |
||||||
|
SYSTEM_FIELD: '', |
||||||
|
INTERFACE_NAME: '', |
||||||
|
INTERFACE_FIELD: '', |
||||||
|
SYSTEM_FIELD_TYPE: 'value', |
||||||
|
SYSTEM_DICT_NAME: '', |
||||||
|
OBJECT_FIELD_TYPE: 'value', |
||||||
|
OBJECT_DICT_NAME: '', |
||||||
|
} |
||||||
|
this.isEditing = true |
||||||
|
}, |
||||||
|
saveField(index) { |
||||||
|
this.data.push(this.submitData) |
||||||
|
this.isEditing = false |
||||||
|
}, |
||||||
|
cancelField(index) { |
||||||
|
this.submitData = { |
||||||
|
SYSTEM_NAME: '', |
||||||
|
SYSTEM_FIELD: '', |
||||||
|
INTERFACE_NAME: '', |
||||||
|
INTERFACE_FIELD: '', |
||||||
|
SYSTEM_FIELD_TYPE: 'value', |
||||||
|
SYSTEM_DICT_NAME: '', |
||||||
|
OBJECT_FIELD_TYPE: 'value', |
||||||
|
OBJECT_DICT_NAME: '', |
||||||
|
} |
||||||
|
this.isEditing = false |
||||||
|
}, |
||||||
|
deleteField(index) { |
||||||
|
this.data.splice(index, 1) |
||||||
|
}, |
||||||
|
thridChange(e) { |
||||||
|
this.submitData.INTERFACE_FIELD = e.target.value |
||||||
|
}, |
||||||
|
localChange(e) { |
||||||
|
this.submitData.SYSTEM_FIELD = e.target.value |
||||||
|
}, |
||||||
|
saveAll() { |
||||||
|
if ( |
||||||
|
this.cachesData.SYSTEM_TABLE_NAME === '' || |
||||||
|
this.cachesData.OBJECT_TABLE_NAME === '' |
||||||
|
) { |
||||||
|
tools.alert('请输入表名') |
||||||
|
return |
||||||
|
} |
||||||
|
if (this.data.length === 0) { |
||||||
|
tools.alert('请输入字段') |
||||||
|
return |
||||||
|
} |
||||||
|
const data = this.data.map(i => { |
||||||
|
return { |
||||||
|
...this.cachesData, |
||||||
|
...i, |
||||||
|
} |
||||||
|
}) |
||||||
|
console.log(data) |
||||||
|
axios |
||||||
|
.post( |
||||||
|
`/std_filed/createBatch`, |
||||||
|
{ Data: JSON.stringify(data) }, |
||||||
|
jwHeader |
||||||
|
) |
||||||
|
.then(res => { |
||||||
|
tools.highlightErrorFields(res.data) |
||||||
|
// window.location.href = './std_filed_map.html' |
||||||
|
}) |
||||||
|
.catch(error => { |
||||||
|
tools.alert(error.message) |
||||||
|
}) |
||||||
|
}, |
||||||
|
cancelAll() { |
||||||
|
window.location.href = './std_filed_map.html' |
||||||
|
}, |
||||||
|
}, |
||||||
|
}) |
||||||
|
</script> |
@ -1,271 +1,324 @@ |
|||||||
var isLoading = false; |
var isLoading = false |
||||||
var tools = { |
var tools = { |
||||||
highlightErrorFields: function (data) { |
highlightErrorFields: function (data) { |
||||||
if (!data.ErrorParameters) { |
if (!data.ErrorParameters) { |
||||||
tools.alert(data.message); |
tools.alert(data.message) |
||||||
return; |
return |
||||||
} |
} |
||||||
data.ErrorParameters.forEach(function (error) { |
data.ErrorParameters.forEach(function (error) { |
||||||
// 获取 Name 属性的值 |
// 获取 Name 属性的值 |
||||||
var fieldName = error.Name; |
var fieldName = error.Name |
||||||
|
|
||||||
// 查找具有相同 name 属性值的所有元素 |
// 查找具有相同 name 属性值的所有元素 |
||||||
var elements = document.getElementsByName(fieldName); |
var elements = document.getElementsByName(fieldName) |
||||||
|
|
||||||
// 循环遍历找到的元素,设置样式 |
// 循环遍历找到的元素,设置样式 |
||||||
for (var i = 0; i < elements.length; i++) { |
for (var i = 0; i < elements.length; i++) { |
||||||
elements[i].style.border = "2px solid red"; |
elements[i].style.border = '2px solid red' |
||||||
|
|
||||||
var spanElement = document.createElement("span"); |
var spanElement = document.createElement('span') |
||||||
spanElement.style.color = "red"; |
spanElement.style.color = 'red' |
||||||
spanElement.style.marginLeft = "5px"; // 调整距离,可根据需要更改 |
spanElement.style.marginLeft = '5px' // 调整距离,可根据需要更改 |
||||||
spanElement.innerHTML = error.Message; |
spanElement.innerHTML = error.Message |
||||||
|
|
||||||
// 将 span 元素添加到当前元素的后面 |
// 将 span 元素添加到当前元素的后面 |
||||||
elements[i].parentNode.insertBefore(spanElement, elements[i].nextSibling); |
elements[i].parentNode.insertBefore( |
||||||
} |
spanElement, |
||||||
setTimeout(function () { |
elements[i].nextSibling |
||||||
for (var i = 0; i < elements.length; i++) { |
) |
||||||
elements[i].style.border = ""; |
} |
||||||
// 移除当前元素后面的 span 元素 |
setTimeout(function () { |
||||||
var nextSibling = elements[i].nextSibling; |
for (var i = 0; i < elements.length; i++) { |
||||||
if (nextSibling && nextSibling.tagName === "SPAN") { |
elements[i].style.border = '' |
||||||
elements[i].parentNode.removeChild(nextSibling); |
// 移除当前元素后面的 span 元素 |
||||||
} |
var nextSibling = elements[i].nextSibling |
||||||
} |
if ( |
||||||
}, 3000); |
nextSibling && |
||||||
}); |
nextSibling.tagName === 'SPAN' |
||||||
}, |
) { |
||||||
alert: function (msg) { |
elements[i].parentNode.removeChild(nextSibling) |
||||||
$(divAlertBody).html(msg); |
} |
||||||
btnAlert.click(); |
} |
||||||
}, |
}, 3000) |
||||||
objectToQueryString: function (obj) { |
}) |
||||||
return Object.keys(obj) |
}, |
||||||
.filter(key => obj[key] !== null && obj[key] !== undefined) // Filter out null and undefined values |
alert: function (msg) { |
||||||
.map(key => key + '=' + encodeURIComponent(obj[key])) |
$(divAlertBody).html(msg) |
||||||
.join('&'); |
btnAlert.click() |
||||||
}, |
}, |
||||||
formToJson: function (formId) { |
objectToQueryString: function (obj) { |
||||||
var form = document.getElementById(formId); |
return Object.keys(obj) |
||||||
var formData = new FormData(form); |
.filter( |
||||||
var jsonData = {}; |
key => obj[key] !== null && obj[key] !== undefined |
||||||
|
) // Filter out null and undefined values |
||||||
|
.map(key => key + '=' + encodeURIComponent(obj[key])) |
||||||
|
.join('&') |
||||||
|
}, |
||||||
|
formToJson: function (formId) { |
||||||
|
var form = document.getElementById(formId) |
||||||
|
var formData = new FormData(form) |
||||||
|
var jsonData = {} |
||||||
|
|
||||||
formData.forEach(function (value, key) { |
formData.forEach(function (value, key) { |
||||||
jsonData[key] = value; |
jsonData[key] = value |
||||||
}); |
}) |
||||||
|
|
||||||
return jsonData; |
return jsonData |
||||||
}, |
}, |
||||||
isValidURLPattern: function (inputString) { |
isValidURLPattern: function (inputString) { |
||||||
var url = "https://www.rezero.com" + inputString; |
var url = 'https://www.rezero.com' + inputString |
||||||
var pattern = /^((http|https|ftp):\/\/)?([a-zA-Z0-9_-]+\.)+[a-zA-Z]{2,6}(\/[a-zA-Z0-9_.-]*)*\/?$/; |
var pattern = |
||||||
return (pattern.test(url)); |
/^((http|https|ftp):\/\/)?([a-zA-Z0-9_-]+\.)+[a-zA-Z]{2,6}(\/[a-zA-Z0-9_.-]*)*\/?$/ |
||||||
}, |
return pattern.test(url) |
||||||
ensureNumeric: function (inputField) { |
}, |
||||||
// 尝试将输入值转换为数字 |
ensureNumeric: function (inputField) { |
||||||
var value = inputField.value; |
// 尝试将输入值转换为数字 |
||||||
|
var value = inputField.value |
||||||
|
|
||||||
// 尝试将输入值转换为数字 |
// 尝试将输入值转换为数字 |
||||||
var numericValue = parseFloat(value); |
var numericValue = parseFloat(value) |
||||||
|
|
||||||
// 如果转换失败,则将值设置为 0 |
// 如果转换失败,则将值设置为 0 |
||||||
if (isNaN(numericValue)) { |
if (isNaN(numericValue)) { |
||||||
numericValue = 0; |
numericValue = 0 |
||||||
} |
} |
||||||
|
|
||||||
// 将更新后的值设置回输入框 |
// 将更新后的值设置回输入框 |
||||||
inputField.value = numericValue; |
inputField.value = numericValue |
||||||
}, |
}, |
||||||
showSpecifiedElementAndHideOthers: function (elementToShowId, elementsToHideIds) { |
showSpecifiedElementAndHideOthers: function ( |
||||||
// 显示指定元素并隐藏其他元素 |
elementToShowId, |
||||||
document.getElementById(elementToShowId).style.display = "block"; |
elementsToHideIds |
||||||
for (var i = 0; i < elementsToHideIds.length; i++) { |
) { |
||||||
document.getElementById(elementsToHideIds[i]).style.display = "none"; |
// 显示指定元素并隐藏其他元素 |
||||||
} |
document.getElementById(elementToShowId).style.display = |
||||||
}, |
'block' |
||||||
assignValuesToObject: function (sourceObject, targetObject) { |
for (var i = 0; i < elementsToHideIds.length; i++) { |
||||||
Object.keys(sourceObject).forEach(function (key) { |
document.getElementById( |
||||||
if (targetObject.hasOwnProperty(key)) { |
elementsToHideIds[i] |
||||||
targetObject[key] = sourceObject[key]; |
).style.display = 'none' |
||||||
} else { |
} |
||||||
console.warn(`Property '${key}' does not exist in the target object.`); |
}, |
||||||
} |
assignValuesToObject: function ( |
||||||
}); |
sourceObject, |
||||||
}, |
targetObject |
||||||
openLoading: function () { |
) { |
||||||
var loadingOverlay = document.getElementById('loadingOverlay'); |
Object.keys(sourceObject).forEach(function (key) { |
||||||
loadingOverlay.style.display = 'flex'; |
if (targetObject.hasOwnProperty(key)) { |
||||||
}, |
targetObject[key] = sourceObject[key] |
||||||
closeLoading: function () { |
} else { |
||||||
var loadingOverlay = document.getElementById('loadingOverlay'); |
console.warn( |
||||||
loadingOverlay.style.display = 'none'; |
`Property '${key}' does not exist in the target object.` |
||||||
}, |
) |
||||||
getValue: function (id) { |
} |
||||||
var element = document.getElementById(id); |
}) |
||||||
if (element) { |
}, |
||||||
return element.value; |
openLoading: function () { |
||||||
} else { |
var loadingOverlay = document.getElementById( |
||||||
return null; |
'loadingOverlay' |
||||||
} |
) |
||||||
}, |
loadingOverlay.style.display = 'flex' |
||||||
checkAuthorization: function () { |
}, |
||||||
setTimeout(function () { |
closeLoading: function () { |
||||||
|
var loadingOverlay = document.getElementById( |
||||||
|
'loadingOverlay' |
||||||
|
) |
||||||
|
loadingOverlay.style.display = 'none' |
||||||
|
}, |
||||||
|
getValue: function (id) { |
||||||
|
var element = document.getElementById(id) |
||||||
|
if (element) { |
||||||
|
return element.value |
||||||
|
} else { |
||||||
|
return null |
||||||
|
} |
||||||
|
}, |
||||||
|
checkAuthorization: function () { |
||||||
|
setTimeout(function () { |
||||||
|
var tokeEle = document.getElementById('txtToken') |
||||||
|
if (tokeEle) return |
||||||
|
|
||||||
var tokeEle = document.getElementById("txtToken"); |
axios |
||||||
if (tokeEle) return; |
.get( |
||||||
|
'/PrivateReZeroRoute/100004/GetDbTypeList', |
||||||
|
jwHeader |
||||||
|
) |
||||||
|
.then(response => { |
||||||
|
this.dbTypeList = response.data |
||||||
|
isLoading = true |
||||||
|
this.error = null |
||||||
|
}) |
||||||
|
.catch(error => { |
||||||
|
isLoading = true |
||||||
|
this.error = error.message |
||||||
|
this.data = null |
||||||
|
}) |
||||||
|
}, 3000) |
||||||
|
}, |
||||||
|
jsonToUrl: function (json) { |
||||||
|
return Object.keys(json) |
||||||
|
.map(function (key) { |
||||||
|
return ( |
||||||
|
encodeURIComponent(key) + |
||||||
|
'=' + |
||||||
|
encodeURIComponent(json[key]) |
||||||
|
) |
||||||
|
}) |
||||||
|
.join('&') |
||||||
|
}, |
||||||
|
initColor: function () { |
||||||
|
if (localStorage.BgColorType == 1) { |
||||||
|
document.body.setAttribute('data-theme', 'dark') |
||||||
|
} else if (localStorage.BgColorType !== 'default') { |
||||||
|
document.body.setAttribute('data-theme', 'default') |
||||||
|
} |
||||||
|
var dropdown = document.querySelector( |
||||||
|
'.dropdown-skin.open' |
||||||
|
) |
||||||
|
|
||||||
axios.get("/PrivateReZeroRoute/100004/GetDbTypeList", jwHeader) |
if (dropdown) { |
||||||
.then(response => { |
// 移除 "open" 类,添加 "close" 类 |
||||||
this.dbTypeList = response.data; |
dropdown.classList.remove('open') |
||||||
isLoading = true; |
dropdown.classList.add('close') |
||||||
this.error = null; |
} |
||||||
}) |
}, |
||||||
.catch(error => { |
appendQueryParams: function (url) { |
||||||
isLoading = true; |
// 从当前 URL 中提取查询参数 |
||||||
this.error = error.message; |
const searchParams = new URLSearchParams( |
||||||
this.data = null; |
window.location.search |
||||||
}); |
) |
||||||
}, 3000) |
const params = {} |
||||||
}, |
|
||||||
jsonToUrl: function (json) { |
|
||||||
return Object.keys(json).map(function (key) { |
|
||||||
return encodeURIComponent(key) + '=' + encodeURIComponent(json[key]); |
|
||||||
}).join('&'); |
|
||||||
}, |
|
||||||
initColor: function () { |
|
||||||
if (localStorage.BgColorType == 1) { |
|
||||||
document.body.setAttribute('data-theme', 'dark'); |
|
||||||
} else if (localStorage.BgColorType !== 'default') { |
|
||||||
document.body.setAttribute('data-theme', 'default'); |
|
||||||
} |
|
||||||
var dropdown = document.querySelector('.dropdown-skin.open'); |
|
||||||
|
|
||||||
if (dropdown) { |
// 动态提取 token 和 model |
||||||
// 移除 "open" 类,添加 "close" 类 |
if (searchParams.has('token')) { |
||||||
dropdown.classList.remove('open'); |
params.token = searchParams.get('token') |
||||||
dropdown.classList.add('close'); |
} |
||||||
} |
if (searchParams.has('model')) { |
||||||
}, |
params.model = searchParams.get('model') |
||||||
appendQueryParams: function (url) { |
} |
||||||
// 从当前 URL 中提取查询参数 |
|
||||||
const searchParams = new URLSearchParams(window.location.search); |
|
||||||
const params = {}; |
|
||||||
|
|
||||||
// 动态提取 token 和 model |
// 如果没有参数,直接返回原始 URL |
||||||
if (searchParams.has('token')) { |
if (Object.keys(params).length === 0) { |
||||||
params.token = searchParams.get('token'); |
return url |
||||||
} |
} |
||||||
if (searchParams.has('model')) { |
|
||||||
params.model = searchParams.get('model'); |
|
||||||
} |
|
||||||
|
|
||||||
// 如果没有参数,直接返回原始 URL |
// 检查 URL 是否已经包含查询参数 |
||||||
if (Object.keys(params).length === 0) { |
const separator = url.includes('?') ? '&' : '?' |
||||||
return url; |
|
||||||
} |
|
||||||
|
|
||||||
// 检查 URL 是否已经包含查询参数 |
// 将参数对象转换为查询字符串 |
||||||
const separator = url.includes('?') ? '&' : '?'; |
const queryString = Object.keys(params) |
||||||
|
.map( |
||||||
|
key => |
||||||
|
`${encodeURIComponent(key)}=${encodeURIComponent( |
||||||
|
params[key] |
||||||
|
)}` |
||||||
|
) |
||||||
|
.join('&') |
||||||
|
|
||||||
// 将参数对象转换为查询字符串 |
// 拼接 URL 和查询参数 |
||||||
const queryString = Object.keys(params) |
return url + separator + queryString |
||||||
.map(key => `${encodeURIComponent(key)}=${encodeURIComponent(params[key])}`) |
}, |
||||||
.join('&'); |
validateDatalist: function (ele, datalistId) { |
||||||
|
const input = ele |
||||||
// 拼接 URL 和查询参数 |
const list = document.getElementById(datalistId) |
||||||
return url + separator + queryString; |
const options = list && list.options |
||||||
}, |
const value = input.value |
||||||
validateDatalist: function (ele, datalistId) { |
let isValid = false |
||||||
const input = ele; |
if (options) { |
||||||
const list = document.getElementById(datalistId); |
for (let i = 0; i < options.length; i++) { |
||||||
const options = list && list.options; |
if (value === options[i].value) { |
||||||
const value = input.value; |
isValid = true |
||||||
let isValid = false; |
break |
||||||
if (options) { |
} |
||||||
for (let i = 0; i < options.length; i++) { |
} |
||||||
if (value === options[i].value) { |
} |
||||||
isValid = true; |
if (!isValid) { |
||||||
break; |
input.value = '' |
||||||
} |
} |
||||||
} |
}, |
||||||
} |
copyText: function (text) { |
||||||
if (!isValid) { |
navigator.clipboard |
||||||
input.value = ''; |
.writeText(text) |
||||||
} |
.then(() => { |
||||||
}, |
tools.alert('复制成功') |
||||||
copyText: function (text) |
}) |
||||||
{ |
.catch(err => { |
||||||
navigator.clipboard.writeText(text).then(() => { |
tools.alert('复制失败') |
||||||
tools.alert("复制成功"); |
}) |
||||||
}).catch(err => { |
}, |
||||||
tools.alert("复制失败"); |
formatDate: function (date) { |
||||||
}); |
if (!date) return '' |
||||||
}, |
const d = new Date(date) |
||||||
formatDate: function (date) { |
const month = '' + (d.getMonth() + 1) |
||||||
if (!date) return ''; |
const day = '' + d.getDate() |
||||||
const d = new Date(date); |
const year = d.getFullYear() |
||||||
const month = '' + (d.getMonth() + 1); |
return [ |
||||||
const day = '' + d.getDate(); |
year, |
||||||
const year = d.getFullYear(); |
month.padStart(2, '0'), |
||||||
return [year, month.padStart(2, '0'), day.padStart(2, '0')].join('-'); |
day.padStart(2, '0'), |
||||||
} |
].join('-') |
||||||
|
}, |
||||||
} |
} |
||||||
Array.prototype.removeArrayItem = function (item) { |
Array.prototype.removeArrayItem = function (item) { |
||||||
const index = this.indexOf(item); |
const index = this.indexOf(item) |
||||||
if (index !== -1) { |
if (index !== -1) { |
||||||
this.splice(index, 1); |
this.splice(index, 1) |
||||||
} |
} |
||||||
return this; |
return this |
||||||
}; |
} |
||||||
setTimeout(function () { |
setTimeout(function () { |
||||||
// 设置请求拦截器 |
// 设置请求拦截器 |
||||||
axios.interceptors.request.use(function (config) { |
axios.interceptors.request.use( |
||||||
if (isLoading) { |
function (config) { |
||||||
tools.openLoading(); |
if (isLoading) { |
||||||
} |
tools.openLoading() |
||||||
return config; |
} |
||||||
}, function (error) { |
return config |
||||||
// 对请求错误做些什么 |
}, |
||||||
return Promise.reject(error); |
function (error) { |
||||||
}); |
// 对请求错误做些什么 |
||||||
|
return Promise.reject(error) |
||||||
// 设置响应拦截器 |
} |
||||||
axios.interceptors.response.use(function (response) { |
) |
||||||
if (isLoading) { |
|
||||||
tools.closeLoading(); |
|
||||||
} |
|
||||||
return response; |
|
||||||
}, function (error) { |
|
||||||
if (error.response) { |
|
||||||
// 请求已发出,但服务器响应的状态码不在 2xx 范围内 |
|
||||||
if (error.response.status === 401) { |
|
||||||
if (isLoading) { |
|
||||||
tools.closeLoading(); |
|
||||||
} |
|
||||||
tools.alert("授权失败,自动跳到授权页面"); |
|
||||||
// 如果是401错误(未授权),则跳转到登录页面 |
|
||||||
setTimeout(function () { |
|
||||||
if (isloginPage) { |
|
||||||
window.location.href = '/rezero/login.html'; |
|
||||||
} else { |
|
||||||
window.location.href = '/rezero/authorization.html'; |
|
||||||
} |
|
||||||
}, 2000); |
|
||||||
|
|
||||||
} else { |
|
||||||
// 处理其他状态码 |
|
||||||
return Promise.reject(error); |
|
||||||
} |
|
||||||
} else if (error.request) { |
|
||||||
// 请求已发出,但没有收到响应 |
|
||||||
console.log('Request:', error.request); |
|
||||||
return Promise.reject(error); |
|
||||||
} else { |
|
||||||
// 发生一些其他问题在设置请求时触发了一个错误 |
|
||||||
console.log('Error', error.message); |
|
||||||
return Promise.reject(error); |
|
||||||
} |
|
||||||
}); |
|
||||||
|
|
||||||
},2000) |
// 设置响应拦截器 |
||||||
|
axios.interceptors.response.use( |
||||||
|
function (response) { |
||||||
|
if (isLoading) { |
||||||
|
tools.closeLoading() |
||||||
|
} |
||||||
|
return response |
||||||
|
}, |
||||||
|
function (error) { |
||||||
|
if (error.response) { |
||||||
|
// 请求已发出,但服务器响应的状态码不在 2xx 范围内 |
||||||
|
if (error.response.status === 401) { |
||||||
|
if (isLoading) { |
||||||
|
tools.closeLoading() |
||||||
|
} |
||||||
|
tools.alert('授权失败,自动跳到授权页面') |
||||||
|
// 如果是401错误(未授权),则跳转到登录页面 |
||||||
|
setTimeout(function () { |
||||||
|
if (isloginPage) { |
||||||
|
window.location.href = '/rezero/login.html' |
||||||
|
} else { |
||||||
|
window.location.href = |
||||||
|
'/rezero/authorization.html' |
||||||
|
} |
||||||
|
}, 2000) |
||||||
|
} else { |
||||||
|
// 处理其他状态码 |
||||||
|
return Promise.reject(error) |
||||||
|
} |
||||||
|
} else if (error.request) { |
||||||
|
// 请求已发出,但没有收到响应 |
||||||
|
console.log('Request:', error.request) |
||||||
|
return Promise.reject(error) |
||||||
|
} else { |
||||||
|
// 发生一些其他问题在设置请求时触发了一个错误 |
||||||
|
console.log('Error', error.message) |
||||||
|
return Promise.reject(error) |
||||||
|
} |
||||||
|
} |
||||||
|
) |
||||||
|
}, 2000) |
||||||
|
Loading…
Reference in new issue