dialog.template.vue 13 KB

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