add.vue 11 KB

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