mangshi.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. <template>
  2. <view class="mangshi">
  3. <view class="timeView">
  4. <its-calendar :sta_num="0" :end_num="24" :int_num="msTimeDate" @getTime="TimeData" @getDate="SelData">
  5. </its-calendar>
  6. <view class="dx_view margin-bottom-sm" v-if="msList.length > 0">
  7. <view class="dx_title">忙时时间</view>
  8. <view class="flex align-center flex-wrap ">
  9. <view v-for="(item,index) in msList" class="btn flex align-center margin-top">
  10. <view>{{item}}</view>
  11. <view class="margin-left-sm" @tap.stop="bindupdata(index,item)">x</view>
  12. </view>
  13. </view>
  14. </view>
  15. <view class="sub" @click="sub()">
  16. 保存选择
  17. </view>
  18. </view>
  19. </view>
  20. </template>
  21. <script>
  22. import itsCalendar from '@/components/its-calendar/its-calendar.vue';
  23. export default {
  24. components: {
  25. itsCalendar
  26. },
  27. data() {
  28. return {
  29. msTimeDate: 0,
  30. newmsList: [],
  31. msList: [],
  32. startTime: '',
  33. yearsDate: '',
  34. }
  35. },
  36. onLoad() {
  37. if (this.$queue.getData('msTimeDate')) {
  38. this.msTimeDate = parseInt(this.$queue.getData('msTimeDate'));
  39. } else {
  40. this.msTimeDate = 60;
  41. }
  42. var date = new Date();
  43. var year = date.getFullYear();
  44. let month = (parseInt(date.getMonth()) + 1) > 9 ? (parseInt(date.getMonth()) + 1) : "0" + (parseInt(
  45. date.getMonth()) + 1) // 当前月份
  46. let days = (date.getDate()) > 9 ? date.getDate() : "0" + date.getDate() //当前日期
  47. let fullDate = `${month}-${days}`
  48. let Time = year + '-' + fullDate
  49. this.yearsDate = Time;
  50. this.getMsTime(Time);
  51. },
  52. methods: {
  53. sub() {
  54. // if (this.msList.length == 0) {
  55. if(this.yearsDate === ''){
  56. this.$queue.showToast('请先添加待选时间!');
  57. return;
  58. }
  59. uni.showModal({
  60. title: '温馨提示',
  61. content: '是否将待选区的时间设置为忙时?',
  62. showCancel: true,
  63. cancelText: '取消',
  64. confirmText: '确认',
  65. confirmColor:'#1EDA94',
  66. success: res => {
  67. if (res.confirm) {
  68. this.saveMangShi();
  69. }
  70. }
  71. });
  72. },
  73. //删除规格
  74. bindupdata(index1, item) {
  75. let over = false;
  76. for (var i = 0; i < this.newmsList.length; i++) {
  77. if (this.newmsList[i].artificerTime === item) {
  78. if (this.newmsList[i].classify == 1) {
  79. over = true;
  80. break;
  81. }
  82. }
  83. }
  84. if (!over) {
  85. this.msList.splice(index1, 1)
  86. } else {
  87. this.$queue.showToast('当前时间已被用户下单,禁止删除!')
  88. }
  89. },
  90. saveMangShi() {
  91. this.$Request.postT('/app/artificerTime/updateArtificerTime?artificerDate=' + this.yearsDate + '&times=' +
  92. this.msList.join(",") + '&artificerId=' + uni.getStorageSync('artificerId')).then(res => {
  93. if (res.code == 0) {
  94. this.$queue.showToast('设置成功!')
  95. } else {
  96. this.$queue.showToast(res.msg);
  97. }
  98. });
  99. },
  100. getMsTime(artificerDate) {
  101. this.yearsDate = artificerDate;
  102. this.$Request.getT('/app/artificerTime/selectArtificerTimeByArtificerId?artificerId=' + uni.getStorageSync(
  103. 'artificerId') + '&artificerDate=' + artificerDate).then(res => {
  104. if (res.code == 0) {
  105. this.msList = [];
  106. this.newmsList = res.data;
  107. res.data.forEach(d => {
  108. this.msList.push(d.artificerTime);
  109. });
  110. }
  111. });
  112. },
  113. SelData(e) {
  114. console.log(e)
  115. var date = new Date();
  116. var year = date.getFullYear();
  117. let Time = year + '-' + e.days
  118. this.getMsTime(Time);
  119. this.msList = [];
  120. },
  121. // 时间段数据
  122. TimeData(e) {
  123. console.log(e, e.days)
  124. var date = new Date();
  125. var year = date.getFullYear();
  126. this.startTime = year + '-' + e.days + ' ' + e.hours
  127. this.yearsDate = year + '-' + e.days
  128. console.log(this.yearsDate)
  129. this.msList.push(e.hours);
  130. }
  131. }
  132. }
  133. </script>
  134. <style lang="scss">
  135. .mangshi {
  136. // background: #FFFFFF;
  137. .sub {
  138. width: 686rpx;
  139. height: 100rpx;
  140. line-height: 100rpx;
  141. text-align: center;
  142. background: #1EDA94;
  143. border-radius: 60rpx 60rpx 60rpx 60rpx;
  144. font-weight: bold;
  145. font-size: 32rpx;
  146. color: #FFFFFF;
  147. margin-top: 24rpx;
  148. margin-left: 32rpx;
  149. }
  150. }
  151. .dx_view {
  152. background: #FFFFFF;
  153. border-radius: 8rpx;
  154. padding: 20rpx 20rpx 40rpx;
  155. width: 710rpx;
  156. margin-top: 20rpx;
  157. .dx_title {
  158. font-size: 30rpx;
  159. font-weight: bold;
  160. }
  161. }
  162. .timeView {
  163. display: flex;
  164. width: 750rpx;
  165. flex-wrap: wrap;
  166. .timeview_item {
  167. background: #F7F7F7;
  168. border-radius: 15rpx;
  169. width: 120rpx;
  170. height: 140rpx;
  171. text-align: center;
  172. padding-top: 14rpx;
  173. margin: 20rpx 20rpx 20rpx 6rpx;
  174. }
  175. .timeview_acitem {
  176. width: 120rpx;
  177. height: 140rpx;
  178. text-align: center;
  179. background: #E8F9EF;
  180. border: 1px solid #00B88F;
  181. color: #00B88F;
  182. border-radius: 15rpx;
  183. padding-top: 14rpx;
  184. margin: 20rpx 20rpx 20rpx 6rpx;
  185. }
  186. .item_text {
  187. width: 120rpx;
  188. font-size: 22rpx;
  189. font-family: PingFang SC;
  190. font-weight: 500;
  191. margin-top: 6rpx;
  192. }
  193. }
  194. .btn {
  195. border: 1upx solid #CCCCCC;
  196. border-radius: 28px;
  197. padding: 15rpx 30rpx;
  198. margin-right: 25rpx;
  199. }
  200. .btns {
  201. border: 1upx dashed #333333;
  202. border-radius: 28px;
  203. padding: 10rpx 30rpx;
  204. margin-right: 25rpx;
  205. }
  206. .active {
  207. /* background: #FCD202; */
  208. /* border: none; */
  209. }
  210. .topView {
  211. width: 750rpx;
  212. height: 180rpx;
  213. background: #FFFFFF;
  214. .topview_item {
  215. width: 160rpx;
  216. height: 120rpx;
  217. text-align: center;
  218. padding-top: 14rpx;
  219. margin: 0rpx 10rpx;
  220. }
  221. .topview_acitem {
  222. width: 160rpx;
  223. height: 120rpx;
  224. text-align: center;
  225. background: #E8F9EF;
  226. border: 1px solid #00B88F;
  227. color: #00B88F;
  228. border-radius: 20rpx;
  229. padding-top: 14rpx;
  230. margin: 0rpx 10rpx;
  231. }
  232. .item_text {
  233. width: 160rpx;
  234. font-size: 20rpx;
  235. font-family: PingFang SC;
  236. font-weight: bold;
  237. margin-top: 6rpx;
  238. }
  239. }
  240. </style>