addSchedule.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469
  1. <template>
  2. <view class="content">
  3. <view class="inner">
  4. <view class="time-box">
  5. <view class="time">
  6. {{toDay}}
  7. </view>
  8. <view class="txt">今日待办</view>
  9. <view class="num">{{num}}</view>
  10. </view>
  11. <view class="form-box">
  12. <text class="form-title">开始时间</text>
  13. <view class="form-item">
  14. <view class="birth-picker" >
  15. <view class="right-box" @click="open()">
  16. <!-- <input type="text" :value="form.itineraryDate+' '+form.itineraryTime" placeholder="请选择日程开始时间"
  17. placeholder-class="form-input" disabled="disabled" /> -->
  18. <text v-if="form.itineraryDate" class="color222" >{{ form.itineraryDate+' '+form.itineraryTime }}</text>
  19. <text v-else >请选择日程开始时间</text>
  20. <image class="w48 h48" src="/static/images/health/right_arrow_right_icon24.png"></image>
  21. </view>
  22. <u-datetime-picker :show="show" v-model="newData" mode="datetime"
  23. @confirm="bindDateChange"></u-datetime-picker>
  24. </view>
  25. <!-- <picker class="birth-picker" mode="date" @change="bindDateChange">
  26. <view class="right-box">
  27. <view class="input-box">
  28. <input type="text" :value="form.itineraryDate" placeholder="请选择日程开始时间" placeholder-class="form-input" disabled="disabled" />
  29. </view>
  30. </view>
  31. </picker> -->
  32. </view>
  33. <text class="form-title">日程安排</text>
  34. <view class="form-item">
  35. <textarea maxlength="200" class="form-textarea" v-model="form.itinerary" placeholder="请输入您的日程安排"
  36. placeholder-class="form-input" />
  37. </view>
  38. </view>
  39. </view>
  40. <view class="btn-box">
  41. <view class="sub-btn" @click="submit()">
  42. 保存
  43. </view>
  44. </view>
  45. </view>
  46. </template>
  47. <script>
  48. import {
  49. getItineraryInfo,
  50. addItinerary,
  51. updateItinerary
  52. } from '@/api/companyUser.js'
  53. export default {
  54. data() {
  55. return {
  56. newData:new Date(),
  57. toDay: this.utils.timeFormat(new Date(), 'yyyy年mm月dd日'),
  58. type: null,
  59. show: false,
  60. patientId: null,
  61. famaleurl: "/static/images/health/female_profile.png",
  62. maleurl: "/static/images/health/my_heads.png",
  63. checked: 1,
  64. array: ['是', '否'],
  65. tags: [{
  66. name: '心脏病',
  67. checked: true,
  68. id: 1
  69. },
  70. {
  71. name: '脑梗死',
  72. checked: false,
  73. id: 2
  74. }, {
  75. name: '肾病',
  76. checked: false,
  77. id: 3
  78. }, {
  79. name: '脂肪肝',
  80. checked: false,
  81. id: 4
  82. }
  83. ],
  84. num: 0,
  85. form: {}
  86. };
  87. },
  88. onLoad(option) {
  89. this.type = option.type;
  90. this.form.userId = option.userId
  91. console.log(this.type)
  92. if (this.type == 'edit') {
  93. uni.setNavigationBarTitle({
  94. title: '编辑日程' // Replace with your desired title
  95. });
  96. this.id = option.id
  97. this.form.id = option.id
  98. this.userId = option.userId;
  99. this.getItineraryInfo();
  100. }
  101. },
  102. methods: {
  103. sexChange(type) {
  104. this.form.sex = type
  105. },
  106. open() {
  107. this.show =!this.show
  108. },
  109. close(){
  110. this.show=false
  111. },
  112. radioClick(item) {
  113. this.checked = item.id
  114. },
  115. getItineraryInfo() {
  116. var data = {
  117. id: this.id
  118. };
  119. getItineraryInfo(data).then(
  120. res => {
  121. if (res.code == 200) {
  122. this.form = res.data;
  123. } else {
  124. uni.showToast({
  125. title: res.msg,
  126. });
  127. }
  128. },
  129. rej => {}
  130. );
  131. },
  132. onChooseAvatar(e) {
  133. let {
  134. avatarUrl
  135. } = e.detail;
  136. uni.uploadFile({
  137. url: uni.getStorageSync('requestPath') + '/app/common/uploadOSS', //仅为示例,非真实的接口地址
  138. filePath: avatarUrl,
  139. name: 'file',
  140. formData: {
  141. 'user': 'test' // 上传附带参数
  142. },
  143. success: (uploadFileRes) => {
  144. this.user.avatar = JSON.parse(uploadFileRes.data).url
  145. }
  146. });
  147. },
  148. submit() {
  149. if (this.form.itineraryDate == null || this.form.itineraryDate =='') {
  150. uni.showToast({
  151. icon: 'none',
  152. title: "行程日期不能为空",
  153. });
  154. return;
  155. }
  156. if (this.form.itineraryTime == null|| this.form.itineraryTime =='') {
  157. uni.showToast({
  158. icon: 'none',
  159. title: "行程时间不能为空",
  160. });
  161. return;
  162. }
  163. if (this.form.itinerary == null || this.form.itinerary =='') {
  164. uni.showToast({
  165. icon: 'none',
  166. title: "行程内容不能为空",
  167. });
  168. return;
  169. }
  170. // if (this.form.birthday == null) {
  171. // uni.showToast({
  172. // icon: 'none',
  173. // title: "出生年月不能为空",
  174. // });
  175. // return;
  176. // }
  177. if (this.type == "add") {
  178. this.addItinerary()
  179. } else if (this.type == "edit") {
  180. this.updateItinerary()
  181. }
  182. },
  183. updateItinerary() {
  184. updateItinerary(this.form).then(
  185. res => {
  186. if (res.code == 200) {
  187. uni.showToast({
  188. icon: 'success',
  189. title: "更新成功",
  190. });
  191. setTimeout(function() {
  192. uni.$emit('refreshSchedule');
  193. uni.navigateBack({
  194. delta: 1
  195. })
  196. }, 500);
  197. } else {
  198. uni.showToast({
  199. icon: 'none',
  200. title: res.msg,
  201. });
  202. }
  203. },
  204. rej => {}
  205. );
  206. },
  207. addItinerary() {
  208. addItinerary(this.form).then(
  209. res => {
  210. if (res.code == 200) {
  211. uni.showToast({
  212. icon: 'success',
  213. title: "操作成功",
  214. });
  215. setTimeout(function() {
  216. uni.$emit('refreshSchedule');
  217. uni.navigateBack({
  218. delta: 1
  219. })
  220. }, 500);
  221. } else {
  222. uni.showToast({
  223. icon: 'none',
  224. title: res.msg,
  225. });
  226. }
  227. },
  228. rej => {}
  229. );
  230. },
  231. // 出生日期选择
  232. bindDateChange: function(e) {
  233. this.form.itineraryDate = this.utils.timeFormat(e.value,'yyyy-mm-dd')
  234. this.form.itineraryTime = this.utils.timeFormat(e.value,'hh:MM:ss')
  235. this.show=false
  236. },
  237. }
  238. }
  239. </script>
  240. <style lang="scss">
  241. page {
  242. height: 100%;
  243. }
  244. .content {
  245. height: 100%;
  246. display: flex;
  247. flex-direction: column;
  248. justify-content: space-between;
  249. .inner {
  250. // height: calc(100% - 120upx);
  251. // padding: 20upx;
  252. background: #008FD3;
  253. .time-box {
  254. padding: 30rpx;
  255. text-align: left;
  256. .time {
  257. font-family: PingFang SC;
  258. font-weight: 500;
  259. font-size: 28rpx;
  260. color: #FFFFFF;
  261. padding-bottom: 25rpx;
  262. }
  263. .txt {
  264. font-weight: 500;
  265. font-size: 24rpx;
  266. color: rgba(255, 255, 255, 0.5);
  267. padding-bottom: 12rpx;
  268. }
  269. .num {
  270. font-family: Roboto, Roboto;
  271. font-weight: 500;
  272. font-size: 64rpx;
  273. color: #FFFFFF;
  274. }
  275. }
  276. .form-box {
  277. padding: 0 30upx;
  278. background: #FFFFFF;
  279. border-radius: 32upx;
  280. margin-bottom: -40upx;
  281. .form-title {
  282. font-family: PingFang SC;
  283. font-weight: 600;
  284. font-size: 36rpx;
  285. color: #222426;
  286. text-align: left;
  287. padding: 30rpx 0;
  288. display: block;
  289. }
  290. .form-item {
  291. padding: 30upx 0;
  292. display: flex;
  293. align-items: flex-start;
  294. border-bottom: 1px solid #F1F1F1;
  295. &:last-child {
  296. border-bottom: none;
  297. }
  298. .label {
  299. width: 300upx;
  300. text-align: left;
  301. font-size: 32upx;
  302. line-height: 44upx;
  303. font-family: PingFang SC;
  304. font-weight: 500;
  305. color: #222222;
  306. flex-shrink: 0;
  307. }
  308. input {
  309. text-align: left;
  310. }
  311. .form-input {
  312. font-size: 30upx;
  313. font-family: PingFang SC;
  314. // font-weight: 500;
  315. color: #B2B2B2;
  316. text-align: left;
  317. }
  318. .form-item-tag {
  319. margin-right: 16rpx;
  320. .tag {
  321. border-radius: 8rpx 8rpx 8rpx 8rpx;
  322. border: 2rpx solid #ECECEC;
  323. display: flex;
  324. align-items: center;
  325. padding: 24rpx;
  326. font-family: PingFang SC;
  327. font-weight: 400;
  328. font-size: 24rpx;
  329. &.active {
  330. background: #F0FAFF;
  331. border: 2rpx solid #008FD3;
  332. color: #008FD3;
  333. }
  334. }
  335. }
  336. .right {
  337. display: flex;
  338. align-items: center;
  339. }
  340. .sex-box {
  341. flex: 1;
  342. display: flex;
  343. align-items: center;
  344. justify-content: flex-end;
  345. .sex-item {
  346. width: 146rpx;
  347. height: 64rpx;
  348. display: flex;
  349. align-items: center;
  350. justify-content: center;
  351. background: #F5F7FA;
  352. border-radius: 32rpx 32rpx 32rpx 32rpx;
  353. margin-left: 16rpx;
  354. .u-icon__icon {
  355. margin: 0;
  356. }
  357. text {
  358. // font-family: PingFang SC, PingFang SC;
  359. font-weight: 400;
  360. font-size: 28rpx;
  361. color: #898E91;
  362. margin-left: 12rpx;
  363. }
  364. &.active {
  365. background: #FCF0E7;
  366. text {
  367. color: #FF5030
  368. }
  369. }
  370. }
  371. }
  372. .form-textarea {
  373. font-size: 30upx;
  374. color: #999999;
  375. height: 100upx;
  376. padding: 4upx 0;
  377. }
  378. .birth-picker {
  379. width: 100%;
  380. .right-box {
  381. width: 100%;
  382. display: flex;
  383. align-items: center;
  384. justify-content: space-between;
  385. .input-box {
  386. flex: 1;
  387. // width: 470upx;
  388. }
  389. text{
  390. font-size: 30upx;
  391. color: #999999;
  392. }
  393. .arrow {
  394. width: 13upx;
  395. height: 23upx;
  396. margin-left: 20upx;
  397. }
  398. }
  399. }
  400. }
  401. }
  402. }
  403. .btn-box {
  404. height: 120upx;
  405. padding: 0 30upx;
  406. display: flex;
  407. align-items: center;
  408. justify-content: center;
  409. .sub-btn {
  410. width: 100%;
  411. height: 88upx;
  412. line-height: 88upx;
  413. text-align: center;
  414. font-size: 32upx;
  415. font-family: PingFang SC;
  416. font-weight: bold;
  417. color: #FFFFFF;
  418. background: #008FD3;
  419. border-radius: 44upx;
  420. margin-bottom: 40upx;
  421. display: flex;
  422. align-items: center;
  423. justify-content: center;
  424. image {
  425. margin-right: 16rpx;
  426. }
  427. }
  428. }
  429. }
  430. </style>