增加新功能,用户导入,未完成,需要对接导入接口

This commit is contained in:
2023-11-08 16:52:38 +08:00
parent bbd24b24ae
commit dc1b11155a
13 changed files with 234 additions and 17 deletions

View File

@@ -31,8 +31,8 @@
<!-- <el-table-column prop="comment" label="描述"></el-table-column>-->
<el-table-column prop="type" label="类型"></el-table-column>
<el-table-column label="删除" width="80">
<template slot-scope="scope">
<el-button @click.native.prevent="removeField(scope.row,scope.$index)" type="text" size="small">
<template slot-scope="scope" >
<el-button @click.native.prevent="removeField(scope.row,scope.$index)" type="text" size="small" v-show="scope.row.type">
删除
</el-button>
</template>
@@ -71,7 +71,7 @@
</el-table-column>
<el-table-column label="删除" width="80">
<template slot-scope="scope">
<el-button @click.native.prevent="removeRelation(scope.row,scope.$index)" type="text" size="small">
<el-button @click.native.prevent="removeRelation(scope.row,scope.$index)" type="text" size="small" v-show="scope.row.label && scope.row.dstId">
删除
</el-button>
</template>

View File

@@ -15,7 +15,7 @@
height="550"
border
style="width: 100%">
<el-table-column prop="comment" label="属性名称"></el-table-column>
<el-table-column prop="comment" label="属性名称" :formatter="handleCommentFormater"></el-table-column>
<el-table-column prop="type" label="数据类型"></el-table-column>
<!-- <el-table-column prop="Null" label="允许空值"></el-table-column>-->
<!-- <el-table-column prop="Default" label="默认值"></el-table-column>-->
@@ -107,6 +107,11 @@ export default {
},
methods: {
handleCommentFormatter(row) {
// for(let i in ) {
//
// }
},
updateValue(space, name) {
vm.space = space;
vm.modifyCmd.name = name;

View File

@@ -489,7 +489,7 @@ export default {
if(node.labels === 'tag_1412011336') {
node.style = {
fill: '#8fe8e8'
fill: '#3cec6c'
}
}

View File

@@ -51,7 +51,7 @@
</template>
</el-table-column>
<el-table-column prop="createTime" label="创建时间" width="180"></el-table-column>
<el-table-column label="操作" width="150">
<el-table-column label="操作" width="180">
<template slot-scope="scope">
<el-button @click.native.prevent="modifyRow(scope.row)" type="text" size="small">
编辑

View File

@@ -16,11 +16,13 @@
</div>
<div style="margin: 0px 0 20px 0">
<el-button type="primary" @click="createRow()" icon="el-icon-plus"> </el-button>
<el-button type="primary" @click="showImportUserPage()" icon="el-icon-upload2">导入用户</el-button>
</div>
<div>
<el-table :data="result.records" style="width: 100%">
<el-table-column type="index" label="行号" width="60"></el-table-column>
<el-table-column prop="fid" label="fid"></el-table-column>
<el-table-column prop="realname" label="姓名"></el-table-column>
<el-table-column prop="labels" label="标签">
<div slot-scope="scope">
<template v-for="(tag,index) in scope.row.labelsArr">
@@ -130,6 +132,11 @@ export default {
_this.qo.pageNo = val;
_this.queryData();
},
showImportUserPage() {
_this.$router.push({
path: "importUser"
});
},
linkUser(item) {
_this.$router.push({
path: "linkUser", query: {

View File

@@ -6,7 +6,7 @@
<i title="返回"></i>
</div>
</div>
<div class="block_box" style="margin-top: 0">
<div class="block_box" style="margin-top: 20px">
<div class="title">推荐</div>
<el-form :inline="true" class="demo-form-inline">
<el-form-item>
@@ -15,7 +15,7 @@
v-for="item in recommendList"></el-option>
</el-select>
</el-form-item>
<el-form-item label="categories">
<el-form-item label="种类">
<el-select v-model="gorseQo.category" @change="getRecommendItem">
<el-option value="" label="无"></el-option>
<el-option :key="item.id" :value="item.name" :label="item.name"
@@ -57,19 +57,19 @@ export default {
user: {},
categoryList: [],
recommendList: [{
label: 'Recommendation',
label: '默认推荐',
value: '_'
}, {
label: 'Offline Recommendation',
label: '离线推荐',
value: 'offline'
}, {
label: 'Collaborative Recommendation',
label: '协同推荐',
value: 'collaborative'
}, {
label: 'Item-based Recommendation',
label: '基于物品推荐',
value: 'item_based'
}, {
label: 'User-based Recommendation',
label: '基于用户推荐',
value: 'user_based'
}],
list: []

View File

@@ -6,7 +6,7 @@
<i title="返回"></i>
</div>
</div>
<div class="block_box" style="margin-top: 0">
<div class="block_box" style="margin-top: 20px">
<div class="title">信息</div>
<div >
<el-form label-width="50px">

View File

@@ -0,0 +1,197 @@
<template>
<div>
<div class="menu-title">
导入用户
<div class="icon icon-back" @click="backBtn">
<i title="返回"></i>
</div>
</div>
<div class="block_box" style="margin-top: 20px;padding: 20px">
<el-form ref="cmd" label-width="100px" :rules="rules" :model="cmd">
<el-form-item label="文件" prop="file">
<el-upload
class="upload-demo"
action="#"
:auto-upload="false"
:on-change="handleFileChange"
:limit="1"
:file-list="fileList">
<el-button size="small" type="primary">点击上传</el-button>
<div slot="tip" class="el-upload__tip">只能上传csv文件</div>
</el-upload>
</el-form-item>
<el-form-item label="字段分隔符" prop="field">
<el-input v-model="cmd.field" placeholder="请输入字段分隔符" style="width: 300px"
@change="refreshList"></el-input>
</el-form-item>
<!-- <el-form-item label="类别分隔符" prop="categories">-->
<!-- <el-input v-model="cmd.categories" placeholder="请输入类别分隔符" style="width: 300px"></el-input>-->
<!-- </el-form-item>-->
<el-form-item label="唯一ID" prop="id">
<el-select v-model="cmd.id" style="width: 300px" v-if="cmd.ifFirstHead"
@change="refreshList">
<template v-if="cmd.ifFirstHead">
<el-option :value="index" :label="item" v-for="(item,index) in columnList" :key="index"></el-option>
</template>
<template v-if="!cmd.ifFirstHead">
<el-option :value="index" :label="index" v-for="(item,index) in columnList" :key="index"></el-option>
</template>
</el-select>
</el-form-item>
<el-form-item label="标签" prop="labels">
<el-select v-model="cmd.labels" style="width: 300px" v-if="cmd.ifFirstHead"
@change="refreshList">
<template v-if="cmd.ifFirstHead">
<el-option :value="index" :label="item" v-for="(item,index) in columnList" :key="index"></el-option>
</template>
<template v-if="!cmd.ifFirstHead">
<el-option :value="index" :label="index" v-for="(item,index) in columnList" :key="index"></el-option>
</template>
</el-select>
</el-form-item>
<el-form-item label="">
<el-checkbox label="第一行为表头" v-model="cmd.ifFirstHead" @change="refreshList"></el-checkbox>
</el-form-item>
</el-form>
<el-table :data="list" style="width: 100%" height="400">
<el-table-column type="index" label="行号" width="60"></el-table-column>
<el-table-column prop="id" :label="'ID('+(cmd.ifFirstHead ? columnList[cmd.id] : cmd.id)+')'"></el-table-column>
<el-table-column prop="labels" :label="'标签('+(cmd.ifFirstHead ? columnList[cmd.labels] : cmd.labels)+')'">
<template v-slot="scope">
<label style="color: red" v-if="scope.row.errorFlag">JSON格式化异常</label>
<label v-if="!scope.row.errorFlag">{{ scope.row.labels }}</label>
</template>
</el-table-column>
</el-table>
<el-button type="primary" class="submit-btn" @click="confirmSubmit">确认提交</el-button>
</div>
</div>
</template>
<script>
import request from '@/utils/request';
var _this;
export default {
name: "ImportUser",
data() {
return {
cmd: {
field: ',',
categories: '|',
id: '',
labels: '',
ifFirstHead: true
},
fileList: [],
originList: [], // 原始的可能包含表头的数据默认存储最多21行如果数据不止21行的话
list: [], // 页面table显示的数据
columnList: [],// 上传csv的表头
rules: {
fid: [
{required: true, message: '请选择文件'}
],
field: [
{required: true, message: '字段分隔符不能为空'}
],
categories: [
{required: true, message: '类别分隔符不能为空'}
],
},
}
},
mounted() {
_this = this;
},
methods: {
handleFileChange(file, fileList) {
const fileReader = new FileReader();
fileReader.onload = function () {
const fileData = fileReader.result;
_this.originList = fileData.split('\n').slice(0, 21);
// 提前填充一个默认的值给对应的ID列和标签列
_this.prepareFieldAndLabels();
_this.refreshList();
};
fileReader.readAsText(file.raw);
},
prepareFieldAndLabels() {
_this.columnList = _this.originList[0].split(_this.cmd.field);
_this.cmd.id = 0;
_this.cmd.labels = 1;
},
refreshList() {
// 处理原始数据将行文本截取成数组放入list
_this.list = [];
if (_this.cmd.field.length === 0) {
return;
}
for (let i in _this.originList) {
if (_this.cmd.ifFirstHead && i == 0) {
// 第一行是表头跳过list塞入
continue;
}
let row = _this.originList[i].split(_this.cmd.field);
let errorFlag = false;
try {
JSON.parse(row[_this.cmd.labels]);
} catch (e) {
errorFlag = true;
}
_this.list.push({
id: row[_this.cmd.id],
labels: row[_this.cmd.labels],
errorFlag: errorFlag
});
}
},
confirmSubmit() { // 提交确认
// request({
// url: '/risk-user/query_unique',
// method: 'post',
// data: {
// EQS_fid: _this.userId
// }
// }).then(res => {
// });
},
backBtn() {
this.$router.push({
path: "userManage", query: {
qo: JSON.stringify({
pageNo: 1,
pageSize: 10,
LIKES_fid: '',
})
}
});
},
}
}
</script>
<style src="../../../css/back.css" scoped></style>
<style scoped lang="scss">
.block_box {
margin: 25px;
background: #FFFFFF;
border-radius: 3px;
.title {
border-bottom: 1px solid #ccc;
padding: 15px 25px;
}
> div {
padding: 25px;
}
.submit-btn {
margin-left: auto;
margin-top: 20px;
display: flex;
}
}
</style>

View File

@@ -6,7 +6,7 @@
<i title="返回"></i>
</div>
</div>
<div class="block_box" style="margin-top: 0">
<div class="block_box" style="margin-top: 10px">
<div class="title">信息</div>
<div>
<el-form label-width="100px">

View File

@@ -6,7 +6,7 @@
<i title="返回"></i>
</div>
</div>
<div class="block_box" style="margin-top: 0">
<div class="block_box" style="margin-top: 20px">
<div class="title">信息</div>
<div>
<el-form label-width="100px">

View File

@@ -21,6 +21,10 @@ div.icon i {
vertical-align: sub;
}
.icon-back {
box-shadow: 0 2px 12px 0 rgba(0,0,0,.1);
}
.icon-back i {
background: url("../assets/image/icon/fanhui.png") no-repeat center/contain;
}

View File

@@ -63,6 +63,10 @@ export default new Router({
path: 'intelligenceRecommend',
component: () => import('@/components/menus/IntelligenceRecommend')
},
{
path: 'importUser',
component: () => import('@/components/menus/user/ImportUser')
},
{
path: 'similarUser',
component: () => import('@/components/menus/user/SimilarUser')

View File

@@ -36,7 +36,7 @@ const menuList = [
{
index: "5",
icon: "el-icon-s-opportunity",
name: "智能推荐",
name: "快捷检索",
url: "/intelligenceRecommend"
}
];