detail.blade.php 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. @extends('layouts.base')
  2. @section('content')
  3. @section('title', '工作时间')
  4. <link rel="stylesheet" href="{{resource_get('plugins/reserve-simple/src/static/index.css')}}">
  5. @include('public.admin.box-item')
  6. <style type="text/css">
  7. .my-calendar .fc-day{
  8. cursor: pointer;
  9. }
  10. .vue-title-yz-modular{
  11. margin: 0 10px 10px 10px;
  12. }
  13. .el-calendar-table .el-calendar-day{
  14. padding: 0;
  15. height: 120px;
  16. }
  17. .add .el-dialog__body{
  18. height:200px;
  19. }
  20. .el-table td, .el-table th.is-leaf{
  21. text-align:center;
  22. }
  23. .el-dialog{border-radius: 10px;}
  24. </style>
  25. <div class="all">
  26. <div>
  27. <div id="app">
  28. <div class="vue-crumbs">
  29. <a @click="goBack()">工作时间管理</a> > 编辑工作时间
  30. </div>
  31. <box-item text="编辑工作时间">
  32. <div>
  33. <span>默认工作时间</span>
  34. <el-button type="primary" @click="addDate">添加默认工作时间</el-button>
  35. </div>
  36. <el-table :data="default_times" style="width: 100%;margin:20px 0;">
  37. <el-table-column prop="id" label="ID"></el-table-column>
  38. <el-table-column prop="work_hour_start" label="开始时间"></el-table-column>
  39. <el-table-column prop="work_hour_end" label="结束时间"></el-table-column>
  40. <el-table-column prop="work_hour_end" label="操作">
  41. <template slot-scope="scope">
  42. <el-button type="text" @click="delTime(scope.row.id)">删除</el-button>
  43. </template>
  44. </el-table-column>
  45. </el-table>
  46. <el-calendar v-model="value" :data="{type:'current-month', isSelected:true, day:' yyyy-MM-dd'}">
  47. <template slot="dateCell" slot-scope="{date, data}">
  48. <div style="width: 100%;height:100%;padding:8px;overflow-y: auto;" @click="changeDate(date, data)">
  49. <div style="text-align:right;">[[data.day.split('-').slice(2).join('-')]]</div>
  50. <template v-for="(item,i) in dateData(data).periods">
  51. <div style="background-color: #29BA9C;color:#fff;margin:5px 0;padding:2px;border-radius: 4px;" v-if="item.status==1">[[item.title]]</div>
  52. <div style="background-color: #DCDFE6;color:#fff;margin:5px 0;padding:2px;border-radius: 4px;" v-else>[[item.title +" 休息"]]</div>
  53. </template>
  54. </div>
  55. </template>
  56. </el-calendar>
  57. </box-item>
  58. <div class="add">
  59. <el-dialog title="默认工作时间" :visible.sync="dialogVisible" width="30%">
  60. <div style="display:flex;align-items: center;justify-content: center;">
  61. <el-time-picker v-model="startTime" placeholder="开始时间" format="HH:mm" value-format="HH:mm"></el-time-picker>
  62. <div style="margin:0 10px;width:10px;height:1px;border:1px solid #ccc;"></div>
  63. <el-time-picker v-model="endTime" placeholder="结束时间" format="HH:mm" value-format="HH:mm"></el-time-picker>
  64. </div>
  65. <span slot="footer" class="dialog-footer">
  66. <el-button @click="dialogVisible = false">取 消</el-button>
  67. <el-button type="primary" @click="addTimeEnter">确 定</el-button>
  68. </span>
  69. </el-dialog>
  70. </div>
  71. <el-dialog title="编辑" :visible.sync="dateShow" width="1000px" @close="dateClose">
  72. <box-item text="编辑工作时间">
  73. <div style="margin-bottom:20px;">预约对象:[[obj_info.name]]</div>
  74. <div style="margin-bottom:20px;">
  75. <span>工作时间</span>
  76. <el-button type="primary" @click="time_list.push({isEdit:true,work_hour_end_str:'',work_hour_start_str:'',isAdd:true})">添加工作时间</el-button>
  77. </div>
  78. <el-table :data="time_list" style="width: 100%;margin:20px 0;">
  79. <el-table-column prop="id" label="ID" width="50"></el-table-column>
  80. <el-table-column prop="work_hour_start_str" label="开始时间" width="240">
  81. <template slot-scope="scope">
  82. <template v-if="!scope.row.isEdit">[[scope.row.work_hour_start_str]]</template>
  83. <el-time-picker v-model="scope.row.work_hour_start_str" placeholder="开始时间" format="HH:mm" value-format="HH:mm" v-else></el-time-picker>
  84. </template>
  85. </el-table-column>
  86. <el-table-column prop="work_hour_end_str" label="结束时间" width="240">
  87. <template slot-scope="scope">
  88. <template v-if="!scope.row.isEdit">[[scope.row.work_hour_end_str]]</template>
  89. <el-time-picker v-model="scope.row.work_hour_end_str" placeholder="开始时间" format="HH:mm" value-format="HH:mm" v-else></el-time-picker>
  90. </template>
  91. </el-table-column>
  92. <el-table-column label="状态">
  93. <template slot-scope="scope" v-if="!scope.row.isAdd">[[scope.row.status==0?"休息":"正常"]]</template>
  94. </el-table-column>
  95. <el-table-column label="操作" width="240">
  96. <template slot-scope="scope">
  97. <template v-if="!scope.row.isEdit">
  98. <el-button type="warning" size="mini" @click="scope.row.isEdit=true" >编辑</el-button>
  99. <el-button type="primary" size="mini" @click="changeEditStatus(scope.row)">[[scope.row.status==1?"休息":"工作"]]</el-button>
  100. <el-button type="danger" size="mini" @click="delteTime(scope.row)" >删除</el-button>
  101. </template>
  102. <el-button type="primary" size="mini" @click="editEnter(scope.row)" v-if="scope.row.isEdit">[[scope.row.isAdd?"确认添加":"保存"]]</el-button>
  103. <el-button type="danger" size="mini" @click="time_list.splice(time_list.length-1,1)" v-if="scope.row.isAdd">取消</el-button>
  104. </template>
  105. </el-table-column>
  106. </el-table>
  107. </box-item>
  108. </el-dialog>
  109. <div class="vue-page" style="text-align:center;">
  110. <el-button type="primary" @click="$message.success('提交成功')">提交</el-button>
  111. </div>
  112. </div>
  113. </div>
  114. </div>
  115. <script>
  116. let vm = new Vue({
  117. el:"#app",
  118. delimiters: ['[[', ']]'],
  119. data(){
  120. let obj_id = "{{ request()-> obj_id }}";
  121. return {
  122. value:new Date(),
  123. dialogVisible:false,
  124. startTime:"",
  125. endTime:"",
  126. obj_id,
  127. date_times:[],
  128. default_times:[],
  129. obj_info:{},
  130. time_list:[],
  131. dateShow:false,
  132. work_date:"",
  133. }
  134. },
  135. created(){
  136. this.getData();
  137. },
  138. methods:{
  139. goBack(){
  140. window.history.go(-1);
  141. },
  142. addTimeEnter(){
  143. if (this.startTime=="") {
  144. this.$message.error("开始时间不能为空");
  145. return false;
  146. }else if(this.endTime==""){
  147. this.$message.error("结束时间不能为空");
  148. return false;
  149. }else if(this.endTime==this.startTime){
  150. this.$message.error("开始时间不能和结束时间相同");
  151. return false;
  152. }else{
  153. let s = this.startTime.split(":");
  154. let e = this.endTime.split(":");
  155. if(s[0]<e[0] || (s[0]==e[0] && s[1]<e[1])) this.addDefaultWorkTimes(this.startTime,this.endTime)
  156. else this.addDefaultWorkTimes(this.endTime,this.startTime)
  157. }
  158. },
  159. addDefaultWorkTimes(time_start,time_end){
  160. let json = {obj_id:this.obj_id,time_start,time_end};
  161. this.$http.post("{!!yzWebFullUrl('plugin.reserve-simple.admin.workTime.addDefaultWorkTimes')!!}",json).then(({data:{result,msg}})=>{
  162. if(result==1){
  163. this.$message.success("设置成功");
  164. this.startTime="";
  165. this.endTime="";
  166. this.getData();
  167. this.dialogVisible = false;
  168. }else this.$message.error(msg);
  169. })
  170. },
  171. delteTime({id:time_id}){
  172. this.$confirm('确定删除吗', '提示', {confirmButtonText: '确定',cancelButtonText: '取消',type: 'warning'}).then(() => {
  173. let loading = this.$loading({ lock: true,text: '删除中',spinner: 'el-icon-loading',background: 'rgba(0, 0, 0, 0.7)'});
  174. this.$http.post("{!!yzWebFullUrl('plugin.reserve-simple.admin.workTime.deleteWorkTime')!!}",{time_id}).then(({data:{result,msg,data}})=>{
  175. loading.close();
  176. if(result==1){
  177. this.$message.success("删除成功");
  178. this.getTime_list();
  179. }else this.$message.error(msg);
  180. })
  181. })
  182. },
  183. delTime(time_id){
  184. this.$confirm('确定删除吗', '提示', {confirmButtonText: '确定',cancelButtonText: '取消',type: 'warning'}).then(() => {
  185. let loading = this.$loading({ lock: true,text: '删除中',spinner: 'el-icon-loading',background: 'rgba(0, 0, 0, 0.7)'});
  186. this.$http.post("{!!yzWebFullUrl('plugin.reserve-simple.admin.workTime.delDefaultWorkTimes')!!}",{time_id}).then(({data:{result,msg,data}})=>{
  187. loading.close();
  188. if(result==1){
  189. this.$message.success("删除成功");
  190. this.dialogVisible = false;
  191. this.getData();
  192. }else this.$message.error(msg);
  193. })
  194. })
  195. },
  196. getData(){
  197. this.$http.post("{!!yzWebFullUrl('plugin.reserve-simple.admin.workTime.getAllWorkTimes')!!}",{obj_id:this.obj_id}).then(({data:{result,msg,data}})=>{
  198. if(result == 1){
  199. this.default_times = data.default_times;
  200. this.date_times = data.date_times;
  201. }
  202. })
  203. },
  204. dateData({day}){
  205. for (let index = 0; index < this.date_times.length; index++) {
  206. let data = this.date_times[index];
  207. if(data.work_date == day){
  208. return data
  209. }
  210. }
  211. return []
  212. },
  213. addDate(){
  214. this.dialogVisible = true;
  215. },
  216. changeDate(date,{day}){
  217. this.dateShow = true;
  218. this.getTime_list(day);
  219. },
  220. getTime_list(day){
  221. let json = {obj_id:this.obj_id,work_date:day};
  222. this.$http.post("{!!yzWebFullUrl('plugin.reserve-simple.admin.workTime.getDateWorkTimesDetail')!!}",json).then(({data:{result,msg,data}})=>{
  223. if(result==1){
  224. this.obj_info = data.obj_info;
  225. this.time_list = data.time_list.map(item=>{
  226. item.isEdit = false;
  227. return item
  228. });
  229. this.work_date = data.work_date;
  230. }else this.$message.error(msg)
  231. })
  232. },
  233. addEnter({work_hour_start_str,work_hour_end_str}){
  234. if (work_hour_start_str=="") {
  235. this.$message.error("开始时间不能为空");
  236. return false;
  237. }else if(work_hour_end_str==""){
  238. this.$message.error("结束时间不能为空");
  239. return false;
  240. }else if(work_hour_end_str==work_hour_start_str){
  241. this.$message.error("开始时间不能和结束时间相同");
  242. return false;
  243. }else{
  244. let s = work_hour_start_str.split(":");
  245. let e = work_hour_end_str.split(":");
  246. let json = {
  247. obj_id:this.obj_id,
  248. work_date:this.work_date,
  249. hour_start:work_hour_start_str,
  250. hour_end:work_hour_end_str
  251. }
  252. if(s[0]>e[0] || (s[0]==e[0] && s[1]>e[1])){
  253. json.hour_start = work_hour_end_str;
  254. json.hour_end = work_hour_start_str;
  255. }
  256. this.$http.post("{!!yzWebFullUrl('plugin.reserve-simple.admin.workTime.addDateWorkTimes')!!}",json).then(({data:{result,msg}})=>{
  257. if(result==1){
  258. this.getTime_list(this.work_date);
  259. this.$message.success(msg);
  260. }else this.$message.error(msg);
  261. })
  262. }
  263. },
  264. editEnter(row){
  265. if(row.isAdd){
  266. this.addEnter(row);
  267. return false;
  268. }
  269. let json = {
  270. time_id:row.id,
  271. hour_start:row.work_hour_start_str,
  272. hour_end:row.work_hour_end_str,
  273. }
  274. this.$http.post("{!!yzWebFullUrl('plugin.reserve-simple.admin.workTime.eidtDateWorkTimes')!!}",json).then(({data:{result,msg}})=>{
  275. if(result==1){
  276. this.$message.success(msg);
  277. row.isEdit = false;
  278. this.getData();
  279. }else this.$message.error(msg);
  280. })
  281. },
  282. changeEditStatus({id,status}){
  283. let json = {time_id:id,status:status==0?1:0};
  284. console.log(json);
  285. this.$http.post("{!!yzWebFullUrl('plugin.reserve-simple.admin.workTime.changeStatus')!!}",json).then(({data:{result,msg}})=>{
  286. if(result==1){
  287. this.$message.success(msg);
  288. this.getTime_list(this.work_date);
  289. }
  290. else this.$message.error(msg);
  291. })
  292. },
  293. dateClose(){
  294. this.getData();
  295. this.$forceUpdate();
  296. }
  297. }
  298. })
  299. </script>
  300. @endsection