<template>
|
<view class="client-visit-detail">
|
<PageHeader :title="detailType === 1 ? '发布制度' : '制度详情'"
|
@back="goBack" />
|
<u-form ref="formRef"
|
label-width="90">
|
<!-- 客户信息 -->
|
<!-- <u-cell-group title="知识信息"> -->
|
<u-form-item label="制度编号"
|
prop="regulationNum"
|
required
|
border-bottom>
|
<u-input v-model="form.regulationNum"
|
:readonly="readonly"
|
placeholder="请输入制度编号" />
|
</u-form-item>
|
<u-form-item label="制度标题"
|
prop="title"
|
required
|
border-bottom>
|
<u-input v-model="form.title"
|
:readonly="readonly"
|
placeholder="请输入制度标题" />
|
</u-form-item>
|
<u-form-item label="制度分类"
|
prop="type"
|
required
|
border-bottom>
|
<u-input v-model="equipmentname"
|
readonly
|
placeholder="请选择制度分类"
|
@click="showEquipmentSheet = true" />
|
<template v-if="!readonly"
|
#right>
|
<up-icon name="arrow-right"
|
@click="openEquipmentSheet"></up-icon>
|
</template>
|
</u-form-item>
|
<u-form-item label="制度内容"
|
prop="scenario"
|
required
|
border-bottom>
|
<u-textarea v-model="form.content"
|
type="textarea"
|
rows="4"
|
:disabled="readonly"
|
placeholder="请输入制度内容" />
|
</u-form-item>
|
<u-form-item label="制度版本"
|
prop="title"
|
border-bottom>
|
<u-input v-model="form.version"
|
:readonly="readonly"
|
placeholder="请输入制度版本" />
|
</u-form-item>
|
<u-form-item label="生效时间"
|
prop="status"
|
required
|
border-bottom>
|
<u-input v-model="form.effectiveTime"
|
readonly
|
placeholder="请选择生效时间"
|
@click="showEffectiveTimeSheet = true" />
|
<template v-if="!readonly"
|
#right>
|
<up-icon name="arrow-right"
|
@click="showEffectiveTimeSheet = true"></up-icon>
|
</template>
|
</u-form-item>
|
<u-form-item label="适用范围"
|
required
|
prop="remark"
|
border-bottom>
|
<up-checkbox-group v-model="form.scope"
|
:disabled="readonly"
|
placement="column"
|
@change="checkboxChange">
|
<up-checkbox :customStyle="{marginBottom: '8px'}"
|
v-for="(item, index) in checkboxList1"
|
:key="index"
|
:label="item.name"
|
:name="item.value">
|
</up-checkbox>
|
</up-checkbox-group>
|
</u-form-item>
|
<u-form-item label="需要确认"
|
prop="solution"
|
border-bottom>
|
<up-switch :disabled="readonly"
|
v-model="form.requireConfirm"></up-switch>
|
</u-form-item>
|
<!-- </u-cell-group> -->
|
<!-- 提交按钮 -->
|
<view v-if="!readonly"
|
class="footer-btns">
|
<u-button class="cancel-btn"
|
@click="goBack">取消</u-button>
|
<u-button class="sign-btn"
|
type="primary"
|
@click="handleSubmit"
|
:loading="loading">保存</u-button>
|
</view>
|
</u-form>
|
<!-- 设备配置选择器 -->
|
<up-action-sheet :show="showEquipmentSheet"
|
:actions="equipmentOptions"
|
@select="handleEquipmentChange"
|
@close="showEquipmentSheet = false" />
|
<!-- 状态选择器 -->
|
<up-action-sheet :show="showStatusSheet"
|
:actions="statusOptions"
|
@select="onStatusSelect"
|
@close="showStatusSheet = false" />
|
<up-datetime-picker :show="showEffectiveTimeSheet"
|
@confirm="handleEffectiveTimeConfirm"
|
@cancel="showEffectiveTimeSheet = false"
|
v-model="effectiveTime"
|
mode="datetime"></up-datetime-picker>
|
</view>
|
</template>
|
|
<script setup>
|
// 替换 toast 方法
|
defineOptions({ name: "meeting-settings-detail" });
|
const showToast = message => {
|
uni.showToast({
|
title: message,
|
icon: "none",
|
});
|
};
|
|
import { ref, onMounted, computed } from "vue";
|
import PageHeader from "@/components/PageHeader.vue";
|
import useUserStore from "@/store/modules/user";
|
import { onLoad } from "@dcloudio/uni-app";
|
import {
|
addRuleManagement,
|
updateRuleManagement,
|
} from "@/api/managementMeetings/rulesRegulationsManagement";
|
import dayjs from "dayjs";
|
const userStore = useUserStore();
|
const showEffectiveTimeSheet = ref(false);
|
const effectiveTime = ref(new Date());
|
// 表单数据
|
const form = ref({
|
id: "",
|
regulationNum: "",
|
title: "",
|
category: "",
|
content: "",
|
version: "",
|
status: "active",
|
readCount: 0,
|
effectiveTime: "",
|
scope: [],
|
requireConfirm: false,
|
});
|
const checkboxList1 = ref([
|
{ name: "全体员工", value: "all" },
|
{ name: "管理层", value: "manager" },
|
{ name: "人事部门", value: "hr" },
|
{ name: "财务部门", value: "finance" },
|
{ name: "技术部门", value: "tech" },
|
]);
|
const equipmentOptions = ref([
|
{ value: "hr", name: "人事制度" },
|
{ value: "finance", name: "财务制度" },
|
{ value: "safety", name: "安全制度" },
|
{ value: "tech", name: "技术制度" },
|
]);
|
const statusOptions = ref([
|
{ value: "high", name: "显著提升" },
|
{ value: "medium", name: "一般提升" },
|
{ value: "low", name: "轻微提升" },
|
]);
|
//// 页面状态
|
const loading = ref(false);
|
const formRef = ref(null);
|
const showEquipmentSheet = ref(false);
|
const showStatusSheet = ref(false);
|
const openEquipmentSheet = () => {
|
showEquipmentSheet.value = true;
|
};
|
// 返回上一页
|
const goBack = () => {
|
uni.navigateBack();
|
};
|
const statusname = ref("");
|
// 状态选择
|
const onStatusSelect = action => {
|
form.value.efficiency = action.value;
|
statusname.value = action.name;
|
showStatusSheet.value = false;
|
};
|
const equipmentname = ref("");
|
const handleEffectiveTimeConfirm = () => {
|
form.value.effectiveTime = dayjs(effectiveTime.value).format(
|
"YYYY-MM-DD HH:mm:ss"
|
);
|
showEffectiveTimeSheet.value = false;
|
};
|
// 制度分类选择
|
const handleEquipmentChange = val => {
|
form.value.category = val.value;
|
equipmentname.value = val.name;
|
showEquipmentSheet.value = false;
|
};
|
// 提交表单
|
const handleSubmit = async () => {
|
if (!form.value.regulationNum) {
|
showToast("请输入制度编号");
|
return;
|
}
|
|
if (!form.value.title) {
|
showToast("请输入制度标题");
|
return;
|
}
|
|
if (!form.value.category) {
|
showToast("请选择制度分类");
|
return;
|
}
|
if (!form.value.content) {
|
showToast("请输入制度内容");
|
return;
|
}
|
if (!form.value.effectiveTime) {
|
showToast("请选择生效时间");
|
return;
|
}
|
if (!form.value.scope.length) {
|
showToast("请选择生效范围");
|
return;
|
}
|
try {
|
loading.value = true;
|
if (detailType.value === 1) {
|
addRuleManagement(form.value).then(res => {
|
if (res.code !== 200) {
|
showToast("保存失败,请重试");
|
return;
|
}
|
loading.value = false;
|
showToast("保存成功");
|
setTimeout(() => {
|
goBack();
|
}, 500);
|
});
|
} else if (detailType.value === 2) {
|
updateRuleManagement(form.value).then(res => {
|
if (res.code !== 200) {
|
showToast("保存失败,请重试");
|
return;
|
}
|
loading.value = false;
|
showToast("保存成功");
|
setTimeout(() => {
|
goBack();
|
}, 500);
|
});
|
}
|
} catch (e) {
|
loading.value = false;
|
console.error("保存失败:", e);
|
showToast("保存失败,请重试");
|
}
|
};
|
|
// 初始化页面数据
|
const initPageData = () => {
|
// 从本地存储中获取会议 room 数据
|
const meetingRoom = uni.getStorageSync("meetingRoom");
|
if (meetingRoom) {
|
form.value = JSON.parse(JSON.stringify(meetingRoom));
|
if (meetingRoom.equipment) {
|
if (Array.isArray(meetingRoom.equipment)) {
|
form.value.equipment = meetingRoom.equipment;
|
} else {
|
form.value.equipment = meetingRoom.equipment.split(",");
|
}
|
}
|
statusname.value = meetingRoom.status === 1 ? "启用" : "禁用";
|
|
// 清除本地存储中的数据,避免下次打开时仍然显示
|
uni.removeStorageSync("meetingRoom");
|
}
|
};
|
const readonly = ref(false);
|
const detailType = ref(1);
|
const knowledgeId = ref("");
|
|
onLoad(options => {
|
detailType.value = Number(options.detailType);
|
knowledgeId.value = options.id || "";
|
|
// 查看模式设置只读
|
if (detailType.value === 3) {
|
readonly.value = true;
|
}
|
});
|
// 重置表单
|
const resetForm = () => {
|
form.value = {
|
id: "",
|
regulationNum: "",
|
title: "",
|
category: "",
|
content: "",
|
version: "",
|
status: "active",
|
readCount: 0,
|
effectiveTime: "",
|
scope: [],
|
requireConfirm: false,
|
};
|
equipmentname.value = "";
|
statusname.value = "";
|
};
|
onMounted(() => {
|
console.log(effectiveTime.value, "生效时间");
|
|
// 从本地存储中获取知识数据
|
const rulesRegulations = uni.getStorageSync("rulesRegulations");
|
initPageData();
|
if (rulesRegulations) {
|
form.value = JSON.parse(JSON.stringify(rulesRegulations));
|
}
|
|
if (detailType.value === 1) {
|
resetForm();
|
}
|
|
if (detailType.value != 1) {
|
equipmentname.value =
|
equipmentOptions.value.find(item => item.value == form.value.category)
|
?.name || "";
|
}
|
});
|
</script>
|
|
<style scoped lang="scss">
|
@import "@/static/scss/form-common.scss";
|
.client-visit {
|
min-height: 100vh;
|
background: #f8f9fa;
|
padding-bottom: 5rem;
|
}
|
|
.footer-btns {
|
position: fixed;
|
left: 0;
|
right: 0;
|
bottom: 0;
|
background: #fff;
|
display: flex;
|
justify-content: space-around;
|
align-items: center;
|
padding: 0.75rem 0;
|
box-shadow: 0 -0.125rem 0.5rem rgba(0, 0, 0, 0.05);
|
z-index: 1000;
|
}
|
|
.cancel-btn {
|
font-weight: 400;
|
font-size: 1rem;
|
color: #666;
|
background: #f5f5f5;
|
border: 1px solid #ddd;
|
width: 45%;
|
height: 2.5rem;
|
border-radius: 2.5rem 2.5rem 2.5rem 2.5rem;
|
}
|
|
.sign-btn {
|
font-weight: 500;
|
font-size: 1rem;
|
color: #fff;
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
border: none;
|
width: 45%;
|
height: 2.5rem;
|
border-radius: 2.5rem 2.5rem 2.5rem 2.5rem;
|
}
|
|
.location-icon {
|
color: #1989fa;
|
font-size: 1.2rem;
|
}
|
|
.selector-container {
|
display: flex;
|
align-items: center;
|
justify-content: space-between;
|
width: 100%;
|
height: 100%;
|
}
|
|
.selector-text {
|
font-size: 14px;
|
color: #333;
|
}
|
|
.popup-content {
|
padding: 20rpx;
|
}
|
|
.popup-header {
|
display: flex;
|
justify-content: space-between;
|
align-items: center;
|
margin-bottom: 20rpx;
|
}
|
|
.popup-title {
|
font-size: 16px;
|
font-weight: bold;
|
color: #333;
|
}
|
|
.close-icon {
|
font-size: 20px;
|
color: #999;
|
}
|
|
.popup-body {
|
max-height: 60vh;
|
overflow-y: auto;
|
margin-bottom: 20rpx;
|
}
|
|
.checkbox-item {
|
margin-bottom: 15rpx;
|
font-size: 14px;
|
}
|
|
.popup-footer {
|
display: flex;
|
justify-content: space-between;
|
gap: 15rpx;
|
}
|
|
.cancel-btn-popup {
|
flex: 1;
|
border-radius: 8rpx;
|
}
|
|
.confirm-btn-popup {
|
flex: 1;
|
border-radius: 8rpx;
|
}
|
.checkbox-item {
|
margin-top: 40rpx;
|
}
|
</style>
|