1 line
6.1 KiB
JavaScript
1 line
6.1 KiB
JavaScript
(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-45f7d646"],{"005a":function(t,e,n){"use strict";n.r(e);var a=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{staticClass:"pro_scheduling"},[n("div",{staticClass:"pick"},[n("span",[t._v("当前日期:"+t._s(t.yue?t.yue:t.dDate))]),n("el-date-picker",{attrs:{"value-format":"yyyy-MM",format:"yyyy 年 MM 月",type:"month",placeholder:"选择日期"},on:{change:t.changeYue},model:{value:t.yue,callback:function(e){t.yue=e},expression:"yue"}})],1),n("el-calendar",{scopedSlots:t._u([{key:"dateCell",fn:function(e){var a=e.date;return[n("div",[n("div",[t._v(t._s(a.getDate()))]),t.isDateAvailable(a)?n("div",[n("el-button",{attrs:{type:"primary",disabled:!t.isDateAvailable(a)},on:{click:function(e){return t.bookDate(a)}}},[t._v(" 可预约 ")]),n("div",{staticClass:"yy"},[t._v("已约 "+t._s(t.bookedCount(a)))]),n("div",{staticClass:"yy"},[t._v("剩余 "+t._s(t.availableCount(a)))])],1):n("div",[n("el-button",{attrs:{disabled:""}},[t._v("不可预约")]),n("div",{staticClass:"test"},[t._v("已约 "+t._s(t.bookedCount(a)))]),n("div",{staticClass:"test"},[t._v("剩余 0")])],1)])]}}]),model:{value:t.yue,callback:function(e){t.yue=e},expression:"yue"}}),n("el-dialog",{attrs:{visible:t.dialogVisible,title:"编辑"},on:{"update:visible":function(e){t.dialogVisible=e},open:t.onOpen,close:t.onClose}},[n("el-form",{ref:"elForm",attrs:{model:t.formData,rules:t.rules,size:"medium","label-width":"100px"}},[n("el-form-item",{attrs:{label:"出行日期",prop:"date"}},[n("el-input",{style:{width:"100%"},attrs:{placeholder:"请输入单行文本单行文本",disabled:!0,clearable:""},model:{value:t.formData.date,callback:function(e){t.$set(t.formData,"date",e)},expression:"formData.date"}})],1),n("el-form-item",{attrs:{label:"可预约数量",prop:"num"}},[n("el-input",{style:{width:"100%"},attrs:{type:"number",placeholder:"请输入可预约数量",clearable:""},model:{value:t.formData.num,callback:function(e){t.$set(t.formData,"num",e)},expression:"formData.num"}})],1)],1),n("div",{attrs:{slot:"footer"},slot:"footer"},[n("el-button",{on:{click:t.close}},[t._v("取消")]),n("el-button",{attrs:{type:"primary"},on:{click:t.handelConfirm}},[t._v("确定")])],1)],1)],1)},r=[],o=n("ade3"),i=n("c7eb"),u=n("1da1"),s=(n("99af"),n("d3b7"),n("4d90"),n("159b"),n("50fc")),c={data:function(){return{dialogVisible:!1,value:new Date,appointments:{},formData:{date:"",num:"",id:""},yue:"",dDate:"",rules:{num:[{required:!0,message:"请输入可预约数量",trigger:"blur"}]}}},created:function(){this.formData.id=this.$route.query.id,this.getList()},methods:Object(o["a"])(Object(o["a"])(Object(o["a"])(Object(o["a"])(Object(o["a"])(Object(o["a"])({getList:function(t){var e=this;return Object(u["a"])(Object(i["a"])().mark((function n(){var a,r,o,u,c,l;return Object(i["a"])().wrap((function(n){while(1)switch(n.prev=n.next){case 0:return a=e.value,r=a.getFullYear(),o=String(a.getMonth()+1).padStart(2,"0"),u="".concat(r,"-").concat(o),e.dDate=u,c={id:e.formData.id,date:t||u},n.next=8,Object(s["d"])(c);case 8:l=n.sent,l&&0===l.error&&(e.appointments={},l.data.forEach((function(t){e.$set(e.appointments,t.date,{books_num:t.books_num,left_num:t.left_num})})));case 10:case"end":return n.stop()}}),n)})))()},changeYue:function(){this.getList(this.yue)},isDateAvailable:function(t){var e=new Date;return e.setHours(0,0,0,0),t>=e}},"isDateAvailable",(function(t){var e=new Date;e.setHours(0,0,0,0);var n=this.yue?new Date(this.yue).getFullYear():e.getFullYear(),a=this.yue?new Date(this.yue).getMonth():e.getMonth(),r=t.getFullYear(),o=t.getMonth();return r>n||r===n&&o>a||r===n&&o===a&&t>=e})),"bookDate",(function(t){console.log("预约日期: ".concat(t.toLocaleDateString())),this.dialogVisible=!0,this.formData.date=t.toLocaleDateString()})),"onOpen",(function(){})),"onClose",(function(){this.$refs["elForm"].resetFields()})),"close",(function(){this.dialogVisible=!1})),"handelConfirm",(function(){var t=this;this.$refs["elForm"].validate(function(){var e=Object(u["a"])(Object(i["a"])().mark((function e(n){var a;return Object(i["a"])().wrap((function(e){while(1)switch(e.prev=e.next){case 0:if(n){e.next=2;break}return e.abrupt("return");case 2:return e.next=4,Object(s["a"])(t.formData);case 4:a=e.sent,0===a.error&&(t.$message.success("预约成功"),t.getList()),t.close();case 7:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}())})),computed:{availableCount:function(){var t=this;return function(e){var n,a=e.toISOString().split("T")[0];return(null===(n=t.appointments[a])||void 0===n?void 0:n.left_num)||0}},bookedCount:function(){var t=this;return function(e){var n,a=e.toISOString().split("T")[0];return(null===(n=t.appointments[a])||void 0===n?void 0:n.books_num)||0}}}},l=c,d=(n("2175"),n("2877")),f=Object(d["a"])(l,a,r,!1,null,"81a84594",null);e["default"]=f.exports},"01a0":function(t,e,n){},2175:function(t,e,n){"use strict";n("01a0")},"50fc":function(t,e,n){"use strict";n.d(e,"e",(function(){return r})),n.d(e,"b",(function(){return o})),n.d(e,"f",(function(){return i})),n.d(e,"g",(function(){return u})),n.d(e,"d",(function(){return s})),n.d(e,"a",(function(){return c})),n.d(e,"c",(function(){return l})),n.d(e,"i",(function(){return d})),n.d(e,"h",(function(){return f}));n("99af");var a=n("b775");function r(){return Object(a["a"])({url:"admin/products/list",method:"get"})}function o(t){return Object(a["a"])({url:"/admin/products/add",method:"post",data:t})}function i(t){return Object(a["a"])({url:"/admin/products/list?page=".concat(t.page,"&limit=").concat(t.limit),method:"get"})}function u(t){return Object(a["a"])({url:"/admin/products/add",method:"post",data:t})}function s(t){return Object(a["a"])({url:"/admin/products/productschedules?id=".concat(t.id,"&date=").concat(t.date),method:"get"})}function c(t){return Object(a["a"])({url:"/admin/products/addproductschedules",method:"post",data:t})}function l(){return Object(a["a"])({url:"/admin/setting/getContractSetting",method:"get"})}function d(t){return Object(a["a"])({url:"/admin/setting/savecontractsetting",method:"post",data:t})}function f(){return Object(a["a"])({url:"/admin/setting/getContractSetting",method:"get"})}}}]); |