zenglf
2023-09-28 997835429a1d66643364091e8437ebbbeb8ff97a
src/views/mdc/base/modules/OvertimeManagement/OvertimeManagementModalEdit.vue
@@ -5,37 +5,37 @@
      <a-form :form="form">
        <a-row :gutter="24">
          <a-col :span="12">
            <a-form-item label="时间" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <j-date :show-time="true" date-format="YYYY-MM-DD HH:mm:ss" placeholder="请选择时间"
                      class="query-group-cust" v-decorator="['torqueDate', validatorRules.torqueDate]"></j-date>
            <a-form-item label="设备编号" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input :disabled="disableSubmit" :readOnly="readOnly" allow-clear placeholder="请输入设备编号"
                       v-decorator="['equipmentId',validatorRules.equipmentId]"/>
            </a-form-item>
          </a-col>
          <a-col :span="12">
            <a-form-item label="加班开始时间" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-time-picker :disabled="disableSubmit" :readOnly="disableSubmit"  @change="changeStartTime"
                             v-decorator="['startTime',validatorRules.startTime]"/>
            </a-form-item>
          </a-col>
        </a-row>
        <a-row :gutter="24">
          <a-col :span="12">
            <a-form-item label="设备名称" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input :disabled="disableSubmit" :readOnly="readOnly" allow-clear placeholder="请输入设备名称"
                       v-decorator="['equipmentName',validatorRules.equipmentName]"/>
            </a-form-item>
          </a-col>
        </a-row>
        <a-row :gutter="24">
          <a-col :span="12">
            <a-form-item label="扭矩值" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input-number :min="0" :disabled="disableSubmit" placeholder="请输入扭矩值"
                       v-decorator="['torqueValue', validatorRules.torqueValue]"/>
            </a-form-item>
          </a-col>
          <a-col :span="12">
            <a-form-item label="设备编号" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input :disabled="disableSubmit" :readOnly="readOnly" allow-clear placeholder="请输入设备编号"
                       v-decorator="['equipmentId',validatorRules.equipmentId]"/>
          <a-col :span="12">
            <a-form-item label="加班结束时间" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-time-picker :disabled="disableSubmit" :readOnly="disableSubmit" @change="changeEndTime"
                             v-decorator="['endTime',validatorRules.endTime]"/>
            </a-form-item>
          </a-col>
        </a-row>
        <a-row :gutter="24">
          <a-form-item label="备注" :labelCol="labelColLong" :wrapperCol="wrapperColLong">
            <a-textarea :maxLength="20" :disabled="disableSubmit"  v-decorator="['notes', validatorRules.notes]" placeholder="请输入备注"  ></a-textarea>
            <a-textarea :maxLength="20" :disabled="disableSubmit"  v-decorator="['remark', validatorRules.remark]" placeholder="请输入备注"  ></a-textarea>
          </a-form-item>
        </a-row>
      </a-form>
@@ -79,7 +79,7 @@
            span: 24
          },
          sm: {
            span: 6
            span: 8
          }
        },
        wrapperCol: {
@@ -87,7 +87,7 @@
            span: 24
          },
          sm: {
            span: 18
            span: 16
          }
        },
        labelColLong: {
@@ -95,7 +95,7 @@
            span: 24
          },
          sm: {
            span: 3
            span: 4
          }
        },
        wrapperColLong: {
@@ -103,7 +103,7 @@
            span: 24
          },
          sm: {
            span: 21
            span: 20
          }
        },
        confirmLoading: false,
@@ -125,6 +125,22 @@
              },
            ],
          },
          startTime:{
            rules:[
              {
                required:true,
                message: "请选择加班开始时间"
              },
            ],
          },
          endTime:{
            rules:[
              {
                required:true,
                message: "请选择加班结束时间"
              },
            ],
          },
          // mdcRepairType:{
          //   rules:[
          //     {
@@ -137,20 +153,35 @@
        },
        url: {
          add: '/mdc/mdcEquipmentRepair/add',
          edit: '/mdc/MdcTorqueConfig/editMdcTorqueConfig'
          add: '/mdc/mdcEquipmentOvertime/add',
          edit: '/mdc/mdcEquipmentOvertime/edit'
        },
        disableSubmit: true,
        partCategoryCascade: [],
        cascadeDefaultValue: [],
        editStart:''
        editStart:'',
        endTimeSHI:'',
        startTimeSHI:'',
        startEdit:'',
        endEdit:''
      }
    },
    created() {
    },
    methods: {
      changeStartTime(data,dataStrings){
        console.log(data);
        console.log(dataStrings)
        this.startTimeSHI = dataStrings
      },
      changeEndTime(data,dataStrings){
        console.log(data);
        console.log(dataStrings)
        this.endTimeSHI = dataStrings
      },
      disabledDate(current){
        //Can not slect days before today and today
        // return current && current < moment().endOf("day");
@@ -223,19 +254,42 @@
        })
      },
      edit(record) {
        console.log(record)
        // record.endTime = moment(record.endTime).format("HH:mm:ss")
        this.startEdit = record.startTime;
        this.endEdit = record.endTime
        this.form.resetFields()
        this.model = Object.assign({}, record)
        // this.editStart  = (this.model.startTime).replace(/:/g,'');
        this.visible = true
        this.$nextTick(() => {
          this.form.setFieldsValue(pick(this.model,'equipmentId', 'equipmentName','torqueDate', 'torqueValue','notes'
          this.form.setFieldsValue(pick(this.model,'equipmentId', 'equipmentName','startTime', 'endTime','remark'
          ))
          this.form.setFieldsValue({
            startTime: moment(this.model.startTime, 'HH:mm:ss'),
            endTime: moment(this.model.endTime, 'HH:mm:ss')
          })
          // console.log(this.model)
        })
      },
      close() {
        this.$emit('close')
        this.visible = false
        this.show = false
      },
      fun(obj) {
        if(obj){
          if (obj = obj.split("T")) {
            var tim = obj[1];
            if(tim = tim.split(".")){
              var tim0 = tim[0];
            }
            var dd = tim0
            return dd;
          }
        }
      },
      handleOk() {
        const that = this
@@ -244,34 +298,74 @@
          if (!err) {
            that.confirmLoading = true
            let formData = Object.assign(this.model, values)
            let obj
            if (!this.model.id) {
              obj = postAction(this.url.add, formData)
            } else {
              obj = requestPut(this.url.edit, formData, {
                id: this.model.id
            if(this.startTimeSHI != ''){
              formData.startTime = this.startTimeSHI
            }else{
              formData.startTime = this.startEdit
            }
            if(this.endTimeSHI != ''){
              formData.endTime = this.endTimeSHI
            }else{
              formData.endTime = this.endEdit
            }
            console.log(formData)
            // let start = moment(formData.startTime).format('HH:mm:ss');
            // let end = moment(formData.endTime).format('HH:mm:ss');
            let startOne = formData.startTime.replace(/:/g,'');
            let endOne = formData.endTime.replace(/:/g,'');
            // var data = new Date();
            // let stertDate = moment(data).format("HH:mm:ss");
            // let dataStart = stertDate.replace(/:/g,'');
            // if(startOne < dataStart){
            //   that.$message.warning("开始时间不能小于当前时间")
            //   that.confirmLoading = false
            // }else{
            if(startOne>=endOne){
              that.$message.warning("结束时间不能小于开始时间");
              // console.log(this.model)
              // this.endTime = ''
              that.confirmLoading = false
            }
            else{
              let obj
              if (!this.model.id) {
                formData.startTime = this.fun(JSON.stringify(formData.startTime));
                formData.endTime = this.fun(JSON.stringify(formData.endTime))
                obj = postAction(this.url.add, formData)
              } else {
                console.log(1111)
                // formData.startTime = this.fun(JSON.stringify(formData.startTime));
                // formData.endTime = this.fun(JSON.stringify(formData.endTime))
                obj = requestPut(this.url.edit, formData, {
                  id: this.model.id
                })
              }
              obj.then((res) => {
                if (res.success) {
                  // that.$message.success("添加成功")
                  that.$notification.success({
                    message:'消息',
                    description:"修改成功"
                  });
                  // that.$message.success(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()
              })
            }
            obj.then((res) => {
              if (res.success) {
                // that.$message.success("修改成功")
                that.$notification.success({
                  message:'消息',
                  description:"修改成功"
                });
                // that.$message.success(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()
            })
          // }
          }
        })
      },