Browse Source

修改日期不能选择

Limengbo 5 years ago
parent
commit
8c6d776d19
2 changed files with 61 additions and 18 deletions
  1. 11 4
      src/views/admin/device/index.vue
  2. 50 14
      src/views/admin/installMaintain/index.vue

+ 11 - 4
src/views/admin/device/index.vue

@@ -24,8 +24,10 @@
       <el-date-picker
         v-model="gmtCreated"
         size="mini"
-        type="date"
-        placeholder="选择设备安装日期"
+        type="daterange"
+        range-separator="至"
+        start-placeholder="设备安装开始日期"
+        end-placeholder="设备安装结束日期"
         format="yyyy 年 MM 月 dd 日"
         value-format="yyyy-MM-dd"
       />
@@ -186,13 +188,17 @@ export default {
   },
   methods: {
     search() {
+      console.log(this.gmtCreated)
+      const startTime = this.gmtCreated ? this.gmtCreated[0] : ''
+      const endTime = this.gmtCreated ? this.gmtCreated[1] : ''
       if (this.type === '2' || this.type === '1,2' || this.type === '2,1') {
         this.$store.dispatch('admin/getDeviceData', {
           deviceCode: this.deviceCode,
           deviceType: this.deviceType,
           region: this.region,
           address: this.address,
-          startTime: this.gmtCreated,
+          startTime,
+          endTime,
           modifier: this.uid
         })
       } else {
@@ -201,7 +207,8 @@ export default {
           deviceType: this.deviceType,
           region: this.region,
           address: this.address,
-          startTime: this.gmtCreated
+          startTime,
+          endTime
         })
       }
     },

+ 50 - 14
src/views/admin/installMaintain/index.vue

@@ -16,8 +16,7 @@
         size="mini"
         placeholder="请输入手机号"
       />
-      <el-select v-model="type" placeholder="请输入人员类型" size="mini">
-        <el-option label="管理员" value="0" />
+      <el-select v-model="type" clearable placeholder="请输入人员类型" size="mini">
         <el-option label="安装员" value="1" />
         <el-option label="维护员" value="2" />
       </el-select>
@@ -80,8 +79,8 @@
       </el-table-column>
     </el-table>
     <el-dialog :title="title" :visible.sync="dialogFormVisible">
-      <el-form ref="form" :model="form" label-width="120px">
-        <el-form-item v-for="item in addInput" :key="item.type" :label="item.name" label-width="120px">
+      <el-form ref="form" :model="form" :rules="formRules" label-width="120px">
+        <el-form-item v-for="item in addInput" :key="item.type" :prop="item.type" :label="item.name" label-width="120px">
           <el-input v-if="!item.select" v-model="form[item.type]" autocomplete="off" />
           <el-select v-else v-model="form[item.type]" multiple :placeholder="item.select">
             <el-option label="安装员" value="1" />
@@ -112,7 +111,7 @@
       </el-form>
       <div slot="footer" class="dialog-footer">
         <el-button @click="dialogFormVisible = false">取 消</el-button>
-        <el-button type="primary" @click="handleOk">确 定</el-button>
+        <el-button type="primary" @click="handleOk('form')">确 定</el-button>
       </div>
     </el-dialog>
     <el-dialog title="修改密码" :visible.sync="dialogFormPassVisible">
@@ -159,6 +158,7 @@ export default {
     }
     return {
       form: {},
+      formRules: {},
       addInput: [],
       dialogFormVisible: false,
       gridData: [],
@@ -232,18 +232,43 @@ export default {
         loginName: '',
         type: []
       }
+      this.formRules = {
+        name: [
+          { required: true, message: '请输入人员名称', trigger: 'blur' }
+        ],
+        mobile: [
+          { required: true, message: '请输入人员手机', trigger: 'blur' }
+        ],
+        password: [
+          { required: true, message: '请输入人员密码', trigger: 'blur' }
+        ],
+        loginName: [
+          { required: true, message: '请输入人员登录名', trigger: 'blur' }
+        ],
+        type: [
+          { type: 'array', required: true, message: '请至少选择一个人员状态', trigger: 'change' }
+        ]
+      }
       this.title = '添加人员'
       this.handleType = 'add'
     },
-    handleOk() {
-      this.form.type = this.form.type.join(',')
-      if (this.handleType === 'add') {
-        this.$store.dispatch('admin/addDeviceModifierData', this.form)
-      }
-      if (this.handleType === 'set') {
-        this.$store.dispatch('admin/setDeviceModifierData', this.form)
-      }
-      this.dialogFormVisible = false
+    handleOk(formName) {
+      this.$refs[formName].validate((valid) => {
+        if (valid) {
+          this.form.type = this.form.type.join(',')
+          if (this.handleType === 'add') {
+            this.$store.dispatch('admin/addDeviceModifierData', this.form)
+          }
+          if (this.handleType === 'set') {
+            this.$store.dispatch('admin/setDeviceModifierData', this.form)
+          }
+          this.formRules = {}
+          this.dialogFormVisible = false
+        } else {
+          console.log('error submit!!')
+          return false
+        }
+      })
     },
     handlePassOk(formName) {
       this.$refs[formName].validate((valid) => {
@@ -280,6 +305,17 @@ export default {
         type: 'type',
         select: '请选择人员类型'
       }]
+      this.formRules = {
+        name: [
+          { required: true, message: '请输入人员名称', trigger: 'blur' }
+        ],
+        mobile: [
+          { required: true, message: '请输入人员手机', trigger: 'blur' }
+        ],
+        type: [
+          { type: 'array', required: true, message: '请至少选择一个人员状态', trigger: 'change' }
+        ]
+      }
       this.form = {
         id: row.id,
         name: row.name,