edit.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428
  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" v-if="form.state == '1'">
  74. <button class="btn zcBtn" @click="meetingAppointSubmit('1')">暂存</button>
  75. <button class="btn tjBtn" @click="meetingAppointSubmit('6')">提交</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, meetingAppointDetail, meetingAppointCheck, meetingAppointEdit} from "@/js_sdk/http";
  107. import dayjs from "dayjs";
  108. export default {
  109. name: "edit",
  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. id: '',
  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.id = options.id
  138. this.getById()
  139. },
  140. onShow() {
  141. },
  142. methods: {
  143. async getByCodes() {
  144. let data = await getByCodes(JSON.stringify(this.dc_key));
  145. this.dic_SelectList = this.$common.handleDicList(data);
  146. this.timeList = this.dic_SelectList.timeSlot
  147. console.log('this.timeList', this.timeList)
  148. },
  149. showTime(e) {
  150. this.timePickerType = e
  151. this.timeShow = true
  152. },
  153. showTimeList(e) {
  154. this.timePickerType = e
  155. this.timeListShow = true
  156. },
  157. // 时间戳转换方法
  158. timestampToDate(timestamp) {
  159. const date = new Date(timestamp); // 如果timestamp是字符串,确保它是整数:parseInt(timestamp)
  160. const year = date.getFullYear();
  161. const month = (date.getMonth() + 1).toString().padStart(2, '0');
  162. const day = date.getDate().toString().padStart(2, '0');
  163. const hours = date.getHours().toString().padStart(2, '0');
  164. const minutes = date.getMinutes().toString().padStart(2, '0');
  165. const seconds = date.getSeconds().toString().padStart(2, '0');
  166. return `${year}-${month}-${day}`;
  167. },
  168. // 时间选择单位
  169. formatter(type, val) {
  170. if (type === 'year') {
  171. return `${val}年`;
  172. } else if (type === 'month') {
  173. return `${val}月`;
  174. } else if (type === 'day') {
  175. return `${val}日`;
  176. } else if (type === 'hour') {
  177. return `${val}时`;
  178. } else if (type === 'minute') {
  179. return `${val}分`;
  180. }
  181. return val;
  182. },
  183. selectTime(e) {
  184. const dateString = this.timestampToDate(e.detail);
  185. this.startTime = dateString
  186. this.timeShow = false
  187. // this.getRoomTime(this.startTime)
  188. },
  189. selectTimeList(e) {
  190. const data = {
  191. id: this.meetingRoomId,
  192. dateStr: this.startTime,
  193. timeSlot: e.detail.value.value
  194. }
  195. meetingAppointCheck(data).then((res) => {
  196. if (res.code == '200') {
  197. this.timeListStr = e.detail.value.label
  198. this.form.timeSlot = e.detail.value.value
  199. this.timeListShow = false
  200. } else {
  201. this.$showToast("时间段已占用或已冻结,请重新选择");
  202. }
  203. }).catch(err => {
  204. this.$showToast(err);
  205. })
  206. },
  207. changeMsg(e){
  208. this.form.remarks = e.detail
  209. },
  210. getById(){
  211. const data = {
  212. id: this.id
  213. }
  214. meetingAppointDetail(data).then(res=>{
  215. if(res.code == '200'){
  216. this.form = res.data.oderDetial
  217. this.startTime = this.form.useTime
  218. let index = this.timeList.findIndex((e) => e.value == this.form.timeSlot)
  219. this.timeListStr = this.timeList[index].label
  220. }
  221. })
  222. },
  223. // 编辑预约
  224. meetingAppointSubmit(e) {
  225. if (this.startTime !== '' && this.startTime !== null && this.startTime !== undefined &&
  226. this.endTime !== '' && this.endTime !== null && this.endTime !== undefined) {
  227. uni.showToast({
  228. title: "请选择使用时间",
  229. });
  230. return false
  231. }
  232. this.form.state = e
  233. this.form.useTime = this.startTime
  234. console.log('提交预约_:', this.form)
  235. meetingAppointEdit(this.form).then((res) => {
  236. console.log('提交预约_:', res)
  237. if (res.code == '200') {
  238. uni.showToast({
  239. title: '预约成功',
  240. icon: 'success',
  241. mask: true,
  242. duration: 1000
  243. });
  244. let pages = getCurrentPages(); // 获取当前页面栈的实例,以数组形式按栈的顺序给出,第一个元素为首页,最后一个元素为当前页面。
  245. let nowPage = pages[pages.length - 1]; //当前页页面实例
  246. let prevPage = pages[pages.length - 2]; //上一页页面实例
  247. prevPage.$vm.otherFun("back")// 給上一頁綁定方法otherFun,傳參object
  248. uni.navigateBack({
  249. delta:1 // 可以不傳delta值,默認為1
  250. })
  251. } else {
  252. uni.showToast({
  253. title: res.msg,
  254. icon: 'success',
  255. mask: true,
  256. duration: 1000
  257. });
  258. }
  259. })
  260. },
  261. }
  262. }
  263. </script>
  264. <style lang="scss">
  265. .resourceAdd {
  266. .topBox {
  267. padding: 24rpx 32rpx;
  268. background: white;
  269. margin: 24rpx 0;
  270. .topTitle {
  271. color: rgba(34, 34, 34, 1);
  272. font-size: 36rpx;
  273. font-weight: 600;
  274. }
  275. .choosTimeBox {
  276. display: flex;
  277. justify-content: space-between;
  278. align-items: center;
  279. .msg {
  280. color: rgba(51, 51, 51, 1);
  281. font-size: 32rpx;
  282. white-space: nowrap;
  283. }
  284. .choosIpt {
  285. display: flex;
  286. align-items: center;
  287. justify-content: center;
  288. width: 260rpx;
  289. height: 96rpx;
  290. font-size: 32rpx;
  291. background: rgba(245, 247, 250, 1);
  292. box-sizing: border-box;
  293. }
  294. }
  295. }
  296. .predetermineUl {
  297. margin: 24rpx 0;
  298. background: white;
  299. box-sizing: border-box;
  300. padding: 0 32rpx;
  301. .predetermineLi {
  302. padding: 32rpx 0;
  303. border-bottom: 1px solid rgba(230, 230, 230, 1);
  304. display: flex;
  305. justify-content: space-between;
  306. }
  307. .predetermineLi2 {
  308. padding: 32rpx 0;
  309. border-bottom: 1px solid rgba(230, 230, 230, 1);
  310. display: flex;
  311. flex-direction: column;
  312. }
  313. .van-cell {
  314. background: #F5F7FA !important;
  315. border-radius: 8rpx;
  316. font-size: 28rpx;
  317. margin-top: 16rpx;
  318. }
  319. .liName {
  320. color: rgba(51, 51, 51, 1);
  321. font-size: 32rpx;
  322. }
  323. .liIpt {
  324. color: rgba(102, 102, 102, 1);
  325. font-size: 32rpx;
  326. text-align: right;
  327. }
  328. .detailLi {
  329. display: flex;
  330. justify-content: space-between;
  331. align-items: center;
  332. padding: 32rpx 0;
  333. border-bottom: 2rpx solid #E6E6E6;
  334. .liInfo {
  335. display: inline-block;
  336. text-align: right;
  337. max-width: 488rpx;
  338. width: 488rpx;
  339. color: rgba(102, 102, 102, 1);
  340. font-size: 32rpx;
  341. line-height: 38rpx;
  342. .radio {
  343. margin-left: 64rpx;
  344. }
  345. }
  346. }
  347. .detailLi2 {
  348. display: flex;
  349. flex-direction: column;
  350. padding: 32rpx 0;
  351. border-bottom: 2rpx solid #E6E6E6;
  352. .detailLi2BoxTop {
  353. display: flex;
  354. flex-wrap: wrap;
  355. justify-content: space-between;
  356. margin: 12rpx 0;
  357. .checkItem {
  358. width: 128rpx;
  359. height: 64rpx;
  360. font-size: 28rpx;
  361. color: #666666;
  362. display: flex;
  363. align-items: center;
  364. justify-content: center;
  365. background: #F5F7FA;
  366. border-radius: 8rpx;
  367. margin: 12rpx 0;
  368. }
  369. .checked {
  370. background: #0365F9;
  371. color: white;
  372. }
  373. }
  374. }
  375. }
  376. .buttonBox {
  377. display: flex;
  378. justify-content: center;
  379. .btn {
  380. width: 240rpx;
  381. height: 80rpx;
  382. display: flex;
  383. border-radius: 8rpx;
  384. align-items: center;
  385. justify-content: center;
  386. margin: 48rpx 16rpx 150rpx 16rpx;
  387. color: white;
  388. letter-spacing: 2rpx;
  389. text-indent: 2rpx;
  390. }
  391. .zcBtn {
  392. background: #FE8643;
  393. }
  394. .tjBtn {
  395. background: #0365F9;
  396. }
  397. }
  398. }
  399. </style>