dialog.template.vue 12 KB

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