AttendanceRuleModal.vue 34 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058
  1. <template>
  2. <j-modal title="排班" :width="1000" :visible="visible" @ok="save()" switchFullscreen @cancel="handleCancel">
  3. <a-spin :spinning="confirmLoading">
  4. <!-- <a-form :form="form">
  5. <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="*上班类型">
  6. <a-radio-group v-model="types">
  7. <a-radio value="1">固定时间上下班</a-radio>
  8. <a-radio value="2">按班次上下班</a-radio>
  9. <a-radio value="3">自由上下班</a-radio>
  10. </a-radio-group>
  11. </a-form-item>
  12. <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="*上班时间" v-if="types==1">
  13. <a-time-picker showTime format='HH:mm' v-model="startDate">
  14. <div slot="addon" style="width:100%;overflow:hidden">
  15. <div style="width:50%;float:left;border-right:solid 1px ;text-align:center">
  16. <div style="padding-top:10%;padding-bottom:10%">
  17. <span style="width:100%;">时</span>
  18. </div>
  19. </div>
  20. <div style="width:50%;float:right;text-align:center">
  21. <div style="padding-top:10%;padding-bottom:10%">
  22. <span style="width:100%;">分</span>
  23. </div>
  24. </div>
  25. </div>
  26. </a-time-picker>
  27. </a-form-item>
  28. <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="*下班时间" v-if="types==1">
  29. <a-time-picker showTime format='HH:mm' v-model="endDate">
  30. <div slot="addon" style="width:100%;overflow:hidden">
  31. <div style="width:50%;float:left;border-right:solid 1px ;text-align:center">
  32. <div style="padding-top:10%;padding-bottom:10%">
  33. <span style="width:100%;">时</span>
  34. </div>
  35. </div>
  36. <div style="width:50%;float:right;text-align:center">
  37. <div style="padding-top:10%;padding-bottom:10%">
  38. <span style="width:100%;">分</span>
  39. </div>
  40. </div>
  41. </div>
  42. </a-time-picker>
  43. </a-form-item>
  44. </a-form> -->
  45. <!-- <a-form-item v-if="types!=2" label="*打卡人员" :labelCol="labelCol" :wrapperCol="wrapperCol">
  46. <a-tag v-for='(user,i) in selectUsers' :key="user.id" closable @close="tagBtnCloseFunc(user)">{{user.realname}}
  47. </a-tag>
  48. </a-form-item> -->
  49. <div v-if="types=='2'">
  50. <div class='month'>
  51. <ul>
  52. <!--点击会触发pickpre函数,重新刷新当前日期 @click(vue v-on:click缩写) -->
  53. <li class='arrow' @click='pickPre(currentYear,currentMonth)'>上个月</li>
  54. <li class='year-month'>
  55. <span class='choose-year'>{{ currentYear }}年</span>
  56. <span class='choose-month'>{{ currentMonth }}月</span>
  57. </li>
  58. <li class='arrow' @click='pickNext(currentYear,currentMonth)'>下个月</li>
  59. </ul>
  60. <br>
  61. </div>
  62. <div>
  63. <a-table bordered :data-source="dataSource" :loading="loading" :columns="columns" :scroll="{ x:300,y:500 }" :pagination="ipagination"
  64. @change="handleTableChange">
  65. <template v-for='(dayobject,i) in days' :slot="dayobject.day.getDate()" style="color: #ff6b81">
  66. <div style="height: 35px;">
  67. <div style="text-align: center;margin-top: -10px;">
  68. <p>{{dayobject.day.getDate()}}</p>
  69. <div style="margin-top: -10px;">
  70. <p v-if='dayobject.day.getDay()==0'>日</p>
  71. <p v-else-if='dayobject.day.getDay()==1'>一</p>
  72. <p v-else-if='dayobject.day.getDay()==2'>二</p>
  73. <p v-else-if='dayobject.day.getDay()==3'>三</p>
  74. <p v-else-if='dayobject.day.getDay()==4'>四</p>
  75. <p v-else-if='dayobject.day.getDay()==5'>五</p>
  76. <p v-else-if='dayobject.day.getDay()==6'>六</p>
  77. </div>
  78. </div>
  79. </div>
  80. </template>
  81. <span v-for='(d,i) in tpdata' style="margin-left: -11px;" :slot="d" slot-scope="text, record, index">
  82. <a-dropdown :trigger="['click']">
  83. <a-tag color="blue" v-if="text=='休息'" @click="UserType(d,record,index)">{{text}}</a-tag>
  84. <a-tag color="#87d068" v-else-if="text!='休息'&&text!=''&&text!=null" @click="UserType(d,record,index)">
  85. {{text}}
  86. </a-tag>
  87. <a-tag color="#FFFFFF" v-else @click="UserType(d,record,index)" style="width: 40px;">.</a-tag>
  88. <a-menu slot="overlay" v-if="record.isColse">
  89. <a-menu-item key="0">
  90. <a @click="shiftOks(0,d,record,index)">休息</a>
  91. </a-menu-item>
  92. <a-menu-item v-if="isShow" v-for="(item,index) in shiftlist" :key="item.id">
  93. <a @click="shiftOks(item,d,record,index)">{{item.name}} ({{item.startDate}} - {{item.endDate}})</a>
  94. </a-menu-item>
  95. </a-menu>
  96. </a-dropdown>
  97. </span>
  98. </a-table>
  99. </div>
  100. </a-calendar>
  101. <a-modal v-model="visibles" title="班次" @ok="shiftOk()">
  102. <div class="table-page-search-wrapper">
  103. <a-form layout="inline">
  104. <a-row :gutter="24">
  105. <a-col :xl="10" :lg="10" :md="8" :sm="24">
  106. <a-form-item label="班次名称">
  107. <a-select v-model="shiftname" placeholder="请选择班次">
  108. <a-select-option value="">请选择</a-select-option>
  109. <a-select-option value="a">休息</a-select-option>
  110. <a-select-option v-for="(item,index) in shiftlist" :value="item.id">{{item.name}}
  111. </a-select-option>
  112. </a-select>
  113. </a-form-item>
  114. </a-col>
  115. </a-row>
  116. </a-form>
  117. </div>
  118. </a-modal>
  119. </div>
  120. </a-spin>
  121. </j-modal>
  122. </template>
  123. <script>
  124. import {
  125. httpAction,
  126. getFileAccessHttpUrl,
  127. getAction,
  128. deleteAction
  129. } from '@/api/manage'
  130. import pick from 'lodash.pick'
  131. import moment from "moment"
  132. import {
  133. JeecgListMixin
  134. } from '@/mixins/JeecgListMixin'
  135. import '@/assets/less/TableExpand.less'
  136. import ar from '../AttendanceRuleList.vue'
  137. export default {
  138. name: "UserShiftModal",
  139. mixins: [JeecgListMixin],
  140. data() {
  141. return {
  142. tts: false,
  143. tpdata: [],
  144. dataSource: [],
  145. columns: [],
  146. queryParam: {
  147. shiftDate: moment(new Date()).format('YYYY-MM-DD HH:mm:ss'),
  148. type: "1"
  149. },
  150. types: "1",
  151. currentMonth: new Date().getMonth(),
  152. currentYear: new Date().getYear(),
  153. days: [],
  154. selectUsers: [],
  155. checkUserIds: "",
  156. visibles: false,
  157. shiftDate: null,
  158. startDate: "",
  159. endDate: "",
  160. show: 1,
  161. id: null,
  162. obj: {
  163. "cid": "C0",
  164. "ctext": "区县"
  165. },
  166. shiftname: "",
  167. username: "",
  168. deptlist: null,
  169. shiftlist: null,
  170. title: "操作",
  171. visible: false,
  172. key: null,
  173. index: null,
  174. vs: false,
  175. model: {},
  176. labelCol: {
  177. xs: {
  178. span: 24
  179. },
  180. sm: {
  181. span: 5
  182. },
  183. },
  184. wrapperCol: {
  185. xs: {
  186. span: 24
  187. },
  188. sm: {
  189. span: 16
  190. },
  191. },
  192. isShow: true,
  193. listData: [],
  194. confirmLoading: false,
  195. form: this.$form.createForm(this),
  196. validatorRules: {},
  197. url: {
  198. add: "/attendanceRule/attendanceRule/add",
  199. userShift: "/userShift/userShift/queryMothByUser",
  200. shift: "/shift/shift/lists",
  201. list: "/sys/user/queryMothByUsers",
  202. moth: "/userShift/userShift/queryMothByUser",
  203. deptlist: "/sys/sysDepart/listAll",
  204. delUserShift: '/userShift/userShift/delete',
  205. edit: '/attendanceRule/attendanceRule/edit',
  206. userShiftDay:'/userShift/userShift/UserShiftType'
  207. },
  208. }
  209. },
  210. created() {
  211. this.initData(null)
  212. this.queryShift()
  213. },
  214. methods: {
  215. tagBtnCloseFunc(e) {
  216. const tags = this.selectUsers.filter(tag => tag !== e);
  217. this.selectUsers = tags;
  218. },
  219. UserType(e, a, index) {
  220. this.isShow = true;
  221. var d = new Date(this.formatDate(this.currentYear, this.currentMonth, e))
  222. var obj = this.dataSource[index];
  223. var list = [];
  224. var sum=0;
  225. var f=false;
  226. if (d.getDay() == 1) {
  227. list.push(this.getDays(0, d));
  228. list.push(this.getDays(1, d));
  229. list.push(this.getDays(2, d));
  230. list.push(this.getDays(3, d));
  231. list.push(this.getDays(4, d));
  232. list.push(this.getDays(5, d));
  233. list.push(this.getDays(6, d));
  234. } else if (d.getDay() == 2) {
  235. list.push(this.getDays(-1, d));
  236. list.push(this.getDays(0, d));
  237. list.push(this.getDays(1, d));
  238. list.push(this.getDays(2, d));
  239. list.push(this.getDays(3, d));
  240. list.push(this.getDays(4, d));
  241. list.push(this.getDays(5, d));
  242. } else if (d.getDay() == 3) {
  243. list.push(this.getDays(-2, d));
  244. list.push(this.getDays(-1, d));
  245. list.push(this.getDays(0, d));
  246. list.push(this.getDays(1, d));
  247. list.push(this.getDays(2, d));
  248. list.push(this.getDays(3, d));
  249. list.push(this.getDays(4, d));
  250. } else if (d.getDay() == 4) {
  251. list.push(this.getDays(-3, d));
  252. list.push(this.getDays(-2, d));
  253. list.push(this.getDays(-1, d));
  254. list.push(this.getDays(0, d));
  255. list.push(this.getDays(1, d));
  256. list.push(this.getDays(2, d));
  257. list.push(this.getDays(3, d));
  258. } else if (d.getDay() == 5) {
  259. list.push(this.getDays(-4, d));
  260. list.push(this.getDays(-3, d));
  261. list.push(this.getDays(-2, d));
  262. list.push(this.getDays(-1, d));
  263. list.push(this.getDays(0, d));
  264. list.push(this.getDays(1, d));
  265. list.push(this.getDays(2, d));
  266. } else if (d.getDay() == 6) {
  267. list.push(this.getDays(-5, d));
  268. list.push(this.getDays(-4, d));
  269. list.push(this.getDays(-3, d));
  270. list.push(this.getDays(-2, d));
  271. list.push(this.getDays(-1, d));
  272. list.push(this.getDays(0, d));
  273. list.push(this.getDays(1, d));
  274. } else if (d.getDay() == 0) {
  275. list.push(this.getDays(-6, d));
  276. list.push(this.getDays(-5, d));
  277. list.push(this.getDays(-4, d));
  278. list.push(this.getDays(-3, d));
  279. list.push(this.getDays(-2, d));
  280. list.push(this.getDays(-1, d));
  281. list.push(this.getDays(0, d));
  282. }
  283. for (var i = 0; i < list.length; i++) {
  284. if (list[i].split("-")[0] != this.currentYear || list[i].split("-")[1] != this.currentMonth) {
  285. getAction(this.url.userShiftDay, {
  286. userid: a.id,
  287. shiftDate:moment(new Date(list[i])).format('YYYY-MM-DD HH:mm:ss') ,
  288. }
  289. ).then((res) => {
  290. if (res.success) {
  291. if(res.result!=0||res.result!='0'){
  292. sum++;
  293. }
  294. }
  295. }).finally(() => {
  296. })
  297. list.splice(i, 1)
  298. }
  299. }
  300. for (var o = 0; o< list.length; o++) {
  301. for (var t in obj) { //用javascript的for/in循环遍历对象的属性
  302. if (t == "shiftid" + list[o].split("-")[2]&&list[o].split("-")[2]==e) {
  303. if(obj[t]!=0){
  304. sum++;
  305. f=true;
  306. }
  307. }else if(t == "shiftid" + list[o].split("-")[2]){
  308. if(obj[t]!=0){
  309. sum++;
  310. }
  311. }
  312. }
  313. }
  314. if (a.category == 106) {
  315. if (sum==6&&f==false) {
  316. this.isShow = false;
  317. }
  318. } else{
  319. if (sum==5&&f==false) {
  320. this.isShow = false;
  321. }
  322. }
  323. },
  324. // 获取当前时间,day为number,getDay(-1):昨天的日期;getDay(0):今天的日期;getDay(1):明天的日期;【以此类推】
  325. getDays(day, date) {
  326. var today = new Date(date);
  327. var targetday_milliseconds = today.getTime() + 1000 * 60 * 60 * 24 * day;
  328. today.setTime(targetday_milliseconds); //注意,这行是关键代码
  329. var tYear = today.getFullYear();
  330. var tMonth = today.getMonth() + 1;
  331. var tDate = today.getDate();
  332. return tYear + "-" + tMonth + "-" + tDate;
  333. },
  334. doHandleMonth(month) {
  335. var m = month;
  336. if (month.toString().length == 1) {
  337. m = "0" + month;
  338. }
  339. return m;
  340. },
  341. shiftOks(a, b, c, d) {
  342. var date = this.currentYear + "-" + this.currentMonth + "-" + b + " 00:00:000";
  343. var name = a.name;
  344. var shift = a.id;
  345. if (a == 0 || a == "0") {
  346. name = "休息";
  347. shift = "0";
  348. }
  349. if (b == 1) {
  350. c.a1 = name;
  351. c.shiftid1 = shift;
  352. } else if (b == 2) {
  353. c.a2 = name;
  354. c.shiftid2 = shift;
  355. } else if (b == 3) {
  356. c.a3 = name;
  357. c.shiftid3 = shift;
  358. } else if (b == 4) {
  359. c.a4 = name;
  360. c.shiftid4 = shift;
  361. } else if (b == 5) {
  362. c.a5 = name;
  363. c.shiftid5 = shift;
  364. } else if (b == 6) {
  365. c.a6 = name;
  366. c.shiftid6 = shift;
  367. } else if (b == 7) {
  368. c.a7 = name;
  369. c.shiftid7 = shift;
  370. } else if (b == 8) {
  371. c.a8 = name;
  372. c.shiftid8 = shift;
  373. } else if (b == 9) {
  374. c.a9 = name;
  375. c.shiftid9 = shift;
  376. } else if (b == 10) {
  377. c.a10 = name;
  378. c.shiftid10 = shift;
  379. } else if (b == 11) {
  380. c.a11 = name;
  381. c.shiftid11 = shift;
  382. } else if (b == 12) {
  383. c.a12 = name;
  384. c.shiftid12 = shift;
  385. } else if (b == 13) {
  386. c.a13 = name;
  387. c.shiftid13 = shift;
  388. } else if (b == 14) {
  389. c.a14 = name;
  390. c.shiftid14 = shift;
  391. } else if (b == 15) {
  392. c.a15 = name;
  393. c.shiftid15 = shift;
  394. } else if (b == 16) {
  395. c.a16 = name;
  396. c.shiftid16 = shift;
  397. } else if (b == 17) {
  398. c.a17 = name;
  399. c.shiftid17 = shift;
  400. } else if (b == 18) {
  401. c.a18 = name;
  402. c.shiftid18 = shift;
  403. } else if (b == 19) {
  404. c.a19 = name;
  405. c.shiftid19 = shift;
  406. } else if (b == 20) {
  407. c.a20 = name;
  408. c.shiftid20 = shift;
  409. } else if (b == 21) {
  410. c.a21 = name;
  411. c.shiftid21 = shift;
  412. } else if (b == 22) {
  413. c.a22 = name;
  414. c.shiftid22 = shift;
  415. } else if (b == 23) {
  416. c.a23 = name;
  417. c.shiftid23 = shift;
  418. } else if (b == 24) {
  419. c.a24 = name;
  420. c.shiftid24 = shift;
  421. } else if (b == 25) {
  422. c.a25 = name;
  423. c.shiftid25 = shift;
  424. } else if (b == 26) {
  425. c.a26 = name;
  426. c.shiftid26 = shift;
  427. } else if (b == 27) {
  428. c.a27 = name;
  429. c.shiftid27 = shift;
  430. } else if (b == 28) {
  431. c.a28 = name;
  432. c.shiftid28 = shift;
  433. } else if (b == 29) {
  434. c.a29 = name;
  435. c.shiftid29 = shift;
  436. } else if (b == 30) {
  437. c.a30 = name;
  438. c.shiftid30 = shift;
  439. } else if (b == 31) {
  440. c.a31 = name;
  441. c.shiftid31 = shift;
  442. }
  443. },
  444. pickPre: function(year, month) {
  445. var d = new Date(this.formatDate(year, month, 1))
  446. d.setDate(0)
  447. this.initData(this.formatDate(d.getFullYear(), d.getMonth() + 1, 1))
  448. this.queryParam.shiftDate = this.formatDate(d.getFullYear(), d.getMonth() + 1, 1) + " 00:00:000";
  449. this.$options.methods.searchQuery.call(this)
  450. },
  451. pickNext: function(year, month) {
  452. var d = new Date(this.formatDate(year, month + 1, 1))
  453. this.initData(this.formatDate(d.getFullYear(), d.getMonth() + 1, 1))
  454. this.queryParam.shiftDate = this.formatDate(d.getFullYear(), d.getMonth() + 1, 1) + " 00:00:000";
  455. this.$options.methods.searchQuery.call(this)
  456. },
  457. initData: function(cur) {
  458. this.columns = [];
  459. var date
  460. if (cur) {
  461. date = new Date(cur)
  462. } else {
  463. var now = new Date()
  464. date = now;
  465. }
  466. this.currentDay = date.getDate()
  467. this.currentYear = date.getFullYear()
  468. this.currentMonth = date.getMonth() + 1
  469. this.currentWeek = date.getDay() // 1...6,0
  470. var str = this.formatDate(
  471. this.currentYear,
  472. this.currentMonth,
  473. this.currentDay
  474. )
  475. this.days.length = 0
  476. var moth = new Date(str);
  477. moth.setDate(28)
  478. moth.setMonth(moth.getMonth() + 1);
  479. moth.setDate(0);
  480. this.columns.push({
  481. title: '名称',
  482. dataIndex: 'realname',
  483. width: '100px'
  484. })
  485. for (var i = 1; i <= moth.getDate(); i++) {
  486. var d = new Date(this.formatDate(this.currentYear, this.currentMonth, i))
  487. this.tpdata.push(i)
  488. var dayobjectSelf = {
  489. width: '49px',
  490. slots: {
  491. title: d.getDate()
  492. },
  493. dataIndex: "a" + d.getDate(),
  494. scopedSlots: {
  495. customRender: i
  496. },
  497. } // 用一个对象包装Date对象 以便为以后预定功能添加属性
  498. var dat = {};
  499. dat.day = d;
  500. this.days.push(dat)
  501. this.columns.push(dayobjectSelf) // 将日期放入data 中的days数组 供页面渲染使用
  502. }
  503. },
  504. // 返回 类似 2016-01-02 格式的字符串
  505. formatDate: function(year, month, day) {
  506. var y = year
  507. if (month > 12) {
  508. y = y + 1;
  509. month = 1;
  510. };
  511. var m = month
  512. if (m < 10) m = '0' + m
  513. var d = day
  514. if (d < 10) d = '0' + d
  515. return y + '-' + m + '-' + d
  516. },
  517. delUserShift(e) {
  518. this.vs = true;
  519. deleteAction(this.url.delUserShift, {
  520. id: e
  521. }).then((res) => {
  522. if (res.success) {
  523. this.$message.success(res.message);
  524. } else {
  525. this.$message.warning(res.message);
  526. }
  527. }).finally(() => {
  528. this.vs = false;
  529. this.getListData(moment(this.queryParam.entryDate).format('YYYY-MM-DD HH:mm:ss'));
  530. })
  531. },
  532. queryUserShifts() {
  533. this.queryParam.shiftDate = moment(new Date()).format('YYYY-MM-DD HH:mm:ss');
  534. this.$options.methods.searchQuery.call(this);
  535. },
  536. close() {
  537. this.selectedRowKeys = [];
  538. this.queryParam = {};
  539. this.shiftname = "";
  540. this.id = null;
  541. this.$emit('close');
  542. this.dataSource = [];
  543. this.visible = false;
  544. this.selectUsers = [];
  545. this.startDate = "";
  546. this.endDate = "";
  547. this.initData(null);
  548. },
  549. queryShift() {
  550. httpAction(this.url.shift, "", "get").then((res) => {
  551. if (res.success) {
  552. this.shiftlist = res.result;
  553. }
  554. }).finally(() => {
  555. })
  556. },
  557. handleCancel() {
  558. this.close()
  559. },
  560. save() {
  561. var userid = "";
  562. var startDate = "";
  563. var endDate = "";
  564. var workDay = "";
  565. var obj = "";
  566. var year = this.currentYear + "-" + this.currentMonth;
  567. if (this.types != '2' && this.types != 2) {
  568. if (this.selectUsers == [] || this.selectUsers.length < 1) {
  569. this.$message.warning('人员不能为空');
  570. return;
  571. } else if (this.types == '1' || this.types == 1) {
  572. if (this.startDate == null || this.startDate == "") {
  573. this.$message.warning('请选择上班时间');
  574. return;
  575. } else if (this.endDate == null || this.endDate == "") {
  576. this.$message.warning('请选择下班时间');
  577. return;
  578. }
  579. startDate = moment(this.startDate).format('YYYY-MM-DD HH:mm') + ":00";
  580. endDate = moment(this.endDate).format('YYYY-MM-DD HH:mm') + ":00";
  581. }
  582. var ids = [];
  583. for (var i = 0; i < this.selectUsers.length; i++) {
  584. ids.push(this.selectUsers[i].id);
  585. }
  586. userid = ids.join(',');
  587. workDay = "1,2,3,4,5";
  588. } else if (this.types == '2' || this.types == 2) {
  589. var data = [];
  590. var uids = [];
  591. userid = this.checkUserIds;
  592. for (var i = 0; i < this.dataSource.length; i++) {
  593. uids.push(this.dataSource[i].id);
  594. if (this.dataSource[i].shiftid1 != "" && this.dataSource[i].shiftid1 != null) {
  595. var str = {
  596. userid: this.dataSource[i].id,
  597. shiftid: this.dataSource[i].shiftid1,
  598. date: year + "-1 00:00:00"
  599. };
  600. data.push(str)
  601. }
  602. if (this.dataSource[i].shiftid2 != "" && this.dataSource[i].shiftid2 != null) {
  603. var str = {
  604. userid: this.dataSource[i].id,
  605. shiftid: this.dataSource[i].shiftid2,
  606. date: year + "-2 00:00:00"
  607. };
  608. data.push(str)
  609. }
  610. if (this.dataSource[i].shiftid3 != "" && this.dataSource[i].shiftid3 != null) {
  611. var str = {
  612. userid: this.dataSource[i].id,
  613. shiftid: this.dataSource[i].shiftid3,
  614. date: year + "-3 00:00:00",
  615. };
  616. data.push(str)
  617. }
  618. if (this.dataSource[i].shiftid4 != "" && this.dataSource[i].shiftid4 != null) {
  619. var str = {
  620. userid: this.dataSource[i].id,
  621. shiftid: this.dataSource[i].shiftid4,
  622. date: year + "-4 00:00:00"
  623. };
  624. data.push(str)
  625. }
  626. if (this.dataSource[i].shiftid5 != "" && this.dataSource[i].shiftid5 != null) {
  627. var str = {
  628. userid: this.dataSource[i].id,
  629. shiftid: this.dataSource[i].shiftid5,
  630. date: year + "-5 00:00:00",
  631. };
  632. data.push(str)
  633. }
  634. if (this.dataSource[i].shiftid6 != "" && this.dataSource[i].shiftid6 != null) {
  635. var str = {
  636. userid: this.dataSource[i].id,
  637. shiftid: this.dataSource[i].shiftid6,
  638. date: year + "-6 00:00:00",
  639. };
  640. data.push(str)
  641. }
  642. if (this.dataSource[i].shiftid7 != "" && this.dataSource[i].shiftid7 != null) {
  643. var str = {
  644. userid: this.dataSource[i].id,
  645. shiftid: this.dataSource[i].shiftid7,
  646. date: year + "-7 00:00:00"
  647. };
  648. data.push(str)
  649. }
  650. if (this.dataSource[i].shiftid8 != "" && this.dataSource[i].shiftid8 != null) {
  651. var str = {
  652. userid: this.dataSource[i].id,
  653. shiftid: this.dataSource[i].shiftid8,
  654. date: year + "-8 00:00:00"
  655. };
  656. data.push(str)
  657. }
  658. if (this.dataSource[i].shiftid9 != "" && this.dataSource[i].shiftid9 != null) {
  659. var str = {
  660. userid: this.dataSource[i].id,
  661. shiftid: this.dataSource[i].shiftid9,
  662. date: year + "-9 00:00:00"
  663. };
  664. data.push(str)
  665. }
  666. if (this.dataSource[i].shiftid10 != "" && this.dataSource[i].shiftid10 != null) {
  667. var str = {
  668. userid: this.dataSource[i].id,
  669. shiftid: this.dataSource[i].shiftid10,
  670. date: year + "-10 00:00:00"
  671. };
  672. data.push(str)
  673. }
  674. if (this.dataSource[i].shiftid11 != "" && this.dataSource[i].shiftid11 != null) {
  675. var str = {
  676. userid: this.dataSource[i].id,
  677. shiftid: this.dataSource[i].shiftid11,
  678. date: year + "-11 00:00:00"
  679. };
  680. data.push(str)
  681. }
  682. if (this.dataSource[i].shiftid12 != "" && this.dataSource[i].shiftid12 != null) {
  683. var str = {
  684. userid: this.dataSource[i].id,
  685. shiftid: this.dataSource[i].shiftid12,
  686. date: year + "-12 00:00:00"
  687. };
  688. data.push(str)
  689. }
  690. if (this.dataSource[i].shiftid13 != "" && this.dataSource[i].shiftid13 != null) {
  691. var str = {
  692. userid: this.dataSource[i].id,
  693. shiftid: this.dataSource[i].shiftid13,
  694. date: year + "-13 00:00:00"
  695. };
  696. data.push(str)
  697. }
  698. if (this.dataSource[i].shiftid14 != "" && this.dataSource[i].shiftid14 != null) {
  699. var str = {
  700. userid: this.dataSource[i].id,
  701. shiftid: this.dataSource[i].shiftid14,
  702. date: year + "-14 00:00:00"
  703. };
  704. data.push(str)
  705. }
  706. if (this.dataSource[i].shiftid15 != "" && this.dataSource[i].shiftid15 != null) {
  707. var str = {
  708. userid: this.dataSource[i].id,
  709. shiftid: this.dataSource[i].shiftid15,
  710. date: year + "-15 00:00:00"
  711. };
  712. data.push(str)
  713. }
  714. if (this.dataSource[i].shiftid16 != "" && this.dataSource[i].shiftid16 != null) {
  715. var str = {
  716. userid: this.dataSource[i].id,
  717. shiftid: this.dataSource[i].shiftid16,
  718. date: year + "-16 00:00:00"
  719. };
  720. data.push(str)
  721. }
  722. if (this.dataSource[i].shiftid17 != "" && this.dataSource[i].shiftid17 != null) {
  723. var str = {
  724. userid: this.dataSource[i].id,
  725. shiftid: this.dataSource[i].shiftid17,
  726. date: year + "-17 00:00:00"
  727. };
  728. data.push(str)
  729. }
  730. if (this.dataSource[i].shiftid18 != "" && this.dataSource[i].shiftid18 != null) {
  731. var str = {
  732. userid: this.dataSource[i].id,
  733. shiftid: this.dataSource[i].shiftid18,
  734. date: year + "-18 00:00:00"
  735. };
  736. data.push(str)
  737. }
  738. if (this.dataSource[i].shiftid19 != "" && this.dataSource[i].shiftid19 != null) {
  739. var str = {
  740. userid: this.dataSource[i].id,
  741. shiftid: this.dataSource[i].shiftid19,
  742. date: year + "-19 00:00:00"
  743. };
  744. data.push(str)
  745. }
  746. if (this.dataSource[i].shiftid20 != "" && this.dataSource[i].shiftid20 != null) {
  747. var str = {
  748. userid: this.dataSource[i].id,
  749. shiftid: this.dataSource[i].shiftid20,
  750. date: year + "-20 00:00:00"
  751. };
  752. data.push(str)
  753. }
  754. if (this.dataSource[i].shiftid21 != "" && this.dataSource[i].shiftid21 != null) {
  755. var str = {
  756. userid: this.dataSource[i].id,
  757. shiftid: this.dataSource[i].shiftid21,
  758. date: year + "-21 00:00:00"
  759. };
  760. data.push(str)
  761. }
  762. if (this.dataSource[i].shiftid22 != "" && this.dataSource[i].shiftid22 != null) {
  763. var str = {
  764. userid: this.dataSource[i].id,
  765. shiftid: this.dataSource[i].shiftid22,
  766. date: year + "-22 00:00:00"
  767. };
  768. data.push(str)
  769. }
  770. if (this.dataSource[i].shiftid23 != "" && this.dataSource[i].shiftid23 != null) {
  771. var str = {
  772. userid: this.dataSource[i].id,
  773. shiftid: this.dataSource[i].shiftid23,
  774. date: year + "-23 00:00:00"
  775. };
  776. data.push(str)
  777. }
  778. if (this.dataSource[i].shiftid24 != "" && this.dataSource[i].shiftid24 != null) {
  779. var str = {
  780. userid: this.dataSource[i].id,
  781. shiftid: this.dataSource[i].shiftid24,
  782. date: year + "-24 00:00:00"
  783. };
  784. data.push(str)
  785. }
  786. if (this.dataSource[i].shiftid25 != "" && this.dataSource[i].shiftid25 != null) {
  787. var str = {
  788. userid: this.dataSource[i].id,
  789. shiftid: this.dataSource[i].shiftid25,
  790. date: year + "-25 00:00:00"
  791. };
  792. data.push(str)
  793. }
  794. if (this.dataSource[i].shiftid26 != "" && this.dataSource[i].shiftid26 != null) {
  795. var str = {
  796. userid: this.dataSource[i].id,
  797. shiftid: this.dataSource[i].shiftid26,
  798. date: year + "-26 00:00:00"
  799. };
  800. data.push(str)
  801. }
  802. if (this.dataSource[i].shiftid27 != "" && this.dataSource[i].shiftid27 != null) {
  803. var str = {
  804. userid: this.dataSource[i].id,
  805. shiftid: this.dataSource[i].shiftid27,
  806. date: year + "-27 00:00:00"
  807. };
  808. data.push(str)
  809. }
  810. if (this.dataSource[i].shiftid28 != "" && this.dataSource[i].shiftid28 != null) {
  811. var str = {
  812. userid: this.dataSource[i].id,
  813. shiftid: this.dataSource[i].shiftid28,
  814. date: year + "-28 00:00:00"
  815. };
  816. data.push(str)
  817. }
  818. if (this.dataSource[i].shiftid29 != "" && this.dataSource[i].shiftid29 != null) {
  819. var str = {
  820. userid: this.dataSource[i].id,
  821. shiftid: this.dataSource[i].shiftid29,
  822. date: year + "-29 00:00:00"
  823. };
  824. data.push(str)
  825. }
  826. if (this.dataSource[i].shiftid30 != "" && this.dataSource[i].shiftid30 != null) {
  827. var str = {
  828. userid: this.dataSource[i].id,
  829. shiftid: this.dataSource[i].shiftid30,
  830. date: year + "-30 00:00:00"
  831. };
  832. data.push(str)
  833. }
  834. if (this.dataSource[i].shiftid31 != "" && this.dataSource[i].shiftid31 != null) {
  835. var str = {
  836. userid: this.dataSource[i].id,
  837. shiftid: this.dataSource[i].shiftid31,
  838. date: year + "-31 00:00:00"
  839. };
  840. data.push(str)
  841. }
  842. }
  843. obj = JSON.stringify(data);
  844. userid = uids.join(",");
  845. }
  846. var url = this.url.add;
  847. var typet = "post"
  848. if (this.id != null && this.id != "") {
  849. url = this.url.edit;
  850. typet = "put";
  851. }
  852. this.confirmLoading = true;
  853. httpAction(url, {
  854. id: this.id,
  855. type: this.types,
  856. startDate: startDate,
  857. endDate: endDate,
  858. userId: userid,
  859. workDay: workDay,
  860. ruleType: obj
  861. },
  862. typet).then((res) => {
  863. if (res.success) {
  864. this.$message.success(res.message);
  865. this.$emit('ok');
  866. } else {
  867. this.$message.warning(res.message);
  868. }
  869. }).finally(() => {
  870. this.confirmLoading = false;
  871. this.close();
  872. })
  873. },
  874. add(e, a) {
  875. this.visible = true;
  876. this.queryParam.usertid = e.join(",");
  877. this.checkUserIds = e.join(",");
  878. this.selectUsers = a;
  879. this.queryParam.shiftDate = moment(new Date()).format('YYYY-MM-DD HH:mm:ss');
  880. this.queryParam.type = "1";
  881. this.$options.methods.searchQuery.call(this)
  882. },
  883. edit(e, a) {
  884. this.visible = true;
  885. this.queryParam.usertid = e.join(",");
  886. this.checkUserIds = e.join(",");
  887. this.selectUsers = a;
  888. this.types = a[0].type;
  889. this.id = a[0].id;
  890. this.queryParam.shiftDate = moment(new Date()).format('YYYY-MM-DD HH:mm:ss');
  891. this.queryParam.type = "2";
  892. if (a[0].startDate != null) {
  893. this.startDate = moment(new Date(a[0].startDate)).format('YYYY-MM-DD HH:mm:ss');
  894. }
  895. if (a[0].endDate != null) {
  896. this.endDate = moment(new Date(a[0].endDate)).format('YYYY-MM-DD HH:mm:ss');
  897. }
  898. this.$options.methods.searchQuery.call(this)
  899. }
  900. }
  901. }
  902. </script>
  903. <style lang="less" scoped>
  904. .month {
  905. width: 100%;
  906. color: #333333;
  907. background: #ffffff;
  908. margin-top: -20px;
  909. }
  910. .month ul {
  911. margin: 0;
  912. padding: 0;
  913. display: flex;
  914. justify-content: space-between;
  915. height: 30px;
  916. list-style-type: none;
  917. }
  918. .year-month {
  919. display: flex;
  920. align-items: center;
  921. justify-content: space-around;
  922. margin-top: 10px;
  923. }
  924. .choose-month {
  925. text-align: center;
  926. font-size: 12px;
  927. }
  928. .arrow {
  929. padding: 15px;
  930. color: #999999;
  931. }
  932. .month ul li {
  933. font-size: 12px;
  934. text-transform: uppercase;
  935. letter-spacing: 3px;
  936. }
  937. .weekdays {
  938. margin: 0;
  939. padding: 10px;
  940. display: flex;
  941. flex-wrap: wrap;
  942. color: #999;
  943. justify-content: space-around;
  944. background: #ffffff;
  945. }
  946. .weekdays li {
  947. display: inline-block;
  948. width: 13.6%;
  949. text-align: center;
  950. }
  951. .days {
  952. padding: 10px;
  953. background: #ffffff;
  954. margin: 0;
  955. display: flex;
  956. flex-wrap: wrap;
  957. }
  958. .ts {
  959. padding: 20px;
  960. background: #ffffff;
  961. margin: 0;
  962. display: flex;
  963. flex-wrap: wrap;
  964. }
  965. .days li {
  966. list-style-type: none;
  967. display: inline-block;
  968. width: 14.2%;
  969. text-align: center;
  970. padding-bottom: 4px;
  971. padding-top: 5px;
  972. font-size: 13px;
  973. color: #000;
  974. height: 40px;
  975. }
  976. .days li .active {
  977. padding: 8px 10px;
  978. border-radius: 5%;
  979. background: #00b8ec;
  980. color: #fff;
  981. }
  982. .days li .other-month {
  983. padding: 5px;
  984. color: gainsboro;
  985. }
  986. .days li:hover .act {
  987. padding: 6px 10px;
  988. border-radius: 50%;
  989. background: #e1e1e1;
  990. color: #fff;
  991. }
  992. </style>