Pārlūkot izejas kodu

布撤防修改

jiawuxian 1 gadu atpakaļ
vecāks
revīzija
e32de613b7

+ 15 - 2
src/components/timeCell/index.vue

@@ -1,6 +1,6 @@
 <template>
   <div class="date-cell">
-    <van-cell v-if="disabled" :title="title" :value="isRow ? label : ''" :label="!isRow ? label : ''" />
+    <van-cell v-if="disabled" :title="title" :value="isRow ? label : ''" :label="!isRow ? label : ''" title-class="date-cell-title" value-class="date-cell-value" />
     <van-cell
       v-else
       :title="title"
@@ -9,6 +9,8 @@
       :value="isRow ? label : ''"
       :label="!isRow ? label : ''"
       @click="clickItem"
+      title-class="date-cell-title" 
+      value-class="date-cell-value" 
     >
       <template #right-icon>
         <van-icon name="notes-o" class="date-icon" />
@@ -27,6 +29,7 @@
         @cancel="cancelPicker"
         @confirm="pickerConfirm"
         confirm-button-text="确定"
+        :max-date="maxDate"
       />
     </van-popup>
   </div>
@@ -44,7 +47,7 @@ export default {
     },
     //默认值
     value: {
-      type: String,
+      type: [String,Date],
       default: null
     },
     //标题
@@ -75,6 +78,9 @@ export default {
     }, 
     valueFormatter:{
       type:String
+    },
+    maxDate:{
+      type:Date
     }
   },
   data() {
@@ -203,6 +209,13 @@ export default {
   color: #323233;
   background-color: #fff;
 }
+.date-cell-title{
+  max-width:35%;
+}
+
+.date-cell-value{
+  width:65%;
+}
 .date-cell::after {
   position: absolute;
   box-sizing: border-box;

+ 17 - 7
src/views/menu/iot/subsystem/components/dialog.stateChange.vue

@@ -1,10 +1,19 @@
 <template>
   <van-dialog @confirm="onConfirm" v-model="show" show-cancel-button>
-    <div style="margin:10px;">
+    <div style="margin: 10px">
       <div>
         <div>是否更新{{ stateText }}时间?</div>
       </div>
-      <time-cell required is-row title="更新时间" v-model="time" dateType="time" textFormatter="H时m分"/>
+      <time-cell
+        v-if="show"
+        required
+        is-row
+        title="更新时间"
+        v-model="time"
+        dateType="datetime"
+        textFormatter="YYYY年M月D日H时m分"
+        :max-date="new Date()"
+      />
     </div>
   </van-dialog>
 </template>
@@ -20,19 +29,20 @@ export default {
       show: false,
       subSystem: {},
       stateText: '',
-      time:dayjs(new Date()) .format("H:m")
+      time: new Date()
     }
   },
   props: {},
   methods: {
     dayjs,
-    onConfirm() {  
-      this.$emit('success',this.subSystem,this.state,`${dayjs().format("YYYY-MM-DD")} ${this.time}:00`)
+    onConfirm() {
+      this.$emit('success', this.subSystem, this.state, this.time)
     },
-    open(subSystem,state, stateText) {
+    open(subSystem, state, stateText) {
       this.subSystem = subSystem
-      this.state=state,
+      this.state = state
       this.stateText = stateText
+      this.time = new Date()
       this.show = true
     }
   }

+ 4 - 3
src/views/menu/iot/subsystem/components/item.vue

@@ -12,7 +12,7 @@
               return false
             "
             v-if="data.status != '1' && data.orgId == orgId"
-            >布防时间登记</van-button
+            >布防登记</van-button
           >
           <van-button
             size="mini"
@@ -23,7 +23,7 @@
               return false
             "
             v-if="data.status != '0' && data.orgId == orgId"
-            >撤防时间登记</van-button
+            >撤防登记</van-button
           >
         </template>
       </van-cell>
@@ -92,10 +92,11 @@ export default {
       //   })
     },
     updateStatus(data, status,changeTime) {      
-      api.updateStatus(data.id, status,changeTime).then(r => {
+      api.updateStatus(data.id, status,dayjs(changeTime).format('YYYY-MM-DD HH:mm:00')).then(r => {
         if (r.data) {
           data.status = status
           data.statusChangeTime = dayjs(changeTime).format('YYYY-MM-DD HH:mm')
+          data.statusUpdatorName=this.$store.getters.userName
         }
       })
     },

+ 103 - 30
src/views/menu/iot/subsystem/index.vue

@@ -6,12 +6,53 @@
         <org-tree v-model="search.orgId" @changeItem="changeTree" @checked="orgCheckChanged" showChecked></org-tree>
       </van-col>
     </van-row>
+    <van-row>
+      <van-col span="10">
+        <!-- <van-field
+            v-model="fieldValue"
+            label-width="3em"
+            clearable
+            :disabled="showStatus"
+            label="状态"
+            placeholder=""
+            @click="showStatus = true"
+            ><van-icon name="arrow-down" slot="button"
+          /></van-field> -->
+        <van-cell title="状态" @click="showStatus = true" is-link arrow-direction="down" :value="defaultStatus" />
+
+        <van-popup v-model="showStatus" round position="bottom">
+          <van-picker
+            title="状态"
+            show-toolbar
+            :columns="statusOptions"
+            @confirm="onStatusConfirm"
+            @cancel="onCancel"
+            default-index="0"
+            :close-on-click-overlay="false"
+          />
+        </van-popup>
+      </van-col>
+      <van-col span="14">
+        <van-cell title="上报时间" @click="showHour = true" is-link arrow-direction="down" :value="defaultHour"/>
+
+        <van-popup v-model="showHour" round position="bottom">
+          <van-picker
+            title="上报时间"
+            show-toolbar
+            :columns="hourOptions.map(o => o.text)"
+            @confirm="onTimeConfirm"
+            @cancel="onCancel"
+            :close-on-click-overlay="false"
+          />
+        </van-popup>
+      </van-col>
+    </van-row>
     <!-- <van-search v-model="search.key" placeholder="请输入搜索关键词" maxlength="50" /> -->
-    <van-dropdown-menu>
-      <!-- <van-dropdown-item :title="selectedOrgName" @open="onItemClick" /> -->
-      <van-dropdown-item v-model="search.status" :options="statusOptions" />
+    <!-- <van-dropdown-menu> -->
+    <!-- <van-dropdown-item :title="selectedOrgName" @open="onItemClick" /> -->
+    <!-- <van-dropdown-item v-model="search.status" :options="statusOptions" />
       <van-dropdown-item v-model="search.hour" :options="hourOptions" />
-    </van-dropdown-menu>
+    </van-dropdown-menu> -->
     <!-- <div>
       <van-picker show-toolbar title="选择" :columns="statusOptions"/>
     </div> -->
@@ -39,13 +80,13 @@ import KList from '@/components/list/index.vue'
 import Item from './components/item.vue'
 import OrgTree from '@/components/orgTree'
 export default {
-  components: { NavBar, KList, Item ,OrgTree},
+  components: { NavBar, KList, Item, OrgTree },
   data() {
     return {
       options: [],
       search: {
         orgId: this.orgId,
-        checkSub:false,
+        checkSub: false,
         status: null,
         hour: null,
         key: null,
@@ -53,11 +94,14 @@ export default {
         pageNum: 1,
         pageSize: 10
       },
-      showOrg: false,
+      // showOrg: false,
       selectedOrgName: null,
-
+      showStatus: false,
+      showHour: false,
+      defaultStatus: '全部',
+      defaultHour: '全部',
       hourOptions: [
-        { value: null, text: '上报时间' },
+        { value: null, text: '全部' },
         { value: 1, text: '1小时内' },
         { value: 2, text: '2小时内' },
         { value: 3, text: '3小时内' },
@@ -73,12 +117,12 @@ export default {
       //     text: ''
       //   }
       // ],
-      fieldNames: {
-        text: 'shortName',
-        value: 'id',
-        children: 'children'
-      },
-      dicts: ["protection_status"]
+      // fieldNames: {
+      //   text: 'shortName',
+      //   value: 'id',
+      //   children: 'children'
+      // },
+      dicts: ['protection_status']
     }
   },
   watch: {
@@ -95,7 +139,7 @@ export default {
     //   }
     // }
   },
-  created() { },
+  created() {},
   mounted() {
     this.getTreeList()
     this.search.orgId = this.orgId
@@ -106,18 +150,26 @@ export default {
   computed: {
     ...mapGetters(['orgName', 'orgId', 'dictionary']),
     statusOptions() {
-      let r = [
-        { value: null, text: '布撤防状态' }
-      ]
-
-      let dict = this.getDictItem('protection_status');
+      let r = ['全部']
+      let dict = this.getDictItem('protection_status')
       if (dict) {
         dict.forEach(element => {
-          r.push({ value: element.dictValue, text: element.dictLabel })
-        });
+          r.push(element.dictLabel)
+        })
       }
 
-      return r;
+      // let r = [
+      //   { value: null, text: '所有布撤防状态' }
+      // ]
+
+      // let dict = this.getDictItem('protection_status');
+      // if (dict) {
+      //   dict.forEach(element => {
+      //     r.push({ value: element.dictValue, text: element.dictLabel })
+      //   });
+      // }
+
+      return r
     }
   },
   methods: {
@@ -131,8 +183,30 @@ export default {
         // console.log(res,'3333')
       })
     },
-    onItemClick() {
-      this.showOrg = true
+    onStatusConfirm(text) {
+      let dict = this.getDictItem('protection_status')
+      for (let item of dict) {
+        if (item.dictLabel === text) {
+          this.search.status = item.dictValue
+        }
+      }
+      this.showStatus=false;
+    },
+
+    onTimeConfirm(text) {
+      for (let item of this.hourOptions) {
+        if (item.text === text) {
+          this.search.hour = item.value
+        }
+      }
+      this.showHour=false;
+    },
+    // onItemClick() {
+    //   this.showOrg = true
+    // },
+    onCancel() {
+      this.showHour = false
+      this.showStatus = false
     },
     //改变机构后将重新发起请求
     changeTree(node) {
@@ -142,11 +216,11 @@ export default {
       this.search.orgId = node.id
       this.selectedOrgName = node.shortName
     },
-    orgCheckChanged(v){
-      this.search.checkSub=v;
+    orgCheckChanged(v) {
+      this.search.checkSub = v
     },
     onFinish({ selectedOptions }) {
-      this.showOrg = false
+      // this.showOrg = false
     }
   }
 }
@@ -158,7 +232,6 @@ export default {
   display: block;
 
   .container {
-
     // overflow: auto;
     // height: calc(100vh - 11rem);
     .k-content-repair {