Browse Source

巡检计划

yuhan 1 year ago
parent
commit
1d40966147

+ 22 - 16
src/views/module_cmms/inspectPlan/InspectPlanList.vue

@@ -132,7 +132,7 @@
             dataIndex: 'planname'
             dataIndex: 'planname'
           },
           },
           {
           {
-            title:'是否开启时间设置:Y是、N否',
+            title:'是否开启时间设置',
             align:"center",
             align:"center",
             dataIndex: 'iftimeset'
             dataIndex: 'iftimeset'
           },
           },
@@ -145,29 +145,35 @@
             }
             }
           },
           },
           {
           {
-            title:'重复',
+            title:'重复周期',
             align:"center",
             align:"center",
-            dataIndex: 'repeatnum'
-          },
-          {
-            title:'重复类型:年、月、周、日、时、分',
-            align:"center",
-            dataIndex: 'repeattype'
+            dataIndex: 'repeatnum',
+            customRender:function (t, r, index) {
+              return r.repeatnum + r.repeattype
+            }
           },
           },
+          // {
+          //   title:'重复类型:年、月、周、日、时、分',
+          //   align:"center",
+          //   dataIndex: 'repeattype'
+          // },
           {
           {
             title:'提前通知时间',
             title:'提前通知时间',
             align:"center",
             align:"center",
-            dataIndex: 'noticenum'
-          },
-          {
-            title:'提前通知类型:天、时、分',
-            align:"center",
-            dataIndex: 'noticetype'
+            dataIndex: 'noticenum',
+            customRender:function (t, r, index) {
+              return r.noticenum + r.noticetype
+            }
           },
           },
+          // {
+          //   title:'通知单位',
+          //   align:"center",
+          //   dataIndex: 'noticetype'
+          // },
           {
           {
             title:'状态(0启用 1停用)',
             title:'状态(0启用 1停用)',
             align:"center",
             align:"center",
-            dataIndex: 'status'
+            dataIndex: 'status_dictText'
           },
           },
           {
           {
             title:'待办人',
             title:'待办人',
@@ -196,7 +202,7 @@
             }
             }
           },
           },
           {
           {
-            title:'是否已通知:是/否',
+            title:'是否已通知',
             align:"center",
             align:"center",
             dataIndex: 'ifnotice'
             dataIndex: 'ifnotice'
           },
           },

+ 121 - 30
src/views/module_cmms/inspectPlan/modules/InspectPlanFormList.vue

@@ -20,12 +20,12 @@
         class="plan-table">
         class="plan-table">
         <!-- :loading="loading" -->
         <!-- :loading="loading" -->
         <template slot="expandedRowRender" slot-scope="record">
         <template slot="expandedRowRender" slot-scope="record">
-          <div v-if="record.type === '巡检路线'" class="line-spot-container">
+          <div v-if="record.tasktype === '巡检路线'" class="line-spot-container">
             <a-table
             <a-table
               size="middle"
               size="middle"
               rowKey="id"
               rowKey="id"
-              :columns="columns"
-              :dataSource="record.sonList"
+              :columns="spotColumns"
+              :dataSource="record.inspectLineVo.detailList"
               :pagination="false"
               :pagination="false"
               :showHeader="false"
               :showHeader="false"
               class="line-spot-table">
               class="line-spot-table">
@@ -35,7 +35,7 @@
                     size="middle"
                     size="middle"
                     rowKey="id"
                     rowKey="id"
                     :columns="contentColumns"
                     :columns="contentColumns"
-                    :dataSource="record.sonList"
+                    :dataSource="record.inspectContentList"
                     :pagination="false"
                     :pagination="false"
                     class="spot-content-table">
                     class="spot-content-table">
                     <template slot="expandedRowRender" slot-scope="record">
                     <template slot="expandedRowRender" slot-scope="record">
@@ -57,12 +57,12 @@
               </template>
               </template>
             </a-table>
             </a-table>
           </div>
           </div>
-          <div v-if="record.type === '巡检点'" class="spot-content-container">
+          <div v-if="record.tasktype === '巡检点'" class="spot-content-container">
             <a-table
             <a-table
               size="middle"
               size="middle"
               rowKey="id"
               rowKey="id"
               :columns="contentColumns"
               :columns="contentColumns"
-              :dataSource="record.sonList"
+              :dataSource="record.inspectSpotVo.inspectContentList"
               :pagination="false"
               :pagination="false"
               class="spot-content-table">
               class="spot-content-table">
               <template slot="expandedRowRender" slot-scope="record">
               <template slot="expandedRowRender" slot-scope="record">
@@ -84,8 +84,8 @@
         </template>
         </template>
       </a-table>
       </a-table>
 
 
-      <inspect-plan-modal-add-line ref="addLineRef" :selectData="inspectLineList" @ok="handleOk"></inspect-plan-modal-add-line>
-      <inspect-plan-modal-add-spot ref="addSpotRef" :selectData="inspectSpotList" @ok="handleOk"></inspect-plan-modal-add-spot>
+      <inspect-plan-modal-add-line ref="addLineRef" :selectData="inspectLineList" @ok="handleLineOk"></inspect-plan-modal-add-line>
+      <inspect-plan-modal-add-spot ref="addSpotRef" :selectData="inspectSpotList" @ok="handleSpotOk"></inspect-plan-modal-add-spot>
     </div>
     </div>
   </a-spin>
   </a-spin>
 </template>
 </template>
@@ -115,7 +115,6 @@
       return {
       return {
         inspectLineList: [],
         inspectLineList: [],
         inspectSpotList: [],
         inspectSpotList: [],
-        addType: '巡检点',
         // model:{
         // model:{
         // },
         // },
         labelCol: {
         labelCol: {
@@ -135,7 +134,7 @@
           queryById: "/cmmsInspectPlan/cmmsInspectPlan/queryById",
           queryById: "/cmmsInspectPlan/cmmsInspectPlan/queryById",
           queryTreeById: "/cmmsInspectPlan/cmmsInspectPlan/queryTreeById"
           queryTreeById: "/cmmsInspectPlan/cmmsInspectPlan/queryTreeById"
         },
         },
-        tableData: [],
+        tableData: [], // 获取或页面展示的数据和格式
         columns: [
         columns: [
           // {
           // {
           //   title: '序号',
           //   title: '序号',
@@ -150,21 +149,36 @@
           {
           {
             title:'巡检类型',
             title:'巡检类型',
             align:"center",
             align:"center",
-            dataIndex: 'type'
+            dataIndex: 'tasktype'
           },
           },
           {
           {
             title:'名称',
             title:'名称',
             align:"center",
             align:"center",
-            dataIndex: 'title',
-            // dataIndex: 'inspectLineVo',
-            // customRender:function (scope) {
-            //   return scope.linename
-            // }
+            // dataIndex: 'title',
+            dataIndex: 'linename',
+            customRender:function (t,r,index) {
+              // console.log(t,r,index)
+              if(r.tasktype === '巡检路线'){
+                return r.inspectLineVo.linename
+              }
+              if(r.tasktype === '巡检点'){
+                return r.inspectSpotVo.contentname
+              }
+            }
           },
           },
           {
           {
             title:'编号',
             title:'编号',
             align:"center",
             align:"center",
-            dataIndex: ''
+            ddataIndex: 'linecode',
+            customRender:function (t,r,index) {
+              // console.log(t,r,index)
+              if(r.tasktype === '巡检路线'){
+                return r.inspectLineVo.linecode
+              }
+              if(r.tasktype === '巡检点'){
+                return r.inspectSpotVo.contentcode
+              }
+            }
           },
           },
           // {
           // {
           //   title:'是否必须执行',
           //   title:'是否必须执行',
@@ -174,9 +188,35 @@
           {
           {
             title:'备注',
             title:'备注',
             align:"center",
             align:"center",
-            dataIndex: 'remark'
+            dataIndex: 'remark',
+            customRender:function (t,r,index) {
+              // console.log(t,r,index)
+              if(r.tasktype === '巡检路线'){
+                return r.inspectLineVo.remark
+              }
+              if(r.tasktype === '巡检点'){
+                return r.inspectSpotVo.remark
+              }
+            }
           }
           }
         ],
         ],
+        spotColumns: [
+          {
+            title:'巡检点编号',
+            align:"center",
+            dataIndex: 'contentcode'
+          },
+          {
+            title:'巡检点名称',
+            align:"center",
+            dataIndex: 'contentname'
+          },
+          {
+            title:'备注',
+            align:"center",
+            dataIndex: 'remark'
+          },
+        ],
         contentColumns: [
         contentColumns: [
           {
           {
             title:'巡检内容编号',
             title:'巡检内容编号',
@@ -269,10 +309,10 @@
     },
     },
     methods: {
     methods: {
       setRowClassName(record){
       setRowClassName(record){
-        if(record.type === '巡检路线'){
+        if(record.tasktype === '巡检路线'){
           return 'line-bg'
           return 'line-bg'
         }
         }
-        if(record.type === '巡检点'){
+        if(record.tasktype === '巡检点'){
           return 'spot-bg'
           return 'spot-bg'
         }
         }
       },
       },
@@ -284,26 +324,77 @@
         this.confirmLoading = true
         this.confirmLoading = true
         // this.model = Object.assign({}, record);
         // this.model = Object.assign({}, record);
         getAction(this.url.queryById, {id: record.id}).then((res) => {
         getAction(this.url.queryById, {id: record.id}).then((res) => {
-          this.tableData = res.result.sonList
-          console.log(res)
-          this.confirmLoading = false
+          if(res.success){
+            this.tableData = JSON.parse(JSON.stringify(res.result.taskList))
+          } else {
+            this.$message.warning(res.message);
+          }
+        }).finally(() => {
+          this.confirmLoading = false;
         })
         })
       },
       },
       // 维护巡检路线
       // 维护巡检路线
       handleAddLine(){
       handleAddLine(){
+        this.inspectLineList = this.tableData.filter(item => item.tasktype === '巡检路线').map(i => i.inspectLineVo)
+        this.$refs.addLineRef.add();
+        this.$refs.addLineRef.title = "选择巡检路线";
+      },
+      handleLineOk(data){
+        // console.log(data) // 新获取的巡检路线数据
+        // console.log(this.inspectLineList) // 原来巡检路线数据
+        // 添加--获取最新巡检路线数据中原来巡检点没有的数据
+        var addData = data.filter(item => !this.inspectLineList.some(i=>i.id === item.id))
+        console.log(addLines)
+        var addLines = addData.map(item=>{
+          return {
+            inspectLineVo: item,
+            tasktype: '巡检路线'
+          }
+        })
+        this.tableData.push(...addLines)
+        // 删除--原来的数据最新的数据中没有了
+        var delLines = this.inspectLineList.filter(item => !data.some(i=>i.id === item.id))
+        console.log('delLines', delLines)
+        
+        delLines.forEach(item => {
+          var i = this.tableData.findIndex(t => t.tasktype === '巡检路线' && t.inspectLineVo.id === item.id)
+          this.tableData.splice(i, 1)
+        });
+
+        console.log(this.tableData)
       },
       },
       // 维护巡检点
       // 维护巡检点
       handleAddSpot(){
       handleAddSpot(){
-        this.addType = '巡检点'
+        this.inspectSpotList = this.tableData.filter(item => item.tasktype === '巡检点').map(i => i.inspectSpotVo)
         this.$refs.addSpotRef.add();
         this.$refs.addSpotRef.add();
         this.$refs.addSpotRef.title = "选择巡检点";
         this.$refs.addSpotRef.title = "选择巡检点";
+        console.log(this.inspectSpotList)
+      },
+      handleSpotOk(data){
+        // console.log(data) // 新获取的巡检点数据
+        // console.log(this.inspectSpotList) // 原来巡检点数据
+        // 添加--获取最新巡检点数据中原来巡检点没有的数据
+        var addData = data.filter(item => !this.inspectSpotList.some(i=>i.id === item.id))
+        console.log(addSpots)
+        var addSpots = addData.map(item=>{
+          return {
+            inspectSpotVo: item,
+            tasktype: '巡检点'
+          }
+        })
+        this.tableData.push(...addSpots)
+        // 删除--原来的数据最新的数据中没有了
+        var delSpots = this.inspectSpotList.filter(item => !data.some(i=>i.id === item.id))
+        console.log('delSpots', delSpots)
+        
+        delSpots.forEach(item => {
+          var i = this.tableData.findIndex(t => t.tasktype === '巡检点' && t.inspectSpotVo.id === item.id)
+          this.tableData.splice(i, 1)
+        });
+
+        // this.tableData.filter(item => item.tasktype === '巡检路线' || (item.tasktype === '巡检点' && !delSpots.some(i=>i.id === item.inspectSpotVo.id)))
+        console.log(this.tableData)
       },
       },
-      handleOk(data){
-        console.log(data)
-        if(this.addType === '巡检点'){
-          this.inspectSpotList = data
-        }
-      }
     }
     }
   }
   }
 </script>
 </script>

+ 32 - 8
src/views/module_cmms/inspectPlan/modules/InspectPlanFormSet.vue

@@ -15,7 +15,8 @@
           </a-col>
           </a-col>
           <a-col :span="12">
           <a-col :span="12">
             <a-form-model-item label="负责人" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="chargeruser">
             <a-form-model-item label="负责人" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="chargeruser">
-              <a-input v-model="model.chargeruser" placeholder="请输入待办人"  ></a-input>
+              <!-- <a-input v-model="model.chargeruser" placeholder="请输入待办人"  ></a-input> -->
+              <j-dict-select-tag v-model="model.chargeruser" placeholder="请选择负责人" dictCode="sys_user,realname,id"/>
             </a-form-model-item>
             </a-form-model-item>
           </a-col>
           </a-col>
           <a-col :span="12">
           <a-col :span="12">
@@ -28,14 +29,14 @@
               <j-dict-select-tag v-model="model.status"  type="radio" dictCode="common_status"/>
               <j-dict-select-tag v-model="model.status"  type="radio" dictCode="common_status"/>
             </a-form-model-item>
             </a-form-model-item>
           </a-col>
           </a-col>
-          <a-col :span="12">
+          <a-col :span="12" v-if="model.iftimeset === 'Y'">
             <a-form-model-item label="开始时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="begintime">
             <a-form-model-item label="开始时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="begintime">
-              <j-date placeholder="请选择开始时间" v-model="model.begintime"  style="width: 100%" />
+              <j-date placeholder="请选择开始时间" v-model="model.begintime"  style="width: 100%" :show-time="true" date-format="YYYY-MM-DD HH:mm:ss" />
             </a-form-model-item>
             </a-form-model-item>
           </a-col>
           </a-col>
-          <a-col :span="12">
-            <a-form-model-item label="重复" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="repeatnum">
-              <a-input-number v-model="model.repeatnum" placeholder="请输入重复" style="width: 40%;"/>
+          <a-col :span="12" v-if="model.iftimeset === 'Y'">
+            <a-form-model-item label="重复周期" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="repeatnum">
+              <a-input-number v-model="model.repeatnum" placeholder="请输入重复周期" style="width: 40%;"/>
               <j-dict-select-tag  v-model="model.repeattype"  placeholder="请选择重复单位" dictCode="plan_cycle_unit" style="width: 30%;"/>
               <j-dict-select-tag  v-model="model.repeattype"  placeholder="请选择重复单位" dictCode="plan_cycle_unit" style="width: 30%;"/>
             </a-form-model-item>
             </a-form-model-item>
           </a-col>
           </a-col>
@@ -44,7 +45,7 @@
               
               
             </a-form-model-item>
             </a-form-model-item>
           </a-col> -->
           </a-col> -->
-          <a-col :span="12">
+          <a-col :span="12" v-if="model.iftimeset === 'Y'">
             <a-form-model-item label="提前通知时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="noticenum">
             <a-form-model-item label="提前通知时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="noticenum">
               <a-input-number v-model="model.noticenum" placeholder="请输入提前通知时间" style="width: 40%" />
               <a-input-number v-model="model.noticenum" placeholder="请输入提前通知时间" style="width: 40%" />
               <j-dict-select-tag v-model="model.noticetype" placeholder="请选择提前通知单位" dictCode="plan_notice_unit" style="width: 30%;"/>
               <j-dict-select-tag v-model="model.noticetype" placeholder="请选择提前通知单位" dictCode="plan_notice_unit" style="width: 30%;"/>
@@ -85,6 +86,8 @@
     data () {
     data () {
       return {
       return {
         model:{
         model:{
+          iftimeset: 'Y',
+          status: '0',
           noticetype: '天',
           noticetype: '天',
           repeattype: '日',
           repeattype: '日',
         },
         },
@@ -98,6 +101,21 @@
         },
         },
         confirmLoading: false,
         confirmLoading: false,
         validatorRules: {
         validatorRules: {
+          planname: [
+            { required: true, message: '请输入巡检计划名称!'},
+          ],
+          chargeruser: [
+            { required: true, message: '请选择负责人!'},
+          ],
+          begintime: [
+            { required: true, message: '请选择开始时间!'},
+          ],
+          repeatnum: [
+            { required: true, message: '请输入重复周期!'},
+          ],
+          noticenum: [
+            { required: true, message: '请输入提前通知时间!'},
+          ],
         },
         },
         url: {
         url: {
           add: "/cmmsInspectPlan/cmmsInspectPlan/add",
           add: "/cmmsInspectPlan/cmmsInspectPlan/add",
@@ -123,8 +141,14 @@
         this.model = Object.assign({}, record);
         this.model = Object.assign({}, record);
         this.visible = true;
         this.visible = true;
       },
       },
-      submitForm () {
+      submitForm (list) {
+        console.log(list)
         const that = this;
         const that = this;
+        if(list.length === 0){
+          that.$message.warning('计划列表未填写');
+          return
+        }
+        this.model.taskList = list
         // 触发表单验证
         // 触发表单验证
         this.$refs.form.validate(valid => {
         this.$refs.form.validate(valid => {
           if (valid) {
           if (valid) {

+ 1 - 1
src/views/module_cmms/inspectPlan/modules/InspectPlanModal.vue

@@ -61,7 +61,7 @@
         this.visible = false;
         this.visible = false;
       },
       },
       handleOk () {
       handleOk () {
-        this.$refs.realForm.submitForm();
+        this.$refs.realForm.submitForm(this.$refs.realList.tableData);
       },
       },
       submitCallback(){
       submitCallback(){
         this.$emit('ok');
         this.$emit('ok');

+ 14 - 6
src/views/module_cmms/inspectPlan/modules/InspectPlanModalAddLine.vue

@@ -64,14 +64,14 @@
           //   }
           //   }
           // },
           // },
           {
           {
-            title:'巡检编号',
+            title:'巡检路线编号',
             align:"center",
             align:"center",
-            dataIndex: 'contentcode'
+            dataIndex: 'linecode'
           },
           },
           {
           {
-            title:'巡检名称',
+            title:'巡检路线名称',
             align:"center",
             align:"center",
-            dataIndex: 'contentname'
+            dataIndex: 'linename'
           },
           },
           {
           {
             title:'备注',
             title:'备注',
@@ -82,7 +82,15 @@
         dataSource: [],
         dataSource: [],
         url: {
         url: {
           getList: "/cmmsInspectItem/cmmsInspectItem/getItemByEqId",
           getList: "/cmmsInspectItem/cmmsInspectItem/getItemByEqId",
-          spotList: "/cmmsInspectSpot/cmmsInspectSpot/listDetails",
+          lineList: "/cmmsInspectLine/cmmsInspectLine/listDetails",
+        },
+      }
+    },
+    watch: {
+      selectData: {
+        handler(newV, oldV){
+          console.log(newV, oldV)
+          this.selectList()
         },
         },
       }
       }
     },
     },
@@ -90,7 +98,7 @@
       add () {
       add () {
         this.visible = true;
         this.visible = true;
         //  {status: '0'}
         //  {status: '0'}
-        getAction(this.url.spotList).then((res) => {
+        getAction(this.url.lineList).then((res) => {
           this.dataSource = res.result.records
           this.dataSource = res.result.records
         })
         })
         this.selectList()
         this.selectList()

+ 8 - 0
src/views/module_cmms/inspectPlan/modules/InspectPlanModalAddSpot.vue

@@ -86,6 +86,14 @@
         },
         },
       }
       }
     },
     },
+    watch: {
+      selectData: {
+        handler(newV, oldV){
+          console.log(newV, oldV)
+          this.selectList()
+        },
+      }
+    },
     methods: {
     methods: {
       add () {
       add () {
         this.visible = true;
         this.visible = true;