yuhan il y a 1 an
Parent
commit
b1add347a2

+ 41 - 5
src/views/module_cmms/inspectContent/InspectContentList.vue

@@ -94,6 +94,10 @@
           </a-button>
         </template>
 
+        <template slot="status" slot-scope="text, record">
+          <a-switch :checked="record.status === '0' ? true : false" checked-children="启动" un-checked-children="停用" @click="changeStatus(record)"/>
+        </template>
+
         <span slot="action" slot-scope="text, record">
           <a @click="handleEdit(record)">编辑</a>
 
@@ -122,6 +126,7 @@
 
 <script>
 
+  import { httpAction, getAction } from '@/api/manage'
   import '@/assets/less/TableExpand.less'
   import { mixinDevice } from '@/utils/mixin'
   import { JeecgListMixin } from '@/mixins/JeecgListMixin'
@@ -159,14 +164,20 @@
             dataIndex: 'contentname'
           },
           {
-            title:'设备id',
+            title:'巡检内容名称',
+            align:"center",
+            dataIndex: 'classification_dictText'
+          },
+          {
+            title:'设备名称',
             align:"center",
-            dataIndex: 'equipmentid'
+            dataIndex: 'equipmentname'
           },
           {
-            title:'状态:启用:0、禁用:1',
+            title:'状态',
             align:"center",
-            dataIndex: 'status'
+            dataIndex: 'status',
+            scopedSlots: { customRender: 'status' }
           },
           {
             title:'备注',
@@ -188,6 +199,7 @@
           deleteBatch: "/cmmsInspectContent/cmmsInspectContent/deleteBatch",
           exportXlsUrl: "/cmmsInspectContent/cmmsInspectContent/exportXls",
           importExcelUrl: "cmmsInspectContent/cmmsInspectContent/importExcel",
+          updateStatus: "/cmmsInspectContent/cmmsInspectContent/updatestatus",
 
         },
         dictOptions:{},
@@ -195,7 +207,7 @@
       }
     },
     created() {
-    this.getSuperFieldList();
+      this.getSuperFieldList();
     },
     computed: {
       importExcelUrl: function(){
@@ -203,6 +215,30 @@
       },
     },
     methods: {
+      changeStatus(record){
+        // console.log(record.status)
+        const that = this
+        that.$confirm({
+          title: "提示",
+          content: record.status ==='0'?'确定停用吗?':'确定启用吗?',
+          onOk() {
+            var status = {
+              id: record.id,
+              status: record.status ==='0' ? '1' : '0',
+            }
+            httpAction(that.url.updateStatus,status,'post').then((res)=>{
+              if(res.success){
+                that.loadData()
+                that.$message.success(res.message);
+              }else{
+                that.$message.warning(res.message);
+              }
+            })
+          },
+          onCancel() {
+          }
+        });
+      },
       initDictConfig(){
       },
       getSuperFieldList(){

+ 26 - 5
src/views/module_cmms/inspectContent/modules/InspectContentForm.vue

@@ -101,14 +101,17 @@
         },
         confirmLoading: false,
         validatorRules: {
+          classification: [
+            { required: true, message: '请先选择巡检内容类型!'},
+          ],
           contentname: [
-          { required: true, message: '请输入巡检内容名称!'},
+            { required: true, message: '请输入巡检内容名称!'},
           ],
           equipmentid: [
-          { required: true, message: '请选择设备!'},
+            { required: true, message: '请选择设备!'},
           ],
           status: [
-          { required: true, message: '请选择状态!'},
+            { required: true, message: '请选择状态!'},
           ],
         },
         url: {
@@ -127,6 +130,16 @@
           //     return parseInt(index)+1;
           //   }
           // },
+          // {
+          //   title:'id',
+          //   align:"center",
+          //   dataIndex: 'id'
+          // },
+          // {
+          //   title:'inspectcheckitemid',
+          //   align:"center",
+          //   dataIndex: 'inspectcheckitemid'
+          // },
           {
             title:'点检项编号',
             align:"center",
@@ -171,6 +184,7 @@
         if (this.model.classification === '1' && this.model.equipmentid == undefined) {
           this.$message.error("请先选择设备!");
         } else {
+          this.$refs.addItemRef.type = this.model.classification
           this.$refs.addItemRef.add();
           this.$refs.addItemRef.title = "选择巡检项";
         }
@@ -185,6 +199,10 @@
         // this.model = Object.assign({}, record);
         getAction(this.url.queryById, {id: record.id}).then((res) => {
           this.model = res.result
+          this.model.cmmsInspectContentItemList.forEach(item => {
+            item.id = item.inspectcheckitemid
+          });
+          console.log(this.model.cmmsInspectContentItemList)
           this.confirmLoading = false
         })
       },
@@ -203,6 +221,9 @@
               httpurl+=this.url.edit;
                method = 'put';
             }
+            this.model.cmmsInspectContentItemList.forEach(item => {
+              item.inspectcheckitemid = item.id
+            });
             httpAction(httpurl,this.model,method).then((res)=>{
               if(res.success){
                 that.$message.success(res.message);
@@ -218,8 +239,8 @@
         })
       },
       handleOk(data){
-        console.log(data)
-        this.model.cmmsInspectContentItemList = data;
+        console.log('handleOk-data', data)
+        this.model.cmmsInspectContentItemList = data
       }
     }
   }

+ 76 - 31
src/views/module_cmms/inspectContent/modules/InspectContentModalAdd.vue

@@ -6,6 +6,10 @@
   @ok="handleOk"
   @cancel="handleCancel"
   cancelText="关闭">
+    <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
+      <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
+      <a style="margin-left: 24px" @click="onClearSelected">清空</a>
+    </div>
     <a-table
       ref="table"
       size="middle"
@@ -14,8 +18,9 @@
       rowKey="id"
       :columns="columns"
       :dataSource="dataSource"
-      :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
-      :pagination="false"
+      :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange, onSelect: onSelect}"
+      :pagination="ipagination"
+      @change="handleTableChange"
       class="j-table-force-nowrap">
     </a-table>
   </j-modal>
@@ -23,12 +28,12 @@
 
 <script>
   import { httpAction, getAction } from '@/api/manage'
+  import { mixinDevice } from '@/utils/mixin'
+  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
   
   export default {
     name: 'SpotcheckContentModalAdd',
-    components: {
-        
-    },
+    mixins:[JeecgListMixin, mixinDevice],
     props: {
       //表单禁用
       equipmentId: {
@@ -90,60 +95,100 @@
           }
         ],
         dataSource: [],
+        chooseData: [],
         url: {
           getList: "/cmmsInspectItem/cmmsInspectItem/getItemByEqId",
           itemList: "/cmmsInspectItem/cmmsInspectItem/list",
         },
       }
     },
+    watch: {
+      selectData: {
+        handler(newV, oldV){
+          console.log(newV, oldV)
+          if(newV.length > 0){
+            this.selectList()
+          }
+        },
+      }
+    },
     methods: {
-      add () {
+      add(){
         this.visible = true;
+        this.loadData()
+      },
+      loadData () {
+        // console.log(this.type)
+        var params = this.getQueryParams();//查询条件
+        this.loading = true;
         if(this.type === '1'){
-          getAction(this.url.getList, {eqid: this.equipmentId}).then((res) => {
-            this.dataSource = res.result
+          params.eqid = this.equipmentId
+          getAction(this.url.getList, params).then((res) => {
+            if (res.success) {
+              this.dataSource = res.result.records||res.result;
+              if(res.result.total)
+              {
+                this.ipagination.total = res.result.total;
+              }else{
+                this.ipagination.total = 0;
+              }
+              // this.selectList()
+            }else{
+              this.$message.warning(res.message)
+            }
+          }).finally(() => {
+            this.loading = false
           })
         } else {
-          getAction(this.url.itemList, {classification: this.type}).then((res) => {
-            this.dataSource = res.result.records
+          params.classification = this.type
+          getAction(this.url.itemList, params).then((res) => {
+            if (res.success) {
+              this.dataSource = res.result.records||res.result;
+              if(res.result.total)
+              {
+                this.ipagination.total = res.result.total;
+              }else{
+                this.ipagination.total = 0;
+              }
+              // this.selectList()
+            }else{
+              this.$message.warning(res.message)
+            }
+          }).finally(() => {
+            this.loading = false
           })
         }
-        this.selectList()
       },
       // 将以选中的值重新在列表中选中
       selectList() {
-        this.selectionRows = this.selectData
-        console.log(this.selectData)
-        this.selectedRowKeys = this.selectData.map((res) => {
+        this.chooseData = [...this.selectData]
+        console.log('chooseData', this.chooseData)
+        this.selectedRowKeys = this.chooseData.map((res) => {
           return res.id
         })
+        console.log(this.selectedRowKeys)
       },
       close () {
-        this.$emit('close');
         this.visible = false;
-        this.onClearSelected()
-        this.selectionRows = this.selectData
-        this.selectedRowKeys = this.selectData.map((res) => {
-          return res.id
-        })
-        this.dataSource = []
       },
       handleOk () {
-        console.log(this.selectionRows)
-        this.$emit('ok', this.selectionRows);
+        this.$emit('ok', this.chooseData);
+        console.log(this.chooseData)
         this.visible = false;
       },
       handleCancel () {
         this.close()
       },
-      onSelectChange(selectedRowKeys, selectionRows) {
-        this.selectedRowKeys = selectedRowKeys;
-        this.selectionRows = selectionRows;
-        console.log(this.selectedRowKeys,this.selectionRows)
-      },
-      onClearSelected() {
-        this.selectedRowKeys = [];
-        this.selectionRows = [];
+      onSelect(selectedRow, selected){
+        // console.log(selectedRow, selected)
+        if(selected){
+          // 新增
+          this.chooseData.push(selectedRow)
+        } else {
+          // 删除(过滤)
+          var index = this.chooseData.findIndex(item => item.id === selectedRow.id)
+          this.chooseData.splice(index, 1)
+        }
       },
     }
   }

+ 7 - 4
src/views/module_cmms/inspectLine/modules/InspectLineForm.vue

@@ -298,6 +298,9 @@
         // this.model = Object.assign({}, record);
         getAction(this.url.queryById, {id: record.id}).then((res) => {
           this.model = res.result
+          this.model.detailList.forEach(item => {
+            item.id = item.inspectspotid
+          });
           console.log(res)
           this.confirmLoading = false
         })
@@ -317,6 +320,9 @@
               httpurl+=this.url.edit;
                method = 'put';
             }
+            this.model.detailList.forEach(item => {
+              item.inspectspotid = item.id
+            });
             httpAction(httpurl,this.model,method).then((res)=>{
               if(res.success){
                 that.$message.success(res.message);
@@ -333,10 +339,7 @@
       },
       handleOk(data){
         console.log(data)
-        this.model.detailList = data.map(item=>{
-          item.inspectspotid = item.id
-          return item
-        })
+        this.model.detailList = data
       },
     }
   }

+ 54 - 31
src/views/module_cmms/inspectLine/modules/InspectLineModalAdd.vue

@@ -14,8 +14,9 @@
       rowKey="id"
       :columns="columns"
       :dataSource="dataSource"
-      :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
-      :pagination="false"
+      :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange, onSelect: onSelect}"
+      :pagination="ipagination"
+      @change="handleTableChange"
       class="j-table-force-nowrap">
     </a-table>
   </j-modal>
@@ -23,12 +24,12 @@
 
 <script>
   import { httpAction, getAction } from '@/api/manage'
+  import { mixinDevice } from '@/utils/mixin'
+  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
   
   export default {
     name: 'InspectLineModalAdd',
-    components: {
-        
-    },
+    mixins:[JeecgListMixin, mixinDevice],
     props: {
       //表单禁用
       equipmentId: {
@@ -80,55 +81,77 @@
           },
         ],
         dataSource: [],
+        chooseData: [],
         url: {
-          getList: "/cmmsInspectItem/cmmsInspectItem/getItemByEqId",
-          spotList: "/cmmsInspectSpot/cmmsInspectSpot/listDetails",
+          list: "/cmmsInspectSpot/cmmsInspectSpot/listDetails",
+        },
+      }
+    },
+    watch: {
+      selectData: {
+        handler(newV, oldV){
+          console.log(newV, oldV)
+          if(newV.length > 0){
+            this.selectList()
+          }
         },
       }
     },
     methods: {
-      add () {
+      add(){
         this.visible = true;
+        this.loadData()
+      },
+      loadData () {
         //  {status: '0'}
-        getAction(this.url.spotList).then((res) => {
-          this.dataSource = res.result.records
+        var params = this.getQueryParams();//查询条件
+        this.loading = true;
+        getAction(this.url.list, params).then((res) => {
+          if (res.success) {
+            this.dataSource = res.result.records||res.result;
+            if(res.result.total)
+            {
+              this.ipagination.total = res.result.total;
+            }else{
+              this.ipagination.total = 0;
+            }
+            // this.selectList()
+          }else{
+            this.$message.warning(res.message)
+          }
+        }).finally(() => {
+          this.loading = false
         })
-        this.selectList()
       },
       // 将以选中的值重新在列表中选中
       selectList() {
-        this.selectionRows = this.selectData
-        console.log(this.selectData)
+        this.chooseData = [...this.selectData]
+        // console.log(this.selectData)
         this.selectedRowKeys = this.selectData.map((res) => {
-          return res.inspectspotid
+          return res.id
         })
       },
       close () {
-        this.$emit('close');
         this.visible = false;
-        this.onClearSelected()
-        this.selectionRows = this.selectData
-        this.selectedRowKeys = this.selectData.map((res) => {
-          return res.inspectspotid
-        })
-        this.dataSource = []
       },
       handleOk () {
-        console.log(this.selectionRows)
-        this.$emit('ok', this.selectionRows);
+        this.$emit('ok', this.chooseData);
+        console.log('chooseData', this.chooseData)
         this.visible = false;
       },
       handleCancel () {
         this.close()
       },
-      onSelectChange(selectedRowKeys, selectionRows) {
-        this.selectedRowKeys = selectedRowKeys;
-        this.selectionRows = selectionRows;
-        console.log(this.selectedRowKeys,this.selectionRows)
-      },
-      onClearSelected() {
-        this.selectedRowKeys = [];
-        this.selectionRows = [];
+      onSelect(selectedRow, selected){
+        // console.log(selectedRow, selected)
+        if(selected){
+          // 新增
+          this.chooseData.push(selectedRow)
+        } else {
+          // 删除(过滤)
+          var index = this.chooseData.findIndex(item => item.id === selectedRow.id)
+          this.chooseData.splice(index, 1)
+        }
       },
     }
   }

+ 7 - 2
src/views/module_cmms/inspectPlan/modules/InspectPlanFormList.vue

@@ -336,12 +336,16 @@
       // 维护巡检路线
       handleAddLine(){
         this.inspectLineList = this.tableData.filter(item => item.tasktype === '巡检路线').map(i => i.inspectLineVo)
+        console.log(this.inspectLineList)
         this.$refs.addLineRef.add();
         this.$refs.addLineRef.title = "选择巡检路线";
       },
       handleLineOk(data){
-        // console.log(data) // 新获取的巡检路线数据
-        // console.log(this.inspectLineList) // 原来巡检路线数据
+        // console.log('ok-data', data) // 新获取的巡检路线数据
+        this.inspectLineList = this.tableData.filter(item => item.tasktype === '巡检路线').map(i => i.inspectLineVo)
+        // 为什么不写上面那一步,直接调用数据会变成data
+        // console.log('inspectLineList', this.inspectLineList) // 原来巡检路线数据
+        
         // 添加--获取最新巡检路线数据中原来巡检点没有的数据
         var addData = data.filter(item => !this.inspectLineList.some(i=>i.id === item.id))
         console.log(addLines)
@@ -375,6 +379,7 @@
       handleSpotOk(data){
         // console.log(data) // 新获取的巡检点数据
         // console.log(this.inspectSpotList) // 原来巡检点数据
+        this.inspectSpotList = this.tableData.filter(item => item.tasktype === '巡检点').map(i => i.inspectSpotVo)
         // 添加--获取最新巡检点数据中原来巡检点没有的数据
         var addData = data.filter(item => !this.inspectSpotList.some(i=>i.id === item.id))
         console.log(addSpots)

+ 2 - 0
src/views/module_cmms/inspectPlan/modules/InspectPlanFormSet.vue

@@ -172,6 +172,8 @@
             }).finally(() => {
               that.confirmLoading = false;
             })
+          } else {
+            that.$message.warning('计划设置参数未填写完全');
           }
          
         })

+ 54 - 33
src/views/module_cmms/inspectPlan/modules/InspectPlanModalAddLine.vue

@@ -6,6 +6,10 @@
   @ok="handleOk"
   @cancel="handleCancel"
   cancelText="关闭">
+    <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
+      <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
+      <a style="margin-left: 24px" @click="onClearSelected">清空</a>
+    </div>
     <a-table
       ref="table"
       size="middle"
@@ -14,23 +18,23 @@
       rowKey="id"
       :columns="columns"
       :dataSource="dataSource"
-      :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
-      :pagination="false"
-      class="j-table-force-nowrap">
+      :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange, onSelect: onSelect}"
+      class="j-table-force-nowrap"
+      :pagination="ipagination"
+      @change="handleTableChange">
     </a-table>
   </j-modal>
 </template>
 
 <script>
   import { httpAction, getAction } from '@/api/manage'
+  import { mixinDevice } from '@/utils/mixin'
+  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
   
   export default {
     name: 'InspectLineModalAdd',
-    components: {
-        
-    },
+    mixins:[JeecgListMixin, mixinDevice],
     props: {
-      //表单禁用
       equipmentId: {
         type: String,
         default: ''
@@ -44,6 +48,7 @@
     },
     data () {
       return {
+        disableMixinCreated: true,
         title:'',
         width: 1000,
         visible: false,
@@ -80,9 +85,11 @@
           },
         ],
         dataSource: [],
+        chooseData: [],
         url: {
-          getList: "/cmmsInspectItem/cmmsInspectItem/getItemByEqId",
-          lineList: "/cmmsInspectLine/cmmsInspectLine/listDetails",
+          list: "/cmmsInspectLine/cmmsInspectLine/listDetails",
+          // getList: "/cmmsInspectItem/cmmsInspectItem/getItemByEqId",
+          // lineList: "/cmmsInspectLine/cmmsInspectLine/listDetails",
         },
       }
     },
@@ -90,53 +97,67 @@
       selectData: {
         handler(newV, oldV){
           console.log(newV, oldV)
-          this.selectList()
+          if(newV.length > 0){
+            this.selectList()
+          }
         },
       }
     },
     methods: {
-      add () {
+      add(){
         this.visible = true;
+        this.loadData()
+      },
+      loadData () {
         //  {status: '0'}
-        getAction(this.url.lineList).then((res) => {
-          this.dataSource = res.result.records
+        var params = this.getQueryParams();//查询条件
+        this.loading = true;
+        getAction(this.url.list, params).then((res) => {
+          if (res.success) {
+            this.dataSource = res.result.records||res.result;
+            if(res.result.total)
+            {
+              this.ipagination.total = res.result.total;
+            }else{
+              this.ipagination.total = 0;
+            }
+            // this.selectList()
+          }else{
+            this.$message.warning(res.message)
+          }
+        }).finally(() => {
+          this.loading = false
         })
-        this.selectList()
       },
       // 将以选中的值重新在列表中选中
       selectList() {
-        this.selectionRows = this.selectData
-        console.log(this.selectData)
+        this.chooseData = this.selectData
+        // console.log(this.selectData)
         this.selectedRowKeys = this.selectData.map((res) => {
           return res.id
         })
       },
       close () {
-        this.$emit('close');
         this.visible = false;
-        this.onClearSelected()
-        this.selectionRows = this.selectData
-        this.selectedRowKeys = this.selectData.map((res) => {
-          return res.id
-        })
-        this.dataSource = []
       },
       handleOk () {
-        console.log(this.selectionRows)
-        this.$emit('ok', this.selectionRows);
+        this.$emit('ok', this.chooseData);
+        console.log(this.chooseData)
         this.visible = false;
       },
       handleCancel () {
         this.close()
       },
-      onSelectChange(selectedRowKeys, selectionRows) {
-        this.selectedRowKeys = selectedRowKeys;
-        this.selectionRows = selectionRows;
-        console.log(this.selectedRowKeys,this.selectionRows)
-      },
-      onClearSelected() {
-        this.selectedRowKeys = [];
-        this.selectionRows = [];
+      onSelect(selectedRow, selected){
+        // console.log(selectedRow, selected)
+        if(selected){
+          // 新增
+          this.chooseData.push(selectedRow)
+        } else {
+          // 删除(过滤)
+          var index = this.chooseData.findIndex(item => item.id === selectedRow.id)
+          this.chooseData.splice(index, 1)
+        }
       },
     }
   }

+ 47 - 32
src/views/module_cmms/inspectPlan/modules/InspectPlanModalAddSpot.vue

@@ -14,8 +14,9 @@
       rowKey="id"
       :columns="columns"
       :dataSource="dataSource"
-      :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
-      :pagination="false"
+      :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange, onSelect: onSelect}"
+      :pagination="ipagination"
+      @change="handleTableChange"
       class="j-table-force-nowrap">
     </a-table>
   </j-modal>
@@ -23,14 +24,13 @@
 
 <script>
   import { httpAction, getAction } from '@/api/manage'
+  import { mixinDevice } from '@/utils/mixin'
+  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
   
   export default {
     name: 'InspectLineModalAdd',
-    components: {
-        
-    },
+    mixins:[JeecgListMixin, mixinDevice],
     props: {
-      //表单禁用
       equipmentId: {
         type: String,
         default: ''
@@ -80,9 +80,10 @@
           },
         ],
         dataSource: [],
+        chooseData: [],
         url: {
-          getList: "/cmmsInspectItem/cmmsInspectItem/getItemByEqId",
-          spotList: "/cmmsInspectSpot/cmmsInspectSpot/listDetails",
+          // getList: "/cmmsInspectItem/cmmsInspectItem/getItemByEqId",
+          list: "/cmmsInspectSpot/cmmsInspectSpot/listDetails",
         },
       }
     },
@@ -90,53 +91,67 @@
       selectData: {
         handler(newV, oldV){
           console.log(newV, oldV)
-          this.selectList()
+          if(newV.length > 0){
+            this.selectList()
+          }
         },
       }
     },
     methods: {
-      add () {
+      add(){
         this.visible = true;
+        this.loadData()
+      },
+      loadData () {
         //  {status: '0'}
-        getAction(this.url.spotList).then((res) => {
-          this.dataSource = res.result.records
+        var params = this.getQueryParams();//查询条件
+        this.loading = true;
+        getAction(this.url.list, params).then((res) => {
+          if (res.success) {
+            this.dataSource = res.result.records||res.result;
+            if(res.result.total)
+            {
+              this.ipagination.total = res.result.total;
+            }else{
+              this.ipagination.total = 0;
+            }
+            // this.selectList()
+          }else{
+            this.$message.warning(res.message)
+          }
+        }).finally(() => {
+          this.loading = false
         })
-        this.selectList()
       },
       // 将以选中的值重新在列表中选中
       selectList() {
-        this.selectionRows = this.selectData
-        console.log(this.selectData)
+        this.chooseData = this.selectData
+        // console.log(this.selectData)
         this.selectedRowKeys = this.selectData.map((res) => {
           return res.id
         })
       },
       close () {
-        this.$emit('close');
         this.visible = false;
-        this.onClearSelected()
-        this.selectionRows = this.selectData
-        this.selectedRowKeys = this.selectData.map((res) => {
-          return res.id
-        })
-        this.dataSource = []
       },
       handleOk () {
-        console.log(this.selectionRows)
-        this.$emit('ok', this.selectionRows);
+        this.$emit('ok', this.chooseData);
+        console.log(this.chooseData)
         this.visible = false;
       },
       handleCancel () {
         this.close()
       },
-      onSelectChange(selectedRowKeys, selectionRows) {
-        this.selectedRowKeys = selectedRowKeys;
-        this.selectionRows = selectionRows;
-        console.log(this.selectedRowKeys,this.selectionRows)
-      },
-      onClearSelected() {
-        this.selectedRowKeys = [];
-        this.selectionRows = [];
+      onSelect(selectedRow, selected){
+        // console.log(selectedRow, selected)
+        if(selected){
+          // 新增
+          this.chooseData.push(selectedRow)
+        } else {
+          // 删除(过滤)
+          var index = this.chooseData.findIndex(item => item.id === selectedRow.id)
+          this.chooseData.splice(index, 1)
+        }
       },
     }
   }

+ 10 - 6
src/views/module_cmms/inspectSpot/modules/InspectSpotForm.vue

@@ -10,8 +10,8 @@
             </a-form-model-item>
           </a-col> -->
           <a-col :span="24">
-            <a-form-model-item label="巡检内容名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="contentname">
-              <a-input v-model="model.contentname" placeholder="请输入巡检内容名称"  ></a-input>
+            <a-form-model-item label="巡检名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="contentname">
+              <a-input v-model="model.contentname" placeholder="请输入巡检名称"  ></a-input>
             </a-form-model-item>
           </a-col>
           <a-col :span="24">
@@ -87,6 +87,9 @@
         },
         confirmLoading: false,
         validatorRules: {
+          contentname: [
+            { required: true, message: '请输入巡检路线名称!'},
+          ],
         },
         url: {
           add: "/cmmsInspectSpot/cmmsInspectSpot/add",
@@ -227,10 +230,11 @@
         })
       },
       handleOk(data){
-        data.map(res=>{
-          
-        })
-        this.model.inspectContentList = data;
+        // this.model.inspectContentList = data;
+        this.model.inspectContentList = data.map(item => {
+          // item.inspectcheckitemid = item.id
+          return item
+        });
       },
     }
   }

+ 95 - 27
src/views/module_cmms/inspectSpot/modules/InspectSpotModalAdd.vue

@@ -14,8 +14,9 @@
       rowKey="id"
       :columns="columns"
       :dataSource="dataSource"
-      :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
-      :pagination="false"
+      :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange, onSelect: onSelect}"
+      :pagination="ipagination"
+      @change="handleTableChange"
       class="j-table-force-nowrap">
     </a-table>
   </j-modal>
@@ -23,9 +24,12 @@
 
 <script>
   import { httpAction, getAction } from '@/api/manage'
+  import { mixinDevice } from '@/utils/mixin'
+  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
   
   export default {
     name: 'SpotcheckContentModalAdd',
+    mixins:[JeecgListMixin, mixinDevice],
     components: {
         
     },
@@ -89,55 +93,119 @@
           },
         ],
         dataSource: [],
+        chooseData: [],
         url: {
-          getList: "/cmmsInspectItem/cmmsInspectItem/getItemByEqId",
-          contentList: "/cmmsInspectContent/cmmsInspectContent/listDetails",
+          list: "/cmmsInspectContent/cmmsInspectContent/listDetails",
+        },
+      }
+    },
+    watch: {
+      selectData: {
+        handler(newV, oldV){
+          console.log(newV, oldV)
+          if(newV.length > 0){
+            this.selectList()
+          }
         },
       }
     },
     methods: {
-      add () {
+      add(){
         this.visible = true;
-        getAction(this.url.contentList, {status: '0'}).then((res) => {
-          this.dataSource = res.result.records
+        this.loadData()
+      },
+      loadData () {
+        //  {status: '0'}
+        var params = this.getQueryParams();//查询条件
+        params.status = '0'
+        this.loading = true;
+        getAction(this.url.list, params).then((res) => {
+          if (res.success) {
+            this.dataSource = res.result.records||res.result;
+            if(res.result.total)
+            {
+              this.ipagination.total = res.result.total;
+            }else{
+              this.ipagination.total = 0;
+            }
+            // this.selectList()
+          }else{
+            this.$message.warning(res.message)
+          }
+        }).finally(() => {
+          this.loading = false
         })
-        this.selectList()
       },
       // 将以选中的值重新在列表中选中
       selectList() {
-        this.selectionRows = this.selectData
-        console.log(this.selectData)
+        this.chooseData = [...this.selectData]
+        // console.log(this.selectData)
         this.selectedRowKeys = this.selectData.map((res) => {
           return res.id
         })
       },
       close () {
-        this.$emit('close');
         this.visible = false;
-        this.onClearSelected()
-        this.selectionRows = this.selectData
-        this.selectedRowKeys = this.selectData.map((res) => {
-          return res.id
-        })
-        this.dataSource = []
       },
       handleOk () {
-        console.log(this.selectionRows)
-        this.$emit('ok', this.selectionRows);
+        this.$emit('ok', this.chooseData);
+        console.log(this.chooseData)
         this.visible = false;
       },
       handleCancel () {
         this.close()
       },
-      onSelectChange(selectedRowKeys, selectionRows) {
-        this.selectedRowKeys = selectedRowKeys;
-        this.selectionRows = selectionRows;
-        console.log(this.selectedRowKeys,this.selectionRows)
-      },
-      onClearSelected() {
-        this.selectedRowKeys = [];
-        this.selectionRows = [];
+      onSelect(selectedRow, selected){
+        // console.log(selectedRow, selected)
+        if(selected){
+          // 新增
+          this.chooseData.push(selectedRow)
+        } else {
+          // 删除(过滤)
+          var index = this.chooseData.findIndex(item => item.id === selectedRow.id)
+          this.chooseData.splice(index, 1)
+        }
       },
+
+
+
+
+
+      // 将以选中的值重新在列表中选中
+      // selectList() {
+      //   this.selectionRows = this.selectData
+      //   console.log(this.selectData)
+      //   this.selectedRowKeys = this.selectData.map((res) => {
+      //     return res.id
+      //   })
+      // },
+      // close () {
+      //   this.$emit('close');
+      //   this.visible = false;
+      //   this.onClearSelected()
+      //   this.selectionRows = this.selectData
+      //   this.selectedRowKeys = this.selectData.map((res) => {
+      //     return res.id
+      //   })
+      //   this.dataSource = []
+      // },
+      // handleOk () {
+      //   console.log(this.selectionRows)
+      //   this.$emit('ok', this.selectionRows);
+      //   this.visible = false;
+      // },
+      // handleCancel () {
+      //   this.close()
+      // },
+      // onSelectChange(selectedRowKeys, selectionRows) {
+      //   this.selectedRowKeys = selectedRowKeys;
+      //   this.selectionRows = selectionRows;
+      //   console.log(this.selectedRowKeys,this.selectionRows)
+      // },
+      // onClearSelected() {
+      //   this.selectedRowKeys = [];
+      //   this.selectionRows = [];
+      // },
     }
   }
 </script>