¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <div ref="device"> |
| | | <a-modal :title="title" :width="900" :visible="visible" :confirmLoading="confirmLoading" |
| | | :getContainer="() => this.$refs.device" |
| | | :okButtonProps="{ props: {disabled: disableSubmit} }" @ok="handleOk" @cancel="handleCancel" |
| | | cancelText="å
³é"> |
| | | <a-spin :spinning="confirmLoading"> |
| | | <a-form :form="form"> |
| | | <a-row :gutter="24"> |
| | | <a-col :span="24"> |
| | | <a-form-item label="设å¤ç»" :labelCol="labelColLong" :wrapperCol="wrapperColLong"> |
| | | <a-input-search :readOnly="true" v-decorator="['equipmentId', validatorRules.equipmentId]" |
| | | @search="deviceSearch" enter-button placeholder="è¯·éæ©è®¾å¤"/> |
| | | </a-form-item> |
| | | </a-col> |
| | | </a-row> |
| | | <a-row :gutter="24"> |
| | | <a-col :span="24"> |
| | | <a-form-item label="çå¶" :labelCol="labelColLong" :wrapperCol="wrapperColLong"> |
| | | <a-select v-decorator="['shiftId', validatorRules.shiftId]" placeholder="è¯·éæ©çå¶" |
| | | :allowClear='allowClear' @change="initShiftSubList"> |
| | | <a-select-option v-for="(em,index) in shiftList" :key="index" :value="em.value"> |
| | | {{ em.label }} |
| | | </a-select-option> |
| | | </a-select> |
| | | </a-form-item> |
| | | </a-col> |
| | | </a-row> |
| | | |
| | | <a-row :gutter="24"> |
| | | <a-col :span="24"> |
| | | <a-form-item label="çææ¶é´" :labelCol="labelColLong" :wrapperCol="wrapperColLong"> |
| | | <div class="mainBox"> |
| | | <Calendar |
| | | v-on:choseDay="clickDay" |
| | | v-on:changeMonth="changeDate" |
| | | v-on:isToday="clickToday" |
| | | :markDate='shiData' |
| | | :agoDayHide='value' |
| | | ></Calendar> |
| | | </div> |
| | | |
| | | </a-form-item> |
| | | </a-col> |
| | | </a-row> |
| | | </a-form> |
| | | </a-spin> |
| | | <device-calender-list-model ref="deviceCalenderListModel" |
| | | @sendSelectionRows="getDeviceRows"></device-calender-list-model> |
| | | <select-device-drawer ref="selectDeviceDrawer" @selectFinished="selectOK" :title="'éæ©è®¾å¤'"/> |
| | | </a-modal> |
| | | </div> |
| | | </template> |
| | | |
| | | <script> |
| | | import DeviceCalendarListModel from './DeviceCalendarListModel' |
| | | import moment from 'moment' |
| | | import pick from 'lodash.pick' |
| | | import { |
| | | getAction, |
| | | postAction, |
| | | requestPut |
| | | } from '@/api/manage' |
| | | |
| | | import Calendar from 'vue-calendar-component' |
| | | import SelectDeviceDrawer from '../../../../system/modules/SelectDeviceDrawer' |
| | | |
| | | export default { |
| | | name: 'ShiftInfoModel', |
| | | components: { SelectDeviceDrawer, DeviceCalendarListModel, Calendar }, |
| | | props: {}, |
| | | data() { |
| | | return { |
| | | value: '', |
| | | date: '', |
| | | week: '', |
| | | selectDate: [], |
| | | // å½åæ¥æ |
| | | allowClear: true, |
| | | title: '', |
| | | isDaySpan: false, |
| | | visible: false, |
| | | show: false, |
| | | model: {}, |
| | | checked: false, |
| | | labelColLong: { |
| | | xs: { |
| | | span: 24 |
| | | }, |
| | | sm: { |
| | | span: 3 |
| | | } |
| | | }, |
| | | wrapperColLong: { |
| | | xs: { |
| | | span: 24 |
| | | }, |
| | | sm: { |
| | | span: 21 |
| | | } |
| | | }, |
| | | labelCol: { |
| | | xs: { |
| | | span: 24 |
| | | }, |
| | | sm: { |
| | | span: 6 |
| | | } |
| | | }, |
| | | wrapperCol: { |
| | | xs: { |
| | | span: 24 |
| | | }, |
| | | sm: { |
| | | span: 18 |
| | | } |
| | | }, |
| | | confirmLoading: false, |
| | | form: this.$form.createForm(this), |
| | | validatorRules: { |
| | | equipmentId: { |
| | | rules: [ |
| | | { |
| | | required: true, message: 'è¯·éæ©è®¾å¤ç»!' |
| | | } |
| | | ] |
| | | }, |
| | | shiftId: { |
| | | rules: [{ |
| | | required: true, message: 'è¯·éæ©çå¶!' |
| | | }] |
| | | } |
| | | }, |
| | | url: { |
| | | add: '/mdc/mdcDeviceCalendar/add', |
| | | edit: '/mdc/mdcshiftsub/edit', |
| | | initShiftList: '/mdc/mdcMdcShift/initShiftList', |
| | | initShiftSubList: '/mdc/mdcshiftsub/initShiftSubList', |
| | | getShiftSubById: '/mdc/mdcshiftsub/getShiftSubById', |
| | | settingCalendar: '/mdc/mdcDeviceCalendar/add' |
| | | }, |
| | | shiftList: [], |
| | | shiftSubList: [], |
| | | disableSubmit: true, |
| | | calData: undefined, |
| | | shiData: [], |
| | | sendDte: [] |
| | | } |
| | | }, |
| | | created() { |
| | | this.value = Math.round(new Date().getTime() / 1000).toString() |
| | | var now = new Date() |
| | | this.date = now.getDate()//å¾å°æ¥æ |
| | | var day = now.getDay()//å¾å°å¨å |
| | | var arr_week = new Array('æææ¥', 'ææä¸', 'ææäº', 'ææä¸', 'ææå', 'ææäº', 'ææå
') |
| | | this.week = arr_week[day] |
| | | this.getWorking() |
| | | }, |
| | | |
| | | methods: { |
| | | getWorking() {//è·åå½åæå·¥ä½æ¥ |
| | | let myDate = new Date() |
| | | let tY = myDate.getFullYear()//å¾å°å½åå¹´ |
| | | let tM = myDate.getMonth()//å¾å°å½åæ+1 |
| | | let tD = new Date(tY, tM + 1, 0) |
| | | let tT = tD.getDate()//å¾å°å½åæçå¤©æ° |
| | | |
| | | for (var i = 1; i <= tT; i++) { |
| | | let week = new Date(tY, tM, i).getDay() |
| | | if (week >= 1 && week <= 5) { |
| | | let dd = tY + '/' + (tM + 1) + '/' + i |
| | | let temp = { className: 'mark1', date: dd } |
| | | this.selectDate.push(temp) |
| | | } |
| | | } |
| | | //console.log(JSON.stringify(this.selectDate)) |
| | | }, |
| | | resetSelect() {//éç½®éä¸çæ¥æ |
| | | this.selectDate = [] |
| | | this.shiData = [] |
| | | this.sendDte = [] |
| | | }, |
| | | fun(obj) { |
| | | console.log(obj) |
| | | if (obj) { |
| | | if (obj = obj.split('/')) { |
| | | var timShi = obj[1] |
| | | var timFen = obj[2] |
| | | if (timShi < 10) { |
| | | timShi = '0' + timShi |
| | | } |
| | | if (timFen < 10) { |
| | | timFen = '0' + timFen |
| | | } |
| | | var dd = (obj[0] + timShi + timFen) |
| | | return dd |
| | | } |
| | | } |
| | | }, |
| | | clickDay(today) {//é䏿¥æ |
| | | let existDate = this.selectDate |
| | | let isExist = true |
| | | for (var i = 0; i < existDate.length; i++) { |
| | | if (existDate[i].date === today) { |
| | | this.selectDate.splice(i, 1) |
| | | this.shiData.splice(i, 1) |
| | | this.sendDte.splice(i, 1) |
| | | isExist = false |
| | | } |
| | | } |
| | | if (isExist) {//å½åæ¥æåå¨ç§»é¤ |
| | | let tempDate = { date: today, className: 'mark1' } |
| | | // let ddd = this.fun(today) |
| | | let ddd = today |
| | | let ccc = this.fun(today) |
| | | this.selectDate.push(tempDate) |
| | | this.shiData.push(ddd) |
| | | this.sendDte.push(ccc) |
| | | } |
| | | }, |
| | | onSelect(value) { |
| | | console.log(value) |
| | | let arr = [] |
| | | arr.push(value) |
| | | this.value = arr |
| | | // this.value = value; |
| | | // this.selectedValue = value; |
| | | }, |
| | | onPanelChange(value) { |
| | | this.value = value |
| | | }, |
| | | deviceSearch() { |
| | | this.$refs.selectDeviceDrawer.visible = true |
| | | this.$refs.selectDeviceDrawer.selectedRowKeys = [] |
| | | this.$refs.selectDeviceDrawer.selectedRows = [] |
| | | this.$refs.selectDeviceDrawer.checkedKeys = this.form.getFieldValue('equipmentId') ? this.form.getFieldValue('equipmentId').split(',') : [] |
| | | }, |
| | | getDeviceRows(val) { |
| | | console.log('========', val) |
| | | var equipmentIds = '' |
| | | for (var i = 0; i < val.length; i++) { |
| | | //equipmentIds = equipmentIds + "," + val[i].equipmentId; |
| | | if (i == 0) { |
| | | equipmentIds = val[i].equipmentId |
| | | } else { |
| | | equipmentIds = equipmentIds + ',' + val[i].equipmentId |
| | | } |
| | | } |
| | | this.form.setFieldsValue({ |
| | | equipmentId: equipmentIds |
| | | }) |
| | | }, |
| | | disabledDate(current) { |
| | | //Can not slect days before today and today |
| | | return current && current < moment().subtract('days', 1) |
| | | }, |
| | | disabledDateEnd(currentend) { |
| | | //Can not slect days before today and today |
| | | return currentend && currentend < moment().subtract('days', 0) |
| | | }, |
| | | initShiftList() { |
| | | getAction(this.url.initShiftList).then((res) => { |
| | | if (res.success) { |
| | | this.shiftList = res.result |
| | | } |
| | | }) |
| | | }, |
| | | add(record) { |
| | | this.resetSelect() |
| | | let _this = this |
| | | this.visible = true |
| | | this.form.resetFields() |
| | | this.model = Object.assign({}, record) |
| | | this.initShiftList() |
| | | this.$nextTick(() => { |
| | | this.form.setFieldsValue(pick(this.model)) |
| | | this.form.setFieldsValue({ |
| | | // takeEffectDate: moment(), |
| | | // invalidDate: moment().endOf('month') |
| | | }) |
| | | }) |
| | | }, |
| | | close() { |
| | | this.$emit('close') |
| | | this.visible = false |
| | | this.show = false |
| | | }, |
| | | handleOk() { |
| | | const that = this |
| | | // 触å表åéªè¯ |
| | | this.form.validateFields((err, values) => { |
| | | if (!err) { |
| | | that.confirmLoading = true |
| | | let formData = Object.assign(this.model, values) |
| | | formData.dateList = this.sendDte |
| | | if (formData.dateList && formData.dateList.length > 0) { |
| | | postAction(this.url.settingCalendar, formData).then((res) => { |
| | | if (res.success) { |
| | | // that.$message.success(res.message) |
| | | that.$notification.success({ |
| | | message: 'æ¶æ¯', |
| | | description: res.message |
| | | }) |
| | | that.$emit('ok', res.result) |
| | | } else { |
| | | // that.$message.warning(res.message) |
| | | that.$notification.warning({ |
| | | message: 'æ¶æ¯', |
| | | description: res.message |
| | | }) |
| | | } |
| | | }).finally(() => { |
| | | that.confirmLoading = false |
| | | that.close() |
| | | }) |
| | | } else { |
| | | that.confirmLoading = false |
| | | that.$notification.warning({ |
| | | message: 'æ¶æ¯', |
| | | description: 'è¯·éæ©çææ¶é´!' |
| | | }) |
| | | } |
| | | } |
| | | }) |
| | | }, |
| | | handleCancel() { |
| | | this.close() |
| | | }, |
| | | |
| | | /** |
| | | * 鿩已æè®¾å¤åç¹å»ç¡®å®æ¶è§¦å |
| | | * @param data 已鿩çè®¾å¤ |
| | | */ |
| | | selectOK(data) { |
| | | this.form.setFieldsValue({ |
| | | equipmentId: data.join(',') |
| | | }) |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style scoped lang="less"> |
| | | |
| | | /deep/ .ant-modal-close { |
| | | color: #1191b0; |
| | | font-size: 24px; |
| | | } |
| | | |
| | | /deep/ .ant-modal-close-x { |
| | | font-size: 24px; |
| | | } |
| | | |
| | | .ant-btn { |
| | | padding: 0 10px; |
| | | margin-left: 3px; |
| | | } |
| | | |
| | | .ant-form-item-control { |
| | | line-height: 0px; |
| | | } |
| | | |
| | | /** 主表åè¡é´è· */ |
| | | .ant-form .ant-form-item { |
| | | margin-bottom: 10px; |
| | | } |
| | | |
| | | /** Tab页é¢è¡é´è· */ |
| | | .ant-tabs-content .ant-form-item { |
| | | margin-bottom: 0px; |
| | | } |
| | | |
| | | /deep/ .mark1 { |
| | | color: white !important; |
| | | background-color: #1890ff !important; |
| | | border-radius: 50%; |
| | | } |
| | | |
| | | /deep/ .mainBox .wh_content_all { |
| | | background-color: #ffffff; |
| | | border: 1px silver solid; |
| | | -webkit-border-radius: 5px; |
| | | -moz-border-radius: 5px; |
| | | border-radius: 5px; |
| | | } |
| | | |
| | | /deep/ .mainBox .wh_content_all .wh_jiantou1 { |
| | | border-top: 2px solid #000000; |
| | | border-left: 2px solid #000000; |
| | | } |
| | | |
| | | /deep/ .mainBox .wh_content_all .wh_jiantou2 { |
| | | border-top: 2px solid #000000; |
| | | border-right: 2px solid #000000; |
| | | } |
| | | |
| | | /deep/ .mainBox .wh_content_all .wh_top_changge li { |
| | | color: black; |
| | | } |
| | | |
| | | /deep/ .mainBox .wh_content_all .wh_content_item { |
| | | margin-top: 5px; |
| | | } |
| | | |
| | | /deep/ .mainBox .wh_content_all .wh_content_item .wh_top_tag { |
| | | color: #000000; |
| | | } |
| | | |
| | | /deep/ .mainBox .wh_content_all .wh_content_item .wh_item_date { |
| | | color: #000000; |
| | | } |
| | | |
| | | /deep/ .mainBox .wh_content_all .wh_content_item .wh_item_date:hover { |
| | | color: #1890ff; |
| | | border: 1px solid #1890ff; |
| | | border-radius: 50%; |
| | | } |
| | | |
| | | /deep/ .mainBox .wh_content_all .wh_content_item .wh_other_dayhide { |
| | | color: #bfbfbf !important; |
| | | } |
| | | |
| | | /deep/ .mainBox .wh_content_all .wh_content_item .wh_want_dayhide { |
| | | color: #bfbfbf !important; |
| | | } |
| | | |
| | | /deep/ .mainBox .wh_content_all .wh_content_item .wh_chose_day { |
| | | background: #ffffff; |
| | | color: #000000; |
| | | } |
| | | |
| | | /deep/ .mainBox .wh_content_all .wh_content_item .wh_isMark { |
| | | color: #ffffff; |
| | | background-color: blue; |
| | | } |
| | | |
| | | /deep/ .mainBox .wh_content_all .wh_content_item .wh_isToday { |
| | | background-color: #ffffff; |
| | | color: #000000; |
| | | } |
| | | |
| | | </style> |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |