生成线下用户

This commit is contained in:
fan 2020-03-30 16:52:53 +08:00
parent 238f8a3d88
commit 338a9e9683
5 changed files with 86 additions and 35 deletions

6
.env.local Normal file
View File

@ -0,0 +1,6 @@
# just a flag
NODE_ENV = 'Local'
# base api
VUE_APP_BASE_API = 'https://joylink.club/jlcloud'
VUE_VOICE_API = 'https://joylink.club'

View File

@ -8,6 +8,7 @@
"dev": "vue-cli-service serve --open", "dev": "vue-cli-service serve --open",
"build": "vue-cli-service build", "build": "vue-cli-service build",
"test": "vue-cli-service build --mode staging", "test": "vue-cli-service build --mode staging",
"local": "vue-cli-service build --mode local",
"preview": "node build/index.js --preview", "preview": "node build/index.js --preview",
"lint": "eslint --ext .js,.vue src", "lint": "eslint --ext .js,.vue src",
"test:unit": "jest --clearCache && vue-cli-service test:unit", "test:unit": "jest --clearCache && vue-cli-service test:unit",

View File

@ -3,9 +3,9 @@ export function getBaseUrl() {
let BASE_API; let BASE_API;
if (process.env.NODE_ENV === 'development') { if (process.env.NODE_ENV === 'development') {
// BASE_API = 'https://joylink.club/jlcloud'; // BASE_API = 'https://joylink.club/jlcloud';
BASE_API = 'https://test.joylink.club/jlcloud'; // BASE_API = 'https://test.joylink.club/jlcloud';
// BASE_API = 'http://192.168.3.5:9000'; // 袁琪 // BASE_API = 'http://192.168.3.5:9000'; // 袁琪
// BASE_API = 'http://192.168.3.6:9000'; // 旭强 BASE_API = 'http://192.168.3.6:9000'; // 旭强
// BASE_API = 'http://192.168.3.41:9000'; // 张赛 // BASE_API = 'http://192.168.3.41:9000'; // 张赛
// BASE_API = 'http://192.168.3.82:9000'; // 杜康 // BASE_API = 'http://192.168.3.82:9000'; // 杜康
// BASE_API = 'http://192.168.3.41:9000'; // 张赛 // BASE_API = 'http://192.168.3.41:9000'; // 张赛

View File

@ -2,23 +2,29 @@
<el-dialog v-dialogDrag title="创建本地用户" :visible.sync="dialogVisible" width="30%" :before-close="doClose" center :close-on-click-modal="false"> <el-dialog v-dialogDrag title="创建本地用户" :visible.sync="dialogVisible" width="30%" :before-close="doClose" center :close-on-click-modal="false">
<el-form ref="form" :model="addModel" label-width="130px" :rules="rules"> <el-form ref="form" :model="addModel" label-width="130px" :rules="rules">
<el-form-item label="批量生成数量" prop="quantity"> <el-form-item label="批量生成数量" prop="quantity">
<el-input-number v-model="addModel.quantity" size="mini" :min="1" :max="999" /> <el-input-number v-model="addModel.quantity" size="mini" :min="1" :max="999" @change="changeQuantity" />
</el-form-item> </el-form-item>
<el-form-item label="是否生成用户权限" prop="generatePermission"> <el-form-item label="是否生成用户权限" prop="generatePermission">
<el-checkbox v-model="addModel.generatePermission" change="changeGeneratePermission" /> <el-checkbox v-model="addModel.generatePermission" @change="changeGeneratePermission" />
</el-form-item>
<el-form-item v-show="addModel.generatePermission" label="权限ID" prop="permissionId">
<el-input v-model="addModel.permissionId" size="mini" style="width:140px" />
</el-form-item>
<el-form-item v-show="addModel.generatePermission" label="权限月数" prop="monthNumber">
<el-input-number v-model="addModel.monthNumber" size="mini" :min="1" :max="999" />
</el-form-item>
<el-form-item v-show="addModel.generatePermission" label="权限数量" prop="permissionQuantity">
<el-input-number v-model="addModel.permissionQuantity" size="mini" :min="1" :max="999" />
</el-form-item> </el-form-item>
</el-form> </el-form>
<div v-if="addModel.generatePermission">
<template v-for="(item, index) in permissionConfigVOList">
<el-form :ref="`form${index}`" :model="item" label-width="130px" :rules="childRules">
<el-form-item label="权限ID" prop="permissionId">
<el-input v-model="item.permissionId" size="mini" style="width:140px" />
</el-form-item>
<el-form-item label="权限月数" prop="monthNumber">
<el-input-number v-model="item.monthNumber" size="mini" :min="1" :max="999" />
</el-form-item>
<el-form-item label="权限数量" prop="quantity">
<el-input-number v-model="item.quantity" size="mini" :min="1" :max="999" />
</el-form-item>
</el-form>
</template>
</div>
<span slot="footer" class="dialog-footer"> <span slot="footer" class="dialog-footer">
<el-button type="primary" @click="handleCorrelation">{{ $t('global.confirm') }}</el-button> <el-button type="primary" @click="handleCommit">{{ $t('global.confirm') }}</el-button>
<el-button @click="dialogVisible = false">{{ $t('global.cancel') }}</el-button> <el-button @click="dialogVisible = false">{{ $t('global.cancel') }}</el-button>
</span> </span>
</el-dialog> </el-dialog>
@ -34,49 +40,86 @@ export default {
dialogVisible: false, dialogVisible: false,
addModel: { addModel: {
quantity: 1, quantity: 1,
generatePermission: false, generatePermission: false
monthNumber: 1,
permissionId: '',
permissionQuantity: 1
}, },
permissionConfigVOList: [],
mapDict: {}, mapDict: {},
mapList: [] mapList: [],
}; rules: {
},
computed: {
rules() {
const rules = {
quantity: [ quantity: [
{ required: true, message: '请输入批量生成用户数量', trigger: 'blur' } { required: true, message: '请输入批量生成用户数量', trigger: 'blur' }
], ]
},
childRules: {
permissionId: [ permissionId: [
{ required: true, message: '请输入权限ID', trigger: 'blur' } { required: true, message: '请输入权限ID', trigger: 'blur' }
], ],
monthNumber: [ monthNumber: [
{ required: true, message: '请输入权限月数', trigger: 'blur' } { required: true, message: '请输入权限月数', trigger: 'blur' }
], ],
permissionQuantity: [ quantity: [
{ required: true, message: '请输入权限数量', trigger: 'blur' } { required: true, message: '请输入权限数量', trigger: 'blur' }
] ]
};
return rules;
} }
};
}, },
mounted() { mounted() {
this.mapDict = {}; this.mapDict = {};
this.changeQuantity();
}, },
methods: { methods: {
doClose(done) { doClose() {
this.dialogVisible = false; this.dialogVisible = false;
}, },
doShow(data) { doShow() {
this.dialogVisible = true; this.dialogVisible = true;
}, },
changeGeneratePermission(val) { changeGeneratePermission(val) {
if (val) {
this.changeQuantity();
} else {
this.permissionConfigVOList = [];
}
}, },
handleCorrelation() { changeQuantity() {
if (this.permissionConfigVOList.length > this.addModel.quantity) {
this.permissionConfigVOList = this.permissionConfigVOList.splice(0, this.addModel.quantity);
} else if (this.permissionConfigVOList.length < this.addModel.quantity) {
const length = this.addModel.quantity - this.permissionConfigVOList.length;
for (let i = 0; i < length; i++) {
this.permissionConfigVOList.push({
monthNumber: 1,
permissionId: '',
quantity: 1
});
}
}
},
handleCommit() {
this.$refs.form.validate((valid) => {
let count = true;
this.permissionConfigVOList.forEach((item, index) => {
// const name = 'form' + index;
// that.$refs[name].validate((valid) => { if (!valid) { count = false; } });
if (!item.permissionId) { count = false; }
});
if (valid && count) {
const data = {
quantity: this.addModel.quantity,
initPassword: '123456',
generatePermission: this.addModel.generatePermission,
permissionConfigVOList: this.permissionConfigVOList
};
generateOfflineUser(data).then(resp=> {
this.$message.success('创建线下用户成功!');
}).catch(() => {
this.$message.error('创建线下用户失败!');
});
self.doClose();
} else {
this.$message.error('请检查并填写数据!');
}
});
} }
} }
}; };

View File

@ -93,8 +93,9 @@ module.exports = {
'@': path.resolve('src') '@': path.resolve('src')
} }
}; };
var appTarget = 'Common'; // var appTarget = 'Common';
// var appTarget = 'HYD';// 哈尔滨项目打包 // var appTarget = 'HYD';// 哈尔滨项目打包
var appTarget = process.env.NODE_ENV === 'Local' ? 'HYD' : 'Common';
config.plugins.push(new webpack.NormalModuleReplacementPlugin(/(.*)_APP_TARGET(\.*)/, config.plugins.push(new webpack.NormalModuleReplacementPlugin(/(.*)_APP_TARGET(\.*)/,
function (resourse) { function (resourse) {
resourse.request = resourse.request.replace(/APP_TARGET/, `${appTarget}`); resourse.request = resourse.request.replace(/APP_TARGET/, `${appTarget}`);