瀏覽代碼

运维-计划

huang_an 2 年之前
父節點
當前提交
e625edb0e3

+ 7 - 7
src/api/classifyManage/index.js

@@ -1,6 +1,6 @@
 import request from '@/utils/request';
 
-export async function getSubPage (data) {
+export async function getSubPage(data) {
   const res = await request.get('/main/categoryLevel/getSubPage', {
     params: data
   });
@@ -9,7 +9,7 @@ export async function getSubPage (data) {
   }
   return Promise.reject(new Error(res.data.message));
 }
-export async function saveOrUpdate (data) {
+export async function saveOrUpdate(data) {
   const res = await request.post('/main/categoryLevel/saveOrUpdate', data);
   if (res.data.code == 0) {
     return res.data;
@@ -18,7 +18,7 @@ export async function saveOrUpdate (data) {
 }
 
 // 根据父级id查分类树
-export async function getTreeByPid (parentId) {
+export async function getTreeByPid(parentId) {
   const res = await request.get(`/main/categoryLevel/getTreeByPid/${parentId}`);
   if (res.data.code == 0) {
     return res.data;
@@ -26,8 +26,8 @@ export async function getTreeByPid (parentId) {
   return Promise.reject(new Error(res.data.message));
 }
 // 根据类型查分类树
-export async function getTreeByType (type) {
-  const res = await request.get(`/main/categoryLevel/getTreeByType/${type}`);
+export async function getTreeByType(type) {
+  const res = await request.get(`/main/categoryLevel/getTreeByPid/${type}`);
   if (res.data.code == 0) {
     return res.data;
   }
@@ -35,7 +35,7 @@ export async function getTreeByType (type) {
 }
 
 // 删除分类
-export async function deleteCategory (id) {
+export async function deleteCategory(id) {
   const res = await request.get(`/main/categoryLevel/delete/${id}`);
   if (res.data.code == 0) {
     return res.data;
@@ -43,7 +43,7 @@ export async function deleteCategory (id) {
   return Promise.reject(new Error(res.data.message));
 }
 //根据ID查询分类详情系信息
-export async function getInfoById (id) {
+export async function getInfoById(id) {
   const res = await request.get(`/main/categoryLevel/getById/${id}`);
   if (res.data.code == 0) {
     return res.data;

+ 9 - 9
src/api/maintenance/patrol_maintenance.js

@@ -1,7 +1,7 @@
 import request from '@/utils/request';
 
 // 计划分页
-export async function getPage (data) {
+export async function getPage(data) {
   const res = await request.get('/eam/planmaintenance/page', { params: data });
   if (res.data.code == 0) {
     return res.data.data;
@@ -9,7 +9,7 @@ export async function getPage (data) {
   return Promise.reject(new Error(res.data.message));
 }
 // 更新或保存
-export async function saveOrUpdate (data) {
+export async function saveOrUpdate(data) {
   const res = await request.post('/eam/planmaintenance/saveOrUpdate', data);
   if (res.data.code == 0) {
     return res.data;
@@ -17,7 +17,7 @@ export async function saveOrUpdate (data) {
   return Promise.reject(new Error(res.data.message));
 }
 // 详情
-export async function getById (id) {
+export async function getById(id) {
   const res = await request.get(`/eam/planmaintenance/getById/${id}`);
   if (res.data.code == 0) {
     return res.data;
@@ -25,7 +25,7 @@ export async function getById (id) {
   return Promise.reject(new Error(res.data.message));
 }
 // 撤回
-export async function revocation (id) {
+export async function revocation(id) {
   const res = await request.get(`/eam/planmaintenance/revocation/${id}`);
   if (res.data.code == 0) {
     return res.data;
@@ -33,7 +33,7 @@ export async function revocation (id) {
   return Promise.reject(new Error(res.data.message));
 }
 // 查询未派单设备数据
-export async function getNotSendOrderList (planId) {
+export async function getNotSendOrderList(planId) {
   const res = await request.get(
     `/eam/planmaintenance/getNotSendOrderList/${planId}`
   );
@@ -43,7 +43,7 @@ export async function getNotSendOrderList (planId) {
   return Promise.reject(new Error(res.data.message));
 }
 // 派单
-export async function sendOrder (data) {
+export async function sendOrder(data) {
   const res = await request.get(`/eam/planmaintenance/sendOrder`, {
     params: data
   });
@@ -54,7 +54,7 @@ export async function sendOrder (data) {
 }
 
 // 工单分页
-export async function getWorkOrderPage (data) {
+export async function getWorkOrderPage(data) {
   const res = await request.get('/eam/workordermaintenance/page', {
     params: data
   });
@@ -65,7 +65,7 @@ export async function getWorkOrderPage (data) {
 }
 
 // 详情
-export async function getWordOrderDetail (workOrderId) {
+export async function getWordOrderDetail(workOrderId) {
   const res = await request.get(
     `/eam/workordermaintenance/maintenanceDetail/${workOrderId}`
   );
@@ -75,7 +75,7 @@ export async function getWordOrderDetail (workOrderId) {
   return Promise.reject(new Error(res.data.message));
 }
 // 工单转派
-export async function workOrderRotate (data) {
+export async function workOrderRotate(data) {
   const res = await request.get('/eam/workordermaintenance/rotate', {
     params: data
   });

+ 15 - 23
src/api/ruleManagement/plan.js

@@ -1,8 +1,8 @@
 import request from '@/utils/request';
 
 // 获取规则名称下拉
-export async function getRule (data) {
-	let par = new URLSearchParams(data);
+export async function getRule(data) {
+  let par = new URLSearchParams(data);
   const res = await request.get(`/main/ruleinfo/page?` + par, {});
   if (res.data.code == 0) {
     return res.data.data;
@@ -11,17 +11,16 @@ export async function getRule (data) {
 }
 
 // 获取类别信息列表
-export async function getCategory (data) {
-  const res = await request.post(`/main/category/getList` , data);
+export async function getCategory(data) {
+  const res = await request.post(`/main/category/getList`, data);
   if (res.data.code == 0) {
     return res.data.data;
   }
   return Promise.reject(new Error(res.data.message));
 }
 
-
 // 获取实体列表分页
-export async function getAssetList (data) {
+export async function getAssetList(data) {
   let par = new URLSearchParams(data);
   const res = await request.get(`/main/asset/page?` + par, {});
   if (res.data.code == 0) {
@@ -30,9 +29,9 @@ export async function getAssetList (data) {
   return Promise.reject(new Error(res.data.message));
 }
 
-// 巡点检计划配置新增或更新 
-export async function saveOrUpdate (data) {
-  const res = await request.post('/eam/planconfig/saveOrUpdate' , data );
+// 巡点检计划配置新增或更新
+export async function saveOrUpdate(data) {
+  const res = await request.post('/eam/planconfig/saveOrUpdate', data);
   if (res.data.code == 0) {
     return res.data.data;
   }
@@ -40,18 +39,18 @@ export async function saveOrUpdate (data) {
 }
 
 // 获取巡点检分页数据
-export async function planConfigPage (data) {
-	let par = new URLSearchParams(data);
-  const res = await request.get(`/eam/planconfig/page?`+ par , {} );
+export async function planConfigPage(data) {
+  let par = new URLSearchParams(data);
+  const res = await request.get(`/eam/planconfig/page?` + par, {});
   if (res.data.code == 0) {
     return res.data.data;
   }
   return Promise.reject(new Error(res.data.message));
 }
 
-// 获取详情  
-export async function getInfoById (id) {
-  const res = await request.get(`/eam/planconfig/getById/`+ id , {} );
+// 获取详情
+export async function getInfoById(id) {
+  const res = await request.get(`/eam/planconfig/getById/` + id, {});
   if (res.data.code == 0) {
     return res.data.data;
   }
@@ -62,14 +61,13 @@ export async function getInfoById (id) {
  * 删除事项
  */
 export async function removeRule(data) {
-  const res = await request.delete('/eam/planconfig/delete', { data } );
+  const res = await request.delete('/eam/planconfig/delete', { data });
   if (res.data.code == 0) {
     return res.data.data;
   }
   return Promise.reject(new Error(res.data.message));
 }
 
-
 // // 更新或保存
 // export async function saveOrUpdate (data) {
 //   const res = await request.post('/main/ruleinfo/saveOrEdit', data);
@@ -106,9 +104,3 @@ export async function removeRule(data) {
 //   }
 //   return Promise.reject(new Error(res.data.message));
 // }
-
-
-
-
-
-

+ 2 - 3
src/components/CommomSelect/equipment-select.vue

@@ -11,7 +11,6 @@
     :placeholder="placeholder"
     @input="updateValue"
     v-on="$listeners"
-    v-bind="$attrs"
     @change="chooseNode"
   />
 </template>
@@ -38,9 +37,9 @@
     },
     methods: {
       async getData() {
-        const res = await getTreeByType(1);
+        const res = await getTreeByType(0);
         this.treeData = res.data;
-        this.$emit('setRootId', res.data[0].id);
+        this.$emit('setRootId', res.data[0].id, res.data);
         // this.treeData = this.$util.toTreeData({
         //   data: data || [],
         //   idField: 'id',

+ 106 - 39
src/components/addPatrolPlanDialog/index.vue

@@ -74,7 +74,7 @@
               />
             </el-form-item>
           </el-col>
-          <el-col :span="8">
+          <!-- <el-col :span="8">
             <el-form-item label="设备类别" prop="categoryId">
               <el-select
                 v-model="addForm.categoryId"
@@ -90,7 +90,7 @@
                 ></el-option>
               </el-select>
             </el-form-item>
-          </el-col>
+          </el-col> -->
           <el-col :span="8">
             <el-form-item label="审核人" prop="verifyUserId">
               <personSelect v-model="addForm.verifyUserId" />
@@ -305,6 +305,7 @@
   import { saveOrUpdate } from '@/api/maintenance/patrol_maintenance';
   import { deepClone } from '@/utils';
   import { getById } from '@/api/maintenance/patrol_maintenance';
+  import { getList } from '@/api/classifyManage/itemInformation';
   export default {
     name: 'addPatrolPlanDialog',
     components: {
@@ -316,7 +317,7 @@
       AddSpareDialog
     },
     props: {},
-    data () {
+    data() {
       return {
         defaultProps: {
           label: 'showName'
@@ -398,13 +399,14 @@
         currentNode: null,
         rootId: null,
         dialogTitle: '新增保养计划配置',
-        editLoading: false
+        editLoading: false,
+        rootData: []
       };
     },
     computed: {},
-    async created () {},
+    async created() {},
     methods: {
-      open (title, row) {
+      open(title, row) {
         this.dialogTitle = title;
         this.formLabel = this.dialogTitle.includes('巡点检')
           ? '巡点检'
@@ -431,14 +433,16 @@
         this.addPatrolPlanDialog = true;
       },
       // 编辑详情
-      async getInfo (id) {
+      async getInfo(id) {
         this.editLoading = true;
-        const res = await getById(id).catch(() => {
+        const res = await getById(id).finally(() => {
           this.editLoading = false;
         });
         if (res?.data) {
-          const data = res.data;
-
+          let data = res.data;
+          if (data.executor && data.executor.length) {
+            data.groupId = data.executor[0].groupName;
+          }
           this.addForm = data;
 
           this.categoryEquipment(this.addForm.categoryLevelId);
@@ -454,7 +458,7 @@
         }
       },
       // 获取计划配置单号
-      async getOrderCode (tips) {
+      async getOrderCode(tips) {
         if (tips.includes('巡点检')) {
           const data = await getCode('partrol_code');
           this.$set(this.addForm, 'code', data);
@@ -465,19 +469,22 @@
         }
       },
       // 获取规则名列表
-      async _getRuleNameList () {
+      async _getRuleNameList() {
         if (this.dialogTitle == '新增巡点检计划') {
           console.log('巡点检计划');
           const res = await getRule({ type: 1, pageNum: 1, size: -1 });
           this.ruleNameList = res.list || [];
         }
-        if (this.dialogTitle == '新增保养计划') {
+        if (
+          this.dialogTitle == '新增保养计划' ||
+          this.dialogTitle == '编辑保养计划'
+        ) {
           console.log('保养计划');
           const res = await getRule({ type: 2, pageNum: 1, size: -1 });
           this.ruleNameList = res.list || [];
         }
       },
-      handleClose () {
+      handleClose() {
         this.addPatrolPlanDialog = false;
         this.$refs.addFormRef.resetFields();
         if (this.$refs.searchTree) {
@@ -504,36 +511,83 @@
           planType: 'PATROL' // 计划规则类型 巡点检: 'PATROL', 保养: 'MAINTAIN', 盘点: 'INVENTORY'
         };
       },
-      getRootId (val) {
-        this.rootId = val;
+      getRootId(val, data) {
+        // this.rootId = val;
+        this.rootData = data;
       },
       // 设备分类选择
-      async handleEquipmentClassChange (item) {
+      async handleEquipmentClassChange(item) {
         this.clickedTreeNode = true;
         this.equipmentInfo = {};
         this._getEquipmentList(item.id);
       },
 
       // 获取设备分类数据
-      async categoryEquipment (id) {
-        const params = { categoryLevelId: id, pageNum: 1, size: -1 };
-        const data = await getCategory(params);
+      async categoryEquipment(id) {
+        const params = {
+          searchKey: '',
+          categoryLevelId: id,
+          pageNum: 1,
+          size: 99
+        };
+        const data = await getList(params);
         this.equipmentList = data.list;
       },
       // 分类树的选择
-      chooseClassify (val) {
-        this.categoryEquipment(val);
+      chooseClassify(val) {
+        this.clickedTreeNode = true;
+        const id = this.findTopLevelAncestorId(this.rootData, val);
+        this.rootId = id;
+        this._getEquipmentList(val, this.isBindPlan);
+        // this.categoryEquipment(val);
+      },
+      findTopLevelAncestorId(dataArray, targetId) {
+        for (const item of dataArray) {
+          const result = this.findTopLevelAncestorIdRecursive(
+            item,
+            targetId,
+            item.id
+          );
+          if (result) {
+            return result; // 返回找到的最顶层祖先的 ID
+          }
+        }
+
+        return null;
+      },
+
+      findTopLevelAncestorIdRecursive(dataItem, targetId, topLevelAncestorId) {
+        if (dataItem.id === targetId) {
+          return topLevelAncestorId;
+        }
+
+        if (dataItem.children) {
+          for (const child of dataItem.children) {
+            const result = this.findTopLevelAncestorIdRecursive(
+              child,
+              targetId,
+              topLevelAncestorId
+            );
+            if (result) {
+              return result; // 返回找到的最顶层祖先的 ID
+            }
+          }
+        }
+
+        return null;
       },
       // 封装 - 获取设备分类列表
-      async _getEquipmentList (val) {
+      async _getEquipmentList(val) {
         const params = {
           pageNum: 1,
-          size: -1,
-          categoryId: val || this.addForm.categoryId,
-          rootCategoryLevelId: this.rootId
+          size: 999,
+          categoryLevelId: val || this.addForm.categoryId,
+          rootCategoryLevelId: this.rootId ? this.rootId : ''
         };
         try {
+          console.log('1', params);
           const res = await getAssetList(params);
+          this.addForm.categoryId = res.list[0]?.categoryId;
           this.planDeviceList = res.list;
           this.planDeviceList.map((item) => {
             item.showName = item.name + '(' + item.code + ')';
@@ -588,7 +642,7 @@
         }
       },
       //选择部门(搜索)
-      searchDeptNodeClick (info) {
+      searchDeptNodeClick(info) {
         // 根据部门获取人员
         const params = { groupId: info };
         this.$nextTick(() => {
@@ -596,7 +650,7 @@
         });
       },
       // 封装 - 获取设备位置名称和code方法
-      getEquiLocation (data) {
+      getEquiLocation(data) {
         // 设备位置编码
         const equiLocationCode = data.position[0].pathIds;
         // 设备位置名称
@@ -604,7 +658,7 @@
         return { equiLocation, equiLocationCode };
       },
       // 设备列表树点击
-      handleNodeClick (data, node) {
+      handleNodeClick(data, node) {
         const { equiLocation, equiLocationCode } = this.getEquiLocation(data);
         this.equipmentInfo = {
           equiCode: data.code,
@@ -625,13 +679,13 @@
           equiLocationCode;
       },
       // 规则名称下拉触发
-      handleRuleNameChange (val) {
+      handleRuleNameChange(val) {
         // this._getMatterRulesDetails(val);
         this.$refs.ruleItemSelectionRef._getMatterRulesDetails(val);
       },
 
       // 从事项弹窗将数据丢到事项配置
-      ruleItemSelectionSubmit (list) {
+      ruleItemSelectionSubmit(list) {
         if (list) {
           if (!this.planDeviceList[this.currentEquItemIndex]['workItems']) {
             this.planDeviceList[this.currentEquItemIndex]['workItems'] = [];
@@ -651,7 +705,8 @@
       },
 
       // 添加操作事项
-      addOperationItems () {
+      addOperationItems() {
+        console.log(this.clickedTreeNode);
         if (!this.clickedTreeNode) {
           return this.$message.warning('请选择设备分类!');
         }
@@ -668,7 +723,7 @@
       },
 
       // 删除操作事项
-      handleDeleteOperationItem (index) {
+      handleDeleteOperationItem(index) {
         if (this.planDeviceList[this.currentEquItemIndex]['workItems']) {
           this.planDeviceList[this.currentEquItemIndex]['workItems'].splice(
             index,
@@ -678,7 +733,7 @@
       },
 
       // 添加备品备件
-      addSpareItems () {
+      addSpareItems() {
         if (!this.clickedTreeNode) {
           return this.$message.warning('请选择设备分类!');
         }
@@ -698,7 +753,7 @@
       },
 
       // 从备品备件弹窗将数据丢到备品备件配置
-      spareItemSelectSubmit (list) {
+      spareItemSelectSubmit(list) {
         // console.log('备品备件:', list)
         // this.planDeviceList[this.currentEquItemIndex]['sparePart'] =
         //   list.map(item => {
@@ -719,7 +774,7 @@
       },
 
       // 删除备品备件
-      handleDeleteSpareItem (index) {
+      handleDeleteSpareItem(index) {
         this.planDeviceList[this.currentEquItemIndex]['sparePart'].splice(
           index,
           1
@@ -728,7 +783,7 @@
       },
 
       // 改变input数据重新计算总费用
-      changeNum () {
+      changeNum() {
         let applayList =
           this.planDeviceList[this.currentEquItemIndex].sparePart;
         let total = 0;
@@ -764,8 +819,19 @@
         );
       },
       // 提交
-      submit () {
+      submit() {
         console.log(this.planDeviceList);
+        this.planDeviceList.forEach((item) => {
+          // 判断是否存在 workItems 属性,如果不存在则添加一个空数组
+          if (!item.workItems) {
+            item.workItems = [];
+          }
+
+          // 判断 workItems 是否为空数组,如果为空则添加有数据的 workItems
+          if (item.workItems.length === 0) {
+            item.workItems.push(/* 添加有数据的 workItems,可以根据需求添加具体的数据 */);
+          }
+        });
         this.$refs.addFormRef.validate(async (valid) => {
           if (valid) {
             try {
@@ -779,7 +845,9 @@
                 const obj = this.planDeviceList.find(
                   (itm) => itm.id === item.id
                 );
+                console.log('obj.workItems:', obj);
                 if (!obj.workItems?.length) {
+                  console.log(111);
                   workItemsChecked = false;
                 }
 
@@ -796,7 +864,6 @@
                   sparePart: obj.sparePart ? obj.sparePart : []
                 };
               });
-
               if (!workItemsChecked || !selectList.length) {
                 this.$message.warning('请添加操作事项!');
                 return;

+ 140 - 139
src/components/addSpareDialog/index.vue

@@ -18,13 +18,14 @@
     <el-row style="height: 80vh">
       <el-col class="tree-col" :span="6">
         <div class="table-add" style="margin-left: 10px"></div>
-           <AssetTree
-               @handleNodeClick="handleNodeClick"
-               @setRootId="setRootId"
-               :type="'7'"
-               :paramsType="'type'"
-               ref="treeList"
-             />
+        <AssetTree
+          @handleNodeClick="handleNodeClick"
+          @setRootId="setRootId"
+          :type="'7'"
+          :paramsType="'type'"
+          ref="treeList"
+          id="6"
+        />
       </el-col>
       <el-col :span="18">
         <el-table
@@ -47,8 +48,7 @@
           />
           <el-table-column prop="code" label="备件类别编码" />
           <el-table-column prop="name" label="备件类别名称" />
-		  <el-table-column label="型号" prop="modelType">
-		  </el-table-column>
+          <el-table-column label="型号" prop="modelType"> </el-table-column>
         </el-table>
       </el-col>
     </el-row>
@@ -61,150 +61,151 @@
 </template>
 
 <script>
-import AssetTree from '@/components/AssetTree'
-import {  getCategoryList } from '@/api/ledgerAssets';
-export default {
-  components: { 
-		// CommonTree,
-   	AssetTree 
-	},
-  props: {
-    selectedSpare: {
-      type: Array,
-      default: () => []
-    }
-  },
-  data () {
-    return {
-      dialogVisible: false,
-      searchParams: {
-        code: '',
-        page: 1,
-        size: 99999
-      },
-      tableLoading: false,
-      tableData: [],
-      currentTreeData: {},
-      pickSpareDataObject: [],
-	  rootId:null
-    }
-  },
-  watch: {
-    selectedSpare (val) {
-      val.map(item => {
-        this.tableData.forEach(c => {
-          if (item.id === c.id) {
-            this.$refs.dialogMultipleTable.toggleRowSelection(c, true)
-          }
-        })
-      })
-    }
-  },
-  methods: {
-    open () {
-      this.pickSpareDataObject = []
-      this.dialogVisible = true
-      this.$nextTick(() => {
-        this.selectedSpare.map(item => {
-          this.tableData.forEach(c => {
-            if (item.id === c.id) {
-              this.$refs.dialogMultipleTable.toggleRowSelection(c, true)
-            }
-          })
-        })
-      })
+  import AssetTree from '@/components/AssetTree';
+  import { getCategoryList } from '@/api/ledgerAssets';
+  import { getList } from '@/api/classifyManage/itemInformation';
+  export default {
+    components: {
+      // CommonTree,
+      AssetTree
     },
-	
-	
-    async doSearch () {
-      const params = {
-        categoryLevelId: this.currentTreeData.id,
-        rootCategoryLevelId: this.rootId,
-        code: this.searchParams.code
+    props: {
+      selectedSpare: {
+        type: Array,
+        default: () => []
       }
-      this._getClassificationSpareList(params)
     },
-	
-	// 获取根节点id
-	setRootId(id){
-	  this.rootId = id
-	},
-	
-    // 树结构点击事件
-    async handleNodeClick (data, node) {
-      this.currentTreeData = data
-      this._getClassificationSpareList(data)
+    data() {
+      return {
+        dialogVisible: false,
+        searchParams: {
+          code: '',
+          page: 1,
+          size: 99999
+        },
+        tableLoading: false,
+        tableData: [],
+        currentTreeData: {},
+        pickSpareDataObject: [],
+        rootId: null
+      };
     },
-
-    // setDefaultList(id){
-    //   let data = {id:id}
-    //    this._getClassificationSpareList(data)
-    // },
-
-    // 获取添加备件弹窗表格数据
-    async _getClassificationSpareList (data) {
-      this.tableLoading = true
-      let params = {
-        page: 1,
-        size: 99999,
-        categoryLevelId: this.currentTreeData.id
+    watch: {
+      selectedSpare(val) {
+        val.map((item) => {
+          this.tableData.forEach((c) => {
+            if (item.id === c.id) {
+              this.$refs.dialogMultipleTable.toggleRowSelection(c, true);
+            }
+          });
+        });
       }
-      const res = await getCategoryList(params)
-	  console.log('res',res)
-      this.tableLoading = false
-      if (res.list.length) {
-        this.tableData = res.list
-        // 切换树节点时回显添加了的备品备件
+    },
+    methods: {
+      open() {
+        this.pickSpareDataObject = [];
+        this.dialogVisible = true;
         this.$nextTick(() => {
-          this.selectedSpare.map(item => {
-            this.tableData.forEach(c => {
+          this.selectedSpare.map((item) => {
+            this.tableData.forEach((c) => {
               if (item.id === c.id) {
-                this.$refs.dialogMultipleTable.toggleRowSelection(c, true)
+                this.$refs.dialogMultipleTable.toggleRowSelection(c, true);
               }
-            })
-          })
-        })
-      } else {
-        this.tableData = []
-      }
-    },
-    // 备件单选框选择时事件
-    pickSpareData (data) {
-      this.pickSpareDataObject = data
-    },
+            });
+          });
+        });
+      },
 
-    // 关闭弹窗
-    handleClose () {
-      this.$nextTick(() => {
-        this.$refs.dialogMultipleTable.clearSelection()
-        this.dialogVisible = false
-      })
-    },
+      async doSearch() {
+        const params = {
+          categoryLevelId: this.currentTreeData.id,
+          rootCategoryLevelId: this.rootId,
+          code: this.searchParams.code
+        };
+        this._getClassificationSpareList(params);
+      },
+
+      // 获取根节点id
+      setRootId(id) {
+        this.rootId = id;
+      },
+
+      // 树结构点击事件
+      async handleNodeClick(data, node) {
+        this.currentTreeData = data;
+        this._getClassificationSpareList(data);
+      },
+
+      // setDefaultList(id){
+      //   let data = {id:id}
+      //    this._getClassificationSpareList(data)
+      // },
+
+      // 获取添加备件弹窗表格数据
+      async _getClassificationSpareList(data) {
+        this.tableLoading = true;
+        let params = {
+          searchKey: '',
+          pageNum: 1,
+          size: 10,
+          categoryLevelId: this.currentTreeData.id
+        };
+        const res = await getList(params);
+        console.log('res', res);
+        this.tableLoading = false;
+        if (res.list.length) {
+          this.tableData = res.list;
+          // 切换树节点时回显添加了的备品备件
+          this.$nextTick(() => {
+            this.selectedSpare.map((item) => {
+              this.tableData.forEach((c) => {
+                if (item.id === c.id) {
+                  this.$refs.dialogMultipleTable.toggleRowSelection(c, true);
+                }
+              });
+            });
+          });
+        } else {
+          this.tableData = [];
+        }
+      },
+      // 备件单选框选择时事件
+      pickSpareData(data) {
+        this.pickSpareDataObject = data;
+      },
+
+      // 关闭弹窗
+      handleClose() {
+        this.$nextTick(() => {
+          this.$refs.dialogMultipleTable.clearSelection();
+          this.dialogVisible = false;
+        });
+      },
 
-    async submit () {
-      this.$emit('submit', this.pickSpareDataObject)
-      this.handleClose()
-      //   this.form.exportList = this.pickSpareDataObject
-      //   this.$forceUpdate()
+      async submit() {
+        this.$emit('submit', this.pickSpareDataObject);
+        this.handleClose();
+        //   this.form.exportList = this.pickSpareDataObject
+        //   this.$forceUpdate()
+      }
     }
-  }
-}
+  };
 </script>
 
 <style lang="scss" scoped>
-.tree-col {
-  border: 1px solid #e6ebf5;
-  margin-right: 10px;
-  width: 20%;
-  padding: 0 !important;
-  height: 100%;
-  overflow: auto;
-}
-.search_wrapper {
-  margin-bottom: 10px;
-  .search_input {
-    width: 200px;
+  .tree-col {
+    border: 1px solid #e6ebf5;
     margin-right: 10px;
+    width: 20%;
+    padding: 0 !important;
+    height: 100%;
+    overflow: auto;
+  }
+  .search_wrapper {
+    margin-bottom: 10px;
+    .search_input {
+      width: 200px;
+      margin-right: 10px;
+    }
   }
-}
 </style>

+ 14 - 7
src/views/maintenance/equipment/plan/components/plan-search.vue

@@ -50,7 +50,10 @@
       </el-col>
       <el-col v-bind="styleResponsive ? { lg: 6, md: 12 } : { span: 6 }">
         <el-form-item label="状态:">
-          <DictSelection dictName="运维计划状态"></DictSelection>
+          <DictSelection
+            dictName="运维计划状态"
+            v-model="where.planStatus"
+          ></DictSelection>
         </el-form-item>
         <div class="ele-form-actions">
           <el-button
@@ -79,7 +82,7 @@
   import equipmentSelect from '@/components/CommomSelect/equipment-select.vue';
   export default {
     components: { equipmentSelect },
-    data () {
+    data() {
       // 默认表单数据
       const defaultWhere = {
         planName: '',
@@ -97,24 +100,28 @@
     },
     computed: {
       // 是否开启响应式布局
-      styleResponsive () {
+      styleResponsive() {
         return this.$store.state.theme.styleResponsive;
       }
     },
-    created () {},
+    created() {},
     methods: {
       /* 搜索 */
-      search () {
+      search() {
         const parmas = this.where;
-        if (parmas.time?.length) {
+        if (parmas.time != null && parmas.time?.length) {
           parmas.startTime = parmas.time[0];
           parmas.endTime = parmas.time[1];
         }
+        if (parmas.time == null) {
+          parmas.startTime = '';
+          parmas.endTime = '';
+        }
         delete parmas.time;
         this.$emit('search', parmas);
       },
       /*  重置 */
-      reset () {
+      reset() {
         this.where = { ...this.defaultWhere };
         this.search();
       }

+ 12 - 12
src/views/maintenance/equipment/plan/details.vue

@@ -110,9 +110,9 @@
                       <span>{{ scope.$index + 1 }}</span>
                     </template>
                   </el-table-column>
-                  <el-table-column label="事项" prop="item" />
+                  <el-table-column label="事项" prop="name" />
                   <el-table-column label="内容" prop="content" />
-                  <el-table-column label="标准" prop="standard" />
+                  <el-table-column label="标准" prop="norm" />
                 </el-table>
               </div>
               <p>备品备件</p>
@@ -184,7 +184,7 @@
         <!-- 保养、执行信息 -->
         <div class="execute_info">
           <HeaderTitle title="执行信息" size="16px"></HeaderTitle>
-          <el-table :data="data.planWorkOrderList">
+          <el-table :data="data.executor">
             <el-table-column label="序号" align="center" width="60">
               <template slot-scope="scope">
                 <span>{{ scope.$index + 1 }}</span>
@@ -304,7 +304,7 @@
   // import { useDictLabel, patrolMatterStatus } from '@/utils/dict/index'
   import { getById } from '@/api/maintenance/patrol_maintenance';
   export default {
-    data () {
+    data() {
       return {
         num: 1,
         infoData: {
@@ -333,18 +333,18 @@
         showtext: false
       };
     },
-    async created () {
+    async created() {
       this.getInfo();
     },
     methods: {
       // getStatus: useDictLabel(patrolMatterStatus),
-      delete () {},
+      delete() {},
       // 点击切换事件
-      tab (index) {
+      tab(index) {
         this.num = index;
       },
       // 表格数据
-      async getInfo () {
+      async getInfo() {
         let res = await getById(this.$route.query.id).catch(() => {
           this.pageLoading = false;
         });
@@ -357,7 +357,7 @@
         this.pageLoading = false;
       },
       //通过按钮事件
-      pass () {
+      pass() {
         let params = {
           id: this.$route.query.id,
           checked: true,
@@ -374,18 +374,18 @@
         });
       },
       //驳回按钮事件
-      reject () {
+      reject() {
         this.showtext = true;
         let bodyscrollHeight = document.body.scrollHeight;
         this.$nextTick(() => {
           document.documentElement.scrollTop = bodyscrollHeight;
         });
       },
-      cancelreject () {
+      cancelreject() {
         this.showtext = false;
         this.cause = '';
       },
-      surereject () {
+      surereject() {
         if (!this.cause) {
           this.$message.info('请填写驳回原因!');
         } else {

+ 10 - 10
src/views/maintenance/equipment/plan/index.vue

@@ -77,14 +77,14 @@
   import DispatchDialog from '@/components/addPatrolPlanDialog/DispatchDialog';
   import AddPatrolPlanDialog from '@/components/addPatrolPlanDialog';
   import PlanSearch from './components/plan-search.vue';
-  import { getPage } from '@/api/maintenance/patrol_maintenance';
+  import { getPage, revocation } from '@/api/maintenance/patrol_maintenance';
   export default {
     components: {
       PlanSearch,
       DispatchDialog,
       AddPatrolPlanDialog
     },
-    data () {
+    data() {
       return {
         // 表格列配置
         columns: [
@@ -134,7 +134,7 @@
             align: 'center',
             showOverflowTooltip: true,
             minWidth: 110,
-            formatter (item) {
+            formatter(item) {
               return { 1: '自动', 0: '手动' }[item.cycleType];
             }
           },
@@ -188,10 +188,10 @@
     computed: {},
     methods: {
       /* 表格数据源 */
-      datasource ({ page, limit, where, order }) {
+      datasource({ page, limit, where, order }) {
         return getPage({ pageNum: page, size: limit, ...where, planType: 2 });
       },
-      async changeEnable (row) {
+      async changeEnable(row) {
         const res = await putRoles(row);
         if (res.code == 0) {
           this.$message({
@@ -203,10 +203,10 @@
         }
       },
       /* 刷新表格 */
-      reload (where) {
+      reload(where) {
         this.$refs.table.reload({ page: 1, where });
       },
-      handleWithdraw (row) {
+      handleWithdraw(row) {
         // 撤回
 
         this.$confirm(`确认撤回计划${row.name}?`, '提示').then(async () => {
@@ -220,14 +220,14 @@
             });
         });
       },
-      openAdd (dialogTitle, row) {
+      openAdd(dialogTitle, row) {
         this.$refs.addPatrolPlanDialogRef.open(dialogTitle, row);
       },
 
-      openDispatch (row) {
+      openDispatch(row) {
         this.$refs.dispatchDialogRef.open(row);
       },
-      goDetail ({ id }) {
+      goDetail({ id }) {
         this.$router.push({
           path: '/maintenance/equipment/plan/details',
           query: {