housePriceSchemeForm.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418
  1. <template>
  2. <a-spin :spinning="confirmLoading">
  3. <j-form-container :disabled="formDisabled">
  4. <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
  5. <a-form-model-item label="房价方案" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="priceScheme">
  6. <a-input v-model="model.priceScheme" placeholder="请输入房价方案" allowClear></a-input>
  7. </a-form-model-item>
  8. <!-- <a-form-model-item label="编号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="number">-->
  9. <!-- <a-input v-model="model.number" placeholder="请输入编号"></a-input>-->
  10. <!-- </a-form-model-item>-->
  11. <a-form-model-item label="客人类型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="guestType">
  12. <a-row>
  13. <a-col :span="10">
  14. <a-select
  15. style="width: 100%"
  16. v-model="model.guestType"
  17. placeholder="请选择客人类型"
  18. :allowClear="true"
  19. @change="e=>handleGuestType(e)"
  20. >
  21. <a-select-option :value="undefined">请选择</a-select-option>
  22. <a-select-option :value="item.value" v-for="item in guestTypeList" :key="item.value">{{ item.text }}</a-select-option>
  23. </a-select>
  24. </a-col>
  25. <a-col :span="8">
  26. <a-select
  27. v-if="model.guestType == 2"
  28. style="width: 100%"
  29. v-model="model.martketMemberId"
  30. placeholder="请选择会员"
  31. :allowClear="true"
  32. @change="e=>handleGuestType(e)"
  33. >
  34. <a-select-option :value="undefined">请选择</a-select-option>
  35. <a-select-option :value="item.id" v-for="item in customerList" :key="item.id">{{ item.name }}</a-select-option>
  36. </a-select>
  37. <a-select
  38. v-if="model.guestType == 3"
  39. style="width: 100%"
  40. v-model="model.agreementUnitId"
  41. placeholder="请选择协议单位"
  42. :allowClear="true"
  43. @change="e=>handleGuestType(e)"
  44. >
  45. <a-select-option :value="undefined">请选择</a-select-option>
  46. <a-select-option :value="item.id" v-for="item in agreementUnitList" :key="item.id">{{ item.customerName }}</a-select-option>
  47. </a-select>
  48. <a-input v-if="model.guestType == 4" style="width: 90%;margin: auto;" v-model="model.mediation" placeholder="请输入名称/简介/联系人"></a-input>
  49. </a-col>
  50. </a-row>
  51. </a-form-model-item>
  52. <a-form-model-item label="有效期" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="validTime">
  53. <a-radio-group v-model="model.validTime">
  54. <a-radio :value="0">无限制</a-radio>
  55. <a-radio :value="1">时间段</a-radio>
  56. </a-radio-group>
  57. <a-row>
  58. <a-col :span="16">
  59. <a-range-picker @change="onValidTimeChange" v-model="validTimeRange" format="YYYY-MM-DD 00:00:00" v-if="model.validTime == 1" />
  60. </a-col>
  61. </a-row>
  62. </a-form-model-item>
  63. <a-form-model-item label="入住时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="checkInTime">
  64. <a-radio-group v-model="model.checkInTime">
  65. <a-radio :value="0">无限制</a-radio>
  66. <a-radio :value="1">时间段</a-radio>
  67. </a-radio-group>
  68. <a-row>
  69. <a-col :span="16" v-if="model.checkInTime == 1">
  70. <a-time-picker v-model="startTime" format="HH:mm"></a-time-picker>
  71. <a-time-picker v-model="endTime" format="HH:mm"></a-time-picker>
  72. </a-col>
  73. </a-row>
  74. </a-form-model-item>
  75. <a-form-model-item label="是否开启" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="openValue">
  76. <a-switch
  77. checked-children="开启"
  78. un-checked-children="关闭"
  79. default-checked
  80. v-model="model.openValue"
  81. @change="e=>onOpenChange(e)"/>
  82. </a-form-model-item>
  83. <!-- <a-form-model-item label="排序" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="sort">-->
  84. <!-- <a-input-number style="width:50%;" v-model="model.sort" :min="0" placeholder="请填写排序"/>-->
  85. <!-- </a-form-model-item>-->
  86. </a-form-model>
  87. </j-form-container>
  88. </a-spin>
  89. </template>
  90. <script>
  91. import { getRoomPlans, getSelectList } from '@/api/api'
  92. import { httpAction, getAction } from '@/api/manage'
  93. import { initDictOptions } from '@/components/dict/JDictSelectUtil'
  94. import moment from 'moment'
  95. import dayjs from 'dayjs'
  96. export default {
  97. name: 'HousePriceSchemeForm',
  98. props: {
  99. disabled: {
  100. type: Boolean,
  101. default: false,
  102. required: false
  103. }
  104. },
  105. data() {
  106. return {
  107. model: {
  108. // weekends:[],
  109. },
  110. labelCol: {
  111. xs: { span: 24 },
  112. sm: { span: 5 }
  113. },
  114. wrapperCol: {
  115. xs: { span: 24 },
  116. sm: { span: 16 }
  117. },
  118. confirmLoading: false,
  119. validatorRules: {
  120. priceScheme: [{ required: true, message: '请输入房价方案!' }],
  121. guestType: [{ required: true, message: '请选择客人类型!' }],
  122. checkInTime: [{ required: true, message: '请选择入住时间!' }],
  123. validTime: [{ required: true, message: '请选择有效期!' }],
  124. open: [{ required: true, message: '请选择是否开启!' }]
  125. },
  126. url: {
  127. add: '/rooms/cesHousePriceScheme/save',
  128. edit: '/rooms/cesHousePriceScheme/modify',
  129. queryById: '/rooms/cesHousePriceScheme/queryById',
  130. queryCustomerList: '/org.jeecg.modules.business/busMarketMember/queryList',
  131. queryAgreementUnitList: '/business/busMarketAgreementUnit/queryList'
  132. },
  133. iconChooseVisible: false,
  134. customerSourceList: [],
  135. guestTypeList: [],
  136. // weeks:[],
  137. open: false,
  138. customerList: [],
  139. agreementUnitList: [],
  140. checkTimeRange: [],
  141. validTimeRange: [],
  142. startTime: null,
  143. endTime: null
  144. }
  145. },
  146. computed: {
  147. formDisabled() {
  148. return this.disabled
  149. }
  150. },
  151. created() {
  152. var _info = JSON.parse(localStorage.getItem('storeInfo'))
  153. if (_info) {
  154. this.model.hotelId = _info.id
  155. this.initData()
  156. this.getDictConfig()
  157. }
  158. this.modelDefault = JSON.parse(JSON.stringify(this.model))
  159. },
  160. methods: {
  161. initData() {
  162. getRoomPlans(this.model.hotelId, null).then((res) => {
  163. if (res.success) {
  164. this.roomPlans = res.result
  165. }
  166. })
  167. },
  168. getDictConfig() {
  169. var that = this
  170. // 客户来源
  171. // var param = {
  172. // dictName:'客人来源设置'
  173. // }
  174. // // var values = JSON.parse(JSON.stringify(param))
  175. // that.confirmLoading = true;
  176. // getAction('/business/busDictItem/queryList',param).then((res)=>{
  177. // console.log(res)
  178. // if(res.success){
  179. // if (res.code == 200 && res.result) {
  180. // this.customerSourceList = res.result;
  181. // this.model.guestSource = res.result[0].id;
  182. // }
  183. // }
  184. // }).finally(() => {
  185. // that.confirmLoading = false;
  186. // })
  187. // 初始化字典 - 客人类型
  188. initDictOptions('guest_type').then((res) => {
  189. if (res.success) {
  190. this.guestTypeList = res.result
  191. }
  192. this.model.guestType = res.result[0].value
  193. })
  194. // 初始化字典 - 客人类型
  195. // initDictOptions('house_price_zmjr').then((res) => {
  196. // if (res.success) {
  197. // that.weeks = res.result;
  198. // }
  199. // });
  200. getAction(this.url.queryCustomerList, {}).then((res) => {
  201. if (res.success) {
  202. this.customerList = res.result
  203. } else {
  204. }
  205. })
  206. getAction(this.url.queryAgreementUnitList, {}).then((res) => {
  207. if (res.success) {
  208. this.agreementUnitList = res.result
  209. } else {
  210. }
  211. })
  212. },
  213. selectIcons() {
  214. this.iconChooseVisible = true
  215. },
  216. handleIconCancel() {
  217. this.iconChooseVisible = false
  218. },
  219. handleIconChoose(value) {
  220. console.log(value)
  221. this.model.icon = value
  222. this.iconChooseVisible = false
  223. },
  224. add() {
  225. this.edit(this.modelDefault)
  226. },
  227. edit(record) {
  228. let _record = record
  229. // _record.guestType = record.guestType.toString();
  230. if (record.id) {
  231. if (record.open == 1) {
  232. _record.openValue = true
  233. } else {
  234. _record.openValue = false
  235. }
  236. // if (record.weekend.length > 0){
  237. // _record.weekends = record.weekend.split(',');
  238. // }
  239. } else {
  240. _record.checkInTime = 0
  241. _record.validTime = 0
  242. }
  243. console.log(_record)
  244. this.model = Object.assign({}, _record)
  245. this.visible = true
  246. if (this.model.id) {
  247. if (this.model.checkInTime === 1) {
  248. this.startTime = moment(this.model.startTime, 'HH:mm')
  249. this.endTime = moment(this.model.endTime, 'HH:mm')
  250. // this.endTime = moment(this.validTimeRange[0]).format('YYYY-MM-DD 00:00:00')
  251. }
  252. if (this.model.validTime === 1) {
  253. this.validTimeRange =
  254. [moment(new Date(this.model.validStartTime)).format('YYYY-MM-DD 00:00:00'),
  255. moment(new Date(this.model.validEndTime)).format('YYYY-MM-DD 00:00:00')]
  256. }
  257. }
  258. getSelectList({ id: this.model.id }).then((res) => {
  259. if (res.success) {
  260. this.members = res.result
  261. }
  262. })
  263. },
  264. onCheckTimeChange(date, dateString) {
  265. // this.checkStartTime = dateString[0];
  266. // this.checkEndTime = dateString[1];
  267. // if (date.length === 0) {
  268. // this.checkTimeRange = [];
  269. // } else {
  270. // console.log("这是开始时间", this.$moment(this.checkTimeRange[0]).format('YYYY-MM-DD 00:00:00'));
  271. // console.log("这是结束时间", this.$moment( this.checkTimeRange[1]).format('YYYY-MM-DD 00:00:00'));
  272. // }
  273. },
  274. onValidTimeChange(date, dateString) {
  275. // this.validStartTime = dateString[0];
  276. // this.validEndTime = dateString[1];
  277. // if (date.length === 0) {
  278. // this.validTimeRange = [];
  279. // } else {
  280. // console.log("这是开始时间", this.$moment(this.validTimeRange[0]).format('YYYY-MM-DD 00:00:00'));
  281. // console.log("这是结束时间", this.$moment( this.validTimeRange[1]).format('YYYY-MM-DD 00:00:00'));
  282. // }
  283. // console.log(this.validTimeRange.length);
  284. },
  285. onOpenChange(e) {
  286. console.log(e)
  287. console.log(this.model.openValue)
  288. // this.model.open = e?1:0;
  289. // this.model.openValue = e
  290. // this.model.openValue = !this.model.openValue
  291. this.model.openValue = e
  292. },
  293. submitForm() {
  294. const that = this
  295. // 触发表单验证
  296. if (this.model.checkInTime == 1) {
  297. // this.model.startTime =moment(this.checkTimeRange[0]).format('YYYY-MM-DD 00:00:00');
  298. // this.model.endTime =moment(this.checkTimeRange[1]).format('YYYY-MM-DD 00:00:00');
  299. this.model.startTime = moment(this.startTime).format('HH:mm')
  300. this.model.endTime = moment(this.endTime).format('HH:mm')
  301. }
  302. if (this.model.validTime == 1) {
  303. this.model.validStartTime = moment(this.validTimeRange[0]).format('YYYY-MM-DD 00:00:00')
  304. this.model.validEndTime = moment(this.validTimeRange[1]).format('YYYY-MM-DD 00:00:00')
  305. }
  306. // this.model.weekend = this.model.weekends.join(',');
  307. this.model.open = this.model.openValue ? 1 : 0
  308. console.log(this.model)
  309. this.$refs.form.validate((valid) => {
  310. if (valid) {
  311. that.confirmLoading = true
  312. let httpurl = ''
  313. let method = ''
  314. if (!this.model.id) {
  315. httpurl += this.url.add
  316. method = 'post'
  317. } else {
  318. httpurl += this.url.edit
  319. method = 'put'
  320. }
  321. httpAction(httpurl, this.model, method)
  322. .then((res) => {
  323. if (res.success) {
  324. that.$message.success(res.message)
  325. that.$emit('ok')
  326. } else {
  327. that.$message.warning(res.message)
  328. }
  329. })
  330. .finally(() => {
  331. that.confirmLoading = false
  332. })
  333. }
  334. })
  335. },
  336. onChange() {
  337. },
  338. handleHolidCancel() {
  339. this.open = false
  340. },
  341. handleHolidConfirm() {
  342. this.open = false
  343. },
  344. moment,
  345. range(start, end) {
  346. const result = []
  347. for (let i = start; i < end; i++) {
  348. result.push(i)
  349. }
  350. return result
  351. },
  352. disabledDate(current) {
  353. // Can not select days before today and today
  354. return current && current < moment().endOf('day')
  355. },
  356. disabledDateTime() {
  357. return {
  358. disabledHours: () => this.range(0, 24).splice(4, 20),
  359. disabledMinutes: () => this.range(30, 60),
  360. disabledSeconds: () => [55, 56]
  361. }
  362. },
  363. // 弹出日历和关闭日历的回调
  364. openChangeOne(status) {
  365. if (status) {
  366. this.open = true
  367. }
  368. },
  369. // 得到年份选择器的值
  370. panelChangeOne(value) {
  371. this.queryParam.year = moment(new Date(value)).format('YYYY')
  372. this.open = false
  373. },
  374. handleOk(e) {
  375. console.log(e)
  376. },
  377. handleChange(e) {
  378. console.log(e)
  379. console.log(this.model.holiday)
  380. this.model.holiday = e + ','
  381. },
  382. handleFocus() {
  383. this.open = true
  384. },
  385. handleGuestType(e) {
  386. console.log(e)
  387. }
  388. }
  389. }
  390. </script>
  391. <style scoped>
  392. .avatar-uploader>.ant-upload {
  393. width: 104px;
  394. height: 104px;
  395. }
  396. .margin_left_6{
  397. margin-left: 6px;
  398. }
  399. </style>