add.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438
  1. <template>
  2. <div class="resourceAdd">
  3. <div class="topBox">
  4. <div class="topTitle">资源预约</div>
  5. <div class="choosTimeBox">
  6. <span class="msg">使用时间</span>
  7. <span class="choosIpt" @click="showTime('startTime')">{{ startTime }} </span>
  8. <span class="choosIpt" @click="showTimeList('startTime')">{{ timeListStr }} </span>
  9. <!-- <input placeholder="请选择时间段" class="choosIpt" disabled>-->
  10. </div>
  11. </div>
  12. <ul class="predetermineUl">
  13. <li class="detailLi">
  14. <span class="liName">主题</span>
  15. <span>
  16. <input class="liInfo" placeholder="请填写" v-model="form.subject">
  17. </span>
  18. </li>
  19. <li class="detailLi">
  20. <span class="liName">容纳人数</span>
  21. <span>
  22. <input class="liInfo" placeholder="请填写整数" v-model="form.peopleNumber">
  23. </span>
  24. </li>
  25. <li class="detailLi">
  26. <span class="liName">联系人</span>
  27. <span>
  28. <input class="liInfo" placeholder="请填写" v-model="form.contacts">
  29. </span>
  30. </li>
  31. <li class="detailLi">
  32. <span class="liName">联系电话</span>
  33. <span>
  34. <input class="liInfo" placeholder="请填写" v-model="form.phone">
  35. </span>
  36. </li>
  37. <li class="detailLi2" style="border-bottom: none">
  38. <div class="titleBox">
  39. <span class="liName">备注</span>
  40. </div>
  41. <van-field
  42. :value="form.remarks"
  43. autosize
  44. type="textarea"
  45. placeholder="请输入"
  46. class="myField"
  47. maxlength="2000"
  48. show-word-limit
  49. @change="changeMsg"
  50. />
  51. </li>
  52. </ul>
  53. <ul class="predetermineUl">
  54. <li class="detailLi">
  55. <span class="liName">预约单位</span>
  56. <span>
  57. <input class="liInfo" placeholder="" v-model="form.unit">
  58. </span>
  59. </li>
  60. <li class="detailLi">
  61. <span class="liName">预约人</span>
  62. <span>
  63. <input class="liInfo" placeholder="请填写" v-model="form.appointUserName">
  64. </span>
  65. </li>
  66. <li class="detailLi">
  67. <span class="liName">预约时间</span>
  68. <span>
  69. <input class="liInfo" placeholder="请填写" v-model="form.appointTime" disabled>
  70. </span>
  71. </li>
  72. </ul>
  73. <div class="buttonBox">
  74. <button class="btn zcBtn" @click="meetingAppointSubmit('1')">暂存</button>
  75. <button class="btn tjBtn" @click="meetingAppointSubmit('2')">提交</button>
  76. </div>
  77. <van-popup
  78. :show="timeShow"
  79. position="bottom"
  80. custom-style="height: 50%;"
  81. >
  82. <van-datetime-picker
  83. type="date"
  84. :value="currentDate"
  85. :formatter="formatter"
  86. @cancel="timeShow=false"
  87. @confirm="selectTime"
  88. />
  89. </van-popup>
  90. <van-popup
  91. :show="timeListShow"
  92. position="bottom"
  93. custom-style="height: 50%;"
  94. >
  95. <van-picker
  96. show-toolbar
  97. :columns="timeList"
  98. value-key="label"
  99. @confirm="selectTimeList"
  100. @cancel="timeListShow = false"
  101. />
  102. </van-popup>
  103. </div>
  104. </template>
  105. <script>
  106. import {getByCodes, getUserDept, getUserLocalStorageInfo, meetingAppoint, meetingAppointCheck} from "@/js_sdk/http";
  107. import dayjs from "dayjs";
  108. // import Toast from "../../../wxcomponents/weapp/lib/toast/index.vue";
  109. export default {
  110. name: "add",
  111. data() {
  112. return {
  113. dc_key: ['timeSlot'],
  114. getUserLocalStorageInfo: getUserLocalStorageInfo(),
  115. theme: '',
  116. unit: '',
  117. postData: {},
  118. form: {
  119. createdId: getUserLocalStorageInfo().userId,
  120. appointTime: dayjs().format('YYYY-MM-DD HH:mm'),
  121. userType: getUserLocalStorageInfo().userType
  122. },
  123. meetingRoomId: '',
  124. startTime: '请选择使用时间',
  125. timeShow: false,
  126. timePickerType: '',
  127. currentDate: new Date().getTime(),
  128. timeList: [], // 时间段列表
  129. timeListStr: '请选择时间段',
  130. timeListShow: false,
  131. dic_SelectList: [],
  132. }
  133. },
  134. created() {
  135. this.getByCodes()
  136. },
  137. onLoad(options) {
  138. this.meetingRoomId = options.meetingRoomId
  139. },
  140. onShow() {
  141. // 企业端
  142. if (getUserLocalStorageInfo().userType == '1') {
  143. this.form.unit = getUserLocalStorageInfo().username
  144. }
  145. // 管理端
  146. if (getUserLocalStorageInfo().userType == '2') {
  147. const data = {
  148. id: getUserLocalStorageInfo().userId
  149. }
  150. getUserDept(data).then(res => {
  151. this.form.unit = res.msg
  152. })
  153. }
  154. },
  155. methods: {
  156. changeMsg(e){
  157. this.form.remarks = e.detail
  158. },
  159. async getByCodes() {
  160. let data = await getByCodes(JSON.stringify(this.dc_key));
  161. this.dic_SelectList = this.$common.handleDicList(data);
  162. // this.timeList = this.dic_SelectList.timeSlot.map(item =>{
  163. // return item.label;
  164. // });
  165. this.timeList = this.dic_SelectList.timeSlot
  166. },
  167. showTime(e) {
  168. this.timePickerType = e
  169. this.timeShow = true
  170. },
  171. showTimeList(e) {
  172. this.timePickerType = e
  173. this.timeListShow = true
  174. },
  175. // 时间戳转换方法
  176. timestampToDate(timestamp) {
  177. const date = new Date(timestamp); // 如果timestamp是字符串,确保它是整数:parseInt(timestamp)
  178. const year = date.getFullYear();
  179. const month = (date.getMonth() + 1).toString().padStart(2, '0');
  180. const day = date.getDate().toString().padStart(2, '0');
  181. const hours = date.getHours().toString().padStart(2, '0');
  182. const minutes = date.getMinutes().toString().padStart(2, '0');
  183. const seconds = date.getSeconds().toString().padStart(2, '0');
  184. return `${year}-${month}-${day}`;
  185. },
  186. // 时间选择单位
  187. formatter(type, val) {
  188. if (type === 'year') {
  189. return `${val}年`;
  190. } else if (type === 'month') {
  191. return `${val}月`;
  192. } else if (type === 'day') {
  193. return `${val}日`;
  194. } else if (type === 'hour') {
  195. return `${val}时`;
  196. } else if (type === 'minute') {
  197. return `${val}分`;
  198. }
  199. return val;
  200. },
  201. selectTime(e) {
  202. const dateString = this.timestampToDate(e.detail);
  203. this.startTime = dateString
  204. this.timeShow = false
  205. // this.getRoomTime(this.startTime)
  206. },
  207. selectTimeList(e) {
  208. const data = {
  209. id: this.meetingRoomId,
  210. dateStr: this.startTime,
  211. timeSlot: e.detail.value.value
  212. }
  213. meetingAppointCheck(data).then((res) => {
  214. if (res.code == '200') {
  215. this.timeListStr = e.detail.value.label
  216. this.form.timeSlot = e.detail.value.value
  217. this.timeListShow = false
  218. } else {
  219. this.$showToast("时间段已占用或已冻结,请重新选择");
  220. }
  221. }).catch(err => {
  222. this.$showToast(err);
  223. })
  224. },
  225. // // 获取日期可以选择的区间
  226. // getRoomTime(roomTime) {
  227. // const reqData = {
  228. // id: this.roomId,
  229. // useTime: roomTime
  230. // }
  231. // roomTimeSoltUseful(reqData).then((res) => {
  232. // this.timeList = res.data
  233. // console.log('获取日期可以选择的区间_:', res)
  234. // })
  235. // },
  236. // 提交预约
  237. meetingAppointSubmit(e) {
  238. if (this.startTime !== '' && this.startTime !== null && this.startTime !== undefined &&
  239. this.endTime !== '' && this.endTime !== null && this.endTime !== undefined) {
  240. uni.showToast({
  241. title: "请选择使用时间",
  242. });
  243. return false
  244. }
  245. this.form.saveType = e
  246. this.form.useTime = this.startTime
  247. this.form.meetingRoomId = this.meetingRoomId
  248. console.log('提交预约_:', this.form)
  249. meetingAppoint(this.form).then((res) => {
  250. console.log('提交预约_:', res)
  251. if (res.code == '200') {
  252. uni.showToast({
  253. title: '预约成功',
  254. icon: 'success',
  255. mask: true,
  256. duration: 1000
  257. });
  258. uni.navigateBack({})
  259. } else {
  260. uni.showToast({
  261. title: res.msg,
  262. icon: 'success',
  263. mask: true,
  264. duration: 1000
  265. });
  266. }
  267. })
  268. },
  269. }
  270. }
  271. </script>
  272. <style lang="scss">
  273. .resourceAdd {
  274. .topBox {
  275. padding: 24rpx 32rpx;
  276. background: white;
  277. margin: 24rpx 0;
  278. .topTitle {
  279. color: rgba(34, 34, 34, 1);
  280. font-size: 36rpx;
  281. font-weight: 600;
  282. }
  283. .choosTimeBox {
  284. display: flex;
  285. justify-content: space-between;
  286. align-items: center;
  287. .msg {
  288. color: rgba(51, 51, 51, 1);
  289. font-size: 32rpx;
  290. white-space: nowrap;
  291. }
  292. .choosIpt {
  293. display: flex;
  294. align-items: center;
  295. justify-content: center;
  296. width: 260rpx;
  297. height: 96rpx;
  298. font-size: 32rpx;
  299. background: rgba(245, 247, 250, 1);
  300. box-sizing: border-box;
  301. }
  302. }
  303. }
  304. .predetermineUl {
  305. margin: 24rpx 0;
  306. background: white;
  307. box-sizing: border-box;
  308. padding: 0 32rpx;
  309. .predetermineLi {
  310. padding: 32rpx 0;
  311. border-bottom: 1px solid rgba(230, 230, 230, 1);
  312. display: flex;
  313. justify-content: space-between;
  314. }
  315. .predetermineLi2 {
  316. padding: 32rpx 0;
  317. border-bottom: 1px solid rgba(230, 230, 230, 1);
  318. display: flex;
  319. flex-direction: column;
  320. }
  321. .van-cell {
  322. background: #F5F7FA !important;
  323. border-radius: 8rpx;
  324. font-size: 28rpx;
  325. margin-top: 16rpx;
  326. }
  327. .liName {
  328. color: rgba(51, 51, 51, 1);
  329. font-size: 32rpx;
  330. }
  331. .liIpt {
  332. color: rgba(102, 102, 102, 1);
  333. font-size: 32rpx;
  334. text-align: right;
  335. }
  336. .detailLi {
  337. display: flex;
  338. justify-content: space-between;
  339. align-items: center;
  340. padding: 32rpx 0;
  341. border-bottom: 2rpx solid #E6E6E6;
  342. .liInfo {
  343. display: inline-block;
  344. text-align: right;
  345. max-width: 488rpx;
  346. width: 488rpx;
  347. color: rgba(102, 102, 102, 1);
  348. font-size: 32rpx;
  349. line-height: 38rpx;
  350. .radio {
  351. margin-left: 64rpx;
  352. }
  353. }
  354. }
  355. .detailLi2 {
  356. display: flex;
  357. flex-direction: column;
  358. padding: 32rpx 0;
  359. border-bottom: 2rpx solid #E6E6E6;
  360. .detailLi2BoxTop {
  361. display: flex;
  362. flex-wrap: wrap;
  363. justify-content: space-between;
  364. margin: 12rpx 0;
  365. .checkItem {
  366. width: 128rpx;
  367. height: 64rpx;
  368. font-size: 28rpx;
  369. color: #666666;
  370. display: flex;
  371. align-items: center;
  372. justify-content: center;
  373. background: #F5F7FA;
  374. border-radius: 8rpx;
  375. margin: 12rpx 0;
  376. }
  377. .checked {
  378. background: #0365F9;
  379. color: white;
  380. }
  381. }
  382. }
  383. }
  384. .buttonBox {
  385. display: flex;
  386. justify-content: center;
  387. .btn {
  388. width: 240rpx;
  389. height: 80rpx;
  390. display: flex;
  391. border-radius: 8rpx;
  392. align-items: center;
  393. justify-content: center;
  394. margin: 48rpx 16rpx 150rpx 16rpx;
  395. color: white;
  396. letter-spacing: 2rpx;
  397. text-indent: 2rpx;
  398. }
  399. .zcBtn {
  400. background: #FE8643;
  401. }
  402. .tjBtn {
  403. background: #0365F9;
  404. }
  405. }
  406. }
  407. </style>