You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

539 lines
17 KiB

<template>
<div class="address_edit">
<!-- 导航栏 -->
2 years ago
<!-- <div class="header_body">
<header-nav
:slefBack="true"
@goBack="goBack"
:titelText="`执法检查计划`"
>
</header-nav>
2 years ago
</div>-->
<!-- 中间 -->
<div class="warp_body">
<van-form @failed="onFailed" @submit="submit">
<van-cell-group>
<!-- <van-field-->
<!-- v-model="submitData.planYear"-->
<!-- required-->
<!-- label="计划年度"-->
<!-- placeholder="必填"-->
<!-- readonly-->
<!-- :rules="[{ required: true, message: '请选择年度计划' }]"-->
<!-- @click="selectDate"-->
<!-- />-->
<van-popup v-model:show="data.showDatePicker" position="bottom">
<van-date-picker
title="选择日期"
v-model="data.currentDate"
:min-date="data.minDate"
:max-date="data.maxDate"
:columns-type="data.columnsType"
@confirm="onDateConfirm"
@cancel="cancelSelectDate"
/>
</van-popup>
2 years ago
<van-field
v-model="submitData.planName"
label="计划名称"
placeholder="请输入"
required
:rules="[{ required: true, message: '请输入计划名称' }]"
/>
<div class="plan-attach">
<div class="plan-time">
<van-field
v-model="data.fieldValue"
is-link
readonly
2 years ago
placeholder="选择时段"
@click="data.dateShowPicker = true"
/>
</div>
2 years ago
<div class="plan-text">行政检查计划</div>
</div>
<van-popup v-model:show="data.dateShowPicker" round position="bottom">
<van-picker
:columns="data.dateColumns"
@cancel="data.dateShowPicker = false"
@confirm="dateOnConfirm"
/>
</van-popup>
<van-field
v-model="submitData.bureauDeptName"
label="执法部门"
placeholder="请选择"
2 years ago
is-link
@click=""
required
readonly
:rules="[{ required: true, message: '请选择执法部门'}]"
/>
<van-field
v-model="submitData.enforcementTime"
label="上传时间"
placeholder="请选择"
clickable
is-link
readonly
required
:rules="[{ required: true, message: '请选择上传时间'}]"
@click="selectEnforcementTime"
/>
<van-popup v-model:show="data.showPicker" position="bottom">
<van-date-picker
title="选择日期"
v-model="data.currentDate1"
:min-date="data.minDate"
:max-date="data.maxDate"
:columns-type="data.columnsTypes"
@confirm="onEnforcementTimeConfirm"
@cancel="cancelEnforcementTime"
/>
</van-popup>
<van-field
v-model="submitData.enforcementArea"
label="执法区域"
placeholder="请输入"
required
:rules="[{ required: true, message: '请输入执法区域'}]"
/>
<div class="file-upload">
<div class="file-upload-center">
文件上传 <span>(仅限PDF文档)</span>
</div>
<van-uploader v-model="data.fileListObj" max-count="1" class="file" :after-read="uploadFiles"
multiple @oversize="onOversize" :before-delete="deleteFile" accept=".pdf">
<template #preview-cover="{ file }">
<div class="preview-cover van-ellipsis">{{ file.name }}</div>
</template>
</van-uploader>
</div>
</van-cell-group>
<van-action-bar>
<van-button round block type="info" native-type="submit">提交</van-button>
</van-action-bar>
</van-form>
</div>
2 years ago
<div class="van-overlay" v-show="data.showIsPublish">
<div class="popcont">
<div class="poptip">是否公布该行政检查计划?</div>
<div class="popup-btn">
<a @click="addPlan(0)">取消</a><a @click="addPlan(1)">确认</a>
</div>
</div>
</div>
</div>
</template>
<script setup name="register">
import {showToast, showSuccessToast, showLoadingToast, closeToast} from 'vant';
import {addEnforcementInspectionProgram, queryUserInfo} from '@/api/enforce'
import {getDict} from '../../api/Home'
import {uploadFile} from '../../util/fileUpload'
import {reactive, ref} from "vue";
import {showConfirmDialog} from 'vant';
const {useCommon, useMy} = $globalStore;
const router = useRouter();
const route = useRoute();
let queryaddressId = ref("");
const data = reactive({
searchResult: [],
showPicker: false,
columns: [],
selectTypeValue: ref[0],
showDatePicker: ref(false),
columnsType: ['year'],
columnsTypes: ['year', 'month', 'day'],
currentDate: ref(['2024']),
minDate: new Date(2020, 0, 1),
maxDate: new Date(2125, 5, 1),
currentDate1: [],
//vant组件上传照片列表
fileListObj: [],
dateShowPicker: false,
fieldValue: "年度",
dateColumns: [
{ text: '年度', value: 'year' },
{ text: '季度', value: 'quarter' },
{ text: '月度', value: 'month' },
],
showIsPublish:false,
});
//保存参数
const submitData = reactive({
//用户id
userId: useCommon.userId,
//关联案件ID
relId: "",
//计划年度
planYear: "",
//计划名称
planName: "",
//执法部门
enforcementDepartment: "",
//执法部门ID
enforcementDepartmentId: "",
//执法时间
enforcementTime: "",
//执法区域
enforcementArea: "",
//是否发布年度执法计划
isPublish: 0,
//后台保存图片列表
fileList: [],
/**局级部门 */
bureauDeptId:"",
bureauDeptName:""
})
// 返回
const goBack = () => {
router.go(-1);
};
const submit = () => {
data.showIsPublish = true;
}
const addPlan = (val) =>{
submitData.planName = submitData.planName + data.fieldValue +"行政检查计划";
submitData.isPublish = val;
addEnforcementInspectionProgram(submitData, success => {
console.log(success)
//跳转企业二维码地址
if (success.success) {
console.log("保存成功");
showSuccessToast('保存成功');
goBack();
}
}, error => {
console.log("保存失败")
})
// showConfirmDialog(submitData).then(() => {
// console.log(1)
// }).catch(() => {
// console.log(0)
// showSuccessToast('保存成功');
// submitData.isPublish = 0
// addEnforcementInspectionProgram(submitData, success => {
// console.log(success)
// //跳转企业二维码地址
// if (success.success) {
// console.log("保存成功");
// showSuccessToast('保存成功');
// goBack();
// }
// }, error => {
// console.log("保存失败")
// })
// });
}
const currentDate =() => {
const now = new Date();
const year = now.getFullYear();
const month = (now.getMonth() + 1).toString().padStart(2, '0');
const day = now.getDate().toString().padStart(2, '0');
data.currentDate1 = [year, month, day]
}
const onFailed = (errorInfo) => {
console.log('failed', errorInfo);
};
//消息提醒
// const toast = showLoadingToast({
// duration: 0,
// forbidClick: true,
// message: '提交成功',
// });
// let second = 3;
// const timer = setInterval(() => {
// second--;
// if (second) {
// } else {
// clearInterval(timer);
// closeToast();
// }
// }, 1000);
// 保存地址操作
const onSave = () => {
router.replace({name: "addressList"});
};
const onConfirm = (value) => {
data.showPicker = false;
console.log(value)
submitData.enforceType = value.selectedValues[0];
submitData.enforceTypeText = value.selectedOptions[0].text;
}
const selectType = () => {
data.showPicker = true;
// console.log(data)
}
const uploadFiles = (file) => {
uploadFile(file, (res) => {
console.log(file.fileName);
submitData.fileList.push({
fileUrl: res.url,
fileName: file.file.name
})
console.log(submitData.fileList);
});
}
const deleteFile = (file, index) => {
// data.fileListObj.filter((item, indexs) => {
// if (index.index == indexs) {
// data.fileListObj.splice(indexs, 1);//splice 删除
// }
// });
submitData.fileList.filter((item, indexs) => {
if (index.index == indexs) {
submitData.fileList.splice(indexs, 1);//splice 删除
}
});
return true;
}
onMounted(() => {
console.log(route?.query?.id);
console.log(route?.query?.lawEnforcementIncident);
submitData.relId = route?.query?.id;
submitData.lawEnforcementIncident = route?.query?.lawEnforcementIncident;
currentDate();
getDict({"dictType": "caseType"}, success => {
console.log(success);
success.data.forEach(res => {
console.log(res)
var obj = {text: res.dictLabel, value: res.dictValue};
data.columns.push(obj)
})
}, error => {
})
//查询企业信息
queryUserInfo(useCommon.userId, success => {
submitData.enforcementDepartment = success.data.dept.deptName;
submitData.enforcementDepartmentId = success.data.dept.deptId;
//局级部门
submitData.bureauDeptName = success.data.bureauDept.deptName;
submitData.bureauDeptId = success.data.bureauDept.deptId;
}, error => {
})
});
const selectDate = () => {
data.showDatePicker = true;
console.log(data.showDatePicker)
}
const onDateConfirm = (value) => {
value.selectedValues.forEach((item, index) => {
submitData.planYear = item;
});
// submitData.establishmentTime = "2023-04-21"
data.showDatePicker = false;
}
//取消日期选择
const cancelSelectDate = () => {
data.showDatePicker = false;
}
//取消
const cancelEnforcementTime = () => {
data.showPicker = false;
}
const selectEnforcementTime = () => {
data.showPicker = true;
}
const onEnforcementTimeConfirm = (value) => {
console.log(value);
value.selectedValues.forEach((item, index) => {
console.log(item);
});
submitData.enforcementTime = value.selectedValues[0] + "-" + value.selectedValues[1] + "-" + value.selectedValues[2];
data.showPicker = false;
}
const dateOnConfirm = ({ selectedOptions }) => {
data.dateShowPicker = false;
data.fieldValue = selectedOptions[0].text;
};
</script>
<style lang="less" scoped>
.address_edit {
display: flex;
flex-direction: column;
height: 100%;
overflow: hidden;
2 years ago
background-color: #ebf3fb;
}
2 years ago
.warp_body {
2 years ago
margin: 0 3%;
2 years ago
padding-bottom: 3rem;
2 years ago
width: 94%;
height: 98%;
2 years ago
background-color: #ebf3fb;
2 years ago
overflow-y: auto;
2 years ago
margin-top: 0.15rem;
2 years ago
}
/* vant4的 Toast 和 Popup 样式冲突,会导致 Toast 变成白底 */
// .van-popup.van-toast{
// background: var(--van-toast-background) !important;
// box-sizing: content-box !important;
// /* 下面3条css,影响不大 */
// transition: all var(--van-duration-fast) !important;
// width: var(--van-toast-default-width) !important;
// max-width: var(--van-toast-max-width) !important;
// }
// .van-popup.van-toast .van-toast__icon{
// font-size: var(--van-toast-icon-size) !important;
// }
.file-upload {
2 years ago
position: relative;
min-height: 4.2rem;
2 years ago
padding: 1rem 0.27rem 0.27rem 0.43rem;
2 years ago
box-sizing: border-box;
}
.file-upload-center {
position: absolute;
2 years ago
top: 0.27rem;
2 years ago
left: 0.43rem;
2 years ago
width: 90%;
height: 0.65rem;
2 years ago
font-size: 0.38rem;
span {
2 years ago
font-size: 0.32rem;
color: rgb(221, 229, 227);
}
}
.file {
position: absolute;
bottom: 10%;
2 years ago
left: 0.43rem;
width: calc(100% - 0.86rem);
}
.preview-cover {
position: absolute;
bottom: 0;
box-sizing: border-box;
width: 100%;
2 years ago
padding: 0.12rem;
color: #fff;
2 years ago
font-size: 0.32rem;
text-align: center;
background: rgba(0, 0, 0, 0.3);
}
/deep/ .van-button {
margin: 5% 3%;
padding: 0;
width: 94%;
height: 1rem;
color: #fff;
font-size: 0.4rem;
border-radius: 1rem;
background: #1367fe;
2 years ago
border: 1px solid #1367fe;
text-align: center;
}
2 years ago
/deep/ .van-action-bar {
box-shadow: 0 0 0.27rem #e5e5e5;
}
:root {
2 years ago
--van-dialog-width: 16rem;
}
2 years ago
.plan-attach {
display: flex;
align-items: center;
width: 100%;
white-space: nowrap;
}
.plan-time {
margin-left: 2.67rem;
width: 2.25rem;
}
.plan-text {
min-width: 30%;
font-size: 0.37rem;
line-height: 3.25;
}
2 years ago
2 years ago
.popcont {
position: absolute;
z-index: 100;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
2 years ago
padding: 5% 3% 0;
width: 70%;
height: 4rem;
background: linear-gradient(to bottom, #d6e7f9, #fff);
border-radius: 0.35rem;
2 years ago
}
.poptip {
margin: 0.3rem;
min-height: 1.25rem;
font-size: 0.4rem;
2 years ago
font-weight: 600;
text-align: center;
//border-bottom: 1px solid #eee;
2 years ago
}
.popup-btn {
display: flex;
align-items: center;
justify-content: space-between;
2 years ago
margin: 2% auto 0;
width: 90%;
2 years ago
height: 1.5rem;
}
.popup-btn a {
width: 45%;
color: #333;
2 years ago
font-size: 0.37rem;
line-height: 2.5;
text-align: center;
border: 1px solid #ddd;
border-radius: 1rem;
2 years ago
}
.popup-btn a:last-child {
background-color: #1367fe;
color: #fff;
border-color: #1367fe;
}
</style>