add.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440
  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. postData: {},
  117. form: {
  118. createdId: getUserLocalStorageInfo().userId,
  119. appointTime: dayjs().format('YYYY-MM-DD HH:mm'),
  120. userType: getUserLocalStorageInfo().userType,
  121. unit: ' '
  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. if(res.data){
  152. this.form.unit = res.data
  153. }
  154. })
  155. }
  156. },
  157. methods: {
  158. changeMsg(e){
  159. this.form.remarks = e.detail
  160. },
  161. async getByCodes() {
  162. let data = await getByCodes(JSON.stringify(this.dc_key));
  163. this.dic_SelectList = this.$common.handleDicList(data);
  164. // this.timeList = this.dic_SelectList.timeSlot.map(item =>{
  165. // return item.label;
  166. // });
  167. this.timeList = this.dic_SelectList.timeSlot
  168. },
  169. showTime(e) {
  170. this.timePickerType = e
  171. this.timeShow = true
  172. },
  173. showTimeList(e) {
  174. this.timePickerType = e
  175. this.timeListShow = true
  176. },
  177. // 时间戳转换方法
  178. timestampToDate(timestamp) {
  179. const date = new Date(timestamp); // 如果timestamp是字符串,确保它是整数:parseInt(timestamp)
  180. const year = date.getFullYear();
  181. const month = (date.getMonth() + 1).toString().padStart(2, '0');
  182. const day = date.getDate().toString().padStart(2, '0');
  183. const hours = date.getHours().toString().padStart(2, '0');
  184. const minutes = date.getMinutes().toString().padStart(2, '0');
  185. const seconds = date.getSeconds().toString().padStart(2, '0');
  186. return `${year}-${month}-${day}`;
  187. },
  188. // 时间选择单位
  189. formatter(type, val) {
  190. if (type === 'year') {
  191. return `${val}年`;
  192. } else if (type === 'month') {
  193. return `${val}月`;
  194. } else if (type === 'day') {
  195. return `${val}日`;
  196. } else if (type === 'hour') {
  197. return `${val}时`;
  198. } else if (type === 'minute') {
  199. return `${val}分`;
  200. }
  201. return val;
  202. },
  203. selectTime(e) {
  204. const dateString = this.timestampToDate(e.detail);
  205. this.startTime = dateString
  206. this.timeShow = false
  207. // this.getRoomTime(this.startTime)
  208. },
  209. selectTimeList(e) {
  210. const data = {
  211. id: this.meetingRoomId,
  212. dateStr: this.startTime,
  213. timeSlot: e.detail.value.value
  214. }
  215. meetingAppointCheck(data).then((res) => {
  216. if (res.code == '200') {
  217. this.timeListStr = e.detail.value.label
  218. this.form.timeSlot = e.detail.value.value
  219. this.timeListShow = false
  220. } else {
  221. this.$showToast("时间段已占用或已冻结,请重新选择");
  222. }
  223. }).catch(err => {
  224. this.$showToast(err);
  225. })
  226. },
  227. // // 获取日期可以选择的区间
  228. // getRoomTime(roomTime) {
  229. // const reqData = {
  230. // id: this.roomId,
  231. // useTime: roomTime
  232. // }
  233. // roomTimeSoltUseful(reqData).then((res) => {
  234. // this.timeList = res.data
  235. // console.log('获取日期可以选择的区间_:', res)
  236. // })
  237. // },
  238. // 提交预约
  239. meetingAppointSubmit(e) {
  240. if (this.startTime !== '' && this.startTime !== null && this.startTime !== undefined &&
  241. this.endTime !== '' && this.endTime !== null && this.endTime !== undefined) {
  242. uni.showToast({
  243. title: "请选择使用时间",
  244. });
  245. return false
  246. }
  247. this.form.saveType = e
  248. this.form.useTime = this.startTime
  249. this.form.meetingRoomId = this.meetingRoomId
  250. console.log('提交预约_:', this.form)
  251. meetingAppoint(this.form).then((res) => {
  252. console.log('提交预约_:', res)
  253. if (res.code == '200') {
  254. uni.showToast({
  255. title: '预约成功',
  256. icon: 'success',
  257. mask: true,
  258. duration: 1000
  259. });
  260. uni.navigateBack({})
  261. } else {
  262. uni.showToast({
  263. title: res.msg,
  264. icon: 'success',
  265. mask: true,
  266. duration: 1000
  267. });
  268. }
  269. })
  270. },
  271. }
  272. }
  273. </script>
  274. <style lang="scss">
  275. .resourceAdd {
  276. .topBox {
  277. padding: 24rpx 32rpx;
  278. background: white;
  279. margin: 24rpx 0;
  280. .topTitle {
  281. color: rgba(34, 34, 34, 1);
  282. font-size: 36rpx;
  283. font-weight: 600;
  284. }
  285. .choosTimeBox {
  286. display: flex;
  287. justify-content: space-between;
  288. align-items: center;
  289. .msg {
  290. color: rgba(51, 51, 51, 1);
  291. font-size: 32rpx;
  292. white-space: nowrap;
  293. }
  294. .choosIpt {
  295. display: flex;
  296. align-items: center;
  297. justify-content: center;
  298. width: 260rpx;
  299. height: 96rpx;
  300. font-size: 32rpx;
  301. background: rgba(245, 247, 250, 1);
  302. box-sizing: border-box;
  303. }
  304. }
  305. }
  306. .predetermineUl {
  307. margin: 24rpx 0;
  308. background: white;
  309. box-sizing: border-box;
  310. padding: 0 32rpx;
  311. .predetermineLi {
  312. padding: 32rpx 0;
  313. border-bottom: 1px solid rgba(230, 230, 230, 1);
  314. display: flex;
  315. justify-content: space-between;
  316. }
  317. .predetermineLi2 {
  318. padding: 32rpx 0;
  319. border-bottom: 1px solid rgba(230, 230, 230, 1);
  320. display: flex;
  321. flex-direction: column;
  322. }
  323. .van-cell {
  324. background: #F5F7FA !important;
  325. border-radius: 8rpx;
  326. font-size: 28rpx;
  327. margin-top: 16rpx;
  328. }
  329. .liName {
  330. color: rgba(51, 51, 51, 1);
  331. font-size: 32rpx;
  332. }
  333. .liIpt {
  334. color: rgba(102, 102, 102, 1);
  335. font-size: 32rpx;
  336. text-align: right;
  337. }
  338. .detailLi {
  339. display: flex;
  340. justify-content: space-between;
  341. align-items: center;
  342. padding: 32rpx 0;
  343. border-bottom: 2rpx solid #E6E6E6;
  344. .liInfo {
  345. display: inline-block;
  346. text-align: right;
  347. max-width: 488rpx;
  348. width: 488rpx;
  349. color: rgba(102, 102, 102, 1);
  350. font-size: 32rpx;
  351. line-height: 38rpx;
  352. .radio {
  353. margin-left: 64rpx;
  354. }
  355. }
  356. }
  357. .detailLi2 {
  358. display: flex;
  359. flex-direction: column;
  360. padding: 32rpx 0;
  361. border-bottom: 2rpx solid #E6E6E6;
  362. .detailLi2BoxTop {
  363. display: flex;
  364. flex-wrap: wrap;
  365. justify-content: space-between;
  366. margin: 12rpx 0;
  367. .checkItem {
  368. width: 128rpx;
  369. height: 64rpx;
  370. font-size: 28rpx;
  371. color: #666666;
  372. display: flex;
  373. align-items: center;
  374. justify-content: center;
  375. background: #F5F7FA;
  376. border-radius: 8rpx;
  377. margin: 12rpx 0;
  378. }
  379. .checked {
  380. background: #0365F9;
  381. color: white;
  382. }
  383. }
  384. }
  385. }
  386. .buttonBox {
  387. display: flex;
  388. justify-content: center;
  389. .btn {
  390. width: 240rpx;
  391. height: 80rpx;
  392. display: flex;
  393. border-radius: 8rpx;
  394. align-items: center;
  395. justify-content: center;
  396. margin: 48rpx 16rpx 150rpx 16rpx;
  397. color: white;
  398. letter-spacing: 2rpx;
  399. text-indent: 2rpx;
  400. }
  401. .zcBtn {
  402. background: #FE8643;
  403. }
  404. .tjBtn {
  405. background: #0365F9;
  406. }
  407. }
  408. }
  409. </style>