提交 c6331cf2 authored 作者: 林国禄's avatar 林国禄

统计点管理

上级 8c2283dd
import request from '@/utils/request' import request from '@/utils/request'
// 查询统计点列表(级联列表)
export function listByProvince(query) {
return request({
url: '/backstage/point/listByProvince',
method: 'get',
params: query
})
}
// 查询统计点列表(级联列表) // 查询统计点列表(级联列表)
export function cascadeList(type) { export function cascadeList(type) {
return request({ return request({
......
...@@ -113,37 +113,75 @@ ...@@ -113,37 +113,75 @@
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row> </el-row>
<el-table v-loading="loading" :data="pointList" @selection-change="handleSelectionChange"> <el-table
<el-table-column type="selection" width="55" align="center" /> :data="pointList"
<el-table-column type="index" :index="table_index" label="序号" align="center" prop="id"/> style="width: 100%"
<el-table-column label="名称" align="center" prop="name" /> row-key="id"
<el-table-column label="账号" align="center" prop="account" /> border
<el-table-column label="密码" align="center" prop="password" /> lazy
<el-table-column label="状态" align="center" prop="status" /> :load="load"
<el-table-column label="经度" align="center" prop="longitude" /> :tree-props="{children: 'children', hasChildren: 'hasChildren'}">
<el-table-column label="纬度" align="center" prop="latitude" /> <el-table-column type="selection" width="55" align="center" />
<el-table-column label="上级id" align="center" prop="superiorId" /> <el-table-column type="index" :index="table_index" label="序号" align="center" prop="id"/>
<el-table-column label="统计点类型" align="center" prop="type" /> <el-table-column label="名称" align="center" prop="name" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width"> <el-table-column label="账号" align="center" prop="account" />
<template slot-scope="scope"> <el-table-column label="密码" align="center" prop="password" />
<el-button <el-table-column label="状态" align="center" prop="status" />
size="mini" <el-table-column label="经度" align="center" prop="longitude" />
type="text" <el-table-column label="纬度" align="center" prop="latitude" />
icon="el-icon-edit" <el-table-column label="上级id" align="center" prop="superiorId" />
@click="handleUpdate(scope.row)" <el-table-column label="统计点类型" align="center" prop="type" />
v-hasPermi="['backstage:point:edit']" <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
>修改</el-button> <template slot-scope="scope">
<el-button <el-button
size="mini" size="mini"
type="text" type="text"
icon="el-icon-delete" icon="el-icon-edit"
@click="handleDelete(scope.row)" @click="handleUpdate(scope.row)"
v-hasPermi="['backstage:point:remove']" v-hasPermi="['backstage:point:edit']"
>删除</el-button> >修改</el-button>
</template> <el-button
</el-table-column> size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['backstage:point:remove']"
>删除</el-button>
</template>
</el-table-column>
</el-table> </el-table>
<!-- <el-table v-loading="loading" :data="pointList" @selection-change="handleSelectionChange">-->
<!-- <el-table-column type="selection" width="55" align="center" />-->
<!-- <el-table-column type="index" :index="table_index" label="序号" align="center" prop="id"/>-->
<!-- <el-table-column label="名称" align="center" prop="name" />-->
<!-- <el-table-column label="账号" align="center" prop="account" />-->
<!-- <el-table-column label="密码" align="center" prop="password" />-->
<!-- <el-table-column label="状态" align="center" prop="status" />-->
<!-- <el-table-column label="经度" align="center" prop="longitude" />-->
<!-- <el-table-column label="纬度" align="center" prop="latitude" />-->
<!-- <el-table-column label="上级id" align="center" prop="superiorId" />-->
<!-- <el-table-column label="统计点类型" align="center" prop="type" />-->
<!-- <el-table-column label="操作" align="center" class-name="small-padding fixed-width">-->
<!-- <template slot-scope="scope">-->
<!-- <el-button-->
<!-- size="mini"-->
<!-- type="text"-->
<!-- icon="el-icon-edit"-->
<!-- @click="handleUpdate(scope.row)"-->
<!-- v-hasPermi="['backstage:point:edit']"-->
<!-- >修改</el-button>-->
<!-- <el-button-->
<!-- size="mini"-->
<!-- type="text"-->
<!-- icon="el-icon-delete"-->
<!-- @click="handleDelete(scope.row)"-->
<!-- v-hasPermi="['backstage:point:remove']"-->
<!-- >删除</el-button>-->
<!-- </template>-->
<!-- </el-table-column>-->
<!-- </el-table>-->
<pagination <pagination
v-show="total>0" v-show="total>0"
:total="total" :total="total"
...@@ -158,19 +196,30 @@ ...@@ -158,19 +196,30 @@
<el-form-item label="名称" prop="name"> <el-form-item label="名称" prop="name">
<el-input v-model="form.name" placeholder="请输入名称" /> <el-input v-model="form.name" placeholder="请输入名称" />
</el-form-item> </el-form-item>
<el-form-item label="账号" prop="account"> <div v-if="this.statisticsPointsType != '6'">
<el-input v-model="form.account" placeholder="请输入账号" /> <el-form-item label="账号" prop="account">
</el-form-item> <el-input v-model="form.account" placeholder="请输入账号" />
<el-form-item label="密码" prop="password"> </el-form-item>
<el-input placeholder="请输入密码" v-model="form.password" show-password></el-input>
</el-form-item> <el-form-item label="登录密码" prop="password">
<el-input show-password type="password" v-model="form.password" autocomplete="off" placeholder="密码要求:8-20位字符在数字、小写、大写字母以及特殊字符中四选三"></el-input>
<el-progress :percentage="passwordPercent" :format="passwordPercentFormat"></el-progress>
</el-form-item>
<el-form-item label="再次输入密码" prop="comfirmPassword">
<el-input show-password type="password" v-model="form.comfirmPassword" autocomplete="off"></el-input>
</el-form-item>
<!-- <el-form-item label="密码" prop="password">-->
<!-- <el-input placeholder="请输入密码" type="password" v-model="form.password" show-password></el-input>-->
<!-- </el-form-item>-->
</div>
<el-form-item v-if="this.statisticsPointsType != '1'" label="所属层级" prop="password"> <el-form-item v-if="this.statisticsPointsType != '1'" label="所属层级" prop="levelValue">
<div class="block"> <div class="block">
<span class="demonstration"></span> <span class="demonstration"></span>
<el-cascader <el-cascader
style="width: 100%" style="width: 100%"
v-model="levelValue" v-model="form.levelValue"
:options="levelOptions" :options="levelOptions"
:props="{ expandTrigger: 'hover' }" :props="{ expandTrigger: 'hover' }"
@change="handleChange" @change="handleChange"
...@@ -203,14 +252,72 @@ ...@@ -203,14 +252,72 @@
</template> </template>
<script> <script>
import { cascadeList, listPoint, getPoint, delPoint, addPoint, updatePoint, exportPoint } from "@/api/backstage/point"; import { listByProvince, cascadeList, listPoint, getPoint, delPoint, addPoint, updatePoint, exportPoint } from "@/api/backstage/point";
export default { export default {
name: "Point", name: "Point",
data() { data() {
const validatePassword = (rule, value, callback) => {
console.log(value)
if (value === '' || value === undefined || value === null) {
if(this.form.id == null){
callback(new Error('如需新增统计点的相关信息,请输入统计点的密码后才能进行操作'));
}else {
callback(new Error('如需修改统计点的相关信息,请输入统计点的密码后才能进行编辑修改'));
}
} else {
//6-20位包含字符、数字和特殊字符
var ls = 0;
if (this.form.password !== '') {
if(this.form.password.match(/([a-z])+/)){
ls++;
}
if(this.form.password.match(/([0-9])+/)){
ls++;
}
if(this.form.password.match(/([A-Z])+/)){
ls++;
}
if(this.form.password.match(/([\W])+/) && !this.form.password.match(/(![\u4E00-\u9FA5])+/)){ ls++;
}
if(this.form.password.length<6 || this.form.password.length>20 ){
callback(new Error('要求6-20位字符'));
ls=0;
}
if(this.form.password.match(/([\u4E00-\u9FA5])+/)){
callback(new Error('不能包含中文字符'));
ls=0;
}
switch (ls) {
case 0: this.passwordPercent = 0;callback(new Error('数字、小写字母、大写字母以及特殊字符中四选三'));break;
case 1: this.passwordPercent = 33;callback(new Error('数字、小写字母、大写字母以及特殊字符中四选三'));break;
case 2: this.passwordPercent = 66;callback(new Error('数字、小写字母 、大写字母以及特殊字符中四选三'));break;
case 3:
case 4: this.passwordPercent = 100;break;
default: this.passwordPercent = 0;break;
}
}
callback();
}
};
const validateConfirmPassword = (rule, value, callback) => {
if (value === '' || value === null) {
callback(new Error('请输入密码'));
} else {
if (this.form.comfirmPassword !== this.form.password) {
callback(new Error('两次输入的密码不一致'));
// this.$refs.ruleForm.validateField('checkPass');
}
callback();
}
};
return { return {
//密码进度条
passwordPercent:0,
//级联选择器相关 //级联选择器相关
levelValue: [], // levelValue: [],
levelOptions: [], levelOptions: [],
//统计点类型对象 //统计点类型对象
statisticsPointsTypeObj: [ statisticsPointsTypeObj: [
...@@ -259,9 +366,35 @@ export default { ...@@ -259,9 +366,35 @@ export default {
type: null, type: null,
}, },
// 表单参数 // 表单参数
form: {}, form: {
name: null,
account: null,
password: null,
status: null,
longitude: null,
latitude: null,
superiorId: null,
type: null,
comfirmPassword: null,
levelValue: null,
},
// 表单校验 // 表单校验
rules: { rules: {
name: [
{ required: true, message: "统计点名称不能为空,请输入统计点名称", trigger: "blur" }
],
account: [
{ required: true, message: "统计点账号不能为空,请输入统计点账号", trigger: "blur" }
],
password:[
{required: true, validator: validatePassword, trigger: ['blur', 'change'] },
],
comfirmPassword:[
{required: true, validator: validateConfirmPassword, trigger: ['blur', 'change'] }
],
levelValue:[
{required: true, message: "统计点所属层级不能为空,请选择统计点层级", trigger: 'change' }
],
} }
}; };
}, },
...@@ -272,11 +405,17 @@ export default { ...@@ -272,11 +405,17 @@ export default {
/** 查询统计点列表 */ /** 查询统计点列表 */
getList() { getList() {
this.loading = true; this.loading = true;
listPoint(this.queryParams).then(response => { listByProvince(this.queryParams).then(response => {
this.pointList = response.rows; this.pointList = response.rows;
this.total = response.total; this.total = response.total;
this.loading = false; this.loading = false;
}); });
// listPoint(this.queryParams).then(response => {
// this.pointList = response.rows;
// this.total = response.total;
// this.loading = false;
// });
}, },
// 取消按钮 // 取消按钮
cancel() { cancel() {
...@@ -296,7 +435,8 @@ export default { ...@@ -296,7 +435,8 @@ export default {
superiorId: null, superiorId: null,
type: null, type: null,
createTime: null, createTime: null,
updateTime: null updateTime: null,
levelValue: null,
}; };
this.resetForm("form"); this.resetForm("form");
}, },
...@@ -318,7 +458,8 @@ export default { ...@@ -318,7 +458,8 @@ export default {
}, },
/** 新增按钮操作 */ /** 新增按钮操作 */
handleAdd() { handleAdd() {
this.statisticsPointsType = ''; this.statisticsPointsType = '';//初始化统计点类型
this.passwordPercent = 0;//初始化密码进度条
this.addStatisticsTypeStatus = true; this.addStatisticsTypeStatus = true;
}, },
//选择新增类型确定按钮 //选择新增类型确定按钮
...@@ -335,20 +476,33 @@ export default { ...@@ -335,20 +476,33 @@ export default {
this.title = "添加"+titleName+"统计点"; this.title = "添加"+titleName+"统计点";
//获取所有统计点级联数据 //获取所有统计点级联数据
this.cascadeList();
},
//获取所有统计点级联数据
cascadeList(){
if(this.statisticsPointsType != '1'){ if(this.statisticsPointsType != '1'){
cascadeList(this.statisticsPointsType).then(res=>{ cascadeList(this.statisticsPointsType).then(res=>{
this.levelOptions = res.data; this.levelOptions = res.data;
}); });
} }
}, },
/** 修改按钮操作 */ /** 修改按钮操作 */
handleUpdate(row) { handleUpdate(row) {
this.passwordPercent = 0;//初始化密码进度条
this.reset(); this.reset();
const id = row.id || this.ids const id = row.id || this.ids;
getPoint(id).then(response => { getPoint(id).then(response => {
this.form = response.data; this.form = response.data;
this.form.levelValue = JSON.parse(response.data.levelValue)
console.log(this.form.levelValue)
this.open = true; this.open = true;
this.title = "修改统计点"; this.title = "修改统计点";
this.statisticsPointsType = response.data.type;
this.form.password = "";
//获取所有统计点级联数据
this.cascadeList();
}); });
}, },
/** 提交按钮 */ /** 提交按钮 */
...@@ -357,23 +511,33 @@ export default { ...@@ -357,23 +511,33 @@ export default {
setTimeout(()=>{ setTimeout(()=>{
this.repeatSubmit = false //点击一次时隔两秒后才能再次点击 this.repeatSubmit = false //点击一次时隔两秒后才能再次点击
},2000) },2000)
this.$refs["form"].validate(valid => { this.$refs["form"].validate(valid => {
if (valid) { if (valid) {
this.form.type = this.statisticsPointsType;//统计点类型 this.form.type = this.statisticsPointsType;//统计点类型
this.form.superiorId = this.levelValue[this.levelValue.length-1];//上级id this.form.superiorId = this.form.levelValue[this.form.levelValue.length-1];//上级id
this.form.levelValue = JSON.stringify(this.form.levelValue)
if (this.form.id != null) { if (this.form.id != null) {
updatePoint(this.form).then(response => { updatePoint(this.form).then(response => {
this.msgSuccess("修改成功"); if(response.code === 200){
this.open = false; this.msgSuccess("修改成功");
this.getList(); this.open = false;
this.getList();
}else {
this.form.levelValue = JSON.parse(this.form.levelValue)
}
}); });
} else { } else {
addPoint(this.form).then(response => { addPoint(this.form).then(response => {
this.msgSuccess("新增成功"); if(response.code === 200){
this.open = false; this.msgSuccess("新增成功");
this.getList(); this.open = false;
this.getList();
}else {
this.form.levelValue = JSON.parse(this.form.levelValue)
}
}); });
} }
} }
...@@ -382,7 +546,7 @@ export default { ...@@ -382,7 +546,7 @@ export default {
/** 删除按钮操作 */ /** 删除按钮操作 */
handleDelete(row) { handleDelete(row) {
const ids = row.id || this.ids; const ids = row.id || this.ids;
this.$confirm('是否确认删除统计点编号为"' + ids + '"的数据项?', "警告", { this.$confirm('是否确认删除统计点数据项?', "警告", {
confirmButtonText: "确定", confirmButtonText: "确定",
cancelButtonText: "取消", cancelButtonText: "取消",
type: "warning" type: "warning"
...@@ -411,7 +575,28 @@ export default { ...@@ -411,7 +575,28 @@ export default {
return (this.queryParams.pageNum - 1) * this.queryParams.pageSize + index + 1 return (this.queryParams.pageNum - 1) * this.queryParams.pageSize + index + 1
}, },
handleChange(value) { handleChange(value) {
console.log(value); // console.log(value);
},
passwordPercentFormat(percentage){
return percentage === 100 ? '符合' : `不符`;
},
//树形表格懒加载
load(tree, treeNode, resolve) {
setTimeout(() => {
resolve([
{
id: 31,
date: '2016-05-01',
name: '王小虎',
address: '上海市普陀区金沙江路 1519 弄'
}, {
id: 32,
date: '2016-05-01',
name: '王小虎',
address: '上海市普陀区金沙江路 1519 弄'
}
])
}, 1000)
} }
} }
}; };
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论