oil-station/fuintAdmin_zt/src/views/components/Service/staff.vue
2024-07-31 17:29:10 +08:00

710 lines
21 KiB
Vue

<template>
<div class="app-containers">
<div class="bai-box" style="margin-top: 20px">
<div class="top-box">
<div class="d-s">
<el-input v-model="queryParams.realName" placeholder="请输入用户姓名"
style="width: 240px;margin-right: 15px"></el-input>
<el-input v-model="queryParams.mobile" placeholder="请输入登录账号"
style="width: 240px;margin-right: 15px"></el-input>
<el-select v-model="queryParams.status" placeholder="请选择状态">
<el-option
v-for="dict in dict.type.zhzt"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</div>
<div>
<el-button
type="primary"
icon="el-icon-search"
@click="handleQuery"
>搜索
</el-button>
<el-button
icon="el-icon-refresh-right"
@click="resetQuery"
>重置
</el-button>
<el-button
type="primary"
icon="el-icon-plus"
@click="handleAdd"
>新增员工
</el-button>
</div>
</div>
<div style="width: 100%;height: 64vh;overflow: auto">
<el-table ref="tables" border v-loading="loading" :data="list" @selection-change="handleSelectionChange"
:default-sort="defaultSort" @sort-change="handleSortChange">
<el-table-column
type="index"
align="center"
label="序号"
width="50">
</el-table-column>
<el-table-column label="用户姓名" width="140" align="center" prop="realName"/>
<el-table-column label="用户角色" width="140" align="center" prop="dutyName">
<template slot-scope="scope">
<span>{{ scope.row.dutyName || "--" }}</span>
</template>
</el-table-column>
<el-table-column label="登录账号" align="center" prop="accountName"/>
<el-table-column label="员工状态" align="center" width="80" prop="status">
<template slot-scope="scope">
<el-switch
v-model="scope.row.status"
active-value="qy"
inactive-value="jy"
active-color="#13ce66"
inactive-color="#ff4949">
</el-switch>
</template>
</el-table-column>
<el-table-column label="一键加油" align="center" prop="isRefuel">
<template slot-scope="scope">
<dict-tag :options="dict.type.display" :value="scope.row.isRefuel"/>
</template>
</el-table-column>
<!-- <el-table-column label="收款通知" align="center" prop="notice">-->
<!-- <template slot-scope="scope">-->
<!-- <dict-tag :options="dict.type.notice" :value="scope.row.notice"/>-->
<!-- </template>-->
<!-- </el-table-column>-->
<el-table-column label="创建时间" align="center" prop="createTime">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime) }}</span>
</template>
</el-table-column>
<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)"
>修改
</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
>删除
</el-button>
</template>
</el-table-column>
</el-table>
</div>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.page"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
</div>
<!-- 添加或修改对话框 -->
<el-dialog :title="title" :visible.sync="open" width="30%" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="120px">
<el-form-item label="所属机构" prop="storeId">
<el-select v-model="form.storeId+''" placeholder="请选择角色" style="width: 270px">
<el-option
v-for="item in options"
:key="item.id+''"
:label="item.name"
:value="item.id+''"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="员工姓名" prop="realName">
<el-input v-model="form.realName" placeholder="请输入姓名" maxlength="30" style="width: 270px"/>
</el-form-item>
<el-form-item label="联系方式" prop="mobile">
<el-input v-model="form.mobile" placeholder="请输入联系人电话" maxlength="30" style="width: 270px"/>
</el-form-item>
<el-form-item label="登录账号" prop="accountName">
<el-input v-model="form.accountName" placeholder="请输入登录账号" maxlength="30" style="width: 270px"/>
</el-form-item>
<el-form-item label="登录密码" prop="password" v-if="!form.id">
<el-input v-model="form.password" placeholder="请输入登录密码" type="password" maxlength="30" style="width: 270px"/>
</el-form-item>
<el-form-item label="用户角色" prop="roleId">
<el-select v-model="form.roleId" placeholder="请选择角色" style="width: 270px">
<el-option
v-for="item in roleList"
:key="item.dutyId+''"
:label="item.dutyName"
:value="item.dutyId+''"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="账号状态" prop="status">
<el-switch
v-model="form.status"
active-value="qy"
inactive-value="jy"
active-color="#13ce66"
inactive-color="#ff4949">
</el-switch>
</el-form-item>
<el-form-item label="一键加油" prop="isRefuel">
<!-- <el-select v-model="form.isRefuel" style="width: 270px">-->
<!-- <el-option-->
<!-- v-for="dict in dict.type.display"-->
<!-- :key="dict.value"-->
<!-- :label="dict.label"-->
<!-- :value="dict.value"-->
<!-- />-->
<!-- </el-select>-->
<div style="display: flex;" v-if="form.isRefuel=='xs'" @click="form.isRefuel='yc'">
<div>
<img src="@/assets/images/danxuan_c.png"/>
<span class="text_49">显示</span>
</div>
<div style="margin-left: 15px">
<img src="@/assets/images/danxuan_h.png"/>
<span class="text_50">隐藏</span>
</div>
</div>
<div style="display: flex;" v-else @click="form.isRefuel='xs'">
<div>
<img src="@/assets/images/danxuan_h.png"/>
<span class="text_50">显示</span>
</div>
<div style="margin-left: 15px">
<img src="@/assets/images/danxuan_c.png"/>
<span class="text_49">隐藏</span>
</div>
</div>
<span class="text_51" >*&nbsp;若用户的一键加油设置为隐藏,则收银台无法选择该员工</span>
</el-form-item>
<!-- </el-row>-->
<!-- <el-row>-->
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm">确 定</el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import {getName} from "../../../utils/fuint";
import {addStaff, delStaff, getStaff, listStaff, updateStaff} from "../../../api/staff/staff";
import {dutyList} from "@/api/duty/duty";
import {getStoreListByDeptId} from "../../../api/store";
// import {getDuty, listDuty} from "@/api/staff/duty";
export default {
name: "StaffList",
dicts: ['ywqx', 'display', 'zhzt', 'transaction', 'time_frame', 'handover', 'handover_quit',
'jbjl', 'special_prem'],
props: ["id", 'deptId'],
data() {
return {
options: [{
value: '选项1',
label: '黄金糕'
}, {
value: '选项2',
label: '双皮奶'
}, {
value: '选项3',
label: '蚵仔煎'
}, {
value: '选项4',
label: '龙须面'
}, {
value: '选项5',
label: '北京烤鸭'
}],
value: '',
input: '',
drawer: false,
// 标题
title: "",
// 遮罩层
loading: false,
// 选中数组
ids: [],
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
categoryOptions: [],
storeOptions: [],
// role:[],
posPrem: '',
posOptions: [
{value: '首页权限', label: '首页权限', children: [{value: '禁用普通收款权限', label: '禁用普通收款权限'},]},
{value: '会员储值', label: '会员储值'},
{value: '会员实体卡', label: '会员实体卡'},
{value: '会员积分', label: '会员积分'},
{value: '加油金变动', label: '加油金变动'},
{value: '会员卡券', label: '会员卡券'},
{value: '会员成长值', label: '会员成长值'},
],
props: {multiple: true},
appletPrem: '',
appletOptions: [
{value: '首页权限', label: '首页权限', children: [{value: '女装', label: '女装'},]},
{value: '会员储值', label: '会员储值'},
{value: '会员实体卡', label: '会员实体卡'},
],
writeOff: [],
write: [],
specialPrem: [],
special: [],
// 总条数
total: 0,
// 表格数据
list: [],
// 是否显示弹出层
open: false,
// 日期范围
dateRange: [],
// 默认排序
defaultSort: {prop: 'createTime', order: 'descending'},
// 角色列表
roleList: [],
// 表单参数
form: {
id: '',
category: '',
userId: '',
mobile: '',
realName: '',
wechat: '',
merchantId: '',
storeId: this.id,
auditedStatus: '',
auditedTime: '',
description: '',
isRefuel: 'yc',
handoverMode: 'dqmdtyjb',
handoverPrem: 'yqx',
handoverOut: 'jbtc',
record: 'qbjl',
merchantStatus: 'qy',
screen: 'qy',
posPrem: '',
appletPrem: '',
notice: 'advice_jy',
oilGunId: '',
timeFrame: 'bx',
refund: 'yqx',
transaction: 'qbjy',
writeOff: '',
specialPrem: '',
official: '',
status: 'qy',
pos: 'jy',
role: ''
},
// 查询参数
queryParams: {
page: 1,
pageSize: 10,
realName: '',
mobile: '',
status: ''
},
// 表单校验
rules: {
realName: [
{required: true, message: "姓名不能为空", trigger: "blur"},
{min: 2, max: 30, message: '姓名长度必须介于 2 和 20 之间', trigger: 'blur'}
],
mobile: [
{required: true, message: "手机号不能为空", trigger: "blur"},
{min: 11, max: 20, message: '手机号长度必须11', trigger: 'blur'}
],
accountName: [
{required: true, message: "请填写登录账号", trigger: "blur"}
],
password: [
{required: true, message: "请填写登录密码", trigger: "blur"}
],
roleId: [
{required: true, message: "请选择员工角色", trigger: "blur"}
],
isRefuel: [
{required: true, message: "请选择加油状态", trigger: "blur"}
],
pos: [
{required: true, message: "请选择员状态", trigger: "blur"}
],
transaction: [
{required: true, message: "请选择", trigger: "blur"}
],
notice: [
{required: true, message: "请选择", trigger: "blur"}
],
timeFrame: [
{required: true, message: "请选择", trigger: "blur"}
],
handoverMode: [
{required: true, message: "请选择", trigger: "blur"}
],
handoverPrem: [
{required: true, message: "请选择", trigger: "blur"}
],
handoverOut: [
{required: true, message: "请选择", trigger: "blur"}
],
record: [
{required: true, message: "请选择", trigger: "blur"}
],
merchantStatus: [
{required: true, message: "请选择", trigger: "blur"}
],
screen: [
{required: true, message: "请选择", trigger: "blur"}
],
status: [
{required: true, message: "请选择", trigger: "blur"}
]
}
};
},
created() {
this.getList();
// this.getDuty();
this.getStoreList();
},
methods: {
showDesc() {
this.drawer = true;
},
handleNodeClick1(data) {
this.form.posPrem = JSON.stringify(data);
},
handleNodeClick2(data) {
this.form.appletPrem = JSON.stringify(data);
},
getCheckbox() {
this.form.writeOff = this.writeOff.toString();
this.form.specialPrem = this.specialPrem.toString();
},
// 页面跳转
toTarget(url) {
this.$router.push({path: url});
},
getName,
// 查询列表
getList() {
this.loading = true;
this.queryParams.storeId = this.id
listStaff(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
this.list = response.data.records;
this.total = response.data.total;
console.log(response)
// response.data.records.forEach(item=>{
// this.categoryOptions.push(item.category)
// })
this.loading = false;
}
);
// getStaffList(this.addDateRange(this.queryParams, this.dateRange)).then( response => {
// this.list = response.data.paginationResponse.content;
// this.total = response.data.paginationResponse.totalElements;
// this.categoryOptions = response.data.categoryList;
// this.loading = false;
// }
// );
},
// 查询角色列表
getDuty() {
listDuty().then(response => {
this.role = response.data
})
},
// 店铺列表
getStoreList() {
// listStaff().then(response => {
// this.storeOptions = response.data.records;
// }
// );
getStoreListByDeptId(this.deptId).then(response => {
this.options = response.data;
}
);
},
// 搜索按钮操作
handleQuery() {
this.queryParams.page = 1;
this.getList();
},
// 重置按钮操作
resetQuery() {
this.dateRange = [];
this.resetForm("queryForm");
this.$refs.tables.sort(this.defaultSort.prop, this.defaultSort.order)
this.queryParams = {
page: 1,
pageSize: 10,
realName: '',
mobile: '',
status: ''
}
this.handleQuery();
},
// 状态修改
handleStatusChange(row) {
let text = row.auditedStatus == "A" ? "启用" : "禁用";
this.$modal.confirm('确认要' + text + '"' + row.realName + '"吗?').then(function () {
// return updateStaffStatus(row.id, row.auditedStatus);
return updateStaff({id: row.id, auditedStatus: row.auditedStatus})
}).then(() => {
this.$modal.msgSuccess(text + "成功");
}).catch(function () {
row.auditedStatus = row.auditedStatus === "A" ? "A" : "N";
});
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.operId)
this.multiple = !selection.length
},
// 排序触发事件
handleSortChange(column, prop, order) {
this.queryParams.orderByColumn = column.prop;
this.queryParams.isAsc = column.order;
this.getList();
},
// 新增按钮操作
handleAdd() {
this.reset();
this.open = true;
this.title = "新增员工";
this.getRoleList1()
},
// 获取角色信息
getRoleList1() {
let data = {
page: 1,
pageSize: 10000,
dutyType: 3
}
dutyList(data).then(res => {
this.roleList = res.data.records
})
},
// 表单重置
reset() {
this.posPrem = '';
this.appletPrem = '';
this.writeOff = []
this.form = {
id: '',
category: '',
userId: '',
mobile: '',
realName: '',
wechat: '',
merchantId: '',
storeId: this.id,
auditedStatus: 'A',
auditedTime: '',
description: '',
isRefuel: 'xs',
handoverMode: 'dqmdtyjb',
handoverPrem: 'yqx',
handoverOut: 'jbtc',
record: 'qbjl',
merchantStatus: 'qy',
screen: 'qy',
posPrem: '',
appletPrem: '',
notice: 'advice_jy',
oilGunId: '',
timeFrame: 'bx',
refund: 'yqx',
transaction: 'qbjy',
writeOff: '',
specialPrem: '',
official: '',
status: 'qy',
pos: 'jy',
role: ''
};
this.resetForm("form");
},
// 取消按钮
cancel() {
this.open = false;
this.reset();
},
// 提交按钮
submitForm: function () {
this.$refs["form"].validate(valid => {
if (valid) {
this.form.storeId = this.id;
if (!this.form.id) {
this.form.posPrem = JSON.stringify(this.form.posPrem);
this.form.appletPrem = JSON.stringify(this.form.appletPrem);
addStaff(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
});
} else {
updateStaff(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
}
}
});
},
// 修改按钮操作
handleUpdate(row) {
this.reset();
this.open = true;
const id = row.id || this.ids;
getStaff(id).then(response => {
this.form = response.data;
// this.form.category = response.data.staffInfo.category + '';
this.open = true;
this.title = "编辑员工信息";
this.writeOff = this.form.writeOff.split(",");
this.specialPrem = this.form.specialPrem.split(",");
this.posPrem = JSON.parse(this.form.posPrem);
this.appletPrem = JSON.parse(this.form.appletPrem);
this.getRoleList1()
});
},
// 删除按钮操作
handleDelete(row) {
const name = row.realName || this.id;
this.$modal.confirm('是否确认删除"' + name + '"的数据项?').then(function () {
return delStaff(row.id);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {
});
}
}
};
</script>
<style scoped>
.app-containers {
width: 98%;
height: 100%;
/* height: 100vh; */
background: #f9f9f9;
margin: 20px auto;
}
.bai-box {
background: #fff;
box-sizing: border-box;
padding: 20px;
}
.pagin-box {
background: white;
box-sizing: border-box;
padding: 20px;
}
.baoguo {
background: white;
box-sizing: border-box;
padding: 20px;
margin-bottom: 20px;
}
.top-box {
width: 100%;
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 15px;
}
.d-s {
display: flex;
align-items: center;
}
.thumbnail_8 {
width: 20px;
height: 20px;
margin-left: 10px;
}
.text_49 {
width: 24px;
height: 12px;
overflow-wrap: break-word;
color: rgba(255, 150, 85, 1);
font-size: 12px;
font-weight: normal;
text-align: left;
white-space: nowrap;
line-height: 18px;
margin-top: 3px;
}
.thumbnail_9 {
width: 20px;
height: 20px;
margin-left: 20px;
}
.text_50 {
width: 24px;
height: 12px;
overflow-wrap: break-word;
color: rgba(153, 153, 153, 1);
font-size: 12px;
font-weight: normal;
text-align: left;
white-space: nowrap;
line-height: 18px;
margin-top: 3px;
}
.text_51 {
width: 257px;
height: 10px;
overflow-wrap: break-word;
color: rgba(153, 153, 153, 1);
font-size: 10px;
font-weight: normal;
text-align: right;
white-space: nowrap;
line-height: 15px;
}
</style>