up.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. <template>
  2. <view>
  3. <view class="mtop"><text class="icon">&#xe617;</text></view>
  4. <view class="time">上次上报:{{ time }}</view>
  5. <view class="cn">
  6. <!--上传门店数据-->
  7. <view class="info" v-if="item.shopType == 1">
  8. <view class="form_group hr">
  9. <view class="lable">散客预约人数</view>
  10. <input type="number" placeholder="请输入散客预约人数" v-model="item.scatteredAppointment" />
  11. </view>
  12. <view class="form_group hr">
  13. <view class="lable">散客接待人数</view>
  14. <input type="number" placeholder="请输入散客接待人数" v-model="item.scatteredReception" />
  15. </view>
  16. <view class="form_group hr">
  17. <view class="lable">团客预约人数</view>
  18. <input type="number" placeholder="请输入团客预约人数" v-model="item.groupAppointment" />
  19. </view>
  20. <view class="form_group hr">
  21. <view class="lable">团客接待人数</view>
  22. <input type="number" placeholder="请输入团客接待人数" v-model="item.groupReception" />
  23. </view>
  24. <view class="form_group hr">
  25. <view class="lable">销售金额(元)</view>
  26. <input type="number" placeholder="请输入销售金额" v-model="item.salesAmount" />
  27. </view>
  28. <view class="form_group hr">
  29. <view class="lable">销售时间</view>
  30. <input type="text" placeholder="请选择销售时间" :disabled="true" v-model="item.salesTime" @click="calendar_show = true" />
  31. </view>
  32. </view>
  33. <!--上传酒店数据-->
  34. <view v-else>
  35. <view class="info">
  36. <view class="item" v-for="(it, index) in item.shopGuestRecordList" :key="index">
  37. <text>{{ it.guestName }}</text>
  38. <text class="icon del" @click="del(it)">&#xe600;</text>
  39. </view>
  40. </view>
  41. <view class="mt10">
  42. <u-divider v-if="item.shopGuestRecordList.length > 0">共添加{{ item.shopGuestRecordList.length }}个游客</u-divider>
  43. </view>
  44. </view>
  45. <button class="btn add" @click="popup" v-if="item.shopType == 2">添加游客</button>
  46. <button class="btn" @click="up()">上报数据</button>
  47. </view>
  48. <!--添加游客信息-->
  49. <u-popup v-model="popup_show" :mask-close-able="false" mode="center" border-radius="14" width="90%" height="auto" :closeable="true">
  50. <view class="u-popup">
  51. <view class="tttt" style="font-weight: bolder;">添加游客</view>
  52. <view class="form_group hr">
  53. <view class="lable">游客姓名</view>
  54. <input placeholder="请输入散客预约人数" v-model="guest.guestName" />
  55. </view>
  56. <view class="form_group hr">
  57. <view class="lable">身份证号</view>
  58. <input placeholder="请输入散客预约人数" v-model="guest.idCard" />
  59. </view>
  60. <view class="form_group hr">
  61. <view class="lable">手机号码</view>
  62. <input type="number" placeholder="请输入散客预约人数" v-model="guest.phone" />
  63. </view>
  64. <view class="form_group hr">
  65. <view class="lable">入住日期</view>
  66. <input :disabled="true" placeholder="请选择入住日期" @click="calendar_show = true" v-model="guest.checkInTime" />
  67. </view>
  68. <view class="form_group hr">
  69. <view class="lable">游客类型</view>
  70. <input :disabled="true" @click="guest_show = true" placeholder="请选择游客类型" v-model="guest.guestType" />
  71. </view>
  72. <button class="btn" @click="add()">保存并继续</button>
  73. </view>
  74. </u-popup>
  75. <u-calendar v-model="calendar_show" @change="calendar"></u-calendar>
  76. <u-select v-model="guest_show" :list="[{ label: '散客', value: '散客' }, { label: '团客', value: '团客' }]" @confirm="confirm"></u-select>
  77. </view>
  78. </template>
  79. <script>
  80. export default {
  81. data() {
  82. return {
  83. item: { shopType: 2, shopGuestRecordList: [] },
  84. guest: { guestType: '散客', checkInTime: this.$util.getDate() }, //游客
  85. guest_list: [],
  86. time: '未上报过',
  87. popup_show: false,
  88. calendar_show: false,
  89. guest_show: false
  90. };
  91. },
  92. onLoad(e) {
  93. if (e.item) {
  94. this.item = JSON.parse(e.item);
  95. if (this.item.shopType == 1) {
  96. this.$nextTick(() => {
  97. uni.setNavigationBarTitle({
  98. title: '门店数据上报'
  99. });
  100. });
  101. }
  102. if (this.item.shopType == 2) {
  103. this.item.shopGuestRecordList = [];
  104. this.$nextTick(() => {
  105. uni.setNavigationBarTitle({
  106. title: '酒店数据上报'
  107. });
  108. });
  109. }
  110. }
  111. //上报时间
  112. if (uni.getStorageSync('time-' + this.item.shopId) != '') {
  113. this.time = this.$u.timeFrom(new Date(uni.getStorageSync('time-' + this.item.shopId).replace(/\-/g, '/')).getTime());
  114. }
  115. },
  116. methods: {
  117. calendar(e) {
  118. this.item.salesTime = e.result;
  119. this.guest.checkInTime = e.result;
  120. },
  121. popup() {
  122. this.guest = { guestName: '', idCard: '', phone: '', guestType: this.guest.guestType, checkInTime: this.guest.checkInTime };
  123. this.popup_show = true;
  124. },
  125. //选择游客类型
  126. confirm(e) {
  127. this.guest.guestType = e[0].value;
  128. },
  129. add() {
  130. let rule = [
  131. { name: 'guestName', checkType: 'notnull', errorMsg: '请输入游客姓名' },
  132. { name: 'idCard', checkType: 'notnull', errorMsg: '请输入游客身份证号' },
  133. { name: 'checkInTime', checkType: 'notnull', errorMsg: '请选择游客入住日期' }
  134. ];
  135. if (!this.$verify.check(this.guest, rule)) {
  136. uni.showModal({ content: this.$verify.error, showCancel: false });
  137. return;
  138. }
  139. this.item.shopGuestRecordList.push(JSON.parse(JSON.stringify(this.guest)));
  140. uni.showToast({ title: '保存成功' });
  141. this.guest = { guestName: '', idCard: '', phone: '', guestType: this.guest.guestType, checkInTime: this.guest.checkInTime };
  142. this.$forceUpdate();
  143. },
  144. del(item) {
  145. this.item.shopGuestRecordList.splice(this.item.shopGuestRecordList.indexOf(item), 1);
  146. this.$forceUpdate();
  147. },
  148. up() {
  149. if (this.item.shopType == 1) {
  150. let rule = [
  151. { name: 'scatteredAppointment', checkType: 'notnull', errorMsg: '请输入散客预约人数' },
  152. { name: 'scatteredReception', checkType: 'notnull', errorMsg: '请输入散客接待人数' },
  153. { name: 'groupAppointment', checkType: 'notnull', errorMsg: '请输入团客预约人数' },
  154. { name: 'groupReception', checkType: 'notnull', errorMsg: '请输入团客接待人数' },
  155. { name: 'salesAmount', checkType: 'notnull', errorMsg: '请输入销售金额' },
  156. { name: 'salesTime', checkType: 'notnull', errorMsg: '请选择销售时间' }
  157. ];
  158. if (!this.$verify.check(this.item, rule)) {
  159. uni.showModal({ content: this.$verify.error, showCancel: false });
  160. return;
  161. }
  162. } else {
  163. if (this.item.shopGuestRecordList == 0) {
  164. uni.showModal({ content: '请先添加游客再上传数据', showCancel: false });
  165. return;
  166. }
  167. }
  168. this.$http.request({
  169. method: 'POST',
  170. url: this.$http.urls.pushRecord,
  171. data: this.item,
  172. success: res => {
  173. uni.showToast({ title: '上报成功' });
  174. uni.setStorageSync('time-' + this.item.shopId, this.$util.getDate('time'));
  175. setTimeout(() => {
  176. uni.navigateBack();
  177. }, 700);
  178. }
  179. });
  180. }
  181. }
  182. };
  183. </script>
  184. <style lang="scss">
  185. .mtop {
  186. text-align: center;
  187. margin-top: 20px;
  188. .icon {
  189. font-size: 90px;
  190. color: $dar;
  191. }
  192. }
  193. .time {
  194. text-align: center;
  195. color: $dar;
  196. font-size: 13px;
  197. margin-top: 10px;
  198. }
  199. .cn {
  200. padding: 15px;
  201. .info {
  202. background-color: white;
  203. border-radius: 5px;
  204. margin-top: 10px;
  205. box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  206. .item {
  207. padding: 12px;
  208. border-bottom: 1px solid #f0f0f0;
  209. .del {
  210. float: right;
  211. color: $theme-color;
  212. font-size: 21px;
  213. }
  214. }
  215. }
  216. .add {
  217. background-color: #2979ff;
  218. border: 1px solid #2979ff;
  219. }
  220. .btn {
  221. margin-top: 25px;
  222. }
  223. }
  224. .u-popup {
  225. padding: 20px;
  226. .tttt {
  227. font-weight: bold;
  228. font-size: 18px;
  229. margin-bottom: 10px;
  230. }
  231. .inp {
  232. text-align: right !important;
  233. padding-right: 5px !important;
  234. }
  235. }
  236. </style>