123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429 |
- <template>
- <div class="resourceAdd">
- <div class="topBox">
- <div class="topTitle">资源预约</div>
- <div class="choosTimeBox">
- <span class="msg">使用时间</span>
- <span class="choosIpt" @click="showTime('startTime')">{{ startTime }} </span>
- <span class="choosIpt" @click="showTimeList('startTime')">{{ timeListStr }} </span>
- <!-- <input placeholder="请选择时间段" class="choosIpt" disabled>-->
- </div>
- </div>
- <ul class="predetermineUl">
- <li class="detailLi">
- <span class="liName">主题</span>
- <span>
- <input class="liInfo" placeholder="请填写" v-model="form.subject">
- </span>
- </li>
- <li class="detailLi">
- <span class="liName">容纳人数</span>
- <span>
- <input class="liInfo" placeholder="请填写整数" v-model="form.peopleNumber">
- </span>
- </li>
- <li class="detailLi">
- <span class="liName">联系人</span>
- <span>
- <input class="liInfo" placeholder="请填写" v-model="form.contacts">
- </span>
- </li>
- <li class="detailLi">
- <span class="liName">联系电话</span>
- <span>
- <input class="liInfo" placeholder="请填写" v-model="form.phone">
- </span>
- </li>
- <li class="detailLi2" style="border-bottom: none">
- <div class="titleBox">
- <span class="liName">备注</span>
- </div>
- <van-field
- :value="form.remarks"
- autosize
- type="textarea"
- placeholder="请输入"
- class="myField"
- maxlength="2000"
- show-word-limit
- @change="changeMsg"
- />
- </li>
- </ul>
- <ul class="predetermineUl">
- <li class="detailLi">
- <span class="liName">预约单位</span>
- <span>
- <input class="liInfo" placeholder="" v-model="form.unit">
- </span>
- </li>
- <li class="detailLi">
- <span class="liName">预约人</span>
- <span>
- <input class="liInfo" placeholder="请填写" v-model="form.appointUserName">
- </span>
- </li>
- <li class="detailLi">
- <span class="liName">预约时间</span>
- <span>
- <input class="liInfo" placeholder="请填写" v-model="form.appointTime" disabled>
- </span>
- </li>
- </ul>
- <div class="buttonBox" v-if="form.state == '1'">
- <button class="btn zcBtn" @click="meetingAppointSubmit('1')">暂存</button>
- <button class="btn tjBtn" @click="meetingAppointSubmit('6')">提交</button>
- </div>
- <van-popup
- :show="timeShow"
- position="bottom"
- custom-style="height: 50%;"
- >
- <van-datetime-picker
- type="date"
- :value="currentDate"
- :formatter="formatter"
- @cancel="timeShow=false"
- @confirm="selectTime"
- />
- </van-popup>
- <van-popup
- :show="timeListShow"
- position="bottom"
- custom-style="height: 50%;"
- >
- <van-picker
- show-toolbar
- :columns="timeList"
- value-key="label"
- @confirm="selectTimeList"
- @cancel="timeListShow = false"
- />
- </van-popup>
- </div>
- </template>
- <script>
- import {getByCodes, getUserDept, getUserLocalStorageInfo, meetingAppointDetail, meetingAppointCheck, meetingAppointEdit} from "@/js_sdk/http";
- import dayjs from "dayjs";
- export default {
- name: "edit",
- data() {
- return {
- dc_key: ['timeSlot'],
- getUserLocalStorageInfo: getUserLocalStorageInfo(),
- theme: '',
- unit: '',
- postData: {},
- form: {
- // createdId: getUserLocalStorageInfo().userId,
- // appointTime: dayjs().format('YYYY-MM-DD HH:mm'),
- // userType: getUserLocalStorageInfo().userType
- },
- id: '',
- startTime: '请选择使用时间',
- timeShow: false,
- timePickerType: '',
- currentDate: new Date().getTime(),
- timeList: [], // 时间段列表
- timeListStr: '请选择时间段',
- timeListShow: false,
- dic_SelectList: [],
- }
- },
- created() {
- this.getByCodes()
- },
- onLoad(options) {
- this.id = options.id
- this.getById()
- },
- onShow() {
- },
- methods: {
- async getByCodes() {
- let data = await getByCodes(JSON.stringify(this.dc_key));
- this.dic_SelectList = this.$common.handleDicList(data);
- this.timeList = this.dic_SelectList.timeSlot
- console.log('this.timeList', this.timeList)
- },
- showTime(e) {
- this.timePickerType = e
- this.timeShow = true
- },
- showTimeList(e) {
- this.timePickerType = e
- this.timeListShow = true
- },
- // 时间戳转换方法
- timestampToDate(timestamp) {
- const date = new Date(timestamp); // 如果timestamp是字符串,确保它是整数:parseInt(timestamp)
- const year = date.getFullYear();
- const month = (date.getMonth() + 1).toString().padStart(2, '0');
- const day = date.getDate().toString().padStart(2, '0');
- const hours = date.getHours().toString().padStart(2, '0');
- const minutes = date.getMinutes().toString().padStart(2, '0');
- const seconds = date.getSeconds().toString().padStart(2, '0');
- return `${year}-${month}-${day}`;
- },
- // 时间选择单位
- formatter(type, val) {
- if (type === 'year') {
- return `${val}年`;
- } else if (type === 'month') {
- return `${val}月`;
- } else if (type === 'day') {
- return `${val}日`;
- } else if (type === 'hour') {
- return `${val}时`;
- } else if (type === 'minute') {
- return `${val}分`;
- }
- return val;
- },
- selectTime(e) {
- const dateString = this.timestampToDate(e.detail);
- this.startTime = dateString
- this.timeShow = false
- // this.getRoomTime(this.startTime)
- },
- selectTimeList(e) {
- const data = {
- id: this.meetingRoomId,
- dateStr: this.startTime,
- timeSlot: e.detail.value.value
- }
- meetingAppointCheck(data).then((res) => {
- if (res.code == '200') {
- this.timeListStr = e.detail.value.label
- this.form.timeSlot = e.detail.value.value
- this.timeListShow = false
- } else {
- this.$showToast("时间段已占用或已冻结,请重新选择");
- }
- }).catch(err => {
- this.$showToast(err);
- })
- },
- changeMsg(e){
- this.form.remarks = e.detail
- },
- getById(){
- const data = {
- id: this.id
- }
- meetingAppointDetail(data).then(res=>{
- if(res.code == '200'){
- this.form = res.data.oderDetial
- this.startTime = this.form.useTime
- let index = this.timeList.findIndex((e) => e.value == this.form.timeSlot)
- this.timeListStr = this.timeList[index].label
- console.log('form.appointTime', this.form.appointTime)
- }
- })
- },
- // 编辑预约
- meetingAppointSubmit(e) {
- if (this.startTime !== '' && this.startTime !== null && this.startTime !== undefined &&
- this.endTime !== '' && this.endTime !== null && this.endTime !== undefined) {
- uni.showToast({
- title: "请选择使用时间",
- });
- return false
- }
- this.form.state = e
- this.form.useTime = this.startTime
- console.log('提交预约_:', this.form)
- meetingAppointEdit(this.form).then((res) => {
- console.log('提交预约_:', res)
- if (res.code == '200') {
- uni.showToast({
- title: '预约成功',
- icon: 'success',
- mask: true,
- duration: 1000
- });
- let pages = getCurrentPages(); // 获取当前页面栈的实例,以数组形式按栈的顺序给出,第一个元素为首页,最后一个元素为当前页面。
- let nowPage = pages[pages.length - 1]; //当前页页面实例
- let prevPage = pages[pages.length - 2]; //上一页页面实例
- prevPage.$vm.otherFun("back")// 給上一頁綁定方法otherFun,傳參object
- uni.navigateBack({
- delta:1 // 可以不傳delta值,默認為1
- })
- } else {
- uni.showToast({
- title: res.msg,
- icon: 'success',
- mask: true,
- duration: 1000
- });
- }
- })
- },
- }
- }
- </script>
- <style lang="scss">
- .resourceAdd {
- .topBox {
- padding: 24rpx 32rpx;
- background: white;
- margin: 24rpx 0;
- .topTitle {
- color: rgba(34, 34, 34, 1);
- font-size: 36rpx;
- font-weight: 600;
- }
- .choosTimeBox {
- display: flex;
- justify-content: space-between;
- align-items: center;
- .msg {
- color: rgba(51, 51, 51, 1);
- font-size: 32rpx;
- white-space: nowrap;
- }
- .choosIpt {
- display: flex;
- align-items: center;
- justify-content: center;
- width: 260rpx;
- height: 96rpx;
- font-size: 32rpx;
- background: rgba(245, 247, 250, 1);
- box-sizing: border-box;
- }
- }
- }
- .predetermineUl {
- margin: 24rpx 0;
- background: white;
- box-sizing: border-box;
- padding: 0 32rpx;
- .predetermineLi {
- padding: 32rpx 0;
- border-bottom: 1px solid rgba(230, 230, 230, 1);
- display: flex;
- justify-content: space-between;
- }
- .predetermineLi2 {
- padding: 32rpx 0;
- border-bottom: 1px solid rgba(230, 230, 230, 1);
- display: flex;
- flex-direction: column;
- }
- .van-cell {
- background: #F5F7FA !important;
- border-radius: 8rpx;
- font-size: 28rpx;
- margin-top: 16rpx;
- }
- .liName {
- color: rgba(51, 51, 51, 1);
- font-size: 32rpx;
- }
- .liIpt {
- color: rgba(102, 102, 102, 1);
- font-size: 32rpx;
- text-align: right;
- }
- .detailLi {
- display: flex;
- justify-content: space-between;
- align-items: center;
- padding: 32rpx 0;
- border-bottom: 2rpx solid #E6E6E6;
- .liInfo {
- display: inline-block;
- text-align: right;
- max-width: 488rpx;
- width: 488rpx;
- color: rgba(102, 102, 102, 1);
- font-size: 32rpx;
- line-height: 38rpx;
- .radio {
- margin-left: 64rpx;
- }
- }
- }
- .detailLi2 {
- display: flex;
- flex-direction: column;
- padding: 32rpx 0;
- border-bottom: 2rpx solid #E6E6E6;
- .detailLi2BoxTop {
- display: flex;
- flex-wrap: wrap;
- justify-content: space-between;
- margin: 12rpx 0;
- .checkItem {
- width: 128rpx;
- height: 64rpx;
- font-size: 28rpx;
- color: #666666;
- display: flex;
- align-items: center;
- justify-content: center;
- background: #F5F7FA;
- border-radius: 8rpx;
- margin: 12rpx 0;
- }
- .checked {
- background: #0365F9;
- color: white;
- }
- }
- }
- }
- .buttonBox {
- display: flex;
- justify-content: center;
- .btn {
- width: 240rpx;
- height: 80rpx;
- display: flex;
- border-radius: 8rpx;
- align-items: center;
- justify-content: center;
- margin: 48rpx 16rpx 150rpx 16rpx;
- color: white;
- letter-spacing: 2rpx;
- text-indent: 2rpx;
- }
- .zcBtn {
- background: #FE8643;
- }
- .tjBtn {
- background: #0365F9;
- }
- }
- }
- </style>
|