Explorar o código

点检,保养——设备优化

wyh hai 1 ano
pai
achega
cc07760a32

+ 61 - 3
src/views/module_cmms/spotcheck/modules/SpotcheckForm.vue

@@ -11,7 +11,21 @@
           </a-col> -->
           <a-col :span="12">
             <a-form-model-item label="设备名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="equipmentid">
-              <j-search-select-tag v-model="model.equipmentid" dict="tpm_equipment,equipmentname,id" placeholder="请选择设备" @change="handleChange" :disabled="disabledEdit"/>
+              <!-- <j-search-select-tag v-model="model.equipmentid" dict="tpm_equipment,equipmentname,id" placeholder="请选择设备" @change="handleChange" :disabled="disabledEdit"/> -->
+              <a-select
+              v-model="model.equipmentid"
+              placeholder="请输入设备名称或设备编号"
+              show-search
+              :disabled="disabledEdit"
+              :filterOption="filterOptions"
+              @search="searchDevice"
+              @change="handleChange"
+              allowClear>
+                <a-select-option v-for="(item, index) in deviceOptions" :key="index" :value="item.id" :label="item.equipmentname">
+                  <span>{{item.equipmentname}}</span>
+                  <span style="position: absolute;right: 2%;">{{ item.equipmentcode }}</span>
+                </a-select-option>
+              </a-select>
             </a-form-model-item>
           </a-col>
           <a-col :span="12">
@@ -229,7 +243,9 @@
           add2: "/cmmsRepair/cmmsRepair/add",
           edit: "/cmmsSpotcheck/cmmsSpotcheck/edit",
           queryById: "/cmmsSpotcheck/cmmsSpotcheck/queryById"
-        }
+        },
+        deviceOptions: [],
+        deviceOptionsAll: [],
       }
     },
     computed: {
@@ -240,10 +256,52 @@
     created () {
        //备份model原始值
       this.modelDefault = JSON.parse(JSON.stringify(this.model));
+      this.getDeviceOption();
     },
     methods: {
+      // 获取设备下拉列表
+      getDeviceOption(){
+        getAction(`/tpmEquipment/tpmEquipment/selectEquipmentList`).then(res=>{
+          console.log(111,res.result)
+          this.deviceOptions = res.result.map((res) => {
+            return {
+              id: res.id,
+              equipmentname: res.equipmentname,
+              equipmentcode: res.equipmentcode,
+            }
+          })
+          // 存一个完整的设备表
+          this.deviceOptionsAll = this.deviceOptions
+          console.log(7878,this.deviceOptionsAll)
+        })
+      },
+      // 筛选设备
+      searchDevice(value) {
+        console.log(1212,value,value.trim().length)
+        // 若输入的值删除,则重新赋完整的设备列表
+        if (value.trim().length === 0) {
+          this.deviceOptions = this.deviceOptionsAll
+        }
+        // 通过判断字符串中是数字还是文字进而判断是通过设备名筛选还是设备编号筛选
+        let panDuan = isNaN(parseFloat(value))
+        if (!panDuan) {
+          // 数字
+          console.log(777)
+          let filteredArray = this.deviceOptionsAll.filter(item => item.equipmentcode.includes(value));
+          this.deviceOptions = filteredArray
+        } else {
+          console.log(888)
+          let filteredArray = this.deviceOptionsAll.filter(item => item.equipmentname.includes(value));
+          this.deviceOptions = filteredArray
+        }
+        console.log(999,this.deviceOptions)
+      },
+      // 解决筛选后option不回显问题
+      filterOptions(input, option) {                    
+        return this.deviceOptions
+      },
       add () {
-        this.edit(this.modelDefault);
+        // this.edit(this.modelDefault);
         this.disabledEdit = false
         // 第二版
         // this.model = this.dataList

+ 59 - 2
src/views/module_cmms/spotcheckContent/modules/SpotcheckContentForm.vue

@@ -18,7 +18,20 @@
               </a-col>
               <a-col :span="12">
                 <a-form-model-item label="选择设备" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="equipmentid">
-                  <j-search-select-tag v-model="model.equipmentid" dict="tpm_equipment,equipmentname,id" :disabled="disabledEdit" />
+                  <!-- <j-search-select-tag v-model="model.equipmentid" dict="tpm_equipment,equipmentname,id" :disabled="disabledEdit" /> -->
+                  <a-select
+                  v-model="model.equipmentid"
+                  placeholder="请输入设备名称或设备编号"
+                  show-search
+                  :disabled="disabledEdit"
+                  :filterOption="filterOptions"
+                  @search="searchDevice"
+                  allowClear>
+                    <a-select-option v-for="(item, index) in deviceOptions" :key="index" :value="item.id" :label="item.equipmentname">
+                      <span>{{item.equipmentname}}</span>
+                      <span style="position: absolute;right: 2%;">{{ item.equipmentcode }}</span>
+                    </a-select-option>
+                  </a-select>
                 </a-form-model-item>
               </a-col>
               <a-col :span="12">
@@ -154,7 +167,9 @@
           edit: "/cmmsSpotcheckContent/cmmsSpotcheckContent/edit",
           // queryById: "/cmmsSpotcheckContent/cmmsSpotcheckContent/queryById"
           queryById: "/cmmsSpotcheckContent/cmmsSpotcheckContent/queryContentAndItemById"
-        }
+        },
+        deviceOptions: [],
+        deviceOptionsAll: [],
       }
     },
     computed: {
@@ -165,8 +180,50 @@
     created () {
        //备份model原始值
       this.modelDefault = JSON.parse(JSON.stringify(this.model));
+      this.getDeviceOption();
     },
     methods: {
+      // 获取设备下拉列表
+      getDeviceOption(){
+        getAction(`/tpmEquipment/tpmEquipment/selectEquipmentList`).then(res=>{
+          console.log(111,res.result)
+          this.deviceOptions = res.result.map((res) => {
+            return {
+              id: res.id,
+              equipmentname: res.equipmentname,
+              equipmentcode: res.equipmentcode,
+            }
+          })
+          // 存一个完整的设备表
+          this.deviceOptionsAll = this.deviceOptions
+          console.log(7878,this.deviceOptionsAll)
+        })
+      },
+      // 筛选设备
+      searchDevice(value) {
+        console.log(1212,value,value.trim().length)
+        // 若输入的值删除,则重新赋完整的设备列表
+        if (value.trim().length === 0) {
+          this.deviceOptions = this.deviceOptionsAll
+        }
+        // 通过判断字符串中是数字还是文字进而判断是通过设备名筛选还是设备编号筛选
+        let panDuan = isNaN(parseFloat(value))
+        if (!panDuan) {
+          // 数字
+          console.log(777)
+          let filteredArray = this.deviceOptionsAll.filter(item => item.equipmentcode.includes(value));
+          this.deviceOptions = filteredArray
+        } else {
+          console.log(888)
+          let filteredArray = this.deviceOptionsAll.filter(item => item.equipmentname.includes(value));
+          this.deviceOptions = filteredArray
+        }
+        console.log(999,this.deviceOptions)
+      },
+      // 解决筛选后option不回显问题
+      filterOptions(input, option) {                    
+        return this.deviceOptions
+      },
       add () {
         // this.edit(this.modelDefault);
         this.model = Object.assign({}, this.modelDefault);

+ 59 - 2
src/views/module_cmms/upkeep/UpkeepList.vue

@@ -17,7 +17,19 @@
           <template v-if="toggleSearchStatus">
             <a-col :xl="6" :lg="7" :md="8" :sm="24">
               <a-form-item label="设备">
-                <j-search-select-tag v-model="queryParam.equipmentid" dict="tpm_equipment,equipmentname,id"  placeholder="请选择设备"/>
+                <!-- <j-search-select-tag v-model="queryParam.equipmentid" dict="tpm_equipment,equipmentname,id"  placeholder="请选择设备"/> -->
+                <a-select
+                v-model="queryParam.equipmentid"
+                placeholder="请输入设备名称或设备编号"
+                show-search
+                :filterOption="filterOptions"
+                @search="searchDevice"
+                allowClear>
+                  <a-select-option v-for="(item, index) in deviceOptions" :key="index" :value="item.id" :label="item.equipmentname">
+                    <span>{{item.equipmentname}}</span>
+                    <span style="position: absolute;right: 2%;">{{ item.equipmentcode }}</span>
+                  </a-select-option>
+                </a-select>
               </a-form-item>
             </a-col>
             <a-col :xl="6" :lg="7" :md="8" :sm="24">
@@ -141,6 +153,7 @@
   import { mixinDevice } from '@/utils/mixin'
   import { JeecgListMixin } from '@/mixins/JeecgListMixin'
   import UpkeepModal from './modules/UpkeepModal'
+  import { httpAction, getAction } from '@/api/manage'
 
   export default {
     name: 'UpkeepList',
@@ -276,11 +289,14 @@
         // },
         dictOptions:{},
         superFieldList:[],
+        deviceOptions: [],
+        deviceOptionsAll: [],
       }
     },
     created() {
       console.log(777,this.url)
-    this.getSuperFieldList();
+      this.getSuperFieldList();
+      this.getDeviceOption();
     },
     computed: {
       importExcelUrl: function(){
@@ -288,6 +304,47 @@
       },
     },
     methods: {
+      // 获取设备下拉列表
+      getDeviceOption(){
+        getAction(`/tpmEquipment/tpmEquipment/selectEquipmentList`).then(res=>{
+          console.log(111,res.result)
+          this.deviceOptions = res.result.map((res) => {
+            return {
+              id: res.id,
+              equipmentname: res.equipmentname,
+              equipmentcode: res.equipmentcode,
+            }
+          })
+          // 存一个完整的设备表
+          this.deviceOptionsAll = this.deviceOptions
+          console.log(7878,this.deviceOptionsAll)
+        })
+      },
+      // 筛选设备
+      searchDevice(value) {
+        console.log(1212,value,value.trim().length)
+        // 若输入的值删除,则重新赋完整的设备列表
+        if (value.trim().length === 0) {
+          this.deviceOptions = this.deviceOptionsAll
+        }
+        // 通过判断字符串中是数字还是文字进而判断是通过设备名筛选还是设备编号筛选
+        let panDuan = isNaN(parseFloat(value))
+        if (!panDuan) {
+          // 数字
+          console.log(777)
+          let filteredArray = this.deviceOptionsAll.filter(item => item.equipmentcode.includes(value));
+          this.deviceOptions = filteredArray
+        } else {
+          console.log(888)
+          let filteredArray = this.deviceOptionsAll.filter(item => item.equipmentname.includes(value));
+          this.deviceOptions = filteredArray
+        }
+        console.log(999,this.deviceOptions)
+      },
+      // 解决筛选后option不回显问题
+      filterOptions(input, option) {                    
+        return this.deviceOptions
+      },
       handleEdit: function (record) {
         this.$refs.modalForm.edit(record);
         this.$refs.modalForm.title = "反馈";

+ 58 - 2
src/views/module_cmms/upkeepPlan/UpkeepPlanList.vue

@@ -36,7 +36,19 @@
             </a-col> -->
             <a-col :xl="6" :lg="7" :md="8" :sm="24">
               <a-form-item label="设备">
-                <j-search-select-tag v-model="queryParam.equipmentid" dict="tpm_equipment,equipmentname,id"  placeholder="请选择设备"/>
+                <!-- <j-search-select-tag v-model="queryParam.equipmentid" dict="tpm_equipment,equipmentname,id"  placeholder="请选择设备"/> -->
+                <a-select
+                v-model="queryParam.equipmentid"
+                placeholder="请输入设备名称或设备编号"
+                show-search
+                :filterOption="filterOptions"
+                @search="searchDevice"
+                allowClear>
+                  <a-select-option v-for="(item, index) in deviceOptions" :key="index" :value="item.id" :label="item.equipmentname">
+                    <span>{{item.equipmentname}}</span>
+                    <span style="position: absolute;right: 2%;">{{ item.equipmentcode }}</span>
+                  </a-select-option>
+                </a-select>
                 <!-- <a-input placeholder="请输入保养项编号" v-model="queryParam.itemcode"></a-input> -->
               </a-form-item>
             </a-col>
@@ -313,11 +325,14 @@
         },
         dictOptions:{},
         superFieldList:[],
-        model: {}
+        model: {},
+        deviceOptions: [],
+        deviceOptionsAll: [],
       }
     },
     created() {
     this.getSuperFieldList();
+    this.getDeviceOption();
     },
     computed: {
       importExcelUrl: function(){
@@ -325,6 +340,47 @@
       },
     },
     methods: {
+      // 获取设备下拉列表
+      getDeviceOption(){
+        getAction(`/tpmEquipment/tpmEquipment/selectEquipmentList`).then(res=>{
+          console.log(111,res.result)
+          this.deviceOptions = res.result.map((res) => {
+            return {
+              id: res.id,
+              equipmentname: res.equipmentname,
+              equipmentcode: res.equipmentcode,
+            }
+          })
+          // 存一个完整的设备表
+          this.deviceOptionsAll = this.deviceOptions
+          console.log(7878,this.deviceOptionsAll)
+        })
+      },
+      // 筛选设备
+      searchDevice(value) {
+        console.log(1212,value,value.trim().length)
+        // 若输入的值删除,则重新赋完整的设备列表
+        if (value.trim().length === 0) {
+          this.deviceOptions = this.deviceOptionsAll
+        }
+        // 通过判断字符串中是数字还是文字进而判断是通过设备名筛选还是设备编号筛选
+        let panDuan = isNaN(parseFloat(value))
+        if (!panDuan) {
+          // 数字
+          console.log(777)
+          let filteredArray = this.deviceOptionsAll.filter(item => item.equipmentcode.includes(value));
+          this.deviceOptions = filteredArray
+        } else {
+          console.log(888)
+          let filteredArray = this.deviceOptionsAll.filter(item => item.equipmentname.includes(value));
+          this.deviceOptions = filteredArray
+        }
+        console.log(999,this.deviceOptions)
+      },
+      // 解决筛选后option不回显问题
+      filterOptions(input, option) {                    
+        return this.deviceOptions
+      },
       initDictConfig(){
       },
       getSuperFieldList(){

+ 58 - 1
src/views/module_cmms/upkeepPlan/modules/UpkeepPlanForm.vue

@@ -18,7 +18,20 @@
               </a-col>
               <a-col :span="12">
                 <a-form-model-item label="选择设备" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="equipmentid">
-                  <j-search-select-tag v-model="model.equipmentid" dict="tpm_equipment,equipmentname,id" :disabled="disabledEdit" style="width: 100%"/>
+                  <!-- <j-search-select-tag v-model="model.equipmentid" dict="tpm_equipment,equipmentname,id" :disabled="disabledEdit" style="width: 100%"/> -->
+                  <a-select
+                  v-model="model.equipmentid"
+                  placeholder="请输入设备名称或设备编号"
+                  show-search
+                  :disabled="disabledEdit"
+                  :filterOption="filterOptions"
+                  @search="searchDevice"
+                  allowClear>
+                    <a-select-option v-for="(item, index) in deviceOptions" :key="index" :value="item.id" :label="item.equipmentname">
+                      <span>{{item.equipmentname}}</span>
+                      <span style="position: absolute;right: 2%;">{{ item.equipmentcode }}</span>
+                    </a-select-option>
+                  </a-select>
                     <!-- <a-button type="primary" icon="search" /> -->
                 </a-form-model-item>
               </a-col>
@@ -250,6 +263,8 @@
             dataIndex: 'remark'
           },
         ],
+        deviceOptions: [],
+        deviceOptionsAll: [],
       }
     },
     computed: {
@@ -260,8 +275,50 @@
     created () {
        //备份model原始值
       this.modelDefault = JSON.parse(JSON.stringify(this.model));
+      this.getDeviceOption();
     },
     methods: {
+      // 获取设备下拉列表
+      getDeviceOption(){
+        getAction(`/tpmEquipment/tpmEquipment/selectEquipmentList`).then(res=>{
+          console.log(111,res.result)
+          this.deviceOptions = res.result.map((res) => {
+            return {
+              id: res.id,
+              equipmentname: res.equipmentname,
+              equipmentcode: res.equipmentcode,
+            }
+          })
+          // 存一个完整的设备表
+          this.deviceOptionsAll = this.deviceOptions
+          console.log(7878,this.deviceOptionsAll)
+        })
+      },
+      // 筛选设备
+      searchDevice(value) {
+        console.log(1212,value,value.trim().length)
+        // 若输入的值删除,则重新赋完整的设备列表
+        if (value.trim().length === 0) {
+          this.deviceOptions = this.deviceOptionsAll
+        }
+        // 通过判断字符串中是数字还是文字进而判断是通过设备名筛选还是设备编号筛选
+        let panDuan = isNaN(parseFloat(value))
+        if (!panDuan) {
+          // 数字
+          console.log(777)
+          let filteredArray = this.deviceOptionsAll.filter(item => item.equipmentcode.includes(value));
+          this.deviceOptions = filteredArray
+        } else {
+          console.log(888)
+          let filteredArray = this.deviceOptionsAll.filter(item => item.equipmentname.includes(value));
+          this.deviceOptions = filteredArray
+        }
+        console.log(999,this.deviceOptions)
+      },
+      // 解决筛选后option不回显问题
+      filterOptions(input, option) {                    
+        return this.deviceOptions
+      },
       add () {
         // this.edit(this.modelDefault);
         this.model = Object.assign({}, this.modelDefault);