Commit bfa801db by 无尘

fix: 增加接口

parent 312180a2
/*
* @Descripttion: 添加/编辑管理员
* @version: 1.0.0
* @Author: 无尘
* @Date: 2020-07-24 12:19:48
* @LastEditors: 无尘
* @LastEditTime: 2020-08-06 12:57:41
*/
import getFetch from './getFetch.js';
let api = {
getAdminList: '/level-list', // 获取部门管理员列表
getSearchAdminList: '/staff-search', // 获取管理员列表
getRoleRange: '/role-range', // 获取商户资源范围列表
addAdmin: {
url: '/role-range-save', // 提交审核
method: 'post',
useFormData: true
}
}
api = getFetch(api, '/hb-manage-web');
export default api;
......@@ -4,7 +4,7 @@
* @Author: 无尘
* @Date: 2020-07-21 10:10:57
* @LastEditors: 无尘
* @LastEditTime: 2020-07-29 11:33:58
* @LastEditTime: 2020-08-06 16:35:13
-->
<!--
授权选择门店绑定弹窗
......@@ -22,15 +22,15 @@
<el-radio v-model="formData.sendRange" label="0" @change="changeRange">所有门店</el-radio>
<el-radio class="m-l-40 m-r-8" v-model="formData.sendRange" label="1" @change="changeRange">选择分组</el-radio>
<el-radio class="m-l-40 m-r-8" v-model="formData.sendRange" label="2" @change="changeRange">选择门店</el-radio>
<div v-if="(formData.sendRange == '1' || formData.sendRange == '2') && !formData.selectList.length" class="el-form-item__error">请选择绑定门店</div>
<div v-if="(formData.sendRange == '1' || formData.sendRange == '2') && !formData.selectList.length || String(formData.sendRange) == 'null' || formData.sendRange === ''" class="el-form-item__error">请选择绑定门店</div>
<store-auth-group v-if="formData.sendRange == '1'" :companyId="enterpriseId" :storeType="bindType" :selectGroup="selectGroupData" @checkGroupIds="checkGroupIds"></store-auth-group>
<store-auth-store v-if="formData.sendRange == '2'" :companyId="enterpriseId" :storeType="bindType" :selectStore="selectStoreData" @checkStoreIds="checkStoreIds"></store-auth-store>
</div>
</div>
</div>
<div slot="footer" class="dialog-footer">
<el-button @click="cancel">取消</el-button>
<el-button type="primary" @click="submitForm">确定</el-button>
<el-button @click.stop="cancel">取消</el-button>
<el-button type="primary" @click.stop="submitForm">确定</el-button>
</div>
</el-dialog>
</template>
......@@ -156,6 +156,9 @@ export default {
*/
submitForm() {
const that = this;
if (String(that.formData.sendRange) == 'null' || that.formData.sendRange === '') {
return false;
}
if (that.formData.sendRange == '1' && !that.formData.selectList.length) {
return false;
}
......
<!--
* @Descripttion: gic选择分组
* @version: 1.0.0
* @Author: 无尘
* @Date: 2020-07-21 10:10:57
* @LastEditors: 无尘
* @LastEditTime: 2020-08-06 11:23:23
-->
<!--
门店绑定-选择分组(仅展示)
<store-auth-group :companyId="companyId" :storeType="storeType" :selectGroup="selectGroup"></store-auth-group>
import storeAuthGroup from '@/components/set/store-auth-group.vue';
-->
<template>
<div class="bind-store-body">
<div class="select-search">
<el-input placeholder="请输入分组名称" clearable v-model="searchSelect" @keyup.native="value => toInput(value, searchSelect)" @clear="clearSearch"> <i slot="prefix" class="el-input__icon el-icon-search"></i> </el-input>
</div>
<div class="select-tree-wrap auth-select-tree m-t-20">
<el-tree ref="groupTree" :filter-node-method="filterNode" check-strictly :data="groupData" node-key="storeGroupId" show-checkbox default-expand-all :props="defaultProps" :expand-on-click-node="false" >
<span :id="data.storeGroupId" class="custom-tree-node" slot-scope="{ node, data }" >
<span class="font-14 color-606266">{{ node.label }}</span><span v-if="data.bindFlag == 1" class="font-12 color-909399 p-l-10">{{ data.bindWxEnterpriseName }} 企业已授权</span>
</span>
</el-tree>
</div>
</div>
</template>
<script>
import { _debounce } from '@/common/js/public';
import fetch from '@/api/merchantAuth.js';
const { getGroupList } = fetch;
// import showMsg from '@/common/js/showmsg';
export default {
props: {
companyId: {
type: String,
default: ''
},
storeType: {
type: String,
default: '1' // 1 门店绑定, 2 门店共享
},
selectGroup: {
type: [Object, Array],
default () {
return {};
}
}
},
data() {
return {
searchSelect: '', // 搜索字段
groupData: [],
groupDataCopy: [],
defaultProps: {
children: 'children',
label: 'storeGroupName'
}
};
},
computed: {},
watch: {
searchSelect(val) {
this.$refs.groupTree.filter(val);
},
selectGroup(val) {
const that = this;
if (val.length) {
that.$nextTick(()=>{
that.$refs.groupTree.setCheckedKeys(val.map(ele=>ele.storeGroupId));
})
}
}
},
methods: {
/**
* 过滤搜索
*/
filterNode(value, data) {
if (!value || !data.label) return true;
return data.label.indexOf(value) !== -1;
},
/**
* 输入
*/
toInput: _debounce(function(e, value) {
const that = this;
if (!that.groupDataCopy.length) {
return false;
}
}, 200),
/**
* 清空
*/
clearSearch() {
// const that = this;
return false;
// that.groupData = JSON.parse(JSON.stringify(that.groupDataCopy));
},
/**
* checkchild
*/
checkChild(arr,checkFlag) {
const that = this;
arr.children.forEach(ele => {
that.$refs.groupTree.setChecked(ele.storeGroupId,checkFlag,true);
// 递归子级禁用和选中
if (!!ele.children && !!ele.children.length) {
that.checkChild(ele, checkFlag);
}
})
},
treeData(data) {
let tree = data.filter(father => {
//循环所有项
let branchArr = data.filter(child => {
return father.storeGroupId == child.parentId; //返回每一项的子级数组
});
if (branchArr.length > 0) {
father.hasSonNode = true;
father.children = branchArr; //如果存在子级,则给父级添加一个children属性,并赋值
} else {
father.children = []
father.hasSonNode = false;
}
return father.parentId == 0; //返回第一层
});
return tree;
},
/**
* 设置回显数据
*/
setSelectCheck() {
const that = this;
const ids = that.selectGroup.map(ele=>ele.storeGroupId);
that.groupData.forEach(ele => {
// 如果父级选中了,设置子级禁用
if (ids.includes(ele.storeGroupId) && !!ele.children.length) {
that.checkChild(ele, true);
}
})
},
/**
* 获取门店分组
*/
getGroup() {
const that = this;
const para = {
type: that.storeType,
enterpriseId: that.companyId
};
getGroupList(para)
.then(async res => {
if (!!res.result && res.result.length) {
res.result.forEach(ele => {
ele.expand = false;
ele.children = [];
ele.disabled = true;
ele.label = ele.storeGroupName;
});
}
that.groupData = await that.treeData(JSON.parse(JSON.stringify(res.result))) || [];
// 存一份数据自己搜索
//console.log(that.groupData)
that.groupDataCopy = JSON.parse(JSON.stringify(res.result));
that.$nextTick(()=>{
// 如果是共享门店,也去设置禁用子级
/*if (that.storeType == 2) {
return false;
}*/
that.setSelectCheck();
})
})
.catch(function(error) {
});
},
},
components: {},
mounted() {
const that = this;
that.getGroup();
if (that.selectGroup.length) {
that.$nextTick(()=>{
that.$refs.groupTree.setCheckedKeys(that.selectGroup.map(ele=>ele.storeGroupId));
})
}
}
};
</script>
<style lang="less" scoped>
.bind-store-body {
width: 331px;
padding: 10px;
margin: 20px 0 0 0 ;
border: 1px solid #e4e7ed;
.w-215 {
width: 215px;
}
.w-115 {
width: 115px;
}
.select-tree-wrap {
height: 323px;
overflow-y: auto;
.el-tree {
width: 309px;
height: 323px;
overflow-x: auto;
.custom-tree-node {
flex: 1;
display: flex;
align-items: center;
justify-content: space-between;
font-size: 14px;
padding-right: 8px;
}
}
}
}
</style>
<!--
* @Descripttion: gic选择门店
* @version: 1.0.0
* @Author: 无尘
* @Date: 2020-07-21 10:10:57
* @LastEditors: 无尘
* @LastEditTime: 2020-08-06 11:10:36
-->
<!--
门店绑定-选择门店(仅展示)
<store-auth-store :companyId="companyId" :storeType="storeType" ></store-auth-store>
import storeAuthStore from '@/components/set/store-auth-store.vue';
-->
<template>
<div class="daily-store-select">
<div class="select-search">
<el-input placeholder="请输入门店名称/代码" v-model="searchSelect" style="width: 100%;" clearable @keyup.native="value => toInput(value, searchSelect)" @clear="clearSearch"> <i slot="prefix" class="el-input__icon el-icon-search"></i> </el-input>
</div>
<!-- <div class="checkbox border-box" style="padding: 15px 20px;">
<el-checkbox :indeterminate="isIndeterminate" v-model="checkAll" @change="handleCheckAllChange">全选</el-checkbox>
</div> -->
<div class="el-scrollbar define-search-select">
<div class="el-select-dropdown__wrap el-scrollbar__wrap">
<el-checkbox-group v-model="dailyRuleForm.stores" @change="handleStoresChange" :max="50">
<ul class="el-scrollbar__view el-select-dropdown__list">
<li :class="['el-select-dropdown__item', item.select ? 'selected hover' : '']" v-for="item in stores" :key="item.storeInfoId" @click.stop="toShowMsg(item)">
<el-checkbox disabled :label="item.storeInfoId" >{{ item.storeInfoName }}</el-checkbox>
<span v-if="item.bindFlag == 1" class="font-12 color-909399 p-l-10">{{ item.bindWxEnterpriseName }} 企业已授权</span>
</li>
<li v-if="!stores.length" class="text-center"><span>暂无数据</span></li>
</ul>
</el-checkbox-group>
</div>
</div>
</div>
</template>
<script>
import { _debounce } from '@/common/js/public';
import fetch from '@/api/merchantAuth.js';
const { getStoreList } = fetch;
import showMsg from '@/common/js/showmsg';
export default {
props: {
companyId: {
type: String,
default: ''
},
storeType: {
type: String,
default: '1' // 1 门店绑定, 2 门店共享
},
selectStore: {
type: [Object, Array],
default () {
return {};
}
}
},
data() {
return {
checkAll: false, // 全选
isIndeterminate: false,
searchSelect: '', // 搜索字段
stores: [], // 门店列表集合
storesCopy: [],
dailyRuleForm: {
stores: [], // 已选门店id结果集
},
pageNum: 1,
pageSize: 300
};
},
computed: {},
methods: {
/**
* 判断提示
*/
toShowMsg(data) {
if (data.bindFlag == 1) {
showMsg.showmsg('当前门店已被其他企业绑定,当前企业无法选择!', 'warning');
}
},
/**
* 选择改变
*/
handleStoresChange(value) {
const that = this;
let arr = [];
that.stores.forEach(ele => {
if (value.includes(ele.storeInfoId)) {
arr.push(ele);
}
})
that.$emit('checkStoreIds', JSON.parse(JSON.stringify(arr)));
},
/**
* 输入
*/
toInput: _debounce(function(e, value) {
const that = this;
if (that.searchSelect != '') {
that.stores = [];
that.pageNum = 1;
that.getStoreData();
}
}, 500),
/**
* 清空
*/
clearSearch() {
const that = this;
that.stores = [];
that.pageNum = 1;
that.getStoreData();
// that.stores = JSON.parse(JSON.stringify(that.storesCopy));
},
/**
* 获取门店
*/
getStoreData() {
let that = this;
let para = {
search: that.searchSelect,
enterpriseId: that.companyId,
type: that.storeType,
pageNum: that.pageNum,
pageSize: that.pageSize
};
getStoreList(para)
.then(res => {
if (that.pageNum == 1) {
that.stores = JSON.parse(JSON.stringify(res.result.result)) || [];
that.storesCopy = JSON.parse(JSON.stringify(res.result.result)) || [];
}else {
res.result.result.forEach(ele => {
that.stores.push(ele);
that.storesCopy.push(ele);
})
}
if (that.pageNum*that.pageSize < res.result.totalCount) {
that.pageNum ++;
that.$nextTick(()=>{
that.getStoreData();
})
}
})
.catch(function(error) {
});
}
},
components: {},
watch: {
selectStore: function(newData, oldData) {
const that = this;
if (!!newData.length) {
that.dailyRuleForm.stores = newData.map(el=>el.storeInfoId) || [];
}else {
that.dailyRuleForm.stores = [];
}
},
},
mounted() {
const that = this;
that.stores = [];
that.storesCopy = [];
that.getStoreData();
if (!!that.selectStore.length) {
that.dailyRuleForm.stores = that.selectStore.map(el=>el.storeInfoId) || [];
}else {
that.dailyRuleForm.stores = [];
}
}
};
</script>
<style lang="less" scoped>
.daily-store-select {
position: relative;
width: 331px;
min-height: 398px;
margin: 20px 0 0 0;
padding: 10px;
border: 1px solid #e4e7ed;
.define-search-select {
.el-select-dropdown__wrap {
max-height: 343px;
}
.el-checkbox-group {
overflow-x: auto;
height: 338px;
ul {
height: 100%;
li {
overflow: unset;
text-overflow: unset;
}
}
}
}
}
</style>
......@@ -4,7 +4,7 @@
* @Author: 无尘
* @Date: 2019-03-20 14:36:37
* @LastEditors: 无尘
* @LastEditTime: 2020-08-05 16:15:57
* @LastEditTime: 2020-08-06 16:31:14
-->
<template>
<div class="my-customer-wrap common-set-wrap">
......@@ -149,11 +149,11 @@ export default {
*/
closeSet(type, arr) {
const that = this;
that.selectMode = String(type); // 0 全部 1部分分组 2 部分门店
that.setVisible = false;
if (type == 'close') {
return false;
}
that.selectMode = String(type); // 0 全部 1部分分组 2 部分门店
if (that.bindType == 1) {
that.authForm.bindStoreMode = String(type);
that.authForm.bindRange = JSON.parse(JSON.stringify(arr));
......
......@@ -4,7 +4,7 @@
* @Author: 无尘
* @Date: 2019-03-20 14:36:37
* @LastEditors: 无尘
* @LastEditTime: 2020-08-05 17:50:18
* @LastEditTime: 2020-08-06 17:24:52
-->
<template>
<div class="my-customer-wrap common-set-wrap">
......@@ -20,13 +20,13 @@
<span style="display:block;">
<template v-for="(item, index) in adminForm.adminList">
<span class="el-tag el-tag--info el-tag--small" :key="index+'bind'">
<span class="el-select__tags-text">{{ item.staffName || '--' }}</span>
<span class="el-select__tags-text">{{ item.levelName || '--' }}</span>
<i class="el-tag__close el-icon-close" @click.stop="delAdmin(index, adminForm.adminList)"></i>
</span>
</template>
</span>
</div>
<div v-if="!adminForm.adminList.length" class="add-admin-btn font-14 color-606266 cursor-pointer" @click="addAdmin">
<div v-if="!adminForm.adminList.length" class="add-admin-btn font-14 color-606266 cursor-pointer" @click="showAdmin">
<span class="iconfont icontianjiajiahaowubiankuang font-12"></span><span class="p-l-10">添加</span>
</div>
</div>
......@@ -42,8 +42,8 @@
<el-table-column label="授权范围">
<template slot-scope="scope">
<el-radio v-model="scope.row.radio" label="1">授权</el-radio>
<div v-if="scope.row.radio==1" class="el-select store-item-content" @click="showAuth">
<div class="el-select__tags">
<div v-if="scope.row.radio==1" class="el-select store-item-content" @click="showAuth(scope.$index, scope.row)">
<div v-if="scope.row.bindStoreMode > 0" class="el-select__tags">
<span style="display:block;">
<template v-for="(item, index) in scope.row.bindRange">
<span class="el-tag el-tag--info el-tag--small" :key="index+'bind'">
......@@ -53,18 +53,21 @@
</template>
</span>
</div>
<span v-if="scope.row.bindStoreMode == 0 && scope.row.bindStoreMode !== '' " class="p-l-10 font-14 color-909399">已选全部</span>
</div>
<el-radio class="m-l-10" v-model="scope.row.radio" label="2">不授权</el-radio>
</template>
</el-table-column>
</el-table>
</el-form-item>
<el-form-item class="m-t-20" prop="enterpriseList">
<el-button type="primary" :loading="loadBtn" @click="saveAdmin('adminForm')">确认新建</el-button>
</el-form-item>
</el-form>
</div>
</div>
<select-admin v-if="showAdminFlag" :selectAdmin="adminForm.adminList" @checkAdmins="checkAdmins"></select-admin>
<select-admin-store :enterpriseId="enterpriseId" @closeSet="closeSet"></select-admin-store>
<select-admin-store :showAuthFlag="showAuthFlag" :enterpriseId="enterpriseId" :selectMode="selectMode" :rangeData="rangeData" :bindType="2" @closeSet="closeSet"></select-admin-store>
<!-- <vue-gic-footer></vue-gic-footer> -->
</div>
......@@ -73,8 +76,8 @@
import navCrumb from '@/components/nav/nav.vue';
import selectAdmin from '@/components/set/select-admin.vue';
import selectAdminStore from '@/components/set/select-admin-store.vue';
import fetch from '@/api/merchantAuth.js';
const { getAuthEnterprise } = fetch;
import fetch from '@/api/edit-admin.js';
const { getRoleRange, addAdmin } = fetch;
// import { _debounce } from '@/common/js/public';
export default {
name: 'authMerchant',
......@@ -105,20 +108,72 @@ export default {
{ type: 'array', required: true, message: '请选择授权范围', trigger: 'change' },
]
},
loadBtn: false,
tableData: [{
enterpriseId: '',
enterpriseName: '',
radio: '1',
bindStoreMode: '',
bindRange: [],
// enterpriseId: '',
// enterpriseName: '',
// radio: '1',
// bindStoreMode: '',
// bindRange: [],
}],
showAdminFlag: false, // 显示选择管理员
showAuthFlag: false // 显示右侧门店授权范围
showAuthFlag: false, // 显示右侧门店授权范围
selectMode: '', // 选择 全部、分组、门店
rangeData: [], // 选择的数据
editIndex: '',
editRow: {
bindRange: [],
bindStoreMode: '',
enterpriseId: '',
enterpriseName: '',
shareRange: [],
shareStoreMode: ''
}
};
},
computed: {},
methods: {
/**
* 保存管理员
*/
saveAdmin(formName) {
const that = this;
const arr = JSON.parse(JSON.stringify(that.tableData));
arr.forEach(ele => {
if (ele.radio == 2) {
ele.bindStoreMode = '';
ele.bindRange = ''
}
})
that.adminForm.enterpriseList = arr;
that.loadBtn = true;
that.$refs[formName].validate((valid) => {
if (valid) {
that.postSave()
} else {
that.loadBtn = false;
return false;
}
});
},
postSave() {
const that = this;
let para = {
roleId: that.$route.query.roleId,
staffIds: that.$route.query.staffId || that.adminForm.adminList.map(ele => ele.staffId).join(','),
enterpriseRange: JSON.stringify(that.tableData),
wxEnterpriseId: that.wxEnterpriseId
};
addAdmin(para)
.then(res => {
that.$router.push('/admin-list');
that.loadBtn = false;
})
.catch(function(error) {
that.loadBtn = false;
});
},
/**
* 显示选择管理员
*/
showAdmin() {
......@@ -139,13 +194,35 @@ export default {
delAdmin(index, arr) {
arr.splice(index, 1);
},
checkAdmins(res) {
const that = this;
that.showAdminFlag = false;
if (res == 'close') {
return false;
}
that.adminForm.adminList = res;
},
/**
* 显示授权
*/
showAuth(){
showAuth(index, row){
const that = this;
that.editIndex = index;
that.editRow = row;
that.selectMode = row.bindStoreMode;
that.rangeData = row.bindRange;
that.showAuthFlag = true;
},
closeSet(type, arr) {
const that = this;
that.showAuthFlag = false;
if (type == 'close') {
return false;
}
that.editRow.bindStoreMode = String(type); // 0 全部 1部分分组 2 部分门店
that.editRow.bindRange = JSON.parse(JSON.stringify(arr));
},
/**
* 删除已选授权
*/
......@@ -165,10 +242,22 @@ export default {
getTableList(val) {
const that = this;
let para = {
roleId: that.$route.query.roleId,
staffId: that.$route.query.staffId,
wxEnterpriseId: that.wxEnterpriseId
};
getAuthEnterprise(para)
getRoleRange(para)
.then(res => {
if (!!res.result && !!res.result.length) {
res.result.forEach(ele=> {
ele.radio = (ele.bindStoreMode == null || ele.bindStoreMode === '') && (ele.bindRange == '[]' || ele.bindRange == '') ? '2' : '1';
if (!!ele.bindRange) {
ele.bindRange = JSON.parse(ele.bindRange);
}else {
ele.bindRange = [];
}
})
}
that.tableData = res.result || [];
})
.catch(function(error) {
......@@ -182,9 +271,8 @@ export default {
mounted() {
const that = this;
that.$emit('showAsideMenu', false);
if (that.$route.query.staffId) {
that.getTableList();
}
that.getTableList();
document.documentElement.style.backgroundColor = '#f0f2f5';
},
destroyed() {
......@@ -224,6 +312,7 @@ export default {
vertical-align: middle;
width: 302px;
height: 32px;
line-height: 32px;
overflow: hidden;
white-space: nowrap;
border-radius: 2px;
......
......@@ -4,7 +4,7 @@
* @Author: 无尘
* @Date: 2018-10-10 14:44:45
* @LastEditors: 无尘
* @LastEditTime: 2020-08-05 18:26:37
* @LastEditTime: 2020-08-06 13:36:02
-->
<template>
<div class="unreview-wrap common-set-wrap">
......@@ -224,7 +224,7 @@ export default {
},
dialogVisible: false,
loadBtn: false,
times: null,
timeFlag: null,
loadingFull: ''
};
},
......@@ -372,14 +372,20 @@ export default {
that.dialogVisible = false;
that.auditIds = ids;
that.$nextTick(()=> {
window.clearInterval(that.times);
that.times = null;
that.times = window.setInterval(() => {
that.loadingFull = that.$loading({
lock: true,
text: '数据处理中,请稍候查看',
spinner: 'el-icon-loading',
background: 'rgba(0, 0, 0, 0.7)'
});
window.clearInterval(that.timeFlag);
that.timeFlag = null;
that.timeFlag = window.setInterval(() => {
that.getDetailFlag(that.auditIds)
}, 2000);
}, 3000);
that.$once('hook:beforeDestroy', () => {
window.clearInterval(that.times);
that.times = null;
window.clearInterval(that.timeFlag);
that.timeFlag = null;
});
})
})
......@@ -394,19 +400,15 @@ export default {
};
getAuditDetail(para)
.then(res => {
console.log(res.result.auditResult, that.times )
console.log(res.result.auditResult, that.timeFlag )
if (res.result.auditResult) {
that.loadingFull.close();
window.clearInterval(that.times);
that.times = null;
window.clearInterval(that.timeFlag);
that.timeFlag = null;
that.detailShow = true;
that.currentPage = 1;
that.getTableList();
}else {
that.loadingFull = that.$loading({
lock: true,
text: '数据处理中,请稍候查看',
spinner: 'el-icon-loading',
background: 'rgba(0, 0, 0, 0.7)'
});
that.detailShow = false;
}
})
......@@ -550,8 +552,8 @@ export default {
that.getBrandData();
},
beforeDestroy() { //清除定时器
window.clearInterval(this.times);
this.times = null;
window.clearInterval(this.timeFlag);
this.timeFlag = null;
},
components: {
storeChange,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment