com-price-day-set.php 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. <style>
  2. .com-time-select {
  3. width: 760px;
  4. margin-top: 12px;
  5. border: 1px solid #cccccc;
  6. }
  7. .item-box {
  8. display: flex;
  9. }
  10. .top-box {
  11. height: 50px;
  12. border-bottom: 1px solid #cccccc;
  13. }
  14. .bottom-box {
  15. height: 250px;
  16. }
  17. .left-box {
  18. width: 23%;
  19. min-width: 22%;
  20. background-color: #f5f6fa;
  21. border-right: 1px solid #cccccc;
  22. }
  23. .right-box {
  24. width: 77%;
  25. }
  26. .not-scroll {
  27. padding: 0 12px;
  28. display: flex;
  29. justify-content: space-between;
  30. align-items: center;
  31. }
  32. .scroll-box {
  33. overflow-y: scroll;
  34. }
  35. .date-item {
  36. padding: 10px 4px;
  37. text-align: center;
  38. border-bottom: 1px solid #cccccc;
  39. cursor: pointer;
  40. }
  41. .selected {
  42. background-color: #ffffff;
  43. font-weight: bold;
  44. }
  45. .date-item:last-child {
  46. border-bottom: none;
  47. }
  48. .top-right {
  49. display: flex;
  50. justify-content: space-between;
  51. align-items: center;
  52. }
  53. .bottom-right {
  54. }
  55. .top-right-item {
  56. width: 25%;
  57. padding: 0 6px;
  58. border-left: 1px solid #cccccc;
  59. }
  60. .top-right-item:first-child {
  61. border-left: none;
  62. }
  63. .f-between {
  64. display: flex;
  65. justify-content: space-between;
  66. align-items: center;
  67. }
  68. .time-item {
  69. margin: 6px 0;
  70. padding-bottom: 6px;
  71. display: flex;
  72. border-bottom: 1px solid #eeeeee;
  73. }
  74. .time-item:last-child {
  75. border-bottom: none;
  76. }
  77. .bottom-right-item {
  78. width: 25%;
  79. padding: 0 6px;
  80. }
  81. .pop-box {
  82. display: flex;
  83. justify-content: space-between;
  84. align-items: center;
  85. }
  86. </style>
  87. <template id="com-price-day-set">
  88. <div class="com-time-select">
  89. <div class="item-box top-box">
  90. <div class="left-box not-scroll">
  91. <span>日期</span>
  92. <el-popover placement="top" width="1020" trigger="click" v-model="popover_batch">
  93. <div class="pop-box">
  94. <span>售价(元)</span>
  95. <el-input placeholder="请输入售价" type="number" v-model="unifyPrice" style="width: 200px;"><template slot="append">元</template></el-input>
  96. <span>划线价(元)</span>
  97. <el-input placeholder="请输入划线价" type="number" v-model="unifyLinePrice" style="width: 200px;"><template slot="append">元</template></el-input>
  98. <span>可预约数量</span>
  99. <el-input placeholder="请输入可预约数量" type="number" v-model="unifyReservationNum" style="width: 200px;"></el-input>
  100. <el-button @click="popover_batch = false">取消</el-button>
  101. <el-button type="primary" @click="unifyConfirm">确认</el-button>
  102. </div>
  103. <el-button type="text" slot="reference"><span style="color: #409EFF;">批量设置</span></el-button>
  104. </el-popover>
  105. </div>
  106. <div class="right-box top-right">
  107. <!-- <div class="top-right-item">时间段</div>-->
  108. <!-- <div class="top-right-item f-between">-->
  109. <!-- <span>售价(元)</span>-->
  110. <!-- </div>-->
  111. <!-- <div class="top-right-item f-between">-->
  112. <!-- <span>划线价(元)</span>-->
  113. <!-- </div>-->
  114. <!-- <div class="top-right-item f-between">-->
  115. <!-- <span>可预约数量</span>-->
  116. <!-- </div>-->
  117. </div>
  118. </div>
  119. <div class="item-box bottom-box">
  120. <template v-if="selectedDates.length > 0">
  121. <div class="left-box scroll-box">
  122. <div v-for="(item,index) in selectedDates" :key="index" class="date-item" :class="item.isSelect ? 'selected' : ''" @click="onDate(index)">{{item.date}}</div>
  123. </div>
  124. <div class="right-box scroll-box">
  125. <el-form-item label="售价">
  126. <el-input style="width: 150px" placeholder="请输入..." type="number" v-model="selectedDates[currentIndex].price" clearable @input="onUpdateValue"></el-input>
  127. </el-form-item>
  128. <el-form-item label="划线价">
  129. <el-input style="width: 150px" placeholder="请输入..." type="number" v-model="selectedDates[currentIndex].linePrice" clearable @input="onUpdateValue"></el-input>
  130. </el-form-item>
  131. <el-form-item label="可预约数量">
  132. <el-input style="width: 150px" placeholder="请输入..." type="number" v-model="selectedDates[currentIndex].reservationNum" clearable @input="onUpdateValue"></el-input>
  133. </el-form-item>
  134. </div>
  135. </template>
  136. </div>
  137. </div>
  138. </template>
  139. <script>
  140. Vue.component('com-price-day-set', {
  141. template: '#com-price-day-set',
  142. props: {
  143. dateList: {
  144. type: Array,
  145. default: () => {
  146. return []
  147. }
  148. }
  149. },
  150. data() {
  151. return {
  152. selectedDates: [],
  153. unifyReservationNum: 0,//统一可预约数量
  154. unifyPrice: 0,//统一售价
  155. unifyLinePrice: 0,//统一划线价
  156. input: 0,
  157. popover_batch: false,
  158. popover_price: false,
  159. popover_m_price: false,
  160. popover_num: false,
  161. currentIndex: 0,
  162. }
  163. },
  164. watch: {
  165. dateList: {
  166. handler(newvalue, oldvalue) {
  167. this.$nextTick(() => {
  168. this.initData();
  169. });
  170. },
  171. immediate: true,
  172. deep: true
  173. },
  174. },
  175. methods: {
  176. initData() {
  177. this.selectedDates = [];
  178. let selectedDates = JSON.parse(JSON.stringify(this.dateList));
  179. console.log('selectedDatesselectedDatesselectedDates', selectedDates)
  180. selectedDates.sort(function (a, b) {
  181. return new Date(a.date || a) - new Date(b.date || b);
  182. })
  183. selectedDates.forEach(d => {
  184. this.selectedDates.push({
  185. date: d.date || d,
  186. price: d.price || 0,
  187. linePrice: d.linePrice || 0,
  188. reservationNum: d.reservationNum || 0,
  189. children: d.children || [],
  190. times: d.times || []
  191. })
  192. })
  193. if(this.selectedDates.length){
  194. this.selectedDates.forEach(item => {
  195. item.isSelect = false;
  196. });
  197. this.selectedDates[this.currentIndex].isSelect = true;
  198. this.$forceUpdate();
  199. }
  200. // this.emit()
  201. },
  202. onDate(index) {
  203. this.selectedDates.forEach(item => {
  204. item.isSelect = false;
  205. });
  206. this.selectedDates[index].isSelect = true;
  207. this.currentIndex = index
  208. },
  209. unifyConfirm() {
  210. this.selectedDates.forEach(item => {
  211. item.price = this.unifyPrice
  212. item.linePrice = this.unifyLinePrice
  213. item.reservationNum = this.unifyReservationNum
  214. this.$forceUpdate();
  215. });
  216. this.emit()
  217. this.popover_batch = false
  218. },
  219. emit() {
  220. this.$emit("on-update-selected-date", this.selectedDates)
  221. },
  222. onUpdateValue() {
  223. this.emit()
  224. this.$forceUpdate()
  225. }
  226. }
  227. })
  228. </script>