dialog.template.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  1. <template>
  2. <div class="question-infos">
  3. <DialogCom :title="title" @close="handleClose" :visible.sync="isShow" :close-on-click-modal="false"
  4. custom-class="gxDialog" width="1100px" append-to-body>
  5. <!-- <div class="p-5 work-time-modify">-->
  6. <el-form
  7. :disabled="title === '查看作息模版'"
  8. label-width="100px"
  9. label-suffix=""
  10. label-position="left">
  11. <el-form-item>
  12. <span slot="label"> <span style="color: red"> * </span>机构 </span>
  13. <org-tree-select v-model="formData.orgIds" :checkShow="true" :disabled="disabled" ></org-tree-select>
  14. </el-form-item>
  15. <el-form-item >
  16. <span slot="label"> <span style="color: red"> * </span>生效日期 </span>
  17. <el-date-picker
  18. v-model="formData.effectiveDate"
  19. value-format="yyyy-MM-dd hh:mm:ss"
  20. :disabled="disabled"
  21. :clearable="!disabled"
  22. :picker-options="startDatepickerOptions"
  23. popper-class="no-atTheMoment"
  24. type="date"
  25. placeholder="请选择日期">
  26. </el-date-picker>
  27. </el-form-item>
  28. <!-- -->
  29. <div class="grid" >
  30. <p>
  31. <span style="color: red;"> * </span>作息设置
  32. </p >
  33. <div class="box">
  34. <el-table border :data="formData.dayOfWeeks">
  35. <el-table-column label="星期" width="100px" prop="dayOfWeekText">
  36. </el-table-column>
  37. <el-table-column label="营业状态">
  38. <template slot-scope="r">
  39. <!-- <el-switch-->
  40. <!-- v-model="r.row.isWorkday"-->
  41. <!-- :active-value="1"-->
  42. <!-- :inactive-value="0"-->
  43. <!-- @change="onEnableChange(r.row)"-->
  44. <!-- active-text="营业"-->
  45. <!-- inactive-text="歇业">-->
  46. <!-- </el-switch>-->
  47. <el-radio-group
  48. v-model="r.row.isWorkday"
  49. @change="onEnableChange(r.row)">
  50. <el-radio text-color="#48bb78" label="1">营业</el-radio>
  51. <el-radio text-color="#f56565" label="0">歇业</el-radio>
  52. </el-radio-group>
  53. </template>
  54. </el-table-column>
  55. <el-table-column label="值班打卡">
  56. <template slot-scope="r">
  57. <el-switch
  58. v-model="r.row.isDuty"
  59. active-value="1"
  60. inactive-value="0"
  61. @change="onEnableChange(r.row)"
  62. active-text="是"
  63. inactive-text="否">
  64. </el-switch>
  65. <!-- <el-radio-group-->
  66. <!-- v-model="r.row.isWorkday"-->
  67. <!-- @change="onEnableChange(r.row)">-->
  68. <!-- <el-radio text-color="#48bb78" label="1">营业</el-radio>-->
  69. <!-- <el-radio text-color="#f56565" label="0">歇业</el-radio>-->
  70. <!-- </el-radio-group>-->
  71. </template>
  72. </el-table-column>
  73. <el-table-column label="上班时间">
  74. <template slot-scope="r">
  75. <el-time-select
  76. style="width: 100%"
  77. size="mini"
  78. :picker-options="pickerOptions"
  79. :disabled="r.row.isWorkday=='0' ||!r.row.isWorkday"
  80. v-model="r.row.workTime"/>
  81. </template>
  82. </el-table-column>
  83. <el-table-column label="营业开始">
  84. <template slot-scope="r">
  85. <el-time-select
  86. style="width: 100%"
  87. size="mini"
  88. :picker-options="pickerOptions"
  89. :disabled="r.row.isWorkday=='0' ||!r.row.isWorkday"
  90. v-model="r.row.openTime"/>
  91. </template>
  92. </el-table-column>
  93. <!-- <el-table-column label="午休开始">-->
  94. <!-- <template slot-scope="r">-->
  95. <!-- <el-time-select-->
  96. <!-- style="width: 100%"-->
  97. <!-- size="mini"-->
  98. <!-- :picker-options="pickerOptions"-->
  99. <!-- :disabled="!r.row.isWorkday || !r.row.isWorkday"-->
  100. <!-- v-model="r.row.noonbreakStart"/>-->
  101. <!-- </template>-->
  102. <!-- </el-table-column>-->
  103. <!-- <el-table-column label="午休结束">-->
  104. <!-- <template slot-scope="r">-->
  105. <!-- <el-time-select-->
  106. <!-- style="width: 100%"-->
  107. <!-- size="mini"-->
  108. <!-- :picker-options="pickerOptions"-->
  109. <!-- :disabled="!r.row.isWorkday || !r.row.isWorkday"-->
  110. <!-- v-model="r.row.noonbreakEnd"/>-->
  111. <!-- </template>-->
  112. <!-- </el-table-column>-->
  113. <el-table-column label="营业结束">
  114. <template slot-scope="r">
  115. <el-time-select
  116. style="width: 100%"
  117. size="mini"
  118. :picker-options="pickerOptions"
  119. :disabled="r.row.isWorkday=='0' || !r.row.isWorkday"
  120. v-model="r.row.closeTime"/>
  121. </template>
  122. </el-table-column>
  123. <el-table-column label="下班时间">
  124. <template slot-scope="r">
  125. <el-time-select
  126. style="width: 100%"
  127. size="small"
  128. :picker-options="pickerOptions"
  129. :disabled="r.row.isWorkday=='0' ||!r.row.isWorkday"
  130. v-model="r.row.workOffTime"/>
  131. </template>
  132. </el-table-column>
  133. </el-table>
  134. </div>
  135. </div>
  136. </el-form>
  137. <div style="color: red;font-size: 12px;line-height: 30px;">
  138. 注:保存后生成或更新本月或下月生效日期后的每日作息
  139. </div>
  140. <!-- </div>-->
  141. <div v-if="title != '查看作息模版'" slot="footer" class="dialog-footer">
  142. <el-button @click="handleClose">取消</el-button>
  143. <btn-tip tip="确定要提交吗?" type="primary" @click="onSubmit">保存</btn-tip>
  144. </div>
  145. </DialogCom>
  146. <DialogCom
  147. title="提示"
  148. :visible="centerDialogVisible"
  149. width="25%"
  150. @close="centerDialogVisible=false"
  151. center>
  152. <span>所选机构中在当前生效日期内已有按指定日期配置的作息数据,是否覆盖按指定日期配置的作息数据?</span>
  153. <span slot="footer" class="dialog-footer">
  154. <el-button @click="submitData(0)">不覆盖</el-button>
  155. <el-button type="primary" @click="submitData(1)">覆盖</el-button>
  156. </span>
  157. </DialogCom>
  158. <DialogCom
  159. title="提示"
  160. :visible="centerDialogVisiblea"
  161. width="25%"
  162. @close="centerDialogVisiblea=false"
  163. center>
  164. <span>已存在其他生效的配置,将会生成{{checkMsg}}的作息,是否提交?</span>
  165. <span slot="footer" class="dialog-footer">
  166. <el-button type="primary" @click="checkDataMsg(1)">提交</el-button>
  167. <el-button @click="handleClose()">取消</el-button>
  168. </span>
  169. </DialogCom>
  170. </div>
  171. </template>
  172. <script>
  173. import BtnTip from "@/components/btnTip";
  174. import OrgTreeSelect from '@/components/orgTreeSelect'
  175. import { timeCheck } from "@/utils/ruoyi";
  176. import {addTimeWeek, queryInfoById} from "@/views/system/workTimeSet/api";
  177. import {json} from './json' //导入默认数据
  178. export default {
  179. components:{BtnTip,OrgTreeSelect},
  180. data() {
  181. return {
  182. title:'',
  183. isShow: false,
  184. row:null,
  185. id:0,
  186. orgId:null,
  187. formData: {
  188. orgIds:[],
  189. dayOfWeeks: null,
  190. effectiveDate:null,
  191. },
  192. disabled: false,
  193. startDatepickerOptions: {
  194. disabledDate(time) {
  195. const date = new Date();
  196. date.setTime(date.getTime() );
  197. return time.getTime() < date;
  198. },
  199. },
  200. centerDialogVisible: false,
  201. centerDialogVisiblea:false,
  202. checkData:null,
  203. checkMsg:null,
  204. //回显tag
  205. tagsList:[]
  206. };
  207. },
  208. props: {},
  209. watch: {
  210. },
  211. computed: {
  212. pickerOptions() {
  213. return {
  214. start: "00:00",
  215. end: "24:00",
  216. step: "00:05",
  217. };
  218. },
  219. },
  220. methods: {
  221. edit(row){
  222. this.title = '编辑作息模版';
  223. this.isShow = true;
  224. this.id = row.id;
  225. this.orgId = row.orgId;
  226. this.getData();
  227. },
  228. add(){
  229. this.title = '新增作息模版';
  230. this.formData.dayOfWeeks = JSON.parse(JSON.stringify(json));
  231. this.isShow = true;
  232. },
  233. show(row) {
  234. this.title = '查看作息模版';
  235. this.isShow = true;
  236. this.id = row.id;
  237. this.orgId = row.orgId;
  238. this.disabled = true;
  239. this.getData();
  240. },
  241. onSubmit() {
  242. if (this.formData.orgIds.length < 1) {
  243. this.$message.error("机构不能为空");
  244. return;
  245. }
  246. if (!this.formData.effectiveDate ) {
  247. this.$message.error("生效日期不能为空");
  248. return;
  249. }
  250. if (this.formData.dayOfWeeks.filter(w => w.isWorkday == 1 || w.isWorkday).length === 0) {
  251. this.$message.error("工作日不能为空");
  252. return;
  253. }
  254. // 校验
  255. for (let workTime of this.formData.dayOfWeeks) {
  256. if (!this.checkItem(workTime)) {
  257. return;
  258. }
  259. }
  260. addTimeWeek(this.formData).then(res=>{
  261. this.handleClose();
  262. this.$emit("ok");
  263. })
  264. },
  265. checkItem(dayOfWeek){
  266. console.log(dayOfWeek,'dayOfWeek');
  267. //是否启用
  268. if(dayOfWeek.isWorkday == '0') return true;
  269. if (!( dayOfWeek.openTime && dayOfWeek.closeTime)) {
  270. this.$message.error(`${dayOfWeek.dayOfWeekText}的营业时间未完整配置`);
  271. return;
  272. }
  273. // if (!dayOfWeek.noonbreakStart ^ !dayOfWeek.noonbreakEnd) {
  274. // this.$message.error(`${dayOfWeek.dayOfWeekText}的午休开始及结束时间必须同时配置`);
  275. // return;
  276. // }
  277. let arr = [dayOfWeek.openTime,dayOfWeek.closeTime];
  278. if (!timeCheck(arr)) {
  279. this.$message.error(`${dayOfWeek.dayOfWeekText}的营业开始时间应在营业结束之前`);
  280. return false;
  281. }
  282. return true;
  283. },
  284. async submitData(result){
  285. this.centerDialogVisible=false;
  286. this.centerDialogVisiblea=false;
  287. this.formData.checkDataResult =result;
  288. // this.$api.workTimeMonth.timeSetAdd(this.formData).then((v) => {
  289. // this.$emit("success");
  290. // this.onHide();
  291. // });
  292. },
  293. async getData() {
  294. queryInfoById({id:this.id}).then(res=>{
  295. res.data.effectiveDate = new Date(res.data.effectiveDate);
  296. this.formData = res.data;
  297. this.formData.orgIds = [res.data.orgId];
  298. })
  299. },
  300. onEnableChange(workTime) {
  301. if (workTime.isWorkday=='0') {
  302. workTime.openTime = null;
  303. workTime.closeTime = null;
  304. // workTime.noonbreakStart = null;
  305. // workTime.noonbreakEnd = null;
  306. workTime.workTime = null;
  307. workTime.workOffTime = null;
  308. }
  309. },
  310. handleClose() {
  311. this.id=null;
  312. this.formData = {
  313. orgIds: [],
  314. dayOfWeeks: null,
  315. effectiveDate: null,
  316. checkDataResult:null,
  317. };
  318. this.tagsList = [];
  319. this.disabled= false;
  320. this.checkData=null;
  321. this.checkMsg=null;
  322. this.centerDialogVisiblea=false;
  323. this.centerDialogVisible=false;
  324. this.isShow = false;
  325. },
  326. },
  327. };
  328. </script>
  329. <style lang="scss" scoped>
  330. .work-time-modify {
  331. .red {
  332. color: red;
  333. }
  334. .grid {
  335. width: 100%;
  336. .title {
  337. }
  338. .box {
  339. padding: 20px;
  340. border: 1px solid #000000;
  341. background: #ffffff;
  342. .time {
  343. }
  344. }
  345. }
  346. //
  347. .el-input {
  348. width: 400px;
  349. }
  350. .el-table {
  351. .el-date-editor.el-input {
  352. width: 100%;
  353. }
  354. }
  355. .el-dialog__body {
  356. overflow-y: auto;
  357. min-height: 200px;
  358. }
  359. }
  360. </style>