Compare commits
No commits in common. 'bd0c5db6e7ad253db18aaefd4c911612aabbd104' and '03fdcc175c42000e061fba94d6409baf9106ff1a' have entirely different histories.
bd0c5db6e7
...
03fdcc175c
5 changed files with 311 additions and 1166 deletions
@ -1,796 +0,0 @@ |
|||||||
@@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,324 +1,271 @@ |
|||||||
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( |
elements[i].parentNode.insertBefore(spanElement, elements[i].nextSibling); |
||||||
spanElement, |
} |
||||||
elements[i].nextSibling |
setTimeout(function () { |
||||||
) |
for (var i = 0; i < elements.length; i++) { |
||||||
} |
elements[i].style.border = ""; |
||||||
setTimeout(function () { |
// 移除当前元素后面的 span 元素 |
||||||
for (var i = 0; i < elements.length; i++) { |
var nextSibling = elements[i].nextSibling; |
||||||
elements[i].style.border = '' |
if (nextSibling && nextSibling.tagName === "SPAN") { |
||||||
// 移除当前元素后面的 span 元素 |
elements[i].parentNode.removeChild(nextSibling); |
||||||
var nextSibling = elements[i].nextSibling |
} |
||||||
if ( |
} |
||||||
nextSibling && |
}, 3000); |
||||||
nextSibling.tagName === 'SPAN' |
}); |
||||||
) { |
}, |
||||||
elements[i].parentNode.removeChild(nextSibling) |
alert: function (msg) { |
||||||
} |
$(divAlertBody).html(msg); |
||||||
} |
btnAlert.click(); |
||||||
}, 3000) |
}, |
||||||
}) |
objectToQueryString: function (obj) { |
||||||
}, |
return Object.keys(obj) |
||||||
alert: function (msg) { |
.filter(key => obj[key] !== null && obj[key] !== undefined) // Filter out null and undefined values |
||||||
$(divAlertBody).html(msg) |
.map(key => key + '=' + encodeURIComponent(obj[key])) |
||||||
btnAlert.click() |
.join('&'); |
||||||
}, |
}, |
||||||
objectToQueryString: function (obj) { |
formToJson: function (formId) { |
||||||
return Object.keys(obj) |
var form = document.getElementById(formId); |
||||||
.filter( |
var formData = new FormData(form); |
||||||
key => obj[key] !== null && obj[key] !== undefined |
var jsonData = {}; |
||||||
) // 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 = |
var pattern = /^((http|https|ftp):\/\/)?([a-zA-Z0-9_-]+\.)+[a-zA-Z]{2,6}(\/[a-zA-Z0-9_.-]*)*\/?$/; |
||||||
/^((http|https|ftp):\/\/)?([a-zA-Z0-9_-]+\.)+[a-zA-Z]{2,6}(\/[a-zA-Z0-9_.-]*)*\/?$/ |
return (pattern.test(url)); |
||||||
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 ( |
showSpecifiedElementAndHideOthers: function (elementToShowId, elementsToHideIds) { |
||||||
elementToShowId, |
// 显示指定元素并隐藏其他元素 |
||||||
elementsToHideIds |
document.getElementById(elementToShowId).style.display = "block"; |
||||||
) { |
for (var i = 0; i < elementsToHideIds.length; i++) { |
||||||
// 显示指定元素并隐藏其他元素 |
document.getElementById(elementsToHideIds[i]).style.display = "none"; |
||||||
document.getElementById(elementToShowId).style.display = |
} |
||||||
'block' |
}, |
||||||
for (var i = 0; i < elementsToHideIds.length; i++) { |
assignValuesToObject: function (sourceObject, targetObject) { |
||||||
document.getElementById( |
Object.keys(sourceObject).forEach(function (key) { |
||||||
elementsToHideIds[i] |
if (targetObject.hasOwnProperty(key)) { |
||||||
).style.display = 'none' |
targetObject[key] = sourceObject[key]; |
||||||
} |
} else { |
||||||
}, |
console.warn(`Property '${key}' does not exist in the target object.`); |
||||||
assignValuesToObject: function ( |
} |
||||||
sourceObject, |
}); |
||||||
targetObject |
}, |
||||||
) { |
openLoading: function () { |
||||||
Object.keys(sourceObject).forEach(function (key) { |
var loadingOverlay = document.getElementById('loadingOverlay'); |
||||||
if (targetObject.hasOwnProperty(key)) { |
loadingOverlay.style.display = 'flex'; |
||||||
targetObject[key] = sourceObject[key] |
}, |
||||||
} else { |
closeLoading: function () { |
||||||
console.warn( |
var loadingOverlay = document.getElementById('loadingOverlay'); |
||||||
`Property '${key}' does not exist in the target object.` |
loadingOverlay.style.display = 'none'; |
||||||
) |
}, |
||||||
} |
getValue: function (id) { |
||||||
}) |
var element = document.getElementById(id); |
||||||
}, |
if (element) { |
||||||
openLoading: function () { |
return element.value; |
||||||
var loadingOverlay = document.getElementById( |
} else { |
||||||
'loadingOverlay' |
return null; |
||||||
) |
} |
||||||
loadingOverlay.style.display = 'flex' |
}, |
||||||
}, |
checkAuthorization: function () { |
||||||
closeLoading: function () { |
setTimeout(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 |
|
||||||
|
|
||||||
axios |
var tokeEle = document.getElementById("txtToken"); |
||||||
.get( |
if (tokeEle) return; |
||||||
'/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' |
|
||||||
) |
|
||||||
|
|
||||||
if (dropdown) { |
axios.get("/PrivateReZeroRoute/100004/GetDbTypeList", jwHeader) |
||||||
// 移除 "open" 类,添加 "close" 类 |
.then(response => { |
||||||
dropdown.classList.remove('open') |
this.dbTypeList = response.data; |
||||||
dropdown.classList.add('close') |
isLoading = true; |
||||||
} |
this.error = null; |
||||||
}, |
}) |
||||||
appendQueryParams: function (url) { |
.catch(error => { |
||||||
// 从当前 URL 中提取查询参数 |
isLoading = true; |
||||||
const searchParams = new URLSearchParams( |
this.error = error.message; |
||||||
window.location.search |
this.data = null; |
||||||
) |
}); |
||||||
const params = {} |
}, 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'); |
||||||
|
|
||||||
// 动态提取 token 和 model |
if (dropdown) { |
||||||
if (searchParams.has('token')) { |
// 移除 "open" 类,添加 "close" 类 |
||||||
params.token = searchParams.get('token') |
dropdown.classList.remove('open'); |
||||||
} |
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 = {}; |
||||||
|
|
||||||
// 如果没有参数,直接返回原始 URL |
// 动态提取 token 和 model |
||||||
if (Object.keys(params).length === 0) { |
if (searchParams.has('token')) { |
||||||
return url |
params.token = searchParams.get('token'); |
||||||
} |
} |
||||||
|
if (searchParams.has('model')) { |
||||||
|
params.model = searchParams.get('model'); |
||||||
|
} |
||||||
|
|
||||||
// 检查 URL 是否已经包含查询参数 |
// 如果没有参数,直接返回原始 URL |
||||||
const separator = url.includes('?') ? '&' : '?' |
if (Object.keys(params).length === 0) { |
||||||
|
return url; |
||||||
|
} |
||||||
|
|
||||||
// 将参数对象转换为查询字符串 |
// 检查 URL 是否已经包含查询参数 |
||||||
const queryString = Object.keys(params) |
const separator = url.includes('?') ? '&' : '?'; |
||||||
.map( |
|
||||||
key => |
|
||||||
`${encodeURIComponent(key)}=${encodeURIComponent( |
|
||||||
params[key] |
|
||||||
)}` |
|
||||||
) |
|
||||||
.join('&') |
|
||||||
|
|
||||||
// 拼接 URL 和查询参数 |
// 将参数对象转换为查询字符串 |
||||||
return url + separator + queryString |
const queryString = Object.keys(params) |
||||||
}, |
.map(key => `${encodeURIComponent(key)}=${encodeURIComponent(params[key])}`) |
||||||
validateDatalist: function (ele, datalistId) { |
.join('&'); |
||||||
const input = ele |
|
||||||
const list = document.getElementById(datalistId) |
// 拼接 URL 和查询参数 |
||||||
const options = list && list.options |
return url + separator + queryString; |
||||||
const value = input.value |
}, |
||||||
let isValid = false |
validateDatalist: function (ele, datalistId) { |
||||||
if (options) { |
const input = ele; |
||||||
for (let i = 0; i < options.length; i++) { |
const list = document.getElementById(datalistId); |
||||||
if (value === options[i].value) { |
const options = list && list.options; |
||||||
isValid = true |
const value = input.value; |
||||||
break |
let isValid = false; |
||||||
} |
if (options) { |
||||||
} |
for (let i = 0; i < options.length; i++) { |
||||||
} |
if (value === options[i].value) { |
||||||
if (!isValid) { |
isValid = true; |
||||||
input.value = '' |
break; |
||||||
} |
} |
||||||
}, |
} |
||||||
copyText: function (text) { |
} |
||||||
navigator.clipboard |
if (!isValid) { |
||||||
.writeText(text) |
input.value = ''; |
||||||
.then(() => { |
} |
||||||
tools.alert('复制成功') |
}, |
||||||
}) |
copyText: function (text) |
||||||
.catch(err => { |
{ |
||||||
tools.alert('复制失败') |
navigator.clipboard.writeText(text).then(() => { |
||||||
}) |
tools.alert("复制成功"); |
||||||
}, |
}).catch(err => { |
||||||
formatDate: function (date) { |
tools.alert("复制失败"); |
||||||
if (!date) return '' |
}); |
||||||
const d = new Date(date) |
}, |
||||||
const month = '' + (d.getMonth() + 1) |
formatDate: function (date) { |
||||||
const day = '' + d.getDate() |
if (!date) return ''; |
||||||
const year = d.getFullYear() |
const d = new Date(date); |
||||||
return [ |
const month = '' + (d.getMonth() + 1); |
||||||
year, |
const day = '' + d.getDate(); |
||||||
month.padStart(2, '0'), |
const year = d.getFullYear(); |
||||||
day.padStart(2, '0'), |
return [year, month.padStart(2, '0'), day.padStart(2, '0')].join('-'); |
||||||
].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( |
axios.interceptors.request.use(function (config) { |
||||||
function (config) { |
if (isLoading) { |
||||||
if (isLoading) { |
tools.openLoading(); |
||||||
tools.openLoading() |
} |
||||||
} |
return config; |
||||||
return config |
}, function (error) { |
||||||
}, |
// 对请求错误做些什么 |
||||||
function (error) { |
return Promise.reject(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