Commit bde7e20f479f5f75cbab57c5831e978936ab1f3c
1 parent
cac28d75
用户导入记录
Showing
3 changed files
with
409 additions
and
0 deletions
src/utils/routerList.js
| @@ -192,6 +192,16 @@ export function getRoutes() { | @@ -192,6 +192,16 @@ export function getRoutes() { | ||
| 192 | } | 192 | } |
| 193 | }, | 193 | }, |
| 194 | { | 194 | { |
| 195 | + path: 'importuser', | ||
| 196 | + name: 'importuser', | ||
| 197 | + | ||
| 198 | + component: () => | ||
| 199 | + import ('@/views/user/picuserimport'), | ||
| 200 | + meta: { | ||
| 201 | + title: '图片导入用户', | ||
| 202 | + } | ||
| 203 | + }, | ||
| 204 | + { | ||
| 195 | path: 'admin', | 205 | path: 'admin', |
| 196 | name: 'admin', | 206 | name: 'admin', |
| 197 | 207 |
src/views/user/components/picuserimport.vue
0 → 100644
src/views/user/picuserimport.vue
0 → 100644
| 1 | +<template> | ||
| 2 | + <div style="padding:10px"> | ||
| 3 | + <div class="seetingsDiv" style=""> | ||
| 4 | + <div class="flex" style="width:75%"> | ||
| 5 | + | ||
| 6 | + | ||
| 7 | + <el-form :inline="true" class="demo-form-inline"> | ||
| 8 | + <el-form-item label="关键字"> | ||
| 9 | + <el-input placeholder="输入关键字搜索" v-model="query.keyword"></el-input> | ||
| 10 | + </el-form-item> | ||
| 11 | + | ||
| 12 | + | ||
| 13 | + | ||
| 14 | + <el-form-item label="最高学历"> | ||
| 15 | + <el-select v-model="query.xueli" placeholder="最高学历"> | ||
| 16 | + <el-option label="大专" value="dazhuan"></el-option> | ||
| 17 | + <el-option label="本科" value="benke"></el-option> | ||
| 18 | + <el-option label="博士" value="boshi"></el-option> | ||
| 19 | + </el-select> | ||
| 20 | + </el-form-item> | ||
| 21 | + | ||
| 22 | + <el-form-item label="性别"> | ||
| 23 | + <el-select v-model="query.sex" placeholder="性别"> | ||
| 24 | + <el-option label="男" value="1"></el-option> | ||
| 25 | + <el-option label="女" value="0"></el-option> | ||
| 26 | + </el-select> | ||
| 27 | + </el-form-item> | ||
| 28 | + | ||
| 29 | + | ||
| 30 | + <el-form-item> | ||
| 31 | + <el-button type="success" @click="search">搜索</el-button> | ||
| 32 | + <el-button size="mini" @click="handleshare()" type="primary">批量确认</el-button> | ||
| 33 | + <el-button size="mini" @click="handleAdd()" type="primary">新增一行</el-button> | ||
| 34 | + </el-form-item> | ||
| 35 | + </el-form> | ||
| 36 | + | ||
| 37 | + </div> | ||
| 38 | + <el-upload class="upload-demo" action="/api/Account/importUsers?UserClassId=0" multiple :limit="1" | ||
| 39 | + :show-file-list="false" :on-exceed="handleExceed" :on-success="handleSuccess" :file-list="fileList"> | ||
| 40 | + <el-button size="small" type="primary">上传待解析图片</el-button> | ||
| 41 | + </el-upload> | ||
| 42 | + </div> | ||
| 43 | + | ||
| 44 | + | ||
| 45 | + | ||
| 46 | + <el-table ref="mytable" :data="table_data" style="width: 100%" @selection-change="handleSelectionChange"> | ||
| 47 | + <el-table-column v-if="radio" type="index" width="50"></el-table-column> | ||
| 48 | + <el-table-column v-if="selection" type="selection" width="55"></el-table-column> | ||
| 49 | + <el-table-column align="center" v-for="(item,index,key) in table_columns" :item="item" :key="key" :index="index" | ||
| 50 | + :label="item.label"> | ||
| 51 | + <template slot-scope="scope"> | ||
| 52 | + <el-input v-if=" scope.row.edit" size="small" v-model="scope.row[item.prop]" :placeholder="'请输入'+item.label"> | ||
| 53 | + </el-input> | ||
| 54 | + <span v-if=" !scope.row.edit">{{scope.row[item.prop]}}</span> | ||
| 55 | + </template> | ||
| 56 | + </el-table-column> | ||
| 57 | + <el-table-column label="操作" align="center" width="300"> | ||
| 58 | + <template slot-scope="scope"> | ||
| 59 | + <!-- 全局控制的编辑 --> | ||
| 60 | + <div v-if="is_edit&&scope.row.add==undefined" style="display: inline-block;"> | ||
| 61 | + <!-- 编辑 --> | ||
| 62 | + <el-button size="mini" v-if="!scope.row.edit" @click="handleEdit(scope.$index, scope.row)" type="primary">编辑 | ||
| 63 | + </el-button> | ||
| 64 | + <!-- 保存 --> | ||
| 65 | + <el-button size="mini" type="success" :plain="true" v-if="scope.row.edit" | ||
| 66 | + @click="handleSave(scope.$index, scope.row)">保存</el-button> | ||
| 67 | + </div> | ||
| 68 | + <!-- 添加控制 --> | ||
| 69 | + <div v-if="scope.row.add!=undefined&&scope.row.add" style="display: inline-block;"> | ||
| 70 | + <!-- 保存 --> | ||
| 71 | + <el-button size="mini" type="success" :plain="true" v-if="scope.row.edit" | ||
| 72 | + @click="handleSave(scope.$index, scope.row)">保存</el-button> | ||
| 73 | + </div> | ||
| 74 | + <!-- 全局控制删除 --> | ||
| 75 | + <el-button size="mini" v-if="is_delete&&scope.row.add==undefined" :plain="true" type="warning" | ||
| 76 | + style="margin-left:10px" @click="handleshare(scope.$index, scope.row)">确认信息</el-button> | ||
| 77 | + <el-button size="mini" v-if="is_delete&&scope.row.add==undefined" :plain="true" type="danger" | ||
| 78 | + style="margin-left:10px" @click="handleDelete(scope.$index, scope.row)">删除</el-button> | ||
| 79 | + </template> | ||
| 80 | + </el-table-column> | ||
| 81 | + </el-table> | ||
| 82 | + </div> | ||
| 83 | +</template> | ||
| 84 | + | ||
| 85 | +<script> | ||
| 86 | + export default { | ||
| 87 | + methods: { | ||
| 88 | + //隔行变色 | ||
| 89 | + tableRowClassName() { | ||
| 90 | + //选取DOM节点 | ||
| 91 | + var trs = this.$refs.mytable.$el | ||
| 92 | + .getElementsByTagName("tbody")[0] | ||
| 93 | + .getElementsByTagName("tr"); | ||
| 94 | + for (var i in trs) { | ||
| 95 | + if (i % 2 == 0) { | ||
| 96 | + //当隔行变色未true时改变颜色 | ||
| 97 | + if (this.space_color) { | ||
| 98 | + trs[i].style.backgroundColor = "#f0f9eb"; | ||
| 99 | + } else { | ||
| 100 | + trs[i].style.backgroundColor = ""; | ||
| 101 | + } | ||
| 102 | + } | ||
| 103 | + } | ||
| 104 | + }, | ||
| 105 | + | ||
| 106 | + //多选框 | ||
| 107 | + handleSelectionChange(val) { | ||
| 108 | + this.multipleSelection = val; | ||
| 109 | + console.log("selection:", this.multipleSelection); | ||
| 110 | + }, | ||
| 111 | + //编辑 | ||
| 112 | + handleEdit(index, row) { | ||
| 113 | + console.log(index, row); | ||
| 114 | + row.edit = true; | ||
| 115 | + }, | ||
| 116 | + //删除 | ||
| 117 | + handleDelete(index, row) { | ||
| 118 | + | ||
| 119 | + console.log(index, row); | ||
| 120 | + | ||
| 121 | + this.table_data.splice(index, 1); | ||
| 122 | + | ||
| 123 | + this.$message({ | ||
| 124 | + message: "删除成功!", | ||
| 125 | + type: "success" | ||
| 126 | + }); | ||
| 127 | + }, | ||
| 128 | + | ||
| 129 | + handleshare(index, row) { | ||
| 130 | + if (!row) { | ||
| 131 | + this.table_data = []; | ||
| 132 | + | ||
| 133 | + } | ||
| 134 | + else { | ||
| 135 | + | ||
| 136 | + console.log(index, row); | ||
| 137 | + this.table_data.splice(index, 1); | ||
| 138 | + } | ||
| 139 | + | ||
| 140 | + | ||
| 141 | + | ||
| 142 | + this.$message({ | ||
| 143 | + message: "确认成功!", | ||
| 144 | + type: "success" | ||
| 145 | + }); | ||
| 146 | + }, | ||
| 147 | + | ||
| 148 | + //保存 | ||
| 149 | + handleSave(index, row) { | ||
| 150 | + console.log(index, row); | ||
| 151 | + row.edit = false; | ||
| 152 | + | ||
| 153 | + delete this.table_data[index].add; | ||
| 154 | + | ||
| 155 | + this.$message({ | ||
| 156 | + message: "保存成功!", | ||
| 157 | + type: "success" | ||
| 158 | + }); | ||
| 159 | + }, | ||
| 160 | + handleAdd() { | ||
| 161 | + var addDataJson = {}; | ||
| 162 | + for (var key in this.new_date_json) { | ||
| 163 | + if (key === "edit") { | ||
| 164 | + delete addDataJson[key]; | ||
| 165 | + } else if (key === "add") { | ||
| 166 | + delete addDataJson[key]; | ||
| 167 | + } else { | ||
| 168 | + addDataJson[key] = ""; | ||
| 169 | + } | ||
| 170 | + } | ||
| 171 | + addDataJson.edit = true; | ||
| 172 | + addDataJson.add = true; | ||
| 173 | + this.table_data.push(addDataJson); | ||
| 174 | + }, | ||
| 175 | + //初始化编辑属性 | ||
| 176 | + initEditAttribute() { | ||
| 177 | + var self = this; | ||
| 178 | + var edit = self.edit; | ||
| 179 | + | ||
| 180 | + var dataArray = [ | ||
| 181 | + { | ||
| 182 | + date: "2022-03-22", | ||
| 183 | + name: "王明", | ||
| 184 | + province: "四川", | ||
| 185 | + phone: '15888888888', | ||
| 186 | + city: "成都", | ||
| 187 | + address: "四川省成都市金牛区茶店子101", | ||
| 188 | + zip: 200333, | ||
| 189 | + sex: '男', | ||
| 190 | + age: 33, | ||
| 191 | + minzu: '汉', | ||
| 192 | + zhuanye: '计算机', | ||
| 193 | + xueli: '博士' | ||
| 194 | + }, { | ||
| 195 | + date: "2022-03-22", | ||
| 196 | + name: "周超", | ||
| 197 | + province: "四川", | ||
| 198 | + phone: '15833344444', | ||
| 199 | + city: "成都", | ||
| 200 | + address: "四川省成都市金牛区茶店子102", | ||
| 201 | + zip: 200333, | ||
| 202 | + sex: '男', | ||
| 203 | + age: 30, | ||
| 204 | + minzu: '汉', | ||
| 205 | + zhuanye: '计算机', | ||
| 206 | + xueli: '博士' | ||
| 207 | + }, { | ||
| 208 | + date: "2022-03-22", | ||
| 209 | + name: "杨志", | ||
| 210 | + province: "四川", | ||
| 211 | + phone: '15827271123', | ||
| 212 | + city: "成都", | ||
| 213 | + address: "四川省成都市金牛区茶店子103", | ||
| 214 | + zip: 200333, | ||
| 215 | + sex: '男', | ||
| 216 | + age: 28, | ||
| 217 | + minzu: '汉', | ||
| 218 | + zhuanye: '计算机', | ||
| 219 | + xueli: '博士' | ||
| 220 | + }, | ||
| 221 | + | ||
| 222 | + ]; | ||
| 223 | + | ||
| 224 | + if (dataArray.length > 0) { | ||
| 225 | + //添加编辑事件 | ||
| 226 | + for (var index in dataArray) { | ||
| 227 | + dataArray[index]["edit"] = false; | ||
| 228 | + this.table_data.push(dataArray[index]); | ||
| 229 | + } | ||
| 230 | + | ||
| 231 | + if (Object.keys(this.new_date_json).length === 0) { | ||
| 232 | + //新增时,初始化数据结构 | ||
| 233 | + this.initAddDataJson(dataArray[0]); | ||
| 234 | + } | ||
| 235 | + } | ||
| 236 | + console.log("this.tableData:", this.table_data); | ||
| 237 | + }, | ||
| 238 | + initAddDataJson(dataArray) { | ||
| 239 | + //新增时,初始化数据结构 | ||
| 240 | + var dataJson = dataArray; | ||
| 241 | + var newDateJson = {}; | ||
| 242 | + for (var key in dataJson) { | ||
| 243 | + if (key === "edit") { | ||
| 244 | + newDateJson[key] = "true"; | ||
| 245 | + } else { | ||
| 246 | + newDateJson[key] = ""; | ||
| 247 | + } | ||
| 248 | + } | ||
| 249 | + newDateJson["add"] = true; | ||
| 250 | + this.new_date_json = newDateJson; | ||
| 251 | + } | ||
| 252 | + }, | ||
| 253 | + mounted: function () { | ||
| 254 | + this.initEditAttribute(); | ||
| 255 | + //确保方法在页面渲染后调用 | ||
| 256 | + this.$nextTick(function () { | ||
| 257 | + /////方法 | ||
| 258 | + this.tableRowClassName(); | ||
| 259 | + }); | ||
| 260 | + }, | ||
| 261 | + watch: { | ||
| 262 | + space_color: function () { | ||
| 263 | + //监听数据变化 | ||
| 264 | + this.$nextTick(function () { | ||
| 265 | + /////方法 | ||
| 266 | + this.tableRowClassName(); | ||
| 267 | + }); | ||
| 268 | + }, | ||
| 269 | + table_data: function () { | ||
| 270 | + //监听数据变化f | ||
| 271 | + this.$nextTick(function () { | ||
| 272 | + /////方法 | ||
| 273 | + this.tableRowClassName(); | ||
| 274 | + }); | ||
| 275 | + } | ||
| 276 | + }, | ||
| 277 | + data() { | ||
| 278 | + return { | ||
| 279 | + query: {}, | ||
| 280 | + new_date_json: {}, //数据结构 | ||
| 281 | + multipleSelection: [], //复选框,数据 | ||
| 282 | + is_edit: true, //是否可编辑 | ||
| 283 | + is_delete: true, //是否可删除 | ||
| 284 | + selection: true, //是否需要复选框 | ||
| 285 | + radio: false, //单选变色 | ||
| 286 | + space_color: true, //隔行变色 | ||
| 287 | + //表头信息 | ||
| 288 | + table_columns: [ | ||
| 289 | + { | ||
| 290 | + prop: "date", | ||
| 291 | + label: "日期", | ||
| 292 | + width: "150" | ||
| 293 | + }, | ||
| 294 | + { | ||
| 295 | + prop: "name", | ||
| 296 | + label: "姓名", | ||
| 297 | + width: "150" | ||
| 298 | + }, | ||
| 299 | + { | ||
| 300 | + prop: "phone", | ||
| 301 | + label: "手机号", | ||
| 302 | + width: "150" | ||
| 303 | + }, | ||
| 304 | + { | ||
| 305 | + prop: "age", | ||
| 306 | + label: "年龄", | ||
| 307 | + width: "80" | ||
| 308 | + }, | ||
| 309 | + { | ||
| 310 | + prop: "sex", | ||
| 311 | + label: "性别", | ||
| 312 | + width: "80" | ||
| 313 | + }, | ||
| 314 | + { | ||
| 315 | + prop: "minzu", | ||
| 316 | + label: "民族", | ||
| 317 | + width: "" | ||
| 318 | + }, | ||
| 319 | + { | ||
| 320 | + prop: "zhuanye", | ||
| 321 | + label: "专业", | ||
| 322 | + width: "" | ||
| 323 | + }, | ||
| 324 | + { | ||
| 325 | + prop: "xueli", | ||
| 326 | + label: "最高学历", | ||
| 327 | + width: "" | ||
| 328 | + }, | ||
| 329 | + { | ||
| 330 | + prop: "city", | ||
| 331 | + label: "城市", | ||
| 332 | + width: "150" | ||
| 333 | + }, | ||
| 334 | + { | ||
| 335 | + prop: "address", | ||
| 336 | + label: "地址", | ||
| 337 | + width: "150" | ||
| 338 | + } | ||
| 339 | + ], | ||
| 340 | + //表格数据 | ||
| 341 | + table_data: [ | ||
| 342 | + // { | ||
| 343 | + // date: "2016-05-03", | ||
| 344 | + // name: "王小虎", | ||
| 345 | + // province: "上海", | ||
| 346 | + // city: "普陀区", | ||
| 347 | + // address: "上海市普陀区金沙江路 1518 弄", | ||
| 348 | + // zip: 200333, | ||
| 349 | + // sex: 18 | ||
| 350 | + // }, | ||
| 351 | + // { | ||
| 352 | + // date: "2016-05-02", | ||
| 353 | + // sex: 18, | ||
| 354 | + // name: "王小虎", | ||
| 355 | + // province: "上海", | ||
| 356 | + // city: "普陀区", | ||
| 357 | + // address: "上海市普陀区金沙江路 1518 弄", | ||
| 358 | + // zip: 200333 | ||
| 359 | + // }, | ||
| 360 | + // { | ||
| 361 | + // date: "2016-05-04", | ||
| 362 | + // name: "王小虎", | ||
| 363 | + // sex: 18, | ||
| 364 | + // province: "上海", | ||
| 365 | + // city: "普陀区", | ||
| 366 | + // address: "上海市普陀区金沙江路 1518 弄", | ||
| 367 | + // zip: 200333 | ||
| 368 | + // } | ||
| 369 | + ] | ||
| 370 | + }; | ||
| 371 | + } | ||
| 372 | + }; | ||
| 373 | +</script> | ||
| 374 | +<style lang="scss" scoped> | ||
| 375 | + .seetingsDiv { | ||
| 376 | + display: flex; | ||
| 377 | + align-items: center; | ||
| 378 | + width: 100%; | ||
| 379 | + padding-top: 10px; | ||
| 380 | + padding-left: 10px; | ||
| 381 | + /* height: 60px; */ | ||
| 382 | + background: #efefef; | ||
| 383 | + /* line-height: 60px; */ | ||
| 384 | + border-radius: 5px; | ||
| 385 | + box-shadow: 0 0 5px #cdcdcd; | ||
| 386 | + justify-content: space-between; | ||
| 387 | + } | ||
| 388 | + | ||
| 389 | + .seetingsDiv button { | ||
| 390 | + height: 40px; | ||
| 391 | + background-color: #304156; | ||
| 392 | + border: 0px; | ||
| 393 | + margin-left: 10px; | ||
| 394 | + box-shadow: 0 0 5px #cdcdcd; | ||
| 395 | + float: none; | ||
| 396 | + margin-right: 10px; | ||
| 397 | + } | ||
| 398 | +</style> | ||
| 0 | \ No newline at end of file | 399 | \ No newline at end of file |