dialog.template.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385
  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="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="营业状态">
  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, 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. 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. queryNode(json){
  217. this.data.orgIdList = JSON.parse(json);
  218. console.log(this.orgIdList,'orgIdList')
  219. },
  220. edit(row){
  221. this.title = '编辑作息模版';
  222. this.isShow = true;
  223. this.formData = row;
  224. },
  225. add(){
  226. this.title = '新增作息模版';
  227. this.isShow = true;
  228. },
  229. show(row) {
  230. this.title = '查看作息模版';
  231. this.isShow = true;
  232. this.id = row.id;
  233. this.orgId = row.orgId;
  234. this.getData();
  235. },
  236. onSubmit() {
  237. this.formData.orgIds = this.data.orgIdList.map(v=>{
  238. return v.id
  239. });
  240. if (this.data.orgIdList.length < 1) {
  241. this.$message.error("机构不能为空");
  242. return;
  243. }
  244. if (!this.formData.effectiveDate ) {
  245. this.$message.error("生效日期不能为空");
  246. return;
  247. }
  248. if (this.formData.dayOfWeeks.filter(w => w.isWorkday == 1 || w.isWorkday).length === 0) {
  249. this.$message.error("工作日不能为空");
  250. return;
  251. }
  252. // 校验
  253. for (let workTime of this.formData.dayOfWeeks) {
  254. if (!this.checkItem(workTime)) {
  255. return;
  256. }
  257. }
  258. addTimeWeek(this.formData).then(res=>{
  259. this.$emit("ok");
  260. this.handleClose();
  261. })
  262. },
  263. checkItem(dayOfWeek){
  264. console.log(dayOfWeek,'dayOfWeek');
  265. //是否启用
  266. if(!dayOfWeek.isWorkday) return true;
  267. if (!( dayOfWeek.openTime && dayOfWeek.closeTime)) {
  268. this.$message.error(`${dayOfWeek.dayOfWeekText}的营业时间未完整配置`);
  269. return;
  270. }
  271. // if (!dayOfWeek.noonbreakStart ^ !dayOfWeek.noonbreakEnd) {
  272. // this.$message.error(`${dayOfWeek.dayOfWeekText}的午休开始及结束时间必须同时配置`);
  273. // return;
  274. // }
  275. let arr = [dayOfWeek.openTime,dayOfWeek.closeTime];
  276. if (!timeCheck(arr)) {
  277. this.$message.error(`${dayOfWeek.dayOfWeekText}的营业开始时间应在营业结束之前`);
  278. return false;
  279. }
  280. return true;
  281. },
  282. async submitData(result){
  283. this.centerDialogVisible=false;
  284. this.centerDialogVisiblea=false;
  285. this.formData.checkDataResult =result;
  286. // this.$api.workTimeMonth.timeSetAdd(this.formData).then((v) => {
  287. // this.$emit("success");
  288. // this.onHide();
  289. // });
  290. },
  291. async getData() {
  292. queryInfoById({id:this.id}).then(res=>{
  293. this.formData = res.data;
  294. if (this.id != 0) {
  295. this.tagsList = [
  296. {
  297. id:res.data.orgId,
  298. name:res.data.orgName
  299. }
  300. ];
  301. this.data.disabled = true;
  302. this.data.orgIdList = [this.formData.orgId];
  303. console.log(this.formData.orgIdList);
  304. if (this.orgId) {
  305. this.data.orgIdList = [this.formData.orgId];
  306. console.log(this.data.orgIdList);
  307. }
  308. } else {
  309. this.data.orgIdList = [];
  310. this.data.disabled= false;
  311. }
  312. })
  313. // this.data.orgIdList =[];
  314. },
  315. onEnableChange(workTime) {
  316. if (!workTime.isWorkday) {
  317. workTime.openTime = null;
  318. workTime.closeTime = null;
  319. // workTime.noonbreakStart = null;
  320. // workTime.noonbreakEnd = null;
  321. // workTime.workTime = null;
  322. // workTime.workOffTime = null;
  323. }
  324. },
  325. handleClose() {
  326. this.id=null;
  327. this.formData = {
  328. orgIdList: [],
  329. dayOfWeeks: json,
  330. effectiveDate: null,
  331. checkDataResult:null,
  332. };
  333. this.tagsList = [];
  334. this.data.orgIdList = [];
  335. this.data.disabled= false;
  336. this.checkData=null;
  337. this.checkMsg=null;
  338. this.centerDialogVisiblea=false;
  339. this.centerDialogVisible=false;
  340. this.isShow = false;
  341. },
  342. },
  343. };
  344. </script>
  345. <style lang="scss" scoped>
  346. .work-time-modify {
  347. .red {
  348. color: red;
  349. }
  350. .grid {
  351. width: 100%;
  352. .title {
  353. }
  354. .box {
  355. padding: 20px;
  356. border: 1px solid #000000;
  357. background: #ffffff;
  358. .time {
  359. }
  360. }
  361. }
  362. //
  363. .el-input {
  364. width: 400px;
  365. }
  366. .el-table {
  367. .el-date-editor.el-input {
  368. width: 100%;
  369. }
  370. }
  371. .el-dialog__body {
  372. overflow-y: auto;
  373. min-height: 200px;
  374. }
  375. }
  376. </style>