add elasticsearch progress
parent
02bf570f08
commit
682bd13b6e
|
@ -401,6 +401,11 @@ export const createIndex = () => {
|
||||||
return getRequest(`/elasticsearch`);
|
return getRequest(`/elasticsearch`);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 初始化商品索引
|
||||||
|
export const getProgress = () => {
|
||||||
|
return getRequest(`/elasticsearch/progress`);
|
||||||
|
};
|
||||||
|
|
||||||
// 分页查询自定义分词
|
// 分页查询自定义分词
|
||||||
export const getCustomWordsPage = (params) => {
|
export const getCustomWordsPage = (params) => {
|
||||||
return getRequest(`/manager/custom-words`, params);
|
return getRequest(`/manager/custom-words`, params);
|
||||||
|
|
|
@ -56,13 +56,15 @@
|
||||||
<div class="label-btns">
|
<div class="label-btns">
|
||||||
<Button type="primary" @click="submit('formValidate')">保存</Button>
|
<Button type="primary" @click="submit('formValidate')">保存</Button>
|
||||||
<Button type="primary" style="margin-left: 100px" @click="createIndex()">重新生成所有商品索引</Button>
|
<Button type="primary" style="margin-left: 100px" @click="createIndex()">重新生成所有商品索引</Button>
|
||||||
|
<div class="progress-item" v-if="showProgress">
|
||||||
|
<i-progress :percent="progressVal"></i-progress>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</Form>
|
</Form>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import { setSetting,createIndex } from "@/api/index";
|
import { setSetting,createIndex,getProgress } from "@/api/index";
|
||||||
import { handleSubmit } from "./validate";
|
import { handleSubmit } from "./validate";
|
||||||
export default {
|
export default {
|
||||||
props: ["res", "type"],
|
props: ["res", "type"],
|
||||||
|
@ -77,6 +79,9 @@ export default {
|
||||||
originalPictureWidth: "0",
|
originalPictureWidth: "0",
|
||||||
originalPictureHeight: "0",
|
originalPictureHeight: "0",
|
||||||
},
|
},
|
||||||
|
progressVal: 0,
|
||||||
|
showProgress: false,
|
||||||
|
intervalProgress: null,
|
||||||
ruleValidate: {} // 验证规则
|
ruleValidate: {} // 验证规则
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
@ -96,10 +101,39 @@ export default {
|
||||||
createIndex().then((res) => {
|
createIndex().then((res) => {
|
||||||
if (res.success) {
|
if (res.success) {
|
||||||
this.$Message.success("开始生成!");
|
this.$Message.success("开始生成!");
|
||||||
} else {
|
this.showProgress = true;
|
||||||
this.$Message.error("服务器异常!");
|
setTimeout(() => {
|
||||||
|
this.intervalProgress = setInterval(()=> {
|
||||||
|
getProgress().then(resp => {
|
||||||
|
let progressResult = resp.result
|
||||||
|
if (progressResult !=null && progressResult.flag === 0) {
|
||||||
|
clearInterval(this.intervalProgress);
|
||||||
|
this.showProgress = false;
|
||||||
|
this.$Message.success("生成成功!");
|
||||||
|
} else {
|
||||||
|
this.progressVal = Math.floor((progressResult.processed / progressResult.total) * 100);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}, 1000);
|
||||||
|
}, 10000);
|
||||||
|
} else if (res.code === 100000) {
|
||||||
|
this.showProgress = true;
|
||||||
|
this.intervalProgress = setInterval(()=> {
|
||||||
|
getProgress().then(resp => {
|
||||||
|
let progressResult = resp.result
|
||||||
|
if (progressResult !=null && progressResult.flag === 0) {
|
||||||
|
clearInterval(this.intervalProgress);
|
||||||
|
this.showProgress = false;
|
||||||
|
this.$Message.success("生成成功!");
|
||||||
|
} else {
|
||||||
|
this.progressVal = Math.floor((progressResult.processed / progressResult.total) * 100);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}, 1000);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
},
|
},
|
||||||
// 保存设置
|
// 保存设置
|
||||||
setupSetting() {
|
setupSetting() {
|
||||||
|
|
Loading…
Reference in New Issue