housePriceSchemeLayoutForm.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686
  1. <template>
  2. <div>
  3. <!-- <a-calendar>-->
  4. <!-- <ul slot="dateCellRender" slot-scope="value" class="events">-->
  5. <!-- <li v-for="item in getListData(value)" :key="item.content">-->
  6. <!-- <a-badge :status="item.type" :text="item.content" />-->
  7. <!-- </li>-->
  8. <!-- </ul>-->
  9. <!-- <template slot="monthCellRender" slot-scope="value">-->
  10. <!-- <div v-if="getMonthData(value)" class="notes-month">-->
  11. <!-- <section>{{ getMonthData(value) }}</section>-->
  12. <!-- <span>Backlog number</span>-->
  13. <!-- </div>-->
  14. <!-- </template>-->
  15. <!-- </a-calendar>-->
  16. <!-- <ul class="events">-->
  17. <!-- <li v-for="item in getListData(value)" :key="item.content">-->
  18. <!-- <a-badge :status="'success'" :text="item.classify_rname +'('+item.num+')'" />-->
  19. <!-- </li>-->
  20. <!-- </ul>-->
  21. <!-- <div>
  22. <a-calendar style="background: #fff" @select="handleSelecrt" @panelChange="onPanelChange" :header-render="headerRender">
  23. <div slot="dateFullCellRender" slot-scope="value" class="ant-fullcalendar-date" :class="{'ant-fullcalendar-date-has-content':getListData(value).length>0}">
  24. <div class="ant-fullcalendar-value">{{getCaledarDate(value)}}</div>
  25. <div class="ant-fullcalendar-content">
  26. <div style="padding-top: 5px;" v-for="item in getListData(value)" :key="item.content">
  27. <a-button type="primary" @click="e=>handleMoney(e,value,item)">
  28. {{item.content}}
  29. </a-button>
  30. </div>
  31. </div>
  32. </div>
  33. </a-calendar> -->
  34. <a-modal v-model="visibleMoney" title="修改房价" @ok="handleOk">
  35. <a-input-number style="width: 100%;margin: auto" v-model="updateMoney" />
  36. </a-modal>
  37. <!-- </div> -->
  38. <a-table :columns="columns" :alert="true" :data-source="calendarData" :rowKey="(record, index) => index + 1">
  39. <!-- 111 -->
  40. <!-- <template slot="layoutName" slot-scope="text, record">
  41. <a-button type="primary">Primary Button</a-button>
  42. </template> -->
  43. <!-- <div slot-scope="text, record" v-for="item in columns"> -->
  44. <template v-for="item in columns" :slot="item.dataIndex" slot-scope="text, record">
  45. <!-- {{ }} -->
  46. <div :class="isWeekend(new Date(item.dataIndex)) ? 'cell_style' : 'cell_stylez'" @click="editPrice(record,item,record[item.dataIndex])">
  47. <!-- <div class="cell_style"> -->
  48. {{ record[item.dataIndex] }}
  49. <!-- <a-button block></a-button> -->
  50. </div>
  51. <!-- <a-button type="primary">Primary Button</a-button> -->
  52. </template>
  53. <!-- </div> -->
  54. <!-- <template slot-scope="text, record">
  55. -->
  56. <!-- 111 -->
  57. <!-- <template :slot="item.dataIndex" slot-scope="text, record">
  58. 111
  59. </template> -->
  60. <!-- {{ record[index] }}111 -->
  61. <!-- {{ record[index] = 1 }} -->
  62. <!-- <template :slot="record[index]" slot-scope="text, record">
  63. {{ record[index] }}
  64. </template>
  65. <template :slot="record[index]" slot-scope="text, record">
  66. {{ record[index] }}
  67. </template>
  68. <template :slot="record[index]" slot-scope="text, record">
  69. {{ record[index] }}
  70. </template> -->
  71. <!-- </div>
  72. </template> -->
  73. <!-- <template slot-scope="scopes">
  74. {{ calendarData }}
  75. <div v-for="item in scopes">
  76. </div>
  77. </template> -->
  78. <!-- {{ record.dataIndex }} -->
  79. <!-- <div>
  80. 111
  81. </div> -->
  82. <!-- <el-dialog
  83. title="提示"
  84. :visible.sync="visibleMoney"
  85. width="30%"
  86. :before-close="handleClose">
  87. <span>这是一段信息</span>
  88. <span slot="footer" class="dialog-footer">
  89. <el-button @click="visibleMoney = false">取 消</el-button>
  90. <el-button type="primary" @click="visibleMoney = false">确 定</el-button>
  91. </span>
  92. </el-dialog> -->
  93. </a-table>
  94. </div>
  95. </template>
  96. <script>
  97. import { httpAction, getAction } from '@/api/manage'
  98. import { validateDuplicateValue } from '@/utils/util'
  99. import moment from 'moment';
  100. import * as dayjs from "dayjs";
  101. const hotelInfo = JSON.parse(localStorage.getItem("storeInfo"));
  102. export default {
  103. name: 'housePriceSchemeLayoutForm',
  104. components: {
  105. },
  106. props: {
  107. //表单禁用
  108. disabled: {
  109. type: Boolean,
  110. default: false,
  111. required: false
  112. },
  113. },
  114. data () {
  115. return {
  116. columns: [
  117. {
  118. title: '房型',
  119. dataIndex: 'layoutName',
  120. scopedSlots: { customRender: 'layoutName' }
  121. }
  122. ],
  123. // 表格数据
  124. calendarData: [],
  125. labelCol: {
  126. xs: { span: 24 },
  127. sm: { span: 5 },
  128. },
  129. wrapperCol: {
  130. xs: { span: 24 },
  131. sm: { span: 16 },
  132. },
  133. confirmLoading: false,
  134. url: {
  135. add: "/business/busHousePriceSchemeLayout/add",
  136. edit: "/business/busHousePriceSchemeLayout/edit",
  137. queryById: "/business/busHousePriceSchemeLayout/queryById",
  138. queryList: "/business/busSchemeLayoutDailyPrice/queryList",
  139. editDailyPrice: "/business/busSchemeLayoutDailyPrice/editDailyPrice",
  140. batchUpdatePrice: "/business/busSchemeLayoutDailyPrice/batchUpdatePrice",
  141. // list: "/business/busHousePriceSchemeLayout/layoutPricePage",
  142. queryListByCond: "/business/busSchemeLayoutDailyPrice/queryListByCond",
  143. },
  144. curDate :moment(new Date()).format('YYYY-MM-DD'),
  145. moneyDays:[],
  146. schemeLayoutId:'',
  147. visibleMoney:false,
  148. updateId:'',
  149. updateSchemeLayoutId:'',
  150. updateMoney:0,
  151. updateDate:'',
  152. selectDate:'',
  153. // 暂存数据
  154. oldList: []
  155. }
  156. },
  157. computed: {
  158. formDisabled(){
  159. return this.disabled
  160. },
  161. },
  162. created () {
  163. this.selectDate = moment(new Date()).format('YYYY-MM-DD 00:00:00')
  164. console.log(this.dataSource);
  165. //获取数据
  166. this.$nextTick(()=>{
  167. getAction(this.url.queryList, {
  168. schemeLayoutId: this.schemeLayoutId,
  169. realDate:this.selectDate
  170. }).then((res) => {
  171. if (res.success) {
  172. this.moneyDays = res.result;
  173. }
  174. });
  175. // var param = {
  176. // schemeId:'1644273323440029697',
  177. // layoutId:'1632671499640946690',
  178. // startDate:'2023-04-10',
  179. // endDate:'2023-04-16',
  180. // }
  181. // getAction(this.url.queryListByCond, param).then((res) => {
  182. // if (res.success) {
  183. // console.log(res.result);
  184. // }
  185. // });
  186. var url = "/rooms/cesHousePriceScheme/listByLayout?hotelId=" + hotelInfo.id+"&layoutId="+'1632671499640946690'
  187. getAction(url, {}).then((res) => {
  188. if (res.success) {
  189. console.log(res.result);
  190. }
  191. });
  192. })
  193. // this.getDateList()
  194. },
  195. methods: {
  196. // 修改价格
  197. editPrice(record,item,val) {
  198. console.log(val);
  199. console.log(record);
  200. console.log(item);
  201. console.log(this.calendarData);
  202. let tempid = ''
  203. this.oldList.forEach(index => {
  204. console.log(index);
  205. if (record.layoutName == index.layoutName) {
  206. index.schemeLayoutDailyPriceList.forEach(cust => {
  207. if (item.dataIndex == cust.date) {
  208. console.log(111);
  209. tempid = cust.id
  210. }
  211. })
  212. }
  213. })
  214. console.log(tempid);
  215. var _time = moment(new Date(item.dataIndex)).format('YYYY-MM-DD 00:00:00')
  216. console.log(_time);
  217. this.updateDate = _time
  218. this.updateMoney = val
  219. this.updateId = tempid
  220. this.updateSchemeLayoutId = record.schemeLayoutId
  221. this.visibleMoney = true
  222. },
  223. // 获取数据
  224. async getDateList() {
  225. console.log(this.dataSource);
  226. await getAction('/business/busHousePriceSchemeLayout/layoutPricePage', {
  227. pageNo: 1,
  228. pageSize: 10,
  229. schemeId: this.model.schemeId
  230. }).then(res => {
  231. console.log(res);
  232. if (res.success) {
  233. this.oldList = res.result.records
  234. let tmeplist = res.result.records
  235. let tempcol = []
  236. tmeplist[0].schemeLayoutDailyPriceList.forEach(index => {
  237. let tempindex = {
  238. title: index.date,
  239. // schemeLayoutId: schemeLayoutId,
  240. dataIndex: index.date,
  241. align: 'center',
  242. // key: 'key',
  243. // customCell: (record) => {
  244. // for (let item in record) {
  245. // const d1 = new Date(item);
  246. // let tempcolor = this.isWeekend(d1)
  247. // console.log(tempcolor);
  248. // if (tempcolor) {
  249. // return {
  250. // style:{
  251. // color:'red'
  252. // }
  253. // }
  254. // }
  255. // }
  256. // }
  257. 'scopedSlots': { 'customRender': index.date }
  258. // customRender(text, record) {
  259. // // return record.layoutPrice
  260. // record.forEach(item => {
  261. // })
  262. // }
  263. // const d1 = new Date(item);
  264. // let tempcolor = this.isWeekend(d1)
  265. }
  266. tempcol.push(tempindex)
  267. });
  268. // console.log(tempcol);
  269. this.columns = this.columns.concat(tempcol)
  270. // console.log(this.columns);
  271. let temprol = []
  272. tmeplist.forEach(item => {
  273. console.log(item);
  274. // let
  275. let tempindex = {}
  276. item.schemeLayoutDailyPriceList.forEach(index => {
  277. // var tempdate = index.date
  278. // tempindex = {
  279. tempindex[index.date] = index.money
  280. tempindex['schemeLayoutId'] = index.schemeLayoutId
  281. tempindex['layoutName'] = item.layoutName
  282. tempindex['hotelId'] = item.hotelId
  283. tempindex['id'] = item.id
  284. // tempdate: index.money,
  285. // dataIndex: ,
  286. // schemeLayoutId: index.schemeLayoutId
  287. // }
  288. })
  289. temprol.push(tempindex)
  290. });
  291. console.log(temprol);
  292. console.log(this.columns);
  293. this.calendarData = temprol
  294. // temprol.forEach(cust => [
  295. // ])
  296. }
  297. })
  298. },
  299. // 处理周末
  300. isWeekend(date = new Date()) {
  301. return date.getDay() === 6 || date.getDay() === 0;
  302. },
  303. // // 处理周末
  304. // exitCustomRow(record, index) {
  305. // console.log(record);
  306. // for (let item in record) {
  307. // console.log(item);
  308. // const d1 = new Date(item);
  309. // let tempcolor = this.isWeekend(d1)
  310. // // console.log(this.isWeekend(d1));
  311. // console.log(tempcolor);
  312. // if (this.isWeekend(d1)) {
  313. // // console.log(123);
  314. // return 'table-color-dust'
  315. // }
  316. // // if (!this.isWeekend(d1)) {
  317. // // // console.log(123);
  318. // // return {
  319. // // style: {
  320. // // background: 'red',
  321. // // },
  322. // // }
  323. // // }
  324. // }
  325. // console.log(index);
  326. // },
  327. edit (record) {
  328. console.log(record);
  329. this.model = Object.assign({}, record);
  330. this.visible = true;
  331. this.schemeLayoutId = record.id
  332. this.getDateList()
  333. },
  334. handleMoney(e,value,item){
  335. var _time = moment(new Date(value)).format('YYYY-MM-DD 00:00:00')
  336. this.visibleMoney = true
  337. this.updateMoney = item.content
  338. this.updateDate = _time
  339. this.updateId = item.id
  340. this.updateSchemeLayoutId = item.schemeLayoutId
  341. e.stopPropagation();//阻止事件冒泡
  342. },
  343. handleOk(e){
  344. //修改每日房价
  345. var that = this;
  346. that.confirmLoading = true;
  347. httpAction(this.url.editDailyPrice,{
  348. id:this.updateId,
  349. schemeLayoutId:this.updateSchemeLayoutId,
  350. hotelId:hotelInfo.id,
  351. date:this.updateDate,
  352. money:this.updateMoney,
  353. },"POST").then((res)=>{
  354. if(res.success){
  355. that.$message.success("操作成功");
  356. // that.$emit('ok');
  357. getAction(that.url.queryList, {
  358. schemeLayoutId: that.schemeLayoutId,
  359. realDate:that.selectDate
  360. }).then((res) => {
  361. if (res.success) {
  362. that.moneyDays = res.result;
  363. this.getDateList()
  364. }
  365. }).finally(()=>{
  366. });
  367. }else{
  368. that.$message.warning(res.message);
  369. }
  370. }).finally(() => {
  371. that.confirmLoading = false;
  372. that.visibleMoney = false
  373. })
  374. },
  375. getListData(value) {
  376. let listData = [];
  377. //获取到所有某个房型的每日房价
  378. //刚进入页面的时候,只显示今天以后的数据
  379. var _time = moment(new Date(value)).format('YYYY-MM-DD')
  380. var _cur = moment(new Date()).format('YYYY-MM-DD')
  381. if(this.selectDate != ""){
  382. for(let item of this.moneyDays){
  383. if (item.date == _time){
  384. listData = [
  385. { content: item.money ,id:item.id ,schemeLayoutId:item.schemeLayoutId },
  386. ];
  387. }
  388. }
  389. }else{
  390. if (_time >= _cur){
  391. for(let item of this.moneyDays){
  392. if (item.date == _time){
  393. listData = [
  394. { content: item.money ,id:item.id ,schemeLayoutId:item.schemeLayoutId},
  395. ];
  396. }
  397. }
  398. }
  399. }
  400. // switch (value.date()) {
  401. // case 8:
  402. // listData = [
  403. // { content: '218' },
  404. // ];
  405. // break;
  406. // case 10:
  407. // listData = [
  408. // { content: '258' },
  409. // ];
  410. // break;
  411. // default:
  412. // }
  413. return listData || [];
  414. },
  415. getMonthData(value) {
  416. if (value.month() === 8) {
  417. return 1394;
  418. }
  419. },
  420. // 点击某天
  421. handleSelecrt(value) {
  422. let selectDate = value.format('YYYY-MM-DD HH:mm:ss') // 当前选中的日历时间
  423. this.selectDateValue = selectDate
  424. this.visible = true; // 打开模态框
  425. this.selectDate = value.format('YYYY-MM-DD 00:00:00')
  426. var _this = this;
  427. getAction(this.url.queryList, {
  428. schemeLayoutId: this.schemeLayoutId,
  429. realDate:this.selectDate
  430. }).then((res) => {
  431. if (res.success) {
  432. _this.moneyDays = res.result;
  433. }
  434. }).finally(()=>{
  435. });
  436. },
  437. // 切换年月
  438. onPanelChange(val) {
  439. this.starT = dayjs(val).format('YYYY-MM-01 00:00:00')
  440. this.endT = dayjs(val).add(1, 'month').format('YYYY-MM-01 00:00:00')
  441. // this.loadData(this.starT, this.endT)//重新加载数据
  442. },
  443. // 获取日历的日期
  444. getCaledarDate(value){
  445. let str = value.format('YYYY-MM-DD').substring(5, 10);
  446. // if(str[0]=='0'){
  447. // str = str.substring(1,2)
  448. // }
  449. return str
  450. },
  451. // 获取日历的日期
  452. getCaledarRealDate(value) {
  453. let str = value.format('YYYY-MM-DD');
  454. // if(str[0]=='0'){
  455. // str = str.substring(1,2)
  456. // }
  457. return str
  458. },
  459. headerRender({ value, type, onChange, onTypeChange }) {
  460. const start = 0
  461. const end = 12
  462. const monthOptions = []
  463. const current = value.clone()
  464. const localeData = value.localeData()
  465. const months = []
  466. for (let i = 0; i < 12; i++) {
  467. current.month(i)
  468. months.push(localeData.monthsShort(current))
  469. }
  470. for (let index = start; index < end; index++) {
  471. monthOptions.push(
  472. <a-select-option class="month-item" key={`${index}`}>
  473. {months[index]}
  474. </a-select-option>
  475. )
  476. }
  477. const month = value.month()
  478. const year = value.year()
  479. const options = []
  480. for (let i = year - 10; i < year + 10; i += 1) {
  481. options.push(
  482. <a-select-option key={i} value={i} class="year-item">
  483. {i + '年'}
  484. </a-select-option>
  485. )
  486. }
  487. // 批量修改价格
  488. var batchStartDate = '';
  489. var batchEndDate = '';
  490. const batchUpdateMoney = () =>{
  491. var _money = document.getElementById("batchMoney").value;
  492. if(_money == '' || _money < 0){
  493. this.$message.warning("请输入正确房价!");
  494. return;
  495. }
  496. if (batchStartDate == '' || batchEndDate == ''){
  497. this.$message.warning("请选择正确时间!");
  498. return;
  499. }
  500. var param = {
  501. schemeLayoutId:this.schemeLayoutId,
  502. hotelId:hotelInfo.id,
  503. startDate:batchStartDate,
  504. endDate:batchEndDate,
  505. money:_money,
  506. }
  507. console.log(param)
  508. var that = this;
  509. that.confirmLoading = true;
  510. httpAction(this.url.batchUpdatePrice,param,"POST").then((res)=>{
  511. if(res.success){
  512. that.$message.success("操作成功");
  513. // that.$emit('ok');
  514. getAction(that.url.queryList, {
  515. schemeLayoutId: that.schemeLayoutId,
  516. realDate:that.selectDate
  517. }).then((res) => {
  518. if (res.success) {
  519. that.moneyDays = res.result;
  520. }
  521. }).finally(()=>{
  522. });
  523. }else{
  524. that.$message.warning(res.message);
  525. }
  526. }).finally(() => {
  527. that.confirmLoading = false;
  528. that.visibleMoney = false
  529. })
  530. }
  531. const onBatchChange = (e, dateString) =>{
  532. // console.log("Selected Time: ", e);
  533. console.log("Formatted Selected Time: ", dateString);
  534. batchStartDate = dateString[0]
  535. batchEndDate = dateString[1]
  536. }
  537. /* 上个月 */
  538. const prevMonth = () => {
  539. let newMonth = moment(value).subtract(1, 'months');
  540. onChange(newMonth);
  541. };
  542. /* 下个月 */
  543. const nextMonth = () => {
  544. let newMonth = moment(value).add(1, 'months');
  545. onChange(newMonth);
  546. };
  547. // 返回今天
  548. const showTotay = () => {
  549. const today = moment(new Date())
  550. onChange(today)
  551. }
  552. return (
  553. <div style={{ padding: ' 15px 15px 40px 15px', textAlign: 'center', position: 'relative'}}>
  554. <div style={{display: 'inline-block', textAlign: 'center'}}>
  555. <a-select
  556. dropdownMatchSelectWidth={false}
  557. class="header-select"
  558. onChange={newYear => {
  559. const now = value.clone().year(newYear)
  560. onChange(now)
  561. }}
  562. value={Number(year)}
  563. >
  564. {options}
  565. </a-select>
  566. <a-select
  567. dropdownMatchSelectWidth={false}
  568. class="header-select"
  569. value={String(month)}
  570. onChange={selectedMonth => {
  571. const newValue = value.clone()
  572. newValue.month(parseInt(selectedMonth, 10))
  573. onChange(newValue)
  574. }}
  575. >
  576. {monthOptions}
  577. </a-select>
  578. </div>
  579. <div style={{position: 'absolute',right: '15px',top: '15px'}}>
  580. <a-button-group>
  581. <a-button type="primary" onClick={() => prevMonth()}><a-icon type="left" />上一月</a-button>
  582. <a-button type="primary" onClick={() => showTotay()}>返回今日</a-button>
  583. <a-button type="primary" onClick={() => nextMonth()}>下一月<a-icon type="right" /></a-button>
  584. </a-button-group>
  585. </div>
  586. <div class="header-title">
  587. <div class="header-title-content">
  588. <a-range-picker class="margin-left-10" id="batchDate" onChange={(e,date)=>onBatchChange(e,date)} />
  589. <a-input-number style={{width:'100px'}} class="margin-left-10" id="batchMoney" placeholder="请输入房价" min="0" precision='2'/>
  590. <a-button class="margin-left-10" type="primary" onClick={() => batchUpdateMoney()}>
  591. 确定
  592. </a-button>
  593. </div>
  594. </div>
  595. </div>
  596. )
  597. },
  598. }
  599. }
  600. </script>
  601. <style>
  602. /*日历头部*/
  603. .header-select{
  604. margin-right: 10px;
  605. }
  606. /deep/ .header-select .ant-select-selection-selected-value {
  607. color: #222;
  608. font-weight: bold;
  609. font-size: 16px;
  610. }
  611. .header-title{
  612. font-weight: bold;
  613. font-size: 17px;
  614. color: #222;
  615. padding-top: 10px;
  616. }
  617. .header-title-content{
  618. text-align: right;
  619. }
  620. .margin-left-10{
  621. margin-left: 10px;
  622. }
  623. /*日历单元格,存在内容时,背景为灰色*/
  624. /deep/ .ant-fullcalendar-date-has-content {
  625. background-color: #f3f3f3;
  626. }
  627. /*日历单元格-今天 背景*/
  628. /deep/ .ant-fullcalendar-fullscreen .ant-fullcalendar-today .ant-fullcalendar-date::after {
  629. content: '今天';
  630. font-size: 30px;
  631. position: absolute;
  632. width: 100%;
  633. text-align: right;
  634. right: 6px;
  635. bottom: 0;
  636. color: rgba(145, 211, 255, 0.65);
  637. letter-spacing: 5px;
  638. font-weight: bold;
  639. }
  640. .table-color-dust {
  641. background-color: #F5222D;
  642. }
  643. .cell_style {
  644. color: red !important;
  645. /* color: #f6de90; */
  646. }
  647. .cell_stylez {
  648. color: #000 !important;
  649. }
  650. </style>