cuilei
5 天以前 ba77fdc6a30c9ad0941e40319f8c4f6fe6fdf9f1
src/views/mdc/base/modules/deviceCalendar/DeviceCalendarAddCon.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,307 @@
<template>
  <div ref="device">
    <a-modal :title="title" :width="1200" :visible="visible" :confirmLoading="confirmLoading" :getContainer="() => this.$refs.device"
             :okButtonProps="{ props: {disabled: disableSubmit} }" @ok="handleOk" @cancel="handleCancel" cancelText="关闭">
        <a-row type="flex" :gutter="24">
          <a-col :md="5">
            <base-tree @getCurrSelected="changeSelectionNode"></base-tree>
          </a-col>
          <a-col :md="19">
            <device-calendar-add-tree></device-calendar-add-tree>
            <!--<a-spin :spinning="confirmLoading">-->
          <!--<a-form :form="form">-->
          <!--<a-row :gutter="24">-->
            <!--<a-col :span="12">-->
              <!--<a-form-item label="生效时间" :labelCol="labelCol" :wrapperCol="wrapperCol">-->
                <!--<a-date-picker v-decorator="['takeEffectDate',validatorRules.takeEffectDate]" :disabled="disableSubmit"-->
                               <!--:readOnly="disableSubmit" :disabledDate="disabledDate"/>-->
              <!--</a-form-item>-->
            <!--</a-col>-->
            <!--<a-col :span="12">-->
              <!--<a-form-item label="失效时间" :labelCol="labelCol" :wrapperCol="wrapperCol">-->
                <!--<a-date-picker v-decorator="['invalidDate',validatorRules.invalidDate]" :disabled="disableSubmit"-->
                               <!--:readOnly="disableSubmit" :disabledDate="disabledDate"/>-->
              <!--</a-form-item>-->
            <!--</a-col>-->
          <!--</a-row>-->
          <!--<a-row :gutter="24">-->
            <!--<a-col :span="12">-->
              <!--<a-form-item label="班制名称" :labelCol="labelCol" :wrapperCol="wrapperCol">-->
                <!--<a-select v-decorator="['shiftId', validatorRules.shiftId]" placeholder="请选择班制"-->
                          <!--@change="initShiftSubList">-->
                  <!--<a-select-option v-for="(em,index) in shiftList" :key="index" :value="em.id">-->
                    <!--{{ em.shiftName }}-->
                  <!--</a-select-option>-->
                <!--</a-select>-->
              <!--</a-form-item>-->
            <!--</a-col>-->
            <!--<a-col :span="12">-->
              <!--<a-form-item label="星期选择" :labelCol="labelCol" :wrapperCol="wrapperCol">-->
                <!--<a-select v-decorator="['weekId', validatorRules.weekId]" placeholder="请选择星期"-->
                          <!--@change="weekChange"  mode="multiple">-->
                  <!--<a-select-option v-for="(em,index) in weekList" :key="index" :value="em.id">-->
                    <!--{{ em.name }}-->
                  <!--</a-select-option>-->
                <!--</a-select>-->
              <!--</a-form-item>-->
            <!--</a-col>-->
          <!--</a-row>-->
        <!--</a-form>-->
            <!--</a-spin>-->
          </a-col>
        </a-row>
    </a-modal>
  </div>
</template>
<script>
  import BaseTree from '../../../common/BaseTree'
  import DeviceCalendarAddTree from './DeviceCalendarAddTree'
  import moment from 'moment'
  import pick from 'lodash.pick'
  import {
    getAction,
    postAction,
    requestPut
  } from '@/api/manage'
  import {
    duplicateCheck
  } from '@/api/api'
  import AFormItem from 'ant-design-vue/es/form/FormItem'
  import {
    JeecgListMixin
  } from '@/mixins/JeecgListMixin'
  export default {
    name: 'DeviceCalendarAddCon',
    mixins: [JeecgListMixin],
    components: { AFormItem,BaseTree,DeviceCalendarAddTree},
    props: {node:{}},
    data() {
      return {
        weekList:[
          {
            id:0,
            name:"星期天"
          },
          {
            id:1,
            name:"星期一"
          },
          {
            id:2,
            name:"星期二"
          },
          {
            id:3,
            name:"星期三"
          },
          {
            id:4,
            name:"星期四"
          },
          {
            id:5,
            name:"星期五"
          },
          {
            id:6,
            name:"星期六"
          }
        ],
        title: '',
        isDaySpan: false,
        visible: false,
        show: false,
        model: {},
        checked: false,
        url: {
          list: '/mdc/mdcequipment/findListEquipment',
          add: '/mdc/mdcshiftsub/add',
          edit: '/mdc/mdcshiftsub/edit',
          initShiftList: '/mdc/mdcshift/initShiftList',
          initShiftSubList: '/mdc/mdcshiftsub/initShiftSubList',
          getShiftSubById: '/mdc/mdcshiftsub/getShiftSubById',
          settingCalendar: '/mdc/mdcdevicecalendar/settingCalendar',
        },
        shiftList: [],
        shiftSubList: [],
        disableSubmit: true,
        selectEquementId:{}
      }
    },
    created() {
    },
    // watch:{
    //   node(val) { //监听currSelected å˜åŒ–,将变化后的数值传递给 getCurrSelected äº‹ä»¶
    //     if (JSON.stringify(val) != '{}') {
    //       // if (val.entity.equipmentId) {
    //       //   this.queryParams.equipmentName = val.entity.equipmentName
    //       //   this.queryParams.parentId = ''
    //       //   this.queryParams.equipmentId = val.entity.equipmentId
    //       // } else {
    //       //   this.queryParams.parentId = val.entity.id
    //       //   this.queryParams.equipmentId = ''
    //       //   this.queryParams.equipmentName = ''
    //       // }
    //       // this.searchQuery()
    //     }
    //   }
    // },
    methods: {
      changeSelection(val) {
        this.selectEquementId = val
      },
      // close() {
      //   this.$emit('close')
      //   this.visible = false
      // },
      // handleCancel() {
      //   this.close()
      // },
      // handleOk() {
      //   // this.selectionRows =  this.SelectedList;
      //   // console.log(this.selectionRows);
      //   this.$emit('sendSelectionRows', this.selectionRows)
      //   this.close()
      // },
      disabledDate(current){
        //Can not slect days before today and today
        return current && current < moment().endOf("day");
      },
      initShiftList() {
        getAction(this.url.initShiftList).then((res) => {
          if (res.success) {
            this.shiftList = res.result
          }
        })
      },
      weekChange(shiftId) {
        // getAction(this.url.initShiftSubList, { shiftId, shiftId }).then((res) => {
        //   if (res.success) {
        //     this.shiftSubList = res.result
        //   }
        // })
      },
      add(record) {
        // let _this = this
        // this.visible = true
        // this.form.resetFields()
        // this.model = Object.assign({}, record)
        // this.initShiftList()
        // this.$nextTick(() => {
        //   this.form.setFieldsValue(pick(this.model, 'equmentName'))
        //   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)
            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()
            })
          }
        })
      },
      handleCancel() {
        this.close()
      },
      // shiftSubChange(val) {
      //   let _this = this
      //   getAction(this.url.getShiftSubById, { shiftSubId: val }).then((res) => {
      //     if (res.success) {
      //       if (res.result.isDaySpan == 'true') {
      //         _this.isDaySpan = true
      //       } else {
      //         _this.isDaySpan = false
      //       }
      //       _this.form.setFieldsValue({
      //         startDate: res.result.startDate,
      //         endDate: res.result.endDate
      //       })
      //       if (res.result.sleepStartDate) {
      //         _this.form.setFieldsValue({
      //           sleepStartDate: res.result.sleepStartDate
      //         })
      //       }
      //       if (res.result.sleepStartDate) {
      //         _this.form.setFieldsValue({
      //           sleepEndDate: res.result.sleepEndDate
      //         })
      //       }
      //     }
      //   })
      // }
    }
  }
</script>
<style scoped lang="less">
  /deep/ .ant-modal-content{
    /*background: -moz-linear-gradient(left, rgba(0, 0, 0, 0.66) 0%, rgba(0, 0, 0, 0.27) 100%);*/
    /*background: -webkit-gradient(linear, left left, right right, color-stop(0%, rgba(0, 0, 0, 0.66)), color-stop(100%, rgba(0, 0, 0, 0.4)));*/
    /*background: -webkit-linear-gradient(left, rgba(0, 0, 0, 0.66) 0%, rgba(0, 0, 0, 0.4) 100%);*/
    /*background: -o-linear-gradient(left, rgba(0, 0, 0, 0.66) 0%, rgba(0, 0, 0, 0.4) 100%);*/
    /*background: -ms-linear-gradient(left, rgba(0, 0, 0, 0.66) 0%, rgba(0, 0, 0, 0.4) 100%);*/
    /*background: linear-gradient(to right, rgba(0, 0, 0, 0.66) 0%, rgba(0, 0, 0, 0.4) 100%);*/
    /*background-color: #000;*/
  }
  /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;
  }
</style>