schedule.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391
  1. <template>
  2. <view class="content">
  3. <ren-calendar ref='ren' :markDays='markDays' :headerBar='false' @onDayClick='onDayClick'></ren-calendar>
  4. <view class="inner">
  5. <view class="title-box align-center">
  6. <text>我的行程</text>
  7. <view class="num">{{num}}</view>
  8. </view>
  9. <view class="form-box">
  10. <u-swipe-action>
  11. <view class="form-swipe mb20" v-for="(item,index) in dataList" :key="index">
  12. <u-swipe-action-item :options="options" @click="action($event, item.id, index)" :name="index" :ref="'swipeAction' + index">
  13. <view class="form-item" @click.stop="showDetail(item)">
  14. <view class="left">
  15. <text class="label">{{item.mark}}</text>
  16. <text class="time">{{item.itineraryTime}}</text>
  17. </view>
  18. <view class="right">
  19. <view>{{item.itinerary}}</view>
  20. </view>
  21. </view>
  22. </u-swipe-action-item>
  23. </view>
  24. </u-swipe-action>
  25. </view>
  26. <view class="btn-box">
  27. <view class="sub-btn" @click="addSchedule()">
  28. <image class="w32 h32" src="@/static/images/company/add_icon.png"></image>
  29. <text>添加日程</text>
  30. </view>
  31. </view>
  32. </view>
  33. </view>
  34. </template>
  35. <script>
  36. import RenCalendar from '@/components/ren-calendar/ren-calendar.vue'
  37. import {
  38. getItinerary,deleteItinerary
  39. } from '@/api/companyUser.js'
  40. import parse from '../../uni_modules/uview-ui/libs/config/props/parse';
  41. export default {
  42. components:{
  43. RenCalendar
  44. },
  45. data() {
  46. return {
  47. options: [{
  48. text: '修改',
  49. style: {
  50. backgroundColor: '#008FD3'
  51. }
  52. }, {
  53. text: '删除',
  54. style: {
  55. backgroundColor: '#FF5030'
  56. }
  57. }],
  58. curDate:this.utils.timeFormat(new Date(), 'yyyy-mm-dd'),
  59. markDays:[],
  60. type: null,
  61. patientId: null,
  62. famaleurl:"/static/images/health/female_profile.png",
  63. maleurl:"/static/images/health/my_heads.png",
  64. checked:1,
  65. dataList:[
  66. // {id:1,time:'09:00',content:'酒店登记入驻,记得检查马桶卫生和柏子是否干净'},
  67. // {id:2,time:'09:00',content:'收拾好行李,准备去医院'},
  68. // {id:3,time:'16:30',content:'酒店登记入驻,记得检查马桶卫生和柏子是否干净'},
  69. ],
  70. form: {
  71. userName: null,
  72. idCard: null,
  73. sex: null,
  74. birthday: null,
  75. remark: null,
  76. },
  77. user:null,
  78. num:0
  79. };
  80. },
  81. onLoad(option) {
  82. // this.user=JSON.parse( uni.getStorageSync('userInfo'))
  83. this.userId=option.userId
  84. this.getItinerary()
  85. uni.$on('refreshSchedule', () => {
  86. this.getItinerary()
  87. })
  88. },
  89. methods: {
  90. //日历
  91. onDayClick(data){
  92. console.log(data,'00')
  93. this.curDate = data.date;
  94. this.getItinerary()
  95. },
  96. action(event, id, index){
  97. var that=this;
  98. let test = 'swipeAction' + index
  99. if(event.index==0){
  100. uni.navigateTo({
  101. url: '/pages_user/user/addSchedule?type=edit&userId='+this.userId+'&id='+id
  102. })
  103. }else{
  104. uni.showModal({
  105. title: '提示',
  106. content: '确定删除记录吗',
  107. success: function (res) {
  108. if (res.confirm) {
  109. var data = {
  110. id:id
  111. };
  112. deleteItinerary(data).then(res => {
  113. if(res.code==200){
  114. uni.showToast({
  115. icon:'success',
  116. title: '删除成功!',
  117. });
  118. that.$refs[test][0].closeHandler()
  119. that.getItinerary()
  120. }else{
  121. uni.showToast({
  122. icon:'none',
  123. title: res.msg,
  124. });
  125. }
  126. });
  127. }
  128. else if (res.cancel) {
  129. that.$refs[test][0].closeHandler()
  130. }
  131. }
  132. });
  133. }
  134. },
  135. addSchedule(){
  136. uni.navigateTo({
  137. url: '/pages_user/user/addSchedule?type=add&userId='+this.userId
  138. })
  139. },
  140. showDetail(item){
  141. uni.navigateTo({
  142. url: '/pages_user/user/addSchedule?type=edit&userId='+this.userId+'&id='+item.id
  143. })
  144. },
  145. getItinerary() {
  146. var data = {
  147. userId: this.userId,
  148. itineraryDate:this.curDate
  149. };
  150. getItinerary(data).then(
  151. res => {
  152. if (res.code == 200) {
  153. this.dataList = res.data.list;
  154. this.num=res.data.total;
  155. } else {
  156. uni.showToast({
  157. title: res.msg,
  158. });
  159. }
  160. },
  161. rej => {}
  162. );
  163. },
  164. submit() {
  165. if (this.form.userName == null) {
  166. uni.showToast({
  167. icon: 'none',
  168. title: "姓名不能为空",
  169. });
  170. return;
  171. }
  172. if (this.form.idCard == null) {
  173. uni.showToast({
  174. icon: 'none',
  175. title: "身份证号不能为空",
  176. });
  177. return;
  178. }
  179. if (this.form.sex == null) {
  180. uni.showToast({
  181. icon: 'none',
  182. title: "性别不能为空",
  183. });
  184. return;
  185. }
  186. if (this.form.birthday == null) {
  187. uni.showToast({
  188. icon: 'none',
  189. title: "出生年月不能为空",
  190. });
  191. return;
  192. }
  193. if (this.type == "add") {
  194. this.addDoc()
  195. } else if (this.type == "edit") {
  196. this.editDoc()
  197. }
  198. },
  199. editDoc() {
  200. editDoc(this.form).then(
  201. res => {
  202. if (res.code == 200) {
  203. uni.showToast({
  204. icon: 'success',
  205. title: "操作成功",
  206. });
  207. setTimeout(function() {
  208. uni.$emit('refreshDoc');
  209. uni.navigateBack({
  210. delta: 1
  211. })
  212. }, 500);
  213. } else {
  214. uni.showToast({
  215. icon: 'none',
  216. title: res.msg,
  217. });
  218. }
  219. },
  220. rej => {}
  221. );
  222. },
  223. addDoc() {
  224. addDoc(this.form).then(
  225. res => {
  226. if (res.code == 200) {
  227. uni.showToast({
  228. icon: 'success',
  229. title: "操作成功",
  230. });
  231. setTimeout(function() {
  232. uni.$emit('refreshDoc');
  233. uni.navigateBack({
  234. delta: 1
  235. })
  236. }, 500);
  237. } else {
  238. uni.showToast({
  239. icon: 'none',
  240. title: res.msg,
  241. });
  242. }
  243. },
  244. rej => {}
  245. );
  246. },
  247. // 出生日期选择
  248. bindDateChange: function(e) {
  249. this.form.birthday = e.target.value
  250. },
  251. }
  252. }
  253. </script>
  254. <style lang="scss">
  255. page {
  256. height: 100%;
  257. background: #FFFFFF;
  258. }
  259. .u-swipe-action-item__right__button__wrapper__text{
  260. font-size: 28rpx !important;
  261. line-height: 28rpx !important;
  262. }
  263. .content {
  264. height: 100%;
  265. // display: flex;
  266. // flex-direction: column;
  267. // justify-content: space-between;
  268. .inner {
  269. // height: calc(100% - 120upx);
  270. padding:30upx;
  271. background: #FFFFFF;
  272. border-radius:16rpx 16rpx 16rpx 16rpx;
  273. margin-top:-20rpx;
  274. position: relative;
  275. .title-box{
  276. text{
  277. font-family: PingFang SC, PingFang SC;
  278. font-weight: 600;
  279. font-size: 36rpx;
  280. color: #222426;
  281. padding: 24rpx 0;
  282. }
  283. .num{
  284. font-weight: 500;
  285. font-size: 28rpx;
  286. color: #898E91;
  287. }
  288. }
  289. .select-box2{
  290. width: 216rpx;
  291. height: 64rpx;
  292. background: #FFFFFF;
  293. border-radius: 32rpx 32rpx 32rpx 32rpx;
  294. display: flex;
  295. align-items: center;
  296. justify-content: center;
  297. text{
  298. font-family: PingFang SC;
  299. font-weight: 400;
  300. font-size: 24rpx;
  301. color: #626468;
  302. margin-left: 5rpx;
  303. }
  304. }
  305. }
  306. .form-box {
  307. // padding:30upx;
  308. // background: #FFFFFF;
  309. // border-radius: 16upx;
  310. .form-swipe{
  311. overflow: hidden;
  312. border-radius: 16rpx 16rpx 16rpx 16rpx;
  313. }
  314. .form-item {
  315. padding: 30upx;
  316. display: flex;
  317. align-items: center;
  318. // justify-content: space-between;
  319. background: #F5F7FA;
  320. .left{
  321. display: flex;
  322. flex-direction: column;
  323. align-items: center;
  324. padding-right: 30rpx;
  325. border-right: 1px solid #CCCCCC;
  326. .label{
  327. font-weight: 400;
  328. font-size: 24rpx;
  329. color: #626468;
  330. }
  331. .time{
  332. font-family: PingFang SC;
  333. font-weight: 500;
  334. font-size: 48rpx;
  335. }
  336. }
  337. .right{
  338. padding-left: 30rpx;
  339. view{
  340. font-weight: 400;
  341. font-size: 24rpx;
  342. color: #222426;
  343. text-align: left;
  344. }
  345. }
  346. }
  347. }
  348. .btn-box {
  349. // display: flex;
  350. // align-items: center;
  351. // justify-content: center;
  352. position: fixed;
  353. right: 20rpx;
  354. bottom: 20%;
  355. z-index: 999;
  356. // transform: translate(-50%,-50%);
  357. // background: #FFFFFF;
  358. .sub-btn {
  359. display: flex;
  360. align-items: center;
  361. justify-content: center;
  362. width: 192rpx;
  363. height: 80rpx;
  364. background: #008FD3;
  365. box-shadow: 0rpx 6rpx 10rpx 0rpx rgba(0,143,211,0.2);
  366. border-radius: 40rpx 40rpx 40rpx 40rpx;
  367. text{
  368. color: #fff;
  369. font-family: PingFang SC;
  370. font-weight: 500;
  371. font-size: 28rpx;
  372. color: #FFFFFF;
  373. }
  374. }
  375. }
  376. }
  377. </style>