edit.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429
  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. console.log('form.appointTime', this.form.appointTime)
  221. }
  222. })
  223. },
  224. // 编辑预约
  225. meetingAppointSubmit(e) {
  226. if (this.startTime !== '' && this.startTime !== null && this.startTime !== undefined &&
  227. this.endTime !== '' && this.endTime !== null && this.endTime !== undefined) {
  228. uni.showToast({
  229. title: "请选择使用时间",
  230. });
  231. return false
  232. }
  233. this.form.state = e
  234. this.form.useTime = this.startTime
  235. console.log('提交预约_:', this.form)
  236. meetingAppointEdit(this.form).then((res) => {
  237. console.log('提交预约_:', res)
  238. if (res.code == '200') {
  239. uni.showToast({
  240. title: '预约成功',
  241. icon: 'success',
  242. mask: true,
  243. duration: 1000
  244. });
  245. let pages = getCurrentPages(); // 获取当前页面栈的实例,以数组形式按栈的顺序给出,第一个元素为首页,最后一个元素为当前页面。
  246. let nowPage = pages[pages.length - 1]; //当前页页面实例
  247. let prevPage = pages[pages.length - 2]; //上一页页面实例
  248. prevPage.$vm.otherFun("back")// 給上一頁綁定方法otherFun,傳參object
  249. uni.navigateBack({
  250. delta:1 // 可以不傳delta值,默認為1
  251. })
  252. } else {
  253. uni.showToast({
  254. title: res.msg,
  255. icon: 'success',
  256. mask: true,
  257. duration: 1000
  258. });
  259. }
  260. })
  261. },
  262. }
  263. }
  264. </script>
  265. <style lang="scss">
  266. .resourceAdd {
  267. .topBox {
  268. padding: 24rpx 32rpx;
  269. background: white;
  270. margin: 24rpx 0;
  271. .topTitle {
  272. color: rgba(34, 34, 34, 1);
  273. font-size: 36rpx;
  274. font-weight: 600;
  275. }
  276. .choosTimeBox {
  277. display: flex;
  278. justify-content: space-between;
  279. align-items: center;
  280. .msg {
  281. color: rgba(51, 51, 51, 1);
  282. font-size: 32rpx;
  283. white-space: nowrap;
  284. }
  285. .choosIpt {
  286. display: flex;
  287. align-items: center;
  288. justify-content: center;
  289. width: 260rpx;
  290. height: 96rpx;
  291. font-size: 32rpx;
  292. background: rgba(245, 247, 250, 1);
  293. box-sizing: border-box;
  294. }
  295. }
  296. }
  297. .predetermineUl {
  298. margin: 24rpx 0;
  299. background: white;
  300. box-sizing: border-box;
  301. padding: 0 32rpx;
  302. .predetermineLi {
  303. padding: 32rpx 0;
  304. border-bottom: 1px solid rgba(230, 230, 230, 1);
  305. display: flex;
  306. justify-content: space-between;
  307. }
  308. .predetermineLi2 {
  309. padding: 32rpx 0;
  310. border-bottom: 1px solid rgba(230, 230, 230, 1);
  311. display: flex;
  312. flex-direction: column;
  313. }
  314. .van-cell {
  315. background: #F5F7FA !important;
  316. border-radius: 8rpx;
  317. font-size: 28rpx;
  318. margin-top: 16rpx;
  319. }
  320. .liName {
  321. color: rgba(51, 51, 51, 1);
  322. font-size: 32rpx;
  323. }
  324. .liIpt {
  325. color: rgba(102, 102, 102, 1);
  326. font-size: 32rpx;
  327. text-align: right;
  328. }
  329. .detailLi {
  330. display: flex;
  331. justify-content: space-between;
  332. align-items: center;
  333. padding: 32rpx 0;
  334. border-bottom: 2rpx solid #E6E6E6;
  335. .liInfo {
  336. display: inline-block;
  337. text-align: right;
  338. max-width: 488rpx;
  339. width: 488rpx;
  340. color: rgba(102, 102, 102, 1);
  341. font-size: 32rpx;
  342. line-height: 38rpx;
  343. .radio {
  344. margin-left: 64rpx;
  345. }
  346. }
  347. }
  348. .detailLi2 {
  349. display: flex;
  350. flex-direction: column;
  351. padding: 32rpx 0;
  352. border-bottom: 2rpx solid #E6E6E6;
  353. .detailLi2BoxTop {
  354. display: flex;
  355. flex-wrap: wrap;
  356. justify-content: space-between;
  357. margin: 12rpx 0;
  358. .checkItem {
  359. width: 128rpx;
  360. height: 64rpx;
  361. font-size: 28rpx;
  362. color: #666666;
  363. display: flex;
  364. align-items: center;
  365. justify-content: center;
  366. background: #F5F7FA;
  367. border-radius: 8rpx;
  368. margin: 12rpx 0;
  369. }
  370. .checked {
  371. background: #0365F9;
  372. color: white;
  373. }
  374. }
  375. }
  376. }
  377. .buttonBox {
  378. display: flex;
  379. justify-content: center;
  380. .btn {
  381. width: 240rpx;
  382. height: 80rpx;
  383. display: flex;
  384. border-radius: 8rpx;
  385. align-items: center;
  386. justify-content: center;
  387. margin: 48rpx 16rpx 150rpx 16rpx;
  388. color: white;
  389. letter-spacing: 2rpx;
  390. text-indent: 2rpx;
  391. }
  392. .zcBtn {
  393. background: #FE8643;
  394. }
  395. .tjBtn {
  396. background: #0365F9;
  397. }
  398. }
  399. }
  400. </style>