dialog.template.vue 13 KB

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