dialog.edit.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. <template>
  2. <div class="question-infos">
  3. <DialogCom title="编辑作息" @close="handleClose" :visible="show" width="800px" append-to-body>
  4. <div class="page-body">
  5. <el-form :model="formData" :rules="formData.isEnable?formDataRules:{}" size="small" ref="form" label-position="right"
  6. label-width="120px" label-prefix=":">
  7. <el-row :gutter="20">
  8. <el-col :span="24">
  9. <el-form-item prop="orgName" label="机构:" >
  10. <span>{{formData.orgName}}</span>
  11. </el-form-item>
  12. </el-col>
  13. <el-col :span="12">
  14. <el-form-item label="日期:">
  15. <span >{{formData.ymdDate}}</span>
  16. </el-form-item>
  17. </el-col>
  18. <el-col :span="12">
  19. <el-form-item label="星期:">
  20. <span>{{parseTime(formData.ymdDate,"dddd")}}</span>
  21. </el-form-item>
  22. </el-col>
  23. <el-col :span="12">
  24. <el-form-item prop="isEnable" label="状态:">
  25. <template >
  26. <el-radio-group v-model="formData.isEnable" @change="onEnableChange(formData)">
  27. <el-radio text-color="#48bb78" label="1">营业</el-radio>
  28. <el-radio text-color="#f56565" label="0">歇业</el-radio>
  29. </el-radio-group>
  30. </template>
  31. </el-form-item>
  32. </el-col>
  33. <el-col :span="12">
  34. <el-form-item prop="isEnable" label="值班打卡:">
  35. <template >
  36. <el-radio-group v-model="formData.isDuty">
  37. <el-radio text-color="#48bb78" label="1">是</el-radio>
  38. <el-radio text-color="#f56565" label="0">否</el-radio>
  39. </el-radio-group>
  40. </template>
  41. </el-form-item>
  42. </el-col>
  43. <el-col v-if="formData.isEnable == '1'" :span="12">
  44. <el-form-item prop="workTime" label="上班时间:">
  45. <template >
  46. <el-time-select
  47. :picker-options="pickerOptions"
  48. v-model="formData.workTime"/>
  49. </template>
  50. </el-form-item>
  51. </el-col>
  52. <el-col v-if="formData.isEnable == '1'" :span="12">
  53. <el-form-item prop="workOffTime" label="下班时间:">
  54. <template >
  55. <el-time-select
  56. :picker-options="pickerOptions"
  57. v-model="formData.workOffTime"/>
  58. </template>
  59. </el-form-item>
  60. </el-col>
  61. <!-- <el-col :span="12">-->
  62. <!-- <el-form-item prop="noonbreakStart" label="午休开始:">-->
  63. <!-- <template>-->
  64. <!-- <el-time-select-->
  65. <!-- :picker-options="pickerOptions"-->
  66. <!-- v-model="formData.noonbreakStart"-->
  67. <!-- :disabled="!formData.isEnable || formData.isEnable === false"/>-->
  68. <!-- </template>-->
  69. <!-- </el-form-item>-->
  70. <!-- </el-col>-->
  71. <!-- <el-col :span="12">-->
  72. <!-- <el-form-item prop="noonbreakEnd" label="午休结束:">-->
  73. <!-- <template >-->
  74. <!-- <el-time-select-->
  75. <!-- :picker-options="pickerOptions"-->
  76. <!-- v-model="formData.noonbreakEnd"-->
  77. <!-- :disabled="!formData.isEnable || formData.isEnable === false"/>-->
  78. <!-- </template>-->
  79. <!-- </el-form-item>-->
  80. <!-- </el-col>-->
  81. <el-col v-if="formData.isEnable == '1'" :span="12">
  82. <el-form-item prop="openTime" label="营业开始:">
  83. <template >
  84. <el-time-select
  85. :picker-options="pickerOptions"
  86. v-model="formData.openTime"/>
  87. </template>
  88. </el-form-item>
  89. </el-col>
  90. <el-col v-if="formData.isEnable == '1'" :span="12">
  91. <el-form-item prop="closeTime" label="营业结束:">
  92. <template >
  93. <el-time-select
  94. :picker-options="pickerOptions"
  95. v-model="formData.closeTime"/>
  96. </template>
  97. </el-form-item>
  98. </el-col>
  99. </el-row>
  100. </el-form>
  101. </div>
  102. <div slot="footer" class="dialog-footer">
  103. <el-button type="primary" @click="onSubmit">确定</el-button>
  104. <el-button @click="handleClose">取消</el-button>
  105. </div>
  106. </DialogCom>
  107. </div>
  108. </template>
  109. <script>
  110. import {queryOrgInfo,editWorkTime} from "@/views/system/workTimeSet/api";
  111. import {timeCheck }from '@/utils/ruoyi'
  112. export default {
  113. data() {
  114. return {
  115. //弹窗展示
  116. show:false,
  117. //选中的id
  118. id: null,
  119. //form数据
  120. formData: {},
  121. workTimeId:null,
  122. //表单验证
  123. formDataRules: {
  124. isEnable: [{ required: true, message: "请选择状态" }],
  125. workTime: [{ required: true, message: "请输入上班时间" }],
  126. workOffTime: [{ required: true, message: "请输入下班时间" }],
  127. // noonbreakStart: [{ required: true, message: "请输入午休开始时间" }],
  128. // noonbreakEnd: [{ required: true, message: "请输入午休结束时间" }],
  129. openTime: [{ required: true, message: "请输入营业开始时间" }],
  130. closeTime: [{ required: true, message: "请输入营业结束时间" }],
  131. },
  132. };
  133. },
  134. created() {
  135. },
  136. computed: {
  137. pickerOptions() {
  138. return {
  139. start: "00:00",
  140. end: "24:00",
  141. step: "00:05",
  142. };
  143. },
  144. },
  145. methods: {
  146. edit(row){
  147. this.orgId = row.id;
  148. queryOrgInfo(row.id).then(res=>{
  149. this.formData = res.data;
  150. this.show = true;
  151. })
  152. console.log(row,'11111')
  153. },
  154. reset() {
  155. return {
  156. isEnable: 1,
  157. openTime: null,
  158. closeTime: null,
  159. // noonbreakStart: null,
  160. // noonbreakEnd: null,
  161. workTime: null,
  162. workOffTime: null,
  163. };
  164. },
  165. onEnableChange(workTime) {
  166. if (workTime.isEnable == '0') {
  167. workTime.openTime = null;
  168. workTime.closeTime = null;
  169. // workTime.noonbreakStart = null;
  170. // workTime.noonbreakEnd = null;
  171. workTime.workTime = null;
  172. workTime.workOffTime = null;
  173. }
  174. },
  175. handleClose() {
  176. this.show = false;
  177. this.formData = this.reset();
  178. console.log(this.$refs.form,'from')
  179. this.$refs.form.clearValidate();
  180. this.id=null;
  181. },
  182. onSubmit() {
  183. this.$refs.form.validate((isValidate) => {
  184. if (!isValidate) return;
  185. // if (
  186. // !timeCheck([
  187. // this.formData.openTime,
  188. // this.formData.closeTime,
  189. // ])
  190. // ) {
  191. // this.$message.warning(`营业开始时间应在营业结束之前`);
  192. // return false;
  193. // }
  194. // if (
  195. // !timeCheck([
  196. // this.formData.workTime,
  197. // this.formData.workOffTime,
  198. // ])
  199. // ) {
  200. // this.$message.warning(`上班开始时间应在下班结束之前`);
  201. // return false;
  202. // }
  203. if (
  204. !timeCheck([
  205. this.formData.workTime,
  206. this.formData.openTime,
  207. this.formData.closeTime,
  208. this.formData.workOffTime,
  209. ])
  210. ) {
  211. this.$message.error(
  212. `请按照(上班时间<营业时间<营业结束<下班时间)顺序配置`
  213. );
  214. return false;
  215. }
  216. editWorkTime(this.formData).then(res=>{
  217. this.show = false;
  218. this.$message.success('操作成功')
  219. this.$emit('ok')
  220. })
  221. });
  222. },
  223. },
  224. };
  225. </script>
  226. <style lang="scss" scoped>
  227. .question-infos {
  228. .el-form {
  229. padding-top: 10px;
  230. }
  231. }
  232. .el-rate {
  233. margin-top: 6px;
  234. }
  235. .change-icon {
  236. font-size: 18px;
  237. }
  238. </style>