提交 62050bd8 authored 作者: lidongxu's avatar lidongxu

Merge branch 'user' into dev

...@@ -2,7 +2,6 @@ import request from '@/utils/request' ...@@ -2,7 +2,6 @@ import request from '@/utils/request'
// 查询物流轨迹 // 查询物流轨迹
export function getLogisticsListAPI(queryParams) { export function getLogisticsListAPI(queryParams) {
console.log(queryParams)
return request({ return request({
url: '/schedule/sent/query_p', // 不会走 token 校验后台 url: '/schedule/sent/query_p', // 不会走 token 校验后台
params: queryParams params: queryParams
......
...@@ -203,6 +203,15 @@ const getPageList = () => { ...@@ -203,6 +203,15 @@ const getPageList = () => {
const handleClick = () => { const handleClick = () => {
hideSideBar.value = !hideSideBar.value hideSideBar.value = !hideSideBar.value
} }
// 重置选中 key
const setCurrentKey = (key) => {
treeRef.value.setCurrentKey(key)
queryParams.searchKey = ''
}
defineExpose({
setCurrentKey
})
</script> </script>
<style scoped <style scoped
......
...@@ -14,7 +14,6 @@ export function useDict(...args) { ...@@ -14,7 +14,6 @@ export function useDict(...args) {
res.value[dictType] = dicts; res.value[dictType] = dicts;
} else { } else {
getDicts(dictType).then(resp => { getDicts(dictType).then(resp => {
console.log('字典数据', resp.data)
res.value[dictType] = resp.data.map(p => ({ label: p.dictLabel, value: p.dictValue, elTagType: p.listClass, elTagClass: p.cssClass })) res.value[dictType] = resp.data.map(p => ({ label: p.dictLabel, value: p.dictValue, elTagType: p.listClass, elTagClass: p.cssClass }))
useDictStore().setDict(dictType, res.value[dictType]); useDictStore().setDict(dictType, res.value[dictType]);
}) })
......
...@@ -18,7 +18,6 @@ if (route.fullPath.includes(reportViewURL.substring(1)) || route.fullPath.includ ...@@ -18,7 +18,6 @@ if (route.fullPath.includes(reportViewURL.substring(1)) || route.fullPath.includ
} else { } else {
openUrl += `?${queryStr}` openUrl += `?${queryStr}`
} }
console.log(openUrl)
</script> </script>
<style scoped <style scoped
......
...@@ -294,7 +294,6 @@ ...@@ -294,7 +294,6 @@
reportId: obj.id, reportId: obj.id,
pageSize: 100 pageSize: 100
}) })
console.log('查询到', res)
selUserList.value = res.data || [] selUserList.value = res.data || []
showSelUser.value = true showSelUser.value = true
if (obj.id) { if (obj.id) {
...@@ -341,8 +340,6 @@ ...@@ -341,8 +340,6 @@
selUserList.value.splice(index, 1) selUserList.value.splice(index, 1)
} }
} }
console.log(selUserList.value.map(o => o.userId), '当前')
} }
// 全选反选用户 // 全选反选用户
const handleSelectAll = (selection) => { const handleSelectAll = (selection) => {
...@@ -364,7 +361,6 @@ ...@@ -364,7 +361,6 @@
}) })
} }
console.log(selUserList.value, '当前')
} }
// 确定分配给用户 // 确定分配给用户
......
...@@ -297,7 +297,6 @@ const submitForm = async () => { ...@@ -297,7 +297,6 @@ const submitForm = async () => {
formData.fileList = [] formData.fileList = []
proxy.$refs.formRef.resetFields() proxy.$refs.formRef.resetFields()
} else { } else {
console.log('校验失败')
} }
}) })
} }
......
...@@ -176,7 +176,6 @@ async function loginByType(type, data) { ...@@ -176,7 +176,6 @@ async function loginByType(type, data) {
router.push({ path: redirect.value || "/", query: param2Obj(redirect.value) }); router.push({ path: redirect.value || "/", query: param2Obj(redirect.value) });
} }
}).catch((err) => { }).catch((err) => {
console.log(err)
accountPassLoading.value = false; accountPassLoading.value = false;
autoLoginLoading.value = false; autoLoginLoading.value = false;
}) })
......
...@@ -114,7 +114,6 @@ const supportedTypes = computed(() => { ...@@ -114,7 +114,6 @@ const supportedTypes = computed(() => {
if (getMobileType() === 'ios') { if (getMobileType() === 'ios') {
return 'image/*,video/*' return 'image/*,video/*'
} else { } else {
console.log('anzhuo2')
if (selectedMediaType.value === 'image') { if (selectedMediaType.value === 'image') {
return 'image/*' return 'image/*'
} else { } else {
...@@ -136,7 +135,6 @@ const customUploadClick = () => { ...@@ -136,7 +135,6 @@ const customUploadClick = () => {
}) })
} else { } else {
// 安卓设备:显示拍照/录像方式确认菜单 // 安卓设备:显示拍照/录像方式确认菜单
console.log('anzhuo1')
show.value = true show.value = true
} }
} }
......
...@@ -325,7 +325,6 @@ const handlePriceChange = async () => { ...@@ -325,7 +325,6 @@ const handlePriceChange = async () => {
} }
// 口味生产日期设置 // 口味生产日期设置
const handleTasteChange = async (index) => { const handleTasteChange = async (index) => {
console.log(selectedTypeObj.value)
const prop = typeMap[selectedTypeObj.value.label].tasteDateKey const prop = typeMap[selectedTypeObj.value.label].tasteDateKey
await createInspectionTaskDetailAPI({ await createInspectionTaskDetailAPI({
taskDetail: { taskDetail: {
......
...@@ -97,7 +97,6 @@ const finished = ref(true); ...@@ -97,7 +97,6 @@ const finished = ref(true);
const refreshLoading = ref(false) const refreshLoading = ref(false)
const getInspectionTaskListFn = async () => { const getInspectionTaskListFn = async () => {
const res = await getInspectionTaskListAPI(query) const res = await getInspectionTaskListAPI(query)
console.log(res, 'res')
resultList.value = [...resultList.value, ...res.data.rows] resultList.value = [...resultList.value, ...res.data.rows]
finished.value = res.data.total <= resultList.value.length finished.value = res.data.total <= resultList.value.length
} }
...@@ -154,13 +153,11 @@ const handleClickStore = (item) => { ...@@ -154,13 +153,11 @@ const handleClickStore = (item) => {
const search = () => { const search = () => {
query.pageNum = 1 query.pageNum = 1
resultList.value = [] resultList.value = []
console.log('zoulema')
getInspectionTaskListFn() getInspectionTaskListFn()
} }
// 删除任务 // 删除任务
const deleteFn = async (item, index) => { const deleteFn = async (item, index) => {
// console.log(item)
// await deleteInspectionTaskAPI({ // await deleteInspectionTaskAPI({
// rstdId: item.rstId // rstdId: item.rstId
// }) // })
......
...@@ -283,7 +283,6 @@ const errorTemWlSctMessage = ref('') ...@@ -283,7 +283,6 @@ const errorTemWlSctMessage = ref('')
const errorPrdClassMessage = ref('') const errorPrdClassMessage = ref('')
// 校验午休结束时间 // 校验午休结束时间
const validatorNoonInTime = (value, obj) => { const validatorNoonInTime = (value, obj) => {
console.log(form.noonOutTime.length > 0, '午休结束判断该')
if (form.noonOutTime.length > 0) { if (form.noonOutTime.length > 0) {
if (!value) { if (!value) {
errorNoonInTimeMessage.value = '请选择午休结束时间' errorNoonInTimeMessage.value = '请选择午休结束时间'
......
...@@ -106,7 +106,6 @@ const showSearch = ref(false) ...@@ -106,7 +106,6 @@ const showSearch = ref(false)
// 从新增页面跳转回来需要刷新列表 // 从新增页面跳转回来需要刷新列表
watch(() => route.path, (newPath, oldPath) => { watch(() => route.path, (newPath, oldPath) => {
if (oldPath.includes('/promotion_plan_editing') && newPath === '/promotion_plan') { if (oldPath.includes('/promotion_plan_editing') && newPath === '/promotion_plan') {
console.log('刷新页面?')
planSearch.value.resetFn() planSearch.value.resetFn()
} }
}); });
......
...@@ -1054,7 +1054,6 @@ ...@@ -1054,7 +1054,6 @@
// 关联的公式计算列,需要特殊处理 // 关联的公式计算列,需要特殊处理
for (const str of col.requestKey) { for (const str of col.requestKey) {
const obj = tableColumns.value.find(item => item.prop == str) const obj = tableColumns.value.find(item => item.prop == str)
console.log(obj, str, 'y')
if (obj.type === 'formula') { if (obj.type === 'formula') {
obj.func(row) obj.func(row)
} }
......
...@@ -762,7 +762,6 @@ ...@@ -762,7 +762,6 @@
// 关联的公式计算列,需要特殊处理 // 关联的公式计算列,需要特殊处理
for (const str of col.requestKey) { for (const str of col.requestKey) {
const obj = tableColumns.value.find(item => item.prop === str) const obj = tableColumns.value.find(item => item.prop === str)
console.log('obj', obj)
if (obj.type === 'formula') { if (obj.type === 'formula') {
obj.func(row) obj.func(row)
} }
......
...@@ -498,7 +498,6 @@ ...@@ -498,7 +498,6 @@
// 关联的公式计算列,需要特殊处理 // 关联的公式计算列,需要特殊处理
for (const str of col.requestKey) { for (const str of col.requestKey) {
const obj = tableColumns.value.find(item => item.prop === str) const obj = tableColumns.value.find(item => item.prop === str)
console.log('obj', obj)
if (obj.type === 'formula') { if (obj.type === 'formula') {
obj.func(row) obj.func(row)
} }
......
...@@ -254,7 +254,6 @@ const columns = ref([ ...@@ -254,7 +254,6 @@ const columns = ref([
// return 0 // return 0
// } // }
// })) // }))
// console.log(maxPhotos, 'maxphotos')
// // 计算需要的列数,每列最多2张图片 // // 计算需要的列数,每列最多2张图片
// const columns = Math.ceil(maxPhotos / 2) // const columns = Math.ceil(maxPhotos / 2)
// if (columns === 0) return 200 // if (columns === 0) return 200
...@@ -359,7 +358,6 @@ getLogisticsReceiptList() ...@@ -359,7 +358,6 @@ getLogisticsReceiptList()
// 查看物流轨迹 // 查看物流轨迹
const handleLogisticsTrack = (row) => { const handleLogisticsTrack = (row) => {
const obj = logisticsTrack.value.find(item => item.code.includes(row.transport * 1)) const obj = logisticsTrack.value.find(item => item.code.includes(row.transport * 1))
console.log(obj)
if (isExternal(obj?.url)) { if (isExternal(obj?.url)) {
window.open(obj.url + row[obj.dataKey], '_blank') window.open(obj.url + row[obj.dataKey], '_blank')
} else { } else {
......
...@@ -3,12 +3,13 @@ ...@@ -3,12 +3,13 @@
<el-row :gutter="20" <el-row :gutter="20"
class="container"> class="container">
<!--部门数据--> <!--部门数据-->
<category-tree :options="deptOptions" <category-tree ref="deptTreeRef"
:defaultProps="{ label: 'label', children: 'children' }" :options="deptOptions"
:defaultProps="defaultProps"
node-key="id" node-key="id"
placeholder="搜索部门名称" placeholder="搜索部门名称"
:defaultExpandList="defaultExpandedKeys" :defaultExpandList="defaultExpandedKeys"
:colSpan="4" :colSpan="categoryTreeColSpan"
@search="handleNodeClick"> @search="handleNodeClick">
</category-tree> </category-tree>
<!--用户数据--> <!--用户数据-->
...@@ -118,7 +119,8 @@ ...@@ -118,7 +119,8 @@
</el-row> </el-row>
<el-table v-loading="loading" <el-table v-loading="loading"
:data="userList"> :data="userList"
@selection-change="handleSelectionChange">
<el-table-column type="selection" <el-table-column type="selection"
width="50" /> width="50" />
<el-table-column label="用户编号" <el-table-column label="用户编号"
...@@ -215,7 +217,6 @@ ...@@ -215,7 +217,6 @@
@pagination="getList" /> @pagination="getList" />
</el-col> </el-col>
</el-row> </el-row>
<!-- 添加或修改用户配置对话框 --> <!-- 添加或修改用户配置对话框 -->
<el-dialog :title="title" <el-dialog :title="title"
v-model="open" v-model="open"
...@@ -233,7 +234,8 @@ ...@@ -233,7 +234,8 @@
prop="userName"> prop="userName">
<el-input v-model="form.userName" <el-input v-model="form.userName"
placeholder="只能小写字母数字组成" placeholder="只能小写字母数字组成"
maxlength="30" /> maxlength="30"
clearable />
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
...@@ -244,7 +246,8 @@ ...@@ -244,7 +246,8 @@
placeholder="请输入密码" placeholder="请输入密码"
type="password" type="password"
maxlength="20" maxlength="20"
show-password /> show-password
clearable />
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
...@@ -396,7 +399,6 @@ ...@@ -396,7 +399,6 @@
</div> </div>
</template> </template>
</el-dialog> </el-dialog>
<!-- 用户导入对话框 --> <!-- 用户导入对话框 -->
<el-dialog :title="upload.title" <el-dialog :title="upload.title"
v-model="upload.open" v-model="upload.open"
...@@ -442,113 +444,76 @@ ...@@ -442,113 +444,76 @@
<script setup <script setup
name="User"> name="User">
import { getToken } from "@/utils/auth"; import { getToken } from "@/utils/auth";
import useAppStore from '@/store/modules/app'
import { changeUserStatus, listUser, resetUserPwd, delUser, getUser, updateUser, addUser, deptTreeSelectList, getProCityAPI, openPromotionSystemAPI } from "@/api"; import { changeUserStatus, listUser, resetUserPwd, delUser, getUser, updateUser, addUser, deptTreeSelectList, getProCityAPI, openPromotionSystemAPI } from "@/api";
const router = useRouter(); const router = useRouter();
const appStore = useAppStore()
const { proxy } = getCurrentInstance(); const { proxy } = getCurrentInstance();
const { sys_normal_disable, sys_user_sex } = proxy.useDict("sys_normal_disable", "sys_user_sex"); const { sys_normal_disable, sys_user_sex } = proxy.useDict("sys_normal_disable", "sys_user_sex");
const userList = ref([]); /*************** 部门数据 ***************/
const open = ref(false); const deptOptions = ref([]); // 部门数据
const loading = ref(true); const defaultProps = ref({ // 树结构属性
const showSearch = ref(true); label: 'label',
const ids = ref([]); children: 'children'
const single = ref(true); })
const multiple = ref(true); const deptTreeRef = ref(null) // 部门数据组件
const total = ref(0); const defaultExpandedKeys = ref([]) // 默认展开树节点
const title = ref(""); const categoryTreeColSpan = ref(4) // 树组件宽度
const dateRange = ref([]);
const deptName = ref("");
const deptOptions = ref(undefined);
const enabledDeptOptions = ref(undefined);
const initPassword = ref(undefined);
const postOptions = ref([]);
const roleOptions = ref([]);
const defaultExpandedKeys = ref([])
/*** 用户导入参数 */
const upload = reactive({
// 是否显示弹出层(用户导入)
open: false,
// 弹出层标题(用户导入)
title: "",
// 是否禁用上传
isUploading: false,
// 是否更新已经存在的用户数据
updateSupport: 0,
// 设置上传的请求头部
headers: { Authorization: "Bearer " + getToken() },
// 上传的地址
url: import.meta.env.VITE_APP_BASE_API + "/system/user/importData"
});
// 列显隐信息
const columns = ref([
{ key: 0, label: `用户编号`, visible: true },
{ key: 1, label: `用户名称`, visible: true },
{ key: 2, label: `用户昵称`, visible: true },
{ key: 3, label: `部门`, visible: true },
{ key: 4, label: `手机号码`, visible: true },
{ key: 5, label: `状态`, visible: true },
{ key: 6, label: `创建时间`, visible: true }
]);
const data = reactive({
form: {},
queryParams: {
pageNum: 1,
pageSize: 10,
userName: undefined,
phonenumber: undefined,
status: undefined,
deptId: undefined
},
rules: {
userName: [{ required: true, message: "用户名称不能为空", trigger: "blur" }, { min: 2, max: 20, message: "用户名称长度必须介于 2 和 20 之间", trigger: "blur" },
{ pattern: /^[a-z0-9]+$/, message: "只能小写字母数字组成", trigger: "blur" }],
nickName: [{ required: true, message: "用户昵称不能为空", trigger: "blur" }],
password: [{ required: true, message: "用户密码不能为空", trigger: "blur" }, { min: 5, max: 20, message: "用户密码长度必须介于 5 和 20 之间", trigger: "blur" }, { pattern: /^[^<>"'|\\]+$/, message: "不能包含非法字符:< > \" ' \\\ |", trigger: "blur" }],
email: [{ type: "email", message: "请输入正确的邮箱地址", trigger: ["blur", "change"] }],
phonenumber: [{ pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/, message: "请输入正确的手机号码", trigger: "blur" }],
postId: [{ required: true, message: "请选择岗位", trigger: "change" }],
roleIds: [{ required: true, message: "请选择角色", trigger: "change" }],
privilegeId: [{ required: true, message: "请选择促销角色", trigger: "change" }]
}
});
const { queryParams, form, rules } = toRefs(data);
/** 通过条件过滤节点 */ // 部门树节点单击事件
const filterNode = (value, data) => { function handleNodeClick(data) {
if (!value) return true; queryParams.value.deptId = data ? data.id : '';
return data.label.indexOf(value) !== -1; handleQuery(); // 搜索用户列表
}; };
/** 根据名称筛选部门树 */ /*************** 新增/编辑用户弹窗 ***************/
watch(deptName, val => { const open = ref(false) // 添加或编辑用户弹出层,开启状态
proxy.$refs["deptTreeRef"].filter(val); const title = ref("") // 弹窗标题
}); const enabledDeptOptions = ref(undefined) // 部门树结构
const initPassword = ref(undefined) // 默认初始密码
/** 查询用户列表 */ const postOptions = ref([]) // 岗位数据列表
function getList() { const roleOptions = ref([]) // 角色数据列表
loading.value = true; const provinceList = ref([]) // 工作地点
listUser(proxy.addDateRange(queryParams.value, dateRange.value)).then(res => { const props = { // 工作地点树形结构
loading.value = false; lazy: true,
userList.value = res.data.rows; async lazyLoad(node, resolve) {
total.value = res.data.total; const res = await getProCityList(node.value)
}); const nodes = res.data.map(o => {
}; return {
value: o.num,
label: o.name,
leaf: true
}
})
resolve(nodes)
}
}
/** 查询部门下拉树结构 */ // 查询部门下拉树结构
function getDeptTree() { function getDeptTree() {
deptTreeSelectList().then(response => { deptTreeSelectList().then(response => {
deptOptions.value = response.data; deptOptions.value = response.data;
enabledDeptOptions.value = filterDisabledDept(JSON.parse(JSON.stringify(response.data))); enabledDeptOptions.value = filterDisabledDept(JSON.parse(JSON.stringify(response.data)));
defaultExpandedKeys.value = [response.data[0].id]; defaultExpandedKeys.value = [response.data[0].id];
}); });
}; }
getDeptTree() // 初始化部门下拉树结构
/** 过滤禁用的部门 */ // 获取省市列表
const getProCityList = async (provinceId) => {
return await getProCityAPI({ provinceId })
}
// 初始化省份列表
const initProvinceList = async () => {
const res = await getProCityList()
provinceList.value = res.data.map(obj => {
return {
value: obj.num,
label: obj.name,
}
})
}
initProvinceList()
// 过滤禁用的部门
function filterDisabledDept(deptList) { function filterDisabledDept(deptList) {
return deptList.filter(dept => { return deptList.filter(dept => {
if (dept.disabled) { if (dept.disabled) {
...@@ -560,137 +525,19 @@ ...@@ -560,137 +525,19 @@
return true; return true;
}); });
}; };
// 新增按钮操作
function handleAdd() {
reset();
getUser().then(response => {
postOptions.value = response.posts;
roleOptions.value = response.roles;
open.value = true; // 打开弹窗
/** 节点单击事件 */ title.value = "添加用户";
function handleNodeClick(data) { form.value.password = initPassword.value;
queryParams.value.deptId = data ? data.id : ''; })
handleQuery();
};
/** 搜索按钮操作 */
function handleQuery() {
queryParams.value.pageNum = 1;
getList();
};
/** 重置按钮操作 */
function resetQuery() {
dateRange.value = [];
proxy.resetForm("queryRef");
queryParams.value.deptId = undefined;
proxy.$refs.deptTreeRef.setCurrentKey(null);
handleQuery();
};
/** 删除按钮操作 */
function handleDelete(row) {
const userIds = row.userId || ids.value;
proxy.$modal.confirm('是否确认删除用户编号为"' + userIds + '"的数据项?').then(function () {
return delUser(userIds);
}).then(() => {
getList();
proxy.$modal.msgSuccess("删除成功");
}).catch(() => { });
};
/** 导出按钮操作 */
function handleExport() {
proxy.download("system/user/export", {
...queryParams.value,
}, `user_${new Date().getTime()}.xlsx`);
};
/** 用户状态修改 */
function handleStatusChange(row) {
let text = row.status === "0" ? "启用" : "停用";
proxy.$modal.confirm('确认要"' + text + '""' + row.userName + '"用户吗?').then(function () {
return changeUserStatus(row.userId, row.status);
}).then(() => {
proxy.$modal.msgSuccess(text + "成功");
}).catch(function () {
row.status = row.status === "0" ? "1" : "0";
});
};
/** 更多操作 */
function handleCommand(command, row) {
switch (command) {
case "handleResetPwd":
handleResetPwd(row);
break;
case "handleAuthRole":
handleAuthRole(row);
break;
default:
break;
}
};
/** 跳转角色分配 */
function handleAuthRole(row) {
const userId = row.userId;
router.push("/system/user-auth/role/" + userId);
};
/** 重置密码按钮操作 */
function handleResetPwd(row) {
proxy.$prompt('请输入"' + row.userName + '"的新密码', "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
closeOnClickModal: false,
inputPattern: /^.{5,20}$/,
inputErrorMessage: "用户密码长度必须介于 5 和 20 之间",
inputValidator: (value) => {
if (/<|>|"|'|\||\\/.test(value)) {
return "不能包含非法字符:< > \" ' \\\ |"
} }
}, // 重置操作表单
}).then(({ value }) => {
resetUserPwd(row.userId, value).then(response => {
proxy.$modal.msgSuccess("修改成功,新密码是:" + value);
});
}).catch(() => { });
};
/** 选择条数 */
function handleSelectionChange(selection) {
ids.value = selection.map(item => item.userId);
single.value = selection.length != 1;
multiple.value = !selection.length;
};
/** 导入按钮操作 */
function handleImport() {
upload.title = "用户导入";
upload.open = true;
};
/** 下载模板操作 */
function importTemplate() {
proxy.download("system/user/importTemplate", {
}, `user_template_${new Date().getTime()}.xlsx`);
};
/**文件上传中处理 */
const handleFileUploadProgress = (event, file, fileList) => {
upload.isUploading = true;
};
/** 文件上传成功处理 */
const handleFileSuccess = (response, file, fileList) => {
upload.open = false;
upload.isUploading = false;
proxy.$refs["uploadRef"].handleRemove(file);
proxy.$alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.msg + "</div>", "导入结果", { dangerouslyUseHTMLString: true });
getList();
};
/** 提交上传文件 */
function submitFileForm() {
proxy.$refs["uploadRef"].submit();
};
/** 重置操作表单 */
function reset() { function reset() {
form.value = { form.value = {
userId: undefined, userId: undefined,
...@@ -706,32 +553,176 @@ ...@@ -706,32 +553,176 @@
postId: null, postId: null,
roleIds: [], roleIds: [],
proStatus: false, // 促销权限 proStatus: false, // 促销权限
privilegeId: undefined, privilegeId: null, // 1 城市经理,2 职能角色
workCityList: [] // 工作城市 workCityList: [] // 工作城市
}; };
proxy.resetForm("userRef"); proxy.resetForm("userRef");
}; }
// 取消按钮
/** 取消按钮 */
function cancel() { function cancel() {
open.value = false; open.value = false;
reset(); reset();
}; }
// 提交按钮
function submitForm() {
proxy.$refs["userRef"].validate(async valid => {
if (valid) {
// 城市列表转城市参数
form.value.workProvinceNum = form.value.workCityList && form.value.workCityList[0]
form.value.workCityNum = form.value.workCityList && form.value.workCityList[1]
// 促销开关 true 转 0,false 转 1
form.value.proStatus = form.value.proStatus == true ? 0 : 1
// 根据用户 userId 决定走更新/新增用户接口
await form.value.userId ? updateUser(form.value) : addUser(form.value)
proxy.$modal.msgSuccess(`${form.value.userId ? '修改' : '新增'}用户成功`)
open.value = false
queryParams.value.pageNum = 1
getList()
// 如果当前是新增状态,促销员权限开启了则同步
// 如果当前是更新状态,无论是否开启促销权限,都需要同步更新促销角色权限
if ((!form.value.userId && form.value.proStatus === 0) || (form.value.userId && form.value.privilegeId)) {
await openPromotionSystemAPI({
loginName: form.value.userName,
privilegeId: form.value.privilegeId,
status: form.value.proStatus // 1 关闭 0 开启
})
}
/** 新增按钮操作 */ reset()
function handleAdd() { }
reset(); })
getUser().then(response => { }
postOptions.value = response.posts;
roleOptions.value = response.roles;
open.value = true;
title.value = "添加用户"; /*************** 导入导出用户列表 ***************/
form.value.password = initPassword.value; // 用户导入参数
const upload = reactive({
open: false, // 是否显示弹出层(用户导入)
title: "", // 弹出层标题(用户导入)
isUploading: false, // 是否禁用上传
updateSupport: 0, // 是否更新已经存在的用户数据
headers: { Authorization: "Bearer " + getToken() }, // 设置上传的请求头部
url: import.meta.env.VITE_APP_BASE_API + "/system/user/importData" // 上传的地址
}) })
// 导入按钮操作
function handleImport() {
upload.title = "用户导入";
upload.open = true;
}
// 导入-文件上传中处理
const handleFileUploadProgress = (event, file, fileList) => {
upload.isUploading = true;
}
// 导入-文件上传成功处理
const handleFileSuccess = (response, file, fileList) => {
upload.open = false;
upload.isUploading = false;
proxy.$refs["uploadRef"].handleRemove(file);
proxy.$alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.msg + "</div>", "导入结果", { dangerouslyUseHTMLString: true });
getList();
}
// 导入-提交上传文件
function submitFileForm() {
proxy.$refs["uploadRef"].submit();
};
// 导出模板操作
function importTemplate() {
proxy.download("system/user/importTemplate", {
fileName: "用户导入模板.xlsx"
});
}
// 导出按钮操作(导出用户列表表格)
function handleExport() {
proxy.download("system/user/export", {
...queryParams.value,
}, `user_${new Date().getTime()}.xlsx`);
} }
/** 修改按钮操作 */ /*************** 用户数据 ***************/
const data = reactive({
form: {},
queryParams: {
pageNum: 1,
pageSize: 10,
userName: undefined,
phonenumber: undefined,
status: undefined,
deptId: undefined
},
rules: {
userName: [{ required: true, message: "用户名称不能为空", trigger: "blur" }, { min: 2, max: 20, message: "用户名称长度必须介于 2 和 20 之间", trigger: "blur" },
{ pattern: /^[a-z0-9]+$/, message: "只能小写字母数字组成", trigger: "blur" }],
nickName: [{ required: true, message: "用户昵称不能为空", trigger: "blur" }],
password: [{ required: true, message: "用户密码不能为空", trigger: "blur" }, { min: 5, max: 20, message: "用户密码长度必须介于 5 和 20 之间", trigger: "blur" }, { pattern: /^[^<>"'|\\]+$/, message: "不能包含非法字符:< > \" ' \\\ |", trigger: "blur" }],
email: [{ type: "email", message: "请输入正确的邮箱地址", trigger: ["blur", "change"] }],
phonenumber: [{ pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/, message: "请输入正确的手机号码", trigger: "blur" }],
postId: [{ required: true, message: "请选择岗位", trigger: "change" }],
roleIds: [{ required: true, message: "请选择角色", trigger: "change" }],
privilegeId: [{ required: true, message: "请选择促销角色", trigger: "change" }]
}
})
const { queryParams, form, rules } = toRefs(data)
const dateRange = ref([]) // 搜索-创建时间
const showSearch = ref(true)
const userList = ref([])
const loading = ref(true)
const ids = ref([]) // 表格复选框选中的用户 ID 们
const single = ref(true) // 复选框是否只选了一个
const multiple = ref(true) // 复选框是否有勾选
const total = ref(0)
// 搜索按钮操作
function handleQuery() {
queryParams.value.pageNum = 1
getList();
}
// 重置搜索条件
function resetQuery() {
dateRange.value = [] // 创建时间置空
proxy.resetForm("queryRef")
queryParams.value.deptId = undefined // 部门搜索置空
console.log(deptTreeRef.value)
deptTreeRef.value.setCurrentKey(null)
handleQuery()
}
// 表格-列表数据
function getList() {
loading.value = true
listUser(proxy.addDateRange(queryParams.value, dateRange.value)).then(res => {
loading.value = false
userList.value = res.data.rows
total.value = res.data.total
})
}
getList()
// 表格-复选框选中(单选/全选)
function handleSelectionChange(selection) {
ids.value = selection.map(item => item.userId)
single.value = selection.length != 1
multiple.value = !selection.length
}
// 列显隐信息
const columns = ref([
{ key: 0, label: `用户编号`, visible: true },
{ key: 1, label: `用户工号`, visible: true },
{ key: 2, label: `用户昵称`, visible: true },
{ key: 3, label: `部门`, visible: true },
{ key: 4, label: `手机号码`, visible: true },
{ key: 5, label: `状态`, visible: true },
{ key: 6, label: `创建时间`, visible: true }
])
// 用户状态修改
function handleStatusChange(row) {
let text = row.status === "0" ? "启用" : "停用";
proxy.$modal.confirm('确认要"' + text + '""' + row.userName + '"用户吗?').then(function () {
return changeUserStatus(row.userId, row.status);
}).then(() => {
proxy.$modal.msgSuccess(text + "成功");
}).catch(function () {
row.status = row.status === "0" ? "1" : "0";
});
};
// 修改按钮操作
function handleUpdate(row) { function handleUpdate(row) {
reset(); reset();
const userId = row.userId || ids.value; const userId = row.userId || ids.value;
...@@ -749,7 +740,7 @@ ...@@ -749,7 +740,7 @@
}) })
response.data.workCityList = [response.data.workProvinceNum, response.data.workCityNum] response.data.workCityList = [response.data.workProvinceNum, response.data.workCityNum]
} }
// 促销权限 0 开 1 关 // 促销权限 0 开 1 关,同步成 true false
response.data.proStatus = response.data.proStatus == 1 || response.data.proStatus == undefined ? false : true; response.data.proStatus = response.data.proStatus == 1 || response.data.proStatus == undefined ? false : true;
// 后台空角色不知道为啥返回 0 不是 null // 后台空角色不知道为啥返回 0 不是 null
// response.data.roleIds = response.data.roleId == 0 ? [] : response.data.roleId; // response.data.roleIds = response.data.roleId == 0 ? [] : response.data.roleId;
...@@ -760,72 +751,41 @@ ...@@ -760,72 +751,41 @@
title.value = "修改用户"; title.value = "修改用户";
form.password = ""; form.password = "";
}); });
};
/** 提交按钮 */
function submitForm() {
proxy.$refs["userRef"].validate(async valid => {
if (valid) {
// 城市列表转城市参数
form.value.workProvinceNum = form.value.workCityList && form.value.workCityList[0]
form.value.workCityNum = form.value.workCityList && form.value.workCityList[1]
// 促销开关 true 转 0,false 转 1
form.value.proStatus = form.value.proStatus == true ? 0 : 1;
await form.value.userId ? updateUser(form.value) : addUser(form.value);
proxy.$modal.msgSuccess(`${form.value.userId ? '修改' : '新增'}用户成功`);
open.value = false;
getList();
// 同步促销角色权限,给另外一个系统
if (form.value.privilegeId === null) return
await openPromotionSystemAPI({
loginName: form.value.userName,
privilegeId: form.value.privilegeId,
status: form.value.proStatus
})
reset()
} }
}); // 删除按钮操作
}; function handleDelete(row) {
const userIds = row.userId || ids.value;
getDeptTree(); proxy.$modal.confirm('是否确认删除用户编号为"' + userIds + '"的数据项?').then(function () {
return delUser(userIds);
}).then(() => {
getList(); getList();
proxy.$modal.msgSuccess("删除成功");
// 工作地点 }).catch(() => { });
const provinceList = ref([]) };
// 重置密码按钮操作
const props = { function handleResetPwd(row) {
// multiple: true, proxy.$prompt('请输入"' + row.userName + '"的新密码', "提示", {
lazy: true, confirmButtonText: "确定",
async lazyLoad(node, resolve) { cancelButtonText: "取消",
const res = await getProCityList(node.value) closeOnClickModal: false,
const nodes = res.data.map(o => { inputPattern: /^.{5,20}$/,
return { inputErrorMessage: "用户密码长度必须介于 5 和 20 之间",
value: o.num, inputValidator: (value) => {
label: o.name, if (/<|>|"|'|\||\\/.test(value)) {
leaf: true return "不能包含非法字符:< > \" ' \\\ |"
} }
})
resolve(nodes)
}, },
}).then(({ value }) => {
resetUserPwd(row.userId, value).then(response => {
proxy.$modal.msgSuccess("修改成功,新密码是:" + value);
});
}).catch(() => { });
};
// 跳转角色分配
function handleAuthRole(row) {
const userId = row.userId;
router.push("/system/user-auth/role/" + userId);
} }
const getProCityList = async (provinceId) => {
return await getProCityAPI({ provinceId })
}
const initProvinceList = async () => {
const res = await getProCityList()
provinceList.value = res.data.map(obj => {
return {
value: obj.num,
label: obj.name,
}
})
}
initProvinceList()
</script> </script>
<style scoped <style scoped
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论