housePriceSchemeForm.vue 20 KB

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